akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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 req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n;cin>>n;
    vint c(n-1),s(n-1),f(n-1);
    rep(i,n-1)cin>>c[i]>>s[i]>>f[i];

    rep(i,n){
        int t=0;
        for(int j=i; j<n-1; j++){
            if(t<s[j]) t+=s[j]-t+c[j];
            else if(t%f[j]==0) t+=c[j];
            else t+=f[j]-t%f[j]+c[j];
        }
        cout<<t<<endl;
    }
}   

Measured memory_bytes: 3668
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
  #define cerrendl 42
#endif
//}}}

signed main() {
  string s;cin>>s;
  int n = sz(s);
  cout << string(n, 'x') << endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

type set struct {
	a, b int
}

type setList []set

func (a setList) Len() int           { return len(a) }
func (a setList) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a setList) Less(i, j int) bool { return a[i].a < a[j].a }

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

	N, K := scanInt(), scanInt()
	L := make(setList, N)
	for i := 0; i < N; i++ {
		L[i].a, L[i].b = scanInt(), scanInt()
	}
	sort.Sort(L)

	cnt := 0
	for _, l := range L {
		cnt += l.b
		if cnt >= K {
			fmt.Println(l.a)
			return
		}
	}
}


Measured memory_bytes: 5076
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    val d = sc.nextInt()
    println(problem164b(a, b, c, d))
}

fun problem164b(a: Int, b: Int, c: Int, d: Int): String {
    var tHp = a
    var aHp = c
    while (true) {
        aHp -= b
        if (aHp <= 0) return "Yes"
        tHp -= d
        if (tHp <= 0) return "No"
    }
}

Measured memory_bytes: 36368
#include "bits/stdc++.h"
#include  <iostream>
 using namespace std;
 
#define IOS         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define mem(a,v)    memset((a), (v), sizeof (a))
#define FOR(i,a,n)  for(int i = (a); i<(n); ++i) 
#define mp(a , b)   make_pair(a , b)
#define pb(a)       push_back(a)

#define anal         '\n'

#define M 1000000007 
typedef long long ll;

 
 




int main(){
     
    IOS;
    
   // freopen("input.in", "r", stdin);
   // freopen("output.in", "w", stdout);
     


    int n;
    cin>>n;
    
    bool flg =0;
    while(n){
      int x = n%10;
      if(x==7) {
      	flg =1;
      	break;
      }
      n /= 10;
    }
     
    if(flg) cout<<"Yes";
    else cout<<"No";
             
  return  0 ;
   	    
 }


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int N;cin >> N;
	vector<int>data(N);
	for (int i = 0;i < N;i++) {
		cin >> data[i];
	}
	int a = 0;
	bool judge = true;
	for (int i = 0;i < N;i++) {
	  a = max(a, data[i]);
	  if (a - data[i] > 1)judge = false;
	}
	if (judge)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rc(s) return cout<<s,0
/*\     /  *   ---  -------   --    ---     VICTOR BOSS FOR EVER!!!
   \   /   |  /        |      /  \  |   \
    \ /    |  \        |      \  /  |- -
     -     |   ---     |       --   |    \  VICTOR BOSS FOR EVER!!! */

using namespace std;
int main(){
    long long int a[4];
    cin>>a[0]>>a[1]>>a[2]>>a[3];
    int s1=0,s2=0,s3=0,s4=0;
    for(int i=0;i<4;i++)
    if(a[i]==1){
        s1++;
    }else if(a[i]==7){
    s2++;
    }else if(a[i]==4){
    s3++;
    }else if(a[i]==9){
    s4++;
    }
    if(s1==0||s2==0||s3==0||s4==0){
        cout<<"NO";
    }else {
    cout<<"YES";
    }
    return 0;}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	vs := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&vs[i])
	}
	cs := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&cs[i])
	}

	r := 0
	for i := 0; i < n; i++ {
		if vs[i] > cs[i] {
			r += vs[i] - cs[i]
		}
	}

	fmt.Print(r)
}


Measured memory_bytes: 512
#include <map>
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <bits/stdc++.h>
#include <complex>
#include <numeric>
#include <climits>
#include <stack>
#include <locale.h>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <ctime>
#include <deque>
#include <queue>
#define mp make_pair
#define pii pair<int,int>
#define ll long long
#define rept(i,n)for(int i=0;i<(int)(n);i++)
#define fi first
#define se second
using namespace std;
long long a[200013],n,ans,j,h;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>a[i];
	for(int i=0;i<n;i++)
	{
		for(j;j<n;j++)
		if((h|a[j])!=h+a[j])
		   break;
		else h=h+a[j],
		ans=ans+j-i+1;
		h-=a[i];
	}
	cout<<ans;
    return 0;
}



Measured memory_bytes: 1792
def main():
    dates = int(input())
    numbers = list(map(int, input().split()))
    count = {i: 0 for i in range(1, dates + 1)}
    for n in numbers:
        count[n] += 1
    answer = 0
    for c in count.values():
        answer += c * (c - 1) // 2
    for n in numbers:
        print(answer - count[n] + 1)


if __name__ == '__main__':
    main()



Measured memory_bytes: 38284
#include<stdio.h>
#define N 500000
 
void merge(int *, int, int, int);
void mergeSort(int *, int, int);
 
int count=0;
 
int main()
{
  int i, n, S[N];
 
  scanf("%d", &n);
 
  for(i = 0; i < n; i++){
    scanf("%d", &S[i]);
  }
 
  mergeSort(S, 0, n);
 
  for(i = 0; i < n-1; i++){
    printf("%d ", S[i]);
  }
  printf("%d\n", S[n-1]);
  printf("%d\n", count);
 
  return 0;
}
 
void merge(int *S, int left, int mid, int right)
{
   
  int n1, n2, i, j, k;
  int L[N], R[N];
   
  n1 = mid-left;
  n2 = right-mid;
 
  for(i = 0; i < n1; i++) L[i] = S[left + i];
  for(i = 0; i < n2; i++) R[i] = S[mid + i];
 
  L[n1] = 1000000000;
  R[n2] = 1000000000;
  i = j = 0;
 
  for(k = left; k < right; k++){
    if(L[i] <= R[j]){
      S[k] = L[i];
      i++;
    }
    else{ 
      S[k] = R[j];
      j++;
    }
    count++;
  }
}
 
void mergeSort(int *S, int left, int right)
{
 
  int mid;
 
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(S, left, mid);
    mergeSort(S, mid, right);
    merge(S, left, mid, right);
  }
}


Measured memory_bytes: 5740
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
int n,x;
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>n;
	while(n)
	{
		--n;
		cin>>x;
		if(x&1)
		{
			continue;
		}
		else
		{
			if(x%3==0||x%5==0)
			{
				continue;
			}
			else
			{
				cout<<"DENIED"<<endl;
				return 0;
			}
		}
	}
	cout<<"APPROVED"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cstring>
#include <functional>

using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(itr,c) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)

int main(){
  int i,j,k;

  string in;
  while(cin >> in){
    rep(i,in.size()){
      if(in[i] == 's') in[i] = rand() % 50 + '0';
    }
    if(in[0] == in[1] && in[1] == in[2]){
      cout << in[0] << endl;
      continue;
    }
    if(in[3] == in[4] && in[4] == in[5]){
      cout << in[3] << endl;
      continue;
    }
    if(in[6] == in[7] && in[7] == in[8]){
      cout << in[6] << endl;
      continue;
    }
    if(in[0] == in[4] && in[4] == in[8]){
      cout << in[0] << endl;
      continue;
    }
    if(in[2] == in[4] && in[4] == in[6]){
      cout << in[2] << endl;
      continue;
    }
    if(in[0] == in[3] && in[3] == in[6]){
      cout << in[0] << endl;
      continue;
    }
    if(in[1] == in[4] && in[4] == in[7]){
      cout << in[1] << endl;
      continue;
    }
    if(in[2] == in[5] && in[5] == in[8]){
      cout << in[2] << endl;
      continue;
    }
    cout << "d" << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,a,b;	cin >> n >> a >> b;
  long long ans=0;
  ans+=n/(a+b)*a;
  n-=n/(a+b)*(a+b);
  ans+=min(a,n);
  cout << ans;
}

Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }
//V,P(大文字)使用不可
int h,w;
int c[15][15];
int a[201][210];

int main(){
    cin>>h>>w;
    rep(i,10){
        rep(j,10) cin>>c[i][j];
    }
    rep(i,h){
        rep(j,w) cin>>a[i][j];
    }
    vector<int> cnt(10,100000);
    for(int i=0;i<10;i++){
        if(i==1) continue;
        vector<int> d;
        for(int j=0;j<10;j++){
            if(i==j) continue;
            d.push_back(j);
        }
        do{
            int s=0;
            for(int j=0;j<9;j++){
                if(j==0){
                    s+=c[i][d[j]];
                }else{
                    s+=c[d[j-1]][d[j]];
                }
                if(d[j]==1) break;
            }
            chmin(cnt[i],s);
        }while(next_permutation(all(d)));
    }
    int ans=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(a[i][j]==-1||a[i][j]==1) continue;
            ans+=cnt[a[i][j]];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std;

bool compare(const pair<int, int> &a, const pair<int, int> &b) {
	if(a.first == b.first) {
		return a.second > b.second;
	} else {
		return a.first < b.first;
	}
}

int main() {
	int N;
	cin >> N;
	
	vector<pair<int, int>> LR(N);
	int l, r;
	int l_max = 0;
	int r_min = INT_MAX;
	int p_max = 0;
	for(int i=0; i<N; i++) {
		cin >> l >> r;
		l_max = max(l_max, l);
		r_min = min(r_min, r);
		p_max = max(p_max, r - l + 1);
		LR[i] = make_pair(l, r);
	}

	int ans = p_max + max(0, r_min - l_max + 1);
	
	sort(LR.begin(), LR.end(), compare);
	
	vector<int> minR(N, LR.back().second);
	for(int i=N-2; i>=0; i--) {
		minR[i] = min(minR[i+1], LR[i].second);
	}
	
	for(int i=1; i<N; i++) {
		int c1_l = LR[i-1].first;		
		int c2_r = minR[i];
		
		int c1_p = max(0, r_min - c1_l + 1);
		int c2_p = max(0, c2_r - l_max + 1);
		
		ans = max(ans, c1_p + c2_p);
	}

	cout << ans << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,a[110];
    cin>>n;
    rep(i,n)cin>>a[i];
    int ans=0;
    rep(i,n){
        if(i%2==0&&a[i]%2)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    
    set<string> S;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        S.insert(s);
    }
    
    cout << S.size() << endl;
    
    return 0;
}

Measured memory_bytes: 19228
#include <iostream>
#include <vector>
#include <map>
#define MOD 1000000007
#include <algorithm>
#include <math.h>
#include <utility>

using namespace std;

long long int dp[101][100000];

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

    vector<int> t;
    map<int,pair<int,int>> mp;
    t.reserve(100000);

    for(int i = 1; sqrt(n) + 1 >= i && n >= i; i++){
        if(n/i != 0)
            t.push_back(n/i);
        t.push_back(i);
    }

    sort(t.begin(), t.end());
    t.erase(unique(t.begin(), t.end()), t.end());

    for(int i = 0; t.size() > i;i++) {
        //cout << t[i] << endl;
        int c = 1;
        if(0 < i) c = t[i] - t[i - 1];
        mp[t[i]] = {i, c};
        
    }
    dp[0][0] = 1;

    for(int i = 0; k > i; i++){
        for(int j = 0; t.size() > j; j++){
            dp[i + 1][mp.at(n/t[j]).first] += dp[i][j];
            dp[i + 1][mp.at(n/t[j]).first] %= MOD;
        }
        for(int j = t.size() - 1; 0 <= j; j--){
            if(j >= 1){
                dp[i + 1][j-1] += dp[i + 1][j];
                dp[i + 1][j-1] %= MOD;
            }
            dp[i + 1][j]  *= mp.at(t[j]).second;
            dp[i + 1][j] %= MOD;
        }
        for(int j = 0; t.size() > j; j++){
            //cout << dp[i + 1][j] << " ";
        }
        //cout <<endl;
    }
    int ans = 0;
    for(int j = t.size() - 1; 0 <= j; j--){
        ans += dp[k][j];
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 81144
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using boost::multiprecision::cpp_int;


cpp_int gcd(cpp_int x, cpp_int y){
 cpp_int tmp;
 cpp_int r;
 if(x > y){
    tmp = x;
    x = y;
    y = tmp;
  }
  r = y % x;
  while(r!=0){
    y = x;
    x = r;
    r = y % x;
  }
  return x;
}
int main(){
    cpp_int mod = 1000000007;
    int n;
    cin >> n;
    cpp_int a;
    cpp_int ans=0;
    cpp_int GCD=1;
    cpp_int LCM=1;
    cpp_int tmp;
    for(int i=0;i<n;i++){
        cin >> a;
        GCD=gcd(LCM,a);
        tmp=LCM/GCD;
        ans *= a/GCD % mod;
        ans += tmp;
        ans %= mod;
        LCM = a * tmp;
    }
    cout << ans << endl;
}

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

using namespace std;

int main(){
    string S;
    cin >> S;
    int n = S.length();
    int ans = 0;
    for (int i = 0; i < n / 2; i++){
        if (S[i] != S[n - i - 1])
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
int main(){

	int a,b,i,x;
	char  op;


	for(i=0;i<=100000;i++)
	{  
		cin>>a>>op>>b;

		if(op=='+')
		{
			x=a+b;
			cout<<x<<endl;
		}
		else if(op=='-')
		{
			x=a-b;
			cout<<x<<endl;
		}
		else if(op=='*')
		{
			x=a*b;
			cout<<x<<endl;
		}
		else if(op=='/')
		{
			x=a/b;
			cout<<x<<endl;
		}
	
		
		if(op=='?'){break;};
	
	}

	return 0;
}


Measured memory_bytes: 3092
using System;
using System.Collections.Generic;
class Solve{
    int N;
    int C;
    int[] a;
    int[] b;
    public Solve(){}
    public static int Main(){
        new Solve().Calc();
        return 0;
    }
    void Calc(){
        getinput();
        long[,] pow = new long[401,C+1];
        long[,] powsum = new long[401,C+1];
        long[,] dp = new long[N+1,C+1];
        for(int i=0;i<401;i++){
            for(int j=0;j<C+1;j++){
                if(j == 0){
                    pow[i,j] = 1;
                }
                else{
                    pow[i,j] = (pow[i,j-1]*i)%Define.mod;
                }
            }
        }
        for(int i=0;i<401;i++){
            for(int j=0;j<C+1;j++){
                if(i == 0){
                    powsum[i,j] = pow[i,j]; 
                }
                else{
                    powsum[i,j] = (pow[i,j]+powsum[i-1,j])%Define.mod;
                }
            }
        }
        for(int i=0;i<N+1;i++){
            for(int j=0;j<C+1;j++){
                if(i == 0 && j == 0){
                    dp[i,j] = 1;
                }
                else if(j == 0){
                    dp[i,j] = (b[i-1]-a[i-1]+1)*dp[i-1,j]%Define.mod;
                }
                else if(i == 0){
                    dp[i,j] = 0;
                }
                else{
                    long count = dp[i-1,j]*(b[i-1]-a[i-1]+1)%Define.mod;
                    for(int k=1;k<j+1;k++){
                        count = (count+((powsum[b[i-1],k]-powsum[a[i-1]-1,k])%Define.mod*dp[i-1,j-k]%Define.mod))%Define.mod; 
                    }
                    dp[i,j] = count;
                }
            }
        }
        Console.WriteLine(dp[N,C] > 0 ? dp[N,C] : dp[N,C]+Define.mod);
        
    }
    void getinput(){
        string[] str = Console.ReadLine().Split(' ');
        N = int.Parse(str[0]);
        C = int.Parse(str[1]);
        a = new int[N];
        b = new int[N];
        str = Console.ReadLine().Split(' ');
        for(int i=0;i<N;i++){
            a[i] = int.Parse(str[i]);
        }
        str = Console.ReadLine().Split(' ');
        for(int i=0;i<N;i++){
            b[i] = int.Parse(str[i]);
        }
    }    
}
public static class Define{
    public const long mod = 1000000007;
    public static void DebugPrint(long[,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                Console.Write(k[i,j]+" ");
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 6488
//sieu nhan
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inp "test.inp"
#define out "test.out"
#define oo 100005
#define inf 1e15
#define mod 1000000007
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define y1 hungdzno1
int n,a[oo],f[oo];
void nhap(){
  cin>>n;
  for(int i=1;i<=n;++i){
    cin>>a[i];
    if(i>1) f[i]=inf;
  }
}
void xuly(){
  for(int i=1;i<=n;++i) for(int j=i;j>=max(i-2,(int)(1));--j) f[i]=min(f[i],f[j]+abs(a[i]-a[j]));
  cout<<f[n];
}
main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  //freopen(inp,"r",stdin);
  //freopen(out,"w",stdout);
  nhap();
  xuly();
}


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

int main()
{
  int X;
  cin >> X;
  vector<bool> expo(X + 1);

  expo[1] = 1;
  for (int b = 2; b <= X; b++)
  {
    int v = b * b;
    while (v <= X)
    {
      expo[v] = 1;
      v *= b;
    }
  }
  for (int i = X; i >= 1; i--)
  {
    if (expo[i])
    {
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int q = sc.nextInt();
			long flags = 0;

			for(int k = 0; k < q; k++) {
				switch(sc.nextInt()) {
				case 0:{
					int i = sc.nextInt();
					System.out.println(flags>>i&1);
					break;
				}
				case 1:{
					int i = sc.nextInt();
					if((flags>>i&1)==0)
						flags += 1L<<i;
					break;
				}
				case 2:{
					int i = sc.nextInt();
					if((flags>>i&1)==1)
						flags -= 1L<<i;
					break;
				}
				case 3:{
					int i = sc.nextInt();
					if((flags>>i&1)==1)
						flags -= 1L<<i;
					else
						flags += 1L<<i;
					break;
				}
				case 4:
					System.out.println(flags == -1?1:0);
					break;
				case 5:
					System.out.println(flags != 0?1:0);
					break;
				case 6:
					System.out.println(flags == 0?1:0);
					break;
				case 7:{
					int cnt = 0;
					for(int j = 0; j < 64; j++) {
						if((flags>>j&1)>0)
							cnt++;
					}
					System.out.println(cnt);
					break;
				}
				case 8:
					System.out.println(Long.toUnsignedString(flags));
					break;
				}
			}
		}
	}
}


Measured memory_bytes: 116492
#include <stdio.h>
#include <string.h>

int		main(void)
{
	char	S[10];
	int		flag;

	flag = 0;
	scanf("%s", &S);
	if (strlen(S) % 2 != 0)
	{
		printf("No");
		return 0;
	}
	//printf("%s", &S);
	if (S[0] == 'h')
	{
		for (int i = 1; S[i]; i++)
		{
			if (i % 2 == 0 && S[i] != 'h')
				flag = 1;
			else if (i % 2 != 0 && S[i] != 'i')
				flag = 1;
		}
		if (flag == 0)
			printf("Yes");
		else
			printf("No");
	}
	else
		printf("No");
	return (0);
}

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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  long long r=0;
  long long g=0;
  long long b=0;
  for(int i=0; i<n; i++){
    if(s.at(i) == 'R') r++;
    if(s.at(i) == 'G') g++;
    if(s.at(i) == 'B') b++;
  }
  long long x = 0;
  for(int i=0; i<n; i++){
    for(int j=i; j<n; j++){
      int k=2*j-i;
      if(k >= n) break;
      if(s.at(i) != s.at(j) && s.at(i) != s.at(k) && s.at(j) != s.at(k)) x += 1;
    }
  }
  //cout << r << endl;
  //cout << g << endl;
  //cout << b << endl;
  cout << r*g*b - x;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
    int n, x;
    cin >> n >> x;
    int y[n];
    int c = 1000000000;
    for (int i = 0; i < n; i++) {
        cin >> y[i];
        y[i] = y[i] - x;
        if (abs(y[i]) < c) {
            c = y[i];
        }
    }   
    bool flag = true;
    while (flag) {
        flag = false;
        for (int i = 0; i < n; i++) {
            if (y[i] % c != 0) {

                //c = gcd(c, y[i]);
                int a, b, r, tmp;
                b = c;
                a = abs(y[i]);


                /* 自然数 a > b を確認・入替 */
                /*
                if (a < b) {
                    tmp = a;
                    a = b;
                    b = tmp;
                }
                */

                /* ユークリッドの互除法 */
                r
                    = a % b;
                while (r != 0) {
                    a = b;
                    b = r;
                    r = a % b;
                }
                c = b;


                flag = true;
            }
        }
    }   
    cout << abs(c) << endl;
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        // TODO code application logic here
        int result = 0;
        Scanner scanner = new Scanner(System.in);
        int input = scanner.nextInt();
        for(int i = 1 ; i <= input ; i ++){
            result += i;
        }
        System.out.print(result);
    }
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

// graph by adjacency list
template <typename T>
struct Edge {
  int dst; T weight;
  Edge(int dst, T weight) : dst(dst), weight(weight) { }
  bool operator < (const Edge<T> &e) const {
    return weight > e.weight;
  }
};

template <typename T>
struct Graph {
  int V;
  vector<vector<Edge<T>>> E;
  Graph(int V) : V(V) { E.resize(V); }
  void add_edge(int src, int dst, T weight) {
    E[src].emplace_back(dst, weight);
  }
};

template <typename T>
struct HeavyLightDecomposition {
  const Graph<T> g;
  vector<int> vid, head, heavy, parent;
  HeavyLightDecomposition(const Graph<T> g, int root = 0) : g(g), vid(g.V, -1), head(g.V), heavy(g.V, -1), parent(g.V) {
    dfs(root, -1);
    bfs(root);
  }

  int dfs(int v, int par) {
    parent[v] = par;
    int sub = 1, max_sub = 0;
    for (Edge<T> child : g.E[v]) {
      if (child.dst != par) {
        int child_sub = dfs(child.dst, v);
        sub += child_sub;
        if (child_sub > max_sub) {
          max_sub = child_sub;
          heavy[v] = child.dst;
        }
      }
    }
    return sub;
  }

  void bfs(int root = 0) {
    int k = 0;
    queue<int> que({root});
    while (not que.empty()) {
      int r = que.front(); que.pop();
      for (int v = r; v != -1; v = heavy[v]) {
        vid[v] = k++;
        head[v] = r;
        for (Edge<T> child : g.E[v]) {
          if (child.dst != parent[v] and child.dst != heavy[v]) que.push(child.dst);
        }
      }
    }
  }

  int lca(int u, int v) {
    while(head[u] != head[v]) {
      if (vid[u] > vid[v]) swap(u, v);
      v = parent[head[v]];
    }
    if (vid[u] > vid[v]) swap(u, v);
    return u;
  }
};

int main() {
  int N; scanf("%d", &N);
  Graph<int> g(N);
  REP(i, N) {
    int k; scanf("%d", &k);
    REP(_, k) {
      int c; scanf("%d", &c);
      g.add_edge(i, c, 1);
      g.add_edge(c, i, 1);
    }
  }

  HeavyLightDecomposition<int> hld(g);

  int Q; scanf("%d", &Q);
  REP(_, Q) {
    int u, v; scanf("%d %d", &u, &v);
    printf("%d\n", hld.lca(u, v));
  }
  return 0;
}

Measured memory_bytes: 24720
import math
n = int(input())
x = list(map(float, (input().split())))
y = list(map(float, (input().split())))
l = [0.0]*n

for i in range(n):
    l[i] = abs(x[i]-y[i])
print(sum(l))
che = max(l)

for i in range(n):
    l[i] = abs(x[i]-y[i])**2
print(math.sqrt(sum(l)))

for i in range(n):
    l[i] = abs(x[i]-y[i])**3
print(math.pow(sum(l), 1.0/3.0))
print(che)

Measured memory_bytes: 7800
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n) - 1; (i) >= 0; --i)
#define SZ(n) (int)(n).size()
#define ALL(n) (n).begin(), (n).end()
#define MOD LL(1e9 + 7)
#define INF 1000000
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int main() {
	LL x;
	cin >> x;
	cout << x * x * x << endl;
	return 0;
}



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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, M; cin >> N >> M;
  vector<int> X(N); REP(i, N) cin >> X[i];

  vector<int> counter(100010, 0);
  for (int x : X) counter[x]++;

  vector<vector<int>> mod_counter(M, vector<int>(2, 0));
  REP(i, 100001) {
    mod_counter[i % M][0] += counter[i] % 2;
    mod_counter[i % M][1] += counter[i] / 2;
  }

  int ans = mod_counter[0][0] / 2 + mod_counter[0][1];
  if (M % 2 == 0) ans += mod_counter[M / 2][0] / 2 + mod_counter[M / 2][1];

  for (int i = 1, j = M - 1; i < j; i++, j--) {
    int p = min(mod_counter[i][0], mod_counter[j][0]);
    ans += p;
    mod_counter[i][0] -= p, mod_counter[j][0] -= p;
    int res1 = min(mod_counter[i][1], mod_counter[j][0] / 2);
    ans += res1 + mod_counter[i][1];
    int res2 = min(mod_counter[j][1], mod_counter[i][0] / 2);
    ans += res2 + mod_counter[j][1];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#pragma 03
using namespace std;
using namespace __gnu_pbds;
// chctxdy
int main(){
	fastio;
	ll n; cin >> n;
	cout << n / 2 + n % 2;
}

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

int main() {

	vector<unsigned long long> v;
	v.push_back(2);
	v.push_back(1);

	int n; scanf("%d", &n);
	while(v.size() <= n) {
		v.push_back(v[v.size() - 1] + v[v.size() - 2]);
	}	

	printf("%llu", v[n]);

	return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	
	int i,j,n,q;
	int count=0;
	
	cin >> n;
	int S[n];
	for (i=0;i<n;i++){
		cin >> S[i];
	}
	cin >> q;
	int T[q];
	for (i=0;i<q;i++){
		cin >> T[i];
	}
	
	for (j=0;j<q;j++){
		for (i=0;i<n;i++){
			if(S[i]==T[j]){
				count++;
				break;
			}
		}
	}
	
	cout << count << endl;
	
	return 0;
}

Measured memory_bytes: 1232
// https://atcoder.jp/contests/abc123/tasks/abc123_b

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    set<int> s;
    int ans = 0;

    for (int i = 0; i < 5; i++) {
        int m, t;
        cin >> m;
        ans += m;
        if (m % 10 != 0) {
            ans += 10 - m % 10;
        }
        t = m % 10;
        if (t > 0) {
            s.insert(t);
        }
    }
    if (s.size() > 0) {
        ans -= 10;
        for (auto x : s) {
            ans += x;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
	map<int, int>ans;
	int now = 2;
	while (now * now <= x) {
		if (x % now == 0) {
			x /= now;
			ans[now]++;
		}
		else now++;
	}
	if (x != 1) ans[x]++;
	return ans;
}

int dp[1005][20005];

signed main() {
	int h, n;
	cin >> h >> n;
	int a[1005], b[1005];
	rep(i, n) {
		cin >> a[i] >> b[i];
	}
	rep(i, n + 1) {
		rep(j, h + 10001) {
			dp[i][j] = INF;
		}
	}
	dp[0][0] = 0;
	for (int i = 1; i <= n; i++) {
		rep(j, h + 10001) {
			if (j < a[i - 1]) dp[i][j] = dp[i - 1][j];
			else dp[i][j] = min(dp[i - 1][j], dp[i][j - a[i - 1]] + b[i - 1]);
		}
	}
	int ans = INF;
	for (int i = h; i < h + 10001; i++) {
		ans = min(ans, dp[n][i]);
	}
	cout <<ans<< endl;

	return 0;
}

Measured memory_bytes: 156672
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#include <math.h>
#define ll long long 
#define PI 3.14159265358979323846
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
using namespace std;



int main() {
    ll count = 0;
    ll N, ans = 1;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    rep(i, N) {
        if (A[i] > 1000000000 || A[i] < -1000000000) count++;
        if (A[i] == 0) {
            cout << "0" << endl;
            return 0;
        }
    }
    if (count > 1) {
        cout << "-1" << endl;
        return 0;
    }
    rep(j, N) {
        ans = A[j] * ans;
        if (ans > 1000000000000000000||ans<-1000000000000000000) {
            cout << "-1" << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
 }


Measured memory_bytes: 4052
#include"bits/stdc++.h"

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


int strr(string s, int n) {
	string ss;
	rep(i, n)ss += s;
	int cnt=0;
	for (int i = 1; i < ss.size(); i++) {
		if (ss[i - 1] == ss[i]) {
			ss[i] = '_';
			cnt++;
		}
	}
	return cnt;
}
int main() {
	string s;
	map<char, int>mp;
	ll k, cnt = 0;
	cin >> s >> k;
	ll slen = s.size();
	for (char c : s)mp[c]++;
	if (mp[s[0]] == slen) {
		cout << (slen * k) / 2 << endl;
		return 0;
	}
	ll dist = strr(s, 2) - strr(s, 1);
	cout << strr(s,1) + dist * (k - 1) << endl;
	return 0;
}


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

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	cout << a * b /2 <<endl;
}

Measured memory_bytes: 256
# AOJ ITP2_8_C: Map: Range Search
# Python3 2018.6.24 bal4u

from bisect import bisect_left, bisect_right, insort_left
dict = {}
keytbl = []
q = int(input())
for i in range(q):
	a = list(input().split())
	ki = a[1]
	if a[0] == '0':
		if ki not in dict:
			insort_left(keytbl, ki)
		dict[ki] = int(a[2])
	elif a[0] == '1':
		print(dict[ki] if ki in dict else 0)
	elif a[0] == '2':
		if ki in dict: dict[ki] = 0
	else:
		L = bisect_left (keytbl, a[1])
		R = bisect_right(keytbl, a[2], L)
		for j in range(L, R):
			if dict[keytbl[j]] > 0: print(keytbl[j], dict[keytbl[j]])



Measured memory_bytes: 38792
#include <stdio.h>

int	 main(void)
{
	int	x,y;

	while(1){
	  scanf("%d%d",&x,&y);
	  
	  if(x == 0 && y ==0)
	    break;

	   if(x <= y)
	    printf("%d %d\n",x,y);
	   else
            printf("%d %d\n",y,x);
	}

	return(0);
}

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

int main() {
	string S;
	cin >> S;
	sort(S.begin(),S.end());
	if(S[0]==S[1]&&S[2]==S[3]&&S[0]!=S[2]) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
ll g(ll x,ll y){
  return moddevide(((x+2)*modncr(x+y+2,y)%mod-y-1+mod)%mod,y+1);
}
int main(){
  // startupcpp();
  // ll test;cin>>test;while(test--){
  ll a,b,c,d,ans=0;
  cin>>a>>b>>c>>d;
  ans=g(c,d);
  if(a)ans-=g(a-1,d);
  if(b)ans-=g(c,b-1);
  if(a&&b)ans+=g(a-1,b-1);
  print((ans+mod)%mod);
  return 0;
}

Measured memory_bytes: 31488
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>
#include <map>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;

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

string s;

void solve(){
  cin >> s;
  int n=s.size();
  int ans=0;
  for(int i=1;i<n;i++){
    if(s[i]==s[i-1]){
      if(s[i]=='0')s[i]='1';
      else s[i]='0';
      ans++;
    }
  }
  cout << ans << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) a.begin(),a.end()
#define INF 1e9

int n,k,q;
int res = INF;
vector<int> a;

void solve(int x){
    vector<int> select;
    priority_queue<int,vector<int>,greater<int>> qu;
    rep(i,n+1){
        if(a[i] < x){
            while(!qu.empty()){
                if((int)qu.size() >= k){
                    select.push_back(qu.top());
                }
                qu.pop();
            }
        }else{
            qu.push(a[i]);
        }
    }
    if((int)select.size() < q) return;
    sort(all(select));
    res = min(res, select[q-1]-select[0]);
}

int main(void){
    cin>>n>>k>>q;
    a.resize(n);
    rep(i,n) cin>>a[i];
    a.push_back(0);
    rep(i,n) solve(a[i]);
    cout<<res<<endl;
    return 0;
}


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

/* I'm too stupid to solve this problem */

using namespace std;
#define PI 3.14159265359
#define eps 1e-7
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
const int INF = 1<<29;
typedef unsigned long long ull;
typedef long long ll;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

string s;

int main(){
	ios_base::sync_with_stdio(false); //Fast I/O
	cin.tie(NULL);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);	

    cin >> s;

    int n=s.length()-2;

    cout << s[0] << n << s[s.length()-1] << endl;
    
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define mkp make_pair
#define no {cout << "-1\n"; return;}

void solve() {
    int n; cin >> n;
    vector <pi> p(n);
    loop(i, n)
        cin >> p[i].F >> p[i].S;
    loop(i, n - 2) {
        if (p[i].F == p[i].S && p[i + 1].F == p[i + 1].S && p[i + 2].F == p[i + 2].S) {
            cout << "Yes"; return;
        }  
    }
    cout << "No";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>

// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #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
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;




int32_t main()
{



     

      int n;
      cin >> n;

      vector<int> v(n);

      for(int i = 0; i < n; i++)cin >> v[i];

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

        int ans = 1;

      for(int i = 0; i < n; i++)
      {
        double b = (double)(1e18)/ans;
        int x = v[i];
        if(x <= b)
        {
          ans *= x;
        }
        else
        {
          cout << -1;
          return 0;
        }
      }

      cout << ans;

    return 0;
}


Measured memory_bytes: 3988
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;

template <typename T> void debug(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void debug(T t, Args... args) { cout<<t<<" "; debug(args...); }

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int n;
int32_t main()
{
    IOS;
    int l,r,d;
    cin>>l>>r>>d;
    int ct=0;
    for(int i=l;i<=r;i++)
        if(i%d==0)
            ct++;
    cout<<ct;
}

Measured memory_bytes: 3596