akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;

using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;//昇順

//A 65
//a 97
//pairの比較関数(昇順)
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
//降順
bool compare_by_b_high(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
  int K,X;cin>>K>>X;
  for(int i= -100000;i<1000001;i++){
    if(abs(X-i)<K){
      cout<<i<<endl;
    }else{
      continue;
    }
  }
}


Measured memory_bytes: 256
n=int(input())
f=[]
w=[0,0,0,0,0]
for i in range(2,n+1):
    c=0
    r=int(i**0.5)
    for j in range(2,r+2):
        while i%j==0:
            c+=1
            i=i//j
        if c!=0:
            f.append([j,c])
            c=0
    if i!=1:
        f.append([i,1])
f.sort()
d=[]
ans=0
if n!=1:
    cou=f[0][1]
    for i in range(1,len(f)):
        if f[i][0]==f[i-1][0]:
            cou+=f[i][1]
        else:
            d.append(cou)
            cou=1
    d.append(cou)

    for i in d:
        for j,num in enumerate([2,4,14,24,74]):
            if i>=num:
                w[j]+=1
    ans=w[4]+w[3]*(w[0]-1)+w[2]*(w[1]-1)+w[1]*(w[1]-1)*(w[0]-2)//2
print(ans)

Measured memory_bytes: 3064
import sys
from itertools import accumulate
N, M, Q = map(int, sys.stdin.readline().split())
 
LR = [[0 for _ in range(N-i)] for i in range(N)]
for i in range(M):
  L, R = map(int, sys.stdin.readline().split())
  LR[L-1][R-L] += 1
 
for i in range(N-2,-1,-1):
  for j, acc in enumerate(accumulate(LR[i])):
    LR[i][j] = acc + LR[i+1][j-1]
  LR[i][0] -= LR[i+1][-1]
 
for i in range(Q):
  p, q = map(int, sys.stdin.readline().split())
  sys.stdout.write(str(LR[p-1][q-p])+"\n")

Measured memory_bytes: 8684
d = int(input())
cl = list(map(int, input().split()))
sl = []
for _ in range(d):
    sl.append(list(map(int, input().split())))

tl = []
# for _ in range(d):
#     tl.append(int(input()))

last_di = [-1]*26
ans = 0
for day in range(d):
    # if day <= 100:
    #     coef = 1.0*day/36.0 + 3.0
    # else:
    #     coef = 10.0 - 1.0*day/36.0 + 3.0
    coef = 6.0 - day/500.0
    best_t = 0
    best_t_val = -999999999999
    for t in range(26):
        curr_val = sl[day][t]*1
        for i in range(26):
            if i == t: continue
            curr_val -= (day-last_di[i])*cl[i]*coef
        if curr_val >= best_t_val:
            best_t = t
            best_t_val = curr_val
    tl.append(best_t+1)
    last_di[best_t] = day
    ans += best_t_val
    # print(ans)
    # print('-- {}---'.format(day))
    # print(best_t)
    # print(last_di)

for t in tl:
    print(t)

# for day, t in enumerate(tl):
#     ans += sl[day][t-1]
#     last_di[t-1] = day
#     for ld, c in zip(last_di, cl):
#         # if ld == -1: continue
#         ans -= (day-ld)*c
#     print(ans)

Measured memory_bytes: 9256
#include<stdio.h>
int main(void){
    int w,h,n;
    int X[1000],Y[1000];
    int i,j,k;
    int ans,min,difx,dify;

    scanf("%d%d%d",&w,&h,&n);
    scanf("%d%d",&X[0],&Y[0]);

    ans=0;
    for(i=1;i<n;i++){
	scanf("%d%d",&X[i],&Y[i]);
	if(X[i]-X[i-1]>0 && Y[i]-Y[i-1]>0){
	    difx=X[i]-X[i-1];
	    dify=Y[i]-Y[i-1];
	    if(difx>dify) ans+=difx;
	    else ans+=dify;
	}else if(X[i]-X[i-1]<0 && Y[i]-Y[i-1]<0){
	    difx=X[i-1]-X[i];
	    dify=Y[i-1]-Y[i];
	    if(difx>dify) ans+=difx;
	    else ans+=dify;
	}else{
	    if(X[i]>X[i-1]) ans+=X[i]-X[i-1];
	    else ans+=X[i-1]-X[i];
	    if(Y[i]>Y[i-1]) ans+=Y[i]-Y[i-1];
	    else ans+=Y[i-1]-Y[i];
	}
    }

    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
char s[100010];
int d[30];
int main()
{

    scanf("%s", s);
    int n = strlen(s);
    for (int i = 0; i < n; i++) {
        d[s[i] - 'a'] = 1;
    }
    for (int i = 0; i < 26; i++) {
        if (d[i] == 0) {
            printf("%c\n", i + 'a');
            return 0;
        }
    }
    puts("None");
    return 0;
}


Measured memory_bytes: 384
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		String str = sc.next();
		int q = sc.nextInt();
		
		for(int i = 0; i < q; i++){
			String cmd = sc.next();
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			if(cmd.equals("print")){
				System.out.println(str.substring(a, b+1));
				continue;
			}

			if(cmd.equals("reverse")){
				String s1 = "";
				if(a >= 1) s1 = str.substring(0, a);
				String s2 = new StringBuilder(str.substring(a, b+1)).reverse().toString();
				String s3 = "";
				if(b <= str.length() - 2) s3 = str.substring(b+1, str.length());
				str = s1 + s2 + s3;
				continue;
			}

			if(cmd.equals("replace")){
				String p = sc.next();
				str = new StringBuilder(str).replace(a, b+1, p).toString();
				continue;
			}
		}
	}
}


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

#define ll long long
#define ld long double
#define COIN const int
#define ite iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define sz(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/

using namespace std;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ll k,n,m=1,i; cin >>n >>k;
	for (i=1;;i++) {
		m*=k;
		if (m>n) {
			cout <<i; return 0;
		}
	}
}
/******************************************************************************
******************************************************************************/


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

int main(){
    char T[200001];
    cin >> T;

    long int len;
    len = strlen(T);

    for(int i = 0; i <= len; i++){
        if(T[i] == '?'){
            if(T[i-1] == 'P'){
                T[i] = 'D';
            }else if(T[i+1] == 'D'){
                T[i] = 'P';
            }else{
                T[i] = 'D';
            }
        }
    }
    cout << T;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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;
}

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll X, Y;
  cin >> X >> Y;

  rep(i, 200) {
    ll x = i;
    ll y = X - i;
    if (x < 0 || y < 0) {
      continue;
    }

    if (x + y == X && x * 2 + y * 4 == Y) {
      COUT("Yes");
      return 0;
    }
  }

  COUT("No");
  return 0;
}

Measured memory_bytes: 3596
#include <cstdio>
using namespace std;
int N, ans;
int main() {
  scanf("%d", &N);
  int cnt = 0;
  for(int i = 0, a; i < N; ++i) {
    scanf("%d", &a);
    if(cnt+1 == a) ++cnt;
  }
  printf("%d\n", cnt==0?-1:N-cnt);
}

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

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> v(n), a(n+1);
	for (int i = 0; i < n; i++) cin >> v[i];
	while (k--)
	{
		for (int i = 0; i < n; i++)
		{
			a[max(0, i - v[i])]++;
			a[min(n, i + v[i]+1)]--;
		}
		for (int i = 1; i < n; i++)
		{
			a[i] += a[i - 1];
		}
		for (int i = 0; i < n; i++) v[i] = a[i];
		for (int i = 0; i < n+1; i++) a[i] = 0;
		int flag = 0;
		for (int i = 0; i < n; i++)
		{
			if (v[i] != n)
			{
				flag = 1;
				break;
			}
		}
		if (flag == 0) break;
	}
	for (int i = 0; i < n; i++)
	{
		cout << v[i] << ' ';
	}

	return 0;
}

Measured memory_bytes: 4788
let () =
    let main () =
        let n = int_of_string (read_line ()) in
        let s = read_line () ^ "$" in
        let rec loop i prev acc =
            if i > n then acc else loop (i + 1) s.[i] (acc + if prev = s.[i] then 0 else 1)
        in
        Printf.printf "%d\n" (loop 1 s.[0] 0)
    in
    main ()

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

using namespace std;

#define MAX 1000100
#define LIM 1010

bool composite[MAX + 100];
int prime[MAX + 100];

void sieve()
{
    for(int i = 2; i <= LIM; i++){
        for(int j = i * i; j <= MAX; j += i)
            composite[j] = true;
    }
    int counter = 0;
    for(int i = 2; i <= MAX; i++){
        if(!composite[i]) counter += 1;
        prime[i] = counter;
    }
}

int main()
{
    sieve();
    int n;
    while(cin >> n){
        cout << prime[n] << "\n";
    }
}

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

int main(void)
{
  int n;
  int b[4] = {0};
  cin >> n;
  string a;
  for(int i=0;i<n;i++){
    cin >> a;
    if(a=="AC") b[0]++;
    else if(a=="WA") b[1]++;
    else if(a=="TLE") b[2]++;
    else if(a=="RE") b[3]++;
  }
  
  cout << "AC x " << b[0] << endl;
  cout << "WA x " << b[1] << endl;
  cout << "TLE x " << b[2] << endl;
  cout << "RE x " << b[3] << endl;

  return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
priority_queue<int> Q;
int N,M;
int main()
{
    // freopen("in.txt","r",stdin);
    scanf("%d %d",&N,&M);
    for(int i=1;i<=N;i+=1)
    {
        int x;scanf("%d",&x);Q.push(x);
    }
    for(int i=1;i<=M;i+=1)
    {
        int x=Q.top();Q.pop();Q.push(x>>1);
    }
    long long Ans=0;
    while(!Q.empty())
    {
        Ans+=Q.top();Q.pop();
    }
    printf("%lld",Ans);
    return 0;
}

Measured memory_bytes: 892
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	N := nextInt()
	var fs = make([][]int, N)
	for i := 0; i  < N; i++ {
		fs[i] = make([]int, 10)
		for j := 0; j < 10; j++ {
			fs[i][j] = nextInt()
		}
	}

	var ps = make([][]int, N)
	for i := 0; i  < N; i++ {
		ps[i] = make([]int, 11)
		for j := 0; j < 11; j++ {
			ps[i][j] = nextInt()
		}
	}

	max := math.MinInt64
	for i := 1; i < 1 << 10; i++ {
		c := 0

		for j := 0; j < N; j++ {
			op := 0
			for k := 0; k < 10; k++ {
				if (i >> uint(k)) & 1 == 1 {
					op += fs[j][k]
				}
			}
			c += ps[j][op]
		}

		if max < c {
			max = c
		}
	}

	fmt.Println(max)
}


Measured memory_bytes: 640
#include <iostream>

int main()
{
	uint16_t x, y;
	std::cin >> x >> y;

	if (y % 2 != 0)
	{
		std::cout << "No" << std::endl;
		return 0;
	}

	uint16_t tmp(y - x * 2);
	if (tmp < 0 || tmp / 2 > x)
		std::cout << "No" << std::endl;
	else
		std::cout << "Yes" << std::endl;
	return 0;
}

Measured memory_bytes: 3540
#include <iostream>
#include <cstdio>
#define N 100000
using namespace std;
int n, mx[2], mi[2], ans=1e9, a[2][N+5];
int main() {
	int i, j, t;
	cin>>n;
	for(i=0; i<n; i++) scanf("%d", &t), a[i%2][t]++;
	for(i=0; i<2; i++) for(j=1; j<=N; j++) {
		if(a[i][j] > mx[i]) mx[i] = a[i][j], mi[i] = j;
	}
	if(mi[0] != mi[1]) ans = n - mx[0] - mx[1];
	else {
		for(i=0; i<2; i++) for(j=1; j<=N; j++) {
			if(j == mi[0]) continue;
			ans = min(ans, n - mx[i] - a[1-i][j]);
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n,c,res=0;
  cin>>n;
  if(n==1){
    cin>>c;
    cout<<c;
    return 0;
  }
  map<int,int> d;
  vector<int> t,ind;
  ++d[0];
  for(int i=0;i<n;++i){
    cin>>c;
    ++d[c];
  }
  for(auto p:d){
    if(p.second>2)return cout<<0,0;
    if(p.second==2){
      t.push_back(p.first);
      t.push_back(24-p.first);
    }
    if(p.second==1)ind.push_back(p.first);
  }
  for(int bit=0;bit<(1<<ind.size());++bit){
    vector<int> s(t);
    for(int i=0;i<ind.size();++i){
      if(bit>>i&1)s.push_back(24-ind[i]);
      else s.push_back(ind[i]);
    }
    sort(s.begin(),s.end());
    s.push_back(s[0]+24);
    int dif=24;
    for(int i=0;i<s.size()-1;++i)dif=min(dif,s[i+1]-s[i]);
    res=max(res,dif%24);
  }
  cout<<res;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	char[] s = sc.next().toCharArray();
      	if(s[2]==s[3] && s[4]==s[5]) System.out.println("Yes");
      	else System.out.println("No");
    }
}

Measured memory_bytes: 35520
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] a = new int[n];
      for(int i = 0; i < n; i++)
        a[i] = sc.nextInt();

      int[] b = new int[n];
      for(int i = 0; i < n; i++)
        b[i] = sc.nextInt();

      long smallCnt = 0;
      long greaterCnt = 0;
      for(int i = 0; i < n; i++) {
        if(a[i] == b[i]) continue;
        if(a[i] < b[i])
          greaterCnt += (b[i] - a[i]) / 2;
        else
          smallCnt += a[i] - b[i];
      }
      System.out.println(greaterCnt >= smallCnt ? "Yes" : "No");
  }
}

Measured memory_bytes: 43684
N, K = map(int, input().split())
L = [[0, 0] for _ in range(N)]
for i in range(N):
  a, b = map(int, input().split())
  L[i] = [a, b]
L.sort()
cnt = 0
for l in L:
  cnt += l[1]
  if cnt >= K:
    print(l[0])
    break

Measured memory_bytes: 20036
#include <iostream>
using namespace std;
int main(){
    int n;cin>>n;
    int a[n];
    for(int i = 0; n > i; i++){
        cin>>a[i];
        cout << a[i];
        if(i+1!=n)cout << " ";
    }
    cout << endl;
    for(int i = 1; n > i; i++){
        int v = a[i];
        int j = i-1;
        while(j >= 0 && a[j] > v){
          a[j+1]=a[j];
          j--;
        }
        a[j+1]=v;
        for(int j = 0; n > j; j++){
          cout << a[j];
          if(j+1!=n)cout << " ";
        }
        cout << endl;
    }
}



Measured memory_bytes: 3080
N = int(input())
prime_list = [0] * (N+1)
cnt=0
for i in range(2, N + 1):
    cnt = 2
    copy=i
    while (cnt ** 2 <= copy):
        if (copy % cnt == 0):
            prime_list[cnt] += 1
            copy = int(copy / cnt)
            
        else:
            cnt += 1
    prime_list[copy] += 1
#ここまではok??　nまでの素因数を格納していく感じ!
cnt3 = 0
cnt5 = 0
cnt15 = 0
cnt25 = 0
cnt75 = 0
for i in range(1, N + 1):
    if (prime_list[i] >= 2):
        cnt3 += 1
    if (prime_list[i] >= 4):
        cnt5 += 1
    if (prime_list[i] >= 14):
        cnt15 += 1
    if (prime_list[i] >= 24):
        cnt25 += 1
    if (prime_list[i] >= 74):
        cnt75 += 1
#ここでは75=3*5*5だから各素因数が何個あるか取り出したいよね。これを必要なところだけ取っていく

#print(cnt75+ cnt25*(cnt3-1)+cnt15*(cnt5-1)+int((cnt5-1)*cnt5/2)*(cnt3-2))       
#こういうことなんだけど一つ一つ説明します笑

a = cnt75
#これはx^74となる数のこと
b = cnt25 * (cnt3 - 1)
#これはx^24*y^3となる数のことなんだけでcnt3にはxも含まれてるよね(というのも上で>=のかたちで数えてるから)
# だから自分の分を引かなきゃだめーって感じ!!
c=cnt15*(cnt5-1)
#これもおなじだよね、うん、、笑
d = int((cnt5-1)*cnt5/2)*(cnt3-2)
#ここも同じなんだけどまずx^5*y^5*z^2の形がほしいんだからcnt5の中から2つ欲しい、つまりnC2の関係を使ってもとめる、このあとz^2はcnt2のなかから取るんだけど
#この中には当然x,yがはいってるからその分の2を引いたものをかける感じ！！　これらをすべて足せばok!!笑

print(a+b+c+d)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ll long long
#define all(a) a.begin(),a.end()
#define endl '\n'
#define y1 y123123
#define int ll

using namespace std;

const int N = 1e5 + 3;
const int inf = 1e9 + 3;
const int md = 1e9 + 7;

string s, t;
int ans, last, n, m;
int nxt[N][26];

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

    cin >> s >> t;
    n = s.size();
    m = t.size();
    for(int i = 0; i < 26; ++i){
        nxt[n][i] = n;
    }
    for(int i = n - 1; i >= 0; i--){
        for(int j = 0; j < 26; ++j)
            nxt[i][j] = nxt[i + 1][j];
        nxt[i][s[i] - 'a'] = i;
    }

    for(int i = 0; i < t.size(); ++i){
        int z = t[i] - 'a';
        if(nxt[last][z] == n){
            ans += s.size();
            last = 0;
        }
        if(nxt[last][z] == n){
            cout << -1;
            return 0;
        }
        last = nxt[last][z] + 1;
    }

    cout << ans + last;
}


Measured memory_bytes: 20944
#include <iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include <queue>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
const ll MOD = 1000000007;

    ll ans=1,temp=0,count=0,N,A,B;
    ll X[10010]={0},num[10100]={0};
int main(){
  scanf("%lld\n",&N );
  REP(i,10010){X[i]=0;num[i]=0;}

  for(int i = 2; i <= N; i++){
    for(int j = 0; j < 500; j++){
      if(X[j] == 0){
        X[j] = i;
      }
  //    cout<<X[j]<<":"<<j<<endl;
      if(i % X[j]==0){
        break;
      }
    }
  }
  for(int i = 2; i <= N; i++){
    int n = i;
    do {
      for(int j = 0; j < 500; j++){
          if(n % X[j]==0){

              num[j]++;
              n /= X[j];
              break;
          }
        }
    } while(n != 1);
  }
  REP(i,500){

    ans = (ans * (num[i]+1)) % 1000000007;
  }
  cout<<ans;
}


Measured memory_bytes: 384
l = list(map(int, input().split()))

a = l[0]
b = l[1]
counter = 0

for i in range(a, b+1):
	word = str(i)
	d = len(word)

	left = word[:d//2]
	right = word[-(d//2):]
	right_r = right[::-1]
	if left == right_r:
		counter += 1
	
print(counter)
		

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)
ll n,x,t,y,z,w[101],v[101];
map<ii,ll> m;

ll dp(ll i, ll j){
    if(j>x)return -1*LLMAX;
    if(i==n)return 0;
    ii p = mp(i,j);
    if(m.count(p)){
        return(m[p]);
    }
    return m[p] = max(dp(i+1,j),dp(i+1,j+w[i])+v[i]);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>x;
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
    }
    cout<<dp(0,0);
    

    return 0;
}

Measured memory_bytes: 6272
import numpy as np

#f = open('./input_B.txt')
#
#N = int(f.readline())
#A = list(map(int, f.readline().split()))

N = int(input())
A = list(map(int, input().split()))

if min(A)==0:
    ans=0
else:
    i = 0
    ans = 1
    for i in range(N):
        ans = ans*A[i]
        if ans > 10**18:
            ans = -1
            break
print(ans)

Measured memory_bytes: 40152
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define Vecpr vector<pair<lli,lli>>
int main() {
  lli A,B,C,D;
  string a,b,c;
  cin >>A>>B>>C;
  A=100*A+10*B+C;
  if(A%4==0)Out("YES");
  else Out("NO");
}


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

long long dp[101][100001];

int main(){
    long long N,W;
    cin>>N>>W;
    long long w[N+1];
    long long v[N+1];
    long long V=100001;
    w[0]=0, v[0]=0;
    for(long long i=1;i<=N;++i){
        cin>>w[i]>>v[i];
    }

    for(long long i=0;i<=N;++i){
        for(long long j=0;j<=V;++j){
            dp[i][j]=1000000001;
        }
    }

    for(long long j=1;j<=V;++j){
      if(v[1]>=j){
        dp[1][j]=w[1];
      }
    }

    for(long long i=2;i<=N;++i){
        for(long long j=1;j<=V;++j){
         //if(j>v[i]){
           // dp[i][j]=dp[i-1][j];
         //}else{
           if(j-v[i]<1) dp[i][j]=min(dp[i-1][j],w[i]);
           else dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
         //}
        }

    }


    long long ans=0;
    for(int j=1;j<=V;++j){
      if(dp[N][j]<=W) ans=j;

    }


    cout<<ans<<endl;
}


Measured memory_bytes: 82476
import java.util.*;

public class Main{
    
    public static Scanner sc;
    
    public static void main(String[] args){
        sc = new Scanner(System.in);
        
        final int INF = 1_000_000_000;
        
        int n = sc.nextInt();
        long c = sc.nextLong();
        long[] x = new long[n];
        long[] v = new long[n];
        
        for(int i=0; i<n; i++){
            x[i] = sc.nextLong();
            v[i] = sc.nextLong();
        }
        
        long sum1 = 0;
        long sum2 = 0;
        long[] dp1 = new long[n+1];
        long[] dp2 = new long[n+1];
        
        for(int i=0; i<n; i++){
            sum1 += v[i];
            dp1[i+1] =  sum1 - x[i];
            dp1[i+1] = Math.max(dp1[i], dp1[i+1]);
            
            sum2 += v[n-i-1];
            dp2[i+1] = sum2 - (c - x[n-i-1]);
            dp2[i+1] = Math.max(dp2[i], dp2[i+1]);
        }
        
        long ans = 0;
        
        for(int i=0; i<n; i++){
            long a1 = Math.max(dp1[i+1], dp1[i+1] - x[i] + dp2[n-i-1]);
            long a2 = Math.max(dp2[i+1], dp2[i+1] - (c-x[n-i-1]) + dp1[n-i-1]);
            long aa = Math.max(a1, a2);
            ans = Math.max(ans, aa);
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 96300
#include <bits/stdc++.h>
using namespace std;
int main(){
  int k,a,b;
  cin >> k;
  cin >> a>>b;
  int i,f=0;
  for(i=a;i<=b;i++){
    if(i%k==0){
      cout << "OK\n";
      f=1;
      break;
    }
  }
  if(!f)
    cout << "NG\n";
  return 0;}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long

int main(){
    int n,p[110];
    string s[110];
    cin>>n;
    rep(i,n) cin>>s[i]>>p[i];
    tuple <string,int,int> P[110];
    rep(i,n) P[i]=make_tuple(s[i],100-p[i],i);
    sort(P,P+n);
    rep(i,n){
        int& k=get<2>(P[i]);
        cout<<k+1<<endl;
    }
}

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




    int main(){
        
        int n, k;
        std::cin >> n >> k;
        int cnt = 0;
        rep(i, n){
            int h;
            std::cin >> h;
            if (h >= k)
            {
                cnt++;
            }
        }
        std::cout << cnt << "\n";
        return 0;
    }


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

int main() {
    int a, b, c, t;
    cin >> a >> b >> c;
    if (a > b) {
        t = a;
        a = b;
        b = t;
    }
    if (b > c) {
        t = b;
        b = c;
        c = t;
    }
    if (a > b) {
        t = a;
        a = b;
        b = t;
    }
    cout << a << ' ' << b << ' ' << c << endl;
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <map>
#include <algorithm> 
#include <vector> 
#include <string.h> 
#include <math.h> 
#include <stdio.h> 
#include <stdlib.h> 
#include <chrono> 
#include <thread> 
#include <iomanip>
#include <typeinfo>
 
//define
#define trav(i,v)   for(auto i: v)
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define all(v)  v.begin(), v.end()
#define itn int 

//typedef
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const long long MOD = 1000000007;
// const long long MOD = 998244353;
const long long inf = 1000000000000000000;
 
using namespace std;

int n, q, n1;

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll power(ll x, ll n)
{
    ll res=1;
    while(n>0){
        if(n&1) res=res*x;
        x=x*x;
        n>>=1;
    }
    return res;
}

bool compare(pair<pii,int> p1, pair<pii,int> p2)
{
    if(p1.fi.fi/n1==p2.fi.fi/n1)
        return p1.fi.se<p2.fi.se;
    return p1.fi.fi<p2.fi.fi;
}

void solve()
{
    cin>>n>>q;
    vi c(n+1);
    n1=sqrt(n);
    repu(i,0,n-1)
    {
        cin>>c[i];
    }
    vector<pair<pii,int>> v;
    int l, r;
    rep(i,q)
    {
        cin>>l>>r;
        l--;
        r--;
        v.pb(mp(mp(l,r),i));
    }
    vi anss(q);
    sort(all(v),compare);
    int ans=0;
    vi v1(n+2,0);
    repu(i,v[0].fi.fi,v[0].fi.se)
    {
        v1[c[i]]++;
        if(v1[c[i]]==1)
            ans++;
    }
    l=v[0].fi.fi;
    r=v[0].fi.se;
    // cout<<l<<" "<<r<<" "<<ans<<endl;
    anss[v[0].se]=ans;
    repu(i,1,q-1)
    {
        int l1=v[i].fi.fi, r1=v[i].fi.se;
        if(l1<l)
        {
            repu(j,l1,l-1)
            {
                v1[c[j]]++;
                if(v1[c[j]]==1)
                    ans++;
            }
        }
        if(r1>r)
        {
            repu(j,r+1,r1)
            {
                v1[c[j]]++;
                if(v1[c[j]]==1)
                    ans++;
            }
        }
        if(l1>l)
        {
            repu(j,l,l1-1)
            {
                v1[c[j]]--;
                if(v1[c[j]]==0)
                    ans--;
            }
        }
        if(r1<r)
        {
            repu(j,r1+1,r)
            {
                v1[c[j]]--;
                if(v1[c[j]]==0)
                    ans--;
            }
        }
        l=l1, r=r1;
        // cout<<l1<<" "<<r1<<" "<<ans<<endl;
        anss[v[i].se]=ans;
    }
    rep(i,q)
    cout<<anss[i]<<endl;
    return;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1, tt=1;
    // cin>>t;
    while(tt<=t)
    {
        // cout<<"Case #"<<tt<<": ";
        solve();
        tt++;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}   

Measured memory_bytes: 15452
N, M = map(int, input().split())

# 繋がってるスイッチの情報
S = [list(map(int, input().split()))[1:] for _ in range(M)]
P = list(map(int, input().split()))

# print(S)
# print(P)

ans = 0

for i in range(1 << N):
    # print(i)
    for m in range(M):
        cnt = 0
        for s in S[m]:  # Sは繋がっているスイッチの情報
            if i & (1 << (s-1)) != 0:
                cnt += 1
        if cnt % 2 != P[m]:
            break
    else:  # このelseはどういうこと
        ans += 1

print(ans)


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

long long unsigned a[1000], ans = 1;

int main() {
	int n; cin >> n;
	for (int i = 2; i <= n; i++) {
		int k = i;
		for (int j = 2; j <= k; j++) {
			while (k % j == 0) {
				a[j]++;
				k /= j;
			}
		}
	}

	for (int i = 2; i <= n; i++)ans = ans * (a[i] + 1) % 1000000007;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
r1, c1, r2, c2 = map(int, input().split())

mod = 1000000007

def pow(x, n):
    ret = 1
    while n > 0:
        if (n & 1) == 1:
            ret = (ret * x) % mod
        x = (x * x) % mod
        n //= 2
    return ret

def fac(n):
    ret = 1
    for i in range(1, n + 1):
        ret = (ret * i) % mod
    return ret

def facinv(n):
    return pow(fac(n), mod - 2)

def cmb(n, k):
    if k < 0 or k > n:
        return 0
    return ((fac(n) * facinv(k)) % mod * facinv(n - k)) % mod

def rect(r, c):
    return cmb(r + c, c)

ret = (rect(r2 + 1, c2 + 1) - rect(r1, c2 + 1) - rect(r2 + 1, c1) + rect(r1, c1) + mod + mod) % mod
print(ret)


Measured memory_bytes: 63092
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  (a, b, h, m) = InputLine.to_fa

  theta1 = h * 30.0 + m * 0.5;
  theta2 = m * 6.0;

  theta = (theta1 - theta2).abs
  theta = [theta, 360.0 - theta].min

  puts Math.sqrt(a * a + b * b - 2.0 * a * b * Math.cos((theta * Math::PI) / 180.0)).to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 14744
use proconio::fastout;
use proconio::input;
use proconio::marker::{Chars};

#[allow(dead_code)]
type Pi = (i32, i32);
#[allow(dead_code)]
fn pri<T: std::fmt::Display>(x: T) {
    println!("{}", x);
}

#[fastout]
fn main() {
    input!{
        s: Chars,
    }
    for e in s {
        if e == '7' {pri("Yes"); return}
    }
    pri("No");
}

Measured memory_bytes: 2180
#include <stdio.h>

int main(void)
{
    int n, m;
    int matrixA[100][100] = {0};
    int matrixB[100][1] = {0};
    int matrixC[100][1] = {0};
    int i, j, k;

    scanf("%d %d", &n, &m);

    for (i = 0; i < n; ++i){
        for (j = 0; j < m; ++j){
            scanf("%d ", &matrixA[i][j]);
        }
    }
    
    for (i = 0; i < m; ++i){
        scanf("%d ", &matrixB[i][0]);
    }

    for (i = 0; i < n; ++i){
        for (j = 0; j < m; ++j){
            matrixC[i][0] += matrixA[i][j] * matrixB[j][0];
        }
    }

    for (i = 0; i < n; ++i){
        printf("%d\n", matrixC[i][0]);
    }
    return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;
#define int long long
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
//cout << std::fixed << std::setprecision(15);
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e9;
const long long MOD = 1e9+7;
signed main(){
    string s; cin >> s;
    rep(i,SZ(s)) cout<<'x';
    cout<<endl;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
  string s;
  cin >> s;
  int count = 0;
  rep(i,s.size()){
    if(i%2==1){
      if(s[i]=='R'){
        cout << "No" << endl;
        return 0;
      }
    }else{
      if(s[i]=='L'){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll n;cin >>n;
    ll ans=0;
    for (int i = 0; i < n; ++i) {
        ll l,r;cin >>l>>r;
        ans+=r-l+1;
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.math.BigInteger;

public class Main {
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        long n = in.nextLong();
        long sum = 1;
        long count = 1;
        while(n>1){
            sum+=Math.pow(2,count);
            ++count;
            n/=2;
        }
        out.println(sum);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext() {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
    }
}



Measured memory_bytes: 33048
#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1);
long double a,b,x,c,ans;
int main(){
	cin>>a>>b>>x;
	if(a*a*b/2<x)c=2*b-2*x/(a*a),ans=atan(c/a)/pi*180,cout<<fixed<<setprecision(8)<<ans<<endl;
	else c=2*x/a/b,ans=atan(b/c)/pi*180,cout<<fixed<<setprecision(8)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
string word;
long long sum, i;

int main() {
    //freopen("test.in", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> word;
    sum = 0;

    for (i=0; i < word.size(); i++) {
        sum += (word[i] - '0');
        sum %= 9;
    }

    if (sum % 9 == 0) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 3752
import sys

readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))

from collections import Counter
from itertools import accumulate
import bisect

n = readint()
a = readints()
b = sorted(Counter(a).values())
exist = len(b)
b = [0]*(n-exist)+b
c = list(accumulate([0]+b))

ans = [n]
for k in range(2,exist+1):
    l = 0
    r = n//k+1
    while r-l>1:
        x = (r+l)//2
        i = bisect.bisect_left(b,x)
        if c[i]+(n-i)*x>=x*k:
            l = x
        else:
            r = x
    ans.append(l)

printrows(ans+[0]*(n-exist))

Measured memory_bytes: 126808
#include <iostream>
using namespace std;
 
int main(){
    //recieve inputs
    int N, X, T;
    cin >> N >> X >> T;
 
    //find the number of times to use the machine
    int times = (N + X - 1) / X;
 
    //find the answer
    int ans = times * T;
 
    //output the answer
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

int calc(int a) {
    if (a % 2 == 0) return a / 2;
    else return 3 * a + 1;
}

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

    int marker = s;
    vector<int> c(1000000);
    for (int i = 0; i < 1000000; ++i) {
        c.at(marker)++;
        if (c.at(marker) < 2) marker = calc(marker);
        else {
            cout << i + 1 << endl;
            break;
        }
    }
}



Measured memory_bytes: 4096
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
#include<assert.h>

typedef long long ll;
typedef unsigned long long ull;

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

int main()
{
	ll a, b;
	scanf("%lld%lld", &a, &b);
	printf("%lld", a * b / gcd(a, b));
}




Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  long H,N;cin>>H>>N;
  vector<long>A(N),B(N);
  for(long i=0;i<N;i++)cin>>A[i]>>B[i];
  vector<vector<long>>DP(N,vector<long>(H+1,LONG_MAX));
  for(long i=0;i<N;i++)DP[i][0]=0;
  //i個目までの魔法を考えた時, 体力j削ぎ落とすための最小の魔力
  
  for(long i=0;i<N;i++){
    for(long j=0;j<=H;j++){
      DP[i][j]=(B[i]*(j/A[i]+(j%A[i]!=0)));
    }
  }
  

  
  for(long i=0;i<N;i++){
    for(long j=0;j<=H;j++){
      if(i==0) continue;
      else if(j>=A[i])DP[i][j]=min(DP[i][j],min(DP[i-1][j],
                                   min((DP[i-1][j-A[i]]+B[i]>=0?DP[i-1][j-A[i]]+B[i]:LONG_MAX),
                                       (DP[i][j-A[i]]+B[i]>=0?DP[i][j-A[i]]+B[i]:LONG_MAX))));
      else DP[i][j]=min(DP[i][j],DP[i-1][j]);
      assert(DP[i][j]>=0);
    }
  }
  /*
  for(long i=0;i<N;i++){
    for(long j=0;j<=H;j++)cout<<DP[i][j]<<" ";
    cout<<endl;
  }*/
  
  
  long ans=LONG_MAX;
  
  for(long i=0;i<N;i++){
    ans=min(ans,DP[i][H]);
    //cout<<DP[i][H]<<endl;
  }
  cout<<ans;
  assert(ans>=0);
}

/*
4落とすのに



*/

Measured memory_bytes: 78464
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, q; cin >> n >> q;
  V<> a(n); for (int i = 0; i < n; ++i) cin >> a[i];
  V<lint> c(n + 1);
  for (int i = 0; i < n; ++i) c[i + 1] = c[i] + a[i];
  for (int i = 0; i < q; ++i) {
    lint x; cin >> x;
    lint res = 0;
    for (int l = 0; l < n; ++l) {
      int r = distance(begin(c), upper_bound(begin(c), end(c), c[l] + x));
      res += max(r - l - 1, 0);
    }
    cout << res << '\n';
  }
}


Measured memory_bytes: 4160
#!/usr/bin/python
from fractions import Fraction
import sys
if sys.version_info[0]>=3: raw_input=input

def gauss(a):
	if not a or len(a)==0: return None
	n=len(a)
	for i in range(n):
		if a[i][i]==0:
			for j in range(i+1,n):
				if a[j][i]!=0:
					for k in range(i,n+1): a[i][k]+=a[j][k]
					break
			else:
				return None
		for j in range(n):
			if i!=j:
				r = Fraction(a[j][i],a[i][i])
				for k in range(i,n+1): a[j][k] = a[j][k] - a[i][k]*r
	for i in range(n):
		x=Fraction(a[i][i],1)
		for j in range(len(a[i])):
			a[i][j] /= x
	return a

uaz=map(int,raw_input().split())
enemy=[0]+[-x+y for x,y in zip(map(int,raw_input().split()),uaz)]
b0=[1]+[x-y for x,y in zip(map(int,raw_input().split()),uaz)]
b1=[1]+[x-y for x,y in zip(map(int,raw_input().split()),uaz)]
b2=[1]+[x-y for x,y in zip(map(int,raw_input().split()),uaz)]
sol=gauss(list(map(list,zip(b0,b1,b2,enemy,[1,0,0,0]))))
print('MISS' if sol and all(0<=e[-1]<=1 for e in sol) else 'HIT')

Measured memory_bytes: 5912
import sys
input=lambda: sys.stdin.readline().rstrip()
n,m,q=map(int,input().split())
A=[tuple(map(int,input().split())) for _ in range(q)]
def pt(X):
  ret=0
  for a,b,c,d in A:
    if X[b-1]-X[a-1]==c:
      ret+=d
  return ret

C=[]
for i in range(m):
  C.append([i+1])

for _ in range(n-1):
  CC=[]
  for c in C:
    for next in range(c[-1],m+1):
      CC.append(c+[next])
  C=CC
ans=0
for c in C:
  ans=max(ans,pt(c))
print(ans)
  


Measured memory_bytes: 30416
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
  int a, b, ans = 0;
  cin >> a >> b;
  if(b != 1){
    ans++;
    int c = a;
    while(c < b){
      c += a - 1;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define ll long long
using namespace std;

int N;
vector<char> vector_of_chars = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'};

int num_of_char(char ch)
{
  for (int i = 0; i < N; i++)
  {
    if (ch == vector_of_chars[i])
    {
      return i;
    }
  }
  cout << "SWW" << endl;
  return 10;
}

char next_c(char ch)
{
  int num = num_of_char(ch);
  if (num >= N)
  {
    return 'z';
  }
  return vector_of_chars[num + 1];
}

// int largest_num_of_char(string str)
// {
//   int ret = 0;
//   for (int i = 0; i < str.size(); i++)
//   {
//     ret = max(ret, num_of_char(str[i]));
//   }
//   return ret;
// }

vector<int> next_vector_of_int(vector<int> vec);

// vector<int> string_to_vector_of_int(string str)
// {
//   vector<int> vec = {};
//   for (int i = 0; i < str.size(); i++)
//   {
//     vec.push_back(num_of_char(str[i]));
//   }
//   return vec;
// }

string vector_of_int_to_string(vector<int> vec)
{
  string str = "";
  for (int i = 0; i < vec.size(); i++)
  {
    str.push_back(vector_of_chars[vec[i]]);
  }
  return str;
}

// vecの0~i番目の中で最大の整数
int largest_int(vector<int> vec, int i)
{
  int ret = 0;
  for (int j = 0; j <= i; j++)
  {
    ret = max(ret, vec[j]);
  }
  return ret;
}

int main()
{
  cin >> N;
  vector_of_chars.resize(N);

  vector<int> last_vector_of_int = {};
  for (int i = 0; i < N; i++)
  {
    last_vector_of_int.push_back(i);
  }

  vector<int> vec(N, 0);

  while (vec != last_vector_of_int)
  {
    cout << vector_of_int_to_string(vec) << endl;
    vec = next_vector_of_int(vec);
  }
  cout << vector_of_int_to_string(last_vector_of_int) << endl;
  return 0;
}

vector<int> next_vector_of_int(vector<int> vec)
{
  vector<int> next_v = vec;

  while (true)
  {
    // 左からi番目(0-index)の整数を+1できるか？
    bool ok = false;
    for (int i = N - 1; i > 0; i--)
    {
      int lar = largest_int(vec, i - 1);
      if (vec[i] <= lar)
      {
        next_v[i]++;
        if (i != N - 1)
        {
          for (int j = i + 1; j < N; j++)
          {
            next_v[j] = 0;
          }
        }
        ok = true;
        break;
      }
    }
    if (ok)
    {
      break;
    }
  }

  return next_v;
}

Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

int main(){
	
	int H, W;
	
	string map[200];
	
	cin >> H >> W;
	
	for(int i = 0; i < H; i++){
		cin >> map[i];
	}
	
	for(int i = 0; i < H; i++){
		bool check = false;
		int count = 0;
		for(int j = 0; j < W; j++){
			if(map[i][j] == 'c'){
				check = true;
				count = 0;
			}else{
				count++;
			}
			if(j == W - 1){
				if(!check){
					cout << "-1";
				}else{
					cout << count;
				}
			}else{
				if(!check){
					cout << "-1 ";
				}else{
					cout << count << " ";
				}
			}
		}
		cout << endl;
	}
	
	return 0;
}

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

#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using pint = pair<int, int>;
using pstring = pair<int, string>;

int main() {
    ll sum;
    ll N;
    cin >> N;
    vector<ll> ans(10001);
    for(ll i = 0; i < N; i++) ans.at(i) = 0;

    for(ll i = 1; i*i+1+1 +i+i+1<= N; i++) {
        for (ll j = i; j*j+i*i+1 + i*j+i+j<= N; j++) {
            for (ll k = j; sum = i*i+j*j+k*k + i*j+j*k+k*i, sum <= N; k++) {
                if( i == j && i == k) ans.at(sum) += 1;
                else if (i != j && i != k && k != j) ans.at(sum) += 6;
                else ans.at(sum) += 3;
                // if(sum == 9997) 
                // cout << i << ' ' << j << ' ' << k << ' ' << sum << endl;

            }
        }
    }

    // cout << endl;
    for(ll i = 1; i <= N; i++)  cout << ans.at(i) << endl;
    return 0;
}


Measured memory_bytes: 3600
let S = readLine()!.characters.map{String($0)}
var ans = S.count
for i in 0..<2 {
    var cnt = 0
    for j in 0..<S.count {
        if (j % 2 == 0) != (S[j] == "\(i)") {
            cnt += 1
        }
    }
    ans = min(ans, cnt)
}
print(ans)

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

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

	vector<int>cnt(9,0);
	for (int i = 0; i < n; i++) {
		if (a[i] <= 399) cnt[0] = 1;
		else if (400 <= a[i] && a[i] <= 790)cnt[1] = 1;
		else if (800 <= a[i] && a[i] <= 1199)cnt[2] = 1;
		else if (1200 <= a[i] && a[i] <= 1599)cnt[3] = 1;
		else if (1600 <= a[i] && a[i] <= 1999) cnt[4] = 1;
		else if (2000 <= a[i] && a[i] <= 2399)cnt[5] = 1;
		else if (2400 <= a[i] && a[i] <= 2799) cnt[6] = 1;
		else if (2800 <= a[i] && a[i] <= 3199) cnt[7] = 1;
		else cnt[8]++;
	}
	int cntMax = 0;
	for (auto x : cnt) {
		cntMax += x;
	}
	cout << ((cntMax - cnt[8]) != 0 ? (cntMax - cnt[8]) : 1) << ' ' << cntMax << endl;

	return 0;
}

Measured memory_bytes: 256