akhauriyash/Code-Regression huggingface dataset:
import math

N = int(input())
P = []
r = 0

def f(x1, y1, x2, y2):
  return math.sqrt( (x1 - x2)**2 + (y1 - y2)**2 )

for i in range(N):
  P.append(list(map(int, input().split())))

for i in range(N):
  for j in range(i+1, N):
    r += f(*(P[i]+P[j]))

print(r * 2 / N)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node{ int p, l, r;};

Node T[MAX];
int n, D[MAX];

void print(int u){
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";
    if(T[u].p==NIL) cout << "root, ";
    else if(T[u].l==NIL) cout << "leaf, ";
    else cout << "internal node, ";
    
    cout << "[";
    
    for(int i=0, c = T[u].l; c!=NIL; i++, c=T[c].r){
        if(i) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

void rec(int u, int p){
    D[u] = p;
    if(T[u].r != NIL) rec(T[u].r,p);
    if(T[u].l != NIL) rec(T[u].l, p+1);
}

int main(){
    int i,j,d,v,c,l,r;
    cin >> n;
    for(int i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;
    
    for(i=0; i<n; i++){
        cin >> v >> d;
        for(j=0; j<d; j++){
            cin >> c;
            if(j==0) T[v].l = c;
            else T[l].r = c;
            l = c;
            T[c].p = v;
        }
    }
    for(i=0; i<n; i++){
        if(T[i].p==NIL) r = i;
    }
    
    rec(r,0);
    
    for(i=0; i<n; i++) print(i);
    
    return 0;
}

Measured memory_bytes: 7796
#define ll				long long
#define MOD				1000000007
#define VTX_MAX			100000
#define EDGE_MAX		100000

#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

typedef struct Edge {
	int vno;
	struct Edge *next;
	int len;
} Edge;

typedef struct Vtx {
	Edge *edge;
	char color;
} Vtx;

Vtx vtxs[VTX_MAX];
int vcnt;
Edge edges[EDGE_MAX * 2];
int ecnt;

FILE *in, *ans;
int tno;

int out(const char *s) {
#ifdef TEST
	char buf[8192];
	fgets(buf, sizeof(buf), ans);
	if (strcmp(buf, s)) {
		printf("err\n");
	}
#else
	printf(s);
#endif
	return 0;
}

int outi(int i) {
	char s[128];
	sprintf(s, "%d\n", i);
	out(s);
	return 0;
}

int outd(double d) {
	char s[128];
	sprintf(s, "%.10lf\n", d);
	out(s);
	return 0;
}

int outll(ll l) {
	char s[128];
	sprintf(s, "%lld\n", l);
	out(s);
	return 0;
}

int geti() {
	int i;
	fscanf(in, "%d", &i);
	return i;
}

ll getll() {
	ll l;
	fscanf(in, "%lld", &l);
	return l;
}

int getstr(char *s) {
	fscanf(in, "%s", s);
	return 0;
}

int fnc() {

	int a = geti();
	int p = geti() + a * 3;
	outi(p / 2);

	return 0;
}

int main() {

#ifdef TEST
	for (tno = TEST_SNO; tno <= TEST_ENO; tno++) {
		char str[128];
		sprintf(str, "test%d.txt", tno);
		in = fopen(str, "r");
		sprintf(str, "ans%d.txt", tno);
		ans = fopen(str, "r");
		fnc();
		fclose(in);
		fclose(ans);
	}
	printf("end\n");
#else
	in = stdin;
	fnc();
#endif

	return 0;
}


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

int main(){
				int a,b;
				cin >> a >> b;
				if(a > b){
								cout << "a > b" << endl;
				}
				else if(a < b){
								cout << "a < b" << endl;
				}
				else{
								cout << "a == b" << endl;
				}
}


Measured memory_bytes: 3084
#include <iostream>
using namespace std;
typedef long long ll;
ll h,w,k,U,R,L,D;
string s,t;
void f(char c,ll n){
    if(c=='U'){
        if(n==0)D++;
        else U--;
    }
    else if(c=='D'){
        if(n==0)U++;
        else D--;
    }
    else if(c=='R'){
        if(n==0)L++;
        else R--;
    }
    else {
        if(n==0)R++;
        else L--;
    }
}
int main(void){
    cin>>h>>w>>k>>U>>L;
    cin>>s>>t;
    D=h-U+1;
    R=w-L+1;
    for(int i=0;i<k;i++){
        f(s[i],1);
        if(R*L*U*D==0){
            cout<<"NO"<<endl;
            return 0;
        }
        //cout<<R<<L<<D<<U<<endl;
        f(t[i],0);
        U=min(U,h);
        D=min(D,h);
        R=min(R,w);
        L=min(L,w);
    }
    cout<<"YES"<<endl;
}


Measured memory_bytes: 776
# -*- coding: utf-8 -*-
# abc152/abc152_b
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    a, b = i2nn()
    print(min(str(a)*b, str(b)*a))
    return

main()


Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const int MAX = 300000;

int main()
{
    int n;
    cin >> n;
    vector<long long> a(3*n);
    for(int i=0; i<3*n; ++i){
        cin >> a[i];
        a[i] *= MAX;
        a[i] += i;
    }

    set<long long> s1, s2;
    long long sum1 = 0;
    long long sum2 = 0;
    for(int i=0; i<n; ++i){
        s1.insert(a[i]);
        sum1 += a[i] / MAX;
    }
    for(int i=n; i<3*n; ++i)
        s2.insert(a[i]);

    auto it1 = s1.begin();
    auto it2 = s2.begin();
    for(int i=0; i<n; ++i){
        sum2 += *it2 / MAX;
        ++ it2;
    }

    long long ans = sum1 - sum2;
    for(int i=n; i<2*n; ++i){
        if(a[i] < *it2){
            sum2 -= a[i] / MAX;
            sum2 += *it2 / MAX;
            ++ it2;
        }
        if(it2 != s2.end() && a[i] == *it2)
            ++ it2;
        s2.erase(a[i]);
        
        s1.insert(a[i]);
        if(a[i] > *it1){
            sum1 -= *it1 / MAX;
            sum1 += a[i] / MAX;
            ++ it1;
        }

        ans = max(ans, sum1 - sum2);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i < (b); ++i)
#define rrep(i,a,b) for(int i = b; i --> (a);)
#define all(v) v.begin(),v.end()
#define trav(x,v) for(auto &x : v)
#define sz(v) (int)(v).size()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n,m;
	cin >> n >> m;
	vector<vi> gr(n);
	vi deg(n);
	rep(_,0,m){
		int a,b;
		cin >> a >> b;
		--a, --b;
		gr[a].push_back(b);
		gr[b].push_back(a);
		++deg[a], ++deg[b];
	}
	vector<bool> vis(n);
	vis[0] = 1;
	deque<int> path(1,0);
	trav(u, gr[0]) --deg[u];
	rep(_,0,2){
		while(deg[path.back()]){
			int v = path.back();
			trav(u, gr[v]) if(!vis[u]){
				vis[u] = 1;
				trav(w, gr[u]) --deg[w];
				path.push_back(u);
				break;
			}
		}
		reverse(all(path));
	}
	cout << sz(path) << endl;
	trav(x, path) cout << x+1 << ' ';
	cout << endl;
}

Measured memory_bytes: 7168
import sys
INF = 1 << 60
MOD = 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()

prime = 998244353
root = 3
def _fmt(A, inverse = False):
    N = len(A)
    logN = (N - 1).bit_length()
    base = pow(root, (prime - 1) // N * (1 - 2 * inverse) % (prime - 1), prime)
    step = N
    for k in range(logN):
        step >>= 1
        w = pow(base, step, prime)
        wj = 1
        nA = [0] * N
        for j in range(1 << k):
            for i in range(1 << logN - k - 1):
                s, t = i + j * step, i + j * step + (N >> 1)
                ps, pt = i + j * step * 2, i + j * step * 2 + step
                nA[s], nA[t] = (A[ps] + A[pt] * wj) % prime, (A[ps] - A[pt] * wj) % prime
            wj = (wj * w) % prime
        A = nA
    return A

def convolution(f, g):
    N = 1 << (len(f) + len(g) - 2).bit_length()
    Ff, Fg = _fmt(f + [0] * (N - len(f))), _fmt(g + [0] * (N - len(g)))
    N_inv = pow(N, prime - 2, prime)
    fg = _fmt([a * b % prime * N_inv % prime for a, b in zip(Ff, Fg)], inverse = True)
    del fg[len(f) + len(g) - 1:]
    return fg

class modfact(object):
    def __init__(self, n):
        fact, invfact = [1] * (n + 1), [1] * (n + 1)
        for i in range(1, n + 1): fact[i] = i * fact[i - 1] % MOD
        invfact[n] = pow(fact[n], MOD - 2, MOD)
        for i in range(n - 1, -1, -1): invfact[i] = invfact[i + 1] * (i + 1) % MOD
        self._fact, self._invfact = fact, invfact

    def fact(self, n):
        return self._fact[n]

    def invfact(self, n):
        return self._invfact[n]

    def comb(self, n, k):
        return self._fact[n] * self._invfact[k] % MOD * self._invfact[n - k] % MOD if 0 <= k <= n else 0

    def perm(self, n, k):
        return self._fact[n] * self._invfact[n - k] % MOD if 0 <= k <= n else 0

from collections import Counter, deque
def resolve():
    n = int(input())
    H = [int(input()) for _ in range(2 * n)]

    mf = modfact(n << 1)
    doublefact = [1] * (2 * n + 10)
    for i in range(2, 2 * n + 1):
        doublefact[i] = i * doublefact[i - 2] % MOD

    F = deque()
    for k in Counter(H).values():
        f = []
        for i in range(k // 2 + 1):
            f.append(mf.comb(k, 2 * i) * doublefact[2 * i - 1] % MOD)
        F.append(f)

    while len(F) > 1:
        F.append(convolution(F.popleft(), F.popleft()))

    f = F.popleft()
    ans = 0
    for i in range(len(f)):
        f[i] = f[i] * doublefact[2 * n - 2 * i - 1] % MOD
        if i & 1:
            ans -= f[i]
        else:
            ans += f[i]
    ans %= MOD
    print(ans)
resolve()

Measured memory_bytes: 135312
#include<iostream>
#include<vector>

template<class T,class F>
struct segment_tree{
  std::vector<T> data;
  int n;F f;T identity;
  segment_tree(){}
  segment_tree(int sz,T ide,F _f):f(_f),identity(ide){
    n=1;while(n<sz)n<<=1;
    data.resize(2*n,identity);
  }
  segment_tree(std::vector<T> const& v,T ide,F _f):f(_f),identity(ide){
    build(v);
  }
  void build(std::vector<T> const& v){
    int sz=v.size();
    n=1;while(n<sz)n<<=1;
    data.resize(2*n,identity);
    for(int i=0;i<sz;++i)data[i+n]=v[i];
    for(int i=n-1;i>0;--i)data[i]=f(data[i<<1|0],data[i<<1|1]);
  }
  void set(int i,T x){
    i+=n;data[i]=x;
    while(i,i>>=1)data[i]=f(data[i<<1|0],data[i<<1|1]);
  }
  T fold(int l,int r)const{
    l+=n,r+=n;
    T x=identity;
    while(l<r){
      if(l&1)x=f(x,data[l++]);
      if(r&1)x=f(x,data[--r]);
      l>>=1,r>>=1;
    }
    return x;
  }
  T operator[](int i)const{return data[i+n];}
};
template<class T,class F>
auto make_segtree(int n,T ide,F f){
  return segment_tree<T,F>(n,ide,f);
}
template<class T,class F>
auto make_segtree(std::vector<T>const& v,T ide,F f){
  return segment_tree<T,F>(v,ide,f);
}

int main(){
  using namespace std;
  using ll = int64_t;
  cin.tie(0);
  ios::sync_with_stdio(false);
  constexpr char newl = '\n';

  int n,q;
  cin>>n>>q;
  vector<ll> a(n);
  for(auto& ai:a)cin>>ai;

  auto seg = make_segtree<ll>(a,0,[](ll a,ll b){return a<b?b:a;});
  while(q--){
    int t;cin>>t;
    if(t==1){
      int x,v;cin>>x>>v;x--;
      seg.set(x,v);
    }
    if(t==2){
      int l,r;cin>>l>>r;l--;r--;
      cout<<seg.fold(l,r+1)<<newl;
    }
    if(t==3){
      int x,v;cin>>x>>v;x--;
      int l=x,r=n+1;
      while(r-l>1){
        int m = l+r>>1;
        if(seg.fold(x,m)>=v)r=m;
        else l=m;
      }
      cout<<r<<newl;
    }
  }

}

Measured memory_bytes: 8900
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;

int main(){
	int N,M;
	cin>>N>>M;
	
	vector<int>oks(N+1,true);
	for(int i=0;i<M;++i){
		int a;cin>>a;
		oks[a]=false;
	}
	
	vector<long long int>dp(N+1);
	dp[0]=1;
	dp[1]=oks[1];

     for(int i=2;i<N+1;i++)
     {
     	if(oks[i])
     	{
		 dp[i]=dp[i-1]+dp[i-2];
		 dp[i]%=mod;
	 }
	 dp[i]=dp[i]%mod;
    }
   // for(int i=0;i<N+1;i++)
    //cout<<dp[i]<<endl;
    
  // cout<<dp[N];
//	dp[N]=dp[N]%mod;
 cout<<dp[N]<<endl;
	return 0;
}

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

int main(void)
{
    int n;
    cin >> n;
    vector<string> v(n);
    map<string, int> mp;
    bool flag = true;
    rep(i, n) cin >> v[i], mp[v[i]]++;
    rep(i, n - 1)
    {
        if (v[i][v[i].size() - 1] != v[i + 1][0])
            flag = false;
    }
    for (auto i : mp)
    {
        if (i.second != 1)
            flag = false;
    }
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3624
from copy import copy
N,A,B = map(int,input().split())
h_ls = [int(input()) for _ in range(N)]
add = A-B

def check(times):
    monster_ls = copy(h_ls)
    need = 0
    for i in range(N):
        monster_ls[i] -= B*times
        if monster_ls[i] > 0:
            need += -(-monster_ls[i]//add)
            #print(-(-monster_ls[i]//add))
    if need > times:
        #print(times,"false")
        return False
    else:
        #print(times,"true")
        return True
    
def return_min_ind_whose_value_not_less_than(upper):
    r = upper
    l = -1
    while True:
        next_ind = (r+l) // 2
        if check(next_ind):
            r = next_ind
        else:
            l = next_ind
        if r - l == 1:
            return r

upper = 10**9+1
print(return_min_ind_whose_value_not_less_than(upper))

Measured memory_bytes: 17164
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    VI a(n);
    REP(i,n) a[i] = in();
    sort(ALL(a));
    int x = n / 2;
    cout << a[x] - a[x - 1] << endl;

    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();
		
		if((r * 100 + g * 10 + b) % 4 == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	}

}


Measured memory_bytes: 21844
<?php
  fscanf(STDIN, "%s", $a);
  $b = str_split($a);
  sort($b);
  if($b[0]==$b[1] && $b[2]==$b[3] && $b[1]!==$b[2]) {
    echo "Yes";
  } else{
    echo "No";
  }

Measured memory_bytes: 4340
fun main(args: Array<String>) {
    val (A,G,C,T) = Array(4){it}
    val n=readLine()!!.toInt()
    var arr = Array(4){Array(4){Array(4){1}}}
    arr[A][G][C]=0
    arr[A][C][G]=0
    arr[G][A][C]=0
    for(i in 0 until n-3){
        val arr2 = Array(4){Array(4){Array(4){0}}}
        for(j in 0 until 4)
            for(k in 0 until 4)
                for(m in 0 until 4){
                    arr2[k][m][A]+=arr[j][k][m]
                    arr2[k][m][T]+=arr[j][k][m]
                    if(k!=A||m!=C)arr2[k][m][G]+=arr[j][k][m]
                    if(!(k==A&&m==G)&&!(j==A&&k==G)&&!(k==G&&m==A)&&!(j==A&&m==G))arr2[k][m][C]+=arr[j][k][m]
                    for(o in 0 until 4){arr2[k][m][o]%=1000000007}
        }
        arr = arr2
    }
    var result =0
    for(j in 0 until 4)
        for(k in 0 until 4)
            for(m in 0 until 4){
                result+=(arr[j][k][m])
                result%=1000000007
            }
    print(result)
}

Measured memory_bytes: 33776
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    if(n%2 == 1) {
        out(0);
        re0;
    }

    ll ans = 0;
    ll p = 10;
    while(p <= n) {
        ans += n/p;
        p *= 5;
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 256
import sys

def main():
    input = sys.stdin.readline
    A, B = map(int, input().split())
    S = str(input().strip())
    if S[:A].isnumeric() and S[A] == '-' and S[A+1:].isnumeric():
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
    string w,t;
    cin >> w;
    int ans = 0;
    while(1){
        cin >> t;
        if(t == "END_OF_TEXT") break;
        transform(t.begin(), t.end(), t.begin(), ::tolower);
        if(t == w) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl

int main() {
    int h, a; cin >> h >> a;
    int cnt = 0;
    while(h>0){
        h -= a;
        cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=100005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll n,m,k;
vl a;

vl f(){
	vl b(k),dp(k),c(n);
	int t=0;
	for(int i=0;i<m;i++){
		if(b[a[i]]){
			t=i;
			break;
		}
		b[a[i]]++;
	}
	dp[t]++;c[0]=1;
	for(int i=1;i<n;i++){
		vl DP(k);
		for(int j=0;j<k;j++){
			(DP[1]+=dp[j])%=mod;
			if(j<k-1) (DP[j+1]+=dp[j]*(k-j-1))%=mod;
			if(j<k-2) (DP[j+2]+=mod-dp[j]*(k-j)%mod)%=mod;
		}
		for(int j=1;j<k;j++) (DP[j]+=DP[j-1])%=mod;
		dp=DP;
		for(int j=0;j<k;j++) (c[i]+=dp[j])%=mod;
	}
	reverse(a.begin(),a.end());
	return c;
}

int main(){
	Init();
	cin>>n>>k>>m;
	a=vl(m);
	ll t=n-m+1;
	for(int i=0;i<n-m;i++) (t*=k)%=mod;
	for(auto &i:a){
		cin>>i;
		i--;
	}
	for(int i=k-1;i<m;i++){
		vl b(k);
		for(int j=i-k+1;j<=i;j++) b[a[j]]++;
		if(b==vl(k,1)){
			cout<<t<<endl;
			return 0;
		}
	}
	vl b(k);
	bool B=0;
	for(int i=0;i<m;i++){
		if(b[a[i]]) B=1;
		b[a[i]]++;
	}
	if(B){
		vl dpl=f(),dpr=f();
		ll sum=0;
		for(int i=0;i<=n-m;i++) (sum+=dpl[i]*dpr[n-m-i])%=mod;
		cout<<(t-sum+mod)%mod<<endl;
	}
	else{
		vl dp(k),dp1(k);
		dp[0]++;
		for(int i=0;i<n;i++){
			vl DP(k),DP1(k);
			for(int j=0;j<k;j++){
				(DP[1]+=dp[j])%=mod;
				if(j<k-1) (DP[j+1]+=dp[j]*(k-j-1))%=mod;
				if(j<k-2) (DP[j+2]+=mod-dp[j]*(k-j)%mod)%=mod;
				(DP1[1]+=dp1[j])%=mod;
				if(j<k-1) (DP1[j+1]+=dp1[j]*(k-j-1))%=mod;
				if(j<k-2) (DP1[j+2]+=mod-dp1[j]*(k-j)%mod)%=mod;
			}
			for(int j=1;j<k;j++) (DP[j]+=DP[j-1])%=mod;
			for(int j=1;j<k;j++) (DP1[j]+=DP1[j-1])%=mod;
			for(int j=m;j<k;j++) (DP1[j]+=DP[j])%=mod;
			dp=DP,dp1=DP1;
		}
		ll sum=0;
		for(auto i:dp1) (sum+=i)%=mod;
		sum=Div(sum*F[k-m]%mod,F[k]);
		cout<<(t-sum+mod)%mod<<endl;
	}
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;
const double pi=acos(-1.0);

signed main(){
    double a,b,x;cin>>a>>b>>x;x/=a;
    cout<<setprecision(20.20);
    if(a*b/2>=x)cout<<90-360*atan(2*x/b/b)/(2*pi)<<endl;
    else cout<<atan(2*(a*b-x)/a/a)*360/(2*pi)<<endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
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 All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    string S;
    int K;
    cin >> S >> K;
    rep(i, S.size()) {
        if(K <= 0)
            break;
        if(i == S.size() - 1) {
            K %= 26;
            rep(j, K) {
                S[i] = (char)(S[i] + 1);
                if(S[i] - 'z' > 0)
                    S[i] = 'a';
            }
            break;
        }
        int dist = S[i] == 'a' ? 0 : ('z' - S[i]) + 1;
        if(dist <= K) {
            S[i] = 'a';
            K -= dist;
        }
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <math.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
using namespace std;
#define rep(I,N) for(int I = 0; I < (int)(N); I++)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;

struct Data{
	int pass, pos, cost;
	Data(int _pass, int _pos, int _cost){
		pass = _pass;
		pos = _pos;
		cost = _cost;
	}
	Data(){}
};
int map[102][102];
int memo[102][3];
int main(void){
	int n, m;
	while(cin >> n >> m, n){
		int mini = INF;
		int co;
		fill_n(*map, 102*102, INF);
		fill_n(*memo, (102)*3, INF);
		rep(i, m){
			int a, b, c;
			cin >> a >> b;
			cin >> c;
			co = c;
			map[a][b] = c;
			map[b][a] = c;
		}
		if(m == 1){
			FIN(co);
			continue;
		}
		queue<Data> que;
		que.push(Data(0, 1, 0));
		while(!que.empty()){
			Data data = que.front();
			que.pop();
			int pos = data.pos;
			int cost = data.cost;
			int pass = data.pass;
			if(memo[pos][pass] <= cost)continue;
			memo[pos][pass] = cost;
			for(int i = 1; i <= 101; i++){
				if(map[pos][i] != INF){
					if(pass == 1){
						que.push(Data(2, i, cost));
					}else{
						que.push(Data(pass, i, cost+map[pos][i]));
						if(pass == 0){
							que.push(Data(1, i, cost));
						}
					}

				}

			}
		}
		FIN(min(memo[n][0],memo[n][2]));
	}
	return 0;
}

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

int main(){
    string S,T;
    cin >> S >> T;

    reverse(S.begin(),S.end());
    reverse(T.begin(),T.end());
    for(int i=0;i<=S.size()-T.size();i++){
        bool flag=true;
        for(int j=0;j<T.size();j++){
            if(S[j+i]!='?'&&S[j+i]!=T[j]){
                flag=false;
                break;
            }
        }
        if(flag){
            for(int j=0;j<T.size();j++){
                S[j+i]=T[j];
            }
            break;
        }
    }
    for(int i=0;i<S.size();i++){
        if(S[i]=='?') S[i]='a';
    }
    reverse(S.begin(),S.end());
    reverse(T.begin(),T.end());
    for(int i=0;i<S.size();i++){
        string re;
        re=S.substr(i,T.size());
        if(re==T){
            cout << S << endl;
            return 0;
        }
    }
    cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    char s1, s2, s3;
    std::cin >> s1 >> s2 >> s3;

    if (s1 == s2 && s2 == s3) {
        std::cout << "No";
    } else {
        std::cout << "Yes";
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();
    
    if(a.equals(b)){
      System.out.println("H");
    }else{
      System.out.println("D");
    }
  }
}

Measured memory_bytes: 20820
import heapq

V, E = map(int, input().split())

edges = [[] for _ in range(V)]
for _ in range(E):
    s, t, w = map(int, input().split())

    edges[s-1].append([w, t-1])
    edges[t-1].append([w, s-1])

# プリム法
def prim(n, w, edges):
    used = [True] * n #True:不使用
    edgelist = []
    for e in edges[0]:
        heapq.heappush(edgelist,e)
    used[0] = False
    res = 0
    while len(edgelist) != 0:
        minedge = heapq.heappop(edgelist)
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        used[v] = False
        for e in edges[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,e)
        res += minedge[0]
    return res

print(prim(V, E, edges))



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

using namespace std ;

const long long mod = 1e9 + 7ll ;
const int MAX = 2e5 + 10 ;

long long arr[MAX] , P[MAX] ;
long long n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	P[0] = 1ll ;
	for(int i = 1 ; i < MAX ; ++i)
		P[i] = (P[i-1] * 2ll) % mod ;
	cin>>n ;
	for(int i = 0 ; i < n ; ++i)
		cin>>arr[i] ;
	sort(arr , arr + n) ;
	long long ans = 0ll ;
	for(int i = 0 ; i < n ; ++i)
	{
		long long a = n-i-1 ;
		long long x = (a * P[a-1]) % mod ;
		x = (x + P[a]) % mod ;
		x = (x * P[a+1]) % mod ;
		x = (x * P[i]) % mod ;
		x = (x * P[i]) % mod ;
		long long y = (arr[i] * x) % mod ;
		ans = (ans + y) % mod ;
	}
	return cout<<ans<<"\n" , 0 ;
}		

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

int main(){
    int x,k;
    cin >> k >> x;
    for(int i = x-k+1; i <= x + k -1;i++){
        cout<< i;
        if( i != x + k -1){
            cout << " ";
        }else{
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, M;
  while (cin >> N >> M) {
    vec<int, 2> S(M);
    for (int i = 0; i < M; i++) {
      int size;
      cin >> size;
      S[i].resize(size);
      for (int j = 0; j < size; j++) cin >> S[i][j], --S[i][j];
    }
    vector<int> P(M);
    for (int& x : P) cin >> x;
    int res = 0;
    for (int m = 0; m < (1 << N); m++) {
      bool ok = true;
      for (int i = 0; i < M; i++) {
        int par = 0;
        for (int j : S[i]) {
          par += (m >> j) & 1;
        }
        if (par % 2 != P[i]) {
          ok = false;
        }
      }
      if (ok) ++res;
    }
    cout << res << endl;
  }
  return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int a,b,k; cin>>a>>b>>k;
	int ans=0;
	vector<int>v;
	while(ans<=a&&ans<=b){
		++ans;
		if(a%ans==0&&b%ans==0)v.emplace_back(ans);
	}
	cout<<v.at(v.size()-k)<<"\n"s;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>

using namespace std;

#define REP(i,e,s) for(register int i=(e); i<=(s); i++)
#define DREP(i,e,s) for(register int i=(e); i>=(s); i--)
#define ll long long
#define DE(...) fprintf(stderr,__VA_ARGS__)
#define DEBUG(a) DE("DEBUG: %d\n",a)
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define int ll
int read() {
	int x=0,f=1,ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=100000+10,p=1e9+7;

int a[MAXN];

int fac[MAXN],inv[MAXN];
int C(int n,int m) {
	if(n<m) return 0;
	return (fac[n]*inv[m])%p*inv[n-m]%p;
}
	
int qpow(int a,int b) {
	int ans=1;
	while(b) {
		if(b&1) ans=ans*a%p;
		a=a*a%p;
		b>>=1;
	}
	return ans;
}


const int N=100000+5;

signed main() {
	int n=read(),k=read();
	fac[0]=1;
	REP(i,1,N-1) fac[i]=fac[i-1]*i%p;
	inv[N-1]=qpow(fac[N-1],p-2);
	
DREP(i,N-1-1,0) inv[i]=inv[i+1]*(i+1)%p;

	REP(i,1,n) a[i]=read();
	sort(a+1,a+1+n);
	ll ans=0;
	REP(i,1,n) ans=(ans-a[i]*C(n-i,k-1)%p+p)%p;
	DREP(i,n,1) ans=(ans+a[i]*C(i-1,k-1)%p+p)%p;	
	printf("%lld\n",ans);
}


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

int main(){

  char ehe[100][100];

  for(int i=0;i<8;i++){
    for(int j=0;j<8;j++) cin >> ehe[j][i];
  }

  cout << "90" << endl;

  for(int j=0;j<8;j++){
    for(int i=7;i>=0;i--) cout << ehe[j][i];
    cout << endl;
  }

  cout << "180" << endl;

  for(int i=7;i>=0;i--){
    for(int j=7;j>=0;j--) cout << ehe[j][i];
    cout << endl;
  }

  cout << "270" << endl;

  for(int i=7;i>=0;i--){
    for(int j=0;j<8;j++) cout << ehe[i][j];
    cout << endl;
  }
}

Measured memory_bytes: 1140
/*
	时间复杂度：
	建树O(nlogn)
	询问O(mlogn)
	总复杂度O((n+m)logn)
	空间复杂度：
	一般为O(n logn logn) 
*/ 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

struct ChairmanTree{
	static const int N = 5e5 + 10;
	int n, tot; //n:原数组长度; tot:离散化后数组长度 
	int a[N], b[N]; //a:原数组; b:离散化后的数组
	int sz, lc[N << 5], rc[N << 5], sum[N << 5], rt[N];
	//sz:结点个数; rt数组：存储每棵线段树的根节点编号
	//lc、rc数组：记录左儿子、右儿子编号，类似于动态开点
	//sum数组：记录节点权值
	
	void init() //初始化 
	{
		tot = sz = 0;
		memset(lc, 0, sizeof lc);
		memset(rc, 0, sizeof rc);
		memset(sum, 0, sizeof sum);
		memset(rt, 0, sizeof rt);
	}
	
	void build(int &rt, int l, int r)
	{
		rt = ++sz; sum[rt] = 0; //新点
		if (l == r) return; //叶子结点，退出
		int mid = (l + r) >> 1;
		build(lc[rt], l, mid);
		build(rc[rt], mid + 1, r);
	}
	
	int update(int o, int l, int r, int p)
	{
		int oo = ++sz; //新点
		lc[oo] = lc[o]; rc[oo] = rc[o]; sum[oo] = sum[o] + 1;
		if (l == r) return oo;
		int mid = (l + r) >> 1;
		if (mid >= p) lc[oo] = update(lc[oo], l, mid, p);
		else rc[oo] = update(rc[oo], mid + 1, r, p);//新加入的节点在哪个区间，就走到哪个区间里去
		return oo;//返回值为新点编号
	}
	
	void discrete() //对a数组初始化存入b数组中 
	{
		tot = n + 1;//取值范围[1,n+1], 故将tot=n+1 
		for (int i = 1; i <= tot; i++) b[i] = i; 
		//stable_sort(b + 1, b + n + 1);
		//tot = unique(b + 1, b + n + 1) - b - 1;
	}
	
	void contribute() //根据b数组建立主席树
	{
		build(rt[0], 1, tot);
		for (int i = 1; i <= n; i++)
		{
			int pos = lower_bound(b + 1, b + tot + 1, a[i]) - b;
			rt[i] = update(rt[i - 1], 1, tot, pos);
		}
	}
	
	int query(int u, int v, int l, int r, int k) 
	{
		int mid = (l + r) >> 1;
		if (l == r) return sum[v] - sum[u];
		int ans = 0;
		if (k <= mid)
		{
			int x = sum[rc[v]] - sum[rc[u]];
			ans += query(lc[u], lc[v], l, mid, k) + x;
		}
		else
			ans += query(rc[u], rc[v], mid + 1, r, k);
		return ans;
	}
	
	int query_geq_k_cnt(int l, int r, int k)//求[l,r]中 大于等于k 的个数
	{
		return query(rt[l - 1], rt[r], 1, tot, k);//前缀和思想，[1,r]-[1,l-1]=[l,r]
	}
}chm_tree;

const int N = 1e6 + 10;
int n, q, a[N], Next[N], pre[N];
//next[i]:点i右侧最近相同权值的下标 

inline int read()
{
    int s = 0, w = 1;
    char c = getchar();
    for (; !isdigit(c); c = getchar()) if (c == '-') w = -1;
    for (; isdigit(c); c = getchar()) s = (s << 1) + (s << 3) + (c ^ 48);
    return s * w;
}
inline void out(int a)
{
	if (a < 0) {putchar('-'); a = -a;}
    if (a >= 10) out(a / 10);
    putchar(a % 10+ '0');
}

int main()
{
	n = read(); q = read();
	for (int i = 1; i <= n; i++) a[i] = read();
	
	for (int i = 1; i <= n; i++)
	{
		if (pre[a[i]]) Next[pre[a[i]]] = i;
		pre[a[i]] = i;
	}
	for (int i = 1; i <= n; i++) 
		if (!Next[i]) Next[i] = n + 1;
	
	chm_tree.init();
	chm_tree.n = n;
	for (int i = 1; i <= chm_tree.n; i++) chm_tree.a[i] = Next[i];
	
	chm_tree.discrete();//此题不需要离散化,模板稍有修改 
	chm_tree.contribute();
	
	while (q--)
	{
		int l, r, k;
		l = read(); r = read();
		k = r + 1;
		int ans = chm_tree.query_geq_k_cnt(l, r, k);
		out(ans);
		puts("");
	}
	
	return 0;
}


Measured memory_bytes: 203396
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

ll ncr(ll n, ll r){
  if(n < r) return 0;
  if(r > n-r) r = n-r;

  ll a = 1, b = 1;
  for(int i = 0; i < r; i++){
    a *= (n - i);
  }
  for(int i = 0; i < r; i++){
    b *= (i + 1);
  }
  return a/b;
}

int main(){
  string N;
  cin >> N;
  int ketaN = N.size();
  int K;
  cin >> K;
  vector<vvll> dp(110, vvll(2, vll(4, 0)));
  dp.at(0).at(1).at(0) = 1; //0
  dp.at(0).at(1).at(1) = N.at(0)-'0' - 1; //その桁の数未満
  dp.at(0).at(0).at(1) = 1; //そのもの
  for(int i = 0; i < ketaN-1; i++){
    int D = N.at(i+1)-'0';
    for(int j = 0; j < 2; j++){
      for(int k = 0; k <= 3; k++){
        for(int l = 0; l <= (j? 9: D); l++){
          if(l != 0){
            if(k == 3) continue;
            dp.at(i+1).at(j || (l < D)).at(k+1) += dp.at(i).at(j).at(k);
          }
          else{
            dp.at(i+1).at(j || (l < D)).at(k) += dp.at(i).at(j).at(k);
          }
        }
      }
    }
  }
  cout << dp.at(ketaN-1).at(0).at(K) + dp.at(ketaN-1).at(1).at(K) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
  
int main()
{
    int a;
    int b;
  
    scanf("%d %d\n", &a, &b);
    if(a < b)
    {
        printf("a < b\n");
    }
    else if(a > b)
    {
        printf("a > b\n");
    }
    else
    {
        printf("a == b\n");
    }
    return 0;
}

Measured memory_bytes: 584
import java.util.*;

public class Main {
    public static double min(double a,double b){
        return (a<b)?a:b;
    }
    
    public static double max(double a,double b){
        return (a>b)?a:b;
    }
    
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        
        double A=(double)a;
        double B=(double)b;
        
        double minA=12.5*A;
        double maxA=12.5*(A+1)-1;
        double minB=10*B;
        double maxB=10*(B+1)-1;
        
       for(int i=0;i<100000;i++){
           if(i>=minA&&i<=maxA&&i>=minB&&i<=maxB){
               System.out.println(i);
               return;
           }
       }
       
       System.out.println(-1);
    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
 
int N;
int main() 
{
    cin >> N;
    int np =N, res = 0;
 
    while (np > 0) res+=np%10, np/=10;
    if (N%res==0) cout << "Yes "  << endl; 
    else cout << "No "  << endl;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int[] xa = sc.intarr;
            if(xa[0] >= xa[1])
            {
                wr.wri("10");
            }
            else
            {
                wr.wri("0");
            }
        }


    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


Measured memory_bytes: 13268
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}

int main(void){
	int n=in(),i,l,r,ans=0;
	rep(i,n){
		l=in();
		r=in();
		ans+=r-l+1;
	}
	print(ans);
	return 0;
}

Measured memory_bytes: 128
using System; 
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq; 
using E = System.Linq.Enumerable; 


class Program {
    static void Main(string[] args) {
        
        var N = long.Parse(Console.ReadLine());
        
        var ans = new long[N];
        var count = 1;
        for(int i=1;i <=55555 ;i = i+5){
            if(IsPrime(i)){
                ans[count-1] = i;
                count++;
                if(count > N){
                    break;
                }
            }
        }
        Console.WriteLine(string.Join(" ",ans));
        
     }
     
     
     public static bool IsPrime(int num) { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; //偶数はあらかじめ除く
      double sqrtNum = Math.Sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) { // 素数ではない 
      return false; } } // 素数である
       return true; }
}
     
     
                   
public class PriorityQueue<T> : IEnumerable<T> { private readonly List<T> _data = new List<T>(); private readonly IComparer<T> _comparer; private readonly bool _isDescending; public PriorityQueue(IComparer<T> comparer, bool isDescending = true) { _comparer = comparer; _isDescending = isDescending; } public PriorityQueue(Comparison<T> comparison, bool isDescending = true) : this(Comparer<T>.Create(comparison), isDescending) { } public PriorityQueue(bool isDescending = true) : this(Comparer<T>.Default, isDescending) { } public void Enqueue(T item) { _data.Add(item); var childIndex = _data.Count - 1; while (childIndex > 0) { var parentIndex = (childIndex - 1) / 2; if (Compare(_data[childIndex], _data[parentIndex]) >= 0) break; Swap(childIndex, parentIndex); childIndex = parentIndex; } } public T Dequeue() { var lastIndex = _data.Count - 1; var firstItem = _data[0]; _data[0] = _data[lastIndex]; _data.RemoveAt(lastIndex--); var parentIndex = 0; while (true) { var childIndex = parentIndex * 2 + 1; if (childIndex > lastIndex) break; var rightChild = childIndex + 1; if (rightChild <= lastIndex && Compare(_data[rightChild], _data[childIndex]) < 0) childIndex = rightChild; if (Compare(_data[parentIndex], _data[childIndex]) <= 0) break; Swap(parentIndex, childIndex); parentIndex = childIndex; } return firstItem; } public T Peek() { return _data[0]; } private void Swap(int a, int b) { var tmp = _data[a]; _data[a] = _data[b]; _data[b] = tmp; } private int Compare(T a, T b) { return _isDescending ? _comparer.Compare(b, a) : _comparer.Compare(a, b); } public int Count => _data.Count; public IEnumerator<T> GetEnumerator() { return _data.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); }




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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code
int main(int argc, char const* argv[])
{
	int n,k;
	cin >> n >> k;
	VVL g(8);
	int edges = 0;
	for (int i = 3; i <= n; i++) {
		for (int j = 0; j < 8; j++) {
			if (((i >> j) & 1) == 1) {
				g[j].push_back(i);
				edges++;
			}
		}
	}
	cout << edges << endl;
	for (int i = 0; i < 8; i++) {
		for (int j = 0; j < g[i].size(); j++) {
			cout << i+1 << " " << g[i][j] << endl;
		}
	}

	for (int j = 0; j < k; j++) {
		string s;
		int ans = 0;
		for (int i = 1; i <= min(8,n); i++) {
			cout << i << endl;
			cin >> s;
			if (s == "Yes") {
				goto end;
			}
			if (s == "Near") {
				ans += (1 << (i - 1));
			}
		}
		cout << ans << endl;
		cin >> s;
end:
		int tmp;
	}
	return 0;
}




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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> heights(N);
    for (int i = 0; i < N; i++) cin >> heights[i];

    vector<int> dp(N, 0);
    dp[0] = 0;

    for (int i = 1; i < N; i++) {
        int idx = i - 1;
        int ans = INT_MAX;
        int limit = K;
        while (limit-- > 0 && idx >= 0) {
            ans = min(ans, dp[idx] + abs(heights[i] - heights[idx]));
            idx -= 1;
        }

        dp[i] = ans;
    }

    cout << dp[N - 1] << endl;
    return 0;
}


Measured memory_bytes: 1024
S = input()
l = sorted(list(set(S)))

ans = ""
for i in range(len(l)):
  if ord(l[i]) !=  97 + i:
    ans = chr(97+i)
    break
  elif i == 25 and l[i] == "z":
    ans = "None"

if ans != "":
 print(ans)
else:
  print(chr(ord(l[-1])+1))


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

using ll = long long;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m + 1, 0);
    rep(i, n) {
        int k;
        cin >> k;
        rep(j, k) {
            int tmp;
            cin >> tmp;
            a[tmp]++;
        }
    }
    int ans = 0;
    rep(i, m + 1) {
        if(a[i] == n)
            ans++;
    }
    cout << ans << endl;

    return 0;
}

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

/*
int main() {
  string a, b;
  while (cin >> a >> b) {
    cout << "m['" << a << "'] = \"" << b << "\";" << endl;
  }
}
*/

vector<string> split(string s) {
  vector<string> res;
  string t;
  for (int i = 0; i < s.size(); ++i) {
    t += s[i];
    if (t.size() == 5) {
      res.push_back(t);
      t = "";
    }
  }

  return res;
}

int main() {
  string s;
  map<char, string> m;
  map<string, string> t;

  m[' '] = "101";
  m['\''] = "000000";
  m[','] = "000011";
  m['-'] = "10010001";
  m['.'] = "010001";
  m['?'] = "000001";
  m['A'] = "100101";
  m['B'] = "10011010";
  m['C'] = "0101";
  m['D'] = "0001";
  m['E'] = "110";
  m['F'] = "01001";
  m['G'] = "10011011";
  m['H'] = "010000";
  m['I'] = "0111";
  m['J'] = "10011000";
  m['K'] = "0110";
  m['L'] = "00100";
  m['M'] = "10011001";
  m['N'] = "10011110";
  m['O'] = "00101";
  m['P'] = "111";
  m['Q'] = "10011111";
  m['R'] = "1000";
  m['S'] = "00110";
  m['T'] = "00111";
  m['U'] = "10011100";
  m['V'] = "10011101";
  m['W'] = "000010";
  m['X'] = "10010010";
  m['Y'] = "10010011";
  m['Z'] = "10010000";

  t["00000"] = "A";
  t["00001"] = "B";
  t["00010"] = "C";
  t["00011"] = "D";
  t["00100"] = "E";
  t["00101"] = "F";
  t["00110"] = "G";
  t["00111"] = "H";
  t["01000"] = "I";
  t["01001"] = "J";
  t["01010"] = "K";
  t["01011"] = "L";
  t["01100"] = "M";
  t["01101"] = "N";
  t["01110"] = "O";
  t["01111"] = "P";
  t["10000"] = "Q";
  t["10001"] = "R";
  t["10010"] = "S";
  t["10011"] = "T";
  t["10100"] = "U";
  t["10101"] = "V";
  t["10110"] = "W";
  t["10111"] = "X";
  t["11000"] = "Y";
  t["11001"] = "Z";
  t["11010"] = " ";
  t["11011"] = ".";
  t["11100"] = ",";
  t["11101"] = "-";
  t["11110"] = "'";
  t["11111"] = "?";

  while (getline(cin, s)) {
    string ss;
    for (int i = 0; i < s.size(); ++i) {
      ss += m[s[i]];
    }

    if (ss.size() % 5) ss += string(5 - (int)ss.size() % 5, '0');
    vector<string> v = split(ss);
    for (int i = 0; i < v.size(); ++i) {
      cout << t[v[i]];
    }
    puts("");
  }
}

Measured memory_bytes: 3072
#coding:utf-8
import sys
n=int(input())
a=map(int,input().split())

min,max,sum=2**63-1,-2**63,0

for i in a:
    if i<min:
        min=i
    if max<i:
        max=i
    sum+=i

print(str(min)+" "+str(max)+" "+str(sum))

Measured memory_bytes: 8372
#include<iostream>
using namespace std;
int main() {
  int A, B;
  cin >> A >> B;
  int a = min(A, B);
  int c = max(A,B);
  int b = 16 - 2*a;
  b = b/2;
  if(c - a <= b)  cout << "Yay!" << endl;
  else  cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 256