akhauriyash/Code-Regression huggingface dataset:
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)

#define yes puts("YES")
#define no puts("NO")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

set<char> s;

signed main(){

    char c;
    rep(i,4) {
        in(c);
        s.insert(c);
    }
    if(s.find('1')!=s.end()&&
    s.find('9')!=s.end()&&
    s.find('7')!=s.end()&&
    s.find('4')!=s.end()){
        yes;
    }else no;

    return 0;
}


Measured memory_bytes: 888
#include<iostream>

using namespace std;

int main()
{
  int A,B,ret = 0;
  int now = 1;
  
  cin >> A >> B;
  
  while(now < B)
  {
  	now = now - 1 + A;
  	ret ++;
  }
  cout << ret;
  
  return 0;
}
  

Measured memory_bytes: 256
import math
a, b, x = map(int, input().split())
temp = a*a*b
if temp//2 >= x:
    
    h = 2*x/(a*b)
    c = math.atan2(1, h/b)
    print(math.degrees(c))
else:
    k = temp-x
    h = 2*k/(a*a)
    c = math.atan2(1, h/a)
    print(90-math.degrees(c))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
template<class T>inline void init(T&x){
	x=0;char ch=getchar();bool t=0;
	for(;ch>'9'||ch<'0';ch=getchar()) if(ch=='-') t=1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+(ch-48);
	if(t) x=-x;return;
}
const int N=2e6+10,mod=1e9+7;
typedef long long ll;
int A[N];
template<class T>inline int fpow(int x,T k){int ret=1;for(;k;k>>=1,x=(ll)x*x%mod)if(k&1) ret=(ll)ret*x%mod;return ret;}
template<class T>inline void Inc(T&x,int y){x+=y;if(x>=mod) x-=mod;}
template<class T>inline void Dec(T&x,int y){x-=y;if(x < 0 ) x+=mod;}
int n,f[N],inv[N];
int main()
{
	init(n);f[0]=0;f[1]=1,inv[1]=1;
	init(A[1]);int S=1;
	int fac=1;
	for(int i=2;i<=n;++i) {
		init(A[i]);inv[i]=(ll)(mod-mod/i)*inv[mod%i]%mod;
		f[i]=((ll)S*inv[i]+1)%mod;Inc(S,f[i]);
		fac=(ll)fac*i%mod;
	}
	int ans=0;
	for(int i=1;i<=n;++i) Inc(ans,(ll)(f[i]+f[n-i+1]-1)*A[i]%mod);
	printf("%lld\n" ,(ll)ans*fac%mod);
	//printf("%d\n",ans);
}


Measured memory_bytes: 6784
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
	int a, b, c;
	scanf("%d", &a);
	scanf("%d", &b); 
	if (a>b) {
		printf("%d\n", a-b);
	}
	else {
		printf("0\n");
	}
}

Measured memory_bytes: 128
n = int(input())
nk = list(map(int,input().split(' ')))

#print(n,nk)
p = []
p1 = []
dp = [0]*n
for i in range(0,n-1):
  p.append(abs(nk[i]-nk[i+1]))

for i in range(0,n-2):
  p1.append(abs(nk[i]-nk[i+2]))

dp[1]=p[0]

for i in range(2,n):
    dp[i] = min((dp[i-1] + p[i-1]),(dp[i-2] + p1[i-2]))
           
#print(p,p1)
print(dp[-1])

Measured memory_bytes: 18952
#include "bits/stdc++.h"
using namespace std;

#define show(x) cerr << #x << " = " << x << endl ;
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define output_to_error freopen("error.txt" , "w" ,stderr)
#define fastio ios_base::sync_with_stdio(0)
#define endl '\n'

const int N = 2e6 + 5;
const int mod = 1e9 + 7;
int fact[N], ifact[N];

int pwr(int a,int b) {
	int ans = 1;
	while(b) {
		if(b & 1) {
			ans = (ans * 1LL * a) % mod;
		}
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

int ncr(int a,int b) {
	if(a < b || b < 0) return 0;
	int ans = (fact[a] * 1LL * ifact[b]) % mod;
	return (ans * 1LL * ifact[a - b]) % mod;
}

int f(int r,int c) {
	if(r < 0 || c < 0) return 0;
	int ans = 0;
	for(int i = 0; i <= c; i++) {
		ans += ncr(r + 1 + i, i + 1);
		ans %= mod;
	}
	return ans;
}

int main()
{
	#ifdef LOCAL
        input_from_file;
        output_to_file;
        output_to_error;
    #endif
	fastio;cin.tie(0);cout.tie(0);
	fact[0] = 1;
	for(int i = 1; i < N; i++) {
		fact[i] = (i * 1LL * fact[i - 1]) % mod;
	}
	ifact[N - 1] = pwr(fact[N - 1], mod - 2);
	for(int i = N - 2; i >= 0; i--) {
		ifact[i] = (ifact[i + 1] * 1LL * (i + 1)) % mod;
	}
	int r1 , c1 , r2 , c2 ;
	cin >> r1 >> c1 >> r2 >> c2;
	int ans = f(r2, c2);
	ans -= f(r2, c1 - 1);
	if(ans < 0) ans += mod;
	ans -= f(r1 - 1, c2);
	if(ans < 0) ans += mod;
	ans += f(r1 - 1, c1 - 1);
	if(ans >= mod) ans -= mod;
	cout << ans;
	return 0;
}


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

namespace patch {
  template < typename T > std::string to_string( const T& n )
  {
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
  }
}
ll mypow(int n, int times) {
  ll t = 1;
  while(times > 0) {
    t = t*n;
    times--;
  }
  return t;
}
int main() {
  ll n;
  cin >> n;
  string s;

  int count = 1;
  ll maxi_range=1,mini_range=0;
  while(n > maxi_range || n < mini_range) {
    ++count;
    if(count % 2 == 0) {
      mini_range -= mypow(2,(count-1));
    }
    else {
      maxi_range += mypow(2,(count-1));
    }
  }
  // count ->s.size();

  ll current_maxi_range = maxi_range, current_mini_range = mini_range;
  if(count % 2 == 0) {
    current_maxi_range = current_mini_range + mypow(2,count-1)-1;
  }
  else {
    current_mini_range = current_maxi_range - mypow(2,count-1)+1;
  }


  while(count > 0) {
    if(n <= current_maxi_range && n >= current_mini_range) {
      s.push_back('1');
      if(count%2 == 0) {
	n += mypow(2,count-1);
      }
      else {
	n -= mypow(2,count-1);
      }

    }
    else {
      s.push_back('0');
    }
    if(count % 2 == 0) {
      //current_mini_range += mini_range + mypow(2,count-1);
      //current_maxi_range = current_mini_range + mypow(2,count-1)-1;
      current_maxi_range = maxi_range;
      mini_range += mypow(2,count-1);
      current_mini_range = current_maxi_range - mypow(2,count-2) + 1;
    }
    else {
      //current_maxi_range -= maxi_range - mypow(2,count-1);
      //current_mini_range = current_maxi_range - mypow(2,count-1)+1;
      current_mini_range = mini_range;
      maxi_range -= mypow(2,count-1);
      current_maxi_range = current_mini_range + mypow(2,count-2) -1;
    }
    count--;
  }
  cout << s << endl;
  return 0;
}

  /* s.size() = 1 -> 1,0
   * 2 -> -1,-2
   * 3-> 2,3,4,5
   * 4 -> -3,..,-10
   */





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

int n;
std::vector<std::string> w;
std::unordered_map<std::string, int> um;

void input()
{
    std::cin>>n;
    w.resize(n);
    for(int i=0;i<n;i++){
        std::string s;
        std::cin>>s;
        w[i] = s;
        um[s]++;
    }

}


int main()
{
    input();
    bool res = true;
    //同じもの
    for(int i=0;i<n;i++)if(um[w[i]]>1)res = false;
    //はじめと後ろ
    for(int i=1;i<n;i++){
        if(*w[i].begin()!=*(w[i-1].end()-1))res = false;
    }
    std::cout<<(res ? "Yes" : "No")<<std::endl;
}

Measured memory_bytes: 256
//cf.cpp
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <vector>
#include <string.h>
#include <cstring>
#include <queue>
#include <math.h>
#include <stack>
#include <bitset>
#include <utility>
#define mp make_pair
#define pb push_back
#define llc (long long)
#define pob pop_back
#define pm %1000000007
using namespace std;

bool comp(long long x, long long y){
	return x>y;
}
int main(){
	int cuf;
	int m=0, k;
	vector <int> d, c;
	vector <int> dl, cl;
	queue <int> csa;
	long long tot=0;
	int n, q;
	cin>>n;
	getchar();
	long long ans;
	for(int i = 0;i < n;i ++){
		switch(getchar()){
			case 'D':
			d.pb(i);
			dl.pb(m);
			break;
			case 'M':
			m++;
			break;
			case 'C':
			c.pb(i);
			cl.pb(m);
			break;
		}
	}
	cin>>q;
	while(q--){
		while(!csa.empty())csa.pop();
		cin>>k;
		ans=0;
		tot=0;
		for(int i = 0;i < c.size();i ++){
			if(d[0]+k<=c[i]){
				cuf=i;
				break;
			}
			if(d[0]<c[i]){
				csa.push(i);
				tot+=cl[i];
			}
			if(i+1==c.size()){
				cuf=c.size();
			}
		}
		ans+=tot-llc dl[0]*csa.size();
		for(int i = 1;i < d.size();i ++){
			for(int j = cuf;j < c.size();j ++){
				if(d[i]+k<=c[j]){
					cuf=j;
					break;
				}
				if(d[i]<c[j]){
					csa.push(j);
					tot+=cl[j];
				}
				if(j+1==c.size()){
					cuf=c.size();
				}
			}
			while(!csa.empty()){
				if(d[i]>c[csa.front()]){
					tot-=cl[csa.front()];
					csa.pop();
				}else{
					break;
				}
			}
			ans+=tot-llc dl[i]*csa.size();
		}
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 12252
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 08/15/20 20:19:02
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int r,c,k; cin>>r>>c>>k;
  vector<vector<int>> item(r, vector<int>(c, 0));
  for (int i = 0; i < k; i++) {
    int rr,cc,v; cin>>rr>>cc>>v; rr--; cc--;
    item[rr][cc] = v;
  }
  vector<vector<array<ll,4>>> dp(r, vector<array<ll,4>>(c, {0,0,0,0}));
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      auto it = item[i][j];
      if (it > 0) {
        for (int s = 2; s >= 0; s--) {
          dp[i][j][s+1] = max(dp[i][j][s+1], dp[i][j][s]+it);
        }
      }
      for (int s = 3; s >= 0; s--) {
        auto& cdp = dp[i][j][s];
        if (i+1 < r) {
          dp[i+1][j][0] = max(dp[i+1][j][0], cdp);
        }
        if (j+1 < c) {
          dp[i][j+1][s] = max(dp[i][j+1][s], cdp);
        }
      }
    }
  }
  ll ans = 0;
  for (int s = 0; s <= 3; s++) {
    ans = max(ans, dp[r-1][c-1][s]);
  }
  cout << ans << endl;

  return 0;
}


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

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


int main(void){

    ll n;
    cin >> n;
    ll k;
    cin >> k;

    int cnt = 0;
    ll t = n; 
    while (t)
    {
        t /= k;
        cnt++;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

S=list(input().rstrip('\n'))
N=len(S)
n = 'R'
change = []
for i in range(1,N):
  if S[i] != n:
    change.append(i)
    n = S[i]

now = 0
last = 0
res = [0]*N
for i in range(len(change)):
  if now==0:
    if i == len(change)-1:
      L=N-change[i]
    else:
      L = change[i+1]-change[i]
    R = change[i]-last
    if (L+R)%2==0:
      res[change[i]]=(L+R)//2
      res[change[i]-1]=(L+R)//2
    else:
      if L>R:
        if L%2==0:
          LR=1
        else:
          LR=0
      else:
        if R%2==0:
          LR=0
        else:
          LR=1
      if LR==0:
        res[change[i]]=(L+R+1)//2
        res[change[i]-1]=(L+R-1)//2
      else:
        res[change[i]]=(L+R-1)//2
        res[change[i]-1]=(L+R+1)//2
    now += 1
  else:
    last = change[i]
    now -= 1
print(*res)


Measured memory_bytes: 15152
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int xcomp(vector<LL>& a, vector<LL>& b) {
	return a[0] < b[0];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;

LL pow2(LL x) {
	if (x == 0) {
		return 1;
	}
	else {
		return pow2(x - 1) * 2;
	}
}

LL ketasu(LL x) {
	if (x == 1) {
		return 1;
	}else
		if (x == 0) {
			return 0;
		}
		else {
			return ketasu(x / 2) + 1;
		}
}

int main() {
	LL N, T;
	cin >> N >> T;
	LL sum=0;
	vector<LL> v(N, 0);
	REP(i, N) {
		cin >> v[i];
		if (i >= 1) {
			if (v[i] - v[i - 1] >= T) {
				sum += T;
			}
			else {
				sum += v[i] - v[i - 1];
			}
		}
		if (i == N - 1) {
			sum += T;
		}
	}
	cout << sum << endl;
}

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

using namespace std;

#define all(x) (x).begin(), (x).end()
typedef long double ld;
typedef long long ll;

int pop(int x) {
  return __builtin_popcount(x);
}

int bit(int mask, int i) {
  return (mask >> i) & 1;
}

int n, a, b;

void rec(int from, int to, int used) {
  assert(pop(from ^ to) % 2 == 1);
  assert((from & used) == (to & used));

  if (pop(used) == n - 1) {
    assert(pop(from ^ to) == 1);
    cout << from << " " << to << " ";
    return;
  }
  
  for (int k = 0; k < n; ++k) {
    if (!bit(used, k) && bit(from, k) != bit(to, k)) {
      for (int j = 0; j < n; ++j) {
        if (!bit(used, j) && j != k) {
          int mid = from ^ (1 << j);
          assert(bit(mid, k) == bit(from, k));
          assert(bit(mid ^ (1 << k), k) == bit(to, k));
          rec(from, mid, used | (1 << k));
          rec(mid ^ (1 << k), to, used | (1 << k));
          return;
        }
      }
      assert(false);
    }
  }
}

int main() {
#ifdef LOCAL
  assert(freopen("c.in", "r", stdin));
#endif

  ios_base::sync_with_stdio(false);

  cin >> n >> a >> b;

  int last = a ^ b;
  if (pop(last) % 2 == 0) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  rec(a, b, 0);
  cout << "\n";
}



Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
	int i,n,m,s,z;
	cin>>n;
	int t[n];
	for(i=1;i<=n;i++)
	{
		cin>>t[i];
	}
	cin>>m;
	int p[m],x[m],j,a,b;
	for(i=1;i<=m;i++)
	{
		cin>>p[i];
		cin>>x[i];
	}
	z=m;
	j=1;
	while(z--)
	{
		a=p[j];
		b=x[j];
		s=0;
		for(i=1;i<=n;i++)
		{
			if(i==a)
			{
				s=s+b;
			}
			else
			{
				s=s+t[i];
			}
		}
		cout<<s<<endl;
		j++;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;





int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string a = "ABC", b = "ARC";
	string s;
	cin >> s;
	cout << (s == a ? b : a);
}

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


int main(){
    string n;
    cin >> n;
    int ns = n.size();
  	char aa = n[ns-1];
    int mun = aa -'0';
    if(mun == 2 || mun == 4 || mun == 5 || mun == 7 || mun == 9){
      cout << "hon" << endl;
    }else if(mun == 0 || mun == 1 || mun == 6 || mun ==8){
      cout << "pon" << endl;
    }else{
      cout << "bon" << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)       for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; cin >> n;

    ll ans = 0;
    for(int i = 1; i < n; ++i){
        for(int j = 1; i*j <= n; ++j){
            if(1 <= n - i*j && n - i*j <= n-1) ++ans;
        }
    }

    cout << ans << endl;

return 0;
}

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

int main() {
  int A, B, i, count;
  int n1, n2, n3, n4, n5;
  count = 0;
  cin >> A >> B;
  i = A;
  for (; i <= B; i++) {
    n5 = i/10000;
    n4 = (i - n5*10000)/1000;
    n3 = (i - n5*10000 - n4*1000)/100;
    n2 = (i - n5*10000 - n4*1000 - n3*100)/10;
    n1 = (i - n5*10000 - n4*1000 - n3*100 - n2*10);
    if (n1 == n5 && n2 == n4) {
      count++;
    }
  }
  cout << count << endl;
}






Measured memory_bytes: 256
#include <iostream>

/*
  195A
  165A
  105A
  189A
  135A

*/

int main(){
  int n;
  std::cin >> n;
  if(n < 105)
    n = 0;
  else if(n < 135)
    n = 1;
  else if(n < 165)
    n = 2;
  else if(n < 189)
    n = 3;
  else if(n < 195)
    n = 4;
  else
    n = 5;
  std::cout << n << std::endl;
}


Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
set<string> st;

int main() {
	cin >> n;
	REP(i, n) {
		string s;
		cin >> s;
		if (s == "insert") {
			string t;
			cin >> t;
			st.insert(t);
		}
		else {
			string t;
			cin >> t;
			if (st.find(t) != st.end()) {
				cout << "yes" << endl;
			}
			else {
				cout << "no" << endl;
			}
		}
	}
}


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

int main() {
  long long n;
  cin >> n;
  string s;
  while (n > 0) {
    long long t = (n) % 26;
    char v;
    if (t == 0) {
      v = 'z';
      n -= 26;
    } else {
      v = 'a' + t-1;
    }
    s = v + s;
    n /= 26;
  }
  cout << s << endl;
}

Measured memory_bytes: 3596
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 1e3 + 10;

char a[N][N];
int dist[N][N];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
	int n, m;
	cin >> n >> m;
	queue<pii> q;
	for (int i = 1; i <= n; ++i) {
		cin >> (a[i] + 1);
		for (int j = 1; j <= m; ++j) {
			if (a[i][j] == '#') {
				q.push({i, j});
			} else {
				dist[i][j] = n * m + 1;
			}
		}
	}
	int ans = 0;
	while (!q.empty()) {
		auto cur = q.front();
		q.pop();
		int i = cur.first, j = cur.second;
		for (int d = 0; d < 4; ++d) {
			int x = i + dx[d];
			int y = j + dy[d];
			if (dist[i][j] + 1 < dist[x][y]) {
				dist[x][y] = dist[i][j] + 1;
				q.push({x, y});
				ans = max(ans, dist[x][y]);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 11408
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std ;
#define MOD 1000000007
#define ll long long int 


ll n,k,num[2005],sum,cur,prv; 
pair<int , int> a[2005];

void f(int x){
	for(int i=0;i<x;i++){
		if(num[x]>num[i])
			cur++;
	}
	for(int i=x+1; i<n;i++){
		if(num[x]>num[i])
			prv++;
	}
}

ll cnt(ll x){
	ll s=1;
	s = x*(x+1)/2;
	return s%MOD;
}
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>num[i];
	}
	
	for(int i=0;i<n;i++) f(i);
	
	ll y=cnt(k-1);
//	cout<<cur<<" "<<prv<<" ";
	
	sum+=cur*y+prv*(y+k);
	sum%=MOD;
	
	cout<<sum<<"\n";
	return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const int MOD = 1e9 +7;
int dx[4] ={1,0,-1,0},dy[4] ={0,1,0,-1};

ll h,w;
char field[1010][1010];
ll cnt[1010][1010];
ll ans=0;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>h>>w;
    queue<pll> que;
    memset(cnt,-1,sizeof(cnt));
    rep(i,h){
        rep(j,w){
            cin>>field[i][j];
            if(field[i][j]=='#'){
                que.push(make_pair(i,j));
                cnt[i][j]=0;
            }
        }
    }
    while(!que.empty()){
        pll p=que.front();
        que.pop();
        rep(i,4){
            ll nx=p.first+dx[i],ny=p.second+dy[i];
            if(nx>=0 && nx <h && ny >=0 && ny <w &&cnt[nx][ny]==-1&& field[nx][ny]=='.'){
                cnt[nx][ny]=cnt[p.first][p.second]+1;
                que.push(pll(nx,ny));

            }
        }
    }
    rep(i,h){
        rep(j,w){
            ans=max(ans,cnt[i][j]);
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A)
{
    if (A.size() == n + 1)
    {
        int now = 0;
        rep(i, q)
        {
            if (A[b[i]] - A[a[i]] == c[i])
                now += d[i];
        }
        ans = max(ans, now);
        return;
    }

    A.push_back(A.back());
    while (A.back() <= m)
    {
        dfs(A);
        A.back()++;
    }
}

int main()
{
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    rep(i, q)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int>(1, 1));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

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

	ll ans = 1;
	ll n = 0;
	ll s = 1;
	rp(i,0,D)s*=100;
	// ote(s);
	for(ll i=s; i<=s*100+s; i+=s){
		// printf("%d %d\n",i,i%(s*100));//
		if(i%(s*100)){
			if(++n==N){
				ote(i);
				return 0;
			}
		}
		// if(D!=0){
		// 	if(++n==N){
		// 		ote(i);
		// 		return 0;
		// 	}
		// }
		// else{
		// 	if(i%100){
		// 		if(++n==N){
		// 			ote(i);
		// 			return 0;
		// 		}
		// 	}
		// }
	}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);
// priority_queue<ll, vector<ll>, greater<ll>> pq;


int main(){
    ll n, m; cin >> n >> m;
    vector<pll> hito(n), p(m);
    rep(i, n){
        ll a, b; cin >> a >> b;
        hito[i] = pll(a, b);
    }
    rep(i, m){
        ll c, d; cin >> c >> d;
        p[i] = pll(c, d);
    }
    rep(i, n){
        ll ans = INF;
        ll ind = -1;
        rep(j, m){
            if(ans > abs(hito[i].first - p[j].first) + abs(hito[i].second - p[j].second)){
                ans = abs(hito[i].first - p[j].first) + abs(hito[i].second - p[j].second);
                ind = j;
            }
        }
        cout << ind+1 << endl;
    }
}


Measured memory_bytes: 3608
if __name__ == "__main__":
    num_activities = int(input())
    activities = [[0, 0] for _ in range(num_activities)]
    for i in range(num_activities):
        activities[i] = list(map(lambda x: int(x), input().split()))

    # Sort by end time in the ascending order.
    activities = sorted(activities, key=lambda x: x[1])

    current_start = -1
    result = 0
    for start, end in activities:
        if current_start < start:
            result += 1
            current_start = end

    print(result)



Measured memory_bytes: 25152
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True


def main():
    A, B = MI()
    S = input()

    if len(S) != A + B + 1:
        print('No')
        # print('1')
        return

    for i in range(len(S)):
        if i == A and S[i] != '-':
            print('No')
            # print('2')
            return
        elif i != A and S[i] not in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']:
            print('No')
            # print('3', i, S[i])
            return

    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 5076
#include <bits/stdc++.h>
using namespace std;
int a[100][100],b[100][100];
int main(){
  int n,m,l;
  cin>>n>>m>>l;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin>>a[i][j];
    }
  }
  for(int i=0;i<m;i++){
    for(int j=0;j<l;j++){
      cin>>b[i][j];
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<l;j++){
      long long sum=0;
      for(int k=0;k<m;k++){
	sum+=a[i][k]*b[k][j];
      }
      (j==l-1)?cout<<sum<<endl:cout<<sum<<" ";
    }
  }
}

Measured memory_bytes: 3204
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

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

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

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

  int a, p;
  cin >> a >> p;

  int ans = (3 * a + p) / 2;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 888
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	ll i,n;cin>>n;vi v(n),d(n,0);for(i=0;i<n;i++) cin>>v[i];
	d[1]=abs(v[1]-v[0]);for(i=2;i<n;i++) d[i]=min(d[i-1]+abs(v[i]-v[i-1]),d[i-2]+abs(v[i]-v[i-2]));
	cout<<d[n-1]<<endl;
}



Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] arr = new int[n];
        for(int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        int[] min = new int[n];
        min[0] = 0;


        for(int i = 1; i < n; i++) {
            int minimum = Integer.MAX_VALUE;
            for(int j = 1; j <= k; j++ ) {
                if(i - j >=0) {
                    minimum = Math.min(minimum, Math.abs(arr[i-j] - arr[i]) + min[i-j]);
                }
            }
            min[i] = minimum;
        }

        System.out.println(min[n-1]);
    }
}


Measured memory_bytes: 51196
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
ll mod=1e9+7;
long long pwr(long long x, long long e){
    if(e==0)
        return 1;
    long long tmp=pwr(x,e/2);
    tmp=(tmp*tmp)%mod;
    if(e%2)
        tmp=(tmp*x)%mod;
    return tmp;
}
ll dp[100010];
int main(){
    ll n, k;
    while(cin>>n>>k){
        ll ans=0;
        for(ll i=k; i>=1; --i){
        	dp[i]=pwr(k/i, n);
        	for(int j=i+i; j<=k; j+=i){
        		dp[i]-=dp[j];
        	}
        	ans+=i*dp[i];
        	ans%=mod;
        }
        if(ans<0){
        	ans+=mod;
        }
        printf("%lld\n",ans);
    }
  return 0;
}




Measured memory_bytes: 4432
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,K;
    cin >> N >> K;
    vector<int> V(N),dp(K+1);//1 勝ち -1 負け
    rep(i,0,N)cin >> V[i];
    rep(i,0,V[0])dp[i] = -1;
    rep(i,V[0],K+1){
        int mini = 1;
        rep(j,0,N){
            if(i - V[j] < 0)continue;
            mini = min(mini, dp[i - V[j]]);
        }
        if(mini == -1)dp[i] = 1;
        else          dp[i] = -1;
    }
    cout << (dp[K] == 1 ? "First" : "Second") << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> num(n);
  for(int i=0; i<n; i++){
    cin>>num.at(i);
  }
  sort(num.begin(),num.end());
  bool flag=0;
  for(int i=0; i<n-1; i++){
    if(num.at(i)==num.at(i+1)){
      flag=1;
      break;
    }
  }
  if(flag){
    cout<<"NO"<<endl;
  }else{
    cout<<"YES"<<endl;
  }
  return 0;
}


Measured memory_bytes: 1024
/*  Bismillahir Rahmanir Rahim  */

#include <bits/stdc++.h>

using namespace std;

const int N = 100005;

int n, a[N];
map <int, int> mp;

int main(){
	int mx = -N, mn = +N;
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i){
		scanf("%d", &a[i]);
		mx = max(mx, a[i]);
		mn = min(mn, a[i]);
		mp[a[i]]++;
	}
	if(mp.size() > 2 || mx - mn > 1){
		printf("No\n");
		return 0;
	}
	if(mx == mn){
		if(mx + 1 == n || mx * 2 <= n) printf("Yes\n");
		else printf("No\n");
		return 0;
	}
	int aa = mp[mn];
	int bb = mx - aa; 
	// cout << aa << ' ' << bb << endl;
	if(aa <= 0 || bb <= 0){
		printf("No\n");
		return 0;
	}
	if(aa + bb * 2 <= n) printf("Yes\n");
	else printf("No\n");
	return 0;
}



Measured memory_bytes: 5376
import sys
import heapq

input = sys.stdin.readline


def main():
    X, Y, Z, K = map(int, input().split())
    A = list(map(lambda x: -int(x), input().split()))
    B = list(map(lambda x: -int(x), input().split()))
    C = list(map(lambda x: -int(x), input().split()))

    A.sort()
    B.sort()
    C.sort()

    p_queue = [(A[0] + B[0] + C[0], 0, 0, 0)]
    visited = set()
    visited.add((0, 0, 0))
    ans = []
    while len(ans) < K:
        s, i_A, i_B, i_C = heapq.heappop(p_queue)
        ans.append(-s)
        if i_A < X - 1 and (i_A + 1, i_B, i_C) not in visited:
            visited.add((i_A + 1, i_B, i_C))
            t = s - A[i_A] + A[i_A + 1]
            heapq.heappush(p_queue, (t, i_A + 1, i_B, i_C))
        if i_B < Y - 1 and (i_A, i_B + 1, i_C) not in visited:
            visited.add((i_A, i_B + 1, i_C))
            t = s - B[i_B] + B[i_B + 1]
            heapq.heappush(p_queue, (t, i_A, i_B + 1, i_C))
        if i_C < Z - 1 and (i_A, i_B, i_C + 1) not in visited:
            visited.add((i_A, i_B, i_C + 1))
            t = s - C[i_C] + C[i_C + 1]
            heapq.heappush(p_queue, (t, i_A, i_B, i_C + 1))

    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 10988
#include<iostream>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main(){
vector <int>a;
int n,k,i,j,sum=0;
cin>>n>>k;
for(i=0;i<n;i++){
        cin>>j;
    a.push_back(j);
}
sort(a.begin(),a.end());
for(i=0;i<k;i++)
    sum+=a[i];
cout<<sum;

}


Measured memory_bytes: 3628
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <functional>
#include <map>
#include <queue>
#include <vector>

using namespace std;

typedef long long ll;

const int INF = 2147483647;

const int MAXN = 500005;
int n, m, e;
int arr[MAXN];
int vis[MAXN * 2];
int ans[MAXN];
struct Query {
    int l, r, id;

    bool operator<(const Query& q) const { return this->l < q.l; }
};
Query queries[MAXN];
int nexxt[MAXN];

class FenwickTree {
   public:
    FenwickTree() = default;

    inline void increase(int t, int n) {
        for (int i = t; i <= N; i += lowbit(i)) {
            _arr[i] += n;
        }
    }
    inline int getSum(int t) {
        int s = 0;
        for (int i = t; i; i -= lowbit(i)) {
            s += _arr[i];
        }
        return s;
    }

   private:
    static const int N = 500005;
    int _arr[N];

    inline int lowbit(int n) { return n & (-n); }
};

FenwickTree tree;

int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d", &n);
    scanf("%d", &m);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &arr[i]);
        if (!vis[arr[i]]) {
            vis[arr[i]] = 1;
            tree.increase(i, 1);
        }
    }
    for (int i = n; i >= 1; i--) {
        if (!vis[arr[i]])
            nexxt[i] = n + 1;
        else
            nexxt[i] = vis[arr[i]];
        vis[arr[i]] = i;
    }

    for (int i = 0; i < m; i++) {
        scanf("%d %d", &queries[i].l, &queries[i].r);
        queries[i].id = i;
    }
    sort(queries, queries + m);
    int j = 1;
    for (int i = 0; i < m; i++) {
        for (; j < queries[i].l; j++) {
            tree.increase(nexxt[j], 1);
        }
        ans[queries[i].id] =
            tree.getSum(queries[i].r) - tree.getSum(queries[i].l - 1);
    }
    for (int i = 0; i < m; i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}

Measured memory_bytes: 19272
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if (1 <= N/1110 <= 9 && N%1110 <= 9){
    cout<<"Yes"<<endl;
  }
  else {
    if (N%1000%111 == 0){
    cout<<"Yes"<<endl;
    }
    else {
      cout<<"No"<<endl;
    }
  }
}

Measured memory_bytes: 256
import numpy as np
N,L=map(int, input().split())
taste_list = np.zeros(N)
for i in range(N):
  taste_list[i]=L+i+1-1
taste_sum = sum(taste_list) - taste_list[np.abs(taste_list)==min(np.abs(taste_list))]
print('{:.0f}'.format(taste_sum[0]))

Measured memory_bytes: 13480
var input = require('fs').readFileSync('/dev/stdin', 'utf8');

var arr=input.trim().split("\n");
var nrl=arr.shift().split(" ").map(Number);
var n=nrl[0];
var L=nrl[2];
var t=[];
var max=[0,0];
var time=0;
for(var i=0;i<n;i++)t[i]=[0,0,i];
arr.push([1,L,0].join(" "));
arr.forEach(function(v){
v=v.split(" ").map(Number);
var d=v[0]-1;
var T=v[1];
var x=v[2];

t[max[0]][1]+=T-time;
time=T;
t[d][0]+=x;

if(x>0){
if(t[d][0]>max[1])max=[d,t[d][0]];
else if(t[d][0]==max[1] && d<=max[0])max=[d,t[d][0]];
}

if(x<0 && max[0]==d){
var MAX=0;
var m=0;
t.forEach(function(V,index){
if(MAX<V[0])m=index;
});

max=[m,t[m][0]];


}


});



t.sort(function(a,b){
if(a[1]==b[1])return a[2]-b[2];
else return b[1]-a[1];});


console.log(t[0][2]+1);

Measured memory_bytes: 126944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m, p, q, f = 0, g = 0, r = 0, s = 0, a[100005] = {};
    ll z = mod * 328ll, u = 0, v = 0, w = 0;
    ll x[100005] = {}, y[200005] = {}, t[100005] = {};
    vector<pii> b, c, d, e;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i < n; i++) {
        if (a[i + 1] > a[i]) b.push_back({a[i], a[i + 1]}), u += a[i + 1] - a[i];
        else c.push_back({a[i], a[i + 1] + m}), v += a[i + 1] - a[i] + m;
    }
    p = (int)b.size(); q = (int)c.size();
    for (int i = 0; i < p; i++) d.push_back({b[i].first + 1, 1}), d.push_back({b[i].second, b[i].first - b[i].second});
    sort(d.begin(), d.end());
    for (int i = 1; i <= m; i++) {
        u -= r;
        x[i] = u;
        while (f < p + p && d[f].first <= i) {
            if (d[f].second == 1) r++;
            else {
                u -= d[f].second + 1;
                r--;
            }
            f++;
        }
    }
    for (int i = 0; i < q; i++) e.push_back({c[i].first + 1, 1}), e.push_back({c[i].second, c[i].first - c[i].second});
    sort(e.begin(), e.end());
    for (int i = 1; i <= m + m; i++) {
        w += s;
        y[i] = w;
        while (g < q + q && e[g].first <= i) {
            if (e[g].second == 1) s++;
            else {
                w += e[g].second + 1;
                s--;
            }
            g++;
        }
    }
    for (int i = 1; i <= m; i++) t[i] = v - y[i] - y[i + m];
    for (int i = 1; i <= m; i++) z = min(z, x[i] + t[i]);
    cout << z;
}


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

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ldb long double 
#define db double
#define int long long

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >

#define mi map<int,int>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int md = 1e9+7;
const int MX = 2e5+5;
const int INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

int power_md(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res=(res%md*a%md)%md;
  a=(a%md*a%md)%md;
  n/=2;
}
res%=md;
return res;
}

int power(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a=a*a;
  n/=2;
}
return res;
}

int abst(int a)
{
 return ((a<0)?(-1*a):(a));
}

class cmp_set{
public:
	bool operator() (int a, int b){
		return a > b;
	}
};

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

int n,A,B,C;
int arr[10];

int fun(int cur,int a,int b,int c)
{
    if(cur==n)
    {
        if(min(a,min(b,c))>0)
         return abst(a-A)+abst(b-B)+abst(c-C)-30;
        else
         return 1e15;
    }
    int res=1e15;
    res=min(res,fun(cur+1,a+arr[cur],b,c)+10);
    res=min(res,fun(cur+1,a,b+arr[cur],c)+10);
    res=min(res,fun(cur+1,a,b,c+arr[cur])+10);
    res=min(res,fun(cur+1,a,b,c));
    return res;
}

int32_t main()
{
    fast;
    cin>>n>>A>>B>>C;
    for(int i=0;i<n;i++)
     cin>>arr[i];
    int res=fun(0,0,0,0);
    cout<<res<<"\n";
    return 0;
}

Measured memory_bytes: 256
h, w, k = map(int, input().split())
cake = [input() for _ in range(h)]
cnt = 1
ans = [[0]*w for _ in range(h)]


for i in range(h):
    cnt_berry = 0
    for j in range(w):
        if cake[i][j] == '#':
            cnt_berry += 1
            if 2 <= cnt_berry:
                cnt += 1
        ans[i][j] = cnt
    if cnt_berry != 0:
        cnt += 1
    else:
        for j in range(w):
            ans[i][j] = ans[i-1][j]

cnt = 0
for row in ans:
    if row[0] == 0:
        cnt += 1
        continue
    break
for i in range(cnt-1, -1, -1):
    for j in range(w):
        ans[i][j] = ans[i+1][j]

for row in ans:
    print(*row)

Measured memory_bytes: 7568
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include <math.h>
#include<algorithm>
#include<functional>
#define ll long long
#define inf  999999999
#define pa pair<int,int>
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

class Point{
	public:
	double x,y;
	Point(double x=0,double y=0):x(x),y(y) {}
	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
	Point operator * (double a) {return Point(x*a,y*a);}
	Point operator / (double a) {return Point(x/a,y/a);}
	double absv() {return sqrt(norm());}
	double norm() {return x*x+y*y;}
	bool operator < (const Point &p) const{
		return x != p.x ? x<p.x: y<p.y;
	}
	bool operator == (const Point &p) const{
		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
	}
};
typedef Point Vector;

struct Segment{
Point p1,p2;
};


double dot(Vector a,Vector b){
	return a.x*b.x+a.y*b.y;
}
double cross(Vector a,Vector b){
	return a.x*b.y-a.y*b.x;
}

//----------------kokomade temple------------
double zz(Vector a,Vector b){
if(a.absv()<EPS || b.absv()<EPS) return 100;
else{
a=a/a.absv();
b=b/b.absv();
double co=dot(a,b),si=cross(a,b);
if(co<=-1+EPS) return 100;
else if(si>0) return acos(co);
else if(co>1-EPS) return 0.0;
else return -acos(co);
}

}


int main(){
int n,k=0,zh;
double x,y;
cin>>n;
Point a[110],q;
Vector v[110];
for(int i=0;i<n;i++){
cin>>x>>y;
a[i].x=x;
a[i].y=y;
}
a[n]=a[0];
double henkaku=0.0;
int qu;
cin>>qu;
for(int i=0;i<qu;i++){
cin>>x>>y;
q.x=x,q.y=y;
zh=0;
henkaku=0.0;
for(int i=0;i<n;i++){
if(zz(a[i]-q,a[i+1]-q)==100) zh=1;
else henkaku=henkaku+zz(a[i]-q,a[i+1]-q);
//cout<<zz(a[i]-q,a[i+1]-q)<<endl;
if(a[i]==q) zh=1;
}
if(zh==1) cout<<"1"<<endl;
else if(fabs(henkaku)<1) cout<<"0"<<endl;
else cout<<"2"<<endl;
//cout<<"he "<<henkaku<<endl;
}
return 0;
}

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

int main()
{
	int i,count = 0;
	string s,t;
	cin>>s;
	cin>>t;
	for(i = 0;i < s.size();i++)
		if(s[i] != t[i])
			count++;

	cout<<count;
	return 0;
}

Measured memory_bytes: 3788