akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;

int n, m, q;
int mp[555][555];

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

  cin >> n >> m >> q;
  for(int i=0;i<m;i++){
    int l, r;
    cin >> l >> r;
    mp[l][r]++;
  }
  
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      mp[i][j] += mp[i-1][j];  
    }
  }

  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      mp[i][j] += mp[i][j-1];
    }
  }
  
  /*
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      printf("%3d ", mp[j][i]);
    }
    printf("\n");
  }
  */

  while(q--){
    int p1, p2;
    cin >> p1 >> p2;
    cout << mp[p2][p2]-mp[p1-1][p2] << endl;
  }

  return 0;
}



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

ans = []
for i in range(L, R + 1):
    for j in range(i + 1, R + 1):
        v = i * j % 2019
        ans.append(v)
        if v == 0:
            break
    else:
        continue
    break
    
print(min(ans))

Measured memory_bytes: 6788
package main

import (
	"fmt"
	"sort"
)

func uniq(a []int) (b []int) {
	m := make(map[int]bool)
	for _, v := range a {
		m[v] = true
	}
	for k := range m {
		b = append(b, k)
	}
	return b
}

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)

	var l []int
	for i := a; i < b+1 && i < a+k; i++ {
		l = append(l, i)
	}
	for i := b - k + 1; a < i && i < b+1; i++ {
		l = append(l, i)
	}

	uniq := uniq(l)
	sort.Ints(uniq)
	for _, v := range uniq {
		fmt.Println(v)
	}
}


Measured memory_bytes: 640
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String a=sc.next();
		String b=sc.next();

		if(a.equals("H")) {
			System.out.println(b);
		}
		else {
			if(b.equals("H")) {
				System.out.println("D");
			}
			else {
				System.out.println("H");
			}
		}
	}
}

Measured memory_bytes: 22612
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main(void) {
    int n;
    cin >> n;
    int x[n];
    for (int i = 0; i < n; i++) cin >> x[i];
    int ans = 1000000;
    for (int i = 0; i < 100; i++) {
        int hp = 0;
        for (int j = 0; j < n; j++) hp += pow((x[j] - i), 2);
        ans = min(ans, hp);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
def nabe(num)
  if num % 3 == 0
    num
  elsif num.to_s =~ /3/
    num
  else
    nil
  end
end

n = gets.to_i
nums = []
1.upto(n) do |i|
  nums << nabe(i)
end
print "\s"
puts nums.compact.join("\s")

Measured memory_bytes: 6304
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

ll a[51],p[51];

ll rec(ll n,ll x){
    if(n==0)return 1;
    if(x==1)return 0;
    else if(x<=a[n-1]+1)return rec(n-1,x-1);
    else if(x==a[n-1]+2)return p[n-1]+1;
    else return p[n-1]+1+rec(n-1,x-(a[n-1]+2));
}

int main(){
    ll N,X;cin >> N >> X;
    a[0]=1;p[0]=1;
    for(int i=0;i<=N;i++){
        a[i+1]=2*a[i]+3;
        p[i+1]=2*p[i]+1;
    }

    cout << rec(N,X) << endl;
    return 0;
}

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

int main(){
  ll X;
  cin >> X;
  ll t=100,ans=0;
  while(t<X){
    t*=1.01;
    t=ll(t);
    ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
def water(list_a):
    if list_a == [0] * len(list_a):
        return 0
    
    elif 0 in list_a:
        n = list_a.index(0)
        return water(list_a[:n]) + water(list_a[n+1:])

    else:
        mini = min(list_a)
        for i in range(len(list_a)):
            list_a[i] -= mini
        return water(list_a) + mini

n = int(input())
list_h = list(map(int, input().split()))
print(water(list_h))

Measured memory_bytes: 3192
#include <cstdio>
#include <stack>
#include <vector>
using namespace std;

using i64 = long long;

#define REP(i, stop) for (register int i = 1; i <= stop; ++i)

const int is = 1 << 17;
char ib[is], *ip = ib + is, it;
inline char getc() {
	if (ip == ib + is) { fread_unlocked(ib, 1, is, stdin); ip = ib; }
	return *ip++;
}
inline int read() {
	int r = 0;
	if (ip + 16 > ib + is) while ((it = getc()) & 16) r = r * 10 + it - '0';
	else while ((it = *ip++) & 16) r = r * 10 + it - '0';
	return r;
}

const int os = 1 << 22;
char ob[os], *op = ob, ot;
inline void putc(const char c) {
	*op++ = c;
//	if (op == ob + os) { fwrite_unlocked(ob, 1, os, stdout); op = ob; }
}
// x shoud be greater than or equal to zero
inline void write(i64 x) {
	char d[20];
	int i = 0;
	while (true) {
		d[i] = x % 10 + 48;
		x /= 10;
		++i;
		if (x <= 0) break;
	}
	while (i--) {
		putc(d[i]);
	}
	putc(' ');
}

i64 cnt[200001];
bool used[200001];
i64 st[200001], *tp;
signed main() {
  i64 N = read(), Q = read();
  vector<vector<i64>> G(N + 1);
  REP(_, N - 1) {
    i64 a = read(), b = read();
    G[a].push_back(b);
    G[b].push_back(a);
  }
  REP(_, Q) {
    i64 p = read(), x = read();
    cnt[p] += x;
  }
  tp = st;
  ++tp;
  *tp = 1;
  while (*tp) {
    i64 a = *tp;
    --tp;
    used[a] = true;
    for (i64 b : G[a]) {
      if (!used[b]) {
        cnt[b] += cnt[a];
        ++tp;
        *tp = b;
      }
    }
  }
  REP(i, N) {
    write(cnt[i]);
  }
  fwrite_unlocked(ob, 1, op - ob, stdout);
}


Measured memory_bytes: 20976
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000


int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<int> d(N,0);
	vector<vector<int>> E(N,vector<int>());
	for(int i=0;i<M;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		d[a]++,d[b]++;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	
	int cnt = 0;
	bool f = false;
	for(int i=0;i<N;i++){
		if(d[i]%2==1){
			cout<<"No"<<endl;
			return 0;
		}
		if(d[i]>=6)f=true;
		cnt += d[i]/2-1;
	}
	
	if(f){
		cout<<"Yes"<<endl;
		return 0;
	}
	
	if(cnt<=1)cout<<"No"<<endl;
	else if(cnt>=3)cout<<"Yes"<<endl;
	else{
		int s = -1,g = -1;
		for(int i=0;i<N;i++){
			if(d[i]==4){
				if(s==-1)s=i;
				else g=i;
			}
		}
		
		vector<bool> visited(N,false);
		visited[s]=true;
		int c = 0;
		queue<int> Q;
		Q.push(s);
		
		while(Q.size()!=0){
			int u = Q.front();
			Q.pop();
			for(int i=0;i<E[u].size();i++){
				int v = E[u][i];
				if(v==g){
					c++;
					continue;
				}
				if(visited[v])continue;
				visited[v]=true;
				Q.push(v);
			}
		}
		if(c==4){
			cout<<"No"<<endl;
		}
		else cout<<"Yes"<<endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 9072
#include <iostream>
#include <string>

using namespace std;

int main(void) {
    string S;
    cin >> S;
    int N = S.size();
    char s = S.at(0);
    int count = 1;
    for(int i=1; i<N; i++) {
        if(i%2 == 0) {
            if(S.at(i) == s) {
                count++;
            }
        } else if(S.at(i) != s) {
            count++;
        }
    }
    if(count >= N/2) {
        cout << N-count << endl;
    } else {
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define num(a) a-'0'
#define charr(a) (a - 'A' + 1)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define maxs(a,b) if(b>a)a=b
#define mins(a,b) if(b<a)a=b
#define debug(x) cerr<<"["<<#x<<":"<<x<<"] "
#define debug2(a,b) debug(a);debug(b)
#define debug3(a,b,c) debug2(a,b);debug(c)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/(__gcd(a,b))
#define print(arr) for(auto it = arr.begin();it < arr.end();it ++){cout << *it << " ";}cout << ln;
#define all(a) (a).begin(), (a).end()
#define vi vector<long long>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define ln "\n"
typedef long double ld;
typedef double d;
using namespace std;
int modF=1e9+7;
int INF=1e11;

void solve(){
	string s,t;
	cin>>s>>t;
	int a,b;
	cin>>a>>b;
	string u;
	cin>>u;
	if(u==s)a--;
	else b--;
	cout<<a<<" "<<b<<ln;
}

signed main(){
	boost_io;
	solve();
	return 0;
}

Measured memory_bytes: 3596
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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

//https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a

ll mod_pow(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;  // n の最下位bitが 1 ならば x^(2^i) をかける
        x = x * x % MOD;
        n >>= 1;  // n を1bit 左にずらす
    }
    return ret;
}

int main()
{
  ll n,a,b; cin>>n>>a>>b;
  
  //nCaの前計算
  ll S=1;
  rep(i,a) S=S*(n-i)%MOD; 
  rep(i,a) S=S*mod_pow(i+1,MOD-2)%MOD;
  
  //nCbの前計算
  ll T=1;
  rep(i,b) T=T*(n-i)%MOD; 
  rep(i,b) T=T*mod_pow(i+1,MOD-2)%MOD;
  
  ll ans=(mod_pow(2,n)-S-T-1)%MOD;
  while(ans<0) ans+=MOD;
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;

    s1[0] -= 32;
    s2[0] -= 32;
    s3[0] -= 32;
    cout << s1[0] << s2[0] << s3[0] << endl;  

}

Measured memory_bytes: 256
/**
*   @author: Kshitiz Srivastava (Pirate_ksh) @ MNNIT Allahabad
*/
#include<bits/stdc++.h>
using namespace std;
 
// General
#define ll long long
#define ld long double
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007 // 998244353
#define PI 3.1415926535897932384
#define endl "\n"
#define debug(x) cout<<x<<endl
#define REP(i,n) for(i=0;i<n;++i)
#define FOR(i,x,n) for(i=x;i<n;++i)
#define RREP(i,n) for(i=n-1;i>=0;--i)
#define RFOR(i,x,n) for(i=n-1;i>=x;--i)
#define TR(i,c) for(auto i=c.begin();i!=c.end();++i)
#define RTR(i,c) for(auto i=c.rbegin();i!=c.rend();++i)
#define sz(a) a.size()
 
// Bounds
#define lb(a,x) a.lower_bound(x)
#define ub(a,x) a.upper_bound(x)
#define all(a) a.begin(),a.end()
 
// Vector
#define vi vector <int>
#define pb(v,x) v.push_back(x)
#define vll vector <ll>
 
// Map
#define mii map <int, int>
#define umii unordered_map <int, int>
 
// Set
#define si set <int>
#define msi multiset<int>
 
// Pair
#define vpii vector<pair < int, int > >
#define vpll vector<pair < ll, ll > >
#define pii pair < int, int >
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define vppi vector<pair<pair<int,int>,int>>
#define ppi pair<pair<int,int>,int>

void solve();

int main(){
    io
    ll t;
    t=1;
    // cin >> t;
    for(int i=0;i<t;++i) solve();
    return 0;
}

void solve() {
    ll i, j;
    string s, t;
    cin >> s >> t;
    ll ans = INT_MAX, len = s.length()-t.length();
    REP(i, len+1) {
        ll cnt = 0;
        REP(j,t.length()) {
            if(s[i+j] != t[j]) cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3652
C = [list(map(int, input().split())) for _ in range(3)]

def f():
    for i in range(2):
        for j in range(2):
            if C[i][j]-C[i][j+1] != C[i+1][j]-C[i+1][j+1]:
                return False
            if C[j][i]-C[j+1][i] != C[j][i+1]-C[j+1][i+1]:
                return False
    return True

if f():
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
#include <algorithm>
#include <vector>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

double pro(double x){
  double tot=0;
  for(int i=1;i<=x;i++){
    tot+=i;
  }
  return tot/x;
}
int main(){
  double N,K;
  cin>>N>>K;
  vector<double>p(N+1);
  for(int i=1;i<=N;i++){
    cin>>p[i];
  }
  vector<double>s(N+1);
  double sum=0;
  for(int i=1;i<=N;i++){
    sum+=pro(p[i]);
    s[i]=sum;
  }
  double ans=0;
  for(int i=1;i<=N-K+1;i++){
    double t=s[i+K-1]-s[i-1];
    ans=max(ans,t);
  }
  cout<<fixed<<setprecision(10)<<ans<<endl;
  return 0;
}

Measured memory_bytes: 6488
using System;
using System.IO;

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int coins = int.Parse(input[0]);
        int money = int.Parse(input[1]);

        if (coins * 500 >= money)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }


    }
}



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

using namespace std;

int gcd(int a, int b){
  int c = a%b;
  if(!c){
    return b;
  }
  else{
    return gcd(b, c);
  }
}

int main(){
  int n;
  cin >> n;
  int l[n];
  for(int i=0; i<n; i++){
    cin >> l[i];
  }
  
  sort(l, l+n);
  int re = l[0];
  for(int i=0; i<n; ++i){
    re = gcd(l[i], re);
    if(re == 1){
      break;
    }
  }
  cout << re << endl;
}

Measured memory_bytes: 640
#include <iostream>

int main(){
   int N, X;
   std::cin >> N >> X;
   int m[N];
   int min = 1000;
   for(int i=0; i<N; ++i){
      std::cin >> m[i];
      X -= m[i];
      if(min>m[i]) min = m[i];
   }

   int sum = N;
   while(X>=min){
      ++sum;
      X -= min;
   }
   std::cout << sum << std::endl;

   return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define MAX 500000

int Tree[MAX]; // Tree

int n;

void maxHeapify(int i){
  int largest ,exchange, gl, gr;
  gl = getLeft(i);
  gr = getRight(i);
  
  if((n >= gl) && (Tree[gl] > Tree[i])) largest = gl;

  else largest = i;
  
  if((n >= gr) && (Tree[gr] > Tree[largest])) largest = gr;

  if (largest != i){

    exchange = Tree[i];
    Tree[i] = Tree[largest];
    Tree[largest] = exchange;
    maxHeapify(largest);

  }  
}

void buildMaxHeap(){
  int i;
  for (i=(n/2); i>=1; i--){
    maxHeapify(i);
	 }
}

int getParent(int i){
  return i/2;
}

int getLeft(int i){
  return (2*i);
}

int getRight(int i){
  return (2*i + 1);
}

main()
{
  int i;
  scanf("%d",&n);

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

    scanf("%d",&Tree[i]);

  }

  buildMaxHeap();

  for(i=1; i<=n; i++){
    
    printf(" %d",Tree[i]);

  }

  printf("\n");

  return 0;
}

Measured memory_bytes: 2552
while True:
    try:
        hand = map(int, raw_input().split(","))
        kind = list(set(hand))
        rank =[]
        for card in kind:
            rank.append(hand.count(card))
            rank.sort()
            rank.reverse()
        if rank[0] == 4:
            print "four card"
        elif rank[0] == 3:
            if rank[1] == 2:
                print "full house"
            else:
                print "three card"
        elif rank[0] == 2:
            if rank[1] == 2:
                print "two pair"
            else:
                print "one pair"
        else:
            hand.sort()
            if hand[4] - hand[0] == 4 or (hand[0] == 1 and hand[1] == 10):
                print "straight"
            else:
                print "null"
    except:
        break

Measured memory_bytes: 4240
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using graph = vector<vector<int>>;
bool visited[100001];
void visit_city(const graph &g, int i){
    if (!visited[i]) {
        visited[i] = true;
        for (const auto &j: g[i]) visit_city(g, j);
    }
}
int main(){
    int n, m;
    cin >> n >> m;
    graph g(n+1);
    for(int i=0; i<m; ++i){
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(int i=1; i<=n; ++i)visited[i]=false;
    int visit_count = 0;
    for(int i=1; i<=n; ++i){
        if (!visited[i]){
            visit_count += 1;
            visit_city(g, i);
        }
    }
    cout << visit_count-1;
    return 0;
}

Measured memory_bytes: 9280
import statistics

N = int(input())
P = [[int(i) for i in input().split()] for _ in range(N)]


left = []
right = []

for i in range(N):
    left.append(P[i][0])
    right.append(P[i][1])

lmed = statistics.median(left)
rmed = statistics.median(right)

if N % 2 == 0:
    print(int((rmed - lmed) * 2 + 1))
else:
    print(rmed - lmed + 1)


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

int cmp(const void *a,const void *b)
{
  return *(int*)b-*(int*)a;
} 

int main()
{
  int n;
  
  scanf("%d",&n);
  
  int a[n];
  int i;
  int ans=0;
  
  for(i=0;i<n;i++)
  {
    scanf("%d",&a[i]);
  }
  
  qsort(a,n,sizeof(int),cmp);
  
  for(i=0;i<n-1;i+=2)
  {
    ans+=a[i]-a[i+1];
  }
  
  if(n%2==1)
  {
    ans+=a[n-1];
  }
  
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
from itertools import product
element = [3,5,7]

N = int(input())
ans = 0
for i in range(3, len(str(N)) + 1) :
    L = product(element, repeat=i)
    for candidate in L :
        if ((3 not in candidate) or (5 not in candidate) or (7 not in candidate)) :
            continue
        l = int("".join(list(map(str,candidate))))
        if l <= N :
            ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
	int x,y,z;
	int ans=0;
	cin>>x>>y>>z;
	for(int i=x;;){
		i-=y+z;
		//cout<<i<<endl;
		if(i<z)break;
		else if(i==z){
			ans++;
			break;
		}
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
# 同一の集合の判定
def same(x, y):
    if find(x) == find(y):
        return True
    else:
        return False
# 集合の辺豪
def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if par[x] > par[y]:
        x, y = y, x
    par[x] += par[y]
    par[y] = x

# 集合の数
def uCnt(x):
    return -par[find(x)]

N, M = map(int, input().split())
p = list(map(int, input().split()))
par = [-1 for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    unite(a, b)

ans = 0
for i in range(N):
    if same(i, p[i] - 1):
        ans += 1

print(ans)

Measured memory_bytes: 13812
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& STL DEBUGGER &&&&&&&&&&&&&&&&&&&&&&&&&&&

//#define _GLIBCXX_DEBUG       // Iterator safety; out-of-bounds access for Containers, etc.
//#pragma GCC optimize "trapv" // abort() on (signed) integer overflow.

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& LIBRARIES &&&&&&&&&&&&&&&&&&&&&&&&&&&

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

/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
template<typename T, typename V = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, V, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>; 
*/
// find_by_order(), order_of_key() 

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEFINES &&&&&&&&&&&&&&&&&&&&&&&&&&&

#define int long long int 
#define ld long double
#define X first
#define Y second
#define all(i) i.begin(), i.end()
#define sz(a) (int)a.size()
 
const ld PI  = 3.141592653589793238463;
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = {-1, 0, 1, 0};
const int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEBUG &&&&&&&&&&&&&&&&&&&&&&&&&&&
 
#define XOX
vector<string> vec_splitter(string s) {
    for(char& c: s) c = c == ','?  ' ': c;
    stringstream ss; ss << s;
    vector<string> res;
    for(string z; ss >> z; res.push_back(z));
    return res;
}
 
void debug_out(vector<string> __attribute__ ((unused)) args, __attribute__ ((unused)) int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
    if(idx > 0) cerr << ", ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, T...);
}
 
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
#else
#define debug(...) 42
#endif
 
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& CODE &&&&&&&&&&&&&&&&&&&&&&&&&&&
	

void solve(){
	int x; cin >> x;
	int bal = 100;
	int times = 0;
	while(bal < x){
		bal += bal/100;
		times++;
	}
	cout << times << '\n';
}

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
    int T = 1; 
    //cin >> T;
    for(int tc = 1; tc <= T; ++tc){
		//cout << "Case #"<< tc <<": ";
        solve();
    }
    return 0;
}
/*
Sample inp
*/

Measured memory_bytes: 3628
a, b, c, d = gets.split.map(&:to_i)
 
count = b - a + 1
lcm = c.lcm(d)
 
cc = (b / c) - (a / c)
cc += 1 if a % c == 0
dc = (b / d) - (a / d)
dc += 1 if a % d == 0
lc = (b / lcm) - (a / lcm)
lc += 1 if a % lcm == 0
 
puts count - (cc + dc - lc)

Measured memory_bytes: 1788
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

const int N = 1e+6+5;
int big = 1e+18+3;
int mod = 1e+9+7;

signed main()
{
    IOS;
        
    int n;
    cin>>n;
    int op = 0;
    int h[n+1];

    repa(i,1,n)
        cin>>h[i];

    while(true)
    {
        bool found = false;
        bool allzero = true;
        repa(i,1,n)
        {
            if (h[i])
            {
                allzero = false;
                found = true;
                h[i]--;
            }

            else
                if (found)
                {
                    op++;
                    found = false;    
                }
        }
        if (found)
            op++;
        if(allzero)
            break;
    }   

    cout << op <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int n;
    cin >> n;
    int ans = 1, max_a = 0;
    rep1(i,n){
        int k = i;
        int cnt = 0;
        while(k % 2 == 0){
            k /= 2;
            cnt++;
        }
        if(max_a < cnt){
            ans = i;
            max_a = cnt;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3560
N,M = map(int,input().split())
array = []
suma = 0
summ = 0
for i in range(N):
    ab = list(map(int,input().split()))
    array.append(ab)
array.sort()

for i in range(N):
    if suma + array[i][1] <= M:
        suma += array[i][1]
        summ += array[i][1]*array[i][0]
    else:
        summ += (M-suma)*array[i][0]
        break
print(summ)

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

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	vector<int> B(N);
	int loop,ans;
	for(loop=0;loop<N;loop++){
		cin >> A[loop] >> B[loop];
	}
	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	if(N%2){
		ans=B[N/2]-A[N/2]+1;
	}else{
		ans=(B[N/2]+B[(N-1)/2])-(A[N/2]+A[(N-1)/2])+1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4848
#include<stdio.h>

int main() {
	int i, n, h[30], max, cnt;
	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d", &h[i]);
	max = h[0];
	cnt = 1;
	for (i = 1; i < n; i++) {
		if (h[i] >= max) {
			max = h[i];
			cnt++;
		}
	}
	printf("%d", cnt);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int ckDist(int nums[], int k){
    for(int i=0;i<5;i++){
        for(int z=0;z<5;z++){
            if(abs(nums[i]-nums[z])>k)return 0;
    }    
    }   
    return 1; 
}

int main(){
    int a, b, c, d, e, k;
    scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e , &k);
    int nums[5] = {a,b,c,d,e};
    if(ckDist(nums, k)==1){
        printf("Yay!\n");
    }else{
        printf(":(\n");
    }
    
    return 0;
} 

Measured memory_bytes: 128
n,k=map(int,input().split())
ans=0
mod=10**9+7
l=[i for i in range(n+1)]
mi=sum(l[:k])
ma=sum(l[n+1-k:])
ans=(ans+ma-mi+1)%mod
for i in range(k+1,n+2):
    mi+=l[i-1]
    ma+=l[-i]
    ans=(ans+ma-mi+1)%mod
print(ans)

Measured memory_bytes: 18480
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int A,B;
    cin>>A>>B;
    if(A>=13){cout<<B<<endl;}
    else if(A>=6&&A<=12){cout<<B/2<<endl;}
    else if(A<=5){cout<<0<<endl;}
    return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;

int main() {
  int inputs [3];
  cin >> inputs[0] >> inputs[1] >> inputs[2];
  int fives = 0;
  int sevens = 0;
  for (int i = 0; i < 3; i++) {
    if (inputs[i] == 5) fives++;
    else if (inputs[i] == 7) sevens++;
  }
  if (fives == 2 && sevens == 1) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int H, W;
int A[500][500];
vector<vector<int> > path;

void move(int i, int j, bool right) {
  if (right) {
    if (j < (W-1)) {
      vector<int> v{i+1, j+1, i+1, j+2};
      path.push_back(v);
    } else if (i < (H-1)) {
      vector<int> v{i+1, j+1, i+2, j+1};
      path.push_back(v);
    }
  } else {
    if (j > 0) {
      vector<int> v{i+1, j+1, i+1, j};
      path.push_back(v);
    } else if (i < (H-1)) {
      vector<int> v{i+1, j+1, i+2, j+1};
      path.push_back(v);
    }
  }
}

bool check(int i, int j, bool odd, bool right) {
  if (odd && A[i][j] % 2 == 0) {
    move(i, j, right);
  } else if (!odd && A[i][j] % 2 != 0) {
    move(i, j, right);
    odd = true;
  } else if (odd && A[i][j] % 2 != 0) {
    odd = false;
  }
  return odd;
}

int main() {
  cin >> H >> W;
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      cin >> A[i][j];
    }
  }
  bool odd = false;
  for (int i=0; i<H; i++) {
    if (i % 2 == 0) {
      for (int j=0; j<W; j++) {
        odd = check(i, j, odd, true);
      }
    } else {
      for (int j=W-1; j>=0; j--) {
        odd = check(i, j, odd, false);
      }
    }
  }
  cout << path.size() << endl;
  for (auto v: path) {
    cout << v[0] << " " << v[1] << " " << v[2] << " " << v[3] << endl;
  }
}

Measured memory_bytes: 9904
import java.io.*;
import java.util.*;

class Main {
    static Scanner scanner = new Scanner();

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int ans = 0;
        for (int i = 1; i <= n; i *= 100) {
            if (i * 10 > n) {
                ans += n - i + 1;
                break;
            }
            ans += i * 10 - i;
        }
        System.out.println(ans);
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 32768);
        StringTokenizer tokenizer;

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

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

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

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

Measured memory_bytes: 20948
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 A, B;
  std::cin >> A >> B;

  std::vector<std::string> s(40);
  for (i64 y = 0; y < 20; ++y) {
    s[y] = std::string(100, '#');
  }
  for (i64 y = 20; y < 40; ++y) {
    s[y] = std::string(100, '.');
  }

  for (i64 i = 0; i < A - 1; ++i) {
    const i64 y = i / 50 * 2;
    const i64 x = i % 50 * 2;
    s[y][x] = '.';
  }
  for (i64 i = 0; i < B - 1; ++i) {
    const i64 y = i / 50 * 2 + 21;
    const i64 x = i % 50 * 2;
    s[y][x] = '#';
  }

  std::cout << 40 << ' ' << 100 << std::endl;
  for (const std::string& s_i : s) {
    std::cout << s_i << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int a[100000],n,k,f[100001][2];
int main()
{
    cin>>n>>k;
    for (int i=0;i<n;++i) {cin>>a[i]; f[a[i]][0]=1;}
    f[0][0]=0;
    f[0][1]=0;
    for (int i=1;i<=k;++i){
        for (int j=0;j<n;++j){
            if (i-a[j]>=0){
                if (f[i-a[j]][1]==0) f[i][0]=1;
                if (f[i-a[j]][0]==0) f[i][1]=1;
            }
        }
    }
    if (f[k][0]==1) cout<<"First";
    else cout<<"Second";
}


Measured memory_bytes: 1152
#include<stdio.h>

int main(void)
{
	char s[1000];
	int i = 0;
	
	fgets(s, 1000, stdin);
	
	while (s[i] != '\n') {
		if (s[i] >= 'a' && s[i] <= 'z') {
			s[i] -= 32;
		}
		i++;
	}
	
	printf("%s", s);
	
	return 0;
}

Measured memory_bytes: 524
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for (auto &it : t) cout << it << " ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

const int N = 1e6 + 11;
bool isprime[N];
vector<int> primes;

void solve(){
  fill (isprime + 2, isprime + N, true);
  for (int i = 2; i < N; i++){
	 if (isprime[i]){
		primes.push_back(i);
		for (int j = 2; i * j < N; j++){
		  isprime[i * j] = false;	
		} 
	  }  
	}
   int a, d, n;
   while (cin >> a >> d >> n && a){
	   int ret = 0;
	   int i = a;
	   for (; i < N ; i += d){
		   ret += isprime[i];
		   if (ret == n) break;
		  }
	   cout << i << endl;  
	 }	
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}




Measured memory_bytes: 4728
#include <bits/stdc++.h>
    using namespace std;
    typedef pair <int, int> pii;
    const int N = 8003;
    string s;
    int x, y;
    vector <pii> a, b;
    bool canx[N][2 * N], fCanx[2 * N];
    bool cany[N][2 * N], fCany[2 * N];
    void make(string s, vector <pii> &a, vector <pii> &b) {
        a.clear(); b.clear();
        int cnt = 0, flip = 0;
        s += 'T';
        for (auto x: s) {
            if (x == 'T') {
                if (!flip) {
                    if (a.size() == 0)
                        a.push_back(make_pair(cnt, cnt));
                    else
                        a.push_back(make_pair(cnt, -cnt));
                }
                else b.push_back(make_pair(cnt, -cnt));
                cnt = 0;
                flip = 1 - flip;
            } else cnt++;
        }
    }
    void canReach(vector <pii> c, bool can[N][2 * N], bool fcan[2 * N]) {
        memset(can, 0, sizeof(can));
        can[0][N] = true;
        int n = c.size();
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j < 2 * N; j++)
                if (can[i - 1][j]) {
                    can[i][j + c[i - 1].first] = can[i][j + c[i - 1].second] = true;
                }
        }
        for (int j = 0; j < 2 * N; j++)
            fcan[j] = can[n][j];
    }
    string resp(int x, int y) {
        if (fCanx[x + N] && fCany[y + N]) return "Yes";
        else return "No";
    }
    void process (string s, vector <pii> &a, vector <pii> & b) {
        make(s, a, b);
        canReach(a, canx, fCanx);
        canReach(b, cany, fCany);
    }
    int main() {
//        freopen("input.inp", "r", stdin);
        try {
            cin >> s;
            process(s, a, b);
            int q; q = 1;
            while (q--) {
                cin >> x >> y;
                cout << resp(x, y) << "\n";
            }
        } catch (exception ex) {
        }
        return 0;
    }

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

#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
typedef long long ll;

using namespace std;

int n;
int q;
string t;

int main(){
    cin>>n;
    cin>>q;
    cin>>t;
    int num[n]={0};
    for(int i=0;i<n-1;i++){
        if(i==0){
            if(t[i]=='A'&&t[i+1]=='C'){
                num[i]=1;
            }else{
                num[i]=0;
            }
        }else{
            if(t[i]=='A'&&t[i+1]=='C'){
                num[i]=num[i-1]+1;
            }else{
                num[i]=num[i-1];
            }
        }
    }
    num[n-1]=num[n-2];
    for(int j=0;j<q;j++){
        int l,r;
        cin>>l>>r;
        int ans=0;
        ans=num[r-1]-num[l-1];
        if(num[r-1]-num[r-2]!=0){
            ans=ans-1;
        }if(num[l-1]-num[l-2]!=0){
            ans=ans+1;
        }
        cout<<ans<<endl;
    }
}


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

int main(void){
    int n;
    cin >> n;
    vector<int> num(n);
    vector<int> check(n-2);
    for(int i = 0; i < n; i++)
        cin >> num[i];
    int count = 0;
    for(int i = 0; i < n-2; i++){
        check[i]=(num[i]+num[i+1]+num[i+2])-max({num[i],num[i+1],num[i+2]})-min({num[i],num[i+1],num[i+2]});
        if(num[i+1]==check[i])
            count++;
    }

    cout << count << 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;

int main(){
    double r, ans;
    cin >> r;
    ans = r * 2 * 3.141592653589;
    cout << setprecision(12) << ans << endl;
    return 0;
}

Measured memory_bytes: 3788
import sys

n = int(sys.stdin.readline())
a_list = [int(x) for x in sys.stdin.readline().split()]
b_list = [int(x) for x in sys.stdin.readline().split()]
result = 0
for i in range(n):
    if b_list[i] <= a_list[i]:
        result += b_list[i]
    else:
        result += a_list[i]
        b_list[i] -= a_list[i]
        if b_list[i] <= a_list[i + 1]:
            a_list[i + 1] -= b_list[i]
            result += b_list[i]
        else:
            result += a_list[i + 1]
            a_list[i + 1] = 0
print(result)

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  int N,K;
  cin>>N>>K;
  vector<ll> A(N);
  for(int i(0);i<N;i++) cin>>A[i];
  ll sum(0);
  for(int i(0);i<K-1;i++){
    sum += A[i];
  }
  for(int i(0);i<N-K;i++){
    if(A[i] >= A[i+K]) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
  return 0;
}



Measured memory_bytes: 4776
def main():
    N = int(input())
    W = [int(i) for i in input().split()]
    S2 = sum(W)
    S1 = 0
    min_d = abs(S2 - S1)
    for i in range(N):
        S1 += W[i]
        S2 -= W[i]
        if abs(S2-S1) < min_d:
            min_d = abs(S2-S1)
    return min_d

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <deque>

using namespace std;

int main(int argc, char const *argv[])
{
	int a,b;
	int tmp = 0;

	cin >> a >> b;

	for (int i = 1; i < b-a; ++i) tmp += i;//value a

	cout << tmp-a << "\n";

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define INPUTL(i,n) for(ll i=0 ; i<n ; i++)
const int MOD = 1000000007 ; //  , 1000000009 , 1000000023 ,998244353
const ll INF = (1e18);
const ld PI = 4*atan((ld)1);
int MAX = MOD;
void array_debug(vector<ll>ar){
    for(auto x: ar)cout << x << ' ';
    cout << '\n';
}
ll power(ll x,ll n)
{
    ll result=1;
    while(n>0){
        if(n&1)result = (result * x)%MOD;
        x=(x*x)%MOD;
        n >>= 1;
    }
    return result%MOD;
}
ll gcd(ll a , ll b){
  if(b==0)return a;
  return gcd(b,a%b);
}

int main() {
    #ifdef AVI  
        freopen("input.txt" , "r" , stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(20);
    
   
    ll n,k;
    cin >> n >> k;
    vector<ll>ar(n);
    for(auto &x:ar)cin >> x;
    vector<ll>dp(n);
    
    dp[0] = 0;
    for(ll i=1 ; i<n ; i++){
      dp[i] = INF;
      for(ll j=i-1 ; j>=(max(i-k , ll(0))) ; j--){
        dp[i] = min(dp[i] , dp[j] + abs(ar[j]-ar[i]));
      }
    }

    cout << dp[n-1];
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

vector<pair<ll ,ll>> prime_factorize(ll n) {
    vector<pair<ll, ll>> res;
    for (ll p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) {
            num++;
            n /= p; 
        }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {

    ll N, P, ans = 1;
    cin >> N >> P;

    auto vec =  prime_factorize(P);
    for (auto pa : vec) {
        // cout << pa.first << " " << pa.second << endl;
        // if (pa.second >= N) {
        //     ans *= pa.first * (pa.second / N);
        // }
        for (int j = 0; j < pa.second / N; j++)
            ans *= pa.first;
    }

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
#include <cmath>
using namespace std;
#define lli long long int
#define f first
#define s second
#define Max 1e9+7
#define fw(i, start, end) for (lli i = start; i < end; ++i)
int dp[100005];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    lli looper;
    cin >> looper;
    int a[looper + 1];
    fw(i, 0, looper)
    {
        cin >> a[i];
    }
    lli K = 2;
    fw(i, K-1, looper+1)
    {
        dp[i] = Max;
        for (lli j = i ; j >= fmax(i - K, 0); j--)
        {
            dp[i] = fmin(dp[i], dp[j] + fabs(a[i] - a[j]));
        }
    }
    cout << dp[looper-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)


struct Problem {

	void Solve() {
		UL a, b; cin >> a >> b;
		
		if (a == b) cout << "Yes" << endl;
		else cout << "No" << endl;
	}

	
	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


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

const ll logx=30;
const ll N=4e5+5;
const ll M=3e5+5;
const ll mod=1e9+7;
const ll INF=1e18+5;
const double PI = 3.14159265358979323846;

#define ints(n) scanf("%d",&n)
#define intp(n) printf("%d\n",n)
#define longs(n) scanf("%intd",&n)
#define longp(n) printf("%intd\n",n)

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }

#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcount(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define ms(dp,val) memset(dp,val,sizeof(dp))
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1ll;x=(x*x)%m;}return ans%m;}

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

int main()
{
  ll a,b,t;
  cin>>a>>b>>t;
  ll tot=t/a;
  ll sum=(tot*b);
  cout<<sum<<endl;
}


Measured memory_bytes: 256
while True:
    m,f,r = map(int,(input().split()))
    if m == f == r == -1:
        break
    if m == -1 or f == -1 :
        print('F')
    elif m + f >= 80:
        print('A')
    elif 65 <= m + f < 80:
        print('B')
    elif 50 <= m + f < 65 or r >= 50:
        print('C')
    elif  m + f < 30:
        print('F')
    elif 30 <= m +f < 50 and r < 50:
        print('D')




Measured memory_bytes: 5592
#include <bits/stdc++.h>
 
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0) (__VA_ARGS__)
#define rep_0(i, end) for (int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for (int i = (fr); i <= (ba); ++i)
#define overload_rep(arg_0, arg_1, arg_2, name, ...) name
#define all(box) box.begin(), box.end()
 
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }

using lint = long long;

int main() {

  lint N, M;
  std::cin >> N >> M;
  std::vector<lint> A(N);
  rep (i, N) std::cin >> A[i];
  rep (i, N) A[i] /= 2;

  int bef = -1;
  rep (i, N) {
    int t = A[i] & -A[i];
    if (bef == -1) bef = t;
    else if (bef != t) {
      puts("0");
      return 0;
    }
  }

  lint now = 1;
  rep (i, N) {
    lint g = std::__gcd(A[i], now);
    now = now / g * A[i];
  }

  std::cout << M / now - M / (now * 2) << '\n';
  return 0;

}


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

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define SZ(x) (int)(x).size()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define SET(a, b) memset((a), (b), sizeof(a))
template <class t> bool ckmin(t& a, const t& b) { return a > b ? a = b, true : false; }
template <class t> bool ckmax(t& a, const t& b) { return a < b ? a = b, true : false; }

#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
  if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p);
template <class T> struct IsC {
  template <class C> static char test(typename C::const_iterator*);
  template <class C> static int test(...);
  static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <> struct IsC<string> { static const bool value = false; };
template <class C> typename enable_if<IsC<C>::value, ostream&>::type operator<<( ostream& o, const C& c) {
  o << '{';
  for (auto it = c.begin(); it != c.end();)
    o << *it << (++it != c.end() ? ", " : "}");
  return o;
}
template <class a, class b> ostream& operator<<(ostream& o, const pair<a, b>& p) {
  return o << '(' << p.fi << ", " << p.se << ')';
}

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

    ll x;
    cin >> x;

    ll cnt = 0;
    for(ll curr = 100; curr < x; ++cnt)
        curr += curr/100;
    cout << cnt << endl;
}




Measured memory_bytes: 3640