akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int k,l,ans=1000;
  for(int i=0 ; i<s.size()-2 ; i++){
    k=100*(s.at(i)-'0')+10*(s.at(i+1)-'0')+(s.at(i+2)-'0');
    if(k>753)
      l=k-753;
    else
      l=753-k;
    ans=min(ans,l);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
l,r = map(int, input().split())
n = r - l + 1
if 2019<=n:
    print(0)
elif 3<=n and n<2019:
    for k in range(l,r+1):
        if k%673==0:
            print(0)
            exit()

    mod = 2019
    for i in range(l,r):
        for j in range(l+1,r+1):
            mod_new = (i*j)%2019
            if mod_new == 1:
                print(1)
                exit()
            else:
                mod = min(mod,mod_new)
    print(mod)                             
else:
    print((l*r)%2019)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define reg register
#define mo 1000000007
#define maxn 1000
inline ll read()
{
	reg ll x=0,w=0;reg char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
inline int ksm(int x,int y)
{
	int a=1;
	while(y)
	{
		if(y&1)a=1ll*a*x%mo;
		x=1ll*x*x%mo;y>>=1;
	}return a;
}
inline void Min(int &x,int y){x=x>y?y:x;}
inline int gcd(int x,int y){return y?gcd(y,x%y):x;}
int n,m,base,res,ans=1,rt;
int headd[maxn],nextt[maxn<<1],to[maxn<<1],cntt=1;
inline void link(int u,int v)
{nextt[++cntt]=headd[u];headd[u]=cntt;to[cntt]=v;}
vector<int>G[maxn];
int tot,cnt,bs[maxn],bel[maxn],low[maxn],dfn[maxn],top,zhan[maxn];
inline void Tarjan(int u)
{
	reg int i,v;
	if(rt==u&&headd[u]==0){G[++tot].push_back(u);return ;}
	zhan[++top]=u;low[u]=dfn[u]=++cnt;
	for(i=headd[u];i;i=nextt[i])
	{
		v=to[i];
		if(!dfn[v])
		{
			Tarjan(v);
			Min(low[u],low[v]);
			if(low[v]>=dfn[u])
			{
				++tot;G[tot].push_back(u);
				while(zhan[top]!=v)
					G[tot].push_back(zhan[top--]);
				--top;G[tot].push_back(v);
			}
		}
		else Min(low[u],dfn[v]);
	}
}
int vis[maxn];
inline int get(int x)
{
	int sz=G[x].size(),i,j,res=0;
	for(i=1;i<=n;++i)vis[i]=0;
	for(i=0;i<sz;++i)vis[G[x][i]]=1;
	for(i=0;i<sz;++i)
		for(j=headd[G[x][i]];j;j=nextt[j])
			if(vis[to[j]]==1)++res;
	return res/2;
}
int jc[maxn];
inline int C(int x,int y)
{
	if(x<y||x<0||y<0)return 0;
	return 1ll*jc[x]*ksm(1ll*jc[y]*jc[x-y]%mo,mo-2)%mo;
}
int main()
{
	n=read(),m=read(),base=read();
	reg int u,v,i,j;
	for(i=1;i<=m;++i)
	{
		u=read(),v=read();
		link(u,v);link(v,u);
	}jc[0]=1;
	for(i=1;i<=m+n+base;++i)jc[i]=1ll*i*jc[i-1]%mo;
	for(i=1;i<=n;++i)if(!dfn[i])rt=i,Tarjan(i);
	for(i=1;i<=tot;++i)bs[i]=get(i);
	for(i=1;i<=tot;++i)
	{
		if(bs[i]==G[i].size())
		{
			res=0;
			for(j=0;j<bs[i];++j)
				(res+=ksm(base,gcd(j,bs[i])))%=mo;
			res=1ll*res*ksm(bs[i],mo-2)%mo;
		}
		else if(bs[i]>G[i].size())res=C(bs[i]+base-1,base-1);
		else res=ksm(base,bs[i]);
		ans=1ll*ans*res%mo;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main()
{
	int n;

	scanf("%d", &n);

	if (n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9)
	{
		printf("hon\n");
	}
	else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8 )
	{
		printf("pon\n");
	}
	else
	{
		printf("bon\n");
	}
	return 0;
}

Measured memory_bytes: 1624
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<fstream>
#include<algorithm>
#include<utility>
using namespace std;
using ll = long long;

int main(){
  int n,m;
  bool flag = true;
  ll ans = 1;
  cin >> n >> m;
  vector<ll> num(n);
  for(ll i=0;i<n;i++) num[i] = -1;
  for(int i=0;i<m;i++){
    int s,c;
    cin >> s >> c;
    if(s>n) flag = false;
    else if(num[s-1]==-1||num[s-1]==c)  num[s-1] = c;
    else  flag = false;
  }
  if(num[0]==0&&n!=1) flag = false;
  if(!flag){
      cout << -1 << endl;
      return 0;
  }
  else{
    if(num[0]==-1){
      if(n==1)  num[0] = 0;
      else  num[0]=1;
    }
    for(ll i=1;i<n;i++){
      if(num[i]==-1)  num[i]=0;
    }
  }
  for(int i=0;i<n;i++){
    cout << num[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  if (S == "RRR") {
    cout << "3" << endl; }
  if (S == "SSS"){
    cout << "0" << endl;  } 
  if (S == "RSS" || S == "SRS" || S == "SSR" || S == "RSR") {
    cout << "1" << endl; }
  if (S == "RRS" || S == "SRR"){
    cout << "2" << endl; }
}


Measured memory_bytes: 3568
import java.util.Scanner;

public class Main {

    static class UnionFind {
        int[] parent;
        int[] rank;
        int[] elmsize;

        UnionFind(int size) {
            parent = new int[size];
            rank = new int[size];
            elmsize = new int[size];

            for(int i = 0; i < size; i++) makeSet(i);
        }

        void makeSet(int x) {
            parent[x] = x;
            rank[x] = 0;
            elmsize[x] = 1;
        }

        void unite(int x, int y) {
            int xRoot = root(x);
            int yRoot = root(y);

            if(rank[xRoot] > rank[yRoot]) {
                parent[yRoot] = xRoot;
                elmsize[xRoot] += elmsize[yRoot];
            } else if(rank[xRoot] < rank[yRoot]) {
                parent[xRoot] = yRoot;
                elmsize[yRoot] += elmsize[xRoot];
            } else if(xRoot != yRoot) {
                parent[yRoot] = xRoot;
                rank[xRoot]++;
                elmsize[xRoot] += elmsize[yRoot];
            }
        }

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

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

        int size(int x) {
            return elmsize[root(x)];
        }
    }

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); int m = sc.nextInt(); int k = sc.nextInt();
        UnionFind uf = new UnionFind(n);
        int[] deg = new int[n];
        for(int i = 0; i < m; i++) {
            int a, b;
            a = Integer.parseInt(sc.next()); b = Integer.parseInt(sc.next());
            --a; --b;
            deg[a]++; deg[b]++;
            uf.unite(a, b);
        }
        int[][] to = new int[k][2];
        for(int i = 0; i < k; i++) {
            to[i][0] = Integer.parseInt(sc.next()) -1;
            to[i][1] = Integer.parseInt(sc.next()) -1;
        }
        int[] ans = new int[n];
        for(int i = 0; i < n ; i++) {
            ans[i] = uf.size(i) - 1 - deg[i];
        }
        for(int i = 0; i < k; i++) {
            if(uf.same(to[i][0], to[i][1])) {
                ans[to[i][0]]--;
                ans[to[i][1]]--;
            }
        }
        for(int i = 0; i < n; i++) {
            System.out.printf("%d%c", ans[i], i==n-1?'\n':' ');
        }
    }
}

Measured memory_bytes: 101512
input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
S = lines.shift().split('')
cnt = 0
p = S[S.length-1]
for (i=S.length- 2; i>=0; i--) {
    if ((p == 0 && S[i] == 1) || (p == 1 && S[i] == 0)) {
        cnt += 2
        S.splice(i, 2)
    }
    p = S[i]
}
console.log(cnt)


Measured memory_bytes: 10956
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

//nCr mod m
#define MOD 998244353
#define M 2200000
vector<ll> fact;
bool h=false;
void init(){
	h=true;
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// a^b mod MOD
ll powmod(ll a,ll b,ll m=MOD){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
//nCr
ll nCr(ll n,ll r,ll m=MOD){
	if(!h)init();
	if(n<0||r<0||n<r)return 1;//??????
	ll out=fact[n]*powmod(fact[r]*fact[n-r]%m,m-2,m)%m;
	return out;
}
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}

int n,m,q;
int out;
vi in;
vvi w;
void dfs(int a,int b){
	if(a==n){
		int s=0;
		rep(i,q)if(in[w[i][1]-1]-in[w[i][0]-1]==w[i][2])s+=w[i][3];
		cmax(out,s);
		return;
	}
	loop(i,b,m+1){
		in[a]=i;
		dfs(a+1,i);
	}
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin>>n>>m>>q;
	in=vi(n);
	w=vvi(q,vi(4));
	rep(i,q)rep(j,4)cin>>w[i][j];
	dfs(0,1);
	cout<<out<<endl;
}


Measured memory_bytes: 3652
x = int(input())

runrun=[[1,2,3,4,5,6,7,8,9],[]]
count=9
keta=2
end=False
ans=-1

if x<=9:
    ans=x
    end=True

while True:
    if end:
        break

    for ini in runrun[keta-2]:

        if ini%10==0:
            runrun[keta-1].append(ini*10)
            count+=1
            if count==x:
                end=True
                ans=ini*10
                break
            runrun[keta-1].append(ini*10+1)
            count+=1
            if count==x:
                end=True
                ans=ini*10+1
                break

        elif ini%10==9:
            runrun[keta-1].append(ini*10+8)
            count+=1
            if count==x:
                end=True
                ans=ini*10+8
                break
            runrun[keta-1].append(ini*10+9)
            count+=1
            if count==x:
                end=True
                ans=ini*10+9
                break

        else:
            runrun[keta-1].append(ini*10+ini%10-1)
            count+=1
            if count==x:
                end=True
                ans=ini*10+ini%10-1
                break
            runrun[keta-1].append(ini*10+ini%10)
            count+=1
            if count==x:
                end=True
                ans=ini*10+ini%10
                break
            runrun[keta-1].append(ini*10+ini%10+1)
            count+=1
            if count==x:
                end=True
                ans=ini*10+ini%10+1
                break

    keta +=1
    runrun.append([])

print(ans)

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

dic = {}

print()

for i in range(N):
    S = input()

    if S in dic:
        dic[S] += 1
    else:
        dic[S] = 1

dic2 = sorted(dic.items(), key=lambda x:x[1], reverse=True)

max_num = dic2[0][1]

l = [p[0] for p in dic2 if p[1] == max_num]

l2 = sorted(l)

for i in range(len(l2)):
    print(l2[i])


Measured memory_bytes: 47324
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val M = nextInt()
    println(24 + (24 - M))
}

Measured memory_bytes: 31800
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
   

    ll n,m;
    cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2 << endl;
}

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

int main(){
    int N,M;
    cin >> N >> M;
    vector<vector<int>> s(M);
    for(int i=0;i<M;i++){
        int k;
        cin >> k;
        for(int j=0;j<k;j++){
            int a;
            cin >> a;
            s[i].push_back(a-1);
        }
    }

    vector<int> p(M);
    for(int i=0;i<M;i++) cin >> p[i];

    long long res = 0;
    for(int bit=0;bit<(1<<N);bit++){
        bool ok = true;
        for(int i=0;i<M;i++){
            int con = 0;
            for(auto v : s[i]){
                if(bit & (1<<v)) con++;
            }
            if(con%2 != p[i]) ok = false;
        }
        if(ok) res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
import sys
from math import log2, floor

L = int(sys.stdin.readline().rstrip())

def main():
    n = floor(log2(L)) + 1
    m = 2 * (n - 1)
    edges = []
    for i in range(1, n):
        edges.append((i, i+1, 0))
        edges.append((i, i+1, 2**(i-1)))
    
    cur = 2 ** (n - 1)
    q = L - cur
    for i in range(1, n):
        q, r = divmod(q, 2)
        if not r:
            continue
        else:
            edges.append((i, n, cur))
            cur += 2 ** (i - 1)
            m += 1
    
    yield (n, m)
    for e in edges:
        yield e

if __name__ == '__main__':
    ans = main()
    for i in ans:
        print(*i, sep=' ')

Measured memory_bytes: 3188
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int N = scanner.nextInt();
        int sum = 0;
        for (int i = 0; i < N; i++) {
            int A = scanner.nextInt();
            int B = scanner.nextInt();
            sum += B-A+1;
        }
        System.out.println(sum);
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {
                    line = br.readLine();
                }
                s = line.split(reg, 0);
                i = 0;
                return s[i++];
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public int nextInt() {
            try {
                return Integer.parseInt(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public double nextDouble() {
            try {
                return Double.parseDouble(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public long nextLong()  {
            try {
                return Long.parseLong(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }
    }
}


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

using namespace std;
using ll = long long;
constexpr int INF = numeric_limits<int>::max();
template <typename T, typename... Args>
const T& min(const T& a, Args... args) {
  return min(a, min(args...));
}
template <typename T, typename... Args>
const T& max(const T& a, Args... args) {
  return max(a, max(args...));
}

#pragma GCC optimize("O3")
static const auto __ = [] {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  return nullptr;
}();

int main(int argc, char* argv[]) {
  int a, b;
  cin >> a >> b;
  cout << (a < 10 && b < 10 ? a * b : -1) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

const int mod = 1000000007;

long long solve(long long A, long long B)
{
	long long ans = 1;
	for (int i = 0; i < A - 1; i++)
		ans = (ans * (A - i)) % mod;

	for (int i = 0; i < B - 1; i++)
		ans = (ans * (B - i)) % mod;

	return ans;
}

int main()
{
	int ans = 1;
	int N, M;

	cin >> N >> M;

	if (abs(N - M) >= 2)
	{
		cout << 0 << endl;
	}
	else
	{
		if (N == M)
			ans = (solve(N, M) * 2) % mod;
		else
			ans = (solve(N, M)) % mod;

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	w := Scan()
	x := make([]int, 26)
	for _, r := range w {
		x[int(r)-97]++
	}
	ans := "Yes"
	for _, v := range x {
		if v%2 != 0 {
			ans = "No"
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1772
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;


int main(void)
{
	//変数の宣言
	int n,m;

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	double ans=0;
	int count=0;
	double temp=0;
	int temp1=0;
	int temp2=0;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;



	//データの読み込み


	scanf("%d %d",&n,&k);
//	scanf_s("%d %d",&n,&k);

//	scanf("%s",&s);
//	scanf_s("%s",&s,5);


/*	for(i=1;i<=n;i++){
//		scanf("%c",&a,&b,&f);
		scanf_s("%c",&a,&b,&f);
	}*/



	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	for(i=1;i<=n;i++){
		temp=1;
		count=i;
		while(count<k){
			count=count*2;
			temp=temp/2;
		}

		ans=ans+temp;
	}

	ans=ans/n;

	//	printf("計算部分終了\n");

	//出力
	printf("%1.12lf",ans);

	//	printf("結果の出力終了\n");

	return 0;
}



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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int N=2e5+100,MOD=1e9+7;

int ppow(int x,int y)
{
    int res=1;
    while(y)
    {
        if(y&1)
            res=res*x%MOD;
        y>>=1;
        x=x*x%MOD;
    }
    return res;
}

int rev(int x)
{
    return ppow(x,MOD-2);
}

vector<int> g[N];
int f[N],r[N];
int cnt[N],dp[N];
int ans[N];

void dfs1(int v,int p)
{
    cnt[v]=1;
    dp[v]=1;
    for(int to:g[v])
        if(to!=p)
        {
            dfs1(to,v);
            cnt[v]+=cnt[to];
            dp[v]=dp[v]*dp[to]%MOD;
            dp[v]=dp[v]*r[cnt[to]]%MOD;
        }
    dp[v]=dp[v]*f[cnt[v]-1]%MOD;
}

void dfs2(int v,int p)
{
    ans[v]=dp[v];
    for(int to:g[v])
        if(to!=p)
        {
            int dp_v=dp[v];
            int cnt_v=cnt[v];
            int dp_to=dp[to];
            int cnt_to=cnt[to];

            dp[v]=dp[v]*rev(dp[to])%MOD;
            dp[v]=dp[v]*f[cnt[to]]%MOD;
            dp[v]=dp[v]*r[cnt[v]-1]%MOD;
            cnt[v]-=cnt[to];
            dp[v]=dp[v]*f[cnt[v]-1]%MOD;

            dp[to]=dp[to]*dp[v]%MOD;
            dp[to]=dp[to]*r[cnt[v]]%MOD;
            dp[to]=dp[to]*r[cnt[to]-1]%MOD;
            cnt[to]+=cnt[v];
            dp[to]=dp[to]*f[cnt[to]-1]%MOD;

            dfs2(to,v);

            dp[v]=dp_v;
            cnt[v]=cnt_v;
            dp[to]=dp_to;
            cnt[to]=cnt_to;
        }
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin>>n;
    for(int i=1;i<=n-1;i++)
    {
        int a,b;
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    f[0]=1;
    for(int i=1;i<=n;i++)
        f[i]=f[i-1]*i%MOD;
    r[n]=rev(f[n]);
    for(int i=n-1;i>=0;i--)
        r[i]=r[i+1]*(i+1)%MOD;
    dfs1(1,0);
    dfs2(1,0);
    for(int i=1;i<=n;i++)
        cout<<ans[i]<<"\n";
}


Measured memory_bytes: 22512
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n;
int p[12]={0},q[12]={0};
int a,b;
int cnt = 0;
bool flag;
int i=1;
void print(const vector<int>& v)
{
    cnt++;
    i=1;
    flag = true;
    for_each(v.begin(), v.end(), [](int x) {
        if(x!=p[i++]) flag = false;
    });
    if(flag) a = cnt;
    i=1; flag = true;
    for_each(v.begin(), v.end(), [](int x) {
        if(x!=q[i++]) flag = false;
    });
    if(flag) b = cnt;
}

int main ()
{
    cin >> n;
    vector<int> v;
    for(int i=0;i<n;i++) v.push_back(i+1);
    for(int i=0;i<n;i++) cin >> p[i+1];
    for(int i=0;i<n;i++) cin >> q[i+1];
    do {
        print(v);
    } while (next_permutation(v.begin(), v.end()));
    cout << abs(a-b) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const long long N = 1e5 + 5;
const long long inf = 1e9;
using namespace std;

vector <long long> adj[N];
long long n, a[N], u, v, root;

void dfs(long long u, long long p){
    long long sum = 0, maxx = -inf;
    for (long long i = 0; i < adj[u].size(); i++){
        long long v = adj[u][i];
        if (v == p) continue;
        dfs(v, u);
        sum += a[v]; maxx = max(maxx, a[v]);
    }
    if (adj[u].size() == 1) return;
    long long x = sum - a[u], y = a[u] - x;
    if (x < 0 || y < 0) {cout << "NO"; exit(0);}
    long long Max = ((maxx > sum/2) ? sum - maxx : sum/2);
    if (Max < x) {cout << "NO"; exit(0);}
    a[u] = 2*a[u]-sum;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (long long i = 1; i <= n; i++) cin >> a[i];
    for (long long i = 1; i < n; i++){
        cin >> u >> v;
        adj[u].push_back(v); adj[v].push_back(u);
    }
    if (n == 2){
        if (a[1] == a[2]) {
            cout << "YES";
        }
        else{
            cout << "NO";
        }
        return 0;
    }
    for (long long i = 1; i <= n; i++) if (adj[i].size() > 1) {root = i; break;}
    dfs(root, root);
    if (a[root] != 0){
        cout << "NO";
    }
    else{
        cout << "YES";
    }
}


Measured memory_bytes: 13184
import sys
n,k=map(int,input().split())
a=list(map(int,input().split()))
visited=[0]*n
town=0
Town=0
visited[0]=0
lst=[]
if a[0]==1:
  print(1)
  sys.exit()
for i in range(n):
  town=a[town]-1
  if visited[town]!=0 or town==0:
    lst.append([town,visited[town],i+1])
    break
  else:
    visited[town]=i+1
Lst=[]
town=lst[0][0]
Lst.append(town)
if lst[0][2]-lst[0][1]-1==0:
  if k<lst[0][1]:
    print(visited.index(k)+1)
    sys.exit()
  else:
    print(lst[0][0]+1)
    sys.exit()
for i in range(lst[0][2]-lst[0][1]-1):
  town=a[town]-1
  Lst.append(town)
if k<=lst[0][1]:
  print(visited.index(k)+1)
else:
  k=k-lst[0][1]
  l=len(Lst)
  k=k%l
  print(Lst[k]+1)


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;

int main()
{
    int n;
    int card[4][13] = {};
    char character;
    int integer;
    cin >> n;
    rep(i, n)
    {
        cin >> character >> integer;
        switch (character)
        {
        case 'S':
            card[0][integer - 1] = 1;
            break;
        case 'H':
            card[1][integer - 1] = 1;
            break;
        case 'C':
            card[2][integer - 1] = 1;
            break;
        case 'D':
            card[3][integer - 1] = 1;
            break;
        }
    }

    rep(i, 4)
    {
        rep(j, 13)
        {
            if (card[i][j] == 0)
            {
                switch (i)
                {
                case 0:
                    cout << "S " << j+1 << endl;
                    break;
                case 1:
                    cout << "H " << j+1 << endl;
                    break;
                case 2:
                    cout << "C " << j+1 << endl;
                    break;
                case 3:
                    cout << "D " << j+1 << endl;
                    break;
                }
            }
        }
    }

    return 0;
}


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);


	int t;
	cin >> t;
	bool flag = false;
	while (t > 0)
	{
		int rem = t % 10;
		if (rem == 7)
		{
			flag = true;
			break;
		}
		t = t / 10;
	}
	if (flag)
		cout << "Yes" << "\n";

	else
		cout << "No" << "\n";




	return 0;
}


Measured memory_bytes: 3608
import qualified Data.Map as M

primes :: [Int]
primes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]

revPower :: Int -> Int -> Int
revPower n d = fst $ helper (0, n)
  where helper (i, n') = if n' `mod` d == 0
                         then helper (i + 1, n' `div` d)
                         else (i, n')

factoring :: Int -> M.Map Int Int
factoring n = M.fromList $ map (\p -> (p, revPower n p)) primes

merge :: (Ord k, Num a) => M.Map k a -> M.Map k a -> M.Map k a
merge  = M.intersectionWith (+)

values :: M.Map k a -> [a]
values = fmap snd . M.assocs

count :: [Int] -> Int
count fs = 
  let g2s = length $ filter (2 <=) fs
      g4s = length $ filter (4 <=) fs
      g14s = length $ filter (14 <=) fs
      g24s = length $ filter (24 <=) fs
      g74s = length $ filter (74 <=) fs
  in g74s +
     g24s * (g2s - 1) +
     g14s * (g4s - 1) +
     g4s * (g4s - 1) * (g2s - 2) `div` 2

main = do
  n <- read <$> getLine :: IO Int
  let fs = values . foldr1 merge $ map factoring [1..n]
  print $ count fs


Measured memory_bytes: 1148
from operator import itemgetter


def solve():
    N = int(input())
    AB = [[0, 0] for _ in range(N)]
    for i in range(N):
        AB[i] = list(map(int, input().split()))
    AB = sorted(AB, key=itemgetter(1))

    t = 0
    for i in range(N):
        t += AB[i][0]
        if t <= AB[i][1]:
            continue
        else:
            print('No')
            exit()
    print('Yes')


if __name__ == '__main__':
    solve()

Measured memory_bytes: 55192
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int a, b, c, d;
	std::cin >> a >> b >> c >> d;
	if (abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d)) {
		std::cout << "Yes\n";
	} else {
		std::cout << "No\n";
	}
}


Measured memory_bytes: 256
L,R = list(map(int,input().split()))

ans = 10**9
if R-L >= 2020:
    for i in range(L,L+2019):
        for j in range(L+1,L+2020):
            ans = min(ans,(i*j)%2019)
else:
    for i in range(L,R):
        for j in range(L+1,R+1):
            ans = min(ans,(i*j)%2019)

print(ans)

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

using namespace std;

int main(){
    long long N, D;
    cin >> N >> D;

    int res = 0;
    for(int i=0; i<N; i++){
        long long x, y;
        cin >> x >> y;
        long long calc = x*x + y*y;
        long long lim = D*D;
        // cout << "x: " << x << "\ty: " << y << endl;
        // cout << "x*x + y*y = " << calc << endl;
        if(calc <= lim)res++;
    }

    cout << res << endl;
}

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+123;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};       ///first 4 for adjacent
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};
ll dx8[]= {+1, +1, -1, -1, +2, +2, -2, -2};    ///knights move
ll dy8[]= {+2, -2, +2, -2, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define MP make_pair
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ a%=MOD;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=MOD;--b;}a*=a;a%=MOD;b/=2;}return pr;}
ll modinverse(ll a){return powmod(a,MOD-2);}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///


void _case()
{
    ll i,n,ans=0,a,b,c,d,x,y;
    cin>>a>>b>>c>>d;
    cout<<max({a*c,a*d,b*c,b*d}) el;
}

main()
{
    fastio();
    _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


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

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

  int n;
  cin>>n;
  vector<int> d(n);
  for(int i=0;i<n;i++){
    cin>>d[i];
  }

  int res=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      res += d[i] * d[j];
    }
  }

  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
int cmp3(T lhs, T rhs) { return (lhs == rhs) ? 0 : (lhs > rhs) ? 1 : -1; }

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

bool solve(string const &S) {
  string eo[2] = { "RUD", "LUD" };
  REP(i, S.size()) {
    if (eo[i%2].find(S[i]) == std::string::npos) {
      return false;
    }
  }
  return true;
}

int main() {
  string S; cin >> S;
  cout << (solve(S) ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
x,y=map(int,input().split())
MOD=10**9+7
ans=0
if y>x:
    x,y=y,x

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = MOD #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

for a in range(1,x//2+1):
    b=x-2*a
    if 2*b+a==y:
        tmp=cmb(b+a,a,mod)%MOD
        ans+=tmp
        ans%=MOD

print(ans)




Measured memory_bytes: 127560
n, y = map(int,input().split())

A = -1
B = -1
C = -1
for a in range(n+1):
    for b in range(n+1):
        c = n-a-b
        tem = 10000*a + 5000*b + 1000*c
        if (tem == y) and (c>=0):
            A = a
            B = b
            C = c
            break

print(A, B, C)      

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cctype>
#include <cstdio>
#include <math.h>
using f32 = float;
using f64 = double;
using f80 = __float80;
constexpr int64_t INF = 1'010'000'000'000'000'017LL;

constexpr int64_t MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = asin(-1.0);
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vs = vector<string>;
using vl = vector<LL>;
using vvl = vector<vl>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
#define rep(i, n) for (LL i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

int main()
{
    int a, b, c = 1, d, n, m;
    cin >> n >> m;
     d = n;
    rep(i, m)
    {
        cin >> a >> b;
        c = max(c, a);
        d = min(d, b);
    }
    cout << max(0, d - c + 1)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back

using namespace std;

int main() {
  int n, tmp;
  while (cin >> n, n) {
    vector<int> score;
    for (int i = 0; i < n; i++) {
      cin >> tmp;
      score.pb(tmp);
    }
    sort(score.begin(), score.end());
    int sum = 0;
    for (int i = 1; i < n-1; i++) {
      sum += score[i];
    }
    cout << sum/(n-2) << el;
  }
}

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

int main() {
  int n,i,a,b;
  cin >> n;
  
  int ans, amin=1000;
  for(i=1; i<n; i++){
    a=i; b=n-a;
    ans=0;
    while(a>0 || b>0){
      ans+= a%10+b%10;
      a/=10; b/=10;
    }
    amin=min(ans, amin);
  }
  
  cout << amin;
}



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

int main(){

	int cnt, list[6][7];
	string str, s;

	for(int i=1; i<7; i++){
		for(int j=1; j<6; j++){
			if(i == 6 && j > 1){
				switch(j){
					case 2 : list[j][i] = '.'; break;
					case 3 : list[j][i] = '?'; break;
					case 4 : list[j][i] = '!'; break;
					case 5 : list[j][i] = ' '; break;
				}
			}
			else {
				list[j][i] = 'a' + 5 * (i - 1) + j - 1;
			}
		}
	}

	while(cin >> str){
		if(str.length() % 2 == 1){
			cout << "NA" << endl;
			continue;
		}
		
		s = "";
		for(int i=0; i<str.length(); i+=2){
			if(str[i] - '0' > 0 && str[i] - '0' < 7 && str[i+1] - '0' > 0 && str[i+1] - '0' < 6){
				s += list[str[i+1]-'0'][str[i]-'0'];
			}
			else {
				cout << "NA" << endl;
				break;
			}
			if(i == str.length() - 2) cout << s << endl;
		}
	}

	return 0;

}

Measured memory_bytes: 1188
N,M = map(int, input().split())
L,R = map(int, input().split())

for _ in range(M-1):
    l,r = map(int, input().split())
    if R>r:
        R = r
    if L<l:
        L = l

if (R-L+1)>0:
    print(R-L+1)
else:
    print(0)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
    long long int n, ans = 0;
    cin>>n;
    
    long long int dp[n+1];
    
    for(long long int i=0;i<=n;i++)
    {
        dp[i] = 1;
    }
    
    for(int i=2;i<=n;i++)
    {
        for(int j=i;j<=n;j=j+i)
        {
            dp[j]++;
        }
    }
    
    for(long long int i=1;i<=n;i++)
    {
        ans += i * dp[i];
    }
    
    cout<<ans;
    return 0;
}

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

template<typename T> struct MedianPrique {
    priority_queue<T> L;
    priority_queue<T, vector<T>, greater<>> R;
    int sz;
    T L_sum, R_sum;
    MedianPrique() : sz(0), L_sum(0LL), R_sum(0LL) {}
    void L_push(T val) { L_sum += val; L.push(val); ++sz; }
    void L_pop()       { L_sum -= L.top(); L.pop(); --sz; }
    void R_push(T val) { R_sum += val; R.push(val); ++sz; }
    void R_pop()       { R_sum -= R.top(); R.pop(); --sz; }
    void push(T val) {
        if (sz == 0) L_push(val);
        else if (sz % 2 == 1) {
            T tp = L.top();
            if (tp > val) {
                L_pop();
                L_push(val);
                R_push(tp);
            } else {
                R_push(val);
            }
        } else {
            T tp = R.top();
            if (val > tp) {
                R_pop();
                R_push(val);
                L_push(tp);
            } else {
                L_push(val);
            }
        }
    }
    T getMedian(bool needtobeodd = true) {
        if (sz % 2 == 1) return L.top();
        assert(!needtobeodd);
        return (L.top() + R.top()) / 2;
    }
    T getMinimumDifference() {
        int L_sz = (sz + 1) / 2;
        int R_sz = sz / 2;
        T med = L.top();
        return (R_sum - med * R_sz) + (med * L_sz - L_sum);
    }
};

signed main() {

    int Q; cin >> Q;

    MedianPrique<ll> mp;
    ll B;

    while (Q--) {
        int q; cin >> q;
        if (q == 1) {
            int a, b; cin >> a >> b;
            mp.push(a);
            B += b;
        } else if (q == 2) {
            cout << mp.L.top() << ' ' << mp.getMinimumDifference() + B << endl;
        }
    }

}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define RAP(i, n) for(ll i=0;i<(n);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)
map<ll, ll> N;
ll mod = pow(10,  9) + 7;
void Pf(ll n){
    ll check = n;
    for(ll i=2;i<=n;i++){
        while(check%i==0){
            N[i]++;
            check /= i;
        }
        if(check==1){
            break;
        }
    }
}
int main(){
    ll n, ans = 1;
    cin >> n;
    for(ll i=2;i<=n;i++){
        Pf(i);
    }
    for(auto itr=N.begin();itr!=N.end();itr++){
        ans = ans*(itr->second+1)%mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main(void){
    char W[11],T[1001];
    int i,count=0;
    
    scanf("%s",W);
    while(1){
        scanf("%s",T);
        if(strcmp(T,"END_OF_TEXT")==0) break;
        for(i=0;T[i]!='\0';i++){
            T[i]=tolower(T[i]);
        }
        if(strcmp(W,T)==0) count=count+1;
    }
    printf("%d\n",count);
    return (0);
}
 


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2 * acos (0.0)
int main()
{
    ll a,b,c,d,e,f,g,h,ct;
    string s1,s2,s3,s4;
    ll n,k,t,x,y,x1,x2,y1,y2,m;
    cin>>t;
    m=0;
    for(ll i=1;i<=t;i++)
    {
        for(ll j=1;j<=t;j++)
        {
            for(ll k=1;k<=t;k++)
            {
                d=__gcd(__gcd(i,j),k);
                m+=d;
            }
        }
    }


     cout<<m<<endl;
}








Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define REPI(i,a,b) for(int (i)=int(a);i<int(b);++i)


int main(void){
  using namespace std;
  int N;cin >> N;
  int D;cin >> D;
  vector<vector<int>> X(N,vector<int>(D));

  REP(i,N){
    REP(j,D){
      cin >> X[i][j];
    }
  }

  auto ans = 0;

  REP(i,N){
    REPI(j,i+1,N){
      auto distanceSquared = 0;
      REP(k,D){
        distanceSquared += pow((X[i][k] - X[j][k]),2);
      }
      auto distance = sqrt((double)distanceSquared);
      if(pow((int)distance,2) == distanceSquared){
        ans++;
      }
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
constexpr ll mod = 1e9 + 7;
#define endl '\n'
 
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  string s;
  cin >> s;
  int i = 0;
  int ans = 0;
  int n = 3;
  while (i < n) {
    while (i < n && s[i] != 'R') ++i;
    if (i == n) break;
    int pi = i++;
    while (i < n && s[i] == 'R') ++i;
    ans = max(ans, i-pi);
  }
  cout << ans << endl;

}


Measured memory_bytes: 3648
#include <stdio.h>
#include <string.h>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;

typedef struct te{
    string s;
    int num;
    int i;
}te;

int main(){
    int a,c,i,j,k,n,r,x,y,z;

    cin >> n;
    int p[n+1],m[n+1];
    string s[n+1];
    for(i=1;i<n+1;i++){
        cin >> s[i];
        cin >> p[i];
    }
    te temp[n+1];

    for(i=1;i<n+1;i++){
        temp[i].s=s[i];
        temp[i].num=p[i];
        temp[i].i=i;
    }

    for(i=1;i<n+1;i++){
        for(j=n;j>i;j--){
            if(temp[j].num>temp[j-1].num){
                swap(temp[j],temp[j-1]);
            }
        }      
    }

    //for(i=1;i<n+1;i++)printf("%d\n",temp[i].i);

    for(i=1;i<n+1;i++){
        for(j=n;j>i;j--){
            if(temp[j].s<temp[j-1].s){
                swap(temp[j],temp[j-1]);
            }
        }
    }

    for(i=1;i<n+1;i++)printf("%d\n",temp[i].i);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll N, M, ans;
    ll Correct, Wrong;
    Correct = 0;
    Wrong   = 0;
    scanf("%lld %lld", &N, &M);
    vector<ll> p(N), q(N);
    REP(int,i,0,N){
        p.at(i) = 0;
        q.at(i) = -1;
    }
    string S;
    ll Number;
    REP(ll,i,0,M){
        cin >> Number >> S;
        if ( S.at(0) == 'W' ){
            p.at(Number-1)++;
        }
        else if ( S.at(0) == 'A' ){
            if ( q.at(Number-1) == -1 ){
                q.at(Number-1) = p.at(Number-1);
                Correct++;
            }
        }
    }
    REP(ll,i,0,N){
        if ( q.at(i) != -1 ) Wrong += q.at(i);
    }
    printf("%lld %lld\n", Correct, Wrong);
    return 0;
}

Measured memory_bytes: 1792
io = STDIN
N,M=io.gets.split.map(&:to_i)
to=Hash.new{|h,k|h[k]=[]}
M.times.each{u,v=io.gets.split.map(&:to_i);to[u]<<v}
S,T=io.gets.split.map(&:to_i)
dist=Array.new(N+1){Array.new(3,-1)}
q=[]
q<<[S,0]
dist[S][0]=0
while vl=q.shift
  v,l=vl
  to[v].each do |nv|
    nl=(l+1)%3
    next unless dist[nv][nl]==-1
    dist[nv][nl]=dist[v][l]+1
    q << ([nv,nl])
  end
end
puts dist[T][0]==-1 ? -1 : dist[T][0]/3


Measured memory_bytes: 21884