akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main()
{
    int n;
    cin>>n;
    int a;
    int b;
    int c;
    a=n%10;
    c=n/100;
    if(a==c) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    //cout << "Hello world!" << endl;
    return 0;
}


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

int main()
{
    int n; cin>>n;
    vector<int> a(n*3); for(auto& e: a) cin>>e;
    sort(rbegin(a), rend(a));
    long res=0;
    for(int i=1; n--; i+=2) res+=a[i];
    cout<<res<<endl;
}

Measured memory_bytes: 1408
import numpy as np

N = int(input())
a = []
x = []
y = []
count = 0

def factorial(n):
    if n<2:
        return 1
    else:
        return(n*factorial(n-1))

for i in range(N):
    a.append(list(map(int,input().split())))    
for i in range(N):
    for j in range(N):
        if i==j:
            continue
        count += np.sqrt((a[i][0] - a[j][0])**2 + (a[i][1] - a[j][1])**2)
b = factorial(N)
print(count/N)


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

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

using namespace std;

int A, B, K;
set<int> st;


int main(void) {
    scanf("%d %d %d", &A, &B, &K);
    
    REP (i, A, min(A+K,B+1)) st.insert(i);
    REVREP (i, B, max(A,B-K+1)) st.insert(i);
    
    
    for (auto itr = st.begin(); itr != st.end(); itr++ ) printf("%d\n", *itr);
    

	return 0;
}


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

struct Card {
    char suit;
    int value;
};

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

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

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

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

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

int main() {
    int n, i, v;
    struct Card A[MAX], B[MAX];
    char S[10];
    int stable = 1;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        scanf("%s %d", S, &v);
        A[i].suit = B[i].suit = S[0];
        A[i].value = B[i].value = v;
    }
    
    mergeSort(A, n, 0, n);
    quickSort(B, n, 0, n - 1);
    
    for (i = 0; i < n ; i++) {
        if (A[i].suit != B[i].suit) stable = 0;
    }
    
    if (stable == 1) printf("Stable\n");
    else printf("Not stable\n");
    for (i = 0; i < n; i++) {
        printf("%c %d\n", B[i].suit, B[i].value);
    } 
    return 0;
}


Measured memory_bytes: 4032
n = int(input())
h = list(map(int, input().split()))
dp = [0]*n
dp[1] = abs(h[1]-h[0])
for i in range(2,n):
  dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])

Measured memory_bytes: 20436
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;

void main()
{
	int n;
	while (n = readln.chomp.to!int, n) {
		auto jewels = new int[][](n, 2);
		auto f = new bool[](n);
		foreach (i; 0..n) {
			jewels[i] = readln.chomp.split.map!(to!int).array;
		}
		auto m = readln.chomp.to!int;
		int[2] rp;
		rp[] = 10;

		foreach (i; 0..m) {
			auto p = readln.chomp.split;
			auto d = p[1].to!int;
			if (p[0] == "N") {
				while (d--) {
					rp[1]++;
					foreach (j; 0..n) if (rp == jewels[j]) f[j] = 1;
				}
			} else if (p[0] == "S") {
				while (d--) {
					rp[1]--;
					foreach (j; 0..n) if (rp == jewels[j]) f[j] = 1;
				}
			} else if (p[0] == "E") {
				while (d--) {
					rp[0]++;
					foreach (j; 0..n) if (rp == jewels[j]) f[j] = 1;
				}
			} else {
				while (d--) {
					rp[0]--;
					foreach (j; 0..n) if (rp == jewels[j]) f[j] = 1;
				}
			} 
		}

		if (f.count!(a=>a==1) == n) writeln("Yes");
		else writeln("No");
	}
}

Measured memory_bytes: 1864
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> G(n), cost(n);
    rep(i,n-1) {
        int a, b, w;
        cin >> a >> b >> w; a--; b--;
        G[a].push_back(b); G[b].push_back(a);
        cost[a].push_back(w); cost[b].push_back(w);
    }
    vector<int> ans(n, -1);
    queue<int> q;
    q.push(0);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        rep(i,G[v].size()) {
            int u = G[v][i];
            int w = cost[v][i];
            if(ans[u]!=-1) continue;
            ans[u] = (ans[v]+w)%2;
            q.push(u);
        }
    }
    rep(i,n) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 11904
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <list>
#include <cmath>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <set>
using ll = long long;
using namespace std;
#define INF 999999999

int main()
{
    int N;
    string A, B, C;
    cin >> N >> A >> B >> C;
    int ans = 0;
    for (int i = 0; i < N; i++)
        ans += max(0, (A[i] != B[i]) + (A[i] != C[i]) + (C[i] != B[i]) - 1);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cstddef>
#include <vector>
#include <deque>
#include <utility>
#include <algorithm>

template <typename RandomIt, typename OutputIt>
OutputIt window_minima(RandomIt first, RandomIt s_last, RandomIt last, OutputIt d_first) {
  std::deque<RandomIt> dq;
  auto width = s_last - first;
  for (auto it = first; it < last; ++it) {
    while (!dq.empty() && !(*dq.back() < *it)) dq.pop_back();
    dq.push_back(it);
    if (width <= it - dq.front()) dq.pop_front();
    if (width-1 <= it - first) *d_first++ = *dq.front();
  }
  return d_first;
}

int main() {
  size_t N;
  ptrdiff_t L;
  scanf("%zu %td", &N, &L);

  std::vector<int> a(N);
  for (auto& ai: a) scanf("%d", &ai);

  std::vector<int> res(N-L+1);
  window_minima(a.begin(), a.begin()+L, a.end(), res.begin());
  for (size_t i = 0; i <= N-L; ++i)
    printf("%d%c", res[i], i<N-L? ' ': '\n');
}



Measured memory_bytes: 10448
#include<bits/stdc++.h>
#define ll long long int
const int INF = 1e9;
using namespace std;
ll dp[100005];
ll solve(int n,vector<int>&h){
	dp[1] = 0;

	
	// for(int i=2;i<=n;i++){
	// 	dp[i] =INF;
	// for(int j=1;j<=k;j++){
	// 	ll tmp = INF;
		
	// 		if(i-j>=1){
	// 		tmp = abs(h[i]-h[i-j])+dp[i-j];
	// 		dp[i] = min(tmp,dp[i]);
				
	// 	}
	// 	else
	// 		break;
	// }
	
//}
	// op1 = abs(h[st]-h[st+1]) +solve(st+1,n,h);
	// if(st+2<=n)
	// 	op2 = abs(h[st]-h[st+2])+solve(st+2,n,h);
	// cout<<op1<<" "<<op2<<endl;
	for(int i=2;i<=n;i++){
		ll op = INF;
		if(i-2>=1)
			op =abs(h[i]-h[i-2])+dp[i-2];
		dp[i] = min(abs(h[i]-h[i-1])+dp[i-1],
			op);
	}
	return  dp[n];

}
int main(){

// #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
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
vector<int>h;
h.push_back(0);
for(int i=0;i<n;i++){
	int tmp;
	cin>>tmp;
	h.push_back(tmp);
}
if(n==1){
	cout<<0;
	return 0;
}
memset(dp,0,n+1);
cout<<solve(n,h);
}
	

Measured memory_bytes: 1528
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    vll a(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }

    ll start = 0;
    V<int> used(n, 0);
    while (true) {
        if (k == 0 || used[start] == 1) break;
        k--;
        used[start] = 1;
        start = a[start];
    }

    if (k == 0) {
        cout << start + 1 << '\n';
        return 0;
    }

    V<int> used2(n, 0);
    ll tmps = start;
    V<int> path;
    while (true) {
        if (used2[tmps] == 1) break;
        path.emplace_back((int)tmps);
        used2[tmps] = 1;
        tmps = a[tmps];
    }

    ll rem = k % (ll)path.size();
    cout << path[rem] + 1 << '\n';
    return 0;
}


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

#define SORT(v) sort(v.begin(),v.end())
#define si(n) scanf("%d",&n)
#define sii(n,m) scanf("%d %d",&n,&m)
#define sl(n) scanf("%lld",&n)
#define sll(n,m) scanf("%lld %lld",&n,&m)
#define ss(cad) scanf("%s",cad)
#define PB push_back
#define fst first
#define scn second
#define DBG(x) cerr << #x << " = " << (x) << endl; 
#define M 1000000007
#define N_MAX 100010

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vp;

int main()
{
	int m, k;
	sii(m, k);

	if(m <= 1)
	{
		if(k == 0)
		{
			printf("0 0");
			for(int i = 1; i < (1<<m); i++)
				printf(" %d %d", i, i);
			printf("\n");
		}
		else
			printf("-1\n");
	}
	else if(k < (1<<m))
	{
		if(k == 0)
		{
			printf("0 0");
			for(int i = 1; i < (1<<m); i++)
				printf(" %d %d", i, i);
			printf("\n");
		}
		else
		{
			stack<int> pila;
			vi ans;
			ans.push_back(0);
			ans.push_back(k);
			for(int i = 1; i < (1<<m); i++)
			{
				if(i == k)
					continue;
				ans.push_back(i);
				pila.push(i);
			}

			ans.push_back(k);
			ans.push_back(0);
			while(!pila.empty())
			{
				ans.push_back(pila.top());
				pila.pop();
			}
			printf("%d", ans[0]);
			for(int i = 1; i < ans.size(); i++)
				printf(" %d", ans[i]);
			printf("\n");
		}
	}
	else
		printf("-1\n");
    return 0;
}


Measured memory_bytes: 3444
import java.util.*;

public class Main {
    static int n;
    static int m;
    static int[] ai;
    static int[] bi;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        m = in.nextInt();
        ABC177DUnionFind unionFind = new ABC177DUnionFind(n);
        ai = new int[m + 1];
        bi = new int[m + 1];
        int[] directFriendCount = new int[n+1];
        for (int i = 1; i <= m; i++) {
            ai[i] = in.nextInt();
            bi[i] = in.nextInt();
            unionFind.unite(ai[i], bi[i]);
            directFriendCount[ai[i]]++;
            directFriendCount[bi[i]]++;
        }
        
        int[] groupSizes = new int[n+1];
        for(int i=1; i<=n; i++) {
            groupSizes[unionFind.root(i)]++;
        }
        int maxGroupSize = 1;
        for(int i=1; i<=n; i++) {
            maxGroupSize = Math.max(maxGroupSize, groupSizes[i]);
        }
        System.out.println(maxGroupSize);
    }
}
class ABC177DUnionFind {
    private int[] parent;
    public ABC177DUnionFind(int n) {
        this.parent = new int[n+1];
        for(int i=1; i<=n; i++) {
            this.parent[i] = i; // みんな、自分がroot
        }
    }
    public int root(int a) {
        if(this.parent[a] == a) {
            return a;
        }
        this.parent[a] = this.root(this.parent[a]);
        return this.parent[a];
    }
    public void unite(int a, int b) {
        int rootA = this.root(a);
        int rootB = this.root(b);
        if(rootA == rootB) {
            return;
        }
        this.parent[rootA] = rootB;
    }
    public boolean isInSameGroup(int a, int b) {
        return this.root(a) == this.root(b);
    }
}

Measured memory_bytes: 74836
S = input()

if(S == "SSS"):
    print(0)
if(S == "RSS" or S == "SRS" or S == "SSR" or S == "RSR"):
    print(1)
if(S == "RRS" or S == "SRR"):
    print(2)
if(S == "RRR"):
    print(3)

Measured memory_bytes: 9044
using System;
using System.Collections;
using System.Collections.Generic;

namespace ABC128 {
  class ProblemA {
    static void Main(string[] args) {
      int[] input = Input.nums;
      System.Console.WriteLine((3 * input[0] + input[1]) / 2);
    }
  }
  public class Input {
    public static string str => System.Console.ReadLine();
    public static string[] strs => str.Split(' ');
    public static char[] charArr => str.ToCharArray();
    public static int num => int.Parse(str);
    public static int[] nums => Array.ConvertAll(strs, int.Parse);
    public static long numL => long.Parse(str);
    public static long[] numLs => Array.ConvertAll(strs, long.Parse);
  }
}

Measured memory_bytes: 11220
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2] != 1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]
def mod_inv(a,mod):
    x = extgcd(a,mod)[0]
    return (mod + x % mod)% mod
n = int(input())
mod = 10**9 + 7
a = list(map(int,input().split()))
il = [[]for i in range(n)]
for i in range(n+1):
    il[a[i]-1].append(i)
    if len(il[a[i]-1]) > 1:
        p,q = il[a[i]-1]
comb = 1
comb2 = 1
c = p + n - q
for i in range(n+1):
    comb = (((comb*(n+1-i))%mod)*mod_inv(i+1,mod))%mod
    if c >= i:
        print((comb-comb2)%mod)
        comb2 = (((comb2*(c-i))%mod)*mod_inv(i+1,mod))%mod
    else:
        print(comb%mod)

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

typedef long long ll;
typedef long double ld; 
typedef double db; 
typedef string str; 

typedef pair<int, int> pi;
typedef pair<ll,ll> pl; 
typedef pair<ld,ld> pd; 

typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound 
#define ub upper_bound 

const int MOD = 998244353;
const ll INF = 1e18;
const int MX = 1000001;

int N;
str A, B;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> N >> A >> B;
    F0R(i, N) {
        cout << A[i] << B[i];
    }
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
const int MAX = 3e3;


int gcd(int a, int b){
  if(a == 0 || b == 0)return max(a, b);
  if(a == b)return a;
  if(a > b)a = a%b;
	else b = b%a;
  return gcd(a, b);
}

int a, b, c, d;
bool solve(){
  if(a < b)return false;
  if(b > d)return false;
  if(c > b)return true;
  int g = gcd(b, d);
  if(b-g+a%g > c)return false;
  return true;
}

signed main(){
  int T;
  scanf("%lld", &T);
  rep(i,T){
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
    printf("%s\n", solve() ? "Yes" : "No");
  }
  return 0;
}










Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Dynamic;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            int r = int.Parse(Console.ReadLine());
            Console.WriteLine(3 * r * r);
        }
    }
}


//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



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

using namespace std;

const int mod = 1000000007;

int main()
{    

	ios_base::sync_with_stdio(false);


    int  d,t,s;
    cin>>d>>t>>s;

    if((d+s-1)/s <=t) cout<<"Yes";
    else cout<<"No";
    
    //cout<< (float) (d/s);
    return 0;
}


Measured memory_bytes: 3648
import math
N,K = map(int,input().split())
ite = []
for n in range(1,N+1):
  num = int(math.ceil(math.log2(K/n)))
  if num > -1:
    ite.append(num)
  else:
    ite.append(0)
ans = []
for i in ite:
  ans.append((1/N)*(0.5)**i)
print(sum(ans))



Measured memory_bytes: 6984
#include <bits/stdc++.h>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

int64_t modpow(int64_t x, int64_t n){
    int64_t res = 1;
    for(int64_t i = n; i > 0; i >>= 1){
        if(i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<int64_t> gcd(k);
    for(int i = k; i > 0; i--){
        gcd[i-1] += modpow(k/i, n);
        for(int j = 2; i * j <= k; j++){
            gcd[i-1] = (gcd[i-1] - gcd[i*j-1] + MOD) % MOD;
        }
    }
    int64_t ans = 0;
    for(int64_t i = 0; i < k; i++){
        ans += (i+1) * gcd[i] % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4044
#include<bits/stdc++.h>
#define sc1(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scl1(a) scanf("%lld",&a)
#define scl2(a,b) scanf("%lld%lld",&a,&b)
#define scl3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define pf1(a) printf("%d ",a)
#define pfl1(a) printf("%lld ",a)
#define pfn printf("\n")
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vl vector<long long>
#define si set<int>
#define sl set<long long>
#define msi multi_set<int>
#define msl multi_set<long long>
#define usi unordered_set<int>
#define usl unordered_set<long long>
#define mii map<int,int>
#define mli map<long long,int>
#define mll map<long long,long long>
#define umii unordered_map<int,int>
#define umli unordered_map<long long,int>
#define umll unordered_map<long long,long long>
#define lp(i,a,b) for(int i=a;i<b;i++)
#define rlp(i,a,b) for(int i=a;i>b;i--)
#define dslp(it,c) for(typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define pb push_back
#define pf push_front
#define ft first
#define sd second
#define N 100001
#define mod 1000000007
#define mod1 100000000
using namespace std;
typedef vector<vector<ll> > matrix;

int main(){
    int n;
    sc1(n);
    ll int a,x=0,y=0;
    lp(i,0,n){
        scl1(a);
        y= ( (y%mod)+(( (x%mod)*(a%mod) )%mod) )%mod;
        x=(x%mod+a%mod)%mod;
    }
    cout<<y<<endl;
}

Measured memory_bytes: 3752
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>   
#include <stdio.h>    
 
using namespace std;
     
#define F first
#define S second
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)2e5 + 123;
const ll inf = (ll)3e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, a[N], sum;

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n;
   for (int i = 1; i <= n; i ++) cin >> a[i], sum += a[i];
   int t1 = sum / n, t2 = (sum + n - 1) / n;
   int ans1 = 0, ans2 = 0;
   for (int i = 1; i <= n; i ++) {
      ans1 += sqr (abs (t1 - a[i]));
      ans2 += sqr (abs (t2 - a[i]));
   }
   cout << min (ans1, ans2);

}                                     

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
// cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}


Measured memory_bytes: 256
from math import factorial
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = {False: 'No', True: 'Yes'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


# show_flg = False
show_flg = True


def main():
    s = S()
    K = I()
    N = len(s)
    n = [int(s[i]) for i in range(N)]
    dp = [[[0 for j in range(max(N + 2, K + 2))]
           for smaller in range(2)]
          for i in range(N + 1)]
    dp[0][0][0] = 1

    for i in range(0, N):
        for smaller in range(2):
            for k in range(K + 1):
                for x in range(10 if smaller else n[i]+1):
                    if x != 0:
                        # print(i, smaller, k, k + 1)
                        dp[i+1][smaller or x < n[i]][k+1] += dp[i][smaller][k]
                    else:
                        dp[i+1][smaller or x < n[i]][k] += dp[i][smaller][k]
        # print(i, dp[i+1])

    # print(dp[N])
    print(dp[N][0][K] + dp[N][1][K])
    # print(C(2 * m + n - 1, 2*m) % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 40428
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (ai,ao,_,aj,al,_,_) = get!(usize, usize, usize, usize, usize, usize, usize);
    
    if ai % 2 == 1 {
        if (aj % 2 == 1 || al % 2 == 1) && (aj>0&&al>0) {
            println!("{}", 3+ai/2*2+ao+(aj-1)/2*2+(al-1)/2*2);
        } else {
            println!("{}", ai/2*2+ao+aj/2*2+al/2*2);
        }
    } else if ai > 0 {
        if aj%2 == 1 && al%2 == 1 {
            println!("{}", 3+(ai-1)/2*2+ao+aj/2*2+al/2*2);
        } else {
            println!("{}", ai/2*2+ao+aj/2*2+al/2*2);
        }
    } else {
        println!("{}", ao+aj/2*2+al/2*2);
    }
}


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

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

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

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

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

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

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

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//main code

int main(int argc, char const* argv[])
{
	int a,b,c;
	cin >> a >> b >> c;
	cout << min(a+b,min(b+c,c+a)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<random>
#include<ctime>
#include<cstdlib>
#include<unordered_map>
#include<string.h>
#include<iostream>
using namespace std;

int r[2005][2005];
signed main() {
	int n, k; cin >> n >> k;
	for (int i = 0; i < n; i++) {
		int x, y; cin >> x >> y;
		x %= k*2;
		y %= k*2;
		char c; cin >> c;
		if (x >= k&&y >= k) {
			x -= k;
			y -= k;
		}
		else if (x >= k) {
			x -= k;
			if (c == 'W')c = 'B';
			else c = 'W';
		}
		else if (y >= k) {
			y -= k;
			if (c == 'W')c = 'B';
			else c = 'W';
		}
		if (c == 'W') {
			r[0][0]++;
			r[0][y+1]--;
			r[x+1][0]--;
			r[x+1][y+1]++;

			r[x + 1][y + 1]++;
			r[x + 1][k]--;
			r[k][y + 1]--;
			r[k][k]++;
		}
		else {
			r[0][0]++;
			r[0][k]--;
			r[k][0]--;
			r[k][k]++;

			r[0][0]--;
			r[0][y+1]++;
			r[x+1][0]++;
			r[x+1][y+1]--;

			r[x + 1][y + 1]--;
			r[x + 1][k]++;
			r[k][y + 1]++;
			r[k][k]--;
		}
	}
	for (int i = 1; i < k; i++) {
		for (int j = 0; j < k; j++) {
			r[i][j] += r[i - 1][j];
		}
	}
	for (int i = 0; i < k; i++) {
		for (int j = 1; j < k; j++) {
			r[i][j] += r[i][j - 1];
		}
	}
	int ans = 0;
	for (int i = 0; i < k; i++) {
		for (int j = 0; j < k; j++) {
			ans = max({ ans, r[i][j] ,n-r[i][j]});
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pr printf
#define P push
#define PB push_back
#define F front
#define T top
#define MP make_pair
#define Fi first
#define Se second
using namespace std;
inline long long gcd(long long a,long long b){return b==0?a:gcd(b,a%b);}
inline long long lcm(long long a,long long b){return a/gcd(a,b)*b;}
inline void read(long long &x){
	char ch;
	do ch=getchar();while(ch<48||ch>57);
	x=0;while(ch<=57&&ch>=48){x=x*10+ch-48;ch=getchar();}
}
inline void read(int &x){
	char ch;
	do ch=getchar();while(ch<48||ch>57);
	x=0;while(ch<=57&&ch>=48){x=x*10+ch-48;ch=getchar();}
}
int i,j,k,n,m,a[110],b[110],c[110],d[110],top;
int main(){
	cin>>n;
	for(i=1;i<=n;i++){
		int A;
		scanf("%d",&A);
		if(A>i){
			cout<<-1<<endl;
			return 0;
		}
		for(j=i;j>=A+1;j--){
			a[j]=a[j-1];
		}
		a[A]=A;
	}
	for(i=1;i<=n;i++)
		cout<<a[i]<<endl;
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

bool solve() {
    auto s = readln.split.map!(to!int);
    auto P = s[0];
    auto Q = s[1];
    auto A = s[2];
    auto N = s[3];
    if (P == 0) return false;

    long dfs(long p, long q, int n, long prod, long prev) {
        if (p == 0) return 1;
        if (prod * prev > A) return 0;
        if (n == N) return 0;
        if (p * prev > q * (N - n)) return 0;
        long ret = 0;
        for (long i = prev; prod * i <= A; ++i) {
            long x = i * p - q;
            long y = i * q;
            if (x < 0) continue;
            if (x != 0 && prod * i * i > A) continue;
            long g = gcd(x, y);
            ret += dfs(x / g, y / g, n + 1, prod * i, i);
        }
        return ret;
    }

    dfs(P, Q, 0, 1, 1).writeln;
    return true;
}

void main() {
    while (solve) {}
}



Measured memory_bytes: 2416
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define pb push_back
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	string str[4] = {"AC", "WA", "TLE", "RE"};
	int cnt[4] = {};
	while (n--) {
		string in;
		cin >> in;
		for (int i = 0; i < 4; i++)
			if (in == str[i]) cnt[i]++;
	}
	for (int i = 0; i < 4; i++)
		cout << str[i] << " x " << cnt[i] << "\n";
	return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main()
{
    long long n,m,p,i,r=0,t=0;
    map<long long,long long>ac,wa;
    string s;
    cin>>n>>m;
    for(i=1;i<=m;i++)
    {
        cin>>p>>s;
        if(s=="AC")
        {
            ac[p]++;
            if(ac[p]==1)
            {
                r++;
                t+=wa[p];
            }
        }
        else 
        {
            wa[p]++;
        }
    }
    cout<<r<<" "<<t<<endl;
    return 0;
}

Measured memory_bytes: 16052
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
#define MOD 1000000007
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int>>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> score(N, K - Q);
    int A;
    rep(i, Q)
    {
        cin >> A;
        score[A-1]++;
    }

    rep(i, N)
    {
        if (score[i] > 0)
        {
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
    //system("pause");
    return 0;
}

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

using namespace std;

const int N = 3e3+5;

int n;
double a[N];
bool vis[N][N];
double mem[N][N];

double go(int idx , int cnt){
    if(idx == n + 1){
        return (cnt == 0);
    }
    if(vis[idx][cnt])
        return mem[idx][cnt];
    double c1 = 0;
    if(cnt)
        c1 = go(idx + 1 , cnt - 1) * a[idx];
    double c2 = go(idx + 1 , cnt) * (1.0 - a[idx]);
    vis[idx][cnt] = 1;
    return mem[idx][cnt] = c1 + c2;
}

int main(){
    scanf("%d " , &n);
    for(int i = 1; i <= n; i++){
        scanf("%lf" , &a[i]);
    }
    double ans = 0;
    for(int i = n / 2 + 1; i <= n; i++)
        ans += go(1 , i);
    printf("%.10lf\n" , ans);
}


Measured memory_bytes: 79336
#include<bits/stdc++.h>
using namespace std;
int n,h[100100],d[100100];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>h[i];
	} 
	for(int i=1;i<n;i++)
	{
		int b;
		int a=abs(h[i-1]-h[i]);
		b=abs(h[i-2]-h[i]);
		d[i]=d[i-1]+a;
		if(i>1 && d[i]>d[i-2]+b)
		{
			d[i]=d[i-2]+abs(h[i-2]-h[i]);
		} 
	}
	cout<<d[n-1];
	return 0;
}

Measured memory_bytes: 1024
n, k = map(int, input().split())
x = list(map(int, input().split()))

ans = 10**9

for i in range(n-k+1):
    l, r = x[i], x[i+k-1]
    ans = min(ans, min(abs(l), abs(r)) + abs(l - r))

print(ans)


Measured memory_bytes: 14568
#include <iostream>
#include <vector>
using namespace std;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

constexpr int MOD = 1000000007;

int main()
{
    int N, J = 0, K = 0, L = 0;
    cin >> N;

    vector<int> st(N * 2 + 1);
    REP(_, N)
    {
        int A, B;
        cin >> A >> B;
        if (A < 0 and B > 0) st[B] = 1, K++;
        else if (A > 0 and B < 0) st[A] = 1, K++;
        else if (A > 0 and B > 0) st[A] = st[B] = 2, L++;
        else J++;
    }

    vector<vector<int>> dp(K + 1, vector<int>(N - L + 1));
    dp[0][0] = 1;

    int G = 0, H = 0;

    REP(i, 2 * N)
    {
        int s = st[2 * N - i];
        if (s == 2) continue;
        else if (s)
        {
            IREP(k, K + 1) REP(j, N - L + 1)
            {
                dp[k][j] = (j < N - L ? dp[k][j + 1] : 0) + (k ? dp[k - 1][j] : 0);
                if (dp[k][j] >= MOD) dp[k][j] -= MOD;
            }
            H++;
        }
        else
        {
            REP(k, K + 1)
            {
                vector<int> tmp = dp[k];
                REP(j, N - L + 1)
                {
                    int pa2 = G - H - (j + 1) + k;
                    dp[k][j] = ((j < N - L ? dp[k][j + 1] * (long long int)(J - pa2 / 2) : 0LL)
                    + (k < K ? dp[k + 1][j] * (long long int)(k + 1) : 0LL)
                    + (j ? tmp[j - 1] : 0)) % MOD;
                }
            }
            G++;
        }
    }
    cout << dp[0][0] << endl;
}


Measured memory_bytes: 640
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var N=arr.shift()-0;
   if(N==0)break;
   var obj={};
   var ary=[];
   for(var i=0;i<N;i++){
      var nws=(arr.shift()).split(" ");
      var name=nws[0];
      var w=nws[1]-0;
      var s=nws[2].split("").map(Number);
      s=(s.length==3)?s[0]*60+s[1]*10+s[2]:s[0]*600+s[1]*60+10*s[2]+s[3];
      obj[name]=(w*1440)+s;
      ary.push((w*1440)+s);
   }
   var P=arr.shift()-0;
   var bad=[];
   for(var i=0;i<P;i++){
      var f=arr.shift();
      ary.push(obj[f]-29.5);
      bad.push(obj[f]);
   }
   ary.sort(function(a,b){return a-b;});
   bad.sort(function(a,b){return a-b;});
   var cnt=0;
   var i=0;
   ary.forEach(function(v){
      if(v%1==0.5){cnt++;i=v+29.5+30;}
      else if(i<=v){cnt++;i=v+30;}
   });
   var i=0;
   bad.forEach(function(v){
      if(i<=v){i=v+30;}
      else cnt=-1;
   });   
   console.log(cnt);
}

Measured memory_bytes: 43528
#include<bits/stdc++.h>
#define ll long long 
#define ull unsigned long long
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define repr(i,n) for (int i = n; i >= 0; --i)
#define P pair<int, int>
#define ALL(x) (x).begin(),(x).end()
const int INF = 1e9;
using namespace std;

void search(int x, int y) {
	
}

void dfs(int x, int y) {
	
}

int solve() {
	
}

int main() {
	unsigned x,y;
	cin >> x >> y;
	bitset<32>bf(x); bitset<32>bs(y);
	cout << (bf&bs) << endl;
	cout << (bf|bs) <<endl;
	cout << (bf^bs) <<endl;
}


Measured memory_bytes: 3160
mod=998244353
n,k=map(int,input().split())
LR=[list(map(int,input().split())) for _ in range(k)]

DP=[0 for _ in range(n+1)]
SDP=[0 for _ in range(n+1)]
DP[1]=1
SDP[1]=1

for i in range(2,n+1):
    for l,r in LR:
        DP[i] +=(SDP[max(i-l,0)]-SDP[max(i-r,1)-1])%mod
        DP[i] %=mod
    SDP[i]=(SDP[i-1]+DP[i])%mod
print(DP[n])

Measured memory_bytes: 100628
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String w[] = s.split("", -1);
        int cnt = 0;
        for(int i = 0; i < 3; i++){
            if(w[i].equals("R")){
                cnt += 1;
            }
        }

        if(cnt == 3){
            System.out.println("3");
        }else if(cnt == 2 && w[1].equals("R")){
            System.out.println("2");
        }else if(cnt == 0){
            System.out.println("0");
        }else{
            System.out.println("1");
        }
    }
}

Measured memory_bytes: 35508
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        var nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nk[0];
        var k = nk[1];
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(a.Count(x => k <= x));
    }

    static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0;
            int next = Console.In.Read();
            int sign = 1;
            while (45 > next || next > 57) next = Console.In.Read();
            if (next == 45) { next = Console.In.Read(); sign = -1; }
            while (48 <= next && next <= 57)
            {
                res = res * 10 + next - 48;
                next = Console.In.Read();
            }
            return res * sign;
        }
    }
}


Measured memory_bytes: 19040
from itertools import combinations
l, r = map(int, input().split())
if l // 2019 < r // 2019:
    print(0)
else:
    m = 2019
    for i, j in combinations(range(l, r+1),2):
        tmp = i*j % 2019
        if m > tmp:
            m = tmp
    print(m)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int N, M;
    cin>>N>>M;
    unordered_map<ll, ll> mp;
    ll s = 0;
    rep(i, N) {
        ll a;
        cin>>a;
        s = (s + a) % M;
        mp[s] += 1;
    }
    ll ans = 0;
    for (auto c : mp) {
        if (c.first == 0) ans += c.second * (c.second + 1) / 2;
        else ans += c.second * (c.second - 1) / 2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3724
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX 1e7
int main(){
    ll number; cin >> number;
    vvl dp(101,vl(100,-INF));
    vi array(100,0);
    rep(i,number)
    cin >> array[i]; dp[0][array[0]] = 1;
    rep(i,number-1){
        rep(j,21){
            if(dp[i][j] != -INF){
                //cout << "dp[i][j] " << i << j << endl;
                int temp1 = j+array[i+1];
                int temp2 = j-array[i+1];
                if(0<=temp1&&temp1<=20){
                    if(dp[i+1][temp1] == -INF)
                        dp[i+1][temp1] = 0;
                    dp[i+1][temp1]+=dp[i][j];}
                if(0<=temp2 && temp2<=20){
                    if(dp[i+1][temp2] == -INF)
                        dp[i+1][temp2] = 0; dp[i+1][temp2]+=dp[i][j];
                }
            }
        }
    }
    cout <<dp[number-2][array[number-1]]<< endl;
    return 0;
}

Measured memory_bytes: 3220
#include <stdio.h>

int main() {
    int s = 0;
    int m = 0;
    int h = 0;
    
    scanf("%d", &s);
    h = s/3600;
    s = s - (3600*h);
    m = s/60;
    s = s - (60*m);
    printf("%d:%d:%d\n", h, m, s);
    return 0;
}


Measured memory_bytes: 2084
#include<bits/stdc++.h>
#define REP(i,n) for(long long i=0;i<n;++i)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
using namespace std;
const int MAX=1e5+1;
const int NIL=-1;
int n,color[MAX];
vector< int > graph[MAX];
void dfs(int r,int c){
    stack< int > S;
    S.push(r);
    color[r]=c;
    while(!S.empty()){
        int u=S.top();S.pop();
        REP(i,graph[u].size()){
            int v=graph[u][i];
            if(color[v]==NIL){
                color[v]=c;
                S.push(v);
            }
        }
    }
}
int main(){
    int s,t,m,q;
    scanf("%d%d",&n,&m);
    REP(i,m){
        scanf("%d%d",&s,&t);
        graph[s].push_back(t);
        graph[t].push_back(s);
    }
    int id=1;
    fill(color,color+MAX-1,NIL);
    REP(u,n){
        if(color[u]==NIL) dfs(u,id++);
    }
    scanf("%d",&q);
    REP(i,q){
        scanf("%d%d",&s,&t);
        printf("%s\n",color[s]==color[t]?"yes":"no");
    }
    return 0;
}




Measured memory_bytes: 9052
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  int N;
  cin >> N;
  for(double i=N;i>0;i--)
  {
    for(int j=0;j<32;j++)
    {
      if(pow(j,2)==i)
      {
        cout << i << endl;
        return 0;
      }
      if(pow(j,3)==i)
      {
        cout << i << endl;
        return 0;
      }
      if(pow(j,4)==i)
      {
        cout << i << endl;
        return 0;
      }
      if(pow(j,5)==i)
      {
        cout << i << endl;
        return 0;
      }
      if(pow(j,6)==i)
      {
        cout << i << endl;
        return 0;
      }
      if(pow(j,7)==i)
      {
        cout << i << endl;
        return 0;
      }
      if(pow(j,8)==i)
      {
        cout << i << endl;
        return 0;
      }
      if(pow(j,9)==i)
      {
        cout << i << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256