akhauriyash/Code-Regression huggingface dataset:
from itertools import combinations_with_replacement

n,m,q=map(int,input().split())
ABCD=[list(map(int,input().split())) for _ in range(q)]
N=[i+1 for i in range(m)]

cnt=0
for A in combinations_with_replacement(N,n):
    point=0
    for a,b,c,d in ABCD:
        if A[b-1]-A[a-1]==c:
            point +=d
    cnt=max(cnt,point)
print(cnt)

Measured memory_bytes: 73364
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
int x, y, a, b, c;
int p[100005], q[100005], r[100005];
priority_queue<int, vector<int>, greater<int> > pq, pq2;
void init(){
    x = read(), y = read(), a = read(), b = read(), c = read();
    for (int i = 1; i <= a; ++i)
        p[i] = read();
    for (int i = 1; i <= b; ++i)
        q[i] = read();
    for (int i = 1; i <= c; ++i)
        r[i] = read();
    sort(r + 1, r + c + 1);
}
void solve(){
    ll sum = 0;
    for (int i = 1; i <= a; ++i){
        pq.push(p[i]);
        sum += 1ll * p[i];
        if (pq.size() > x) 
            sum -= 1ll * pq.top(), pq.pop();
    }
    for (int i = 1; i <= b; ++i){
        pq2.push(q[i]);
        sum += 1ll * q[i];
        if (pq2.size() > y) 
            sum -= 1ll * pq2.top(), pq2.pop();
    }
    for (int i = c; i >= 1; --i){
        if (r[i] >= pq.top() || r[i] >= pq2.top()){
            if (pq.top() < pq2.top()) 
                sum -= 1ll * pq.top(), pq.pop(), pq.push(r[i]);
            else 
                sum -= 1ll * pq2.top(), pq2.pop(), pq2.push(r[i]);
            sum += 1ll * r[i];
        }else break;
    }
    printf("%lld\n", sum);
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 2552
#include <iostream>
#include <vector>
#include <cstdio>

int digitCount(int number)
{
    int result = 1;
    while (number > 9) {
        number /= 10;
        result++;
    }
    return result;
}

int main(int argc, const char * argv[]) {

    std::string line;
    std::vector<int> sum;
    int n1 = 0;
    int n2 = 0;
    
    while (std::getline(std::cin, line))
    {
        sscanf((const char*) line.c_str(), "%d %d", &n1, &n2);
        sum.push_back(digitCount(n1 + n2));
        
    }
    //std::cout << std::endl;
    //std::cout << std::endl;
    
    std::vector<int>::iterator it = sum.begin();
    std::cout << *it << std::endl;
    
    while (++it < sum.end()) {
        
        std::cout << *it << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 1260
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 1e3+10;
int n,cnt[N],s,m,ans[N];

int b[N];
poly res;
bool vis[N];
inline bool check(int len){
	int las=n-len;
	if (m-las+1<=0||m+len>s) return 0;
	For(i,1,n) vis[i]=0;
	For(i,m-las+1,m) vis[ans[i]]=1;
	int mn=1e9,mx=0;
	For(i,1,n) b[i]=cnt[i]-(vis[i]^1),mn=min(mn,b[i]),mx=max(mx,b[i]);
	if (mn<0) return 0;
	res={};
	if (mn*2>=mx){
		For(i,1,n) if (!vis[i]) res.pb(i);
		return 1;
	} else if (mn*2+1==mx){
		poly A,B;
		For(i,1,n) if (!vis[i]&&b[i]==mx) A.pb(i);
		For(i,1,n) if (!vis[i]&&b[i]==mn) A.pb(i);
		For(i,1,n) if (!vis[i]&&b[i]!=mx&&b[i]!=mn) B.pb(i);
		int l1=0,l2=0;
		while (l1<siz(A)||l2<siz(B)){
			if (l2==siz(B)) res.pb(A[l1++]);
			else if (l1==siz(A)) res.pb(B[l2++]);
			else if (A[l1]<B[l2]) res.pb(A[l1++]);
			else res.pb(B[l2++]);
		}
		int r=0,l=0;
		For(i,1,las){
			if (b[ans[m-i+1]]==mx) r=i;
			if (b[ans[m-i+1]]==mn&&!l) l=i;
		}
		FOR(i,0,siz(res)){
			if (b[res[i]]==mx) r=las+i+1;
			if (b[res[i]]==mn&&!l) l=las+i+1; 
		}
		if (r<l) return 1;
			else return 0;
	} else return 0;
}
inline bool check(poly a,poly b){
	int n=max(siz(a),siz(b));
	a.resize(n),b.resize(n);
	FOR(i,0,n) if (a[i]!=b[i]) return a[i]<b[i];
	return 0;
}
inline void insert(){
	poly ret;
	For(i,1,n)
		if (check(i))
			if (ret.empty()||check(res,ret)) ret=res;
	for (auto i:ret) ans[++m]=i,cnt[i]--;
}

int main(){
	n=read();
	int mx=0,mn=1e9;
	For(i,1,n){
		cnt[i]=read(),s+=cnt[i];
		mx=max(mx,cnt[i]),mn=min(mn,cnt[i]);
	}
	if (mn*2<mx) return puts("-1"),0;
	while (m<s) insert();
	For(i,1,m) printf("%d ",ans[i]);
}

Measured memory_bytes: 3696
#include <iostream> 
#include <stdlib.h> 
#include <string.h> 
#include <string> 
#include <sstream>
#include <cstring> 
#include<cmath>
using namespace std;
int main()
{
	int w, a, b;
	cin >> w >> a >> b;
	int c= max(a, b) - min(a + w, b + w);
	if (c > 0)
		cout << c;
	else
		cout << 0;
    return 0;
}

Measured memory_bytes: 3560
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

long a[10][10][15];

long n;

int main(){
    scanf("%ld", &n);
    for(int i = 0; i < n; i++){
        long b, f, r, v;
        scanf("%ld%ld%ld%ld", &b, &f, &r, &v);
        a[b][f][r] += v;
    }
    for(int i = 1; i <= 4; i++){
        for(int j = 1; j <= 3; j++){
            for(int k = 1; k <= 10; k++){
                printf(" %ld", a[i][j][k]);
            }
            printf("\n");
        }
        if(i < 4){
            printf("####################\n");
        }
    }
}



Measured memory_bytes: 3220
#include<stdio.h>

int main(void){
  char a[4];
  
  scanf("%s",a);
  int i,j;
  int k,l;
  k=0;
  l=0;
  if(a[0]==a[1]){
  	if(a[1]!=a[2]){
        if(a[2]==a[3]){
          printf("Yes");
          k+=1;
        }
    }
  }
  if(a[0]==a[3]){
    if(a[0]!=a[1]){
      if(a[1]==a[2]){
        printf("Yes");
          k+=1;
      }
    }
  }
  if(a[0]==a[2]){
      if(a[0]!=a[1]){
        if(a[1]==a[3]){
          printf("Yes");
            k+=1;
        }
      }
    }
  if(k==0){
            printf("No");
  }
  return 0;
}

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

namespace AtCoderCs
{
    class Program
    {
        static void Main()
        {

            var Arg = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            if (Arg[1] == 1) Console.WriteLine(0);
            else
            {

                var CompareA = Arg[0] % Arg[1];
                var CompareB = Arg[1] - CompareA;

                Console.WriteLine((CompareA < CompareB ? CompareA : CompareB));

            }

        }

    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include <numeric>
#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll gcd(ll x,ll y){
	if(!(x%y))return y;
	else return gcd(y,x%y);
}

ll lcm(ll x,ll y){
	return (x*y)/gcd(x,y);
}

int main() {
  ll a,b,c,d;cin >> a >> b>> c>> d;
  ll dif=b-a;
  ll e = lcm(c,d);

  ll p = b/c-(a-1)/c;
  ll q =  b/d-(a-1)/d;
  ll r = b/e-(a-1)/e;

  cout << dif+1-(p+q-r);

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i = a;i < n;i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;


ull gcd(ull a,ull b){
	if(!b) return a;
	return gcd(b,a%b);
}


int main(){
	int n,m,a,b;
	cin >> n >> m;
	int c[n] = {0},d[n] = {0};
	
	rep(i,0,m){
		cin >> a >> b;
		if(a == 1){
			c[b-1] = 1;
		}
		else if(b == 1){
			c[a-1] = 1;
		}
		else if(a == n){
			d[b-1] = 1;
		}
		else if(b == n){
			d[a-1] = 1;
		}
	}
	
	rep(i,1,n-1){
		if(c[i] && d[i]){
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	
	cout << "IMPOSSIBLE" << endl;
	
	return 0;
}

Measured memory_bytes: 1792
#!/usr/bin/env python
# coding: utf-8

# In[8]:


N,M = map(int, input().split())
A = []
B = []
for _ in range(N):
    A.append(input())
for _ in range(M):
    B.append(input())


# In[11]:


f = False
for h in range(N-M+1):
    for w in range(N-M+1):
        for i in range(M):
            for j in range(M):
                if B[i][j] != A[i+h][j+w]:
                    break
            else:
                continue
            break
        else:
            f = True
            print("Yes")
            break
    else:
        continue
    break
if f != True:
    print("No")


# In[ ]:






Measured memory_bytes: 9032
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var s = Read();
            var ans = 0;
            for (int i = 0; i < n-2; i++)
            {
                if(s[i].ToString() + s[i + 1].ToString() + s[i + 2].ToString() == "ABC")
                {
                    ans++;
                }
            }
            WriteLine(ans);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int n,x;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    int cnt=0;
    for(int i=1;i<=n;i++){
        cin>>x;
        if(x&1) cnt++;
    }
    if(cnt&1){
        cout<<"NO"<<endl;
    }
    else cout<<"YES"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;cin >> s;
    int n=s.size();
    vector<int> c(n),r(n),l(n);
    int cnt=0;
    for(int i=0;i<n;i++){
        if(s[i]=='R'){
            cnt++;
        }
        else{
            r[i-1]=cnt;
            cnt=0;
        }
    }
    for(int i=n-1;i>=0;i--){
        if(s[i]=='L'){
            cnt++;
        }
        else{
            l[i+1]=cnt;
            cnt=0;
        }
    }
    for(int i=0;i<n;i++){
        if(i){
            if(s[i-1]=='R'&&s[i]=='L'){
                c[i-1]+=(r[i-1]+1)/2+l[i]/2;
                c[i]+=r[i-1]/2+(l[i]+1)/2;
            }
        }
    }
    for(int i=0;i<n;i++){
        cout << c[i] << " ";
    }
    cout << endl;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> b(n - 1);
    rep(i, n - 1) cin >> b[i];
    vector<int> a(n);
    rep(i, n)
    {
        if (i == 0)
            a[i] = b[i];
        else if (i == n - 1)
            a[i] = b[i - 1];
        else
            a[i] = min(b[i - 1], b[i]);
    }
    int ans = 0;
    rep(i, n) ans += a[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
import java.util.HashMap;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scn = new Scanner(System.in);
        int n = scn.nextInt();
        scn.nextLine();
        FreqMap map = new FreqMap();
        String[] arrstr = scn.nextLine().split(" ");
        long[] array = new long[n];

        for (int i = 0; i < n; i++) {
            array[i] = Integer.parseInt(arrstr[i]);
            map.add(array[i]);
        }
        long ans = 0;
        for (long num : map.map.values()) {
            ans += num * (num - 1) / 2;
        }

        for (int i = 0; i < n; i++) {
            long num = map.getCount(array[i]);
            long finalans = ans - (num * (num - 1) / 2) + ((num - 1) * (num - 2) / 2);
            System.out.println(finalans);
        }

    }

}

class FreqMap {
    HashMap<Long, Long> map;

    FreqMap() {
        map = new HashMap<>();
    }

    public void add(long n) {
        if (map.containsKey(n)) {
            map.put(n, map.get(n) + 1);
        } else {
            map.put(n, 1L);
        }
    }

    public long getCount(long n) {
        return map.get(n);
    }
}

Measured memory_bytes: 92616
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,sum=0;
  cin>>n>>k;
  float a[n];
  for(int y=0;y<n;y++)
  {
  	cin>>a[n];
  	if(a[n]>=k)
  	sum++;
  }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))



def isOK(A, index, key):
    if A[index] >= key:
        return True
    else:
        return False


def binary_search(A, key):
    ng = -1
    ok = len(A)

    while(abs(ok-ng) > 1):
        mid = (ok + ng) // 2

        if isOK(A, mid, key):
            ok = mid
        else:
            ng = mid
    return ok


count = 0
for key in T:
    if S[binary_search(S, key)] == key:
        count += 1

print(count)


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

int main () {
  int N ;
  cin >> N ;
  int A = N ;
  int sum = 0 ;
  for(int i = 0 ; i < 10 ; i++){
    if(N<1){
      break;
    }
    sum += N%10 ;
    N /= 10 ;
  }
  
  if (A%sum==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
import itertools
import math
import fractions
import functools
import copy

s=input()
count1 = 0
for i in range(len(s)):
    if i % 2 == 0 and s[i] != "0":
        count1 += 1
    if i % 2 != 0 and s[i] == "0":
        count1 += 1

count2 = 0
for i in range(len(s)):
    if i % 2 == 0 and s[i] != "1":
        count2 += 1
    if i % 2 != 0 and s[i] == "1":
        count2 += 1

print(min(count1,count2))

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;

const int dy[] = {0,0,1,-1};
const int dx[] = {1,-1,0,0};
int main()
{
	int n, m;
	cin >> n >> m;

	vector<int> iti(0);
	// 1 から行ける場所
	set<int> enu;
	rep(i,m){
		int a, b;
		cin >> a >> b;
		if(a == 1){
			iti.push_back(b);
		}
		if(b == n){
			enu.insert(a);
		}
	}
	for(auto x:iti){
		if(enu.count(x)){
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 8292
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;


int main() {
  str S;
  cin>>S;
  int N=S.size();
  int ans=999;
  for(int i=0;i<=N-3;i++){
      int num= (S[i]-'0')*100+(S[i+1]-'0')*10+(S[i+2]-'0');
      ans=min(ans,abs(num-753));
  }
  cout<<ans<<endl;
}


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

int main()
{
  char c;
  cin >> c;

  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
  {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
typedef pair<int, ll> P;
class BiOp1 {
public:
	ll operator()(ll a, ll b) const {
		return max(a, b);
	}
};
class BiOp2 {
public:
	ll operator()(ll a, ll b) const {
		return a + b;
	}
};
class BiOp3 {
public:
	ll operator()(ll a, ll b) {
		return a + b;
	}
};
template<class T1, class T2, class BiOp1, class BiOp2, class BiOp3>
struct LazySegmentTree {
	//BiOp1:T1×T1->T1
	//BiOp2:T2×T2->T2
	//BiOp3:T1×T2->T1
	vector<T1> data;
	vector<T2> lazy;
	T1 e1;
	T2 e2;
	BiOp1 op1;
	BiOp2 op2;
	BiOp3 op3;
	int size;
	LazySegmentTree(int n, T1 e1, T2 e2, BiOp1 op1, BiOp2 op2, BiOp3 op3) :e1(e1), e2(e2), op1(op1), op2(op2), op3(op3) {
		size = 1;
		while (size < n) size *= 2;
		data.resize(size * 2 - 1);
		lazy.resize(size * 2 - 1);
		for (int i = 0; i < size * 2 - 1; i++) {
			data[i] = e1;
			lazy[i] = e2;
		}
	}
	void push(int k) {
		if (lazy[k] == e2) return;
		if (k < size) {
			lazy[k * 2 + 1] = op2(lazy[k * 2 + 1], lazy[k]);
			lazy[k * 2 + 2] = op2(lazy[k * 2 + 2], lazy[k]);
		}
		data[k] = op3(data[k], lazy[k]);
		lazy[k] = e2;
	}
	T1 query(int a, int b) {
		return query(a, b, 0, 0, size);
	}
	T1 query(int a, int b, int k, int l, int r) {
		if (b <= l || r <= a) return e1;
		if (a <= l && r <= b) return op3(data[k], lazy[k]);
		push(k);
		return op1(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
	}
	T1 get(int x) {
		return query(x, x + 1, 0, 0, size);
	}
	void update(int a, int b, T2 v, int k, int l, int r) {
		if (b <= l || r <= a) return;
		if (a <= l && r <= b) {
			lazy[k] = op2(lazy[k], v);
			return;
		}
		push(k);
		update(a, b, v, k * 2 + 1, l, (l + r) / 2);
		update(a, b, v, k * 2 + 2, (l + r) / 2, r);
		data[k] = op1(op3(data[k * 2 + 1], lazy[k * 2 + 1]), op3(data[k * 2 + 2], lazy[k * 2 + 2]));
	}
	void update(int a, int b, T2 v) {
		update(a, b, v, 0, 0, size);
	}
};
vector<P> range[200000];
int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int l, r;
		ll a;
		cin >> l >> r >> a;
		l--; r--;
		range[r].emplace_back(l, a);
	}
	LazySegmentTree<ll, ll, BiOp1, BiOp2, BiOp3> S(N, 0, 0, BiOp1(), BiOp2(), BiOp3());
	for (int i = 0; i < N; i++) {
		if (i > 0) {
			ll x = S.query(0, i);
			S.update(i, i + 1, x);
		}
		for (P p : range[i]) {
			S.update(p.first, i + 1, p.second);
		}
	}
	cout << max(0LL, S.query(0, N)) << endl;
}

Measured memory_bytes: 19328
n = gets.to_i
ps = [0, *gets.split.map(&:to_i)]

v = ps.each_with_index.with_object(Array.new(n + 1, 1)) do |(p, i), arr|
  arr[p] = 0 if p == i
end[1..-1]

ans = 0

(n - 1).times do |i|
  next if v[i] == 1

  v[i + 1] = 1
  ans += 1
end

ans += 1 if v[-1] == 0

puts ans


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

const int maxn=1e5+100;
struct node{
	int i;
	int rank;
	bool operator<(const node& x){
		return rank<x.rank;
	}
};

vector<node> v(0);
int N;
node curr;

int main(){
	cin>>N;
	int rank;
	for(int i=1;i<N+1;i++){
		cin>>rank;
		curr.i = i;
		curr.rank = rank;
		v.push_back(curr);
	}	
	sort(v.begin(),v.end());
	for(int i=0;i<v.size();i++){
		if(i!=0) cout<<" ";
		cout<<v[i].i;
	}
	return 0;
} 

Measured memory_bytes: 1780
def SumIndicatedPoint(pcandid):
	point = list(str(pcandid))
	conNum = nums[0]
	count = 1
	sum = 0
	for p in point:
		if p == '0':
			conNum = conNum + nums[count]
		elif p == '1':
			sum = sum + int(conNum)
			conNum = nums[count]
		count = count + 1
	sum = sum + int(conNum)
	#print(str(sum))	
	return sum
	
if __name__ == '__main__':	
	nums = list(input())
	#nums.reverse()
	ALLSUM = 0
	pcandidstr = '0' + str(len(nums) - 1) + 'b'
	pcandid = 0
	if len(nums) > 1:
		maxcandid = int('1' * (len(nums) - 1),2)
		#add = format(1,pcandidstr)
		while pcandid <= maxcandid:
			ALLSUM = ALLSUM + SumIndicatedPoint(format(pcandid,pcandidstr))
			pcandid = pcandid + 1
	elif len(nums) == 1:
		ALLSUM = int(nums[0])
	print(str(ALLSUM))

Measured memory_bytes: 3064
/*
declare function require(id:string);
const {stdin} = require('process');
let input = "";
stdin.on('data', x => {input += x});
stdin.on('end', () => {
    let [a, b] = input.split(' ')
        .map(x=>x.trim()).map(x=>parseInt(x));
    if (8 < a || 8 < b) {
        console.log(':(');
    }
    else {
        console.log('Yay!');
    }
});
*/

var stdin = require('process').stdin;
var input = "";
stdin.on('data', function (x) { input += x; });
stdin.on('end', function () {
    var _a = input.split(' ')
        .map(function (x) { return x.trim(); }).map(function (x) { return parseInt(x); }), a = _a[0], b = _a[1];
    if (8 < a || 8 < b) {
        console.log(':(');
    }
    else {
        console.log('Yay!');
    }
});


Measured memory_bytes: 21192
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N, X;
  cin >> N >> X;
  vector<int> m(N);
  for(int i=0; i<N; i++){
	cin >> m.at(i);
  }
  for(int i=0; i<N; i++){
    X -= m.at(i);
  }
  sort(m.begin(), m.end());
  int count = 0;
  while(X >= m.at(0)){
    X -= m.at(0);
    count++;
  }
  cout << N+count << endl;


  }  

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



i64 n, a[202020];
i64 d[202020];
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		d[i+1] = d[i]+a[i];
	}
	
	i64 ans = LINF;
	for(int i = 1; i < n; i++){
		chmin(ans, abs(d[n]-d[i] - d[i]));
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<map>
using namespace std;
int main(){
  map<string,int> word;
  string s,ss;
  int a = 0,b = 0;
  while(cin >>s) word[s]++;
  for(map<string,int>::iterator it = word.begin(); it!=word.end(); it++){
    if(a < it->second){a = it->second;ss = it->first;}
    if(b < (it->first).size()){b =  (it->first).size();s = (it->first);}
  }
  cout <<ss<<" "<<s<<endl;
  return 0;
}

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

int main( )
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a > b) swap(a, b);
    if (b > c) swap(c, b);
    if (a > b) swap(a, b);
    if (a == 5 && b == 5 && c == 7) {
        cout << "YES\n";
    }
    else {
        cout << "NO\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
typedef long long ll;
int main() {
//input
long long k;
long long count=0;
long long a=0;
long long b=0;
scanf("%lld",&a);
scanf("%lld",&b);
scanf("%lld",&k);

if(k<=a){
	a=a-k;
}
else if(k>a){
	if(k<=(a+b)){
		// b=k-a-b;
		b=b-(k-a);
		a=0;
	}
	else{
		a=0;
		b=0;
	} 
}

//output
	printf("%lld %lld",a,b);
	return 0;
}

Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let x: usize = sc.read();
    let mut dp = vec![false; x + 1];
    dp[0] = true;
    for v in vec![0, 1, 2, 3, 4, 5].into_iter() {
        let v = v + 100;
        for i in 0..x {
            if dp[i] && i + v <= x {
                dp[i + v] = true;
            }
        }
    }

    if dp[x] {
        println!("1");
    } else {
        println!("0");
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ll)(1e9)+7)

int main(){
	int n;
	cin >> n;
	ll a[n+1];
	a[0]=-1;
	for(int i=1; i<=n; i++) cin >> a[i];

	int d[3];
	fill(d, d+3, -1);
	ll ans=1;
	for(int i=1; i<=n; i++){
		int t=0;
		for(int j=0; j<3; j++){
			if(a[i]==d[j]+1) t++;
		}
		ans=ans*t%mod;
		for(int j=0; j<3; j++){
			if(a[i]==d[j]+1){
				d[j]++;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 998244353, INF = 1E9 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

int arr[100005], dp[100005] ;
int n, k ;

int check(int pos)
{
    if (dp[pos] != INF) {
        return dp[pos] ;
    }
    else {
        for (int i = 1; i <= k; i++) {
            if (pos - i < 0)    continue ;
            dp[pos] = min(dp[pos], check(pos - i) + abs(arr[pos] - arr[pos - i]) ) ;
        }
        return dp[pos] ;
    }
}

int main()
{
    int ans ;
    cin >> n >> k ;

    for (int i = 0; i < n; i++) {
        cin >> arr[i] ;
        dp[i] = INF ;
    }
    dp[0] = 0 ;
    ans = check(n - 1) ;
    cout << ans ;

    return 0 ;
}


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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
//debug
#define vecprint(v) rep(i,v.size())cout << v[i] << " ";cout << endl;
#define setprint(s) for(auto i=s.begin();i!=s.end();i++)cout << *i << " ";cout << endl;
#define mappairprint(s) for(auto i=s.begin();i!=s.end();i++)cout << i->first << " " << i->second << endl;cout << endl;
//reader
#define r1(a) cin>>(a)
#define r2(a,b) cin>>(a)>>(b)
#define r3(a,b,c) cin>>(a)>>(b)>>(c)
//writer
#define w1(a) cout<<(a)<<" "
#define w2(a,b) cout<<(a)<<" "<<(b)<<" "
#define w3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "
#define wl1(a) cout<<(a)<<endl
#define wl2(a,b) cout<<(a)<<" "<<(b)<<endl
#define wl3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
//variable definition
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
//roop
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define all(c) c.begin(),c.end()
//term
#define elif else if
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
using namespace std;
using ll = long long;
//const
constexpr double PI = 3.141592653589793238462643383279;
vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};


int main() {
  //input
  ll a,v,b,w,t;
  cin >> a >> v >> b >> w >> t;

  //process
  ll diff = abs(a-b);
  ll move = abs(v-w);
  
  //output
  if(v <= w) {
    cout << "NO" << endl;
  } else if(diff <= move * t) {
    cout << "YES" << endl;
  } else { 
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    ll A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    ll ans = 0;
    if (2*C < A+B) {
        ans += min(X, Y) * C * 2;
        if (X > Y) {
            ans += (X-Y) * min(A, C*2);
        } else {
            ans += (Y-X) * min(B, C*2);
        }
    } else {
        ans += X * A;
        ans += Y * B;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

struct Sieve {
    int n;
    vector<int> f, primes;
    Sieve(int n=1):n(n), f(n+1) {
        f[0] = f[1] = -1;
        for (ll i = 2; i <= n; i++) {
            if (f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            for (ll j = i*i; j <= n; j += i) {
                if (!f[j]) f[j] = i;
            }
        }
    }
    bool isPrime(int x) { return f[x] == x;}
    vector<int> factorList(int x) {
        vector<int> res;
        while (x != 1) {
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    vector<P> factor(int x) {
        vector<int> fl = factorList(x);
        if (fl.size() == 0) return {};
        vector<P> res(1, P(fl[0], 0));
        for (int p : fl) {
            if (res.back().first == p) {
                res.back().second++;
            } else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
    vector<pair<ll,int>> factor(ll x) {
        vector<pair<ll,int>> res;
        for (int p : primes) {
            int y = 0;
            while (x%p == 0) x /= p, ++y;
            if (y != 0) res.emplace_back(p,y);
        }
        if (x != 1) res.emplace_back(x,1);
        return res;
    }
};

vector<int> d;
map<int,int> mp;
int ans = 0;

int dp[30][80];

int main() {
    int n;
    cin >> n;
    Sieve sieve(n);
    for (int i = 1; i <= n; i++) {
        vector<P> a = sieve.factor(i);
        for (auto p : a) {
            mp[p.first] += p.second;
        }
    }
    d = sieve.primes;
    
    rep(i,30)rep(j,80) dp[i][j] = 0;
    dp[0][1] = 1;
    rep(i,d.size()) {
        for (int j = 1; j <= 75; j++) {
            if (dp[i][j] == 0) continue;
            int x = mp[d[i]];
            for (int k = 0; k <= x; k++) {
                if (j*(k+1) > 75) break;
                dp[i+1][j*(k+1)] += dp[i][j];
            }
        }
    }
    cout << dp[d.size()][75] << endl;
    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<cstring>
#include<cmath>
#include<vector>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<climits>
#include<algorithm>
#include<functional>
#include<iomanip>
#define LL long long
using namespace std;

int T,a[15];

int main(void){
    scanf("%d",&T);
    while(T--){
        int i;
        for(i=1;i<=10;i++) scanf("%d",&a[i]);
        bool can=true;
        int l=0,r=0;
        for(i=1;i<=10;i++){
            if(a[i]<l && a[i]<r){
                can=false;
                break;
            }
            if(l<r){
                if(a[i]>r) r=a[i];
                else l=a[i];
            }
            else{
                if(a[i]>l) l=a[i];
                else r=a[i];
            }
        }
        if(can) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}



Measured memory_bytes: 3016
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		sc.close();

		int ans=1000;
		int len = t.length();

		String[] arrayT = t.split("");
		for(int i=0;i<=s.length()-len;i++) {
			int tmp = 0;
			String str = s.substring(i, i+len);
			String[] arrayS = str.split("");
			for(int j=0;j<len;j++) {
				if(!arrayS[j].equals(arrayT[j])) {
					tmp++;
				}
			}
			ans = Math.min(tmp, ans);

		}

		System.out.println(ans);

	}
}


Measured memory_bytes: 55544
import Control.Monad
main = do
  n_in <- getLine
  let n = (read :: String -> Int) n_in
  call n 1 1
  
  where
    call :: Int -> Int -> Int -> IO ()
    call n i x = do
      if i`mod`3==0 then f1 i
      else if i`mod`10==3 then f1 i
      else f2 i x
      
      if i<n then call n (i+1) (i+1)
      else putStrLn ""
      
    f1 i = do
      --putStr " CHECK_NUM"
      putStr $ (" " ++ show i)
    f2 i x = 
      if i`div`10>0 && x`mod`10==3 then f1 i
      else if i`div`10>0 && x`div`10>0 then f2 i (x`div`10)
      else return ()


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

int main()
{
	int n; cin >> n;
	
	vector<string> s;
	vector<long long> num(5,0);

	for (int i = 0; i < n; i++) {		
		
		string tmp_s;
		cin >> tmp_s;
		if (tmp_s.at(0) == 'M' || tmp_s.at(0) == 'A' || tmp_s.at(0) == 'R' || tmp_s.at(0) == 'C' || tmp_s.at(0) == 'H') {
	
			s.push_back(tmp_s);

			if (tmp_s.at(0) == 'M') num[0]++;
			else if (tmp_s.at(0) == 'A') num[1]++;
			else if (tmp_s.at(0) == 'R') num[2]++;
			else if (tmp_s.at(0) == 'C') num[3]++;
			else if (tmp_s.at(0) == 'H') num[4]++;
		
		}
	
	}
	
	long long ans = 0;

	ans += num[0] * num[1] * num[2] * 1      * 1;
	ans += num[0] * num[1] * 1      * num[3] * 1;
	ans += num[0] * 1      * num[2] * num[3] * 1;
	ans += 1      * num[1] * num[2] * num[3] * 1;
	ans += num[0] * num[1] * 1      * 1      * num[4];
	ans += num[0] * 1      * num[2] * 1      * num[4];
	ans += 1      * num[1] * num[2] * 1      * num[4];
	ans += num[0] * 1      * 1      * num[3] * num[4];
	ans += 1      * num[1] * 1      * num[3] * num[4];
	ans += 1      * 1      * num[2] * num[3] * num[4];
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5748
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

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

	bool app[26]; // true/falseの配列を用意する

	for (int i = 0; i < 26; ++i) { // falseで初期化する
		app[i] = false;
	}

	for (int i = 0; S[i] != '\0'; ++i) { // 文字列で値があればtrueにする
		app[S[i] - 'a'] = true;
	}

	for (int i = 0; i < 26; ++i) { // 値のない最小の文字を出力する
		if (!app[i]) {
			printf("%c\n", (char)(i + 'a'));
			return 0;
		}
	}

	puts("None");
	return 0;
}



Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
int H, W, K;
ll dpw[10];
ll dpx[110][10];
const ll P = 1e9+7;

int main(){
	cin >> H >> W >> K;

	dpw[0] = 1;
	dpw[1] = 2;
	for(int i=2; i<=W; i++) dpw[i] = dpw[i-2]+dpw[i-1];
	//for(int i=0; i<=W; i++) cout << dpw[i] << endl;
	//
	
	dpx[0][0] = 1;
	for(int h=1; h<=H; h++){
		for(int k=0; k<W; k++){
			dpx[h][k] += dpx[h-1][k] * (k-1>=0?dpw[k-1]:1) * (W-k-2>=0?dpw[W-k-2]:1);
			if(k>0) dpx[h][k] += dpx[h-1][k-1] * (k-2>=0?dpw[k-2]:1) * (W-k-2>=0?dpw[W-k-2]:1);
			if(k<W-1) dpx[h][k] += dpx[h-1][k+1] * (k-1>=0?dpw[k-1]:1) * (W-k-3>=0?dpw[W-k-3]:1);
			dpx[h][k] %= P;
			//cout << h << " " << k << " " << dpx[h][k] << endl;
		}
	}

	cout << dpx[H][K-1] << endl;

	return 0;
}


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

const int MAXN = 105;
int a[MAXN];
int n;
int x[MAXN], y[MAXN], tot = 0;

int main()
{
	scanf("%d", &n);
	int maxp = -1, minp = -1;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		if (maxp == -1 || a[i] > a[maxp]) maxp = i;
		if (minp == -1 || a[i] < a[minp]) minp = i;
	}
	// cerr << maxp << " " << minp << endl;
	if (a[maxp]+a[minp] >= 0) {
		for (int i = 1; i <= n; i++) {
			if (i != maxp) ++tot, x[tot] = maxp, y[tot] = i;
		}
		for (int i = 1; i < n; i++)
			++tot, x[tot] = i, y[tot] = i+1;
	} else {
		for (int i = 1; i <= n; i++) {
			if (i != minp) ++tot, x[tot] = minp, y[tot] = i;
		}
		for (int i = n-1; i >= 1; i--)
			++tot, x[tot] = i+1, y[tot] = i;
	}
	cout << tot << endl;
	for (int i = 1; i <= tot; i++) {
		cout << x[i] << " " << y[i] << endl;
		a[y[i]] += a[x[i]];
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007

const int MAX = 3000;
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;
}


int main() {
  int N, K;
  cin >> N >> K;
  COMinit();

  for (int i = 1; i <= K; i++) {
    ll x = (COM(N - K + 1, i) * COM(K - 1, i - 1)) % MOD;
    cout << x << endl;
  }


}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll L, R, D;
    cin >> L >> R >> D;
    ll ans = 0;
    FOR(i, R + 1, L) {
        if (i % D == 0)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner;
 
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    int train_fee = n * a;
    if(train_fee > b){
      System.out.println(b);
    }else if(b > train_fee){
      System.out.println(train_fee);
    }else if(b == train_fee){
      System.out.println(b);
    }
  }
}

Measured memory_bytes: 23892
def main():
    S = input()
    N = len(S)
    dp = [[0]*13 for i in range(N+1)]

    mod = 10**9 + 7
    dp[0][0] = 1
    for i, x in enumerate(S):
        for j in range(13):
            if x != '?':
                x = int(x)
                k = j*10 + x
                dp[i+1][k % 13] += dp[i][j]
                dp[i+1][k % 13] %= mod
            else:
                for k in range(10):
                    dp[i+1][(j*10+k) % 13] += dp[i][j]
                    dp[i+1][(j*10+k) % 13] %= mod
    print(dp[-1][5])


main()


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

using namespace std;

long long inf=1000000007;

int main(){
	string s;
	cin>>s;
	char now=s.at(0);
	int cnt=1;

	for(int i=1;i<s.size();i++){
		if(now!=s.at(i)) cnt++;
		now=s.at(i);
	}

	cout<<cnt-1<<endl;

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  string a;
  cin >> a;
 
  cout << (a[0]==a[2]? "Yes":"No") << endl;
  
}



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

int main() {
    
    int h, w; cin >> h >> w;
    const int n = 10;
    vector<vector<int>> d(n, vector<int>(n));    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> d[i][j];
        }
    }
    for (int k = 0; k < n; k++) {       // 経由する頂点
        for (int i = 0; i < n; i++) {    // 始点
            for (int j = 0; j < n; j++) {  // 終点
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]); // k を経由する場合と経由しない場合を(すべてのkについて)比較
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int a; cin >> a;
            if (a == -1) continue;
            ans += d[a][1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    # S = [x for x in sys.stdin.readline().split()][0]  # 文字列 一つ
    # N = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ
    X, Y = [int(x) for x in sys.stdin.readline().split()]  # 複数int
    # h_list = [int(x) for x in sys.stdin.readline().split()]  # 複数int

    # grid = [list(sys.stdin.readline().split()[0]) for _ in range(N)]  # 文字列grid
    # v_list = [int(sys.stdin.readline().split()[0]) for _ in range(N)]
    # grid = [[int(x) for x in sys.stdin.readline().split()]
    #         for _ in range(N)]  # int grid

    logger.debug('{}'.format([]))

    if Y % 2 == 0 and (Y / 2 - X) >= 0 and (2 * X - Y / 2) >= 0:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 8"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2 100"""
        output = """No"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1 2"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """0 0"""
        output = """Yes"""
        self.assertIO(input, output)


Measured memory_bytes: 16336
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
 
ll i,j,k,l,ii,jj;
ll n,m,q;
ll a[300005],b[300005],c[300005];
ll x,y,look,ans=INF,num;
bool flag;
char s[300005];
ll e,w,ee,ww;


int main(){
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	look=1;
	ans=0;
	x=0;
	y=0;
	num=0;
	while(true){
		if(x==y){
			num += a[x];
			y++;
		}else if(num + a[y] == (num | a[y])){
			ans += y-x;
			num += a[y];
			y++;
		}else{
			num -= a[x];
			x++;
		}
		if(y==n)break;
	}
	p(ans+n);
	return 0;
}


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

if x >= 400 and x <= 599:
  print(8)
elif x >= 600 and x <= 799:
  print(7)
elif x >= 800 and x <= 999:
  print(6)
elif x >= 1000 and x <= 1199:
  print(5)
elif x >= 1200 and x <= 1399:
  print(4)
elif x >= 1400 and x <= 1599:
  print(3)
elif x >= 1600 and x <= 1799:
  print(2)
else:
  print(1)

Measured memory_bytes: 9188
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define S 800005
#define M 1000000007
#define nl cout<<"\n";
#define er  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (lli)(x.size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define Y cout<<"YES\n";
#define N cout<<"NO\n";
#define print(x)                 cout<<#x<<": "<<x<<endl;
#define print2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl;
#define print3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define print4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define print5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define print6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;


void solve()
{

   lli a,b,c,d;
   cin>>a>>b;
   cin>>c>>d;
   lli ans=max({a*c,a*d,b*c,b*d});
   cout<<ans;





}



int main()
{
    fast
    #ifndef ONLINE_JUDGE
     freopen("inputa.txt", "r", stdin);
     freopen("outputa.txt", "w", stdout);
    #endif
     // test
     {
        solve();
        nl
     }
    
}
//a+b=a?b+2?(a&b)
//__builtin_popcnt(number)
//cout<<fixed<<setprecision(8)<<output<<"\n";

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	
	while (cin >> n, n){
		int mi = 500, ma = 0;
		for (int i = 0; i < n; i++){
			int sum = 0;
			for (int j = 0; j < 5; j++){
				int sco;
				cin >> sco;
				sum += sco;
			}
			mi = min(sum, mi);
			ma = max(sum, ma);
		}
		cout << ma << ' ' << mi << endl;
	}
	return (0);
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
int main(){
  int n,d,x;
  cin>>n>>d>>x;
  d--;
  int sum=0;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=(d/a[i]+1);
  }
  sum+=x;
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256