akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
using lint = long long;

int main()
{
    int n;

    scanf("%d", &n);

    std::vector<std::vector<std::pair<int, int>>> tree(n);
    std::vector<int> edge_color(n - 1);

    for (int i = 0; i < n - 1; ++i)
    {
        int a, b;
        scanf("%d", &a);
        scanf("%d", &b);

        tree[a - 1].push_back(std::make_pair(b - 1, i));
        tree[b - 1].push_back(std::make_pair(a - 1, i));
    }

    int k = 0;

    for (int i = 0; i < n; ++i)
    {
        int edge_num = tree[i].size();
        if (k < edge_num)
        {
            k = edge_num;
        }
    }

    std::vector<int> seen(n, 0);
    std::deque<std::pair<int, int>> q;

    q.push_back(std::make_pair(0, 0));
    seen[0] = 1;

    while (!q.empty())
    {
        auto cur = q.front();
        q.pop_front();

        int color_cand = 1;
        int prev_color = cur.second;

        for (auto next = tree[cur.first].begin(); next != tree[cur.first].end(); next++)
        {
            if (!seen[next->first])
            {
                if (color_cand == prev_color)
                {
                    color_cand++;
                }
                edge_color[next->second] = color_cand;
                q.push_back(std::make_pair(next->first, color_cand));
                seen[next->first] = 1;
                color_cand++;
            }
        }
    }

    std::cout << k << "\n";

    for (int i = 0; i < n - 1; ++i)
    {
        printf("%d\n", edge_color[i]);
    }

    return 0;
}


Measured memory_bytes: 7424
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

int main()
{
	for (int i = 0; i < 5; i++)
	{
		int x;
		std::cin >> x;
		if (x == 0)
		{
			std::cout << i + 1 << '\n';
			break;
		}
	}
}


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

void selectionSort(int *a, int n){
	int count = 0;
	for(int i = 0; i < n - 1; i++) {
		int minv = i;
		for(int j = i + 1; j < n; j++) {
			if(a[minv] > a[j])
				minv = j;
		}
		if(minv == i) continue;
		swap(a[i], a[minv]);
		count++;
	}
	for(int i = 0; i < n - 1; i++)
		printf("%d ", a[i]);
	printf("%d\n", a[n-1]);
	printf("%d\n", count);
}

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



Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
int main () {
  int a, b;
  cin >> a >> b;

  int max;
  max = a+b;
  if( a-b > max) {
    max = a-b;
  }
  if( a*b > max){
    max = a*b;
  }

  cout << max <<endl;
}


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

using namespace std;
using ll = long long;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int> ar(n);
	for (int& v: ar) {
		cin >> v;
	}
	ar.push_back(0);
	bool was = true;
	while (k && was) {
		k--;
		was = false;
		vector<int> tmp(n + 1, 0);
		for (int i = 0; i < n; ++i) {
			tmp[max(0, i - ar[i])]++;
			tmp[min(n, i + ar[i] + 1)]--;
		}
		int cur = 0;
		for (int i = 0; i < n; ++i) {
			cur += tmp[i];
			tmp[i] = cur;
			was |= cur != n;
		}
		swap(tmp, ar);
	}
	ar.pop_back();
	for (int& v: ar) {
		cout << v << " ";
	}
	cout << endl;
}

Measured memory_bytes: 5224
#include <stdio.h>

int main(){
   int n,i,p,j;
    
   scanf("%d",&n);
   for (i=j=0;i<n;i++) {
      scanf("%d",&p);
      if (p!=i+1) j++;
   }
   if (j==0 || j==2) puts("YES");
   else              puts("NO");
   return 0;
}


Measured memory_bytes: 128
/* kadai2_2 
   ABC074 A
*/
#include <stdio.h>



int main(void){

    //N,Aを格納する変数を宣言
    int N,A;
    //標準入力から受け取り
    scanf("%d",&N);
    scanf("%d",&A);
    //N^2-Aを出力
    printf("%d\n",N*N-A);
    return 0;
}

Measured memory_bytes: 128
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from bisect import bisect_right
from itertools import accumulate

n,m,k=nii()
a=lnii()
b=lnii()
ar=[0]+list(accumulate(a))
br=list(accumulate(b))

ans=0
for i in range(n+1):
  time=ar[i]
  if time>k:
    break
  t_ans=i
  inx=bisect_right(br,k-time)
  t_ans+=inx
  ans=max(ans,t_ans)
print(ans)

Measured memory_bytes: 49332
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#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 all(x) (x).begin(), (x).end()

#define INF 10000000000

ll a, b, c, n, m, x, y, z, w, h, ans = 0, cnt = 0, mx = 0, mn = INF;
string s, t;

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

    cin >> a >> b;
    rep(i, a, b + 1){
        if(i / 10000 == i % 10 && i % 10000 / 1000 == i % 100 / 10){
            ans++;
        }
    }
    cout << ans << endl;
}



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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    int n, a;
    cin >> n >> a;
    cout << n * n - a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const char NL = '\n'; 
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int h,w; cin >> h >> w;
  vector<string> field(h);
  REP(i,h) cin >> field[i];
  
  int cnt = 0;
  REP(i,h) REP(j,w) if(field[i][j]=='#') cnt++;
  cout << (cnt==h+w-1 ? "Possible\n" : "Impossible\n");

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;

    int lmax=-1;int rmin=100020;
    for(int i=0;i<m;i++){
        int l,r;
        cin>>l>>r;
        if(lmax<l)
        lmax=l;
        if(rmin>r)
        rmin=r;
    }
    if(rmin-lmax>=0)
    cout<<rmin-lmax+1<<endl;
    else
    cout<<0<<endl;

    return 0;
}

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

Measured memory_bytes: 768
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

int main() {
	int N; cin >> N;
	long long a = 0;
	vector<long long>A(N),B(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) {
		cin >> B[i];A[i] -= B[i];
	}
	sort(A.begin(), A.end());
	int ans = 0;
	for(int i=0;i<N;i++){
		if (A[i] < 0) {
			a += A[i]; ans++;
			A[i] = 0;
		}
	}
	for (int i = N-1; i >= 0; i--) {
		if (a >= 0)break;
		a += A[i]; ans++;
	}
	if (a>=0)cout << ans << endl;
	else cout << -1 << endl;
}





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

signed main()
{
  int a, b, c;
  cin >> a >> b >> c;

  if (a < b && b < c){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return (0); 
}

Measured memory_bytes: 3084
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, K, X, Y;

  std::cin >> N >> K >> X >> Y;

  std::cout << std::min(K, N) * X + std::max(N - K, 0) * Y << std::endl;

  return 0;
}


Measured memory_bytes: 256
N=int(input())
B=[]
for i in range (N):
    a=int(input())
    b=[]
    for j in range(a):
        x,y=map(int,input().split())
        b.append([x,y])
    B.append(b)
ans=0
for k in range(2**N):
    num=0
    L=[0]*N
    p=0
    for j in range(N):
        if ((k>>j)&1):
            L[N-1-j]=1
            num+=1
    for k in range(N):
        if L[k]==1:
            for m in range(len(B[k])):
                if L[B[k][m][0]-1]!=B[k][m][1]:
                    p=1
    if p==0:
        ans=max(ans,num)

print(ans)

Measured memory_bytes: 9256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){
  string s,t;
  cin >> s >> t;
  bool ans =false;
  rep(i,s.size()){
    if(s==t){
      ans = true;
      break;
    }
    s = s.back() + s.substr(0,s.size()-1);
  }
  if(ans){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
s=int(input())
def f(n):
  if n%2==0:
    return n/2
  else:
    return 3*n+1
  
seq=[0 for i in range(1000000)]
seq[0]=s
seq[1]=f(seq[0])
count =1
set={s,seq[1]}
while 1-(f(seq[count]) in set):
  seq[count+1]=f(seq[count])
  set.add(f(seq[count]))
  count=count+1

print(count+2)

Measured memory_bytes: 16844
n=int(input())
l=list(map(int,input().split()))
z=0
m=0
s=0
t=10000000000000
for i in range(n):
    s+=abs(l[i])
    t=min(t,abs(l[i]))
    if l[i]==0:
        z+=1
    if l[i]<0:
        m+=1
        
if z>0 or m%2==0:
    print(s)
else:
    print(s-t*2)


Measured memory_bytes: 14412
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b)
#define chmin(a, b) (a)=min(a, b)
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/


 
int main(void) {
  ll i, j, k;
  
  ll a, b;
  cin >>a >> b;
  
  if(a<=b) {
    pt("unsafe");
  }else {
    pt("safe");
  }
  
  
  
  
  
}
 
 


Measured memory_bytes: 3568
#include "bits/stdc++.h"
using namespace std;

class LazySegmentTree {
private:
	long long Size;
	vector<long long> Node, Lazy;
	vector<bool> Flag;
public:
	LazySegmentTree(long long N) {
		Size = 1;
		while (Size < N) Size <<= 1;
		Node.assign(Size * 2, 0);
		Lazy.assign(Size * 2, 0);
		Flag.assign(Size * 2, false);
	}
	void Eval(long long K, long long L, long long R) {
		if (Flag[K]) {
			Node[K] = Lazy[K] * (R - L);
			if (R - L > 1) {
				Lazy[K * 2] = Lazy[K];
				Flag[K * 2] = true;
				Lazy[K * 2 + 1] = Lazy[K];
				Flag[K * 2 + 1] = true;
			}
			Flag[K] = false;
		}
	}
	void Update(long long A, long long B, long long X, long long K, long long L, long long R) {
		Eval(K, L, R);
		if (B <= L || R <= A) return;
		if (A <= L && R <= B) {
			Lazy[K] = X;
			Flag[K] = true;
			Eval(K, L, R);
			return;
		}
		Update(A, B, X, K * 2, L, (L + R) / 2);
		Update(A, B, X, K * 2 + 1, (L + R) / 2, R);
		Node[K] = Node[K * 2] + Node[K * 2 + 1];
	}
	void Update(long long A, long long B, long long X) {
		Update(A, B, X, 1, 0, Size);
		return;
	}
	long long Query(long long A, long long B, long long K, long long L, long long R) {
		Eval(K, L, R);
		if (B <= L || R <= A) return 0;
		if (A <= L && R <= B) return Node[K];
		return Query(A, B, K * 2, L, (L + R) / 2) + Query(A, B, K * 2 + 1, (L + R) / 2, R);
	}
	long long Query(long long A, long long B) {
		return Query(A, B, 1, 0, Size);
	}
};

long long INF = 2000000000000000000;
static long long MOD = 1000000007;

int main() {
	int N;
	long long A, B;
	cin >> N >> A >> B;
	if (A > B) swap(A, B);
	vector<long long> S(N + 1);
	S[0] = -INF;
	for (int i = 1; i <= N; i++) cin >> S[i];
	for (int i = 0; i + 2 <= N; i++) {
		if (S[i + 2] - S[i] < A) {
			cout << 0 << endl;
			return 0;
		}
	}
	LazySegmentTree Seg(N + 1);
	Seg.Update(0, 1, 1);
	for (int i = 1; i <= N; i++) {
		int ID = upper_bound(S.begin(), S.end(), S[i] - B) - S.begin() - 1;
		Seg.Update(i, i + 1, Seg.Query(0, ID + 1) % MOD);
		if (S[i] - S[i - 1] < A) {
			Seg.Update(0, i - 1, 0);
		}
	}
	cout << Seg.Query(0, N + 2) % MOD << endl;
}

Measured memory_bytes: 5120
using System;
using System.Linq;

class C
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var gs = new int[h[1]].Select(_ => read()).ToArray();
		Console.WriteLine(Math.Max(gs.Min(g => g[1]) - gs.Max(g => g[0]) + 1, 0));
	}
}


Measured memory_bytes: 26172
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------
var (
	dxs = []int{-1, 1, 0, 0}
	dys = []int{0, 0, -1, 1}
	s   [][]byte
	v   [][]bool
)

func visited(i, j int) bool {
	return v[i+1][j+1]
}
func visit(i, j int) {
	v[i+1][j+1] = true
}

func main() {
	defer stdout.Flush()
	h := readInt()
	w := readInt()
	s = make([][]byte, h)
	v = make([][]bool, h+2)
	v[0] = make([]bool, w+2)
	v[h+1] = make([]bool, w+2)
	for i := range v[0] {
		v[0][i] = true
		v[h+1][i] = true
	}
	for i := range s {
		s[i] = []byte(readString())
		v[i+1] = make([]bool, w+2)
		v[i+1][0] = true
		v[i+1][w+1] = true
	}

	var ans int64
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			b, w := rec('#', i, j)
			ans += b * w
		}
	}
	println(ans)
}

func rec(c byte, i, j int) (bsum int64, wsum int64) {
	if visited(i, j) {
		return 0, 0
	}
	if s[i][j] != c {
		return 0, 0
	}
	visit(i, j)
	if c == '#' {
		bsum++
	} else {
		wsum++
	}
	nc := byte('#')
	if c == '#' {
		nc = '.'
	}
	for k := range dys {
		ni := i + dys[k]
		nj := j + dxs[k]
		b, w := rec(nc, ni, nj)
		bsum += b
		wsum += w
	}
	return bsum, wsum
}

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


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

using namespace std;
#define int long long
const int INF = 200000000007;


  
signed main(){
    int n;
    cin>>n;
    vector<pair<int,int>> hen[n];
    int iro[n]={};
    int u,v,w;
    
    for(int i=0;i<n-1;i++){
        cin>>u>>v>>w;
        hen[u-1].push_back(make_pair(v-1,w));
        hen[v-1].push_back(make_pair(u-1,w));
    }
    queue<int> que;
    que.push(0);
    iro[0]=1;
    int t;
    while(!que.empty()){
        t=que.front();
       // cerr<<t<<' ';
        que.pop();
     for(int i=0;i<hen[t].size();i++){
         if(iro[hen[t][i].first]==0){
             iro[hen[t][i].first]=iro[t]*(1- 2*(hen[t][i].second%2));
             que.push(hen[t][i].first);
         }
     }
    }
    for(int i=0;i<n;i++){
        cout<<(iro[i]+1)/2<<endl;
    }
    
   
    
    
    
    return 0;
}


Measured memory_bytes: 8704
n, m = map(int, input().split())
maxl, minr = map(int, input().split())
for i in range(m - 1):
	l, r = map(int, input().split())
	maxl = max(maxl, l)
	minr = min(minr, r)
print(max(0, minr - maxl + 1))

Measured memory_bytes: 44136
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B;
  cin >> A >> B;
  if (A==1){
    A = 14;
  }
  if (B==1){
    B = 14;
  }
  
  if (A==B){
    cout << "Draw" << endl;
  }
  else if (A>B){
    cout << "Alice" << endl;
  }
  else {
    cout << "Bob" << endl;
  }
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define mod 1000000007
#define bitcount __builtin_popcountll
#define ll long long
#define pb push_back
#define pi pair<int,int>
#define pii pair<pi,int>
#define mp make_pair
int main()
{
	int i,j,k;
	int q;
	sd(q);
	while(q--)
	{
		ll l,r,ans=0,mid,a,b;
		l=1,r=4e9;
		slld(a);
		slld(b);
		while(l<=r)
		{
			ll mid1,mid2;
			mid=(l+r)/2;
			mid1=mid2=mid+1;
			mid1=(1+mid1)/2;
			mid2=(2+mid2)/2;
			if(mid1>=a)
				mid1++;
			if(mid2<=b)
				mid2--;
			if(mid1*mid2>=a*b)
			{
				r=mid-1;
				continue;
			}
			ll mid3,mid4;
			mid3=mid1+1;
			mid4=mid2-1;
			if(mid3==a)
				mid3++;
			if(mid4==b)
				mid4--;
			if(mid3*mid4>=a*b)
			{
				r=mid-1;
				continue;
			}
			mid3=mid1-1;
			mid4=mid2+1;
			if(mid3==a)
				mid3--;
			if(mid4==b)
				mid4++;
			if(mid3*mid4>=a*b)
			{
				r=mid-1;
				continue;
			}
			ans=max(ans,mid);
			l=mid+1;
		}
		printf("%lld\n",ans );
	}
	return 0;
}

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

int main(){
  int N,L[220],sum=0; cin>>N;
  for(int i=0;i<2*N;i++){
    cin>>L[i];
  }
  sort(L,L+2*N);
  for(int i=0;i<2*N;i++){
    if(i%2==0){
      sum=sum+L[i];
    }
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author G. Guarnieri
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int min = Integer.MAX_VALUE;
            int max = Integer.MIN_VALUE;

            if (n == 1) {
                out.println(0);
                return;
            }

            for (int i = 0; i < n; i++) {
                int current = in.nextInt();
                if (current < min) {
                    min = current;
                }
                else if (current > max) {
                    max = current;
                }
            }
            out.println(max - min);
        }

    }
}



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

signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  double xs, ys, xt, yt; cin >> xs >> ys >> xt >> yt;
  int n; cin >> n;
  vector<double> x(n + 2), y(n + 2), r(n + 2); for (int i = 1; i <= n; i++) cin >> x[i] >> y[i] >> r[i];
  x[0] = xs; y[0] = ys; r[0] = 0.0;
  x[n + 1] = xt; y[n + 1] = yt; r[n + 1] = 0.0;
  struct adj { int to; double cost; };
  vector<vector<adj>> G(n + 2);
  for (int i = 0; i <= n + 1; i++) {
    for (int j = 0; j <= n + 1; j++) {
      if (j == i) continue;
      G[i].push_back(adj{j, max(0.0, hypot(x[j] - x[i], y[j] - y[i]) - r[i] - r[j])});
    }
  }
  vector<double> d(n + 2, 1e12);
  d[0] = 0.0;
  typedef pair<double, int> P;
  priority_queue<P, vector<P>, greater<P>> pq;
  pq.push(P(0.0, 0));
  while (not pq.empty()) {
    P p = pq.top(); pq.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (auto i : G[v]) {
      if (d[i.to] > d[v] + i.cost) {
        d[i.to] = d[v] + i.cost;
        pq.push(P(d[i.to], i.to));
      }
    }
  }
  cout << setprecision(12) << d[n + 1] << '\n';
  return 0;
}

Measured memory_bytes: 22256
L = int(input())

N = len(bin(L)[2:])
M = 2*(N-1) + bin(L)[3:].count("1")
print(N, M)

for i in range(1, N):
  print(i, i+1, 0)
  print(i, i+1, 2**(i-1))

temp = L
for i in range(1, N):
  if bin(L)[-i] == "1":
    print(i, N, temp-2**(i-1))
    temp -= 2**(i-1)

Measured memory_bytes: 9156
/*
1~nまでの自然数のうち、nと互いに素なものの個数を返す
verify:
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_D&lang=jp
*/

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

typedef long long int ll;

ll EulerPhi(ll n){
    ll ret=n;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            while(n%i==0) n/=i;
            ret-=ret/i;
        }
    }
    if(n>1) ret-=ret/n;
    return ret;
}

signed main(){
    ll n;
    cin>>n;
    cout<<EulerPhi(n)<<endl;
}


Measured memory_bytes: 3108
N = int(input())

list = [(0,0,0)]
for i in range(N):
	data = input().split()
	list.append((int(data[0]), int(data[1]), int(data[2])))

for i in range(1, len(list)):
	t = list[i][0] - list[i-1][0]
	if(list[i][1] != list[i-1][1]):
		x = abs(list[i][1] - list[i-1][1])
		t -= x
		if(t < 0):
			print("No")
			exit()
	if(list[i][2] != list[i-1][2]):
		y = abs(list[i][2] - list[i-1][2])
		t -= y
		if(t < 0):
			print("No")
			exit()
	if(t % 2 != 0):
		print("No")
		exit()

print("Yes")


Measured memory_bytes: 17332
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF=1e9+7;

int main() {
    int N,m=INF,mn=100,mx=-100;
    cin >> N;
    vector<int> a(N);

    rep(i,N) {
        cin >> a.at(i);
        mn = min(mn, a.at(i));
        mx = max(mx, a.at(i));
    }

    rep(i,mx-mn+1) {
        int b=mn+i,s=0;
        rep(j,N)
            s += pow((a.at(j)-b),2);
        m = min(m,s);
    }

    cout << m << endl;
}

Measured memory_bytes: 256
for _ in range(input()):
	s = raw_input()
	cur = 0
	for __ in range(input()):
		cmd = raw_input()
		if   cmd == "forward char":
			cur = min(len(s),cur+1)
			
		elif cmd == "forward word":
			while cur < len(s) and s[cur] == " ": cur+=1
			while cur < len(s) and s[cur] != " ": cur+=1
				
		elif cmd == "backward char":
			cur = max(0,cur-1)
			
		elif cmd == "backward word":
			while cur > 0 and s[cur-1] == " ": cur-=1
			while cur > 0 and s[cur-1] != " ": cur-=1
			
		elif cmd == "delete char":
			s = s[:cur] + s[cur+1:]
			
		elif cmd == "delete word":
			temp=cur
			if temp>=len(s):
				continue
			while temp<len(s) and s[temp]==" ":
				temp+=1
			if temp>=len(s):
				continue
			while temp<len(s) and s[temp]!=" ":
				temp+=1
			s = s[:cur] + s[temp:]
		elif cmd[:6] == "insert":
			s = s[:cur] + cmd[8:-1] + s[cur:]
			cur += len(cmd[8:-1])

	print s[:cur] + "^" + s[cur:]

Measured memory_bytes: 4304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    string s;
    ll k;
    cin >> s >> k;
    ll n = s.size();
    map<char, ll> mp;
    for (ll i = 0; i < n;i++){
        mp[s[i]]++;
    }
    if(mp.size()==1){
        cout << k * n / 2 << endl;
    }
    else if(s[0]!=s[n-1]){
        ll tmp = 1;
        ll ans = 0;
        for (ll i = 0; i < n - 1; i++) {
            while (s[i] == s[i + 1]) {
                tmp++;
                i++;
            }
                ans += tmp / 2;
                tmp = 1;
            }
        cout << ans*k << endl;
    }
    else {
        ll left = 0, right = 0;
        for (ll i = 0; i < n;i++){
            if(s[i]!=s[0]){
                left=i;
                break;
            }
        }
        for (ll i = n - 1; i >= 0;i--){
            if(s[i]!=s[n-1]){
                right = i;
                break;
            }
        }
        ll tmp = 1;
        ll ans = 0;
        for (ll i = 0; i < n - 1; i++) {
            while (s[i] == s[i + 1]) {
                tmp++;
                i++;
            }
                ans += tmp / 2;
                tmp = 1;
        }
        cout << ans * k - (k - 1) * (left / 2 + (n - right - 1) / 2 - (left + n - right-1) / 2) << endl;
    }
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int t[4],s[4],ans,a[4];
    for(int i=0;i<4;i++){
        cin>>t[i]>>s[i];
        if(t[i]==1) ans=6000*s[i];
        else if(t[i]==2) ans=4000*s[i];
        else if(t[i]==3) ans=3000*s[i];
        else ans=2000*s[i];
        a[i]=ans;
        }
    cout<<a[0]<<endl<<a[1]<<endl<<a[2]<<endl<<a[3]<<endl;

}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	ll res = 0;
	int n;
	cin >> n;
	FOR(i, 1, n + 1) {
	  if (i % 3 == 0 || i % 5 == 0) continue;
	  res += i;
	}
	cout << res << endl;
    
    return 0;
}



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

typedef long long ll;

const ll INF = 1e18;

const ll N = 120000;
const ll MOD = 1e9 + 239;

using namespace std;

string s;
int n, l[N], r[N];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    if (s.size() == 1)
    {
        cout << "YES";
        return 0;
    }
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> l[i] >> r[i];
        l[i]--, r[i]--;
    }
    if (s.size() % 2 == 1)
    {
        int pos = s.size() / 2;
        for (int i = 0; i < n; i++)
        {
            if (l[i] == pos && r[i] == pos)
            {
                n--;
                swap(l[i], l[n]);
                swap(r[i], r[n]);
                i--;
                continue;
            }
            if (l[i] > pos) l[i]--;
            if (r[i] >= pos) r[i]--;
        }
        string t = "";
        for (int i = 0; i < s.size(); i++) if (i != pos) t += s[i];
        s = t;
    }
    int len = s.size() / 2;
    for (int i = 0; i < n; i++)
    {
        if (l[i] < len && r[i] >= len)
        {
            int p1 = len - l[i], p2 = r[i] - len + 1;
            if (p1 == p2) l[i] = -1, r[i] = -1;
            if (p1 < p2)
            {
                l[i] += 2 * p1;
            }
            if (p1 > p2)
            {
                r[i] -= 2 * p2;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (l[i] >= len)
        {
            int rr = s.size() - 1 - l[i];
            int ll = s.size() - 1 - r[i];
            l[i] = ll, r[i] = rr;
        }
    }
    string a = "", b = "";
    for (int i = 0; i < len; i++) a += s[i];
    for (int i = len; i < s.size(); i++) b += s[i];
    reverse(b.begin(), b.end());
    vector<int> x(len + 2);
    for (int i = 0; i < len; i++)
    {
        x[i + 1] = (b[i] + 26 - a[i]) % 26;
    }
    //for (int i = 0; i <= len; i++)
    //{
    //    cout << x[i] << " ";
    //}
    //cout << endl;
    for (int i = len + 1; i > 0; i--)
    {
        x[i] = (x[i] - x[i - 1] + 26) % 26;
    }
    for (int i = 0; i < n; i++)
    {
        l[i]++, r[i]++, r[i]++;
    }
    vector<int> root(len + 2), sz(len + 2);
    iota(root.begin(), root.end(), 0);
    fill(sz.begin(), sz.end(), 1);
    for (int i = 0; i < n; i++)
    {
        int a = l[i], b = r[i];
        while (a != root[a]) a = root[a];
        while (b != root[b]) b = root[b];
        if (a == b) continue;
        if (sz[a] < sz[b])
        {
            sz[b] += sz[a];
            root[a] = b;
        }
        else
        {
            sz[a] += sz[b];
            root[b] = a;
        }
    }
    vector<int> summ(len + 2);
    for (int i = 1; i < x.size(); i++)
    {
        int j = i;
        while (j != root[j]) j = root[j];
        summ[j] += x[i];
    }
    int t = -1;
    for (int i = 0; i <= len; i++)
    {
        if (summ[i] % 26 != 0)
        {
            if (t == -1) t = i;
            else cout << "NO", exit(0);
        }
    }
    if (t == -1) cout << "YES", exit(0);
    int s = 0;
    while (s != root[s]) s = root[s];
    if (s == t) cout << "YES", exit(0);
    else cout << "NO", exit(0);
}


Measured memory_bytes: 2156
#include <iostream>
#include <set>

using namespace std;

int main() {
    int n;
    cin >> n;
    set<int> si;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        si.insert(x);
    }
    cout << si.size() << endl;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define incant() cin.tie(0), ios::sync_with_stdio(false)
#define int long long
#define uint unsigned long long
#define double long double
using str = string;
template <class T> using vec = vector<T>;
template <class T> using vvec = vec<vec<T>>;
template <class T> using que = queue<T>;
template <class T> using pque = priority_queue<T>;
template <class... T> using tup = tuple<T...>;
using vint = vec<int>;
using vvint = vvec<int>;
using vstr = vec<str>;
using pint = pair<int, int>;
using vp = vec<pint>;
using tll = tup<int, int, int>;
using vt = vec<tll>;
using mint = map<int, int>;
using dict = map<str, int>;
using qint = que<int>;
using qp = que<pint>;
using pqint = pque<int>;
using pqp = pque<pint>;
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fir first
#define sec second
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define sz(x) x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define ms(v, x) memset(v, x, sizeof(v))
#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 _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload3(__VA_ARGS__, revi, _rev,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define indent() cout << '\n'
#define print(x) out(x), indent()
#define debug(x) cerr << __LINE__ << ": " << #x << ": " << (x) << '\n'
#define YN(x) print((x) ? "YES" : "NO")
#define Yn(x) print((x) ? "Yes" : "No")
#define yn(x) print((x) ? "yes" : "no")
#define POS(x) print((x) ? "POSSIBLE" : "IMPOSSIBLE")
#define Pos(x) print((x) ? "Possible" : "Impossible")
#define pos(x) print((x) ? "possible" : "impossible")
const int INF = 1e16, MOD = 1e9 + 7, LIMIT = 100001;
const int dx4[] = {-1, 0, 1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {-1, 0, 1, -1, 1, -1, 0, 1}, dy8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const double EPS = 1e-9;
int gcd(int a, int b){return b == 0 ? a : gcd(b, a % b);}
int lcm(int a, int b){return a / gcd(a, b) * b;}
int factorial(int a){return a < 2 ? 1 : factorial(a - 1) * a;}
int summation(int a){return a < 1 ? 0 : (a * a + a) / 2;}
int combination(int n, int r){int res = 1; rep(i, 1, r + 1) res *= n--, res /= i; return res;}
const str alphabet = "abcdefghijklmnopqrstuvwxyz";
int n, m, x, y, z, w, h, res = 0, cnt = 0, sum = 0, mx = -INF, mn = INF;
str s, t;
bool flag = true;

signed main(){
    incant();
    cin >> n;
    int a[n + 1], b[n + 1], c[n + 1];
    rep(i, 1, n + 1){
        cin >> a[i] >> b[i] >> c[i];
    }
    int dp[n + 1][3] = {};
    rep(i, 1, n + 1){
            dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
            dp[i][1] = max(dp[i - 1][2], dp[i - 1][0]) + b[i];
            dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
    }
    print(max({dp[n][0], dp[n][1], dp[n][2]}));
}


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

vector<long long> fn(51, 1);
vector<long long> fp(51, 1);


long long dfs(long long level, long long x){
    if(level == 0){
        return 1;
    }
    
    if(x == 1){
        return 0;
    }
    else if(2 <= x and x <= 1 + fn[level-1]){
        return dfs(level-1, x-1);
    }
    else if(x == 2+ fn[level-1]){
        return fp[level-1] + 1;
    }
    else if(3+fn[level-1] <= x and x <= 2+2*fn[level-1]){
        return fp[level-1] + 1 + dfs(level-1, x-2-fn[level-1]);
    }
    else if(x == 3 + 2*fn[level-1]){
        return 2*fp[level-1] + 1;
    }
    return -1;

}

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

    for(long long i = 1; i <= 50; i++){
        fn[i] = 2*fn[i-1] + 3;
        fp[i] = 2*fp[i-1] + 1;
    }

    cout << dfs(n, x) << endl;
    return 0;
}

Measured memory_bytes: 3620
N, M, R = gets.split.map(&:to_i)
r = gets.split.map(&:to_i)

dist = Array.new(N) { Array.new(N, Float::INFINITY) }
M.times do |i|
  a, b, c = gets.split.map(&:to_i)
  dist[a-1][b-1] = c
  dist[b-1][a-1] = c
end

N.times do |k|
  N.times do |i|
    N.times do |j|
      if dist[i][j] > dist[i][k] + dist[k][j]
        dist[i][j] = dist[i][k] + dist[k][j]
      end
    end
  end
end

min = Float::INFINITY
r.permutation(R) do |seq|
  sum = 0
  seq.each_cons(2) do |x, y|
    sum += dist[x-1][y-1]
  end
  min = sum if min > sum
end
puts min


Measured memory_bytes: 2556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define endl '\n'
#define y1 holyshit
const int inf=0x3f3f3f3f;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    string S; cin>>S;
    if(S[2]==S[3]&&S[4]==S[5]) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){

  int n;
  cin >> n;

  if (n < 105){
    cout << 0 << endl;
    return 0;
  }

  int count = 0;
  int y;
  int d;
  for (int i = 105;i <= n; i = i + 2){
    y = 0;
    // d = i / 2;
    for (int j = 1; j <= n; j++){
      if (i % j == 0){
        y += 1;
      }
    }
    // cout << y << endl;
    if (y == 8){
      count += 1;
    }
  }
  cout << count << endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9+1;
const ll LINF = 1e18+1;
const long double PI = acos(-1.0);

#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SORT(v) sort(ALL(v));
#define RSORT(v) sort(RALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;
 
#define HOGE COUT("HOGE")
 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}
 
template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
template<typename T> T gcd(T a,T b){if(b==0){return a;}else{return gcd(b, a%b);}}
template<typename T> T lcm(T a,T b){return a*b/gcd(a, b);}


const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
int main() {
    IN(int, x);
    while (true) {
        bool flag = true;
        for (int i = 2; i*i <= x; i++) {
            if (x%i==0) {
                flag = false;
                break;
            }
        }
        if (flag) {
            COUT(x);
            return 0;
        }
        x++;
    }
}


Measured memory_bytes: 3648
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>

using namespace std;


/* エラトステネスのふるい

   O(n log log n) だいたい線形。 10万とかは余裕
*/
template<typename T>
std::vector<T> sieve(T n)
{
    std::vector<T> primes;
    std::vector<bool> is_prime(n, true);
    is_prime[0] = is_prime[1] = false;

    for (T i = 2; i <= n; ++i) {
        if (is_prime[i]) {
            primes.push_back(i);
            for (T j = 2 * i; j <= n; j += i) {
                is_prime[j] = false;
            }
        }
    }
    return primes;
}

/** 素因数分解
 */
template<typename T>
std::map<T, size_t>&
factor( T n, const std::vector<T>& primes, std::map<T, size_t>& ret) {
    auto f = primes.begin();
    while (n > 1) {
        while (n % *f == 0) {
            ret[*f] = ret[*f] + 1;
            n /= *f;
        }
        ++f;
    }

    return ret;
}

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

    const auto primes = sieve<int64_t>(N);

    constexpr int64_t DIV = 1000000007;
    std::map<int64_t, size_t> factors;
    for (int i = 1; i <= N; ++i) {
        factor<int64_t>(i, primes, factors);
    }

    // 約数の個数と素因数分解の関係→受験数学
    // https://juken-mikata.net/how-to/mathematics/number-of-divisor.html
    int64_t c = 1;
    for (auto f: factors) {
        c *= f.second+1;
        c %= DIV;
    }

    std::cout << c << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n;
int32_t main(){
CODE_START;
cin>>n;
cout<<n*n*n;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = getLine >>= print . foldl max 0 . map length .  filter head . group . map f

f 'A' = True
f 'T' = True
f 'G' = True
f 'C' = True
f _ = False

Measured memory_bytes: 380
import java.util.Arrays;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner  scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }
        int[] dp = new int[n];
        Arrays.fill(dp,Integer.MAX_VALUE);
        dp[0] = 0;
        dp[1] = Math.abs(arr[1]-arr[0]);
        for (int i = 2; i < n; i++) {
            for (int j = 1; j <=k ; j++) {
                if(j<=i)
                    dp[i] = Math.min(dp[i - j] + Math.abs(arr[i] - arr[i - j]), dp[i]);
            }
        }
        System.out.println(dp[n-1]);
    }
}


Measured memory_bytes: 59884
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
  char c[100001][10],box[10],c2[100001][10];
  int time[100001];
  int i,j=0,n,q,top=0,tail=0,fcount=0,tcount=0,counta[100001];;
  scanf("%d%d",&n,&q);
  
  for(i=0;fcount != n;i++){
    if(i < n){ 
      tail++;
      scanf("%s%d",c[i],&time[i]);
      continue;
    }
    if(time[top] - q == 0 || time[top] - q < 0){
      tcount += time[top];
      time[top]=0;
      strcpy(c2[j],c[top]);
      counta[j]=tcount;
      j++;
      fcount++;
      if(top == n) top =0;
      else top++;
    }
      else{
	time[top]-=q;
	strcpy(c[tail],c[top]);
	time[tail]=time[top];
	tcount+=q;
	if(top == n) top = 0;
	else top++;
	if(tail == n) tail =0;
	else tail++;
      }  
  }
  for(i=0;i<n;i++) printf("%s %d\n",c2[i],counta[i]);
  return 0;
}
    

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

using namespace std;

#define mod 1000000007
#define ll long long
#define sf(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define sfc(a) scanf("%c",&a);
#define pf(a) printf("%d\n",a);
#define pfl(a) printf("%lld\n",a);
#define pb push_back
#define ft first
#define sd second
typedef pair<ll, ll> PII;

int a[100001],dp1[100001],dp2[100001];
vector<pair<int ,int > > v1,v2;

bool cmp(pair<int,int> a,pair<int,int> b){

	if(a.ft==b.ft)
		return(a.sd<b.sd);
	return(a.ft>b.ft);

}

int main() {

	int n;
	sf(n)

	int i,j,k=0,l=0,maxi=0,e1,e2;

	for(i=1;i<=n;i++){
		sf(a[i])
		maxi=max(maxi,a[i]);
		if(i%2)
			dp1[a[i]]++;
		else
			dp2[a[i]]++;
	}

	for(i=1;i<=maxi;i++){
		if(dp1[i]!=0){
			v1.pb({dp1[i],i});
		}
		if(dp2[i]!=0){
			v2.pb({dp2[i],i});
		}
	}

	sort(v1.begin(),v1.end(),cmp);
	sort(v2.begin(),v2.end(),cmp);

	// for(i=0;i<v1.size();i++)
	// 	cout<<v1[i].ft<<" "<<v1[i].sd<<"\n";
	// for(i=0;i<v2.size();i++)
	// 	cout<<v2[i].ft<<" "<<v2[i].sd<<"\n";

	if(v1[0].sd==v2[0].sd){
		if(v1[0].ft+v2[1].ft>v1[1].ft+v2[0].ft){
			e1=v1[0].sd;
			e2=v2[1].sd;
		}
		else{
			e1=v1[1].sd;
			e2=v2[0].sd;
		}
	}
	else{
		e1=v1[0].sd;
		e2=v2[0].sd;
	}

	int ans=0;
	for(i=1;i<=n;i++){
		if(i%2){
			if(a[i]!=e1)
				ans++;
		}
		else{
			if(a[i]!=e2)
				ans++;
		}
	}

	pf(ans)

    return 0;
}


Measured memory_bytes: 2428
#include <stdio.h>

	int main () {
		int mons;
		int serv;
		
		scanf("%i", &mons, 1 < mons < 10*10*10*10);
		scanf("%i", &serv, 1 < serv < 10*10*10*10);
		
		int kill;
		kill = mons/serv;
		
		if (mons%serv > 0){
		kill++;
		}
		
		printf("%i", kill);
		
		return 0;
	}

Measured memory_bytes: 1728
#include<iostream>
#include<float.h>
#include<cfloat>
#include<string>
#include<ctype.h>
#include<algorithm>
#include<errno.h>
#include<cerrno>
#include<assert.h>
#include<cassert> 
#include<map>
#include<memory.h>
#include<cctype>
#include<ctype.h>
#include<math.h>
#include<vector> 
#include<cstdio> 
#include<set>
#include<string.h>
#include<stdio.h>
#include<new>
#include<memory>
#include<cmath>
#include<queue>
#include<cstring>
#define ll long long
#define fo(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define br break
#define ct continue
#define pb push_back
#define pi 3.141592653589793238462643383279502884197169
#define F first
#define S second
#define em empty()
#define vei vector<int>
#define ves vector<string>
#define qui queue<int> 
#define qu queue
using namespace std;
int main()
{int a,b,c,d;
 cin>>a>>b>>c>>d;
 if(a+b>c+d){
 cout<<"Left"<<endl;}
 else if(a+b<c+d){
 cout<<"Right"<<endl;}
 else{
 cout<<"Balanced"<<endl;} 
 system("pause");
 return 0;
}

Measured memory_bytes: 504
n = int(input())
S = [input() for _ in range(n)]

from collections import Counter

counters = [Counter(s) for s in S]

all = set(counters[0])
for counter in counters:
    all &= set(counter)

minc = {c:100 for c in all}
for c in all:
    for counter in counters:
        minc[c] = min(minc[c], counter[c])

print("".join(c * minc[c] for c in sorted(minc.keys())))


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    int n, m, a, b, cnt = 0;
    cin >> n >> m;
    int v[n + 1];
    for(int i = 1; i <= n; i++)
        cin >> v[i];
    map<int, int> mp;
    while(m--){
        cin >> a >> b;
        mp[a] = max(mp[a], v[b]);
        mp[b] = max(mp[b], v[a]);
    }
    for(int i = 1; i <= n; i++)
        if(v[i] > mp[i])
            cnt++;
    cout << cnt << "\n";
    return 0;
}


Measured memory_bytes: 8692