akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
int N, C;
int s[100000], t[100000], c[100000];
int sm[200002];
int tt[200002];
int main() {
  scanf("%d%d", &N, &C);
  for (int i = 0; i < N; i++)
    scanf("%d%d%d ", &s[i], &t[i], &c[i]);
  for (int i = 1; i <= C; i++) {
    for (int j = 0; j < 200002; j++)
      tt[j] = 0;
    for (int j = 0; j < N; j++)
      if (c[j] == i)
        tt[s[j] * 2 - 1]++, tt[t[j] * 2]--;
    for (int j = 1; j < 200002; j++)
      tt[j] += tt[j - 1];
    for (int j = 0; j < 200002; j++)
      if (tt[j] > 0)
        sm[j]++;
  }
  int mx = 0;
  for (int j = 0; j < 200002; j++)
    if (mx < sm[j])
      mx = sm[j];
  printf("%d\n ", mx);
}


Measured memory_bytes: 4432
#include <stack>
#include <string>
#include <iostream>
#include <utility>
using namespace std;
int main(void){
    string c;
    cin >> c;
    int length = c.length();
    int depth[length+10];
    for(int i = 0;i < length + 10; i++)
        depth[i] = 0;
    
    stack<pair<int,int> > S;
    for(int i = 0;i<length;i++){
        if(c[i] == '\\'){
            S.push(make_pair(0,i));
        }
        
        else if(c[i] == '_'){
            S.push(make_pair(1,i));
        }
        else if(c[i] == '/'){
            while(!S.empty() && S.top().first != 0 ){
                S.pop();
            }
            if(!S.empty()){
				for(int j=S.top().second;j < i;j++){
					depth[j+1]++;
				}
				S.pop();
            }
        }
    }
    float amounts[length+10] = {};
    float sum = 0.0;
    int cnt = 0;
    int start = 0;
    for(int i = start;i < length+1;i++){
        if(depth[i] == 0 && amounts[cnt] >= 1.0){
			cnt++;
		}
		amounts[cnt] += (depth[i] + depth[i+1])*0.50;
		sum += (depth[i] + depth[i+1])*0.50;
		
    }
    
    cout << (int)sum << endl;
    cout << cnt;
    if(cnt>0)
        cout << ' ';
    else cout << endl;
    for(int i = 0;i < cnt-1;i++){
        cout << amounts[i] << ' ';
    }
    if(cnt > 0)
        cout << (int)amounts[cnt-1] << endl;
    return 0;
}

Measured memory_bytes: 3464
#include <stdio.h>

// int getMiddle(int a);
int main(int argc, char const *argv[])
{
	int i, j, n, s;
	// データセットの数
	scanf("%d", &n);
	for (i = 1; i <= n; ++i) {
		scanf("%d", &s);
		if (s > 1 && s < 10000) {
			printf("Case %d:\n", i);
			for (j = 0; j < 10; j++) {
				s = s * s;
				s = s / 100;
				s = s % 10000;
				printf("%d\n", s);

			}
		}
	}
	return 0;
}

/*
// 中央の数値を返す
int getMiddle(int a) {
	a = a / 100;
	a = a % 10000;
	return a;
}
*/

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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> tree(n);
	for (int i = 0; i < n; i++) {
		cin >> tree[i];
	}
	sort(tree.begin(),tree.end());
	int ans = tree[n-1];
	for (int i = k-1; i < n; i++) {
		if (tree[i]-tree[i-k+1]<ans) {
			ans = tree[i]-tree[i-k+1];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
s=list(input())
a=int(input())

w = ""
c = 0
cnt = 0
for i in s:
    if w != i:
        #print(w)
        cnt += c//2
        c = 1
        w = i
    else:
        c +=1
cnt += c//2
#print(cnt)

start = 0
start_w = s[0]
for i in s:
    if start_w != i:
        break
    else:
        start +=1

s.reverse()

end = 0
end_w = s[0]
for i in s:
    if end_w != i:
        break
    else:
        end +=1

same = len(list(set(s)))
#print(same)

if s[0] != s[-1]:
    print(cnt*a)
elif same ==1:
    print(len(s)*a//2)
else:
    print(cnt*a-(a-1)*(start//2+end//2-(start+end)//2))

Measured memory_bytes: 3064
#[allow(dead_code)]
fn rd() -> String {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    input.trim().to_owned()
}

/// 1行の文字を空白で分割してVec<T>にする。
#[allow(dead_code)]
fn rd_vec<T : std::str::FromStr>() -> Vec<T> {
    rd().split_whitespace().map(|x| x.parse().ok().unwrap()).collect()
}

/// 1つの要素を入力で受け取る
#[allow(dead_code)]
fn rd_one<T : std::str::FromStr>() -> T {
    rd().parse().ok().unwrap()
}

/// 複数回read_splitを行う
#[allow(dead_code)]
fn rd_vec_mul<T : std::str::FromStr>(count : i32) -> Vec<Vec<T>> {
    (0..count).map(|_| rd_vec()).collect()
}

/// Vecを1列で出力する
#[allow(dead_code)]
fn op_vec<T : std::fmt::Display>(item : Vec<T>, splitter : char) {
    let cnt = item.len();
    let mut c = 0;
    for i in item.iter() {
        c+=1;
        if cnt > c {print!("{}{}", i, splitter);} else {println!("{}", i);}
    }
}

fn main() {
    let input = rd();
    println!("{}", match &*input {
        "Sunny" => "Cloudy",
        "Rainy" => "Sunny",
        "Cloudy" => "Rainy",
        _ => ""
    });
}

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

int main() {
  string str1;
  bool flag = true;
  cin >> str1;
  
  for(int i=0; i < str1.size() && flag == true; i++){
    if(i%2 == 0){
      if(str1.at(i) == 'R' || str1.at(i) == 'U' || str1.at(i) == 'D'){}else{flag = false;}
    } else {
      if(str1.at(i) == 'L' || str1.at(i) == 'U' || str1.at(i) == 'D'){}else{flag = false;}
    }
  }
  cout << (flag ? "Yes":"No") << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <cmath>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define ins insert
#define iter ::iterator
#define upb upper_bound
#define lwb lower_bound

#define sz(v) v.size()
#define aloc(i, a, n) i *a = new i[n]

#define for0(i,a) for(ll i = 0; i < a; i++)
#define fori(i,a,b) for(ll i = a; i < b; ++i)
#define rfor0(i,a) for(ll i = a; i >= 0; --i)
#define rfor(i,a,b) for(ll i = a; i >= b; --i)


//##############################################################################

int arr[3];

int main(){
  int a, b;
  cin >> a >> b;
  arr[0] = a + b;
  arr[1] = a * b;
  arr[2] = a - b;

  cout << *max_element(arr + 0, arr + 3) << endl;
  return 0;
}


Measured memory_bytes: 256
@n, @a, @b, @c = gets.chomp.split(" ").map(&:to_i)

@l = []
@n.times do
  @l << gets.chomp.to_i
end
INF = 10**9

def dfs(cur, a, b, c)
  if cur == @n
    if [a, b, c].min > 0
      return (a - @a).abs + (b - @b).abs + (c - @c).abs - 30
    else
      return INF
    end
  end
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + @l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a , b + @l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + @l[cur]) + 10
  return [ret0, ret1, ret2, ret3].min
end

puts dfs(0, 0, 0, 0)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int r;
  cin >> r;
  cout << r*r << endl;
}


Measured memory_bytes: 256
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-23 16:46:45
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    LL n, m;
    cin >> n >> m;

    LL ans = 0;
    if (abs(n-m) <= 1) {
        ans = 1;
        
        for (LL i = 2; i <= n; i++) {
            ans *= i;
            ans %= MOD;
        }
        for (LL i = 2; i <= m; i++) {
            ans *= i;
            ans %= MOD;
        }

        if (n == m) {
            ans *= 2;
            ans %= MOD;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()

def chk_substr(s, t):
    p = -1
    for i in t:
        p = s.find(i, p + 1)
        if p == -1:
            return False
    return True

ans = 0
for i in range(1000):
    t = str(i).zfill(3)
    if chk_substr(s, t):
        ans += 1
print(ans)

Measured memory_bytes: 3188
#include <iostream>

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

    long long int sum = 0;
    for (int i = 1; i <= n; ++i)
    {
        if (!(i % 5 == 0 || i % 3 == 0))
            sum += i;
    }

    std::cout << sum;
}


Measured memory_bytes: 3632
def find(x):
    if x == par[x]:
        return x
    par[x] = find(par[x])
    return par[x]
 
def union(x,y):
    x,y = find(x),find(y)
    if x == y:
        return
    par[y] = x
 
n,m = map(int,input().split())
par = {i:i for i in range(1,n+1)}
for _ in range(m):
    a,b,c = map(int,input().split())
    union(a,b)
print(sum([1 for i in range(1,n+1) if par[i] == i]))

Measured memory_bytes: 15084
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(false)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 1e8;
const LL     INFF =0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a,LL b){LL s=1;while(b>0){if(b&1)s=s*a%mod;a=a*a%mod;b>>=1;}return s;}
LL gcd(LL a,LL b) {return b?gcd(b,a%b):a;}
int dr[2][4] = {1,-1,0,0,0,0,-1,1};
typedef pair<int,int> P;
const int maxn = 1e5+100;
vector<P> edge[maxn];
bool inq[maxn];
//int  color[maxn];
int dis[maxn];
set<int> color[maxn];
int N,M;
void init(){
    for(int i = 1;i <= N; ++i) edge[i].clear(),color[i].clear();
    int u,v,w;
    while(M--){
        scanf("%d%d%d",&u,&v,&w);
        edge[u].Pb(P(v,w));
        edge[v].Pb(P(u,w));
    }
}
int solve(){
    me(inq);
    me(color);
    fill(dis+1,dis+N+1,INF);
    dis[1] = 0;
    queue<int> q;
    q.push(1);
    while(!q.empty()){
        int  u = q.front(); q.pop();
        inq[u] = false;
//        cout<<u<<endl; 
        for(int i = 0;i < edge[u].size(); ++i){
            P &e = edge[u][i];
            int t = 0;
            if(color[u].find(e.SE) == color[u].end()) t++;
//            cout<<t<<endl;
            if(dis[u] + t <= dis[e.FI]){
                if(dis[u] +t  < dis[e.FI]) color[e.FI].clear();
                if(color[e.FI].find(e.SE) != color[e.FI].end()) continue;
                color[e.FI].insert(e.SE);
                dis[e.FI] = dis[u]+t;
                if(!inq[e.FI]){
                     q.push(e.FI);
                     inq[e.FI] = true;
                }
            }   
        }
    }
    if(dis[N] < INF) return dis[N];
    else return -1;
}
int main(void)
{
   while(cin>>N>>M){
       init();
       cout<<solve()<<endl;
   }


   return 0;
}


Measured memory_bytes: 23412
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

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


    vector<int> ans(N, 0);
    vector<vector<int> > E(N+1);
    E[1].push_back(2);
    for(int n=2; n<N; n++) {
        E[n].push_back(n-1);
        E[n].push_back(n+1);
        if(n==X) {
            E[n].push_back(Y);
        } else if(n==Y) {
            E[n].push_back(X);
        }
    }
    E[N].push_back(N-1);

    if(X==1) {
        E[1].push_back(Y);
    }
    if(Y==N) {
        E[N].push_back(X);
    }

    // for(int n=1; n<=N; n++) {
    //     cout << n << ": " ;
    //     for(int i=0; i<E[n].size(); i++) {
    //         cout << E[n][i] << " ";
    //     }
    //     cout << endl;
    // }
    
    for(int n=1; n<=N; n++) {
        queue<int> que;
        que.push(n);
        vector<int> dist(N+1, -1);
        dist[n]=0;
        
        while(!que.empty()) {
            int cur=que.front();que.pop();
            
            for(int i=0; i<E[cur].size(); i++) {
                if(dist[E[cur][i]]!=-1) continue;
                dist[E[cur][i]] = dist[cur]+1;
                ans[dist[E[cur][i]]]++;
                
                que.push(E[cur][i]);
            }
        }
    }

    for(int n=1; n<=N-1; n++) {
        cout << ans[n]/2 << endl;
    }

    return 0;
    
}

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

const int nmax = 8;
vector<vector<bool>> routemap(nmax, vector<bool>(nmax, false));

int dfs(int n, int place, vector<bool>& visit)
{
  int i;
  bool allvisit = true;
  for(i = 1; i < n; i++)
  {
    if(visit.at(i) == false)
    {
      allvisit = false;
    }
  }
  if(allvisit == true) return 1;
  int result = 0;
  for(i = 1; i < n; i++)
  {
    if(visit.at(i) == false && routemap.at(place).at(i) == true)
    {
      visit.at(i) = true;
      result += dfs(n, i, visit);
      visit.at(i) = false;
    }
  }
  return result;
}

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  vector<int> b(m);
  int i, j;
  vector<bool> visit(n, false);
  for(i = 0; i < m; i++)
  {
    cin >> a.at(i);
    cin >> b.at(i);
  }
  for(i = 0; i < m; i++)
  {
    routemap.at(a.at(i)-1).at(b.at(i)-1) = true;
    routemap.at(b.at(i)-1).at(a.at(i)-1) = true;
  }
  cout << dfs(n, 0, visit) << endl;
} 

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
alice = []
bob = []
a.sort()
a = a[::-1]
for i in range(n):
    if len(alice) > len(bob):
        bob.append(a[i])
    else:
        alice.append(a[i])
print(sum(alice) - sum(bob))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
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; }
ll MOD = 1000000007;

void solve()
{	
	int n; cin >> n;
	int a = 0, b = 0;
	rep(i, n)
	{
		string s, t;
		cin >> s >> t;
		if(s < t)b += 3;
		else if(s > t)a += 3;
		else {a++;b++;}
	}
	cout << a <<" "<< b << endl;
	return;
}

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



Measured memory_bytes: 3224
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
using namespace std;

int main() {
    int A,B,Q; cin >> A >> B >> Q;
    vector<long long> va, vb;

    for (int i=0; i<A; i++) {
        long long s; cin >> s;
        va.push_back(s);
    }
    for (int i=0; i<B; i++) {
        long long t; cin >> t;
        vb.push_back(t);
    }
    for (int i=0; i<Q; i++) {
        long long x; cin >> x;
        int ia = upper_bound(va.begin(), va.end(), x) - va.begin();
        int ib = upper_bound(vb.begin(), vb.end(), x) - vb.begin();

        // printf("ia = %d, ib = %d\n", ia, ib);
        long long ans = LLONG_MAX;

        // 左のみに移動
        if (ia > 0 && ib > 0) {
            ans = min(ans, abs(x - min(va[ia-1], vb[ib-1])));
        }
        // 右のみに移動
        if (ia < A && ib < B) {
            ans = min(ans, abs(max(va[ia], vb[ib]) - x));
        }
        // 左に移動してから右に移動(神社 -> 寺)
        if (ia > 0 && ib < B) {
            ans = min(ans, 2*abs(x - va[ia-1]) + abs(vb[ib] - x));
        }
        // 左に移動してから右に移動(寺 -> 神社)
        if (ib > 0 && ia < A) {
            ans = min(ans, 2*abs(x - vb[ib-1]) + abs(va[ia] - x));
        }
        // 右に移動してから左に移動(神社 -> 寺)
        if (ia < A && ib > 0) {
            ans = min(ans, 2*abs(va[ia] - x) + abs(x - vb[ib-1]));
        }
        // 右に移動してから左に移動(寺 -> 神社)
        if (ib < B && ia > 0) {
            ans = min(ans, 2*abs(vb[ib] - x) + abs(x - va[ia-1]));
        }

        cout << ans << endl;
    }

    return 0;
}

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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

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

typedef pair<int, int> pint;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front

#define MOD (1000 * 1000 * 1000 + 7)

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

    vector<int> d(N);
    REP(i, N) {
        cin >> d[i];
    }

    int ans = 0;

    REP(i, N) {
        REP(j, i) {
            ans += d[i] * d[j];
        }
    }


    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/// Thank you tanakh!!!
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(n: usize, x: [f64; n], m: usize, k: usize, a: [usize1; m]);
    let mut swap: Vec<Vec<usize>> = vec![(0..(n - 1)).map(|i| i).collect()];
    let mut s = swap[0].clone();
    for &a in a.iter() {
        s.swap(a - 1, a);
    }
    swap.push(s);
    for i in 1..64 {
        let mut next = vec![0; n - 1];
        {
            let ref prev = &swap[i];
            for i in 0..(n - 1) {
                next[i] = prev[prev[i]];
            }
        }
        swap.push(next);
    }

    let mut operations: Vec<usize> = (0..(n - 1)).map(|i| i).collect();
    for i in 0..64 {
        if (1 << i) & k != 0 {
            let mut next = operations.clone();
            for j in 0..(n - 1) {
                next[j] = operations[swap[i + 1][j]];
            }
            operations = next;
        }
    }

    let num = operations
        .iter()
        .map(|&i| x[i + 1] - x[i])
        .collect::<Vec<_>>();
    let mut ans = vec![0.0; n];
    ans[0] = x[0];
    for i in 1..n {
        ans[i] = ans[i - 1] + num[i - 1];
    }
    for &ans in ans.iter() {
        println!("{}", ans);
    }
}


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

int main() {
	int w,h,x,y,r; cin >> w>>h>>x>>y>>r;
	if((x-r>=0)&&(x+r<=w)&&(y-r>=0)&&(y+r<=h)){cout << "Yes\n";}else{cout << "No\n";}
	return 0;
}

Measured memory_bytes: 3068
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();
        int plus = a + b;
        int minus = a - b;
        int multiple = a * b;

        System.out.println(Math.max(plus,Math.max(minus,multiple)));
    }
}

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


/*
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <ctype.h>
*/
typedef struct  llnode
{
	int x;
	struct llnode *next;
}
slnode;


using namespace std;

typedef pair<int , int > pii;
typedef pair<long , long> pll;
typedef pair<pii , int > piii;
typedef pair<pll , long > plll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector <pii> vii;
typedef vector<pll> vll;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef unsigned long long int ulli;
typedef long long int lli;
typedef double d;
typedef float f;
typedef string s;
typedef char ch;
typedef pair<int,ll> pill;

#define loop(n) for(int i = 0; i < (n); i++)
#define lp(x , s , e) for(int x = (s); x < (e); x++)
#define lpe(x , s , e) for(int x = (s); x <= (e); x++)
#define readline(s) getline(cin,s)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;
#define MP make_pair
#define PB push_back
#define all(a) a.begin(),a.end()
#define clr(x , val) memset((x) , (val) , sizeof(x))
#define endl '\n'

ll power(ll a, ll b)
{
    ll res = 1;
    for(int i = 0; i<b; i++)
       res *= a;

    return res;
}
int findSingle(int ar[], int ar_size)
    {
        int res = ar[0];
        for (int i = 1; i < ar_size; i++)
            res = res ^ ar[i];
        return res;
    }
const int con = 2e5;
int freq[con + 9];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll n;
    cin >> n;
    ll sum = n *(n + 1) / 2;
    ll three=3;
    while(three<= n)
    {
    	sum -= three;
    	three += 3;
    }
    ll five = 5;
    while(five <= n)
    {
    	if (five % 3 != 0)
    	{
    		sum -= five;
    	}
    	five += 5;
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type& a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	vi a(n);
	vi b(n-1);
	REP(i,n-1) cin>>b[i];
	
	a[0]=b[0];
	for(int i=1;i<n-1;++i){
		a[i]=min(b[i-1],b[i]);
	}
	a[n-1]=b[n-2];
	
	llong ans=0;
	REP(i,n) ans+=a[i];
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

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

        int N;
        int M;
        priority_queue<int> que;
        priority_queue<int> que_edge;
        int sum = 0;
        int cnt0;
        int tmp;

        cin >> N >> M;

        if(M <= N) {
                cout << 0;
                return 0;
        }

        for(int cnt0 = 0; cnt0 < M; cnt0++){
                cin >> tmp;
                que.push(tmp);
        }

        tmp = que.top();
        que.pop();
        int tmp1;
        do {
                tmp1 = que.top();
                que.pop();
                que_edge.push(tmp - tmp1);
                tmp = tmp1;
        }while(que.size());

        for(cnt0 = 0; cnt0 < N-1; cnt0++){
                que_edge.pop();
        }


        while(que_edge.size()){
                sum += que_edge.top();
                que_edge.pop();
        }
        cout << sum;
        return 0;
}

Measured memory_bytes: 1400
from sys import stdin, setrecursionlimit


def find(arr, n):
    arr_2 = sorted(arr)
    for i in range(len(arr_2)):
        if arr_2[i] == n:
            return i


def main():
    input = stdin.buffer.readline
    n = int(input())
    p = list(map(int, input().split()))
    q = list(map(int, input().split()))

    f = [1] * n
    for i in range(n - 1):
        f[i + 1] = f[i] * (i + 2)

    ans_p = 0
    ans_q = 0
    tmp_p = p
    tmp_q = q
    for i in range(n):
        p_i = find(tmp_p, tmp_p[0])
        tmp_p = tmp_p[1:]
        ans_p += p_i * f[len(tmp_p) - 1]
        q_i = find(tmp_q, tmp_q[0])
        tmp_q = tmp_q[1:]
        ans_q += q_i * f[len(tmp_q) - 1]
    print(abs(ans_q - ans_p))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 38384
#include<cstdio>
#include<cstring>

const int maxn=1e5+5;

int ha[maxn][3];

int dp[maxn][3];

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

int main(){
	
	int n; scanf("%d",&n);

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

 	memset(dp,0,sizeof(dp)); int ans=0;	

	for(int i=0;i<3;i++) { dp[1][i]=ha[1][i]; ans=max(ans,dp[1][i]); }

	for(int i=2;i<=n;i++){
		
		for(int j=0;j<3;j++){
	
			for(int k=0;k<3;k++){
	
				if(j==k) continue;

				dp[i][j]=max(dp[i][j],dp[i-1][k]+ha[i][j]);	

				if(i==n) ans=max(ans,dp[i][j]);	
			}
		}
	}

	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N;
int A[112345];

int main() {
	cin >> N;
	REP(i, N) scanf("%d", A + i);
	
	bool ok = true;
	ll l = 2, r = 3;
	for(int i = N - 1; i >= 0; i--) {
		l = (l + A[i] - 1) / A[i] * A[i];
		r = (r + A[i] - 1) / A[i] * A[i];
		
		if (l == r) {
			puts("-1");
			return 0;
		}
	}
	
	printf("%lld %lld\n", l, r - 1);
	
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
int main() {
	vector<int> n;
	while (true){
		int a = 0, ya = 0, b = 0;
		cin >> a;
		if (a == 0) {
			break;
		}
		for (int i = 0; i < a / 4; ++i) {
			cin >> b;
			ya += b;
		}
		n.push_back(ya);
		ya=0;
	}
	for (int i = 0; i < n.size(); ++i) {
		cout << n[i] << endl;
	}
	return 0;
}

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

int main(){
  int k, a, b;
  cin >> k;
  cin >> a >> b;
  int leng=0;
  for(int i=1;i<=1000;i++){
    leng=k*i;
    if(a <=leng && leng <= b){
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <random>
#include <tuple>
#include <iomanip>
#include <cstring>

using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
//typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n-1); i >= 0; i--)
#define pb push_back
#define f first
#define s second
//const ll INFL = 1LL << 60;//10^18 = 2^60
const ll INFL = 1LL << 60;
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

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

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; 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;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

string L;

void solve(){
  int len = L.size();
  ll dp[len+1][2];
  rep(i, len+1)rep(j, 2) dp[i][j] = 0;
  dp[0][0] = 1;
  rep(i, len){
    if(L[i] == '1'){
      dp[i+1][1] += 3 * dp[i][1];
      //dp[i+1][0] += dp[i][1];
      dp[i+1][1] += dp[i][0];
      dp[i+1][0] += 2 * dp[i][0];
      dp[i+1][1] %= MOD;
      dp[i+1][0] %= MOD;
      dp[i+1][1] %= MOD;
      dp[i+1][0] %= MOD;
    }else{
      dp[i+1][1] += 3 * dp[i][1];
      //dp[i+1][0] += dp[i][1];
      //dp[i+1][1] += dp[i][0];
      dp[i+1][0] += dp[i][0];
      dp[i+1][1] %= MOD;
      dp[i+1][0] %= MOD;
      dp[i+1][1] %= MOD;
      dp[i+1][0] %= MOD;
    }
  }
  cout << (dp[len][1] + dp[len][0]) % MOD << endl;
}

int main(){
  cin >> L;
  solve();
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    // vector<ll> p(a), q(b), r(c);
    // rep(i, a) cin >> p[i];
    // rep(i, b) cin >> q[i];
    // rep(i, c) cin >> r[i];
    priority_queue<ll> p, q, r;
    rep(i, a) {
        ll v;
        cin >> v;
        p.push(v);
    }
    rep(i, b) {
        ll v;
        cin >> v;
        q.push(v);
    }
    rep(i, c) {
        ll v;
        cin >> v;
        r.push(v);
    }
    priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;
    rep(i, x) {
        ll v = p.top(); p.pop();
        pq.push(make_pair(v, 0));
    }
    rep(i, y) {
        ll v = q.top(); q.pop();
        pq.push(make_pair(v, 1));
    }
    ll ans = 0, skip = 0;
    vector<ll> rem(2);
    rem[0] = x; rem[1] = y;
    while(!pq.empty()) {
        if ((rem[0] == 0) && (rem[1] == 0)) break;
        pair<ll, ll> v1 = make_pair(LONG_LONG_MIN, -1);
        if (!pq.empty()) v1 = pq.top();
        ll v2 = LONG_LONG_MIN;
        if (!r.empty()) v2 = r.top();
        if ((v1.first < v2) && (rem[v1.second] > 0)) {
            r.pop();
            pq.pop();
            ans += v2;
            rem[v1.second]--;
        }
        else {
            pq.pop();
            ans += v1.first;
            rem[v1.second]--;
        }
        // printf("ans=%lld\n", ans);
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
	int a[5];
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
	}
	sort(a, a + 5);
	for (int i = 4; i >= 0; i--) {
		cout << a[i] << " \n"[i == 0];
	}
	return 0;
}

Measured memory_bytes: 3128
#include <stdio.h>
int main(){
  int n,k;
  scanf("%d%d",&n,&k);
  int d[k],available[10]={0};
  for(int i=0;i<k;i++){
      scanf("%d",&d[i]);
      available[d[i]]++;
  }
  for(int i=n;i<9999999;i++){
   int cpy=i;
   while(cpy>0){
       if(available[cpy%10]>0){
           break;
       }else{
           cpy/=10;
       }
   }
   if(cpy==0){
       printf("%d",i);
       return 0;
   }
  }
  
  return 0;
}


Measured memory_bytes: 128
s=list(input())
k=int(input())
for i in range(len(s)):
    if s[i] == 'a': continue
    c = ord('z') - ord(s[i]) + 1
    if c <= k:
        k -= c
        s[i] = 'a'
s[-1] = chr(ord('a') + ((ord(s[-1]) - ord('a') + k) % 26))
print(''.join(s))

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

using namespace std;

int main() {
    int k; 
    cin >> k;
    string s, ans;
    cin >> s;
    if (s.size() > k) {
        for (int i = 0; i < k; i++) ans += s[i];
        ans += "...";
        cout << ans;
    } else {
        cout << s;
    }
    cout << "\n";

}

Measured memory_bytes: 3628
import fractions
A,B,C,D = list(map(int,input().split()))
gcd = fractions.gcd(C,D)
lcm = C*D//gcd
a = ((A-1)//C+(A-1)//D-(A-1)//lcm)
b = B//C+B//D-B//lcm
print(B-A+1-(b-a))

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

long long div(long long n1) {
		for (long long i = 2; i <= sqrt(n1);) {
				if (n1 % i == 0) {
						return i;
				}
				else {
						i++;
				}
		}
		return -1;
}

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

		cout << n << ":";

		while (1) {
				if(div(n) == -1) {
						cout << " " << n;
						break;
				}
				cout << " " << div(n);
				n = n / div(n);
				}

		cout << endl;

		return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L

int main() {
    int n, d;
    cin >> n >> d;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        long double x, y;
        cin >> x >> y;
        if (sqrt((x * x) + (y * y)) <= d) cnt++;
    }
    cout << cnt;

    return 0;
}

Measured memory_bytes: 3756
/*input
100000 100000 1
50000 50000

*/
/*

  ####   #    #    ##    #####    ####           #    #
 #       #    #   #  #   #    #  #    #          #    #
  ####   ######  #    #  #    #  #    #          #    #
      #  #    #  ######  #    #  #    #          # ## #
 #    #  #    #  #    #  #    #  #    #          ##  ##
  ####   #    #  #    #  #####    ####  #######  #    #

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
using namespace std;
#define N  10005
const int M=200007;
lld dp[N];
lld h,w,n;
lld f[M],inv[M];
lld expo(lld base,lld exponent,lld mod)
{
    lld ans=1;
    while(exponent!=0)
    {
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
void compute()
{
	f[0]=1;
	rep(i,1,M){
		f[i]=(1LL*i*f[i-1])%hell;
	}
	inv[M-1]=expo(f[M-1],hell-2,hell);
	for(lld i=M-2;i>=0;i--)
	{
		inv[i]=(1LL*(i+1)*inv[i+1])%hell;
	}
}
lld C(lld n,lld r)
{
	if(n<r || r<0)
	{
		return 0;
	}
	return (1LL*((1LL*f[n]*inv[r])%hell)*inv[n-r])%hell;
}
inline void solve()
{
	cin >> h >> w >> n;
	n+=2;
	std::vector<pii> v(n);
	v[0].F=1,v[0].S=1;
	rep(i,1,n-1)
	{
		lld c1,c2;
		cin >> v[i].F >> v[i].S;
	}
	v[n-1].F=h;
	v[n-1].S=w;
	compute();
	dp[0]=0;
	sort(all(v));
	rep(i,1,n)
	{
		dp[i]=C(v[i].F+v[i].S-2,v[i].F-1)%hell;
		rep(j,0,i)
		{
			if(v[j].S<=v[i].S)
				dp[i]=(dp[i]-(dp[j]*(C(v[i].F+v[i].S-v[j].F-v[j].S,v[i].F-v[j].F)))%hell + hell)%hell;
		}
		dp[i]%=hell;
	}
	dp[n-1]=(dp[n-1]+hell)%hell;
	cout << dp[n-1]%hell << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

Measured memory_bytes: 3456
#include <stdio.h>


int main() {
	int A, B, C;

	int x, z;

	scanf("%d %d %d", &A, &B, &C);

	x = B / A;

	if (x > C) {
		printf("%d\n", C);
	}
	else {
		printf("%d\n", x);
	}

	return 0;

}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

int main() {
  int A, B;
  multiset<int> a = {1, 2, 3};
  multiset<int> b;
  multiset<int> result;

  cin >> A >> B;
  b.insert(A);
  b.insert(B);
  
  // 差集合を計算する
  set_difference(a.begin(), a.end(),
                  b.begin(), b.end(),
                  inserter(result, result.end()));
  
  std::for_each(result.begin(), result.end(), [](int x) {
    std::cout << x << std::endl;
  });

}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a, b;
    cin >> a >> b;
    if(a >= 10 || b >= 10){
        cout << -1 << endl;
    }
    else    cout << a * b << endl;
}

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

int N, K;
int a[100010];
ll s[100010];
ll _s[100010];

void Main()
{
	cin >> N >> K;
	rep(i,N) cin >> a[i];
	s[0] = 0;
	_s[0] = 0;
	rep(i,N) {
		s[i + 1] = s[i] + a[i];
		_s[i + 1] = _s[i] + max(a[i], 0);
	}
	ll res = -1e18;
	rep(i, N - K + 1) {
		ll tmp = s[i + K] - s[i];
		ll l = _s[i] - _s[0];
		ll r = _s[N] - _s[i + K];
		res = max(max(tmp + l + r, l + r), res);
	}
	cout << res << endl;
}

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


Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;

ll nCr(ll n, ll r) {
	if (r > n) { return 0; }
	if (r * 2 > n) r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
ll sumdigit(ll n) {
	ll dig = 0, sum = 0;
	while (n) {
		dig = n % 10;
		sum = sum + dig;
		n = n / 10;
	}
	return sum;
}



int main() {
	int n = 0, m = 0,some = 0;
	std::cin >> n >> m;
	std::map<int, int> map;

	rep(i, m) {
		
		std::cin >> some;
		map[some]++;
		std::cin >> some;
		map[some]++;
		
	}
	for(int i = 1; i<=n; i++){
		std::cout << map[i] << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll p1,p2;
ll lcm(ll a,ll b)
{
    return (a*b)/__gcd(a,b);
}
ll fun(ll n)
{
    if(n==0)
        return 0;
    ll ans=0;
    for(int a=0;a<2;a++)
    {
        for(int b=0;b<2;b++)
        {
            ll counting =0;
            ll dis=1;
            if(a)
            {
                dis=lcm(p1,dis);
                counting++;
            }
            if(b)
            {
                dis=lcm(p2,dis);
                counting++;
            }
            ll sign = counting%2==1?1:-1;
            if(counting==0)
                continue;
            ans+=sign*n/dis;
        }
    }
    return n-ans;
}
int main()
{
    ll a,b;
    cin>>a>>b>>p1>>p2;
    cout<<fun(b)-fun(a-1)<<endl;
    return 0;
}


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

int LP[1005][1005];

int main(){
    int j, k;
    string x, y;
    cin >> x >> y;

    for(j = 1; j <= x.size(); j++){
        LP[j][0] = j;
    }
    for(k = 1; k <= y.size(); k++){
        LP[0][k] = k;
    }

    for(j = 1; j <= x.size(); j++){
        for(k = 1; k <= y.size(); k++){
            int m = min(LP[j-1][k] + 1, LP[j][k-1] + 1);//削除、追加
            if(x[j-1] == y[k-1]){
                m = min(LP[j-1][k-1], m);
                LP[j][k] = m;
            }
            else{
                m = min(LP[j-1][k-1] + 1, m);//置換する
                LP[j][k] = m;
            }
        }
    }

    printf("%d\n", LP[x.size()][y.size()]);
    return 0;
}


Measured memory_bytes: 7168
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int main(int argc,char** argv){
	ll n,m;
	cin>>n>>m;
	if(n==1||m==1)cout<<1;
	else cout<<(n*m+1ll)/2ll;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long int N = 2e5+1;
long long int n;
long long int tree[2*N]{0};
void build(){
    for(long long int i=n-1;i>0;i--){
        tree[i]=max(tree[i<<1],tree[i<<1|1]);
    }
}
void modify(long long int p,long long int value){
    for(tree[p+=n]=value;p>1;p>>=1){
        tree[p>>1]=max(tree[p],tree[p^1]);
    } 
}
long long int query(long long int l,long long int r){
    r++;
    long long int ret = 0;
    for(l+=n,r+=n;l<r;l>>=1,r>>=1){
        if(l&1) ret=max(tree[l++],ret);
        if(r&1) ret=max(tree[--r],ret);
    }
    return ret;
}
void pre(){}
void solve(){
    cin>>n;
    set<pair<long long int,long long int>>s;
    map<long long int,long long int>m;
    long long int arr[n];
    long long int brr[n];
    for(long long int i=0;i<n;i++) cin>>arr[i];
    for(long long int i=0;i<n;i++) cin>>brr[i];
    n++;
    for(long long int i=0;i<n-1;i++){
        modify(arr[i],query(0,arr[i])+brr[i]);
    }
    cout<<query(0,n)<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=2*1e5+100,P=1e4+100;
int n,p,h[N],t[P],ans,inv[N];
char s[N];
int m_pow(int a,int b)
{
	int ans=1;
	while (b)
	{
		if (b&1) ans=(ans*a)%p;
		b>>=1;
		a=(a*a)%p;
	}
	return ans;
}
signed main()
{
	scanf("%lld%lld",&n,&p);
	scanf("%s",s+1);
	for (int i=1;i<=n;i++)
	  h[i]=((h[i-1]*10)%p+(s[i]-'0'))%p;
	if (p==2 || p==5)
	{
		for (int i=1;i<=n;i++)
		  if (h[i]==0) ans+=i;
		printf("%lld\n",ans);
		return 0;
	}
	inv[0]=1;
	for (int i=1;i<=n+1;i++) inv[i]=(inv[i-1]*10)%p;
	for (int i=1;i<=n+1;i++) inv[i]=m_pow(inv[i],p-2);
	for (int i=n;i>=1;i--)
	{
		t[(h[i]*inv[i+1])%p]++;
		ans+=t[(h[i-1]*inv[i])%p];
	}
	printf("%lld\n",ans);
}

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

using namespace std;
using pii = pair<int, int>;
using ppii = pair<int, pii>;

int n;
vector<pair<int, pii>> a;
set<ppii> edge;

bool less_x(ppii s, ppii t) {
  return s.second.first < t.second.first;
}

bool less_y(ppii s, ppii t) {
  return s.second.second < t.second.second;
}

vector<int> par;

int root(int x) {
  if (par[x] == x) return x;
  return par[x] = root(par[x]);
}

void unite(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y) return;
  par[x] = y;
}

bool same(int x, int y) {
  return root(x) == root(y);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  a = vector<ppii>(n);
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    a[i] = make_pair(i, make_pair(x, y));
  }
  sort(a.begin(), a.end(), less_x);
  auto p0 = a[0];
  for (int i = 1; i < n; i++) {
    auto p1 = a[i];
    int cost = min(abs(p0.second.first - p1.second.first), abs(p0.second.second - p1.second.second));
    edge.insert(make_pair(cost, make_pair(p0.first, p1.first)));
    p0 = p1;
  }
  sort(a.begin(), a.end(), less_y);
  p0 = a[0];
  for (int i = 1; i < n; i++) {
    auto p1 = a[i];
    int cost = min(abs(p0.second.first - p1.second.first), abs(p0.second.second - p1.second.second));
    edge.insert(make_pair(cost, make_pair(p0.first, p1.first)));
    p0 = p1;
  }
  par = vector<int>(n);
  for (int i = 0; i < n; i++) {
    par[i] = i;
  }
  long long ans = 0;
  for (auto e: edge) {
    int c = e.first, u = e.second.first, v = e.second.second;
    if (same(u, v)) {
      continue;
    }
    ans += c;
    unite(u, v);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 14336
n,k = input().split()
n = int(n)
k = int(k)
count = 0
for i in range(1,k+1):
    if 6 * i % k == 0 and 2 * i % k == 0:
        s = (n - i) // k
        count += (s + 1) ** 3
print(count)

Measured memory_bytes: 3060
def partition(a, p, r)
	x = a[r]
	i = p - 1
	for j in p..r-1
		if a[j] <= x
			i += 1
			a[j],a[i] = a[i],a[j]
		end
	end
	a[r],a[i+1] = a[i+1],a[r]
	return i+1
end

n = gets.to_i
a = gets.split(" ").map(&:to_i)

i = partition(a,0,n-1)

puts a[0,i].join(" ") + " [" + a[i].to_s + "] " + a[i+1,n-i-1].join(" ")

Measured memory_bytes: 17760