akhauriyash/Code-Regression huggingface dataset:
"""
ABC146D Diff: 1175
"""
# BFSで各親の子供をループして調べていく.
# 各ノードの周りにある色を集合で持ったらTLE
# -> 色を塗る規則に注意すれば各親に対してintを1つ用意すれば十分

from collections import deque
import sys
input = sys.stdin.readline
    
def bfs(v, N, G, E):
    #訪れたかどうか
    visited = [0]*N
    queue = deque()
    K = -1
    # 各ノードで使っている色の中で最大の色
    node2color = [-1 for _ in range(N)]
    queue.append(v)
    visited[v] = 1
    while queue:
        q = queue.popleft()
        # 使う色(int)を初期化: 0から++していくことで、
        # 調べる親qの子に対してできるだけ小さい色を塗れる。
        color = 0
        for nex in G[q]:
            if visited[nex]:
                #すでに訪れていたらcontinue
                continue
            visited[nex] = 1
            color += 1
            if color == node2color[q]:
                color += 1
            
            node2color[nex] = color
            # 辞書に記録
            E[(min(q, nex), max(q, nex))] = color
            queue.append(nex)
        K = max(K, color)
    return K

def main():
    N = int(input())
    G = [deque() for _ in range(N)]
    E = dict() # (a, b) -> color
    for _ in range(N-1):
        a, b = map(lambda x: int(x)-1, input().split())
        G[a].append(b)
        G[b].append(a)
        E[(a, b)] = 0 #辺->色の辞書
    K = bfs(0, N, G, E)
    # ans_list = [value for value in E.values()]
    print(K)
    for value in E.values():
        print(value)
main()

Measured memory_bytes: 162612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if (N==1) {
			System.out.println("Hello World");
		} else {
			int A = sc.nextInt();
			int B = sc.nextInt();
			System.out.println(A+B);
		}

	}
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
// using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] ab = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] AopB = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
            // List<long> kl=new List<long>(hs.Keys);
            // kl.Sort();
            // foreach(long k in kl){
            //     s[1]-=hs[k];
            //     if(s[1]<1){Console.WriteLine("{0}",k);break;}
            // }
            Console.WriteLine(N*800-200*(N/15));
        }
        //最小公倍数
        static long Lcm(long a, long b)
        {
            return a/Gcd(a,b)*b;
        }

        //最大公約数
        static long Gcd(long m, long n)
        {
            if(n==0)return m;
            return Gcd(n,m%n);
        }
    }
}

Measured memory_bytes: 11092
m=10**9+7
f=max
r=range
for _ in r(int(input())):
	x,y=sorted(map(int,input().split()))
	s=-1
	i=j=1
	while j<=x and i+j<=y:i,j,s=j,i+j,s+1
	if x<2 or y<3:print(1,x*y%m);continue
	else:
		a=f(0,(y-j)//i+1)+f(0,(x-j)//i+1)
		i=j=1
		for c in r(s):
			k,l=j,i+j*2
			for _ in r(s-c):k,l=l,k+l
			if x>=k:a+=f(0,(y-l)//k+1)
			if y>=k:a+=f(0,(x-l)//k+1)
			i,j=j,i+j
		print(s+1,a%m)

Measured memory_bytes: 81180
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

main {
  int n, m;
  while (cin >> n >> m, n || m) {
    vi l(n), r(m);
    cin >> l >> r;
    vi v;
    v.reserve(n + m);
    for (auto &x : l) v.push_back(move(x));
    for (auto &x : r) v.push_back(move(x));
    sort(all(v));
    int maxi = v[0];
    loop(i, 1, n + m) cmax(maxi, v[i] - v[i - 1]);
    cout << maxi << endl;
  }
}

Measured memory_bytes: 3208
def gcd(n,m):#n,mは正の整数、最大公約数　許容は？
    if n==0:
        return m
    elif m==0:
        return n
    elif n>m:
        n=n%m
        return gcd(n,m)
    else:
        m=m%n
        return gcd(n,m)

def ord(N,n):#N,nは正の整数、Nで割り切れる回数、許容はN^1000
    if n%N!=0:
        return 0
    else:
        return 1+ord(N,n//N)

def get_sieve_of_eratosthenes_new(n):
    import math
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

primelist=get_sieve_of_eratosthenes_new(10**6)

A,B=map(int,input().split())
x=gcd(A,B)
count=1

for i in range(0,len(primelist)):
    if x%primelist[i]==0:
        count+=1
        x=x//primelist[i]**ord(primelist[i],x)
if x!=1:
    count+=1
print(count)

Measured memory_bytes: 135112
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <unordered_set>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;

  unordered_set<int> segment_front;
  int p = 0;
  while (p < n) {
    if (s[p] == 'o') {
      segment_front.insert(p);
      p += c + 1;
    }
    else p++;
  }
  unordered_set<int> segment_back;
  p = n-1;
  while (p >= 0) {
    if (s[p] == 'o') {
      segment_back.insert(p);
      p -= c + 1;
    }
    else p--;
  }

  if ((int) segment_front.size() > k) {
    cout << endl;
    return 0;
  }

  vector<int> ans;
  for (auto &x: segment_front) {
    if (segment_back.find(x) != segment_back.end()) ans.push_back(x);
  }

  sort(ans.begin(), ans.end());

  for (auto &x: ans) cout << x + 1 << endl;

  return 0;
}


Measured memory_bytes: 20060
<?php
// $S = trim(fgets(STDIN));
// $T = trim(fgets(STDIN));
fscanf(STDIN,"%s",$S);
fscanf(STDIN,"%s",$T);
$ans = strlen($T);
for($i = 0; $i < strlen($S) - strlen($T) + 1; $i++){
    $cnt = 0;
    for($j = 0; $j < strlen($T); $j++){
        if($S[$i+$j] != $T[$j]){
            $cnt++;
        }
    }
    $ans = min($ans, $cnt);
}
echo $ans . "\n";
?>

Measured memory_bytes: 15996
#include <bits/stdc++.h>
#define root 1, n, 1, pre[top[u]], pre[u]
#define ls l, mid, k << 1
#define rs mid + 1, r, k << 1 | 1
#define L k << 1
#define R k << 1 | 1
using namespace std;
int read();

int n;
vector<int> e[200005];
void add(int f, int t) { e[f].push_back(t), e[t].push_back(f); }
int fa[200005], dep[200005], sn[200005], sz[200005];

void dfs1(int u) {
	sz[u] = 1;
    for (vector<int>::iterator v = e[u].begin(); v != e[u].end(); v++)
        if ((*v) != fa[u]) {
			dep[*v] = dep[u] + 1, fa[*v] = u, dfs1(*v);
			sz[u] += sz[*v], sn[u] = sz[sn[u]] < sz[*v] ? *v : sn[u];
		}
}

int pre[200005], top[200005], dfn;
void dfs2(int u) {
	pre[u] = ++dfn;
	if (!sn[u]) return;
	top[sn[u]] = top[u], dfs2(sn[u]);
    for (vector<int>::iterator v = e[u].begin(); v != e[u].end(); v++)
		if ((*v) != fa[u] && (*v) != sn[u]) top[*v] = *v, dfs2(*v);
}

queue<int> q;

struct Seg {
	int mn[400005], xsum[400005];
	int tag1[400005], tag2[400005];
	void Tag1(int k, int v) { mn[k] += v, tag1[k] += v; }
	void Tag2(int k, int v) { xsum[k] ^= v, tag2[k] ^= v; }
	void psd1(int k) { Tag1(L, tag1[k]), Tag1(R, tag1[k]), tag1[k] = 0;	}
	void psd2(int k) { Tag2(L, tag2[k]), Tag2(R, tag2[k]), tag2[k] = 0; }
	void mdi1(int l, int r, int k, int st, int en, int v) {
		if (st > r || en < l) return;
		if (st <= l && en >= r) return Tag1(k, v);
		psd1(k);
		int mid = l + r >> 1;
		mdi1(ls, st, en, v), mdi1(rs, st, en, v), mn[k] = min(mn[L], mn[R]);
	}

	void mdi2(int l, int r, int k, int st, int en, int v) {
		if (st > r || en < l) return;
		if (st <= l && en >= r) return Tag2(k, v);
		psd2(k);
		int mid = l + r >> 1;
		mdi2(ls, st, en, v), mdi2(rs, st, en, v);
	}

	void work(int l, int r, int k) {
		if (l == r)	return mn[k] = 1000000000, q.push(xsum[k]);
		int mid = l + r >> 1;
		psd1(k), psd2(k);
		if (mn[L] == 1) work(ls);
		if (mn[R] == 1) work(rs);
		mn[k] = min(mn[L], mn[R]);
	}
} seg;

void modi(int u, int v, int val, int id) {
	while (top[u] != top[v]) {
		if (dep[top[u]] < dep[top[v]]) swap(u, v);
		seg.mdi1(root, val), seg.mdi2(root, id), u = fa[top[u]];
	}
	if (dep[u] > dep[v]) swap(u, v);
	seg.mdi1(1, n, 1, pre[u] + 1, pre[v], val);
	seg.mdi2(1, n, 1, pre[u] + 1, pre[v], id);
}

struct E {
	int u, v;
	void init(int i) { modi(u = read(), v = read(), 1, i); }
} p[200005];

int main() {
    n = read();
    for (int i = 1; i < n; ++i) add(read(), read());
    dep[1] = 1, dfs1(1), top[1] = 1, dfs2(1);
    for (int i = 1, u, v; i < n; ++i) p[i].init(i);
	seg.mdi1(1, n, 1, 1, 1, 100000000),	seg.work(1, n, 1);
	int cnt = 0;
	while (!q.empty()) {
		int t = q.front();
		cerr << t << endl;
		q.pop(), cnt++, modi(p[t].u, p[t].v, -1, t), seg.work(1, n, 1);
	}
    puts(cnt == n - 1 ? "YES" : "NO");
    return 0;
}

int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') f = (c == '-') ? -1 : f, c = getchar();
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}


Measured memory_bytes: 24064
n = int(input())
a = [int(_) for _ in input().split()]

num_cnt = [0] * 200001
for i in a:
    num_cnt[i] += 1

pat_cnt = [0] * 200001
for i in range(200001):
    b = num_cnt[i]
    pat_cnt[i] = (b*(b-1))//2

ans = sum(pat_cnt)

for i in range(n):
    #print(ans, pat_cnt[a[i]], num_cnt[a[i]])
    print(ans - pat_cnt[a[i]] + ((num_cnt[a[i]]-1) * (num_cnt[a[i]]-2))//2)


Measured memory_bytes: 25712
N,K = map(int,input().split())
V = list(map(int,input().split()))

import heapq
ans = 0
for a in range(min(N,K)+1):
    for b in range(min(N,K)-a+1):
        A = V[:a] + V[N-b:]
        heapq.heapify(A)
        for c in range(min(a+b, K-a-b)):
            small = heapq.heappop(A)
            if small > 0:
                heapq.heappush(A,small)
                break
        ans = max(ans, sum(A))
print(ans)


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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const int N_MAX = 110;
const int W_MAX = 1000000;


int main(void){

	int N, W; cin >> N >> W;
	vector<int> w(N);
	vector<int> v(N);
	REP(i,N) cin >> w[i] >> v[i];
	vector<vector<long long>> dp(N_MAX, vector<long long>(W_MAX, 0));

	REP(i,N){
		REP(sum_w,W+1){
			if(sum_w - w[i] >= 0){
				dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w-w[i]] + v[i]);
			}
			dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w]);
		}
	}

	cout << dp[N][W] << endl;

	return 0;

}


Measured memory_bytes: 867864
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Ti4 tuple<int, int, int, int>
#define Tlll tuple<ll, ll, ll>
#define PI 3.141592653589793

int main() {
    int n, p;
    while (cin >> n >> p) {
        if (n == 0) return 0;
        int b[n] = {}, cnt = 1;
        for (int i = 0; 1; i++) {
            if (p > 0) {
                b[i % n]++;  p--;
                cnt = 1;
            }
            else {
                if (b[i % n]) {
                    p = b[i % n];
                    b[i % n] = 0;
                    cnt = 1;
                }
                else {
                    cnt++;
                }
            }
            if (cnt == n) {
                cout << (i + 1) % n << endl;
                break;
            }
        }
    }
}



Measured memory_bytes: 3056
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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; }

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};

ll sumofdigits(ll n){
    int sum =0;
    while(n>0){
        sum += n%10;
        n /=10;
    }
    return sum;
}

void solve(){
    ll n;
    cin>>n;
    if(n%sumofdigits(n)==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    solve();

    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n,x,y = map(int, input().split())

ans = [0] * n
for i in range(1, n + 1):
    for j in range(1 + i, n + 1):
        a = abs(i - x) + abs(j - y) + 1
        b = abs(i - j)
        c = min(a, b)
        ans[c] += 1

for i in range(1, n):
    print(ans[i])


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

#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int, int> pi;
typedef vector<int> vi;
void print_pair(pi a){
  cerr<<"("<<a.first<<", "<<a.second<<") ";
}
template<int T1, int T2>
void print_2d(int a[T1][T2], int x, int y){
  For(i, x){
    For(j, y){
      cerr<<a[i][j]<<" ";
    }
    cerr<<endl;
  }
}

int N;
string S;
unordered_map<string,ll> l,r;

int main(){
  cin>>N>>S;
  reverse(S.begin(),S.begin()+N);
  REP(1<<N){
    string red,black;
    For(j,N){
      if(i&1<<j)red+=S[j];
      else black+=S[j];
    }
    string tmp = red+" "+black;
    if(l.find(tmp)==l.end()){
      l[tmp]=1;
    }else{
      l[tmp]++;
    }
    cerr<<"("<<tmp<<","<<l[tmp]<<")"<<endl;
  }
  REP(1<<N){
    string red,black;
    For(j,N){
      if(i&1<<j)red+=S[j+N];
      else black+=S[j+N];
    }
    string tmp = red+" "+black;
    if(r.find(tmp)==r.end()){
      r[tmp]=1;
    }else{
      r[tmp]++;
    }
    cerr<<"("<<tmp<<","<<r[tmp]<<")"<<endl;
  }
  ull ans=0;
  for(auto tmp:l){
    if(r.find(tmp.first)!=r.end())ans+=tmp.second*r[tmp.first];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 68468
/*
	Bakul Gaur (caesar1551)
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PrePro ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define fr(i,n) for(ll i = 0; i < n; i++)
#define fre(i,a,b) for(ll i = a; i <= b; i++)
#define fb(i,n) for(ll i = n; i >= 0; i--)
#define fbe(i,a,b) for(ll i = a; i >= b; i--)
#define umap(x,y) unordered_map<x,y>
#define uset(x) unordered_set<x>
#define vv(x) vector<x>
#define pp(x,y) pair<x,y>
#define prar(a,n) fr(i,n){cout << a[i] << " ";}
#define inar(a,n) fr(i,n){cin >> a[i];}
#define mk make_pair
#define pb push_back
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define MAX 1000001
inline ll gcd(ll a, ll b){
	if(b == 0){
		return a;
	}
	return gcd(b,a%b);
}
inline ll pwr(ll a, ll b, ll modulo = mod){
	if(a == 0 && b == 0){
		return 0;
	}
	ll ans = 1;
	while(b > 0){
		if(b&1){
			ans = ((ans%modulo) * (a%modulo))%modulo;
		}
		b >>= 1;
		a = ((a%modulo) * (a%modulo))%modulo;
	}
	return (ans+modulo)%modulo;
}
inline ll modInverse(ll a, ll p){
	// Only if p is prime.
	return pwr(a,p-2,p);
}



/* #############
   START SOLVING 
   ############# */

void dfs(vv(vv(ll)) &graph, vv(bool) &vis, vv(ll) &dp, ll start){
	vis[start] = true;
	for(auto i:graph[start]){
		if(vis[i] == false){
			dfs(graph,vis,dp,i);
		}
		dp[start] = max(dp[start], 1 + dp[i]);
	}
}

void solve(){
	ll n, m;
	cin >> n >> m;
	vv(vv(ll)) graph(n+1);
	while(m--){
		ll a, b;
		cin >> a >> b;
		graph[a].pb(b);
	}
	vv(bool) vis(n+1,false);
	vv(ll) dp(n+1,0);
	fre(i,1,n){
		if(vis[i] == false){
			dfs(graph,vis,dp,i);
		}
	}
	ll ans = 0;
	fre(i,1,n){
		ans = max(ans,dp[i]);
	}
	cout << ans << endl;
}
int main(){
	PrePro
	/* #ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif */
    ll t = 1;
    // cin >> t;
    fr(i,t){
    	// cout << "Case #" << i+1 << ": ";
    	solve();
    	// cout << endl;
    }
	return 0;
}

Measured memory_bytes: 12912
//Contains functions for implementing a disjoint set union
#include<bits/stdc++.h>
using namespace std;
//#define num 1000000007
#define num 998244353
#define inf 1000000000000000000ll
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pi pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) (a>b)?a:b
//#define min(a,b) (a>b)?b:a
#define max3(a,b,c) (a>b)?(a>c)?a:c:(b>c)?b:c
#define min3(a,b,c) (a<b)?(a<c)?a:c:(b<c)?b:c
#define avg(a,b) ((a)+(b))/2
//#define push push_back
//#define pop pop_back
#define mp make_pair
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define fir first
#define sec second
#define mod(a) ((a)>0)?(a):(-(a))
 
 
typedef long long ll;
 
ll next(ll a, ll n)
{
    return (a==n-1)?0:a+1;
}
ll parent[1000005],size[1000005],  tail[300005];
set<ll> cur_par;
ll n,m,q;
ll pos(ll x,ll y)
{
    return (m*(x-1))+y;
}
void init_parent(ll n)
{
    memset(parent,-1,sizeof(parent[0])*n);
}
void make_set(ll v)
{
    parent[v]=v;
    ::size[v]=1;
    tail[v]=v;
}
ll find_set(ll v)
{
    if(parent[v]==v)
    return v;
    return parent[v]=find_set(parent[v]);
}
void union_sets(ll a,ll b, ll A[])
{
    a=find_set(a);
    b=find_set(b);
    if(a==b)
    return;
    if(::size[a]<::size[b])
    {
        swap(a,b);
    }
    parent[b]=a;
    ::size[a]+=::size[b];
    A[a] = min(A[a], A[b]);
}
ll prev(ll a,ll n)
{
    if(a==0)
    return n-1;
    return a-1;
}
ll nex(ll a,ll n)
{
    if(a==n-1)
    return 0;
    else
    return a+1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    while(n)
    {
        if(n%10==7)
        {
            cout<<"Yes\n";
            exit(0);
        }
        n/=10;
    }
    cout<<"No\n";
    return 0;
}

Measured memory_bytes: 3656
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).end()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 

#define int ll

using namespace std;

const int N = 3e5 +5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

int F(int n , int p){
    int t = n/p ;
    int res = p;
    res = res * (t * (t + 1) / 2) ;
    // cout << p << ' ' << t << ' ' << res << '\n';
    return res ;
}
void solve()
{
    int n ;
    cin >> n ;

    int res = F(n , 1) - F(n , 3) - F(n , 5) + F(n , 15);
    cout << res; 
}   

     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}

Measured memory_bytes: 3696
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if((100*a+10*b+c)%4==0){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {

    public Main(){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();

        if(T.startsWith(S)){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    public static void main(String[] args) {
        Main M = new Main();
    }
}


Measured memory_bytes: 35668
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  double a, b, x;
  cin >> a >> b >> x;
  double pi = acos(-1.0);
  double ans;
  if(2 * x > a * a * b)
    ans = atan2(2 * a * a * b - 2 * x, pow(a, 3)) * 180.0 / pi;
  else
    ans = atan2(a * b * b, 2 * x) * 180.0 / pi;
  printf("%.10f\n", ans);
}

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

int n, a, b;

int whole;

int main(void){
    // Here your code !
    scanf("%d %d %d", &n, &a, &b);

    for (int i = 1; i <= n; ++i) {
      string t = to_string(i);

      int sum = 0;
      for (int j = 0; j < t.size(); ++j) {
        int num = (int)t[j] - 48;
        sum += num;
      }
      if (a <= sum && sum <= b) whole += i;
    }

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


Measured memory_bytes: 256
using System;
class Prpgram
{
    static void Main(string[] args)
    {
        string input = Console.ReadLine();
        char[] S= input.ToCharArray();

        char mozi3 = S[2];
        char mozi4 = S[3];
        char mozi5 = S[4];
        char mozi6 = S[5];

        if (mozi3 == mozi4)
        {
            if (mozi5 == mozi6) Console.Write("Yes");
            else Console.Write("No");
        }
        else Console.Write("No");
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	ll X, K, D; cin >> X >> K >> D;
	ll absX = abs(X);
	if (absX / D >= K) {
		cout << absX - D * K << endl;
	} else {
		int parity = (absX / D) % 2;
		int kParity = K % 2;
		if (parity == kParity) {
			cout << absX % D << endl;
		} else {
			cout << D - absX % D << endl;
		}
	}
}

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


Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll N,Q,A[100007],C[100007];

int main(){
  ll ANS=0;
  cin >> N ;
  rep(i,N){
    cin >> A[i];
    C[A[i]]++;
    ANS+=A[i];
  }
  cin >>  Q;
  rep(i,Q){
    ll X,Y;
    cin >> X >> Y;
    C[Y]+=C[X];
    ANS+=(Y-X)*C[X];
    C[X]=0;
    cout << ANS << endl;
  }
}

Measured memory_bytes: 5164
<>;@t=glob<>;@v=glob<>;
while(@v){
	$m=0;($m+=$t[@v-$_])-=$-=$m-$v[@v-$_]for 1..$#v;
	$V="@v"<$m?
		"@v"-$V<"@t"?
			($\+=("@v"**2-$V**2)/2+("@t"-"@v"+$V)*"@v","@v"):
			($\+="@t"*($V+"@t"/2),$V+"@t")
		:$m-$V>"@t"?
			($\+="@t"*($V+"@t"/2),$V+"@t"):
			($u=("@t"+$V+$m)/2,$u>"@v")?
				($\+=("@v"**2*2-$V**2-$m**2)/2+2*($u-"@v")*"@v",$m):
				($\+=($u**2-$V**2+$u**2-$m**2)/2,$m);
	shift@t;shift@v
}
print

Measured memory_bytes: 896
n = int(input())
a = list(map(int, input().split()))
absa = [abs(i) for i in a]
c = 0
for i in a:
  if i < 0:
    c += 1
if c%2 == 0:
  print(sum(absa))
else:
  print(sum(absa)-min(absa)*2)

Measured memory_bytes: 14412
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(void) {
	unsigned short *A, *B;

	int C[VMAX + 1];
	int n, i, j;
	scanf("%d", &n);

	A = malloc(sizeof(short) * n + 1);
	B = malloc(sizeof(short) * n + 1);

	for (i = 0; i <= VMAX; i++)C[i] = 0;

	for (i = 0; i < n; i++) {
		scanf("%hu", &A[i + 1]);
		C[A[i + 1]]++;
	}
	for (i = 1; i <= VMAX; i++)C[i] = C[i] + C[i - 1];
	for (j = 1; j <= n; j++) {
		B[C[A[j]]] = A[j];
		C[A[j]]--;
	}
	for (i = 1; i <= n; i++) {
		if (i > 1)printf(" ");
		printf("%d", B[i]);
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 9592
// Problem : D - Leaping Tak
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

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

/* DEBUGGING */
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/* MACROS */ 
typedef long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

typedef map<int,int> mii;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  all(x)      (x).begin(), (x).end()
#define  lcm(x, y)   ((x) * (y) / __gcd(x, y))
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcountll(x)
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b) for(int i=a ; i>=b ; --i)

/* CONSTANTS */ 
#define PI 3.141592653589793
const ll MOD = 998244353;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;

// #define cerr if(false)cerr
/* CODE STARTS HERE */

void solve(){
    ll n,k; cin >> n >> k;
    
    vpii v(k);    
    rep(i,0,n) cin >> v[i].ff >> v[i].ss;
    
    vll pref(MAX_N+1),curr(MAX_N+1);
    
    // deb(v);
    rep(i,1,n+1){
        pref[i] = (pref[i-1]+pref[i])%MOD;
        
        if(i==1) curr[i] = 1;
        else curr[i] = pref[i];
        
        rep(j,0,k){
            if(i+v[j].ff < MAX_N) 
                pref[i+v[j].ff] = (pref[i+v[j].ff]+curr[i])%MOD;
            if(i+v[j].ss < MAX_N) 
                pref[i+v[j].ss+1] = (pref[i+v[j].ss+1]%MOD - curr[i]%MOD + MOD)%MOD;
        }
        
    }
    
    cout << curr[n]%MOD;
}

int main(){
    IOS;
    solve();
}

Measured memory_bytes: 6344
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,a,b;
    cin>>n>>a>>b;
    vector<char> s(n);
    rep(i,n) cin>>s[i];
    rep(i,n){
        if(s[i]=='a'){
            if(0<a+b){
                cout<<"Yes";
                a--;
            }else cout<<"No";
        }else if(s[i]=='b'){
            if(0<a+b&&0<b){
                cout<<"Yes";
                b--;
            }else cout<<"No";
        }else cout<<"No";
        cout<<endl;
    }
}

Measured memory_bytes: 3700
#include <iostream>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    ll n;
    cin>>n;
    if(n%2==0){
        cout<<n<<endl;
    }else{
        cout<<n*2<<endl;
    }
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define sz(c)       int(c.size())
#define rep(i,a,b)  for (int i=a; i<(b); ++i)
#define per(i,a,b)  for (int i=(b)-1; i>=(a); --i)
#define fore(c,...) for (auto __VA_ARGS__:(c))
using namespace std;
typedef long long ll;



int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	int n;
	cin>>n;
	cout<<(n+1)/2<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF             1e14
#define dd              double
#define MOD             1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl              cout<<endl
#define fill(a,val)     memset(a,val,sizeof(a))
#define mp              make_pair
#define endl            "\n"
#define pb              push_back
#define ff              first    
#define ss              second
#define SIZE            200005
#define all(v)          v.begin(),v.end()
#define s(ar,n)         sort(ar,ar+n)
#define rs(ar,n)        sort(ar, ar+n, greater<ll>()) 
#define oa(a,n)         for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n)         for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N)      *max_element(ar,ar+N)
#define mina(ar,N)      *min_element(ar,ar+N)
#define fastio()        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock      cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
ll power(ll x, ll y){
    ll res=1;x=x;
    while(y>0){
        if(y&1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}  
ll logtwo(ll n){
    if(n==1)
        return 0;
    return logtwo(n/2)+1;
}
vector<ll> adj[200005];
stack<ll> s[200005];
vector<ll> v(200005);
ll ar[200005];
ll ans[200005];
void dfs(int cur,int par)
{
    for(auto child:adj[cur])
    {
        if(child==par)
            continue;
        auto it=lower_bound(v.begin(),v.begin()+ans[cur],ar[child]);
        if(it==v.begin()+ans[cur])
        {
            v[ans[cur]]=ar[child];
            s[ans[cur]].push(ar[child]);
            ans[child]=ans[cur]+1;
        }
        else
        {
            *it=ar[child];
            s[it-v.begin()].push(ar[child]);
            ans[child]=ans[cur];
        }
        dfs(child,cur);
    }
    auto it=lower_bound(v.begin(),v.begin()+ans[cur],ar[cur]);
    s[it-v.begin()].pop();
    *it=0;
    if(s[it-v.begin()].size())
        *it=s[it-v.begin()].top();
}
signed main()
{
    fastio();   
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif 
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll N;
        cin>>N;
        cn(ar,N);
        for(ll i=0;i<N-1;i++)
        {
            ll a,b;
            cin>>a>>b;
            a--;b--;
            adj[a].pb(b);
            adj[b].pb(a);
        }
        ans[0]=1;
        s[0].push(ar[0]);
        v[0]=ar[0];
        dfs(0,-1);
        for(ll i=0;i<N;i++)
            cout<<ans[i]<<endl;
    } 
    printclock;
}

Measured memory_bytes: 171828
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

S = readline().rstrip()
S = S[::-1]
dp = [0]*13
dp[0] = 1

for i,s in enumerate(S):
    dpnew = [0]*13
    pow10 = pow(10,i,13)
    if s != '?':
        k = int(s)
        for j in range(13):
            dpnew[(k*pow10+j)%13] = (dpnew[(k*pow10+j)%13]+dp[j])%mod
    else:
        for k in range(10):
            for j in range(13):
                dpnew[(k*pow10+j)%13] = (dpnew[(k*pow10+j)%13]+dp[j])%mod
    dp = dpnew

print(dp[5])


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

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define ncr(n,r) fact[n]*modInv(fact[r])*modInv(fact[n-r])
#define modInv(a) binExp(a,mod-2)
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)

signed main()
{
    fast

    #ifndef ONLINE_JUDGE
        freopen("inputf.in","r",stdin);
        freopen("outputf.in","w",stdout);
    #endif

    int n;
    cin>>n;

    int a[n];
    cin>>a[0];
    int cur = a[0];
    int ans = 0;
    f0(i,1,n)
    {
        cin>>a[i];
        if(a[i] < cur)
        {
            ans += cur-a[i];
            a[i] = cur;
        }
        else
        {
            cur = a[i];
        }
    }
    cout<<ans;
}

Measured memory_bytes: 5176
#include <iostream>
#include <cstring>
#include <vector>
#include <cctype>
#include <cstdio>
#include <cmath>
using namespace std;
#define rep(i, n) for( int i = 0; i < n; i++ )
typedef vector<int> vec;

int main(){
    double a, b, C;
    cin >> a >> b >> C;
    C = C * M_PI / 180;
    double S = a*b*sin(C)/2;
    // if( S < 0 ) S *= -1;
    double c = (sqrt)(a*a + b*b - 2.0*a*b*cos(C));
    double h = c*(sqrt)(1.0 - (pow)((a*a+c*c-b*b)/(2.0*a*c), 2.0));

    printf("%.5f\n%.5f\n%.5f\n", S, a+b+c, h);
}

Measured memory_bytes: 1240
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

const ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
int compare(string a, string b) {
	int i;
	for (i = 0; i < a[i] != '\0'; i++) {
		if (b[i] == '\0')
			return -1;
		else if (a[i] < b[i])
			return 1;
		else if (a[i] > b[i])
			return -1;
	}
	if (b[i] != '\0')
		return 1;
	else
		return 0;
}
int main() {
	int i, j;
	char s[55], t[10] = "AKIHABARA";
	cin >> s;
	i = 0;
	j = 0;
	while (s[i] != '\0'&&j < 9) {
		if (s[i] == t[j]) {
			i++;
			j++;
		}
		else if (t[j] == 'A')
			j++;
		else {
			cout << "NO" << endl;
			return 0;
		}
	}
	if (s[i] == '\0'&&j>=8)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll fast_int()
{
	ll x;
	scanf("%lld",&x);
	return x;
}
void fast_out(ll x)
{
	printf("%lld",x);
}

int main()
{
    ll k,n;
    k=fast_int();
    n=fast_int();
    vector<ll>v(n),v1(n);
    for(ll i=0;i<n;i++)
    {
       scanf("%lld",&v[i]);
    }
    v1[0]=v[n-1]-v[0];
    for(ll i=1;i<n;i++)
    {
        v1[i]=k-(v[i]-v[i-1]);
    }
    sort(v1.begin(),v1.end());
    fast_out(*v1.begin());
}

Measured memory_bytes: 3328
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<iomanip>
//<< setprecision(5)
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<-1<<endl;return 0
const int mod=1000000007;
const int big=1e9+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	llint n,L,K,i;cin>>n>>L>>K;
	llint ans=0;
	vector<pair<llint,llint>>retu(n+2);
	vector<llint>wa(n+2);
	retu[0]=mp(0L,0L);retu[n+1]=mp(0L,0L);
	for(i=1;i<=n;i++){
		llint a,d;cin>>a>>d;retu[i]=mp(a,d);
		wa[i]=wa[i-1]+a*L+d*L*(L-1)/2;
	}
	wa[n+1]=wa[n];
	//????????????????????????,??????????°?????????????
	llint kan=K/L;llint ama=K%L;
	for(i=0;i+kan+1<=n+1;i++){//i????°?????????????
		llint ou=wa[i+kan]-wa[i];//?????¨???????????????????????????
		maxeq(ans,ou+retu[i+kan+1].fir*ama+retu[i+kan+1].sec*ama*(ama-1)/2);
		maxeq(ans,ou+(retu[i].fir+retu[i].sec*L)*ama-retu[i].sec*ama*(ama+1)/2);
		llint dx=retu[i].sec-retu[i+kan+1].sec;//dx?????£????????¶
		llint sy=retu[i].fir+retu[i].sec*L-retu[i+kan+1].fir-retu[i+kan+1].sec*ama;//??£????????¶
		//cout<<"de"<<ans<<" "<<dx<<" "<<sy<<endl;
		if(dx<=0||sy<=0){continue;}
		llint mae=sy/dx;
		if(mae<=0||ama<=mae){continue;}
		llint syo=retu[i].fir+retu[i].sec*(L-mae);//??????
		ou+=syo*mae+retu[i].sec*mae*(mae-1)/2;
		llint ato=ama-mae;
		ou+=retu[i+kan+1].fir*ato+retu[i+kan+1].sec*ato*(ato-1)/2;
		maxeq(ans,ou);
	}
	kan--;ama+=L;//?????????????°????????????? kan?????????????????????
	for(i=0;i+kan+1<=n+1;i++){//i????°?????????????
		//cout<<"de"<<ans<<endl;
		llint ou=wa[i+kan]-wa[i];//?????¨???????????????????????????
		llint dx=retu[i].sec-retu[i+kan+1].sec;//dx?????£????????¶
		llint sy=retu[i].fir+retu[i].sec*L-retu[i+kan+1].fir-retu[i+kan+1].sec*ama;//??£????????¶
		if(dx<=0||sy<=0){continue;}
		llint mae=sy/dx;
		if(mae<=ama-L||L<=mae){continue;}
		llint syo=retu[i].fir+retu[i].sec*(L-mae);//??????
		ou+=syo*mae+retu[i].sec*mae*(mae-1)/2;
		llint ato=ama-mae;
		ou+=retu[i+kan+1].fir*ato+retu[i+kan+1].sec*ato*(ato-1)/2;
		maxeq(ans,ou);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5204
import java.util.*;

public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int plus = X;
        while (true) {
            if (boolPrimeNumber(plus)){
                System.out.println(plus);
                break;
            }
            plus++;
        }
    }

    public static boolean boolPrimeNumber (int x){
        for (int i = 2; i < (int) Math.sqrt(x); i++){
            if (x % i == 0){
                return false;
            }
        }
        return true;
    }
}

Measured memory_bytes: 35608
#include <iostream>
#include <cstdlib>

int main() {
    int a, b, c, d, e, k;
    std::cin >> a >> b >> c >> d >> e >> k;

    // std::cout << (e - a <= k ? "Yay!" : ":(") << std::endl;
    if (e - a <= k) {
        std::cout << "Yay!" <<std::endl;
    } else {
        std::cout << ":(" << std::endl;
    }
}

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

int main() {
  int s;
  cin >> s ;
  //s no ue niketa
  int a = s/100;
  //s no sita niketa
  int b = s%100;
  if (0<a && a<13){
    if(0<b && b<13){
    cout << "AMBIGUOUS" << endl;
    }
    else {
      cout << "MMYY" << endl;
    }
  }
  else if(0<b && b<13){
    cout << "YYMM" << endl;
    }
    else {
      cout << "NA" << endl;
    }
}


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

int main() 
{
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	ll sum=0;
	if(a>=k)
	{
	    sum=sum+k;
	}
	else if(a+b>=k)
	{
	    sum=sum+a;
	}
	else if(a+b+c>=k)
	{
	    sum=sum+a-(k-a-b);
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3480
#include <iostream>
using namespace std;
int main() {
    int n, m, k, l;
    cin >> n >> m;
    int a[31]={0};
    for(int i=0; i<n; i++) {
        cin >> k;
        for(int j=0; j<k; j++) {
            cin >> l;
            a[l]++;
        }
    }
    int cnt=0;
    for(int i=0; i<31; i++) {
        if(a[i]==n) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256