akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

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

#処理内容
def main():
	H, W = getlist()
	L = []
	for i in range(H):
		l = list(input())
		L.append(l)

	redTable = [["."] * W for i in range(H)]
	blueTable = [["."] * W for i in range(H)]
	for i in range(H):
		redTable[i][0] = "#"
		blueTable[i][-1] = "#"

	for i in range(H):
		if i % 2 == 0:
			for j in range(1, W - 1):
				redTable[i][j] = "#"
		else:
			for j in range(1, W - 1):
				blueTable[i][j] = "#"

	# for i in range(H):
	# 	print(*redTable[i])
	# print()
	# for i in range(H):
	# 	print(*blueTable[i])

	for i in range(H):
		for j in range(1, W - 1):
			if L[i][j] == "#":
				if i % 2 == 0:
					blueTable[i][j] = "#"
				else:
					redTable[i][j] = "#"

	for i in range(H):
		print("".join(redTable[i]))
	print()
	for i in range(H):
		print("".join(blueTable[i]))

if __name__ == '__main__':
	main()

Measured memory_bytes: 56176
#include <numeric>
#include <iostream>
#include <array>
#include<vector>
#include<algorithm>
#include<math.h>
#include <iomanip>
using namespace std;

int main(){
    int N;
    double sum,average;

    cin>>N;

    vector<double> x(N);
    vector<double> y(N);
    vector<int> p(N);
    iota(p.begin(), p.end(), 0); 

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

    do{
        //for(auto x : p) cout << x << " "; cout << "\n";
        for(int i=0; i<N-1; i++){
            sum+=sqrt((x[p[i+1]]-x[p[i]])*(x[p[i+1]]-x[p[i]])+(y[p[i+1]]-y[p[i]])*(y[p[i+1]]-y[p[i]]));
        }
        //cout<<sum<<endl;
    }while(next_permutation(p.begin(), p.end()));



    for(int i=0; i<N; i++){
        sum=sum/(N-i);
        //cout<<N-i<<endl;
    }
    cout << std::fixed;
    cout << std::setprecision(7) <<sum<<endl;

    return 0;
}

Measured memory_bytes: 256
def POW(x, n, mod): #xのn乗をmodで割った際の余りの高速計算
    ans = 1
    while n > 0:
        if n % 2 == 1:
            ans *= x%mod
        x = (x*x)%mod
        n >>= 1						#ビットシフト
    return ans

if __name__ == '__main__':
	N, K = map(int, input().split())
	lst = [0] * (K+1)
	mod = 10 ** 9 + 7

	ans = 0

	for i in range(K):
		k = K - i
		n = K // k
		v = POW(n,N,mod)
		m = 2
		while(m * k <= K):
			v -= lst[m*k]
			if v < 0:
				v += mod
			m += 1
		lst[k] = v
		v = (k * v)%mod
		ans = (ans+v)%mod

	print(int(ans))

Measured memory_bytes: 76696
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
  int h,w,n;
  cin>>h>>w>>n;
  int a[n];
  rep(i,n)cin>>a[i];
  int dt[h][w];
  int cnt=0;
  rep(i,h){
    if(i%2){
      for(int j=w-1;j>=0;j--){
	if(a[cnt]==0)cnt++;
	dt[i][j]=cnt+1;
	a[cnt]--;
      }
    }else{
      for(int j=0;j<w;j++){
	if(a[cnt]==0)cnt++;
	dt[i][j]=cnt+1;
	a[cnt]--;
      }
    }
  }
  rep(i,h){
    rep(j,w){
      if(j==0)cout<<dt[i][j];
      else cout<<" "<<dt[i][j];
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    int ans = n + 1;
    int i = 1;
    while(i * i <= n){
        if( n % i == 0) chmin(ans,i + n / i);
        i ++;
    }
    cout << ans - 2 << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin,(x).end()

int main(){
  string s;
  cin >> s;
 // sort(s.begin(),s.end());
  if(s[0]==s[1]&&s[1]==s[2] || s[1]==s[2]&&s[2]==s[3]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll h, w, k;
  cin >> h >> w >> k;
  vector<string> c(h);
  rep(i, h) cin >> c[i];

  ll ans = 0;

  rep(bit, 1<<h) {
    vector<int> d(h);
    rep(i, h) if (bit & (1 << i)) {
      d[i] = 1;
    }
    rep(bitW, 1<<w) {
      vector<int> dW(w);
      rep(j, w) if (bitW & (1 << j)) {
        dW[j] = 1;
      }

      // rep(i, h) cout << d[i];
      // cout << endl;
      // rep(i, w) cout << dW[i];
      // cout << endl;

      ll cnt = 0;
      rep(m, h) {
        rep(l, w) {
          if (d[m] != 0 || dW[l] != 0) continue;
          if (c[m][l] == '#') cnt++;
        }
      }
      // cout << cnt << endl;


      if (cnt == k) ans++;
    }
    // cout << endl;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int r;
	cin >> r;
	cout << 3 * r * r << '\n';
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int64_t abs(int64_t n) {
  if (n < 0) {
    n = -n;
  }
  return n;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

int main() {
  int n;
  cin >> n;
  int max = 0;
  vector <int> v(n);
  rep(i, n) {
    cin >> v.at(i);
    if (max < v.at(i)) {
      max = v.at(i);
    }
  }
  int tmp = 0, max2 = 0;
  rep(i, n) {
    if (max == v.at(i)) {
      tmp++;
    } else if ((max2 < v.at(i)) && (v.at(i) < max)) {
      max2 = v.at(i);
    }
  }
  if (tmp >= 2) {
    rep(i, n) cout << max << endl;
  } else {
    rep(i, n) {
      if (v.at(i) == max) {
        cout << max2 << endl;
      } else {
        cout << max << endl;
      }
    }
  }
}

Measured memory_bytes: 2432
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;
P temp;

void enqueue(P x){ //push

  Q[tail]=x;
  if(tail==LEN)
    tail=1;
  else
    tail++;

}

P dequeue(){ //pop
  P x;
  x=Q[head];
  
  if(head==LEN)
    head=1;
  else
    head++;

  return x;

}


int main(){
  int elaps = 0, c;
  int i, q,remain,total=0;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  head=1;
  tail=n+1;

  while(head!=tail){
    temp=dequeue();
    remain=temp.t-q;
    if(remain>0) {
      total+=q;
      temp.t=remain;
      enqueue(temp);
    }
    else {
      total+=temp.t;
      printf("%s %d\n",temp.name,total);
    }

  }

  
  
    return 0;
}

Measured memory_bytes: 10756
#include<stdio.h>
int main(){
	int i,x[10001],y[10001];
	
	for(i=1;;i++){
		scanf("%d %d",&x[i],&y[i]);
		if(x[i]==0 && y[i]==0) break;
	}		
	
	for(i=1;;i++){
		if(x[i]==0 && y[i]==0) break;
		if(x[i]<y[i]) printf("%d %d\n",x[i],y[i]);
		else printf("%d %d\n",y[i],x[i]);	
	}

	return 0;
}

Measured memory_bytes: 1740
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int L = scan.nextInt();
        List<String> list = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            list.add(scan.next());
        }
        list.sort(Comparator.naturalOrder());
        StringBuilder sb = new StringBuilder();
        for (String s : list) {
            sb.append(s);
        }
        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 23380
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll INF = 1e18;

ll f(ll n, ll b) {
  ll res = 0;
  while (n) {
    res += n%b;
    n /= b;
  }
  return res;
}

int main() {
  ll n, s;
  cin >> n >> s;
  if (n < s) {
    cout << -1 << endl;
    return 0;
  }
  if (n == s) {
    cout << n+1 << endl;
    return 0;
  }
  for (ll i=2; i*i<=n; i++) {
    if (f(n, i) == s) {
      cout << i << endl;
      return 0;
    }
  }
  /*
  bp+q = n
  p+q = s
  bp-p = n-s
  p(b-1) = n-s
  b = (n-s)/p+1
  (n = bp+q >= bp > p*p)
  */
  ll ans = INF;
  for (ll i=1; i*i<n; i++) {
    if ((n-s)%i == 0) {
      ll b = (n-s)/i+1;
      if (f(n, b) == s)
        ans = b;
    }
  }
  if (ans != INF)
    cout << ans << endl;
  else 
    cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	// your code goes here
	ll n,wm;
	cin>>n>>wm;
	ll w[n],v[n];
	for(ll i=0;i<n;i++)cin>>w[i]>>v[i];
	ll dp[wm+1][n];
	for(ll i=0;i<=wm;i++)
	{
		for(ll j=0;j<n;j++)
		{
			if(i==0)dp[i][j]=0;
			else 
			{
				dp[i][j]=0;
				if(w[j]<=i)dp[i][j]=v[j]+((j>0)?dp[i-w[j]][j-1]:0);
				if(j>0)dp[i][j]=max(dp[i][j],dp[i][j-1]);
			}
		}
	}
	cout<<dp[wm][n-1]<<endl;
	return 0;
}

Measured memory_bytes: 78336
from collections import defaultdict, deque


def read():
    return int(input())


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


def readmap():
    return map(int, input().split())


N, M = readmap()
es = []
for _ in range(N - 1 + M):
    a, b = readmap()
    es.append([a, b])

v = N
n = N - 1 + M
# es = [[int(x) for x in input().split()] for _ in range(n)]

outs = defaultdict(list)
ins = defaultdict(int)
for v1, v2 in es:
    outs[v1].append(v2)
    ins[v2] += 1

q = deque(v1 for v1 in range(v) if ins[v1] == 0)
res = []
while q:
    v1 = q.popleft()
    res.append(v1)
    for v2 in outs[v1]:
        ins[v2] -= 1
        if ins[v2] == 0:
            q.append(v2)

del res[0]
topo = res
inv_topo = [0] * N
for i in range(1, N+1):
    inv_topo[topo[i-1]-1] = i

parent = [0 for _ in range(N+1)]
for edge in es:
    child = edge[1]
    if parent[child] == 0:
        parent[child] = edge[0]
    else:
        if inv_topo[parent[child] - 1] < inv_topo[edge[0] - 1]:
            parent[child] = edge[0]

del parent[0]
for p in parent:
    print(p)



Measured memory_bytes: 50096
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    s=[readline() for i in 1:n]
    march=Dict{Char,Int}('M'=>0,'A'=>0,'R'=>0,'C'=>0,'H'=>0)
    for i in s
        if haskey(march,i[1])
            march[i[1]]+=1
        end
    end
    cnt=collect(values(march))
    ans=0
    for i in 1:5
        for j in i+1:5
            for k in j+1:5
                ans+=cnt[i]*cnt[j]*cnt[k]
            end
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 193000
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 1e18;
const ll fact_table = 800008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
// #define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
 
ll mod = 998244353;
// ll mod = 1000000007;
  
ll mypow(ll number1,ll number2, ll mod){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = mypow(number1,number2 / 2, mod);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
bool multicase = false;

ll n,m,num,sum,a,b,c,d,e,h,q,p;
ll w, ans;
ll k;
ll x[500005], y[500005];
ll dp[1005][1005];
ll table[500005];
char s[500005];

void solve(){
    cin >> a >> b;
    string s = "", t = "";
    for(ll i=0;i<a;i++){
        s += (char)(b + '0');
    }
    for(ll i=0;i<b;i++){
        t += (char)(a + '0');
    }
    p(min(s, t));
    return;
}

int main(){
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q;
    if(multicase){
        cin >> q;
    }else{
        q = 1;
    }
    while(q--){
        solve();
    }
    return 0;

}


















Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define MAXN 200005
#define MOD 998244353
LL ans,f[MAXN];
int fa[MAXN],farest[MAXN];
int n;
struct node
{
    int x,d;
    bool operator <(const node &t)const
    {
        return x<t.x;
    }
}robots[MAXN];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&robots[i].x,&robots[i].d);
    sort(robots+1,robots+n+1);
    robots[0].x=robots[1].x-1;
    robots[0].d=robots[n].x-robots[1].x+1;
    farest[n]=n;
    f[n]=1;
    for(int i=n-1;i>=0;i--)
    {
        f[i]=1;
        farest[i]=i;
        for(int j=i+1;j<=n;j=farest[j]+1)
        {
            if(robots[j].x>=robots[i].x+robots[i].d)
            break;
            fa[j]=i;
            farest[i]=farest[j];
        }
        
    }
    for(int i=n;i>0;i--)
    {
        f[i]++;
        f[fa[i]]=f[fa[i]]*f[i]%MOD;
    }
    cout<<f[0]<<endl;
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int a[100001];
int main()
{
	int N;
	cin >> N;
	for (auto i = 0; i < N; ++i)
	{
		cin >> a[i];
	}
	a[N] = 1000000;

	sort(a, a + (N + 1));
	auto left = 0;
	auto right = 0;
	auto result = 0;
	for (auto i = 0; i <= 100000; ++i)
	{
		for (; a[left] < i - 1; ++left);
		for (; a[right] < i + 2; ++right);
		result = max(result, right - left);
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 640
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


nm = {}
def nCr(n, b):
    if b > n - b:
        b = n - b
    key = (n,b)
    if key in nm:
        return nm[key]
    r = 1
    for k in range(n, n-b, -1):
        r = r * k
    d = 1
    for k in range(1, b+1):
        d = d * k
    nm[key] = r / d
    return nm[key]


def main():
    rr = []

    n,m,l = LI()
    ps = [LI() for _ in range(n)]
    ts = []
    rs = []
    us = []

    for p,t,v in ps:
        if v == 0:
            ts.append(0)
            rs.append(0)
            us.append(0)
            continue
        p /= 100
        u = l / v
        ti = []
        ri = []
        for i in range(m+1):
            ti.append(u+t*i)
            k = pow(1-p, m-i) * pow(p, i) * nCr(m, i)
            ri.append(k)
        ts.append(ti)
        rs.append(ri)
        ui = ri[:]
        for i in range(1,m+1):
            ui[i] += ui[i-1]
        us.append(ui)

    for i in range(n):
        r = 0
        if ts[i] == 0:
            rr.append(r)
            continue
        for j in range(m+1):
            tr = rs[i][j]
            tt = ts[i][j] + 1.0 / 10**10
            for k in range(n):
                if i == k or ts[k] == 0:
                    continue
                bi = bisect.bisect_left(ts[k], tt)
                if bi > 0:
                    tr *= 1 - us[k][bi-1]
            r += tr
        rr.append('{:.9f}'.format(r))

    return '\n'.join(map(str,rr))


print(main())



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

int main(){
    
    int N;cin>>N;
    vector<ll> A(N);
    bool flag=true;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    if(A[0]!=0) flag=false;
    for(int i=1;i<N;i++){
        if(A[i]-A[i-1]>=2) flag=false;
    }
    
    if(flag){
        ll ans=0;
        for(int i=1;i<N-1;i++){
            if(A[i]+1!=A[i+1]) ans+=A[i];
        }
        ans+=A[N-1];
        cout<<ans<<endl;
    }else cout<<-1<<endl;
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>

#define MOD (1000000007)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];


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


// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int A, B;
    cin >> A >> B;    

    cout << A*B << endl;
    return 0;
}



Measured memory_bytes: 3592
#include<iostream>
using namespace std;
 
int main(){
  string now;
  cin>>now;
  if(now=="Sunny"){
    cout << "Cloudy";
  }
  
  if(now == "Cloudy"){
    cout << "Rainy";
  }
  
  if(now == "Rainy"){
  	cout << "Sunny";
  }
	return 0;
}

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>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

int main() {
  //
  int x;
  cin >> x;
  x = 2000 - x + 199;
  cout << x / 200;
}


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

int main() {
  int x, a, b;
  std::cin >> x >> a >> b;
  if (std::abs(x - a) < std::abs(x - b)) {
    std::cout << "A" << std::endl;
  } else {
    std::cout << "B" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
length = int(input())
num_list = defaultdict(int)
target = [int(n) for n in input().split(" ")]

for t in target:
    num_list[t] += 1
if length == 1 and target[0] == 0:
    print(1)
elif length % 2 == 1:
    for k,v in num_list.items():
        if k % 2 != 0 or (k != 0 and v != 2) or (k == 0 and v != 1):
            print(0)
            break
    else:
        print((2**(length//2)) % (10**9 + 7))
else:
    for k,v in num_list.items():
        if k % 2 != 1 or (k != 0 and v != 2) or (k == 0 and v != 1):
            print(0)
            break
    else:
        print((2**(length//2)) % (10**9 + 7))


Measured memory_bytes: 55404
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;

int main(){
    int N,K;
    cin >> N >> K;
    int c[N];
    fill(c,c+N,0);
    for(int i=0;i<N;i++){
        int t;
        cin >> t;
        c[t-1]++;
    }
    int count=0;
    for(int i=0;i<N;i++){
        if(c[i]>0) count++;
        else c[i]=1000000;
    }
    sort(c,c+N);
    int ans=0;
    for(int i=0;i<count-K;i++)
        ans+=c[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

int main(void){
    double a,b,x;
    scanf("%lf%lf%lf",&a,&b,&x);

    double V=a*a*b;

    double h;
    double htan;
    //水の量が容積の半分以上
    if(x>=(V/2)){
        h=2*b-2*x/(a*a);
        htan=h/a;
    }
    else{
        h=2*x/(a*b);
        htan=b/h;
    }

    double ans=atan(htan)*180/(atan(1.0) * 4.0);
    printf("%.7lf\n",ans);

    return 0;
}

Measured memory_bytes: 128
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define f first
#define s second
#define pb push_back
#define pp pop_back
#define mp make_pair
#define ll long long
#define ld long double
#define ull unsigned long long
#define PI pair < int, int > 

const ld Pi = acos(-1);
const ll Inf = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const ld eps = 1e-12;
const int N = 1e5 + 123;

void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
int mult(int a, int b) {
  return 1ll * a * b % mod;
}
int sum(int a, int b) {
  add(a, b);
  return a;
}

int t;
int n, ans[N], cnt[30];
vector < int > g[N];

void dfs(int v = 1, int p = -1) {
  for (auto to : g[v]) {
    if (to != p) {
      dfs(to, v);
    }
  }
  memset(cnt, 0, sizeof cnt);
  for (auto to : g[v]) {
    if (to != p) {
      for (int j = 0;j < 30;j++) cnt[j] += ((ans[to] >> j) & 1);
    }
  }
  int id = -1;
  for (int j = 0;j < 30;j++) {
    if (cnt[j] > 1) {
      id = j;
    }
  }
  int pos = -1;
  for (int j = id + 1;j < 30;j++) {
    if (cnt[j] == 0) {
      pos = j;
      break;
    }
  }
  ans[v] += 1 << pos;
  for (int j = pos + 1;j < 30;j++) {
    if (cnt[j]) ans[v] += 1 << j;
  } 
}
void solve() {
  cin >> n;
  for (int i = 1, u, v;i < n;i++) {
    cin >> u >> v;
    g[u].pb(v);
    g[v].pb(u);
  }
  dfs();
  int id = -1;
  for (int i = 0;i < 30;i++) {
    if ((ans[1] >> i) & 1) {
      id = i;
    }
  }
  cout << id << endl;
}
int main() {
  #ifdef wws
    freopen("in", "r", stdin);
    freopen("out", "w", stdout); 
  #endif 
  ios_base::sync_with_stdio(0);
  t = 1;
  while(t--) solve();
  return 0; 
}

Measured memory_bytes: 11776
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <unordered_map>
#include <map>
#include <math.h>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define SZ(x) ((int)(x).size())
typedef long long ll;

using namespace std;

int main(){
  int N;
  cin >> N;
  int P[N];
  int mismatch = 0;
  rep(i,N)cin >> P[i];
  rep(i,N){
    if(P[i] != i+1) mismatch += 1;
  }
  if(mismatch > 2) cout << "NO" << endl;
  else cout << "YES" << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

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

    if(N < 2) {
        cout << 0 << endl;
        return 0;
    }
    if(N < 4) {
        cout << 1 << endl;
        return 0;
    }

    map<u64, u64> prms;
    u64 p = 2;

    while(N >= p) {
        if(N % p == 0) {
            prms[p] = prms[p] + 1;
            N /= p;
        } else {
            p++;
            if(p*p > N) { // N is prime
                prms[N] = 1;
                break;
            }
        }
    }

    u64 ans = 0;

    for(auto itr=prms.begin(); itr!=prms.end(); itr++) {
        u64 k = 1;
        u64 val = itr->second;
        while(val >= k) {
            val -= k;
            k++;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3608
n,k=map(int,input().split())
h=list(map(int,input().split()))
h+=[0]*k
inf=10**9
dp=[inf]*(n+k)
dp[0]=0
for i in range(n):
    for j in range(1,k+1):
        dp[i+j]=min(dp[i]+abs(h[i]-h[i+j]),dp[i+j])
print(dp[n-1])


Measured memory_bytes: 52448
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>

using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)


const double pai = 3.1415926535897;
const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];


int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}
//x未満の要素数を返す二分探索関数
int b_s(vector<int>& vec, int xx) {
	int t = -1;
	int f = vec.size();
	while (f - t > 1) {
		int m = (t + f) / 2;
		if (vec[m] < xx) {
			t = m;
		}
		else {
			f = m;
		}
	}
	return f;
}
template<typename T>
void vecout(vector<T>& vec) { for (T t : vec) cout << t << " "; cout << endl; }
template<typename TT>
void vecin(vector<TT>& vec) { for (TT t : vec) cin >> t; }


// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
//グループが0個でもいいときはnにxを足す
// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	if (xx == 1) {
		return 0;
	}
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}


signed main() {
	int x, y;
	cin >> x >> y;
	if (2 * x > y || 4 * x < y||y&1) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 3628
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       X: i64,
    }

    let mut ans: usize = 0;

    let mut a = vec![];
    let mut index = vec![];
    for i in -300_i64..300_i64 {
        //mydbg!(i.pow(5));
        a.push(i.pow(5));
        index.push(i);
    }

    mydbg!(a[a.len() - 1]);
    for i in 0..a.len() {
        for j in 0..a.len() {
            if a[i] - a[j] == X {
                echo!(index[i], index[j]);
                return;
            }
        }
    }
}


Measured memory_bytes: 2188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
      
        {            
            var a = int.Parse(Console.ReadLine());
            var b = a / 60;
            var c = b / 60;
            Console.WriteLine("{0}:{1}:{2}",c,b%60,a%60);

         
            
        }
    }
}

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

int main()
{
    int n;
    cin >> n;
    int ans =0;
    map<int, int> m;
    while(n--){
        int t;
        cin >> t;
        m[t]++;
    }
    for(auto c: m){
        if(c.second %2 == 1) ans++; 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4864
n = int(input())
b = list(map(int, input().split()))
a = [None]*n
a[0] = b[0]
ans = a[0]

for i in range(n-2):
    a[i+1] = min(b[i], b[i+1])
    ans += a[i+1]
ans += b[n-2]
print(ans)

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

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

    long r=0, g=0, b=0;
    for (int i = 0; i < n; i++){
        if(s[i] == 'R') ++r;
        if(s[i] == 'G') ++g;
        if(s[i] == 'B') ++b;
    }
    long c = r*g*b;
    for (int i = 0; i < n-2; i++)
    {
        for (int j = 1; i+2*j < n; j++)
        {
            if(s[i] != s[i+j] 
                && s[i] != s[i+j+j] 
                && s[i+j] != s[i+j+j])
            {
                c--;
            }
        }
    }
    cout << c << endl;
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


Measured memory_bytes: 3644
n=int(input())
h=list(map(int,input().split()))
k=0
k1=0
if n==2:
    print(abs(h[1]-h[0]))
else:
    k=(abs(h[1]-h[0]))
    k1=abs(h[2]-h[0])
    for i in range(3,n):
        k3=k1
        k1=min(k+abs(h[i]-h[i-2]),k1+abs(h[i]-h[i-1]))
        k=k3
    print(k1)

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

int main() {
  int N;
  cin >> N;
  
  vector<int64_t> data(N+1);
  data.at(0)= 2;
  data.at(1)= 1;
  for (int i=2; i<=N; i++) {
    data.at(i)= data.at(i-1)+ data.at(i-2);
  }
  
  cout << data.at(N) << endl;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    c = input()
    w = c.count("W")
    ans = 0
    r = n - w
    for i in range(n):
        target = "R" if i < r else "W"
        if c[i] != target:
            ans += 1
    print(min(ans // 2, w, r) if 0 < w < n else 0)


if __name__ == '__main__':
    main()



Measured memory_bytes: 9480
n = int(input())
a = list(map(int, input().split()))
cnt = [0] * 3
num = 0
ans = 1

for i in range(n):
	if cnt.count(a[i])  == 0:
		ans = 0
		break
	else:
		ans = (ans * cnt.count(a[i])) % 1000000007
		cnt[cnt.index(a[i])] += 1
	num = 0

print(ans)

Measured memory_bytes: 14020
n = int(input())
a = list(map(int, input().split()))

def judge(x, y):
  if x > y:
    return(x-y)
  else:
    return(0)
ans = 0
for i in range(n - 1):
  xy = judge(a[i], a[i+1])
  a[i+1] += xy
  ans += xy
  
print(ans)

Measured memory_bytes: 32172
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

        int c = b*2-a;

			System.out.println(c);

		}

	}

Measured memory_bytes: 21844
#include <stdio.h>
int main(){
int h,w,i,o;
while(1){
    scanf("%d %d",&h,&w);
        if(!(h==0 && w==0)){
for(i=1;i<=h;i++){
    for(o=1;o<=w;o++){
        printf("#");
            }
            printf("\n");

}
printf("\n");}
else break;

}
return 0;









}



Measured memory_bytes: 2064
#include<cstdio>
#define MAXN (int)20010
#define _rep(i,a,b) for(int i = (a); i <= (b); ++i)
int N;
int a[MAXN],b[MAXN];
int p[MAXN];
int main(){
	scanf("%d",&N);
	_rep(i,1,N)scanf("%d",&p[i]),a[i] = i * N,b[i] = (N - i + 1) * N;
	_rep(i,1,N)b[p[i]] += (i - 1);
	_rep(i,1,N - 1)printf("%d ",a[i]);printf("%d\n",a[N]);
	_rep(i,1,N - 1)printf("%d ",b[i]);printf("%d\n",b[N]);
	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<map>
#include<cmath>
#include<cstring>
#define For(i,j,k)	for(int i=j;i<=k;++i)
#define Dow(i,j,k)	for(int i=k;i>=j;--i)
#define ll  long long
using namespace std;
inline ll read()
{
	ll t=0,f=1;char c=getchar();
	while(c<'0'||c>'9')	{c=getchar();}
	while(c>='0'&&c<='9')	t=t*10+c-48,c=getchar();
	return t*f;
}
char s[200001];
int l=20000001,r=0,len;
int main()
{
	scanf("%s",s);
	len=strlen(s);
	if(len%2==0)
	For(i,len/2,len-1)
	{
		if(s[i]!=s[len-i-1]||s[i]!=s[i-1])
		{
			cout<<i<<endl;
			return 0;
		}
	} 
	else
		For(i,len/2+1,len-1)
	{
		if(s[i]!=s[len-i-1]||s[i]!=s[i-1])
		{
			cout<<i<<endl;
			return 0;
		}
	} 
	cout<<len<<endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int k = sc.nextInt();

		if (e-a > k) {
			System.out.print(":(");
		} else {
			System.out.print("Yay!");
		}
	}
}


Measured memory_bytes: 21844
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
ll imos[31][100005];
int main(){
    int n,ch;
    cin>>n>>ch;
  for(int i=0;i<n;i++){
      int a,b,c;
      cin>>a>>b>>c;
      imos[c-1][a-1]++;
      imos[c-1][b]--;
  }
  for(int i=0;i<ch;i++){
       for(int j=0;j<100001;j++)imos[i][j+1]+=imos[i][j];
  }
   for(int i=0;i<100001;i++){
       for(int j=0;j<ch;j++)imos[j+1][i]+=min((ll)j+1,imos[j][i]);
  }
ll ans=0;
 for(int i=0;i<100001;i++){
     chmax(ans,imos[ch][i]);
 }
 cout<<ans<<endl;
}


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

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

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

const int MAX = 1e5 + 10;
int N;
int a[MAX], b[MAX];
map<PII, int> rev_idx;
VI G[MAX];
int color[MAX];

void dfs(const int cur, const int par, const int par_color) {
    if (par != -1) {
        color[rev_idx[MP(min(cur, par), max(cur, par))]] = par_color;
    }

    int nxt_color = 1;
    FORE(nxt, G[cur]) if (nxt != par) {
        while (nxt_color == par_color) nxt_color++;
        dfs(nxt, cur, nxt_color++);
    }
}

int main(void) {
    scanf("%d", &N);
    REP(i, N - 1) {
        scanf("%d %d", a + i, b + i);
        a[i]--; b[i]--;
        rev_idx[MP(min(a[i], b[i]), max(a[i], b[i]))] = i;
        G[a[i]].EB(b[i]);
        G[b[i]].EB(a[i]);
    }

    REP(i, N) if (G[i].size() == 1) {
        dfs(i, -1, 0);
        break;
    }

    int ma = 0;
    REP(i, N - 1) {
        chmax(ma, color[i]);
    }
    printf("%d\n", ma);
    REP(i, N - 1) {
        printf("%d\n", color[i]);
    }
}


Measured memory_bytes: 15232
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int h,w;
char f[25][25];
const int INF = 1000000;
int d[25][25];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
typedef pair<int ,int> P;

int dfs(int sx,int sy,int gx,int gy)
{
    queue<P> q;
    
    if (f[sx][sy] == '#' || f[gx][gy] == '#'){
        return -1;
    }
    
    for (int i = 1;i <= h;i++){
        for (int j = 1;j <= w;j++){
            d[i][j] = INF;
        }
    }
    
    q.push(P(sx,sy));
    d[sx][sy] = 0;
    
    while (q.size()){
        P p = q.front();
        q.pop();
        if (p.first == gx && p.second == gy){
            break;
        }
        for (int i = 0;i < 4;i++){
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            
            if (1 <= nx && nx <= h && 1 <= ny && ny <= w && d[nx][ny] == INF && f[nx][ny] != '#'){
                q.push(P(nx,ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
    return d[gx][gy];
}

int main()
{
    cin >> h >> w;
    for (int i = 1;i <= h;i++){
        for (int j = 1;j <= w;j++){
            cin >> f[i][j];
        }
    }
    
    int ans = 0;
    
    for (int i = 1;i <= h;i++){
        for (int j = 1;j <= w;j++){
            for (int k = 1;k <= h;k++){
                for (int l = 1;l <= w;l++){
                    ans = max(ans,dfs(i,j,k,l));
                }
            }
        }
    }
    cout << ans << endl;
}


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

using namespace std;

int main(void) {

  long long N;
  cin >> N;
  vector<long long> A(N);
  for (long long i = 0; i<N; i++) {
      cin >> A.at(i);
  }

  long long count = 0;
  for (long long i = 1; i<N; i++) {
      if (A.at(i - 1) > A.at(i)) {
          count += A.at(i - 1) - A.at(i);
          A.at(i) = A.at(i - 1);
      }
  }

    cout << count << endl;
}


Measured memory_bytes: 4840
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdint>

using namespace std;
int main()
{
  int64_t a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
  if(a>b)
  {
    swap(a,b);
  }
  auto dis=b-a;
  auto able=(v-w)*t;
  if(able>=dis)
  {
    cout<<"YES"<<endl;
  }
  else
  {
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define bitcount(x)  __builtin_popcount(x)
#define bitcountll(x)  __builtin_popcountll(x)
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 500003  //check the limits, man
int main()
{
    int a,b,k,g,i;
    in2(a,b);
    g=gcd(a,b);
    in(k);
    i=g;
    while(k>0)
    {
        if(g%i==0)
            k--;
        i--;
    }
    out(i+1);
}


Measured memory_bytes: 256