akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

struct Tree
{
    int N;
    vector<vector<int>> adjacency_list;

    int root;
    vector<bool> marked;
    vector<int> marks;

    Tree(const int N) : N(N), adjacency_list(N), marked(N), marks(N) {}

    void add_edge(const int a, const int b)
    {
        adjacency_list[a].push_back(b);
        adjacency_list[b].push_back(a);
    }

    void mark_vertex(const int v, const int p)
    {
        root = v;
        marked[v] = true;
        marks[v] = p;
    }

    vector<int> solve()
    {
        const auto infinity = int(1e9);

        struct Interval { int lower, upper; };
        auto constraints = vector<Interval>(N);

        auto distances = vector<int>(N);

        function<void(int, int)> preprocess = [&](const int v, const int parent)
        {
            if (marked[v]) constraints[v] = {marks[v], marks[v]};
            else constraints[v] = {-infinity, infinity};

            for (const auto w : adjacency_list[v]) if (w != parent)
            {
                distances[w] = distances[v]+1;
                preprocess(w, v);
                constraints[v].lower = max(constraints[v].lower, constraints[w].lower-1);
                constraints[v].upper = min(constraints[v].upper, constraints[w].upper+1);
            }
        };
        preprocess(root, -1);

        for (auto v = 0; v < N; v++) if (marked[v])
            if (distances[v]%2 != abs(marks[v]-marks[root])%2)
                return {};

        auto is_consistent = true;
        function<void(int, int)> process = [&](const int v, const int parent)
        {
            auto found = false;
            if (v == root)
                found = constraints[v].lower <= marks[v] && marks[v] <= constraints[v].upper;
            else
            {
                for (const auto m : {marks[parent]-1, marks[parent]+1})
                {
                    if (constraints[v].lower <= m && m <= constraints[v].upper)
                    {
                        marks[v] = m;
                        found = true;
                    }
                }
            }

            if (!found)
            {
                is_consistent = false;
                return;
            }
            else
            {
                for (const auto w : adjacency_list[v]) if (w != parent)
                    process(w, v);
            }
        };
        process(root, -1);

        if (is_consistent) return marks;
        else return {};
    }
};

int main()
{
    ios::sync_with_stdio(false);

    int N; cin >> N;
    auto tree = Tree(N);
    for (auto i = 0; i < N-1; i++)
    {
        int a, b; cin >> a >> b;
        tree.add_edge(a-1, b-1);
    }

    int K; cin >> K;
    for (auto i = 0; i < K; i++)
    {
        int v, p; cin >> v >> p;
        tree.mark_vertex(v-1, p);
    }

    const auto answer = tree.solve();
    if (answer.empty()) cout << "No" << "\n";
    else
    {
        cout << "Yes" << "\n";
        for (const auto x : answer) cout << x << "\n";
    }
}


Measured memory_bytes: 17024
#include <stdio.h>

int main(void)
{
  int n;
  scanf("%d", &n);
  int a[n], b[n], c[n - 1];
  for (int i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }
  for (int j = 0; j < n; j++){
    scanf("%d", &b[j]);
  }
  for (int k = 0; k < n - 1; k++){
    scanf("%d", &c[k]);
  }
  
  int stsf = 0;
  for (int l = 0; l < n; l++){
    stsf += b[a[l] - 1];
    if (l < n - 1){
      if (a[l + 1] == a[l] + 1) stsf += c[a[l] - 1];
    }
  }
  printf("%d\n", stsf);
  return 0;
}

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

int main(){
  int N;
  cin >>N;
  int a[100010];
  for(int i=0;i<N;i++) cin >> a[i];
  
  bool visit[100010];
  for(int i=0;i<N;i++) visit[i]=false;
  
  int i=0;
  int count=0;
  visit[0]=true;
  
  while(true){
    int j=a[i]-1;
    if(visit[j]){
      cout << "-1" <<endl;
      return 0;
    }else{
      visit[j]=true;
      count++;
      i=j;
    }
    if(i==1){
      cout<<count <<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 768
//お姉さん方式
#include <stdio.h>
int main(void){
    int a, b, c, x, cou=0;
    int i, j, k;
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &x);
    
    for(i=0; i<=a; i++){
        for(j=0; j<=b; j++){
            for(k=0; k<=c; k++){
                if(x == i*500 + j*100 + k*50){
                    cou++;
                }
            }
        }
    }
    
    printf("%d\n", cou);
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
#include<unordered_set>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

VI g[100010];
int color[100010], n, m, q, v[100010], d[100010], c[100010];
bool dp[100010][15];
void func(int d, int v, int c) {
	if(dp[v][d] || d<0) return;
	//cout << d << " " << v << " " << c << endl;
	if(!color[v]) color[v] = c;
	dp[v][d] = true;
	func(d-1, v, c);
	for(int i: g[v]) func(d-1, i, c);
}

signed main(void)
{
	cin >> n >> m;
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].PB(b);
		g[b].PB(a);
	}
	cin >> q;
	REP(i, q) cin >> v[i] >> d[i] >> c[i];

	for(int i=q-1; i>=0; --i) {
		//cout << "i:" << i << endl;
		func(d[i], v[i]-1, c[i]);
	}
	REP(i, n) cout << color[i] << endl;

	return 0;
}


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

int buy(int i, int j, int k){
	i -= j;
	int p = i / k;
	i -= p * k;
	return i;
}

int main(){

	int x, a, b;
	cin >> x >> a >> b;

	cout << buy(x, a, b) << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
         
typedef long long ll;
using namespace std;
        
#define F first
#define S second
#define sqr(x) x*x
#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define repit(i, n) for(auto it = n.begin(); it != n.end(); ++it)
       
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);}
     
int main(){ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n; 
    int arr[n];
    double s = 0;
    int s1 = 0;
    for(int i = 0; i < n; ++i){
        cin >> arr[i];
        s += arr[i];
        s1 += arr[i];
    }
    s = ceil(s / n);
    int s2 = int(s);
    s1 = s1 / n;
    int ans = 0;
    int ans1 = 0;
    for(int i = 0; i < n; ++i){
        ans += pow((arr[i] - s1),2);
        ans1 += pow((arr[i] - s2),2);
    }
    cout << min(ans, ans1);
    
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void)
{
int W,H,x,y,r;
	
	scanf("%d""%d""%d""%d""%d",&W,&H,&x,&y,&r);
	
	if(r <= x&&r <= y&&x+r <= W&&y+r <= H){
			printf("Yes\n");
	}
	else{
		printf("No\n");
	}

return 0;
}

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

int main(){
  int n; cin>>n;
  for(int i=1;i<=50000;i++){
    int x=(i*1.08)/1;
    if(x==n){
      cout<<i<<endl;
      return 0;
    }else if(x>n){
      cout<<":("<<endl;
      return 0;
    }
  }cout<<":("<<endl;
}

Measured memory_bytes: 256
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n=n0()
a=n1()

print("YES" if len(a)==len(list(set(a))) else "NO")

Measured memory_bytes: 25932
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
				Scanner s = new Scanner(System.in);
		int N = Integer.valueOf(s.next());
		
		N = N % 1000;
		if(N == 0) {
			System.out.println(0);
		}else {
			System.out.println(1000 - N);
		}
	}
}

Measured memory_bytes: 35564
import java.util.Scanner;

public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        if(x > 0 && x < W && y > 0 && y < H){
            if(x >= r && (x + r) <= W && y >=r && (y + r) <= H) System.out.println("Yes");
            else System.out.println("No");
        }else System.out.println("No");
        
    }
}


Measured memory_bytes: 26284
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()

#define boost ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

const ll INF=1e18;
const ll inf=1e9;
const ld eps=1e-7;
const ld pi=acos(-1);
const int dx[4]={0,0 ,1,-1};
const int dy[4]={1,-1,0,0};
const int N=1e5+11;
const int M=1e6+11;
const int mod1=998244353;
const int mod2=1e9+7;

int a[N];

int main(){
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  int ans=0;
  for(int i=1;i<=n;i++){
    int j=i;
    while(j<n&&a[j]>=a[j+1])j++;
    ans=max(ans,j-i);
    i=j;
  }
  cout<<ans;
}


Measured memory_bytes: 640
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

kk = inputs[0][0]

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
end

puts kk/2 * (kk - kk/2)


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

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

string vectostr(vector<char> v)
{
    string ret;
    bool head_flag = true;
    for (auto it = v.rbegin(); it != v.rend(); ++it){
        auto& n = *it;
        if (head_flag && n == 0 && v.size() != 1) continue;
        head_flag = false;
        ret.push_back('0' + n);
    }
    return ret;
}

void func(int n, vector<char>& v)
{
    char r = (n % 2 != 0);
    v.emplace_back(r);
    if (n - r == 0) return;
    func(-((n - r) / 2), v);
}

int main()
{
    scanInt(N);
    vector<char> v;
    func(N, v);
    cout << vectostr(v) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  set<char> s;
  char a; 
  cin >> a;
  s.insert(a);
  cin >> a;
  s.insert(a);
  cin >> a;
  s.insert(a);
  if(s.count('a') and s.count('b') and s.count('c'))
    cout << "Yes";
  else
    cout << "No";
}


Measured memory_bytes: 3612
#![allow(non_snake_case)]

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let N: usize = read();
    let mut A: Vec<i32> = read_vec();
    A = (1..N+1).map(|i| A[i-1] - i as i32).collect();
    A.sort();
    let len = A.len();
    let b = if len % 2 == 0 {(A[len/2-1] + A[len/2]) / 2} else {A[len/2]};
    let ans: i64 = A.iter().map(|&x| (x - b).abs() as i64).sum();
    println!("{}", ans);
}


Measured memory_bytes: 8444
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18;
int main(){
    string s;
    cin>>s;
    vector<int>ans(s.size(),0);
    int cnt_R = 0,cnt_L = 0;
    rep(i,s.size()){
        if(i == s.size()-1){
            if(s[i]=='R')ans[i]++;
        }
        else if(s[i]=='R'&&s[i+1]=='L'){
            ans[i]+=cnt_R/2+1;
            ans[i+1]+=cnt_R/2+cnt_R%2;
            cnt_R = 0;
        }
        else if(s[i]=='R'){
            cnt_R++;
        }
    }
    rrep(i,s.size()){
        if(i == 0){
            if(s[i] == 'L')ans[i]++;
        }
        else if(s[i]=='L'&&s[i-1]=='R'){
            ans[i]+=cnt_L/2+1;
            ans[i-1]+=cnt_L/2+cnt_L%2;
            cnt_L = 0;
        }
        else if(s[i]=='L'){
            cnt_L++;
        }
    }
    rep(i,s.size()-1)cout<<ans[i]<<" ";
    cout<<ans[s.size()-1]<<endl;
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	string ans;
	ans+=s[0];
	ans+=s[1];
	ans+=s[2];
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,m;
  cin>>n>>m;
  vector<pll> a(m),b(m);
  rep(i,m){
    ll z,x;
    cin>>z>>x;
    a[i]=mp(z,x);
    b[i]=mp(z,x);
  }
  map<pll,string> p;
  sort(all(b));
  b.pb(pll(-111,22));
  ll cu=1;
  rep(j,m){
    string u=to_string(b[j].F);
    string d=to_string(cu);
    for(int i=sz(u);i<6;i++){
      u='0'+u;
    }
    for(int i=sz(d);i<6;i++){
      d='0'+d;
    }
    string k=u+d;
    p[pll(b[j].F,b[j].S)]=k;
    cu++;
    if(b[j].F!=b[j+1].F) cu=1;
  }
  rep(i,m){
    COUT(p[a[i]]);
  }
}

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

using namespace std;
typedef long long ll;

ll DP[3002][3002];
int N;
vector<ll> nums;

ll findMax(int l, int r) {
	if (DP[l][r] != -1) { return DP[l][r]; }
	if (l > r) { return 0; }

	ll c1 = nums[r] - findMax(l, r - 1);
	ll c2 = nums[l] - findMax(l + 1, r);

	DP[l][r] = max(c1, c2);
	return DP[l][r];
}

int main() {
	cin >> N;
	nums.resize(N);
	for (auto &x : nums) { cin >> x; }
	memset(DP, -1, sizeof(DP));

	cout << findMax(0, N - 1) << endl;
}

Measured memory_bytes: 70912
#include<bits/stdc++.h>
using namespace std;
vector<int> v;
int tot=1;
void build(int u,int pos)
{
	if(!pos)return;
	printf("%d %d\n",u,++tot);
	build(tot,pos-1);
	for(int i=v[pos-1]+1;i<v[pos];i++)printf("%d %d\n",u,++tot);
}
string s;
int n;
int main()
{
	cin>>s;
	n=int(s.size());s='0'+s;
	if(s[1]=='0')return puts("-1"),0;
	for(int i=0;i<=n;i++)
		if(s[i]!=s[n-i])return puts("-1"),0;
		else if(s[i]=='1')v.push_back(i);
	v.push_back(n);
	build(1,int(v.size()-1));
	assert(tot==n);
}


Measured memory_bytes: 5236
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = int(1e9);
typedef long long int ll;

/* -- template -- */
int main(){
    int N; cin >> N;
    pair<int, int>A[N];
    rep(i, N)cin >> A[i].first, A[i].second = i + 1;
    sort(A, A + N);
    rep(i, N){
        cout << A[i].second << endl;
    }
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
const int MAX_V=210;
int d[MAX_V][MAX_V];
  int m,r;
  int hoge[100]={};
int V;
void warshall_floyd(){
  for(int k=0;k<V;k++)
    for(int i=0;i<V;i++)
      for(int j=0;j<V;j++)
	d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
}
int ans=INF;
void dfs(int now,int depth,int cost,int visit){
  if(depth == r){
    ans=min(ans,cost);
    return;
  }
  for(int i=0;i<r;i++){
    if(!(visit&(1<<i))){
      dfs(hoge[i],depth+1,cost+d[now][hoge[i]],visit+(1<<i));
    }
  }
}
int main(){
cin>>V>>m>>r;
 for(int i=0;i<MAX_V;i++)
   for(int j=0;j<MAX_V;j++)
     d[i][j]=INF;
 for(int i=0;i<r;i++){
    cin>>hoge[i];
    hoge[i]--;
 }
  for(int i=0;i<m;i++){
    int a,b,c;cin>>a>>b>>c;
    d[--a][--b]=c;
    d[b][a]=c;
  }
  warshall_floyd();

  for(int i=0;i<r;i++){
    dfs(hoge[i],1,0,1<<i);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
/* Focus your enery towards light */

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

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define forn(i,n) for(ll i=0;i<n;i++)
#define fore(i,a,b) for(ll i=a;i<=b;i++)
#define ford(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265
#define inf 1e18

/******************************************************************************************************/
void file() {
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
}
/******************************************************************************************************/

const ll nax = 1e7 + 1;
// const ll mod = 1e9 + 7;

vector<ll> prime(nax);

void sieve() {
    fore (i, 2, nax) {
        if (prime[i]) continue;
        ll skip = i;
        for (ll j = i; j < nax; j += skip) {
            prime[j] = skip;
        }
    }
}

int main() {

    sync

    ll testCases = 1;
    // cin >> testCases;
    sieve();
    while (testCases--) {
        ll n;
        cin >> n;
        ll ans = 1;
        fore (i, 2, n) {
            ll x = i;
            ll temp = 1;
            while (x != 1) {
                ll div = prime[x];
                ll cnt = 0;
                while (x % div == 0) {
                    cnt++;
                    x /= div;
                }
                temp *= (cnt + 1);
            }
            ans += (i * temp);
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main () {
    int N; cin >> N;
    vector<int> a(N); rep(i, N) cin >> a[i];

    int ma = *max_element(a.begin(), a.end());
    int mi = *min_element(a.begin(), a.end());
    cout << ma-mi << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
const ll mod = 998244353;

ll powmod(ll a, ll e) {
  ll sum = 1;
  ll cur = a;
  while (e > 0) {
    if (e % 2) {
      sum = sum * cur % mod;
    }
    cur = cur * cur % mod;
    e /= 2;
  }
  return sum;
}


int main(void) {
  int n;
  cin >> n;
  vector<PL> pt(n);
  REP(i, 0, n) {
    int x, y;
    cin >> x >> y;
    pt[i] = PL(x, y);
  }
  ll tot = powmod(2, n);
  tot += mod - 1 - n;
  tot %= mod;
  // Eliminate one-liners
  REP(i, 0, n) {
    REP(j, i + 1, n) {
      int elim = 0;
      REP(k, j + 1, n) {
	// i-j-k?
	PL v1(pt[j].first - pt[i].first, pt[j].second - pt[i].second);
	PL v2(pt[k].first - pt[i].first, pt[k].second - pt[i].second);
	ll outer = v1.first * v2.second - v1.second * v2.first;
	if (outer == 0) {
	  elim += 1;
	}
      }
      tot += mod - powmod(2, elim);
      tot %= mod;
    }
  }
  cout << tot << endl;
}


Measured memory_bytes: 256
S = input()
 
def solve(S):
    buf = [1] * len(S)
 
    for i in range(len(buf) - 2):
        if S[i] == "R" and S[i+1] == "R":
            buf[i+2] += buf[i]
            buf[i] = 0
 
    for i in range(len(buf) - 1, 1, -1):
        if S[i] == "L" and S[i-1] == "L":
            buf[i-2] += buf[i]
            buf[i] = 0
 
    return " ".join(map(str, buf))
 
print(solve(S))


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

#define ll long long

#define ull unsigned long long

#define pii pair<int, int>

#define pll pair<ll int, ll int>

#define ff first

#define ss second

#define pb push_back

#define eb emplace_back

#define debug(n) cout << "DEBUG1 " << n << "\n";

#define debug2(n, m) cout << "DEBUG2 " << n << ' ' << m << "\n";

#define debug3(n, m, x) cout << "DEBUG3 " << n << ' ' << m << ' ' << x << "\n";

#define debug4(n, m, x, y) cout << "DEBUG4 " << n << ' ' << m << ' ' << x << ' ' << y << "\n";

#define ss_def stringstream ss // stringstream, do ss_def(str), then ss >> n (n is int)

#define upzero(n) if (n < 0) n = 0

#define alive(n) cout << "Alive here: checkpoint " << n << endl

#pragma GCC optimize("Ofast")

using namespace std;

void yes() {

 cout << "YES\n";

 return;

}

void no() {

 cout << "NO\n";

 return;

}

void init() {

 // initialize

 

}

int pp(int n) {

 int cnt = 0;

 for (int i = 1;i < ceil(sqrt(n));i++) {

     if (n % i == 0) cnt += 2;

 }

 if (floor(sqrt(n)) * floor(sqrt(n)) == n) cnt++;

 return cnt;

}

void solve(int case_no) {

 // implementation

 int n;

 cin >> n;

 int cnt[n+1] = {0};

 ll int ans = 0;

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

     for (int j=i;j<=n;j+=i) {

         cnt[j]++;

     }

 }

 for (int i=1;i<n;i++) ans += cnt[i];

 cout << ans << endl;

}

int main() {

    ios::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);

    srand(time(NULL));

    init();

    int t = 1;

//    cin >> t;

    for (int i = 1;i <= t;i++) solve(i);

}

/*

*/

Measured memory_bytes: 7476
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char const* argv[])
{
    int a,b,c,d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    printf("%d\n", (a*b > c*d ? a*b : c*d));
    
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		char[] sa =  S.toCharArray();
		System.out.println((sa[0] == sa[1] && sa[1] == sa[2] || sa[1] == sa[2] &&sa [2] == sa[3] ) ? "Yes" : "No");


//		int cnt = 0;
//		char c = 'a';
//
//		for (char s : S.toCharArray()){
//			if (s == c){
//				cnt++;
//			}else {
//				cnt = 0;
//			}
//
//			if (cnt >= 2){
//				System.out.println("Yes");
//				return;
//			}
//			c = s;
//		}
//		System.out.println("No");
//		return;
	}
}


Measured memory_bytes: 20820
const double = Float64
const int = Int64
const vint = Vector{int}
const vdouble = Vector{double}

int(x) = parse(int,x)
parseint(x) = parse(int, x)

function readint()
  moji = readline(stdin)
  moji = split(moji)
  return map(parseint,moji)

end
function check(A, arr)
  score = 0
  q = size(arr)[2]
  for i in 1:q
    a,b,c,d = @view arr[:,i]
    if c == A[b] - A[a] 
      score += d
    end
  end
  return score
end

function dfs(A, n, m, p, arr, numMax)
  
  # 葉まで行ったら
  if p == n
    # 処理を書く
    #println(A, " ", numMax)
    numMax = max(numMax, check(A,arr)) # println(A)
    
    #println(A, " ", numMax)
    return  numMax
  end
  
  # 葉にいって無いなら子を探す
  p+=1
  for i in A[p-1]:m
    A[p] = i
    numMax = dfs(A, n, m, p, arr, numMax) 
  end
  return numMax
end

function main()
  n, m, q = readint()
  abcd = Array{int, 2}(undef,4,q)
  for i in 1:q
    kari = readint()
    abcd[:,i] .=  kari
  end

  #println(abcd)
  # A の列の定義
  A = ones(int,n)
  println(dfs(A, n, m, 1, abcd, 0))
end

main()

Measured memory_bytes: 254024
/*
*  Problem Link: https://atcoder.jp/contests/abc168/virtual
*  Author: Raunak Sett
*/
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long 
#define vi vector<int>
int main() {
    IOS
    // Code Here
    int n;
    cin>>n;
    int d = n%10;

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

Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N;
long A[1000];
long ep[1000],parent[1000];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	for(int i=0;i<N;i++)
	{
		ep[i]=A[i];
		parent[i]=-1;
		for(int j=i-2;j>=0;j-=2)
		{
			if(ep[i]<ep[j]+A[i])
			{
				ep[i]=ep[j]+A[i];
				parent[i]=j;
			}
		}
	}
	int id=0;
	for(int i=1;i<N;i++)
	{
		if(ep[id]<ep[i])id=i;
	}
	cout<<ep[id]<<endl;
	vector<int>x;
	while(id>=0)
	{
		x.push_back(id);
		id=parent[id];
	}
	reverse(x.begin(),x.end());
	vector<int>ans;
	for(int i=N-1;i>x[x.size()-1];i--)ans.push_back(i);
	for(int i=(int)x.size()-2;i>=0;i--)
	{
		int t=(x[i+1]-x[i])/2;
		for(;t>0;t--)
		{
			ans.push_back(x[i]+t);
		}
	}
	for(int i=x[0]-1;i>=0;i--)ans.push_back(0);
	cout<<ans.size()<<endl;
	for(int i:ans)cout<<i+1<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin Header {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) x.begin(), x.end()
#define rep(i, n) for (intmax_t i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T>
using MaxHeap = priority_queue<T, vector<T>, less<T>>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class T>
inline void input(vector<T> &vec) {
    for (auto &e: vec) {
        cin >> e;
    }
}

template <class T>
inline void input(vector<vector<T>> &mat) {
    for (auto &vec: mat) {
        input(vec);
    }
}

inline void print() { cout << "\n"; }
template <class Head, class... Tail>
inline void print(Head&& head, Tail&&... tail) {
    static constexpr const char *delim[] = {"", " "};
    cout << head << delim[sizeof...(tail)];
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &strm, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        strm << e << delim[&e == &vec.back()];
    }
    return strm;
}

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

template <class T>
inline bool chmax(T &a, const T &b) noexcept {
    return b > a && (a = b, true);
}

template <class T>
inline bool chmin(T &a, const T &b) noexcept {
    return b < a && (a = b, true);
}

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(int, H, A);

    const auto updiv = [&](intmax_t n, intmax_t d) { return (n + d - 1) / d; };

    print(updiv(H, A));

    return 0;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
ans = 0
c = n - 1
for a in range(n - 2):
    c = n - 1
    for b in range(a + 1, n - 1):
        #　各a,bに対してのcを尺取法で探索
        while l[a] >= l[b] + l[c]:
            c -= 1
            if c <= b:
                break
        else:
            # print(l[a], l[b], l[c])
            ans += c - b
            continue
        break
print(ans)

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

#define FOR(s, i, n) for(int i = s; i n; i++)
typedef long long ll;
const int INF = 1e9;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	string n;
	cin>>n;
	if (n[1] == 'R'){
		cout<<"ABC\n";
	}else{
		cout<<"ARC\n";
	}
	return 0;
}

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

using namespace std;

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

  int n, N;
  cin >> n;
  N = n;

  int res = 0;
  while (n > 0) {
    res += n%10;
    n /= 10;
  }
  cout << (N % res == 0 ? "Yes" : "No") << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n;
	cin>>n;
	if(n==1){cout<<"Hello World"<<endl;return 0;}
	else{
		int a,b;
		cin>>a>>b;
		cout<<a+b<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
//#include "pch.h"
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	ll n, m;

	cin >> n >> m;

	string s1, s2;

	for (int i = 0; i < n; i++) {
		s1 += (char)(m + '0');
	}

	for (int i = 0; i < m; i++) {
		s2 += (char)(n + '0');
	}

	vector<string>list;
	list.push_back(s1);
	list.push_back(s2);

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

	cout << list[0] << endl;




	return 0;
}


Measured memory_bytes: 256
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<LL,LL> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

vector<int> g[133333];
vector<pii> a[133333];

LL ub;
int n,v[133333];
void dfs(int x)
{
	if((int)g[x].size()==0)
	{
		a[x].pb(mp(v[x],v[x]));
		return;
	}
	
	int l=g[x][0],r=g[x][1],cur=0;
	dfs(l);dfs(r);
	for(int i=0;i<(int)a[l].size();i++)
	{
		while(cur<(int)a[r].size()&&a[r][cur].ss+a[l][i].ff>ub)cur++;
		if(cur<(int)a[r].size())
		{
			a[x].pb(mp(a[l][i].ss+v[x],a[r][cur].ff+v[x]));
			a[x].pb(mp(a[r][cur].ff+v[x],a[l][i].ss+v[x]));
		}
	}
	cur=0;
	for(int i=0;i<(int)a[r].size();i++)
	{
		while(cur<(int)a[l].size()&&a[l][cur].ss+a[r][i].ff>ub)cur++;
		if(cur<(int)a[l].size())
		{
			a[x].pb(mp(a[r][i].ss+v[x],a[l][cur].ff+v[x]));
			a[x].pb(mp(a[l][cur].ff+v[x],a[r][i].ss+v[x]));
		}
	}/**/
/*	for(int i=0;i<(int)a[l].size();i++)for(int j=0;j<a[r].size();j++)
	{
		if(a[l][i].ff+a[r][j].ss<=ub)a[x].pb(mp(a[l][i].ss+v[x],a[r][j].ff+v[x]));
		if(a[l][i].ss+a[r][j].ff<=ub)a[x].pb(mp(a[l][i].ff+v[x],a[r][j].ss+v[x]));
	}/**/
	sort(a[x].begin(),a[x].end());
	cur=0;
	for(int i=0;i<(int)a[x].size();i++)
	{
		if(cur==0||a[x][cur-1].ss>a[x][i].ss)
			a[x][cur++]=a[x][i];
	}
	a[x].resize(cur);
//	printf("x= %d\n",x);
//	for(int i=0;i<(int)a[x].size();i++)printf("pair= %d %d\n",a[x][i].ff,a[x][i].ss);
//	puts("");
}
bool check(LL x)
{
	ub=x;
	for(int i=1;i<=n;i++)
	{
		a[i].clear();
		a[i].swap(a[i]);
	}
	dfs(1);
	if(a[1].size()>0)return true;
	else return false;
}
int main()
{
	get1(n);
	for(int i=2,a;i<=n;i++)
	{
		get2(a,v[i]);
		g[a].pb(i);
	}
//	printf("check %d\n",check(15));
	LL l=-1,r=1ll<<40,mid;
	while(l<r-1)
	{
		mid=(l+r)>>1;
		if(check(mid))r=mid;
		else l=mid;
	}
	printendl(r);/**/
	return 0;
}

Measured memory_bytes: 51344
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    priority_queue<P> que;
    for(int i = 0; i < a; ++i){
        int p;
        cin >> p;
        que.push(P(p, 0));
    }
    for(int i = 0; i < b; ++i){
        int q;
        cin >> q;
        que.push(P(q, 1));
    }
    for(int i = 0; i < c; ++i){
        int r;
        cin >> r;
        que.push(P(r, 2));
    }
    ll ans = 0;
    int cnt = 0;
    while(!que.empty()){
        P p = que.top();
        que.pop();
        if(p.second == 0){
            if(x > 0){
                ans += p.first;
                --x;
            }
        }
        else if(p.second == 1){
            if(y > 0){
                ans += p.first;
                --y;
            }
        }
        else{
            ans += p.first;
            ++cnt;
        }
        if(x + y == cnt)    break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6384
#include <stdio.h>
#include <limits.h>

#define LENGTH 256

int mod(int l, int r) {
    int a, b, n;
    int c, d;
    int m = INT_MAX;
    if ((r-l) >= 2019) return 0;
    if (l+2019 < r) r = l + 2019;

    for (a = l; a < r; a++) {
        for ( b = a+1; b <=r; b++) {
            c = a % 2019;
            d = b % 2019;
            n = (c * d) % 2019;
            if ( n < m) m = n;
            if ( m == 0) return 0;
        }
    }
    return m;
}

int main(void) {
    char input[LENGTH];
    int l, r;
    int n;
    if (scanf("%d %d", &l, &r) == 1);
    n = mod(l ,r);
    printf("%d", n);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdlib>
#include<utility>
#include<tuple>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<queue>
#include<deque>
#include<bitset>
#include<cmath>
#include<map>
#include<iomanip>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a; i < b; i++)

int main() {
	
	int a;
	cin >> a;

	cout << a + a * a + a * a * a << endl;

	return 0;
}

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

#define int long long
#define REP(i, l, r) for (__typeof(l) i = (l); i != (r); (l)<(r)?++i:--i)
#define popcount __builtin_popcountll

const int INF = 1LL<<60;
const int MOD = 998244353;

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> t) {
    return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> t) {
    return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ", " + to_string(get<3>(t)) + ")";
}

template <typename A>
string to_string(vector<A> v) {
    bool first = true;
    string result = "[";
    for (A i : v) {
        if (!first) result += ", ";
        first = false;
        result += to_string(i); 
    }
    return result + "]";
}

template <typename A>
string to_string(A x[], signed n) {
    string result = "{";
    for (signed i=0; i<n; ++i) {
        if (i!=0) result += ", ";
        result += to_string(x[i]); 
    }
    return result + "}";
}

string bin_string(int x) {
    const int d = 64;
    string result(d, ' ');
    for (signed i=d-1; i>=0; --i) result[d-1-i] = '0'+((x&1LL<<i)!=0);
    return result;
}

int powa(int base, int exp) {
    if (exp<=0) return 1;
    if (base<=0) return 0;
    int val = powa(base, exp>>1);
    val = val*val % MOD;
    if (exp&1) {
        val = val*base % MOD;
    }
    return val;
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    int res = 0, n; string s;
    cin >> n >> s;
    int startfrom[10][10];
    REP(i, 0, 10) {
        int ind = 0;
        while (ind < n && s[ind] != i+'0') ++ind;
        REP(j, 0, 10) {
            int nextind = ind+1;
            while (nextind < n && s[nextind] != j+'0') ++nextind;
            REP(k, 0, 10) {
                int lastind = nextind+1;
                while (lastind < n && s[lastind] != k+'0') ++lastind;
                if (lastind < n) ++res;
            }
        }
    }
    cout << res;
}


Measured memory_bytes: 384
/*
ID: skipian1
PROB: 
LANG: C++11
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF = 2000000000
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define X first
#define Y second

int main() {
  int h, w;
  int MOD = 1e9+7;
  string str;
  cin >> h >> w;
  int dp[h][w];
  dp[0][0] = 1;
  for (int i = 0; i < h; i++) {
    cin >> str;
    for (int j = 0; j < w; j++) {
      if (str.at(j) == '#') dp[i][j] = 0;
      else {
	if (i == 0 && j == 0) continue;
	if (i == 0) dp[i][j] = dp[i][j-1];
	else if (j == 0) dp[i][j] = dp[i-1][j];
	else dp[i][j] = dp[i-1][j] + dp[i][j-1];
      }
      dp[i][j] %= MOD;
    }
  }
  cout << dp[h-1][w-1] << "\n";
}


Measured memory_bytes: 4096
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

const int MAX = 2000010;//設定して

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;//＊１
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  COMinit();

  ll n,k;cin>>n>>k;
  if(n-1<=k){
    ll ans=1;
    ans*=fac[2*n-1];
    ans%=mod;
    ans*=finv[n];
    ans%=mod;
    ans*=finv[n-1];
    ans%=mod;
    cout<<ans<<ENDL;
    return 0;
  }

  ll ans=0;
  rep(i,0,n){
    if(2*k+n-2*i<n)continue;
    ll res=COM(n,i);
    res*=fac[n-1];
    res%=mod;
    res*=finv[n-i-1];
    res%=mod;
    res*=finv[i];
    res%=mod;

    ans+=res;
    ans%=mod;
    //cerr<<i<<" "<<res<<ENDL;
  }
  cout<<ans<<ENDL;


}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 47104
//二分探索木：削除
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

Node * treeMinimum(Node *x) {
    while (x->left != NIL)
        x = x->left;
    return x;
}

Node * treeSuccessor(Node *x) {
    if (x->right != NIL)
        return treeMinimum(x->right);
    Node *y = x->parent;
    while (y != NIL && x == y->right) {
        x = y;
        y = y->parent;
    }
    return y;
}

Node * find(Node *u, int k) {
    while (u != NIL && k != u->key) {
        if(k < u->key) 
            u = u->left;
        else
            u = u->right;
    }
    return u;
}

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }

    z->parent = y;
    if (y == NIL) {
        root = z;
    } else {
        if (z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void treeDelete(Node *z) {
    Node *y; //削除する対象
    Node *x; //yの子

    // 削除する節点を決める
    if (z->left == NIL || z->right == NIL)
        y = z;
    else
        y = treeSuccessor(z);
    
    // yの子xを決める
    if (y->left != NIL)
        x = y->left;
    else
        x = y->right;
    
    if (x != NIL)
        x->parent = y->parent;

    if (y->parent == NIL)
        root = x;
    else {
        if (y == y->parent->left)
            y->parent->left = x;
        else
            y->parent->right = x;   
    }

    if (y != z)
        z->key = y->key;

    free(y);
}

// 中間順巡回
void inorder(Node *u) {
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

// 先行順巡回
void preorder(Node *u) {
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

// 後行順巡回
void postorder(Node *u) {
    if (u == NIL) return;
    postorder(u->left);
    postorder(u->right);
    printf(" %d", u->key);
}

int main() {
    int n, i, x;
    string com;

    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        cin >> com;

        if(com == "insert") {
            scanf("%d", &x);
            insert(x);
        }

        else if (com == "delete") {
            scanf("%d", &x);
            treeDelete(find(root, x));
        }

        else if (com == "find") {
            scanf("%d", &x);
            Node *t = find(root, x);
            if (t != NIL) printf("yes\n");
            else printf("no\n");
        }
        
        else if (com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 22080
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin>>N;
	int ans=N;
	int d[N];
	for(int i=0;i<N;i++){
		cin>>d[i];
	}
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			if(d[i]==d[j]){
				ans--;
				break;
			}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256