akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
	"os"
)

func main() {
	var n int
	var p float64
	var pList [2][]float64
	prev := 0
	current := 1
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	fmt.Fscan(fp, &n)
	pList[prev] = make([]float64, n+1)
	pList[prev][0] = 1.0
	pList[current] = make([]float64, n+1)
	for j := 1; j <= n; j++ {
		fmt.Fscan(fp, &p)
		for i := 0; i <= n; i++ {
			if i == 0 {
				pList[current][i] = pList[prev][i] * (1 - p)
				continue
			}
			pList[current][i] = pList[prev][i-1]*p + pList[prev][i]*(1-p)
		}
		prev, current = current, prev
	}

	sum := 0.0
	for i := n; i > n/2; i-- {
		sum += pList[prev][i]
	}

	fmt.Println(sum)

}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define first first
#define second se
using namespace std;
typedef pair<int, int> P;
typedef vector<int> vi;

signed main(){
    int n;
    cin >> n;
    int l = 1;
    vector<int> a(n);
    rep(i, 0, n){
        cin >> a[i];
    }
    rep(i, 1, n){
        if(a[i] != a[i % l]){
            l = i + 1;
        }
    }
    if(n % l) cout << 1 << endl;
    else cout << n / l << endl;
}

Measured memory_bytes: 4392
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include <functional>

using namespace std;
typedef long long ll;

ll X, Y, Z, K;
ll A[1001] = {};
ll B[1001] = {};
ll C[1001] = {};
ll sum[3001] = {};

int main() {
	cin >> X >> Y >> Z >> K;
	for (int i = 1; i <= X; i++)cin >> A[i];
	stable_sort(A, A + X + 1, greater<ll>());
	for (int i = 1; i <= Y; i++)cin >> B[i];
	stable_sort(B, B + Y + 1, greater<ll>());
	for (int i = 1; i <= Z; i++)cin >> C[i];
	stable_sort(C, C + Z + 1, greater<ll>());
	for (int i = 0; i < X; i++) {
		if (sum[K - 1] != 0 && A[i] + B[0] + C[0] < sum[K - 1])break;
		for (int j = 0; j < Y; j++) {
			if (sum[K - 1] != 0 && A[i] + B[j] + C[0] < sum[K - 1])break;
			for (int l = 0; l < Z; l++) {
				if (A[i] + B[j] + C[l] > sum[K - 1]) {
					sum[K - 1] = A[i] + B[j] + C[l];
					stable_sort(sum, sum + K, greater<ll>());
				}
				else {
					break;
				}
			}
		}
	}
	for (int i = 0; i < K; i++)cout << sum[i] << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<ii> vii;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fr(be, en) for(int i = be; i <= en; i++) 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n; cin >> n;
	string s;
	map<string, int> hm;
	map<string, int> :: iterator it;
	while(n--)
	{
		cin >> s;
		it = hm.find(s);
		if(it == hm.end()) hm.insert({s, 1});
		else it->se++;
	}
	map<int, vs> m2;
	map<int, vs> :: iterator it1;
	int maxo = 1;
	for(it = hm.begin(); it != hm.end(); it++)
	{
		it1 = m2.find(it->se);
		maxo = max(maxo, it->se);
		if(it1 == m2.end()) m2.insert({it->se, {it->fi}});
		else it1->se.pb(it->fi);
	}
	it1 = m2.find(maxo);
	for(int i = 0; i < it1->se.size(); i++) cout << it1->se[i] << "\n";
}

Measured memory_bytes: 25584
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int k = *max_element(all(a));
	vector<int> cnt(k+1);
	for(int i = 0; i < n; i++){
		cnt[a[i]]++;
	}

	bool flag = true;
	if(k%2==0){
		for(int i = 1; i <= k; i++){
			if(i<k/2 && cnt[i]>0) flag = false;
			if(i>k/2 && cnt[i]<2) flag = false;
			if(i==k/2 && cnt[i]!=1) flag = false;
		}
	}else{
		k++;
		for(int i = 1; i <k; i++){
			if(i<k/2 && cnt[i]>0) flag = false;
			if(i>k/2 && cnt[i]<2) flag = false;
			if(i==k/2 && cnt[i]!=2) flag = false;
		}
	}
	
	cout << (flag?"Possible":"Impossible") << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    int n;
    cin >> n;
    if(n < 1200)P("ABC");
    else if(n < 2800)P("ARC");
    else P("AGC");
    
    return  0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
constexpr int MAX_N=100000;

int n,k;
int a[MAX_N];
long long int sum=0;
long long int res=0;

int main(){
    while(1){
        std::cin>>n>>k;
        if(n+k==0)
            break;
        res=0;
        sum=0;

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

        for(int i=0;i<k;++i)
            sum+=a[i];

        res=sum;

        int s=0,t=k;

        while(t<=n){
            sum-=a[s];
            sum+=a[t];
            ++s;
            ++t;
            res=std::max(res,sum);
        }
        std::cout<<res<<std::endl;
    }
    return 0;
}

Measured memory_bytes: 3404
use std::io;

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

const SPLIT_DELIMITER: char = ' ';
#[allow(dead_code)]
fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

const MODNUM: usize = 1_000_000_007;

fn permutation(mut n: usize, r: usize) -> usize {
    let mut ans = 1;
    if n < r {
        ans = 0;
    }
    for _ in 0..r {
        ans *= n;
        ans = ans % MODNUM;
        n -= 1;
    }
    ans
}

fn dfs(v: &Vec<Vec<usize>>, visit: &mut Vec<bool>, depth: usize, n: usize, k: usize) -> usize {
    visit[n] = true;

    let mut pnum = 2;
    if depth == 0 {
        pnum = 1;
    }

    let mut ans = 1;

    for z in &v[n] {
        if !visit[*z] {
            ans *= dfs(v, visit, depth + 1, *z, k);
            ans = ans % MODNUM;
        }
    }
    let cnum;
    if n == 0 {
        cnum = v[n].len();
    } else {
        cnum = v[n].len() - 1;
    }
    permutation(k - pnum, cnum) * ans % MODNUM
}

fn main() {
    let (n, k): (usize, usize);
    input!(n, k);

    let mut v = vec![Vec::new(); n];
    let mut visit = vec![false; n];

    for _ in 0..n - 1 {
        let (a, b): (usize, usize);
        input!(a, b);
        v[a - 1].push(b - 1);
        v[b - 1].push(a - 1);
    }
    p(dfs(&v, &mut visit, 0, 0, k) * k % MODNUM);
}

Measured memory_bytes: 17532
const Main = (input: string): void => {
	const [a, b] = input.split(" ")
	const numA = parseInt(a)
	const numB = parseInt(b)
	const diff = numB - numA
	let sum = 0;
	for (let i = 1; i <= diff; i++) {
		sum += i
	}
	console.log(sum - numB)
}

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

Measured memory_bytes: 7372
import math

while True:
    D, E = map(int, input().split())
    if D == 0 and E == 0:
        break
    ans = float("inf")
    for x in range(D + 1):
        for y in range(D + 1):
            if x + y == D:
                # print("x: {}, y: {}, sqrt: {}".format(x, y, math.sqrt(x * x + y * y)))
                ans = min(abs(math.sqrt(x * x + y * y) - E), ans)

    print(ans)



Measured memory_bytes: 5676
#include<stdio.h>
int min(int a, int b);
int max(int a, int b);
int K, S, ans, i, l;
int main(){
	scanf("%d%d", &K, &S);
	for(i=max(S-K, 0), l=min(K<<1, S); i<=l; i++){
		ans+=min((K<<1)-i+1, i+1);
	}
	printf("%d\n", ans);
}

int min(int a, int b){
	return a>b?b:a;
}
int max(int a, int b){
	return a<b?b:a;
}


Measured memory_bytes: 128
use std::io;

fn main() {
    let mut temp = String::new();
    let mut line = String::new();
    io::stdin().read_line(&mut temp).expect("aaaaaaaaaaaaa");
    io::stdin().read_line(&mut line).expect("aaaaaaaaaaaaa");

    let mut list: Vec<i32> = line.split_whitespace()
                    .map(|s| s.parse().expect("bbbbbbbbbb"))
                    .collect();

    let mut count: i32 = 0;
    loop {
        let mut temp_list: Vec<i32> = Vec::new();

        for value in list.iter() {
            if value % 2 == 1 {
                println!("{}", count);
                return;
            }

            temp_list.push(value / 2);
        }

        list = temp_list;
        count += 1;
    }
}


Measured memory_bytes: 2136
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <map>
// #include <bits/stdc++.h>
using namespace std;

int main()
{
  int N;
  cin >> N;
  int L[N];
  int max = 0;
  for (int i = 0; i < N; i++) {
    cin >> L[i];
    if (L[i] > max) max = L[i];
  }

  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += L[i];
  }

  cout << (sum > max * 2 ? "Yes" : "No") << endl;

  return 0;
}

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

int digit_sum(int x){
  int ret = 0;
  while(x > 0){
    ret += x%10;
    x /= 10;
  }
  return ret;
}

template<typename T>
T power(T x, long long k){
  T ret{1};
  while(k > 0){
    if(k&1) ret *= x;
    x *= x;
    k /= 2;
  }
  return ret;
}

int main(){
  int a, n, m;
  cin >> a >> n >> m;
  int ans = 0;
  for(long long i = 1; i < m; ++i){
    long long x = power<long long>(i,n);
    if(x > m) break;
    if(i == a+digit_sum(x)){
      ++ans;
      //cerr << i << endl;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3100
#include<iostream>
#include<cstdio>
#define _USE_MATH_DEFINES
#include<math.h>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<map>
#include<unordered_map>
#include<set>
#include <algorithm>
#include <utility>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::pair;
using std::make_pair;
using std::priority_queue;

typedef unsigned long long ull;
typedef long long ll;

#define Prime1 1000000007
#define Prime2 9999973

#define INF 0x7fffffffffffffff

int i, j, k, l, m, n;
ull H, W, Q;
ull a, b, c, x, y;
ull K,L,N,M,S,D;

struct Vertex {
	ull v;
	ull d;
	Vertex() {}
	Vertex(const ull& v_, const ull& d_) { v = v_; d = d_; }
	const bool operator<(const Vertex& right) const {
		return d > right.d;
	}
}; 
priority_queue<Vertex> que;

int main()
{
	cin >> N;
	vector<ull> D(N,INF);
	vector<vector<pair<ull, ull>>> edge(N);

	for (i = 0; i < N - 1; ++i) {
		cin >> a >> b >> c;
		edge[a-1].push_back(make_pair(b-1, c));
		edge[b-1].push_back(make_pair(a-1, c));
	}
	cin >> Q >> K;
	K--;
	D[K] = 0;

	que.push(Vertex(K, 0));
	while (!que.empty())
	{
		Vertex v = que.top();
		que.pop();
		for (auto itr = edge[v.v].begin(); itr != edge[v.v].end(); ++itr)
		{
			if (D[itr->first] == INF)
			{
				D[itr->first] = D[v.v] + itr->second;
				que.push(Vertex(itr->first, D[itr->first]));
			}
		}
	}

	while(Q--)
	{
		cin >> x >> y;
		cout << D[x-1] + D[y-1] << '\n';
	}
	return 0;
}


Measured memory_bytes: 11120
class Array
  def gcd; inject(:gcd) end
  def diff; (size-1).times.map { |i| self[i + 1] - self[i] } end
end

n, s = gets.split.map(&:to_i)
x    = gets.split.map(&:to_i)

p x.push(s).sort.diff.gcd

Measured memory_bytes: 10864
a, b, c, k = [int(i) for i in input().split()]
r = 0
if k <= a:
    r += k
    k = 0
else:
    r += a
    k -= a
if k <= b:
    k = 0
else:
    k -= b
if k != 0:
    r -= k
print(r)

Measured memory_bytes: 9064
#include<bits/stdc++.h>
using namespace std;
bool dp[5003][5003];
int ans,x[5003],n,ned,l,r;
int main(){
	cin>>n>>ned;
	for(int i=1;i<=n;i++)
		cin>>x[i];
	sort(x+1,1+x+n);
	r=n+1;
	while(l!=r)
	{
		int i=(l+r)/2;
		for(int j=0;j<=n;j++)
			for(int k=0;k<ned;k++)
				dp[j][k]=0;
		dp[0][0]=1;
		//for(int j=0;j<n;j++)dp[j][0]=1;
		//if(i&&x[0]<ned)dp[1][x[0]]=1;
		//cout<<x[0];
		for(int j=1;j<=n;j++)
			if(i!=j)
				for(int k=0;k<ned;k++)
					dp[j][k]|=(dp[j-1][k]|(k>=x[j]&&dp[j-1][k-x[j]]));
			else
				for(int k=0;k<ned;k++)
					dp[j][k]=(dp[j-1][k]|dp[j][k]);
		/*for(int j=1;j<=n;j++)
		{
			for(int k=0;k<ned;k++)
				cout<<dp[j][k];
			cout<<endl;
		}*/
		bool f=1;
		for(int j=1;j<=min(x[i],ned);j++)
			if(dp[n][ned-j])
			{
				r=i;
				f=0;
				break;
			}
		if(f){
			//if(l==i)break;
			l=i+1;
		}
	}
	cout<<r-1;
} 

Measured memory_bytes: 24704
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n = 0;
  cin >> n;
  string s;
  int flag = 0;
  for(int i = 0; i < n; i++){
    cin >> s;
    if(s == "Y"){
      flag = 1;
      break;
    }
  }
  if(!flag){
    cout << "Three";
  }else{
    cout << "Four";
  }
}
    
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define INF 1000000000000000000
typedef long long ll;
vector<ll>uni(100010,-1);
int root(ll a){
    if(uni[a]<0)return a;
    return uni[a]=root(uni[a]);
}
bool connect(ll a,ll b){
    a=root(a);
    b=root(b);
    if(a==b)return false;
    if(uni[a]>uni[b])swap(a,b);
    uni[a]+=uni[b];
    uni[b]=a;
    return true;
}
int main(){
    ll n,m;cin>>n>>m;vector<ll>A;
    ll x=n*(n-1)/2;A.push_back(x);
    vector<vector<ll>>v(m,vector<ll>(2));
    rep(i,m)cin>>v[i][0]>>v[i][1];
    rep(i,m-1){
        ll y=uni[root(v[m-1-i][0])]*uni[root(v[m-1-i][1])];
        if(connect(v[m-1-i][0],v[m-1-i][1]))x-=y;
        A.push_back(x);
    }
    reverse(A.begin(),A.end());
    rep(i,m)cout<<A[i]<<endl;
}

Measured memory_bytes: 8436
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main{
	static int[]dp=new int[100001];
	static ArrayList<ArrayList<Integer>>al=new ArrayList<ArrayList<Integer>>();
	static int solve(int src){
		if(dp[src]!=0)
			return dp[src];

		boolean leaf=true;
		int bestChild=0;
		for(int child:al.get(src)){
			leaf=false;
			bestChild=Math.max(bestChild,solve(child));
		}
		return dp[src]= leaf?0:1+bestChild;
	}
	public static void main(String[] args)throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String s=br.readLine();
		String[]s1=s.split(" ");
		int n=Integer.parseInt(s1[0]);
		int m=Integer.parseInt(s1[1]);
		for (int i = 0; i <=n; i++) 
            al.add(new ArrayList<Integer>());
		for(int i=0;i<m;i++){
			String d=br.readLine();
			String[]s2=d.split(" ");
			int x=Integer.parseInt(s2[0]);
			int y=Integer.parseInt(s2[1]);
			al.get(x).add(y);
		}
		int ans=0;
		for(int i=1;i<=n;i++){
			ans=Math.max(ans,solve(i));
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 64256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
using namespace std;

int n;
string s;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> s;
    for( auto l:s ) cout << (char)((l-'A'+n)%26+'A');

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Node> L = new ArrayList<>();
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                int w = sc.nextInt();
                if(i<j&&w!=-1){
                    Node N = new Node();
                    N.element(w,i,j);
                    L.add(N);
                }
            }
        }
        Collections.sort(L, new Comparator<Node>() {
            @Override
            public int compare(Node o1, Node o2) {
                return o1.w<o2.w?-1:1;
            }
        });
        ArrayList<Set<Integer>> T = new ArrayList<>();
        int opt = 0;
        while(L.size()!=0){
            Node e = L.remove(0);
            int t1=-1,t2=-1;
            for(int i=0;i<T.size();i++){
                if(T.get(i).contains(e.v1)) t1 = i;
                if(T.get(i).contains(e.v2)) t2 = i;
            }
            if(t1==-1&&t2==-1){
                Set<Integer> t = new HashSet<>();
                t.add(e.v1);
                t.add(e.v2);
                T.add(t);
                opt+=e.w;
            }
            else if(t1!=t2){
                opt+=e.w;
                if(t1==-1) T.get(t2).add(e.v1);
                else if(t2==-1)T.get(t1).add(e.v2);
                else{
                    T.get(t1).addAll(T.get(t2));
                    T.remove(t2);
                }
            }
        }
        System.out.println(opt);
    }
    public static class Node{
        int w,v1,v2;
        public void element(int w,int v1,int v2){
            this.w = w;
            this.v1 = v1;
            this.v2 = v2;
        }
    }
}


Measured memory_bytes: 41500
import math

def C(m,n):
    return math.factorial(m)//math.factorial(n)//math.factorial(m-n)

N,K = map(int,input().split())
for i in range(1,K+1):
    if N-K+1>=i:
        print(int(C(K-1,i-1)*C(N-K+1,i))%(10**9+7))
    else:
        print(0)


Measured memory_bytes: 3316
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int main(){
    int n;cin >> n;
    string s;
    ll v=1;
    if(n==0){
        cout << "0" << endl;
        return 0;
    }
    while(n){
        if(n%(2*abs(v))){
            s+='1';
            n-=v;
        }else{
            s+='0';
        }
        v*=-2;
    }
    reverse(s.begin(),s.end());
    cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;
 
template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
 
const double PI = acos(-1.0);
const int INF = 1e9 + 47;
const LL LINF = 1LL * INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	LL x, k, d;
	cin >> x >> k >> d;
	//cout << k * d << endl;
	if((1.0 * k * d < 1e18) && abs(x) >= k * d)
	{
		cout << (abs(x) - k * d) << endl;
		return 0;
	}
	LL ost1 = x % d;
	LL ost2;
	if(ost1 > 0)
		ost2 = ost1 - d;
	else
		ost2 = ost1 + d;
	LL ans = d;
	LL len1 = abs(ost1 - x) / d;
	LL len2 = abs(ost2 - x) / d;
	if(k % 2 == len1 % 2)
		setmin(ans, abs(ost1));
	if(k % 2 == len2 % 2)
		setmin(ans, abs(ost2));
	cout << ans << endl;
	
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}
 


Measured memory_bytes: 3808
# -*- coding: utf-8 -*-
from sys import stdin, stdout


def read():
    x = stdin.readline().rstrip()
    return x


def __main__():

    q = int(read())

    a = q // 500
    b = q - a*500
    c = b // 5

    print(a*1000 + c*5)

__main__()

Measured memory_bytes: 38256
n = gets.to_i
tn, an = gets.split.map(&:to_i)
(n - 1).times do
  t, a = gets.split.map(&:to_i)
  tr, ar = tn % t, an % a
  tnn = tn + (tr == 0 ? 0 : t - tr)
  ann = an + (ar == 0 ? 0 : a - ar)
  if (x = tnn / t * a) >= an
    tn, an = tnn, x
  else
    tn, an = ann / a * t, ann
  end
end
puts tn + an

Measured memory_bytes: 1788
def resolve():
    h1, m1, h2, m2, k = map(int, input().split())
    h = h2 - h1
    if h < 0:
        h += 24
    m = m2 - m1
    if m < 0:
        m += 60
        h -= 1

    print(h * 60 + m - k)

resolve()

Measured memory_bytes: 9108
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
    
int main()
{
	double a, b, h;
	int C;
	cin >> a >> b >> C ;
	h = b * sin(M_PI * C / 180);
	cout << fixed << setprecision(4)
		 << a * h / 2 << ' '
		 << a + b + sqrt( pow(h,2) + pow(a - b * cos(M_PI * C / 180),2)) << ' '
		 << h
		 << endl;
	return 0;
}

Measured memory_bytes: 3464
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

int main(void){
    ll x;
    cin>>x;
    ll ans;
    ans = x / 11;
    ans *= 2;
    if(x%11<=6 && x%11>0) ans++;
    else if(x%11>6) ans+=2;
    cout << ans << endl;
}


Measured memory_bytes: 256
s=input()
n=len(s)
s+='0'
ans=[0]*n
cnt=0
for i in range(n+1):
  if (s[i]=='R')and(s[i+1]=='R'):
    cnt+=1
  elif (s[i]=='R')and(s[i+1]=='L'):
    cnt+=1
    if cnt%2!=0:
      ans[i]+=cnt//2+1
      ans[i+1]+=cnt//2
    else:
      ans[i]+=cnt//2
      ans[i+1]+=cnt//2
    cnt=0
cnt=0
s=s[:n][::-1]+'0'
ans=ans[::-1]
for i in range(n+1):
  if (s[i]=='L')and(s[i+1]=='L'):
    cnt+=1
  elif (s[i]=='L')and(s[i+1]=='R'):
    cnt+=1
    if cnt%2!=0:
      ans[i]+=cnt//2+1
      ans[i+1]+=cnt//2
    else:
      ans[i]+=cnt//2
      ans[i+1]+=cnt//2
    cnt=0
print(' '.join(list(map(str,ans[::-1]))))

Measured memory_bytes: 11880
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    set<string>s;
    for(int i=0;i<n;i++)
    {
        string c;
        cin>>c;
        s.insert(c);
    }
    cout<<s.size()<<"\n";
    }


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<char>> str(N, vector<char>(M));
  vector<int> x(N), y(M);
  for (int i = 0; i < N; i++){
    for (int j =0; j < M; j++){
      cin >> str.at(i).at(j);
      if (str.at(i).at(j) == '#'){
        x.at(i) = 1;
        y.at(j) = 1;
      }
    }
  }
  for (int i = 0; i < N; i++){
    if(x.at(i) == 0) continue;
    for (int j =0; j < M; j++){
      if (y.at(j) == 0) continue;
      cout << str.at(i).at(j);
    }
    cout << endl;
  }
}

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

const int N = 109;

int n, a[N]={};

int main(){
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]); a[i] *= -1;
    }

    sort(a,a+n);
    int ans = 0;
    for(int i = 0; i < n; i++)
        if(i % 2 == 0) ans -= a[i];
        else ans += a[i];

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
int mod =1000000007;
const double PI = acos(-1);
int main(){
    int a,b,c;cin>>a>>b>>c;
    int ans=a/b*c;
    if(a%b)ans+=c; 
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(void){
  int N,M,X,Y,i,max_x,min_y,tmp;
  scanf("%d %d %d %d",&N,&M,&X,&Y);
  for(i=0;i<N;i++){
    scanf("%d",&tmp);
    if(i==0)max_x=tmp;
    else{
      if(max_x <= tmp)max_x=tmp;
    }
  }
  for(i=0;i<M;i++){
    scanf("%d",&tmp);
    if(i==0)min_y=tmp;
    else{
      if(min_y >= tmp)min_y=tmp;
    }
  }
  for(i=X+1;i<=Y;i++){
     if(max_x < i && min_y >= i){
      	 printf("No War");
         break;
     }
  }
  if(i==Y+1){
   	printf("War");
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>

using namespace std;

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

    string t;
    stack<bool> st;

    for (auto x : s) {
        if (x == 'S') st.push(true);
        else if (st.size()) st.pop();
        else t += x;
    }

    cout << t.length() + st.size() << endl;

    return 0;
}


Measured memory_bytes: 644
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>       // for next_permutation
#include <vector>
#include <cstdlib>
#define INF 998244353

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pi;

const ll MOD = 1e9+7;

static long gcd(long a, long b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}
/*
long long int facctorialMethod(int k){//階乗
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}*/

long long int tousasum(long long int n){//等差数列
    return n*(n+1)/2;
}

unsigned GetDigit(unsigned num){//桁数
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

bool IsPrime(int num)//素数判定
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

map< ll, ll > prime_factor(ll n) {//素因数分解
    map< ll, ll > ret;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

ll calcNumOfCombination(ll n, ll r){
    ll num = 1;
    for(ll i = 1; i <= r; i++){
        num = num * (n - i + 1) / i;
    }
    return num;
}

int bubblesort(vector<int> array,int size){//バブルソート　転倒数
    int kaisu = 0;
    for(int i = 0; i < size; i++){
        for(int j = i + 1; j < size; j++){
            if(array[i] > array[j]){
                int number = array[i];
                array[i] = array[j];
                array[j] = number;
                kaisu++;
            }
        }
    }
    return kaisu;
}

ll facctorialMethod(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum = (sum * i)%MOD;
    }
    return sum;
}

// nPnの順列に対して処理を実行する
void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}



int main() {
    int N;
    cin >> N;
    for(int a=0;a<=N;a+=100){
        for(int b=0;a+b<=N;b+=101){
            for(int c=0;a+b+c<=N;c+=102){
                for(int d=0;a+b+c+d<=N;d+=103){
                    for(int e=0;a+b+c+d+e<=N;e+=104){
                        for(int f=0;a+b+c+d+e+f<=N;f+=105){
                            if(a+b+c+d+e+f==N){
                                cout << 1 << endl;
                                return 0;
                            }

                        }

                    }

                }

            }

        }

    }
    cout << 0 << endl;




}










Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int a,b,c;
	cin >>a>>b>>c;
	if( b-a == c-b ){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let s: String = sc.read();
    println!("{}", &s[0..3]);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 2128
import sys
import bisect

n = int(input())
a = [int(sys.stdin.readline().rstrip()) for _ in range(n)][::-1]

bottoms = [a[0]]

for i in range(1, n):
    pos = bisect.bisect_right(bottoms, a[i])
    if pos == len(bottoms):
        bottoms.append(a[i])
    else:
        bottoms[pos] = a[i]

print(len(bottoms))

Measured memory_bytes: 50780
#include <iostream>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

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

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

    int B[N];
    long ans = 0;
    for(int i=0; i<N; i++){
        if(i-A[i]<0){
            cout << -1 << endl;
            return 0;
        }
        B[i] = i - A[i];
    }

    for(int i=1; i<N; i++){
        if(B[i]<B[i-1]) {
            cout << -1 << endl;
            return 0;
        }
        if(B[i-1]<B[i])ans += (i-1) - B[i-1];
    }
    ans += (N-1)-B[N-1];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

typedef long long ll;
typedef long double ld;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(5, 0);
    rep(i, 5) cin >> A[i];
    sort(A.begin(), A.end());
    ll ans = 5;
    if(N % A[0] == 0){
        ans += N / A[0] - 1;
    }
    else{
        ans += N / A[0];
    }
    cout << ans << endl;
}

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

m=[0]*3
for i in list:
    if i%4==0:
        m[0]+=1
    elif i%2==0:
        m[1]+=1
    else:
        m[2]+=1

if(m[0]+1>=m[2]+m[1]%2):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14252
import java.util.Scanner;

public class Main{
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

     while(true){
        int H = sc.nextInt();
        int W = sc.nextInt();
        if(H==0 && W==0){
            break;
        }
        for(int x=0; x<W; x++){
            System.out.print('#');
        }
        System.out.println();
        for(int y=1; y<H-1; y++){
            System.out.print('#');
            for(int x=1; x<W-1; x++){
                System.out.print('.');
            }
            System.out.print('#');
            System.out.println();
        }
        for(int x=0; x<W; x++){
            System.out.print('#');
        }
        System.out.println();
        System.out.println();

     }
    }
}



Measured memory_bytes: 37748
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>

using namespace std;

const int MAX_N = 2000000;

int main()
{
	int n,A[MAX_N] = {0},B[MAX_N] = {0},C[10000] ={0},max;

	scanf("%d", &n);

	max = 0;

	for(int i = 0; i < n; i++)
	{
		scanf("%d", &A[i]);
		if (max < A[i])
		{
			max = A[i];
		}
	}

	

	for(int i = 0; i < n; i++)
	{
		C[A[i]]++;
	}

	for(int i = 1; i <= max; i++)
	{
		C[i] += C[i-1];
	}
	
	for(int i = n-1; i >= 0; i--)
	{
		B[C[A[i]]] = A[i];
		C[A[i]]--;
	}


	for(int i = 1; i <= n; i++)
	{
		if (i == n)
		{
			printf("%d\n", B[i]);
		}else
		{
			printf("%d ", B[i]);
		}
	}

	return 0;
}
	

Measured memory_bytes: 18884
#include <iostream>
using namespace std;
int main (){
    int a,b,c,t;
    cin >>a>>b>>c;
    if (a>c){
        t=a;
        a=b;
        b=t;
    }
    if (b>c){
        t=b;
        b=c;
        c=t;
    }
    if (a>b){
        t=a;
        a=b;
        b=t;
    }
    
    cout << a << " " << b << " " << c << endl;
    return 0;
}


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

int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  
  if ( S.at(K-1) == 'A' ) {
    S.at(K-1) = 'a';
  }
  else if ( S.at(K-1) == 'B' ) {
     S.at(K-1) = 'b';
  }
  else {
     S.at(K-1) = 'c';
  }
  
  cout << S << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }



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

  ll x;
  cin >> x;

  cout << 360 / gcd(360, x) << endl;
  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll,ll>;
using pi = pair<int,int>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;

class SegmentTree{//Range Maximum Queery
	private:
		ll len;
		vl seg;
	public:
		SegmentTree(ll n){
			len = n;
			seg.resize(2*n , 0);
		}

		void add(ll ind , ll x){
			ind += len;
			seg[ind] += x;
			while(true){
				ind /= 2;
				if(ind == 0)break;
				seg[ind] = max(seg[2*ind] , seg[2*ind+1]);
			}
		}

		void update(ll ind , ll x){
			ind += len;
			seg[ind] = x;
			while(true){
				ind /= 2;
				if(ind == 0)break;
				seg[ind] = max(seg[2*ind] , seg[2*ind+1]);
			}
		}

		ll get_max(ll l , ll r){
			ll ans = 0;
			l += len; r += len;
			while(l < r){
				if(l % 2 == 1){
					chmax(ans , seg[l]);
					l++;
				}
				l /= 2;
				if(r % 2 == 1){
					chmax(ans , seg[r-1]);
					--r;
				}
				r /= 2;
			}
			return ans;
		}
};


signed main(){
	//cout << fixed << setprecision(10);
    ll n,k; cin >> n >> k;
	vl a(n);
	SegmentTree seg(300001);
	rep(i,0,n){
		ll x; cin >> x;
		a[i] = x;
	}
	rep(i,0,n){
		ll l = max((ll)0 , a[i] - k);
		ll r = min((ll)300001 , a[i] + k);
		seg.update(a[i] , seg.get_max(l , r+1) + 1);
	}
	cout << seg.get_max(0 , 300001) << endl;
	

	return 0;
}

Measured memory_bytes: 10380
#include<iostream>
using namespace std;
 
int main(){
int x , y;
 
while(1){
cin >> x >> y;
if ( x == 0 && y == 0 ) break;
 
if ( x < y ){
cout << x << " " << y << endl;
} else {
cout << y << " " << x  << endl;
}
}
 
return 0;
}
 

Measured memory_bytes: 1160
/*
g++ --std=c++17 E.cpp
*/

#include <iostream>
#include <iomanip> //! for setprecision(20)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < int(n); ++i)
template<class T> inline bool chmax(T& a, T b) { bool ret = (a < b); if (ret) { a = b; } return ret; }
template<class T> inline bool chmin(T& a, T b) { bool ret = (b < a); if (ret) { a = b; } return ret; }
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int INF = 1000000000;
const int MOD = 1000000007;

LL n;
int x, m;
LL a[100000];
LL sum[100000];

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

  cin >> n >> x >> m;
  map<int, int> occ; //! number => first occurance

  int begin = 0;
  int end = 0;
  a[1] = x;
  sum[0] = 0;
  sum[1] = x;
  occ[x] = 1;
  for (int i = 2; begin == 0 && i < m+10; ++i) {
    a[i] = (a[i-1] * a[i-1]) % m;
    sum[i] = sum[i-1] + a[i];
    if (occ[a[i]]) {
      begin = occ[a[i]];
      end = i;
    } else {
      occ[a[i]] = i;
    }
  }

  LL ans = sum[begin-1];
  int len = end - begin;
  LL repCount = (n-begin+1) / len;
  ans += repCount * (sum[end-1] - sum[begin-1]);
  int restCount = (n-begin+1) % len;
  ans += sum[begin+restCount-1] - sum[begin-1];
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6736
n=int(input())
X=list(map(int,input().split()))
Y=list(map(int,input().split()))
for p in range(1,4):
	print("{0:.6f}".format(sum([abs(a-b)**p for a,b in zip(X,Y)])**(1/p)))
print("{0:.6f}".format(max([abs(a-b) for a,b in zip(X,Y)])))


Measured memory_bytes: 5652
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    string s;
    cin >> s;
    int N = (int)s.size();
    //コーナーケースの除去（すべて'W' or 'B'の場合）
    bool is = true;
    rep(i, N-1){
        if(s[i] != s[i+1]){
            is = false;
            break;
        }
    }
    if(is){
        cout << 0 << endl;
        return 0;
    }
    int cnt = 0; //挟まれている状態の黒の集合の個数
    rep(i, N){
        if(s[i] == 'B' && s[i-1] == 'W'){
            while(i < N && s[i] == 'B') i++;
            if(i != N) cnt++;
        }
    }
    cnt *= 2;
    if(s[0] == 'B') cnt++;
    if(s[N-1] == 'B') cnt++;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N,M;
    cin>>N>>M;
    vi A(N),B(N);
    rep(i,N) {
        cin>>A[i]>>B[i];
    }
    vector<pii> v(N);
    rep(i,N) {
        v[i]=make_pair(A[i],B[i]);
    }
    sort(all(v));
    ll answer=0;
    rep(i,N) {
        int counter=min(M,v[i].se);
        answer+=(ll)counter*v[i].fi;
        M-=counter;
    }
    printf("%ld\n",answer);
}

Measured memory_bytes: 1792
using namespace std;

#include <iostream>

#define MAXN 200005

long long sz[MAXN];
int root[MAXN];

void init() {
	for(int i = 0;i < MAXN;++i) {
		sz[i] = 1;
		root[i] = i;
	}
	return;
}

int fr(int a) {
	int cur = a;
	if(root[cur] != cur) {
		root[cur] = fr(root[cur]);
	}
	return root[cur];
}

void merge(int a,int b) {
	if(sz[a] > sz[b]) swap(a,b);
	if(fr(a) == fr(b)) return;
	sz[fr(b)] += sz[fr(a)];
	root[fr(a)] = fr(b);
	return;
}

int main() {
	init();
	int N,M;
	cin >> N >> M;
	for(int i = 0;i < M;++i) {
		int a,b;
		cin >> a >> b;
		merge(a,b);
	}
	long long ans = 0;
	for(int i = 0;i < MAXN;++i) {
		// cout << sz[i] << endl;
		ans = max(ans,sz[i]);
	}
	cout << ans << endl;
	return 0;
}

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

#define ll long long
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)


void func(long long N, long long M, std::vector<long long> s, std::vector<long long> c){
    int num[3];
    rep(i,3) num[i]=-1;
    rep(i,M) s[i]--; // sを0始まりにする
    rep(i,M) {
        int si = s[i];
        int ci = c[i];

        if (num[si] != -1) {
            if (num[si] != ci) {
                cout << -1 << endl; // 入力内容が矛盾している場合
                return;
            }
        }
        num[si] = ci;
    }

    rep(i,3){
        if (num[i] == -1) {
            if(i==0 && N!=1) {
                num[i] = 1;
            } else {
                num[i] = 0;
            }
        }
    }

    if(N!=1 && num[0] == 0) {
        cout << -1 << endl;
        return;
    }
    

    int ans = 0;
    rep(i, N) ans += num[i] * pow(10,N-1-i);

    cout << ans << endl;
}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> s(M);
    std::vector<long long> c(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&s[i]);
        scanf("%lld",&c[i]);
    }
    func(N, M, std::move(s), std::move(c));
    return 0;
}


Measured memory_bytes: 256
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
struct Node {
    int key;
    struct Node *prev;
    struct Node *next;
};
   
struct Node *note;
   
void insert(int key) {
    struct Node *x = (struct Node *)malloc(sizeof(struct Node));
    x->key = key;
    note->next->prev = x;
    x->next = note->next;
    note->next = x;
    x->prev = note;
}
   
struct Node* search(int key) {
    struct Node *x = note->next;
    while(x != note && x->key != key ) {
        x = x-> next;
    }
    return x;
}
   
void deleteNode(struct Node *t) {
    if (t == note) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
}
 void deleteKey(int key) {
    deleteNode(search(key));
}  
void deleteFirst() {
    deleteNode(note->next);
}
   
void deleteLast() {
    deleteNode(note->prev);
}
   
void print() {
    struct Node *x;
    x = note->next;
    int i = 0;
    while(1) {
        if (x == note) break;
        if(i++ > 0) printf(" ");
        printf("%d", x->key);
        x = x->next;
    }
    printf("\n");
}
   
   
int main(void) {
    int key, n;
    char order[20];
    scanf("%d", &n);
    note = (struct Node *)malloc(sizeof(struct Node));
    note->next = note;
    note->prev = note;
    for (int i = 0; i < n; i++) {
        scanf("%s%d",order, &key);
        if(order[0] == 'i') {
            insert(key);
        }else if(order[0] == 'd') {
            if(strlen(order) > 6) {
                if( strlen(order) > 10) {
                    deleteFirst();
                }else if( strlen(order) > 9) {
                    deleteLast();
                }
            }else {
                deleteKey(key);
            }
        }
    }
    print();
    return 0;
}

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

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<int, int> pi;

#define N 400020
int cnt[N], pre[N];

int main()
{
    double n;
    cin >> n;
    n /= 3;
    cout << fixed << setprecision(7) << n*n*n << "\n";


    return 0;
}


Measured memory_bytes: 256