akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>

using namespace std;

#define int long long
#define dotimes(i, n) for (int i = 0, i##max__ = (n); i < i##max__; i++)
#define whole(f, x, ...) ([&](decltype((x)) c) { return (f)(begin(c), end(c), ## __VA_ARGS__); })(x)

int rint() {
  int x;
  scanf("%lld", &x);
  return x;
}

void wint(int x) {
  printf("%lld\n", x);
}

template<typename T> int size(T const& c) { return static_cast<int>(c.size()); }
template <typename T> bool maxs(T& a, T const& b) { return a < b ? a = b, true : false; }
template <typename T> bool mins(T& a, T const& b) { return a > b ? a = b, true : false; }

class fenwick_tree {
  vector<int> a;
public:
  fenwick_tree(int n) : a(n+1) {}
  void add(int i, int x) {
    int n = ::size(a) - 1;
    for (; i <= n; i += i & -i)
      a[i] += x;
  }
  int psum(int i) const {
    int r = 0;
    for (; i > 0; i -= i & -i)
      r += a[i];
    return r;
  }
};

signed main() {
  const int n = rint();
  const int q = rint();
  fenwick_tree ft(n);
  dotimes(i, q) {
    const int com = rint();
    const int x = rint();
    const int y = rint();
    if (com)
      wint(ft.psum(y) - ft.psum(x-1));
    else
      ft.add(x, y);
  }
  return 0;
}



Measured memory_bytes: 3192
n = gets.to_i
nums = gets.split.map(&:to_i)
dists = Array.new(n, 0)

current_dist = 0
max_dist_idx = 0
max_dist = -1
last = 10**10



(n - 1).downto(0) do |idx|
    i = nums[idx]
    if last > i
        # last = i
        current_dist = 0
    end
    dists[idx] = current_dist
    if current_dist > max_dist
        max_dist_idx = idx
        max_dist = current_dist 
    end
    last = i
    current_dist += 1
end

puts max_dist

Measured memory_bytes: 9348
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <cstdlib>
#include <stack>
#include <queue>
#include <list>
#include <set>
using namespace std;
#define llong long long int

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s, t; cin >> s >> t;
    for (int i=0; i<s.size(); ++i) {
        if (s[s.size()-1] + s.substr(0, s.size()-1) == t) {
            cout << "Yes" << endl;
            return 0;
        }
        s = s[s.size()-1] + s.substr(0, s.size()-1);
        //cout << s << endl;
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 384
{-# LANGUAGE BangPatterns #-}

import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import Data.Bits
import Control.Monad
import Control.Monad.ST

swap :: (VUM.Unbox a) => (a -> Bool) -> VUM.MVector s a -> ST s Int
swap f vec = loopl 0 (VUM.length vec - 1)
  where
    loopl x y | x > y = return x
    loopl x y = do
      vx <- VUM.unsafeRead vec x
      if (f vx) then
        loopl (x+1) y
      else
        loopr x y vx
    loopr x y vx | x > y = return x
    loopr x y vx = do
      vy <- VUM.unsafeRead vec y
      if not (f vy) then
        loopr x (y-1) vx
      else do
        VUM.unsafeWrite vec x vy
        VUM.unsafeWrite vec y vx
        loopl (x+1) (y-1)

sums :: Int -> VU.Vector Int -> ST s (VUM.MVector s Int)
sums n as = do
  vec <- VUM.new $ (n * (n + 1)) `div` 2
  let loop !i !x !y !prevSum
        | y < n = do VUM.unsafeWrite vec i newSum
                     loop (i+1) x (y+1) newSum
        | x < n = loop i (x+1) (x+1) 0
        | otherwise = return ()
        where
          newSum = prevSum + as VU.! y
  loop 0 0 0 0
  return vec
  

query :: Int -> Int -> VU.Vector Int -> Int
query n k as = runST $ do
  svec <- sums n as
  loop svec 39 0
  where
    loop _ (-1) acc = return acc
    loop svec !lev !acc = do
      t <- swap (`testBit` lev) svec
      if k <= t then
        loop (VUM.take t svec) (lev - 1) (acc `setBit` lev)
      else
        loop svec (lev - 1) acc

main = do
  [n,k] <- map read . words <$> getLine
  as <- VU.unfoldrN n (BS.readInt . BS.dropWhile (==' ')) <$> BS.getLine
  putStrLn $ show $ query n k as


Measured memory_bytes: 4732
#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    // 1つの数字
    let n: usize =  {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.parse().unwrap()
    };

    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let s = s.trim_right().to_owned();

    let mut count = 0;
    let mut prev_char = '0';
    for c in s.chars() {
        if c != prev_char {
            count += 1;
            prev_char = c;
        }
    }

    println!("{}", count)
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
template<class T>using numr=std::numeric_limits<T>;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    std::vector<lint>a(n);
    for(lint&x:a)std::cin>>x;
    lint sum=std::accumulate(ALL(a),0ll);
    for(lint X=std::max(0ll,sum-n*(n-1));X<=sum;X++){
        lint cnt=0;
        bool ng=false;
        for(lint x:a){
            x+=X;
            if(x%(n+1)==n){
                ng=true;
                break;
            }
            cnt+=x/(n+1);
        }
        if(ng)continue;
        if(cnt==X){
            std::cout<<X<<'\n';
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

class Union_Find{
private:
    vector<int> par, rank;


public:
    Union_Find(int Max_Node){
        par.resize(Max_Node);
        rank.resize(Max_Node);
        for(int i = 0; i < Max_Node; i++){
            par[i] = i;
            rank[i] = 0;
        }
    }

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

    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y)return ;

        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y])rank[x]++;
        }
    }

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


int main(){
  int N, M;
  cin >> N >> M;
  Union_Find uf(N + 10);
  int X, Y, Z;
  for(int i = 0; i < M; i++) {
    cin >> X >> Y >> Z;
    uf.unite(X, Y);
  }
  set<int> se;
  for(int i = 1; i <= N; i++) {
    se.insert(uf.find(i));
  }
  cout << se.size() << endl;
  return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const string YES = "Yes";
const string NO = "No";
const ll mod = 1e9+7;



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

    int a, b; cin >> a >> b ;
    if (a>b) {
        REP(i,a) cout <<  b;
        return 0;
    }
    else{
        REP(i,b) cout << a;
        return 0;
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

const int MAX_V=100000;
const int INF=1e18;
struct edge{ int to,cost; };

int V,E,dist[MAX_V];
vector<edge> G[MAX_V];

void dijkstra(int s)
{
    REP(i,V) dist[i]=INF; 
    dist[s]=0;
    priority_queue<pint,vector<pint>,greater<pint>> Q;
    Q.push(pint(0,s));

    while(!Q.empty()){
        pint p=Q.top(); Q.pop();
        int v=p.second;
        if(p.first>dist[v]) continue;
        for(edge e:G[v]){
            if(dist[e.to]>dist[v]+e.cost){
                dist[e.to]=dist[v]+e.cost;
                Q.push(pint(dist[e.to],e.to));
            }
        }
    }
}

signed main()
{   
    int r; cin>>V>>E>>r;
    REP(i,E){
        int a,b,c; cin>>a>>b>>c;
        G[a].push_back((edge){b,c});
    }
    dijkstra(r);
    REP(i,V){
        if(dist[i]==INF) cout<<"INF"<<endl;
        else cout<<dist[i]<<endl;
    }
}


Measured memory_bytes: 19544
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m;
struct node{
	ll x,y,num;
	char ans[15];
}a[100005];
int cmp_1(node a,node b){
	if (a.x!=b.x) return a.x<b.x;
	return a.y<b.y;
}
int cmp_2(node a,node b){
	return a.num<b.num;
}
void build(node &a,int p){
	ll z=1000000000000+a.x*1000000+p;
	for (int i=12;i>=1;i--)
		a.ans[i]='0'+z%10,z/=10;
}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++)
		scanf("%lld%lld",&a[i].x,&a[i].y),a[i].num=i;
	sort(a+1,a+1+m,cmp_1);
	int num=1;
	a[0].x=a[1].x-1;
	for (int i=1;i<=m;i++){
		if (a[i].x==a[i-1].x)
			num++;else num=1;
		build(a[i],num);
	}
	sort(a+1,a+1+m,cmp_2);
	for (int i=1;i<=m;i++)
		puts(a[i].ans+1);
}

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

int main(){
	ios::sync_with_stdio(0);
	int N;
	cin>>N;
	int min=INT_MAX;
	for(int i=1;i<N;++i){
		string S,T;
		S=to_string(i);
		T=to_string(N-i);
		int sum=0;
		for(int k=0;k<S.size();++k){
			sum+=S.at(k)-'0';
		}
		for(int k=0;k<T.size();++k){
			sum+=T.at(k)-'0';
		}
		if(sum<min)min=sum;
	}
	cout<<min<<"\n";
	return 0;
}

Measured memory_bytes: 256
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return map(int,input().split())
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

N,M = mint()
student = [0]*N
point = [0]*M
for i in range(N):
    x,y = mint()
    student[i] = (x,y)
for j in range(M):
    x,y = mint()
    point[j] = (x,y)
    
ans = [0]*N
for i in range(N):
    x1,y1 = student[i]
    tmp = INF
    k = 0
    for j in range(M):
        x2,y2 = point[j]
        if abs(x1-x2)+abs(y1-y2)<tmp:
            tmp = abs(x1-x2)+abs(y1-y2)
            k = j+1
    ans[i] = str(k)

lprint(ans)

Measured memory_bytes: 67304
M, D = map(int, input().split())

ans = 0
for m in range(1, M+1):
    for d in range(1, D+1):
        d1 = d%10
        d2 = (d-d1)//10
        if d1>=2 and d2 >= 2 and d1*d2 == m:
            ans += 1
print(ans)

Measured memory_bytes: 2940
H,N = map(int,input().split())
magics = [list(map(int,input().split())) for _ in range(N)]

max_A = max(a for a,b in magics)
INF = 10**10
DP = [INF]*(H+max_A)
DP[0] = 0

for i in range(1,H+max_A):
    DP[i] = min(DP[i-a] + b for a,b in magics)
    
ans = min(DP[H:])
print(ans)


Measured memory_bytes: 3832
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val N = sc.nextInt()
    val L = sc.nextInt()

    var S = listOf<String>()
    for(i in 0..(N-1)){
        S += sc.next()
    }
    S = S.sortedBy{it}
    for(i in S){
        print(i)
    }
    println()

}

Measured memory_bytes: 37936
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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




// ***************************************


int main(){

    int A, B;
    cin >> A >> B;
    cout << A * B << endl;

    return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 410
int n,h;
int in[MAXN],out[MAXN],cnt[MAXN],fa[MAXN];
int Find(int x)
{
	return fa[x]==0?x:fa[x]=Find(fa[x]);
}
int main()
{
	int a,b,c,d,x,y;
	scanf("%d%d",&n,&h);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d%d%d",&a,&b,&c,&d);
		x=c==0?a:(c+200);
		y=d==0?(b+200):d;
		in[y]++,out[x]++;
		x=Find(x),y=Find(y);
		if(x!=y)
			fa[x]=y;
	}
	bool f=1;
	for(int i=1;i<=400;i++)
		if(in[i]!=out[i])
		{
			if((in[i]<out[i]&&i>200)||(in[i]>out[i]&&i<200))
			{
				f=0;
				break;
			}
			int x=Find(i);
			cnt[x]++;
		}
	if(f)
	{
		for(int i=1;i<=400;i++)
			if((in[i]||out[i])&&cnt[Find(i)]==0)
			{
				f=0;
				break;
			}
	}
	if(f) printf("YES\n");
	else printf("NO\n");
}

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

using mint= atcoder::modint998244353;
constexpr int Nmax= 200'000; // '

struct S{
  mint mS_rep;
  int  mS_digit;
};

struct F{
  mint mF_assign;
  bool mF_id;
};

vector<mint> g_aux(Nmax+ 1);
void init(){
  g_aux.at(1)= 1;
  for(int i= 2; i<= Nmax; i++){
    g_aux.at(i)= g_aux.at(i-1)*mint(10) + mint(1);
  }
}

S op(S left, S right){ return S{left.mS_rep*mint(10).pow(right.mS_digit) + right.mS_rep, left.mS_digit+ right.mS_digit}; };

S e(){ return S{0, 0}; };

S mapping(F f, S s){
  if(f.mF_id){ return s; }
  else{
    return S{f.mF_assign* g_aux.at(s.mS_digit), s.mS_digit};
  }
};

F composition(F f2, F f1){
  if(f2.mF_id){ return f1; }
  else        { return f2; }
};

F id(){ return F{0, true}; };

int main(){
  init();

  int N,Q;
  cin >> N >> Q;

  atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(vector<S>(N, S{1,1}));

  int bufL,bufR,bufD;
  for(int q=0; q<Q; q++){
    cin >> bufL >> bufR >> bufD;
    bufL--; // [bufL,bufR] 1-indexed -> [bufL,bufR) 0-indexed
    seg.apply(bufL, bufR, F{bufD, false});

    cout << seg.all_prod().mS_rep.val() << endl;
  }
}

Measured memory_bytes: 11748
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >

using namespace std;

int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};

const long double Pi=acos(-1),e=2.718;
const int N=2e3+10, mod=1e9+7;

int main ()
{
    FASTIO
    ll n,k,sum=1;
    cin >> n >> k;
    for(ll i=k;i<=n;i++){
        ll x = (i)*(i-1)/2;
        ll y = (i)*(n+(n-i+1))/2;
        sum += y-x+1;
        sum %= mod;
    }
    cout << sum << endl;
    return 0;
}
/**

*/


Measured memory_bytes: 3616
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	int n; cin >> n;
	VI p(n); rep(i, n)cin >> p[i];

	int ans;
	for (int i = n; i >= 0; i--) {

		int cnt = 0;
		rep(j, n)if (p[j] >= i)cnt++;

		if (i <= cnt) {
			ans = i;
			break;
		}
	}

	Cout(ans);
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  int n, k;
  cin >> n >> k;
  vector<int> cnt(200005);
  REP(i,n){
    int a;
    cin >> a;
    cnt[a]++;
  }

  sort(RALL(cnt));
  int ans = 0;
  REP2(i, k,200005){
    ans += cnt[i];
    if(cnt[i] == 0) break;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4056
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    string input_str;
    cin >> input_str;
    int max_len = 0;
    int cur_len = 0;
    for (int i = 0; i < input_str.size(); i++)
    {
        char chr = input_str[i];
        if (chr == 'A' || chr == 'T' || chr == 'G' || chr == 'C')
        {
            cur_len++;
        }
        else
        {
            cur_len = 0;
        }
        if (max_len < cur_len)
        {
            max_len = cur_len;
        }
    }
    cout << max_len;
    return 0;
}

Measured memory_bytes: 256
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let mut ans = std::i64::MAX;
    let mut p = 1;
    while p+p <= n {
    	let mut x = p;
    	let mut y = n - x;
        let mut sum = 0;
        while x > 0 {
        	sum += x % 10;
            x /= 10;
        }
        while y > 0 {
        	sum += y % 10;
            y /= 10;
        }
        ans = std::cmp::min(ans, sum);
        p += 1;
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
import sys
sys.setrecursionlimit(10**6)
def dfs(tree, n, ans):
    for i in tree[n]:
        ans[i] += ans[n]
        tree[i].remove(n)
        dfs(tree, i, ans)
 
n, q = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n-1)]
px = [list(map(int,input().split())) for _ in range(q)]
 
g = [[] for _ in range(n)]
for i in range(n-1):
    g[ab[i][0]-1].append(ab[i][1]-1)
    g[ab[i][1]-1].append(ab[i][0]-1)
 
ans = [0]*n
for i in range(q):
    ans[px[i-1][0]-1] += px[i-1][1]
dfs(g, 0, ans)
 
print(*ans)

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

using namespace std;

int a[100001][3],n;
int dp[100001][3];

int go(int i,int k)
{
	if(i>=n)
	  return 0;
	else
	  {if(dp[i][k]==-1) 
	  	{
	  	 if(k==0)
	  	   dp[i][k]=a[i][k]+max(go(i+1,1),go(i+1,2));
	  	 else if(k==1)
	  	   dp[i][k]=a[i][k]+max(go(i+1,0),go(i+1,2));
	  	 else
	  	   dp[i][k]=a[i][k]+max(go(i+1,1),go(i+1,0));
	    }
	    return dp[i][k];
	  }
}

int main()
{   cin>>n;
   memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++)
	  {
	  	 cin>>a[i][0]>>a[i][1]>>a[i][2];
	  }
	cout<<max(go(0,0),max(go(0,1),go(0,2)));  
	return 0;
}

Measured memory_bytes: 7296
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
	Scanner scan = new Scanner(System.in);
	int x = scan.nextInt();
	int y = x/60;
	x %= 60;
	int z  = y/60;
	y %= 60;
	System.out.println(z+":"+y+":"+x);
	}
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

int main() {
	int W, H, N;
	scanf("%d %d %d", &W, &H, &N);
	int ans = 0;
	int nx, ny, X, Y;
	scanf("%d %d", &X, &Y);
	nx = X; ny = Y;
	FOR(i, 1, N) {
		scanf("%d %d", &X, &Y);
		if((nx < X && ny < Y) || (nx > X && ny > Y)) {
			ans += min(abs(nx - X), abs(ny - Y));
			int tmp = min(abs(nx - X), abs(ny - Y));
			if(nx < X && ny < Y) {
				nx += tmp; ny += tmp;
			}
			else {
				nx -= tmp; ny -= tmp;
			}
		}
		ans += abs(nx - X) + abs(ny - Y);
		nx = X; ny = Y;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3176
def solve():
    N = int(input())
    W = [int(i) for i in input().split()]
    sumW = sum(W)
    key = 0
    for i in range(len(W)):
        if sumW / 2 < sum(W[:i + 1]):
            key = i
            break
    print(min(abs(sum(W[:key]) - sum(W[key:])),
              abs(sum(W[:key + 1]) - sum(W[key + 1:]))))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    unsigned int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; ++i)  cin >> a[i];

    unsigned int count = 0;
    unsigned int ans = 1;

    for(int i = 0; i < N; ++i){
        ans = a[ans - 1];
        ++count;

        if(ans == 2){
            cout << count << endl;
            return 0;
        }
    }
  
 	cout << -1 << endl;

    return 0;
}

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

int main() {
  int q;
  cin >> q;
  while(q--){
    int n,m;
    cin >> n >> m;
    int nm = n*n+m*m;
    vector <int> num;
    for(int i=0;i*i<=nm;i++)
      for(int j=i;j*j<=nm;j++){
	if(i+j == 0)continue;
	if(nm%(i*i+j*j) == 0)num.push_back(i*i+j*j);
      }

    int ans = 0;
    for(int i=0;i<num.size();i++)
      for(int j=i;j<num.size();j++)
	if(num[i]*num[j] == nm)  ans+=2;

    if(ans  == 2)  cout << 'P'<<endl;
    else cout <<"C"<<endl;
  }

  return 0;
}  

Measured memory_bytes: 1212
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
ll gcd(ll a, ll b)
{
	if(a == 0)
		return b;
	return gcd(b%a, a);
}
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a, b;
    cin>>a>>b;
    ll h = gcd(a, b);
    cout<<(a*b)/h<<endl;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rep(I, N) for (ll I = 0; I < (N); ++I)
#define repp(I, a, B) for (ll I = (a); I <= (B); ++I)
#define inn ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);srand(time(NULL));cout<<fixed<<setprecision(10);clock_t clk;clk = clock();
#define outt clk=clock()-clk;cerr<<fixed<<setprecision(6)<<"Time: "<<((double)clk)/CLOCKS_PER_SEC<<"\n";return 0;
using namespace std;
#define TRACE
#ifdef TRACE
#define t(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define t(...)
#endif
const int N = 2e5 + 5;
const int MAX = 2e6 + 5;
const int MOD = 1000000007;

//

signed main()
{
    inn;

    double a, b;
    cin >> a >> b;
    cout << a / b;

    outt;
}

Measured memory_bytes: 256
N = int(input())
TA = []
for _ in range(N):
    t, a = map(int, input().split())
    TA.append([t, a])

t0, a0 = 1, 1
for t, a in TA:
    t0 = -(-t0 // t) * t
    a0 = -(-a0 // a) * a
    if t0 / a0 < t / a:
        t0 = t * a0 // a
    else:
        a0 = a * t0 // t

ans = t0 + a0
print(ans)


Measured memory_bytes: 3060
/*Bismillahir Rahmanir Rahim*///{
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std; using __gnu_cxx::power;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1; const double eps = 1e-6, ldeps = 1e-9;
struct Dbg { static constexpr auto &os = cout;   // replace by cerr in interactive.
template<class C> static auto o(C *x)->decltype(os << *x, 0);
template<class C> static char o(...);
template<class C> typename enable_if<sizeof o<C>(0)!=1,Dbg&>::type operator<<(const C &x) {os<<x; return *this;}
template<class C> Dbg &dump(C b, C e) {
    for (struct{C i;int j;} i={(*this<<"\n[",b),0}; i.i!=e and i.j<26; i.i++, i.j++) *this<<", "+2*(i.i==b)<<*i.i;
    return *this << ']';
}
template<class C> typename enable_if<sizeof o<C>(0)==1, Dbg&>::type operator<<(const C &x) {
    return dump(begin(x), end(x));
}
template<class C, size_t X> typename enable_if<!is_same<C, const char>::value, Dbg&>::type operator<<(C (&x)[X]) {
    return dump(begin(x), end(x));
}
template<class B, class C> Dbg &operator<<(const pair<B, C> &x) {return *this<<'{'<<x.first<<", "<<x.second<<'}';}
Dbg &operator<<(ostream&(*x)(std::ostream&)) { os << x; return *this; }
} dbg;
void err(istringstream *iss) { delete iss; }
template<class C, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args...);
}
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl
#define cbug(a, args...) if (a) bug(args);
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
int T, Q, cn;//}
const int inf = 1000000007, mxn = 200005;

int n;
vector<int> g[mxn];

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    cin >> n;
    for (int i = 0; i < n-1; i++) {
        int u, v;
        cin >> u >> v;
        if (u > v) swap(u, v);
        g[u].push_back(v);
    }

    ll ans = 0, cur = 0;
    for (int i = n; i >= 1; i--) {
        int o = n-i+1;
        ans += o*ll(o+1)/2;
        for (auto &j : g[i]) {
            cur -= n-j+1;
        }
        ans += cur;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 14528
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int X, Y;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> X >> Y;
    int ans = X + Y / 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cctype>
#include<cstring>
using namespace std;
class EmacsLikeEditor{
 public:
  vector<string> text;
  int cur;
  int line;
  string buf;
  EmacsLikeEditor(const vector<string> &vs){
    cur = 0;
    line = 0;
    buf = "";
    for(int i = 0; i < vs.size(); ++i){
      text.push_back( "" );
      for(int j = 0; j < vs[i].length(); ++j){
	//if( !iscntrl( vs[i][j] ) ){
	  text[i] += vs[i][j];
	  //}
      }
      text[i] += "$";
    }
  }
  void Command(char c){
    switch( c ){
    case 'a': MoveLineFront(); break;
    case 'e': MoveLineEnd(); break;
    case 'p': MoveAbove(); break;
    case 'n': MoveBelow(); break;
    case 'f': MoveFront(); break;
    case 'b': MoveBack(); break;
    case 'd': Delete(); break;
    case 'k': CutLine(); break;
    case 'y': Paste(); break;
    default:
      break;
    }
  }
  bool ExistAboveLine(){ return line > 0; }
  bool ExistBelowLine(){ return line < text.size() - 1; }
  bool FrontOfLine(){ return cur == 0; }
  bool EndOfLine(){ return cur == text[line].size() - 1; }

  void MoveLineFront(){ cur = 0; }
  void MoveLineEnd(){ cur = text[line].size() - 1; }

  void MoveAbove(){ if( ExistAboveLine() ){ --line; } MoveLineFront(); }
  void MoveBelow(){ if( ExistBelowLine() ){ ++line; } MoveLineFront(); }

  void MoveFront(){ if( !EndOfLine() ){ ++cur; }else{ if( ExistBelowLine() ){ ++line; cur = 0; } } }
  void MoveBack(){ if( !FrontOfLine() ){ --cur; }else{ if( ExistAboveLine() ){ --line; cur = text[line].size()-1; } } }

  void Delete(){
    if( !EndOfLine() ){ text[line].erase( text[line].begin() + cur );
    }else if( ExistBelowLine() ){
      text[line].erase( text[line].end() - 1 );
      for(int i = 0; i < text[line+1].length(); ++i){
	text[line]+=text[line+1][i];
      }
      text.erase( text.begin() + line + 1 );
    }
  }
  void CutLine(){
    if( EndOfLine() ){
      if( ExistBelowLine() ){ buf="$"; Delete(); }
    }else{
      buf = string( text[line].begin() + cur, text[line].end() - 1 );
      text[line].erase( text[line].begin() + cur, text[line].end() - 1 );
      cur = text[line].size() - 1;
    }
  }
  void Paste(){
    if( buf == "" ) return ;
    else{
      if( buf == "$" ){
	text.insert( text.begin() + line + 1, string(text[line].begin() + cur, text[line].end()) );
	text[line].erase( text[line].begin() + cur, text[line].end() - 1);
	++line;
	cur = 0;
      }else{
	text[line].insert( text[line].begin() + cur, buf.begin(), buf.end() );
	cur += buf.length();
      }
    }
  }
  
};
int main()
{

  vector<string> vs;
  while(true){
    string s;
    getline(cin,s);
    //while(iscntrl(s[s.length()-1]))s.erase(s.end()-1);
    if( s == "END_OF_TEXT" ) break;
    vs.push_back( s );
  }
  EmacsLikeEditor ele(vs);
  while(true){
    char command;
    cin >> command;
    if( command == '-' ) break;
    ele.Command( command );
  }

  for(int i = 0; i < ele.text.size(); ++i){
    ele.text[i].erase( ele.text[i].end() - 1 );
    cout << ele.text[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 0
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func getNextWord(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextWord(scanner))
	return i
}
func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	ss := make([]int, n)
	for i := 0; i < n; i++ {
		ss[i] = getNextInt(scanner)
	}
	mergeSort(ss, 0, n)
	fmt.Fprintln(writer, strings.Trim(fmt.Sprintf("%v", ss), "[]"))
	fmt.Fprintln(writer, cnt)

	writer.Flush()
}

var ll [500001]int
var rr [500001]int
var cnt int

func merge(a []int, l, m, r int) {
	n1 := m - l
	n2 := r - m
	ll[n1] = 1000000000
	rr[n2] = 1000000000
	for i := 0; i < n1; i++ {
		ll[i] = a[l+i]
	}
	for i := 0; i < n2; i++ {
		rr[i] = a[m+i]
	}
	i, j := 0, 0
	for k := l; k < r; k++ {
		cnt++
		if ll[i] <= rr[j] {
			a[k] = ll[i]
			i++
			continue
		}
		a[k] = rr[j]
		j++
	}
}

func mergeSort(a []int, l, r int) {
	if l+1 < r {
		m := (l + r) >> 1
		mergeSort(a, l, m)
		mergeSort(a, m, r)
		merge(a, l, m, r)
	}
}



Measured memory_bytes: 39528
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
int main(){
  int a[3];
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  if(a[0]==a[1] or a[1]==a[2]){
    if(a[0]==a[1]){
      if(a[1]!=a[2])
        cout<<"Yes";
      else
        cout<<"No";
    }
    else{
      if(a[0]!=a[1])
        cout<<"Yes";
      else
        cout<<"No";
    }
  }
  else{
    cout<<"No";
  }
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nm = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            for (var i = nm[1] / nm[0]; i >= 1; i--)
            {
                if (nm[1] % i == 0)
                {
                    Console.WriteLine(i);
                    return;
                }
            }
        }

        static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll x;
  cin>>x;
  for(ll a=-200;a<200;a++){
    for(ll b=-200;b<200;b++){
      ll tmp=pow(a,5)-pow(b,5);
      if(x==tmp){
        cout<<a<<' '<<b<<'\n';
        return(0);
      }
    }
  }
  return(0);
}


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

struct item{
    int wt;
    int val;
};
int solve(vector<item> &ar, int n, int W)
{  int maximum_value=n*1000;
    int dp[n+1][maximum_value+1];
    //memset(dp, 0, sizeof dp);
    for(int val=0;val<=maximum_value;val++){
        dp[1][val]= INT_MAX;
    }
    dp[1][0]=0;
    dp[1][ar[1].val]=ar[1].wt;


    for(int i=2;i<=n;++i){
        for(int v=0;v<=maximum_value;v++){
            dp[i][v]=dp[i-1][v];
             if(ar[i].val>v){
                 continue;
             }
             dp[i][v]=min(dp[i][v], ar[i].wt+ dp[i-1][v-ar[i].val]);
        }
    }

     int ans=0;
    for(int x=0;x<=maximum_value;x++){
       if(dp[n][x]<=W){
           ans=x;
       }
    }
    return ans;
}



int32_t main() {
    int n,w; cin>>n>>w;
    vector<item> ar(n+1);
    for(int i=1;i<=n;++i){
        cin>>ar[i].wt>>ar[i].val;
    }
    cout<<solve(ar,n,w);



    return 0;
}


Measured memory_bytes: 81744
s = input()
K = int(input())
 
substrings = set()
 
for i in range(len(s)):
    for j in range(i+1, min(len(s)+1, i+K+1)):
        substrings.add(s[i:j])
 
substrings_list = sorted(list(substrings))
print(substrings_list[K-1])


Measured memory_bytes: 4592
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

char S[100001];
int ans[1000001];

int main(){
  int len;
  scanf("%s",S);
  len = strlen(S);
  for (int i=0; i<len;) {
    int r_len = 0;
    int l_len = 0;
    int r_end = 0;
    while (i<len && S[i] == 'R') {
      r_len++;
      ans[i] = 0;
      i++;
    }
    r_end = i-1;
    while (i<len && S[i] == 'L') {
      l_len++;
      ans[i] = 0;
      i++;
    }
    ans[r_end] = r_len/2 + l_len/2 + r_len%2;
    ans[r_end+1] = r_len/2 + l_len/2 + l_len%2;
  }
  for (int i=0; i<len; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}

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

const int N=1010;
const int mod=1000000007;
typedef long long ll;
int C[N][N],f[N],g[N],n,m,K,F[N],a[N],b[N],fa[N],se[N];
bitset<N>sz[N];
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
int ksm(ll a,int b,int c=1){
	for(;b;b/=2,a=a*a%mod)
		if(b&1)c=c*a%mod;
	return c;
}
void Init(){
	for(int i=0;i<N;++i){
		C[i][0]=1;
		for(int j=1;j<=i;++j)C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
	for(int i=0;i<=m;++i)g[i]=C[i+K-1][i];
	for(int i=1;i<=m;++i){
		for(int j=0;j<i;++j)
			f[i]=(f[i]+ksm(K,__gcd(i,j)))%mod;
		f[i]=ksm(i,mod-2,f[i]);
	}
}
int flag[N];
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>m>>K;Init();
	int ans=1;
	for(int i=1;i<=m;++i)cin>>a[i]>>b[i];
	for(int i=1;i<=m;++i){
		for(int j=1;j<=n;++j)fa[j]=j;
		for(int j=1;j<=m;++j)if(i!=j){
			int u=find(a[j]),v=find(b[j]);
			fa[u]=v;
		}
		if(find(a[i])==find(b[i]))flag[i]=1;
		else ans=(ll)ans*K%mod;
	}
	for(int i=1;i<=m;++i)F[i]=i,sz[i][a[i]]=sz[i][b[i]]=1,se[i]=1;
	for(int i=1;i<=m;++i)if(flag[i]){
		int I=i;for(;F[I]!=I;I=F[I]);
		for(int j=i+1;j<=m;++j)if(flag[j]&&(a[i]==a[j]||a[i]==b[j]||b[i]==a[j]||b[i]==b[j])){
			int u,v,w;
			if(a[i]==a[j]||a[i]==b[j])u=b[i];else u=a[i];
			if(a[j]==a[i]||a[j]==b[i])v=b[j];else v=a[j];
			w=a[i]+b[i]-u;
			for(int k=1;k<=n;++k)fa[k]=k;
			for(int k=1;k<=m;++k)if(a[k]!=w&&b[k]!=w){
				int t=find(a[k]),s=find(b[k]);
				fa[t]=s;
			}
			if(find(u)==find(v)){
				int J=j;for(;F[J]!=J;J=F[J]);
				if(I==J)continue;
				sz[J]|=sz[I];se[J]+=se[I];
				F[I]=J;I=J;
			}
		}
	}
	for(int i=1;i<=m;++i)if(flag[i]&&F[i]==i){
		int siz=sz[i].count();
		if(siz!=se[i])ans=(ll)ans*g[se[i]]%mod;
		else ans=(ll)ans*f[se[i]]%mod;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if((a-b)<=c){
        cout<<c-(a-b)<<endl;
    }
    else if((a-b)>c){
        cout<<"0"<<endl;
    }
}

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

// varibable settings
#define int long long
const int INF=1e18;
const int MOD=1e9+7;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

bool is_prime(int n) {/*{{{*/
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return n != 1;
}/*}}}*/

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

  set<int> d;
  set<int> d2;
  for(int i=1; i*i<=n; i++){
    if (n%i==0){
      d.insert(i);
      if (is_prime(n/i)) d2.insert(i);

      d.insert(n/i);
      if (is_prime(n/(n/i))) d2.insert(n/i);
    }
  }
  d.erase(n);
  d2.erase(n);
  dump(d);
  dump(d2);

  int M = sz(d);
  int m = sz(d2);
  cout << m << " " << M << endl;
  return 0;
}



Measured memory_bytes: 3240
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#include <math.h>
#define ll long long
#define PI 3.14159265358979323846
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
using namespace std;

double deg2rad(double degree)
{
    return degree * PI / 180.0;
}


int main() {
    double A, B, H, M;
    double ans;
    cin >> A >> B >> H >> M;
    double longkaku, smallkaku;
    double degree;
    longkaku = H * 30 + M * 0.5;
    smallkaku = M * 6;
    degree = longkaku - smallkaku;
    double radian = deg2rad(degree);
    ans = (A * A + B * B - 2 * A * B * cos(radian));
    ans = sqrt(ans);
    cout <<setprecision(11)<< ans << endl;
    return 0;

}


Measured memory_bytes: 4244
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

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

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;
const int N = 1e6 + 10;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
    ll n;cin >> n;
    vector<ll>a(5);
    for(int i = 0;i<5;i++) cin >> a[i];
    sort(a.begin(),a.end());
    cout << (n+a[0]-1)/a[0]+4<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3628
n = int(input())
x_n = list(map(int, input().split()))
ave = sum(x_n)//n
res = 0
for x_i in x_n:
    res += x_i**2
for p in range(ave - 2, ave + 3):
    point = 0
    for x_i in x_n:
        point += (x_i - p)**2
    res = min(res, point)
print(res)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

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

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

    sort(all(a), greater<>());
    int total = accumulate(all(a), 0);
    double thred = double(total) / (4.0*double(m));

    if (a[m-1] < thred) puts("No");
    else puts("Yes");
}

Measured memory_bytes: 256
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
#sort = sorted(a)[::-1] 降順
x = int(input())

if 400 <= x and x <= 599:
    print(8)

elif 600 <= x and x <= 799:
    print(7)

elif 800 <= x and x <= 999:
    print(6)

elif 1000 <= x and x <= 1199:
    print(5)

elif 1200 <= x and x <= 1399:
    print(4)

elif 1400 <= x and x <= 1599:
    print(3)

elif 1600 <= x and x <= 1799:
    print(2)

else:
    print(1)


Measured memory_bytes: 9176
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
  char suit;
  int value;
};

struct Card L[MAX/2+2],R[MAX/2+2];

void merge( struct Card [],int,int,int,int);
void mergeSort( struct Card [],int,int,int);
int partition( struct Card [],int,int,int);
void quickSort( struct Card [],int,int,int);

int main(){
  int n,i,v;
  struct Card A[MAX],B[MAX];
  char S[10];
  int stable=1;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s %d", S,&v);
    A[i].suit=S[0];
    B[i].suit=S[0];
    A[i].value=v;
    B[i].value=v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i=0;i<n;i++){
    if(A[i].suit != B[i].suit) stable=0;
  }

  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",B[i].suit,B[i].value);
  }
  return 0;
}

void merge( struct Card A[],int n,int left,int mid,int right){
  int i,j,k,n1,n2;
  n1=mid-left;
  n2 = right - mid;
  for(i=0;i<n1;i++) L[i]=A[left+i];
  for(i=0;i<n2;i++) R[i]=A[mid+i];
  L[n1].value = R[n2].value = SENTINEL;
  i=j=0;
  for(k=left;k<right;k++){
    if(L[i].value<=R[j].value){
      A[k]=L[i++];
    }
    else{
      A[k]=R[j++];
    }
  }
}

void mergeSort( struct Card A[],int n,int left,int right){
int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int partition( struct Card A[],int n,int p,int r){
  int i,j;
  struct Card t,x;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;

  return i+1;
}

void quickSort( struct Card A[],int n ,int p,int r){
  int q;
  if(p<r){
    q=partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}


Measured memory_bytes: 4144
n,q=map(int,input().split())
s=input()
L=[list(map(int,input().split())) for i in range(q)]

L2=[0]
r=0
for i in range(1,n):
      if s[i-1]+s[i]=="AC":
            r+=1
      L2.append(r)

for i in range(q):
      print(L2[L[i][1]-1]-L2[L[i][0]-1])

Measured memory_bytes: 69208
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool Finish_read;
template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
/*================Header Template==============*/
int a,b,c,d;
int main() {
	read(a),read(b),read(c),read(d);
	writeln(min(a,b)+min(c,d));
}

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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  
  for(int i =0 ; i <n ; i++) {
    cin >> v.at(i);
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  
  int s =0;
  for(int i =0 ; i<n ; i +=2){
    s += v.at(i);
  }
  
  int t = 0;
  for(int i =1 ; i<n ; i +=2){
    t += v.at(i);
  }
  
  cout << s - t << endl;
}


Measured memory_bytes: 256