akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];

    ll ans = 0;
    rep(i, n-1){
        if (a[i] > a[i+1]){
            ans += a[i] - a[i+1];
            a[i+1] = a[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4840
// cand <genesis?>
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const ll base = 7;
const ll N = 1e3 + 9;
const ll inf = 1000100009;
typedef pair<ll,ll> LL;

ll n,k,i,m,x;
bool b[N];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("test.INP", "r", stdin);
    cin>>n>>k;
    while(k--){
        cin>>m;
        for (i=1;i<=m;i++){
            cin>>x;
            b[x] = true;
        }
    }
    ll cnt = 0;
    for (i=1;i<=n;i++) if (!b[i]) cnt++;
    cout<<cnt;
}


Measured memory_bytes: 3656
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    ll ans = 0;
    for(int i=1; i<=n; ++i) {
        if (i%3==0 && i%5==0) continue;
        if (i%3==0) continue;
        if (i%5==0) continue;
        ans+=i;
    }
    ct(ans);
}



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

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


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

int main() {
  int N, M;
  vector<int> load(N);
  cin >> N >> M;

  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;

    load.at(a - 1)++;
    load.at(b - 1)++;
  }

  for (int i = 0; i < N; i++) {
    cout << load.at(i) << endl;
  }
}


Measured memory_bytes: 24960
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000011
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
int main(){
 int n;
  cin>>n;
  int w[n];
  rep(i, n){
    cin>>w[i];}
  
  int ans=10000000;
  for(int i=1;i<n;i++){
    int ss=0;
    int sl=0;
    for(int j=0;j<n;j++){
      if(j<=i){
        ss+=w[j];}
      else{
        sl+=w[j];}
    }
    int ansl=abs(ss-sl);
    ans=min(ans, ansl);
  }
  
  cout<<ans<<endl;
  
  
  
 
}

Measured memory_bytes: 256
N = int(input())
dp = [999999] * (N+1)
dp[0] = 0
for i in range(1, N+1):
    dp[i] = dp[i-1] + 1
    k = 6
    while i - k >= 0:
        dp[i] = min(dp[i], dp[i-k] + 1)
        k *= 6
    k = 9
    while i - k >= 0:
        dp[i] = min(dp[i], dp[i-k] + 1)
        k *= 9
print(dp[N])


Measured memory_bytes: 3828
N = int(input())
A = list(map(int, input().split()))
p = max(A)
q = p//2
r = 10**9+7
ans = 0
for k in range(N):
    if abs(A[k]-q) < r and A[k] != p:
        r = abs(A[k]-q)
        ans = A[k]

print(p,ans)

Measured memory_bytes: 14428
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x);putchar(' ');}
inline void pr2(int x){write(x);putchar('\n');}
const LL mod=1e9+7;
const int MAXN=2005;
LL C[MAXN][MAXN];
LL p1[MAXN][MAXN],p2[MAXN][MAXN];
LL init()
{
	C[0][0]=1;
	for(int i=1;i<=2000;i++)
	{
		C[i][0]=1;
		for(int j=1;j<=i;j++)C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
	for(int i=0;i<=2000;i++)
	{
		p1[i][0]=1;
		for(int j=1;j<=2000;j++)p1[i][j]=(p1[i][j-1]+C[i][j])%mod;
	}
	for(int i=0;i<=2000;i++)
	{
		p2[i][0]=1;
		for(int j=1;j<=2000;j++)p2[i][j]=(p2[i][j-1]+p1[i][j])%mod;
	}
}
int n,m;
void ad(LL &x,LL y){x+=y;if(x>=mod)x-=mod;}
int main()
{
	init();
	n=read();m=read();
	if(!n&&!m)return puts("0"),0;
	LL ans=0;
	for(int t=1;t<=n+1;t++)
		for(int i=1;i<=min(m-1,t-1);i++)
			ad(ans,C[m-1][i]*p2[i-1][t-i-1]%mod);
	ad(ans,n+1);
	pr2(ans);
	return 0;
}


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

#define rep(var, start, end)  for(int var = start; var <= end; ++var)
#define drep(var, start, end) for(int var = start; var >= end; --var)

typedef long long ll;

using namespace std;

int main() {

    ll N;
    vector<ll> t(100000);
    vector<ll> x(100000);
    vector<ll> y(100000);
    ll nx = 0;
    ll ny = 0;
    bool can = true;

    cin >> N;
    rep(i, 1, N) {
        cin >> t[i] >> x[i] >> y[i];
    }

    rep(i, 1, N) {
        ll dif = abs(x[i] - nx) + abs(y[i] - ny);
        if (((dif % 2) == (t[i] % 2)) && dif <= t[i]){
            continue;
        } else {
            can = false;
            break;
        }
    }

    if (can) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 2560
//
// Created by chuan on 2020-04-10.
//

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>

using ll = long long ;

using namespace std;

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

    double r; cin>>r;
    cout<< setprecision(20)<<M_PI*2*r<<endl;

    return 0;
}



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

void solve() {
  int x; cin >> x;
  cout << (x >= 30 ? "Yes" : "No") << endl;
}

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>

int main() {
	long long int sum = 0;
	int n;
	scanf ("%d", &n);
	
	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0 || i % 5 == 0) {
			
		}
		else {
			sum += i;
		}
	}
	printf ("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
int main(){
  string q;
  int a=0,b=0,c=0,d=0;
  for(int i=0;i<4;i++){
    cin>>q;
    if(q=="1") a=1;
    if(q=="4") b=1;
    if(q=="7") c=1;
    if(q=="9") d=1;
  }
  if(a+b+c+d==4) cout<<"YES";
  else cout<<"NO";
  cout<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define print(x) cout << x << endl
#define ll unsigned long long int
using namespace std;
 
int main() {
	int h1,m1,h2,m2,k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	int awoke = ((h2-h1) * 60) + (m2-m1);
	int ans = awoke - k;
	if(ans < 0)
		ans = 0;
	print(ans);
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if(abs(a-c)<=d){
    cout << "Yes" << endl;
  }
  else if(abs(a-b)<=d && abs(b-c)<=d){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

return 0;  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct node{
  int key;
  node *left,*right,*p;
  node(){}
  node(int key):key(key){left=right=p=NULL;};
};
node *root;
void insert(node z){
  node *y=NULL;
  node *x=root;
  while(x!=NULL){
    y=x;
    if(z.key<x->key) x=x->left;
    else x=x->right;
  }
  z.p=y;
  if(y==NULL) root=new node(z);
  else if(z.key<y->key) y->left=new node(z);
  else y->right=new node(z);
}
bool find(int z){
  node *x=root;
  while(x!=NULL){
    if(z==x->key) return true;
    if(z<x->key) x=x->left;
    else x=x->right;
  }
  return false;
}
node *nxt(node *x){
  if(x->left!=NULL) return nxt(x->left);
  return x;
}
void del(node *x){
  //cout<<x->key<<endl;
  node *y=x->p;
  if(x->left==NULL&&x->right==NULL){
    if(y!=NULL&&y->left==x) y->left=NULL;
    if(y!=NULL&&y->right==x) y->right=NULL;
    delete(x);
    return;
  }
  if(x->left==NULL&&x->right!=NULL){
    if(y!=NULL&&y->left==x) y->left=x->right;
    if(y!=NULL&&y->right==x) y->right=x->right;
    x->right->p=y;
    delete(x);
    return;
  }
  if(x->left!=NULL&&x->right==NULL){
    if(y!=NULL&&y->left==x) y->left=x->left;
    if(y!=NULL&&y->right==x) y->right=x->left;
    x->left->p=y;
    delete(x);
    return;
  }
  node *z=nxt(x->right);
  x->key=z->key;
  del(z);
}
void del(int k){
  node *x=root;
  while(x!=NULL){
    if(k==x->key) break;
    if(k<x->key) x=x->left;
    else x=x->right;
  }
  //cout<<k<<" "<<x->key<<endl;
  del(x);
}
void inorderTreeWalk(node *v){
  if(v==NULL) return;
  inorderTreeWalk(v->left);
  cout<<" "<<v->key;
  inorderTreeWalk(v->right);
}
void preorderTreeWalk(node *v){
  if(v==NULL) return;
  cout<<" "<<v->key;
  preorderTreeWalk(v->left);
  preorderTreeWalk(v->right);
}
signed main(){
  int n;
  cin>>n;
  root=NULL;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    //cout<<(root==NULL?-1:root->key)<<endl;
    if(s=="print"){
      inorderTreeWalk(root);
      cout<<endl;
      preorderTreeWalk(root);
      cout<<endl;
      continue;
    }
    int x;
    cin>>x;
    if(s=="insert"){
      insert(node(x));
    }
    if(s=="find"){
      cout<<(find(x)?"yes":"no")<<endl;
    }
    if(s=="delete"){
      del(x);
    }
  }
  return 0;
}



Measured memory_bytes: 21928
# coding: utf-8

S = input()
P = 2019
N = len(S)
num = [0] * P
num[0] = 1
c = 0
ans = 0
dgt = 1
for i in range(N-1, -1, -1):
    c = (c + int(S[i]) * dgt) % P
    dgt *= 10
    dgt %= P
    ans += num[c]
    num[c] += 1
 
print(ans)

Measured memory_bytes: 9160
n = int(input())
v = list(map(int, input().split()))
checklist = [0 for i in range(max(v))]
cnt = 0
for i in range(0, n, 2):
    checklist[v[i] - 1] += 1
    cnt += 1
ans = cnt - (max(checklist))
cnt2 = 0
checklist2 = [0 for i in range(max(v))]
for i in range(1, n, 2):
    checklist2[v[i] - 1] += 1
    cnt2 += 1

checklist.append(0)
checklist2.append(0)

#print(checklist), checklist2

sortchecklist = sorted(checklist)
sortchecklist2 = sorted(checklist2)

e1 = checklist.index(sortchecklist[-1])
e2 = checklist.index(sortchecklist[-2])
o1 = checklist2.index(sortchecklist2[-1])
o2 = checklist2.index(sortchecklist2[-2])
#print(sortchecklist, sortchecklist2)
anse1 = 0
anse2 = 0
anso1 = 0
anso2 = 0

for i in range(0, n, 2):
    if v[i] - 1 != e1:
        anse1 += 1
    if v[i] - 1 != e2:
        anse2 += 1
for i in range(1, n, 2):
    if v[i] - 1 != o1:
        anso1 += 1
    if v[i] - 1!= o2:
        anso2 += 1
#print(e1, e2, o1, o2)
#print(anse1, anse2, anso1, anso2)
if e1 != o1:
    print(anse1 + anso1)
else:
    print(min(anse1 + anso2, anse2 + anso1))



Measured memory_bytes: 14204
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

void main_()
{
    ll K, S;
    cin >> K >> S;

    ll ans = 0;
    for (ll x = 0; x <= K; ++x) {
        for (ll y = 0; y <= K; ++y) {
            auto z = S - x - y;
            if (0 <= z && z <= K) {
                ans++;
            }
        }
    }
    cout << ans << "\n";
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];
double dist(ll i, ll j)
{
    double dx=x[i]-x[j];
    double dy=y[i]-y[j];
    return pow(dx*dx+dy*dy,0.5);
}

int main()
{
    ll n,k,q,i,j,cc=0;
    cin>>n>>k>>q;
    ll ara[n+1];
    for(i=1;i<=n;i++){
        ara[i]=k-q;
    }
    while(q--){
        cin>>j;
        ara[j]+=1;
    }
    for(i=1;i<=n;i++){
        if(ara[i]>0)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}


Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
void Main(){
    int N;cin>>N;
    vector<int> S(N);
    For(i,0,N) cin>>S[i];
    sort(S.begin(),S.end());
    int ans=0;
    For(i,0,N){
        ans+=S[i];
    }
    if(ans%10){
        cout<<ans<<endl;
    }
    else{
        bool flag=true;
        For(i,0,N){
            if(S[i]%10){
                flag=false;
                ans-=S[i];
                break;
            }
        }
        cout<<(flag?0:ans)<<endl;
    }
}
int main(){
    Main();
    return 0;
}

Measured memory_bytes: 256
n, a, b, c = map(int, input().split())
T = [a, b, c]
L = [int(input()) for _ in range(n)]

import itertools
ans = 10**18
for p in itertools.product(range(4), repeat=n):
    C = [0]*3
    temp = [0]*3
    for i in range(n):
        if p[i] == 3:
            continue
        C[p[i]] += 1
        temp[p[i]] += L[i]
    flag = True
    for i in range(3):
        if C[i] == 0:
            flag = False
            break
    if not flag:
        continue
    mp = 0
    for i in range(3):
        mp += 10*(C[i]-1)
        mp += abs(temp[i]-T[i])
    ans = min(ans, mp)
print(ans)


Measured memory_bytes: 74296
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int slen = S.length();
    REP(i,slen){
        if(i%2 == 0){
            if(S[i] == 'L'){
                cout << "No" << endl;
                return 0;
            }
        }else{
            if(S[i] == 'R'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;

}


Measured memory_bytes: 256
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

aa = inputs[0][0] / 100
bb = inputs[0][0] % 100

# body
if $debugFlag
  puts aa
  puts bb
end

if aa >=1 and aa <= 12
  if bb >=1 and bb <= 12
    ans = 'AMBIGUOUS'
  else
    ans = 'MMYY'
  end
else
  if bb >=1 and bb <= 12
    ans = 'YYMM'
  else
    ans = 'NA'
  end  
end

puts ans

#YYMM, MMYY, AMBIGUOUS, NA 


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
const ll INF = 1LL << 60;
#define MOD 1000000007
#define MAX_V 100010
#define MAX_N 100010

bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}

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

ll junnretu(ll n){
    ll ans=1;
    for (ll i=1;i<=n;i++){
        ans*=i;
    }
    return ans;
}

int main(){
    ll ans=0;
    string s;
    cin >> s;
    ll c=0;
    for (ll i=0;i<s.size();i++){
        if (s[i]=='A' || s[i]=='T' || s[i]=='C' || s[i]=='G'){
            c++;
        }else{
            ans=max(c,ans);
            c=0;
        }
    }
    ans=max(c,ans);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
ll n,K;
ll a[105];
ll dp[105][100001];
ll pre[100001];
int main(){FAST;
cin>>n>>K;
for(ll i=1;i<=n;++i)cin>>a[i];
dp[0][0] = 1;
for(ll j=0;j<=K;++j){
  pre[j] = dp[0][j]+((j)?pre[j-1]:0);
  pre[j] %= MOD;
}
for(ll i=1;i<=n;++i){
  for(ll j=0;j<=K;++j){
    ll L = max(j-a[i],0LL);
    ll R = j;
    ll ways = pre[R]-((L)?pre[L-1]:0)+MOD;
    ways %= MOD;
    dp[i][j] = ways;
    dp[i][j] %= MOD;
  }
  for(ll j=0;j<=K;++j){
    pre[j] = dp[i][j]+((j)?pre[j-1]:0);
    pre[j] %= MOD;
  }
}
// for(ll i=0;i<=n;++i){
//   for(ll j=0;j<=K;++j){
//     cout<<dp[i][j]<<' ';
//   }
//   cout<<'\n';
// }
cout<<dp[n][K];
return 0;
}

/*
 WA? check edge cases, N=1,M=1 etc. Read code fully once and check all variables.
 Read the question again and see what you might have missed.
 Consider changing your solution or find more cases.
 */


Measured memory_bytes: 82536
import itertools

N = int(input())
S = input() + '#'

ans = 0
for comb in itertools.product('0123456789', repeat=3):
    found = 0
    for s in S:
        if found == 3:
            ans += 1
            break
        elif s == comb[found]:
            found += 1

print(ans)


Measured memory_bytes: 41052
class Dice:
    def __init__(self, dice):
        self.dice = dice
        self.face = {'head':1, 'tail':4, 'left':3, 'right':2, 'above':0, 'below':5}
    
    def roll(self, ch):
        dice = self.dice
        face = self.face
        if ch == 'S':
            tmp = dice[face['head']]
            dice[face['head']] = dice[face['above']]
            dice[face['above']] = dice[face['tail']]
            dice[face['tail']] = dice[face['below']]
            dice[face['below']] = tmp
        elif ch == 'N':
            tmp = dice[face['head']]
            dice[face['head']] = dice[face['below']]
            dice[face['below']] = dice[face['tail']]
            dice[face['tail']] = dice[face['above']]
            dice[face['above']] = tmp
        elif ch == 'W':
            tmp = dice[face['left']]
            dice[face['left']] = dice[face['above']]
            dice[face['above']] = dice[face['right']]
            dice[face['right']] = dice[face['below']]
            dice[face['below']] = tmp
        else:
            tmp = dice[face['left']]
            dice[face['left']] = dice[face['below']]
            dice[face['below']] = dice[face['right']]
            dice[face['right']] = dice[face['above']]
            dice[face['above']] = tmp

    def top(self):
        dice = self.dice
        face = self.face
        return dice[face['above']]
    
    def find_right(self, a, b):
        dice = self.dice
        face = self.face
        order = 'NNNNWNNNWNNNENNNENNNWNNN'
        for ch in order:
            self.roll(ch)
            if dice[face['above']] == a and dice[face['head']] == b:
                break
        return dice[face['right']]

dice = Dice([*map(int, input().split())])
q = int(input())
while q > 0:
    q -= 1
    a, b = map(int, input().split())
    print(dice.find_right(a, b))


Measured memory_bytes: 5612
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,k = list(map(int,readline().split()))
h = np.array(read().split(),dtype=np.int32)
dp = np.zeros(n,dtype=np.int32)

for i in range(1,n):

    l = max(i-k,0)
    dp[i] = np.min(np.abs(h[i]-h[l:i])+dp[l:i])

print(dp[-1])


Measured memory_bytes: 17944
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	string s; cin>>s;
	int n=s.size();
	rep(i,0,n){
		if(s[i]=='9'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 3576
#include<iostream>
#include<string.h>
#define LL long long
using namespace std;
const int maxn=1e5+10;
int n;
char a[maxn];
int main()
{
    while(scanf("%s",a)!=EOF)
    {
        int ans=0;
        int len=strlen(a);
        for(int i=1; i<len-1; i++)
            if(a[i-1]!=a[i+1])
			 ans++;
        if(ans==0)
        {
            printf("Second\n");
            continue;
        }
        if(a[0]!=a[len-1])
		  {
		    if(len%2==1)
			printf("%s\n","First");
			else
			printf("%s\n","Second");
		  	
		  }
	  else if(len%2==1)
			printf("%s\n","Second");
			else
			printf("%s\n","First");	
    }
    return 0;
}

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

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

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    
    if(s[k - 1] == 'A') s[k-1] = 'a';
    if(s[k - 1] == 'B') s[k-1] = 'b';
    if(s[k - 1] == 'C') s[k-1] = 'c';
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
/*
	f(v, v', k):- min f(v, v',k - 1) + e(v, v'), 

*/
#include <bits/stdc++.h>

using namespace std;

const int INF = (1 << 30) - 1;
const int mxv = 16;
int V, E;
int adj[mxv][mxv], dp[( 1 << mxv )][mxv], a, b, c;


int tsp( int v, int bitmask ){

	if( bitmask == ( 1 << V ) - 1 )
		return adj[v][0];

	if( dp[bitmask][v] < INF )
		return dp[bitmask][v];	

	for( int i = 0; i < V; ++i )
		if( !(bitmask & ( 1 << i ) ) )
			dp[bitmask][v] = min( dp[bitmask][v], adj[v][i] + tsp( i, bitmask|( 1 << i ) ) );
	return dp[bitmask][v];
}




int main( void ){
	
	//freopen("input.in", "r", stdin);
	scanf("%d%d", &V, &E);

	for( int i = 0; i < V; ++i )
		for( int j = 0; j < V; ++j )
			adj[i][j] = INF;

	for( int i = 0; i < ( 1 << V ); ++i )
		for( int j = 0; j < V; ++j )
			dp[i][j] = INF;

	for( int i = 0; i < E; ++i )
		scanf("%d%d%d", &a, &b, &c), adj[a][b] = c;
	
	dp[1][0] = 0;
	for( int i = 1; i < ( 1 << V ); ++i )
		for( int j = 0; j < V; ++j ){
			if( !(i & ( 1 << j )) )
				continue;
			for( int k = 0; k < V; ++k ){
				if( i & ( 1 << k ) )
					continue;
				dp[i| ( 1 << k )][k] = min( dp[i| ( 1 << k )][k], dp[i][j] + adj[j][k]); 
			}
		}

	int solve = INF;
	for( int i = 1; i < V; ++i )
		solve = min( solve, dp[( 1 << V ) - 1][i] + adj[i][0]);
	
	printf("%d\n", ( solve == INF)?-1:solve);
	
	return 0;
}

Measured memory_bytes: 5280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>
#include <queue>
 
#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;
 
using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }

int main() {
  //std::cout << std::fixed << std::setprecision(10);
  ull n, k;
  cin >> n >> k;

  vector<ull> h;
  each(i, n) {
    ull tmp;
    cin >> tmp;
    h.push(tmp);
  }
  sort_asc(h);

  ull result = INF;
  for (ull i=0; (i+k-1) < n; i++) {
    ull diff = h[i + k - 1] - h[i];
    result = min({result, diff});
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 1400
main = interact $ unlines . map (show . rate_changed . map read . words) . init . lines

rate_changed [x,y,s] = maximum [tax y s1 + tax y s2 | s1<-[1..(s'-1)], s2<-[(s'-s1-1)..(s'-s1+1)] , s2 > 0, tax x s1 + tax x s2 == s]
 where
  s' = tax' x s 
  tax r n = floor $ fromIntegral n * (100.0 + fromIntegral r) / 100.0
  tax' r n = ceiling $ fromIntegral n / (100.0 + fromIntegral r) * 100.0

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

int main(){
    cin >> X;
    int i = 0;
    ll x = 100;
    while(x < X){
        x *= 1.01;
        ++i;
    }
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#include <string>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;

#define rep(i, n) for(int i = 0; i < n ; i++ )
#define For(i, a, b) for(int i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

int main(void){
    int a[5];
    int answer = 0;
    int min_time = 9;
    int idx = 0;

    rep(i, 5){
        cin >> a[i];
        int ad = a[i] % 10;
        if (ad >= 1 && ad <= 9){
            if (min_time > ad){
                idx = i;
                min_time = ad;
            }
        }
    }

    
    rep(i, 5){
        int ad = a[i] % 10;
        if (a[i] % 10 != 0 && i != idx){
            answer += a[i] + (10 - ad);
        }else{
            answer += a[i];
        }
    }

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
#include<queue>
using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> adj[n]; // 隣接リスト
    vector<int> sirusi(n, -1); // i番目の部屋の道しるべ。
    vector<bool> isVisit(n, false);

    int a, b;
    for(int i=0;i<m;i++){
        cin >> a >> b;
        adj[a-1].push_back(b-1);
        adj[b-1].push_back(a-1);
    }

    // 幅優先探索
    queue<int> q;

    for(int i=0;i<n;i++){
        if(!isVisit[i]){
            q.push(i);
            while(!q.empty()){
                int v = q.front();
                q.pop();
                isVisit[v] = true;
                for(int j=0;j<adj[v].size();j++){
                    //cout << adj[v].size() << "サイズ" << endl;
                    if(!isVisit[adj[v][j]]){
                        q.push(adj[v][j]);
                        sirusi[adj[v][j]] = v+1;
                        isVisit[adj[v][j]] = true;
                    }
                }
            }
        }
    }

    printf("Yes\n");
    for(int i=1;i<n;i++){
        printf("%d\n", sirusi[i]);
    }
}


Measured memory_bytes: 10224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  
  cin >> N ;
   
 int d;
  
 int q=0;
  
 int qmin=1000;
 
  int i;
  
  for(i=0 ; i<N ; i++){

    cin >> d;
    
    q=0;
    
    while(d%2==0){d=d/2; q++;}
    
    if(q<qmin){qmin = q;}
    
    
  }
 
	cout << qmin << endl;

}


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

bool dp[5000][5000];

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

    
    ll n,k,s;
    cin>>n>>k>>s;
    ll INF = 1e9;
    if(s != INF){
        for(int i=0;i<k;i++){
            cout << s << " ";
            n--;
        }
        for(int i=0;i<n;i++){
            cout << INF << " ";
        }
        cout << endl;
        return 0;
    }
    for(int i=0;i<k;i++){
        cout << INF <<" ";
        n--;
    }
    for(int i=0;i<n;i++){
        cout << 1 << " ";
    }
    cout << endl;
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int g[15][15];

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

    REP(i, N){
        REP(j, N){
            g[i][j] = -1;
        }
    }

    REP(i, N){
        int m;
        cin >> m;
        REP(j, m){
            int a, x;
            cin >> a >> x;
            --a;
            g[i][a] = x;
        }
    }

    int ans = 0;
    REP(i, 1 << N){
        vector<int> d(N);
        REP(j, N){
            if (i >> j&1){
                d[j] = 1;
            }
        }
        bool ok = true;
        REP(j, N){
            if(d[j]){
                REP(k, N){
                    if(g[j][k] == -1) continue;
                    if(g[j][k] != d[k]) ok = false;
                }
            }
        }
        if (ok) {
            ans = max(ans, __builtin_popcount(i));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define maxn 100500
int prime[maxn],si;
bool notprime[maxn];
int main(){
	int x;scanf("%d",&x);
	for(int i=2;;i++){
		if(!notprime[i]){
			if(i>=x)return printf("%d",i),0;
			prime[si++]=i;
		}
		for(int j=0;j<si;j++){
			if(1ll*i*prime[j]>=maxn)break;
			notprime[i*prime[j]]=1;
			if(i%prime[j]==0)break;
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
#define MSG(a) cout << #a << " " << a << "\n";

int main(){
    int N,ans=0,count=0; cin >> N;
    vint H(N); REP(i,N) cin >> H.at(i);
    REP(i,N-1){
        if(H.at(i+1) <= H.at(i)){
            count++;
        }else{
            ans = max(ans,count);
            count = 0;

        }
        
    }
    ans = max(ans,count);

    cout << ans <<endl;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using Grid = vector<vector<char>>;
using PQueue = priority_queue<
    tuple<int, int, int>,
    vector<tuple<int, int, int>>,
    greater<tuple<int, int, int>>>;

int main()
{
    int H, W;
    cin >> H >> W;
    Grid grid(H, vector<char>(W, 0));
    int Ch, Cw;
    cin >> Ch >> Cw;
    --Ch; --Cw;
    int Dh, Dw;
    cin >> Dh >> Dw;
    --Dh; --Dw;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> grid[i][j];
        }
    }
    vector<vector<int>> cost(H, vector<int>(W, -1));
    PQueue p_que;
    p_que.push({0, Ch, Cw});
    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};
    int cost_hw, h, w;
    while (!p_que.empty()) {
        auto tpl = p_que.top(); p_que.pop();
        tie(cost_hw, h, w) = tpl;
        for (int i = 0; i < 4; ++i) {
            int nh = h + dx[i];
            int nw = w + dy[i];
            int cost_nhnw = cost_hw;
            if (nh < 0 || H <= nh || nw < 0 || W <= nw)
                continue;
            if (grid[nh][nw] == '#')
                continue;
            if (cost[nh][nw] == -1 || cost[nh][nw] > cost_nhnw) {
                cost[nh][nw] = cost_nhnw;
                p_que.push({cost_nhnw, nh, nw});
            }
        }
        for (int dh = -2; dh < 3; ++dh) {
            for (int dw = -2; dw < 3; ++dw) {
                int nh = h + dh;
                int nw = w + dw;
                if (nh < 0 || H <= nh || nw < 0 || W <= nw)
                    continue;
                if (grid[nh][nw] == '#')
                    continue;
                int cost_nhnw = cost_hw + 1;
                if (cost[nh][nw] == -1 || cost[nh][nw] > cost_nhnw) {
                    cost[nh][nw] = cost_nhnw;
                    p_que.push({cost_nhnw, nh, nw});
                }
            }
        }
    }
    cout << cost[Dh][Dw] << endl;
}


Measured memory_bytes: 8600
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

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

    int N;
    cin >> N;
    tuple<int, int, int> ma(0, 0, 0);
    vi a(N);
    rep(i, N) {
        cin >> a[i];
        smax(ma, mt(abs(a[i]), a[i], i));
    }

    int ab, val, id;
    tie(ab, val, id) = ma;
    if (ab == 0) {
        cout << 0 << endl;
    } else{
        cout << 2 * N << endl;
        vector<pii> ans;
        if (val < 0) {
            rep(i, 2)ans.emplace_back(id + 1, N);
            for (int i = N; i >= 2; --i) {
                rep(j, 2)ans.emplace_back(i, i - 1);
            }
        } else {
            rep(i, 2)ans.emplace_back(id + 1, 1);
            for (int i = 1; i <= N - 1; ++i) {
                rep(j,2)ans.emplace_back(i, i + 1);
            }
        }
        each(p, ans)cout << p.first << ' ' << p.second << endl;
    }
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        n: usize,
        s_vec: [String; n],
    }

    let mut map: HashMap<String, usize> = HashMap::new();
    

    for i in 0..n {
        *map.entry(s_vec[i].clone()).or_insert(0) += 1;
    }

    let max = map.values().max().unwrap();

    let mut ans_vec = map.iter().filter(|x| x.1 == max).map(|x| x.0.to_string()).collect::<Vec<String>>();
    ans_vec.sort();
    for ans in ans_vec.into_iter() {
        println!("{}", ans)
    }
}


Measured memory_bytes: 43380
#include <algorithm>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e8;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n, k, s;
  while (cin >> n >> k >> s) {
    if (n == 0 && k == 0 && s == 0) break;
    int ans = 0;
    loop(i, 1, (1 << n)) {
      int sum = 0, bit = 0;
      loop(j, 1, n + 1) {
        if (i & (1 << (j - 1))) {
          bit++;
          sum += j;
        }
      }
      if (bit != k) continue;
      if (sum == s) ans++;
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3080
a, b = map(int,input().split())
t = []
for _ in range(int(input())):
    t += list(map(int, input().split()))
print(1 if sum(i <= a for i in t) % 2 or sum(i >= b for i in t) % 2 or sum(a < i and i < b for i in t) else 0)


Measured memory_bytes: 5604
#include <bits/stdc++.h> 
using namespace std; 
  
int main() 
{ 
	long long int n;
	cin>>n;
    string str,s; cin>>str;
    //sort(str.begin(), str.end()); 
  
 
    auto res = unique(str.begin(), str.end()); 
  
    /*cout << string(str.begin(), res) 
         << endl; */
      // cout<<res.size()<<endl;
      s=string(str.begin(), res);
    //  cout<<s<<endl;
      cout<<s.size()<<endl;
      return 0;
} 

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
ll N;
ll a[200001];
ll ans = 0;
ll temparr[200001];
void mergesort(ll left, ll right){
  if(right - left <= 1)
    return;
  ll mid = (left + right+1) / 2;
  mergesort(left, mid);
  mergesort(mid,right);
  ll id1 = left;
  ll id2 = mid;
  ll cnt = 0;
  for(ll i = left; i < right; i++){
    if(id1 == mid){
      temparr[i] = a[id2];
      id2++;
    }else if(id2 == right){
      temparr[i] = a[id1];
      id1++;
    }else{
      if(a[id1] < a[id2]){
	temparr[i] = a[id1];
	id1++;
      }else{
	temparr[i] = a[id2];
	cnt += (mid -  id1);
	id2++;
      }
    }
  }
  for(ll i = left; i < right; i++){
    a[i] = temparr[i];
  }

  //  cout << left << ' ' << right << ' ' << cnt << endl;
     
  ans += cnt;
}
int main(){
  cin >> N;
  for(ll i = 0; i < N; i++){
    cin >> a[i];
  }

  mergesort(0, N);

  cout << ans << endl;
}

Measured memory_bytes: 6200
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
int n;
  cin>>n;
  if(n%10==7 || (n/10)%10==7 || (n/100)%10==7)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 3616
//by Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<s32>
#define p32 pair<int,int>
#define p64 pair<ll,ll>
#define fi first
#define se second
#define ln '\n'
#define debug(x) cout << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream& operator<<(ostream& out, const pair<T,U>& p){
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename ...Args>
void print_container(const ContainerType<ValueType, Args...>& c){
	cout << "{ ";
	for(const auto& v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

int main()
{
	FASTIO;
	int a,b;
	cin >> a >> b;
	cout << ceil((b - 1) / (1.0 * (a - 1))) << ln;
	return 0;
}


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

typedef long long ll;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)


int main()
{
    optimize();
    long double r;
    cin>> r;
    cout<< fixed<< setprecision(20);
    cout<< 2*r*3.1416;
    nl;


    return 0;
}



Measured memory_bytes: 3820
import math
def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    
    return table

N = int(input())
table = num_divisors_table(N)

res = 0

for c in range(N)[1:]:
  res += table[N-c]

print(res)

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

typedef long long ll;
using namespace std;
int main()
{

  ll n,s[110];
  ll max=0;
  cin>>n;
  rep(i,n){
    cin>>s[i];
    max+=s[i];
  }

  if(max%10!=0){
    cout<<max<<endl;
    return 0;
  }

  sort(s,s+n);
  rep(i,n){
    if(s[i]%10!=0){
      cout<<max-s[i]<<endl;
      return 0;
    }
  }

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


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
	pair<ll,ll> a[100000];
	static unsigned ll N,M;
	static unsigned ll c,d;
	static unsigned ll ans=0;

	cin>>N>>M;
	for(ll i=0;i<N;i++){
		cin>>c>>d;
		a[i]=make_pair(c,d);
	}
	
	sort(a,a+N);

	ll i=0;

	while(M){
		if(a[i].second>=M){
			ans+=a[i].first*M;
			M=0;
		}else{
			ans+=a[i].first*a[i].second;
			M-=a[i].second;
		}
		i++;
	}

	cout<<ans<<endl;
	
}


Measured memory_bytes: 1792
#define ALL(obj) (obj).begin(), (obj).end()

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>

using namespace std;
typedef long long ll;
const ll INF = 1e18;

string S;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> S;
    for (ll i=0; i<S.length(); i++) {
        cout << 'x';
    }
    
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
N=int(input())
TTBL=[list(map(int,input().split())) for i in range(N-1)]
def GT(k,t):
  c,s,f=TTBL[k][0],TTBL[k][1],TTBL[k][2]
  return s+max(0,t-s+(f-1))//f*f+c
for i in range(N-1):
  ret = 0
  for j in range(i,N-1):
    ret=GT(j,ret)
  print(ret)
print(0)

Measured memory_bytes: 3188
from itertools import *

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

total = 0
minim = 1000000000
num_negs = 0

for a in An:
    if a < 0:
        num_negs += 1
        a *= -1
        pass
    total += a
    minim = min(minim, a)
    pass

if num_negs % 2:
    print(total - 2*minim)
else:
    print(total)
    pass


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

int main(){
  int m;
  int n,a,cnt;
  m =0 , n=0, a=0, cnt =0;
  while(1){
    cin >> m;
    if(m == 0) break;
    cin >> n;
 
    for(int i=m;i<=n;i++){
      a = i;
      
      while(a % 2 ==0) a = a / 2;
      while(a % 3 ==0) a = a / 3;
      while(a % 5 ==0) a = a / 5;

      if(a == 1) cnt++;
    }


    cout << cnt << endl;
    cnt =0;

  }



}



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

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

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

  string a, b, c;
  cin >> a >> b >> c;

  cout << (char)toupper(a.at(0));
  cout << (char)toupper(b.at(0));
  cout << (char)toupper(c.at(0)) << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(s) for s in input().split()]
memory = []
flag = False
for i in range(n):
    if a[i] > 0:
        if a[i] in memory:
            print(i+1)
            flag = True
            break
        else:
            memory.append(a[i])
    else:
        if len(memory) > 0 and memory[-1] == abs(a[i]):
            memory.pop()
        else:
            print(i+1)
            flag = True
            break

if flag == False:
    print("OK")



Measured memory_bytes: 5620