akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
typedef long long int ll;
int c[300001];
int q(const void *a, const void *b){
    return *(ll*)a - *(ll*)b;
}
int main(void){
  int n,cnt=0;
  scanf("%d",&n);
  ll a[n],b[n];
  FOR(n)scanf("%lld",&a[i]),b[i]=a[i];
  qsort(b,n,sizeof(ll),q);
  FOR(n)if(a[i]!=b[i])cnt++,c[i]++;
  if(cnt<1){
    PRN(0);
    return 0;
  }
  int m,l,r;
  scanf("%d",&m);
  FOR(m){
    scanf("%d %d",&l,&r);
    l--,r--;
    if(a[l]==a[r])continue;
    if(a[l]==b[r]){
      cnt--;
      c[r]--;
    }
    if(a[r]==b[l]){
      cnt--;
      c[l]--;
    }
    if(a[r]==b[r]){
      cnt++;
      c[r]++;
    }
    if(a[l]==b[l]){
      cnt++;
      c[l]++;
    }
    if(cnt<1){
      PRN(i+1);
      return 0;
    }
    ll t=a[l];
    a[l]=a[r];
    a[r]=t;
  }
  PRN(-1);
  return 0;
}


Measured memory_bytes: 8384
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()
a = nin(n)

ans = 0
cnt = 0
for i in range(n):
    if a[i] != 0:
        cnt += a[i]
    else:
        ans += cnt // 2
        cnt = 0
ans += cnt // 2

print(ans)

Measured memory_bytes: 7088
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;
const int a[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1\
, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
int main()
{
  int k;
  cin >> k;

  cout << a[k-1] << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  double out = A.at(0);
  for(int i = 1; i < N; i++){
    out += A.at(i);
    out/= 2;
  }
  cout <<setprecision(20)<< out;
}


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

using namespace std;

const int max_n = 555;

int n, m, h, w, a[max_n][max_n];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d%d%d%d", &n, &m, &h, &w);
    //int k1 = n / h, k2 = m / w;
    int inf = 1000000000 / (h * w) - 1;
    //inf = 3999;
    for (int i = 0; i < n; i += h) {
        for (int j = 0; j < m; j += w) {
            for (int k = 0; i + k < n && k < h; ++k) {
                for (int q = 0; j + q < m && q < w; ++q) {
                    if (k + 1 == h && q + 1 == w) {
                        a[i + k][j + q] = -(h * w - 1) * inf - 1;
                    } else {
                        a[i + k][j + q] = inf;
                    }
                }
            }
        }
    }
    long long sum = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            sum += a[i][j];
        }
    }
    //cout << sum << endl;
    if (sum < 0) {
        printf("No\n");
    } else {
        printf("Yes\n");
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < m; ++j) {
                printf("%d ", a[i][j]);
            }
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 3840
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            if(n == i * j){
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#define FOR(i,j,k) for(int i=j;i<=k;i++)
using namespace std;
typedef pair<int,int> pr;
#define MAXN (300000)
int a[MAXN];
pr b[MAXN];
set<int> s;
typedef long long LL;
int main (int argc, char *argv[])
{
	std::ios::sync_with_stdio(false);
	int n;cin>>n;
	FOR(i,1,n)	cin>>a[i];
	FOR(i,1,n)	b[i]=pr(a[i],i);
	sort(b+1,b+1+n);
	LL ans=0;
	s.insert(0);
	s.insert(n+1);
	FOR(i,1,n){
		LL r=*s.lower_bound(b[i].second);
		LL l=*(--s.lower_bound(b[i].second));
		LL m=b[i].second;
		//cout<<l<<" "<<m<<" "<<r<<endl;
		ans+=((m-l-1)*(r-m-1)+(m-l-1)+(r-m-1)+1)*b[i].first;
		//cout<<ans<<endl;
		s.insert(b[i].second);
	}
	cout<<ans<<endl;
	return 0;
}


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

int n, k, a[100001], f[100001]={2147483647};

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    /*#ifndef ONLINE_JUDGE
    freopen("FROG1.inp","r",stdin);
    freopen("FROG1.out","w",stdout);
    #endif // ONLINE_JUDGE*/
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    f[1]=0;
    for (int i = 2; i <= n; i++)
    {
        f[i]=1000000001;
        for (int j = 1; j <= k; j++)
        {
            if (i>j)
            {
                f[i]=min(f[i],f[i-j]+abs(a[i]-a[i-j]));
            }
        }
    }
    cout << f[n];
    return 0;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
N = int(input())
S = input()

R = 0
G = 0
B = 0

for i in range(N):
  if S[i] == 'R':
    R += 1
  elif S[i] == 'G':
    G += 1
  else:
    B += 1
    
count = 0
for i in range(N-1):
  for j in range(i+1,N):
    if 2*j-i>=N:
      break
    if S[i]!=S[j] and S[2*j-i]!=S[i] and S[2*j-i]!=S[j]:
      count += 1

print(R*G*B-count)

Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define REP(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define TF(flag) (flag)?1:0
#define fi first
#define se second
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

int main(void){
  int N,M; cin>>N>>M;
  int INF=INT_MAX;
  mat<int> dp(M+1,vec<int>(1<<N,INF));
  vec<pi> key(M);
  rep(i,M){
    int a,b; cin>>a>>b;
    int x=0;
    rep(j,b){
      int c; cin>>c; --c;
      x+=(1<<c);
    }
    key[i]=pi(a,x);
  }
  
  dp[0][0]=0;
  rep(i,M){
    rep(j,1<<N){
      if(dp[i][j]==INF) continue;
      dp[i+1][j|key[i].se]=min(dp[i+1][j|key[i].se],dp[i][j]+key[i].fi);
      dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
    }
  }
  /*
  rep(i,M+1){
    rep(j,1<<N){
      if(dp[i][j]==INF) cout<<-1<<" ";
      else cout<<dp[i][j]<<" ";
    }
    cout<<endl;
  }
  */
  if(dp[M][(1<<N)-1]==INF){
    cout<<-1;
  }
  else{
    cout<<dp[M][(1<<N)-1];
  }
}

Measured memory_bytes: 16256
#include<stdio.h>

#define INFTY 1000000000
 int c=0;
 
 void merge(int*A, int left,int mid,int right){
   int i,j,k,n1,n2;

   
   n1 = mid -left;
   n2 = right -mid;

   int L[n1+1],R[n2+1];

   for(i=0;i<n1;i++)
     L[i] = A[left+i];

   for(i=0;i<n2;i++)
     R[i] = A[mid+i];

   L[n1] = INFTY;
   R[n2] = INFTY;

   i=0;
   j=0;

   for(k=left;k<right;k++){
     c++;
     if(L[i] <= R[j]){
       A[k] = L[i];
       i++;
     }
     else{
       A[k] = R[j];
       j++;
     }
   }
   

}

mergeSort (int*A,int left,int right){
  int mid;
  
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

int main(){
  int n,i;

  scanf("%d",&n);

  int A[n];

  for(i=0;i<n;i++)
    scanf("%d",&A[i]);

  mergeSort(A,0,n);

  for(i=0;i<n;i++){
    if(i!=0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n%d\n",c);
  

  return 0;
  
}



Measured memory_bytes: 5600
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  string S;
  ll K;
  cin >> S;
  cin >> K;
  bool ans = true;
  for(ll i=0; i<K; i++){
    if(S[i] != '1'){
      cout << S[i] << endl;
      ans = false;
      break;
    }
  }
  if(ans) cout << 1 << endl;
}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define SZ(x) ((int)(x.size()))
#define FOR(i,s,n) for (ll i = (s); (i) < (n); ++i)
#define FORD(i,s,l) for (ll i = (s); (i) >= l; --i)
#define F first
#define S second
#define TC int __tc; cin >> __tc; FOR(case_num,1,__tc+1)
#define TEST(x,i) ((x)&(1ll<<(i)))
#define SET(x,i) ((x)|(1ll<<(i)))
#define FLIP(x,i) ((x)^(1ll<<(i)))
#define CLEAR(x,i) ((x)&~(1ll<<(i)))

const double pi = 4 * atan(1);
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
const int MAXN = 200005;

int arr[105];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	
	int tot = 0;
	
	FOR(i,0,n) {
		cin >> arr[i];
		tot+=arr[i];
	}
	
	int m;
	cin >> m;
	while (m--){
		int p, x;
		cin >> p >> x;
		cout << (tot-arr[p-1]+x) << "\n";
	}

}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}
ll mpower(ll a,ll b,ll c){
    int z;
    if(b==0){
        z=1;
        z%=c;
        return z;
    }
    if(b==1){
        z=a;
        z%=c;
        return z;
    }
    else{
        return (((mpower(a,b/2,c))*(mpower(a,b/2,c))%c)*mpower(a,b%2,c)%c);
    }
}

int main(){
  string a;
  cin>>a;
  if(a.at(0)==a.at(1)&&a.at(1)==a.at(2)){
    cout<<"No";
    return 0;
  }
  cout<<"Yes";
}

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

int main() {
        int n, q;
        scanf("%d%d", &n, &q);
        n = 2 * n;
        vector<long long> a(n), b(n);
        for (int i = 0; i < n; i ++) scanf("%lld", &a[i]);
        for (int i = 0; i < n; i ++) scanf("%lld", &b[i]);
        multiset<long long> positive, negative;
        long long psum = 0, nsum = 0;
        for (int i = 0; i < n; i ++) {
                if (i == 0 || i == n - 1) {
                        psum += a[i];
                        continue;
                }
                long long c = a[i] - b[i];
                if (c >= 0) { 
                        positive.insert(c);
                        psum += a[i];
                } else { 
                        negative.insert(- c);
                        nsum += b[i];
                }
        }
        while (q --) {
                int p;
                long long x, y;
                scanf("%d%lld%lld", &p, &x, &y);
                p --;
                if (p == 0 || p == n - 1) {
                        psum -= a[p];
                        psum += x;
                        a[p] = x;
                } else {
                        //remove
                        long long c = a[p] - b[p];
                        if (c >= 0) {
                                positive.erase(positive.find(c));
                                psum -= a[p];
                        } else {
                                negative.erase(negative.find(-c));
                                nsum -= b[p];
                        }
                        //insert
                        long long z = x - y;
                        if (z >= 0) {
                                positive.insert(z);
                                psum += x;
                        } else {
                                negative.insert(-z);
                                nsum += y;
                        }
                }
                a[p] = x;
                b[p] = y;
                long long ans;
                if (positive.size() % 2 == 0) ans = psum + nsum;
                else ans = psum + nsum - min(*positive.begin(), *negative.begin());
                printf("%lld\n", ans);
        }
        return 0;
}


Measured memory_bytes: 14208
i,a[1<<17],b[1<<17];c;
main(s){
	for(;~(c=getchar_unlocked());)c-10?a[i]=a[i]*10+c-48:i++;
	for(b[i=s]=1;!b[s=a[s]]&&s-2;i++)b[s]=1;
	printf("%d",s==2?i:-1);
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <set>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int n, k;
set<string> st;
void calc(int bit, vector<int> &v)
{
    vector<int> num;
    for(int i = 0; i < n; i++)
    {
        if(bit & (1<<i)) num.push_back(v[i]);
    }
    sort(num.begin(), num.end());
    do
    {
        string s = "";
        for(int i = 0; i < num.size(); i++) s += to_string(num[i]);
        st.insert(s);
    }
    while(next_permutation(num.begin(), num.end()));
}
void dfs(int bit, int pos, vector<int> &v)
{
    if(__builtin_popcount(bit) == k)
    {
        calc(bit, v);
        return;
    }
    if(pos >= n) return;
    dfs(bit, pos + 1, v);
    dfs(bit | (1<<pos), pos + 1, v);
}
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n >> k, n or k)
    {
        st.clear();
        vector<int> v(n);
        for(int i = 0; i < n; i++) cin >> v[i];
        dfs(0, 0, v);
        cout << st.size() << endl;
    }
    return 0;
}




Measured memory_bytes: 3428
//        ★★ ASHWINI SHARMA ★★ 
#include <bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)
#define foreach(it,ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
#define debug(x) cout<<#x<<": "<<x<<endl
#define ull unsigned long long int
#define ll long long int
#define ld double
#define ui unsigned int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second 
 
 
#define PI 3.1415926535897932385
#define INF 1e18
#define EPS 1e-7
#define MAXN 1000005
#define MOD 1000000007
                                  //          ★★ ASHWINI SHARMA ★★      
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll exp(ll x, ll y, ll p)
{
    ll res = 1;   
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)    
            res = (res*x) % p;
        y = y>>1;     
        x = (x*x) % p; 
    }
    return res;
}
 
 
 
int main() {
    
    fastio;
    string s, t;
    cin >> s >> t;
    int n = s.length();
    int m = t.length();
    int dp[n+1][m+1];
    

    rep(i, n+1)
    {
        rep(j, m+1)
        {
            if(!i || !j)
                dp[i][j] = 0;
            else if(s[i-1] == t[j-1])
                dp[i][j] = dp[i-1][j-1]+1;
            else
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);

        }
       
        
    }
    int len = dp[n][m];
    char ans[len];
    
    int i = n;
    int j = m;
    while(i > 0 && j > 0)
    {
        if(s[i-1] == t[j-1])
        {
            ans[len-1] = s[i-1];
            i--;
            j--;
            len--;
        }
        else if(dp[i-1][j] > dp[i][j-1])
            i--;
        else
            j--;
    }
    rep(i, dp[n][m])
    cout << ans[i];
    return 0; 
}

Measured memory_bytes: 35456
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){

	int l[15];
	int i,a,b;

	while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&a,&b)!=EOF){

        double sum=0;
        for(i=0;i<10;i++){
            sum+=(double)l[i];
        }

	double c=0,d=0;
	for(i=0;i<10;i++){
        //c+=l[i];
        c+=l[i];
        d+=(double)l[i]/a*b;
        //cout<<"-"<<c<<"-"<<d<<endl;
        if(c+d>=sum)break;
	}
	cout<<i+1<<endl;

	}
	return 0;
}

Measured memory_bytes: 1204
import sys
bbn=1000000007
	
#+++++
		
def main():
	a = int(input())
	for i in range(16):
		if 7 * i <= a and (a - (7*i))%4==0:
			return 'Yes'
	return 'No'
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 38620
li = [0]*(10**5+1)

N = int(input())
A = [int(i) for i in input().split()]
p = sum(A)

for i in A:
    li[i] += 1

ans = []
Q = int(input())
for i in range(Q):
    B,C = [int(zz) for zz in input().split()]
    p += (C-B)*li[B]
    li[C] += li[B]
    li[B] = 0
    ans.append(p)

[print(i) for i in ans]


Measured memory_bytes: 21424
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

x = [0]*M
y = [0]*M
c = [0]*M

ans = sorted(a)[0]+sorted(b)[0]
for i in range(M):
    x[i], y[i], c[i] = map(int, input().split())
    if a[x[i]-1] + b[y[i]-1] - c[i] < ans:
        ans = a[x[i]-1] + b[y[i]-1] - c[i]



print(ans)


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

const ll MOD = 1e9+7;

int main(){

    ll n;
    cin >> n;
    ll a[n] = {};
    rep(i,0,n) cin >> a[i];
    map<ll,ll> m;

    rep(i,0,n){
        if(m.count(a[i]-1) == 0){
            m[a[i]] = 1;
        }
        else{
            m[a[i]] = m[a[i]-1] + 1;
        }
    }

    ll memo = 0;
    rep(i,0,n){
        memo = max(memo,m[i+1]);
    }

    cout << n - memo << endl;
}


Measured memory_bytes: 17672
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

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

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	int cnt = 0;

	while((A % 2 == 0) && (B % 2 == 0) && (C % 2 == 0)) {
		int An, Bn, Cn;
		An = (B + C) / 2;
		Bn = (C + A) / 2;
		Cn = (A + B) / 2;
		if ((An == A) && (Bn == B) && (Cn == C)) {
			cout << -1 << endl;
			goto END;
		}
		A = An;
		B = Bn;
		C = Cn;
		cnt++;
	}

	cout << cnt << endl;

	END:

	return 0;
}


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

int main(){
 int N;
 cin >> N;
 
 int cnt = 0;
 int P[N];
 for(int i=0; i<N; i++){
  int p[3];
  cin >> p[0] >> p[1] >> p[2];

  sort(p, p+3);

  P[i] = ((p[0]-1)*1000+(p[1]-1))*1000+(p[2]-1);
 }

 for(int I=0; I<N; I++){
  for(int i=I+1; i<N; i++){
   if(P[i]==P[I]){
    cnt++;
    P[i] = cnt;
   }
  }
 }

 cout << cnt << endl;

 return 0;
}

Measured memory_bytes: 3144
import java.awt.geom.Point2D;
import java.util.*;
public class Main {

	private double getS(double a, double b, double c){

		double z = (a + b + c) / 2;
		double s = z * (z - a) * (z - b) * (z - c);
		s = Math.sqrt(s);
		return s;
	}

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		sc.useDelimiter("[, \\r\\n]+");
		ArrayList<Point2D> list = new ArrayList<Point2D>();
		while(sc.hasNext()){
			list.add(new Point2D.Double(sc.nextDouble(), sc.nextDouble()));
		}
		double sum =0;
		int len = list.size();
		Point2D start = list.get(0);
		for(int i=1; i < len; i++ ){
			sum += getS(list.get(i).distance(start), list.get((i+1) % len).distance(start), list.get((i+1) % len).distance(list.get(i)));
		}
		System.out.printf("%1.6f\n",sum);
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();

	}

}

Measured memory_bytes: 12000
#include <stdio.h>

int gcd(int x, int y)
{
	if (y == 0) return x;
	else return gcd(y, x % y);
}

int main()
{
	int x, y;

	scanf("%d", &x);
	scanf("%d", &y);

	printf("%d\n", gcd(x, y));
	
	return 0;
}

Measured memory_bytes: 1820
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
template<typename T> T changeMax(T& a, T b){if(a < b)a = b;return 0;}

int main()
{
    string s;
    cin >> s;
    s[0] = s[0]+0x01;
    cout << s << endl;
    
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------

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

    ll n;
    cin >> n;
    vll a(10000+1,0);

    for(ll i=1;i<=100;i++){
        for(ll j=1;j<=100;j++){
            for(ll k=1;k<=100;k++){
                ll tmp = i*i + j*j + k*k + i*j + j*k + k*i;
                if(1<=tmp && tmp<=10000){
                    a[tmp]++;
                }
            }
        }
    }
    for(ll i=1;i<=n;i++){
        cout << a[i] <<endl;
    }




    
    return 0;
}



Measured memory_bytes: 3700
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n, m = map(int, input().split())
    S = []
    for i in range(m):
        k, *s = map(int, input().split())
        s = [i-1 for i in s]
        S.append(s)
    p = list(map(int, input().split()))
    ans = 0
    for i in range(2**n):
        check = [False]*m
        for j in range(m):
            s = S[j]
            cnt = 0
            for idx in s:
                if (i>>idx)&1:
                    cnt += 1
            if cnt%2 == p[j]:
                check[j] = True
        if not False in check:
            ans += 1
    print(ans)

        

if __name__ == '__main__':
    main()

Measured memory_bytes: 9220
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


void solve(long long N, std::vector<long long> a){
    if(N==1)cout<<1<<endl;
    else{
        REP(i, N){
            if(a[i]>=1&&a[i]<=399)a[i]=1;
            else if(a[i]>=400&&a[i]<=799)a[i]=2;
            else if(a[i]>=800&&a[i]<=1199)a[i]=3;
            else if(a[i]>=1200&&a[i]<=1599)a[i]=4;
            else if(a[i]>=1600&&a[i]<=1999)a[i]=5;
            else if(a[i]>=2000&&a[i]<=2399)a[i]=6;
            else if(a[i]>=2400&&a[i]<=2799)a[i]=7;
            else if(a[i]>=1800&&a[i]<=3199)a[i]=8;
            else if(a[i]>=3200)a[i]=9;
        }
        // REP(i, N)debug(a[i]);
        map<int, int> m;
        int ans=0;
        REP(i,10)m[i]=0;
        REP(i, N){
            m[a[i]]++;
        }
        // for(int i=1; i <10; i++)debug(m[i]);
        for(int i=1; i <=8; i++)if(m[i]>0)ans++;
        if(ans==0 &&m[9]>0) cout<<1<<" "<<m[9]<<endl;
        else cout<<ans<<" "<<ans+m[9]<<endl;
    }
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 256
//よくわかんない～～～～

#include <stdio.h>
  
using namespace std;
  
void outPut(int Array[],char mark){
    for(int i = 1; i <= 13; i++){
        if(Array[i] == 0) printf("%c %d\n",mark,i);
    }
}
  
int main(){
    char mark[2];
    int n,S[14],H[14],C[14],D[14],tmp;
    for(int i = 0; i < 14; i++) S[i] = H[i] = C[i] = D[i] = 0;
    scanf("%d",&n);
  
    for(int i = 0; i < n; i++){
        scanf("%s %d",mark,&tmp);
        switch(mark[0]){
        case 'S':
            S[tmp] = 1;
            break;
        case 'H':
            H[tmp] = 1;
            break;
        case 'C':
            C[tmp] = 1;
            break;
        case 'D':
            D[tmp] = 1;
            break;
        }
    }
    outPut(S,'S');
    outPut(H,'H');
    outPut(C,'C');
    outPut(D,'D');
}


Measured memory_bytes: 2736
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;
	public static void main(String[] args) {
		String N=sc.next();
		int ans=0;
		int ans2=0;
		int f=N.charAt(0)-48;
		int g=9*(N.length()-1);
		ans2=f+g-1;
		for(int i=0;i<N.length();i++) {
			ans+=N.charAt(i)-48;
		}
		p(Math.max(ans, ans2));
	}
	//N==S
	//E==W
//83 S 
	//69E
	//78N
	//87W
	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

struct edge{
    int from, to; lint cost;
    edge(int f, int t, lint c) : from(f), to(t), cost(c) {}
    edge(int t, lint c) : from(-1), to(t), cost(c) {}
};

struct dijkstra{
    vector<vector<edge> > G;
    vector<lint> d;
    int V, s;
    dijkstra(vector<vector<edge> > _G, int _s) : G(_G), s(_s){
        init();
    }
    void init(){
        V = G.size();
        d = vector<lint>(V, INF);
        priority_queue<P, vector<P>, greater<P> > que; que.push(P(0, s));
        d[s] = 0;
        while(!que.empty()){
            P p = que.top(); que.pop();
            int v = p.second;
            if(d[v] < p.first) continue;
            for(int i = 0; i < G[v].size(); i++){
                edge e = G[v][i];
                if(d[e.to] > d[v] + e.cost){
                    d[e.to] = d[v] + e.cost;
                    que.push(P(d[e.to], e.to));
                }
            }
        }
    }
    int dist(int t){
        return d[t];
    }
};

int main(){
    int n,m,s,t; cin>>n>>m>>s>>t;
    s--; t--;
    vector<vector<edge> > ga(n), gb(n);
    rep(i,m){
        lint u,v,a,b; cin>>u>>v>>a>>b;
        u--; v--;
        ga[u].push_back(edge(v,a));
        ga[v].push_back(edge(u,a));
        gb[u].push_back(edge(v,b));
        gb[v].push_back(edge(u,b));
    }

    dijkstra da(ga, s), db(gb, t);
    
    vector<P> vp;
    const lint L = 1e15;
    rep(i,n){
        lint c = da.d[i] + db.d[i];
        vp.push_back(P(L-c, i));
    }
    sort(all(vp), [](P& l, P& r){
        return l.fi > r.fi;
    });

    int j = 0;
    rep(i, n){
        while(1){
            if(vp[j].se < i){
                j++; continue;
            }else break;
        }
        out(vp[j].fi);
    }
}


Measured memory_bytes: 40504
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
using namespace std;
#define ll long long
#define INF (int)(1e9+5)
#define MOD (int)(1e9 + 7) 
#define pi 3.14159265

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    if(s.size() == 6 and s[2] == s[3] and s[4] == s[5]) {
        cout << "Yes\n"; 
    }
    else cout << "No\n";
    return 0;
}



Measured memory_bytes: 3580
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   int N;
   cin >> N;
   int h = 0;
   int tmp = N;
   for (;;) {
      h += N % 10;
      N /= 10;
      if (N == 0) break;
   }
   if (tmp % h == 0) cout << "Yes" << endl;
   else cout << "No" << endl;
   return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc= new Scanner(System.in);
		int n =sc.nextInt();
    	int x=sc.nextInt();
	    int t=sc.nextInt();

	    int min =0;

	    for(;n>0;n=n-x) {
		min=min+t;
	   }
	    System.out.println(min);
	  }

}

Measured memory_bytes: 35676
X, N = map(int, input().split(' '))
P = []
if N > 0:
  P = sorted(list(map(int, input().split(' '))))
  ans = 0
  i = 0
  while True:
    if (X-i) not in P:
      ans = (X-i)
      break
    elif (X+i) not in P:
      ans = (X+i)
      break
    else:
      i += 1

if N > 0:
  print(ans)
else:
  print(X)

Measured memory_bytes: 9172
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    n,m = LI()
    t = [0 for i in range(n+1)]
    for i in range(m):
        l,r = LI()
        t[l-1] += 1
        t[r] -= 1
    for i in range(n):
        t[i+1] += t[i]
        if t[i] == m:
            t[i] = 1
        else:
            t[i] = 0
    print(sum(t[:n]))
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    q = I()
    m = 0
    l = [-float("inf"),float("inf")]
    x = 0
    num = 0
    for _ in range(q):
        Q = LI()
        if len(Q) == 1:
            print(x,m)
        else:
            z,a,b = Q
            m += b
            if num == 0:
                num += 1
                l = [a,float("inf")]
                x = a
            elif num == 1:
                if a != l[0]:
                    num += 1
                    l = [min(a,l[0]),max(a,l[0])]
                    x = l[0]
                    m += l[1]-l[0]
            else:
                num += 1
                if num % 2:
                    if l[0] <= a < l[1]:
                        m += min(a-l[0],l[1]-a)
                        x = a
                    elif a < l[0]:
                        m += l[0]-a
                        x = l[0]
                        l = [a,l[1]]
                    else:
                        m += a-l[1]
                        x = l[1]
                        l = [l[0],a]
                else:
                    if l[0] <= a < l[1]:
                        if a < x:
                            m += x-a
                            l = [a,x]
                            x = a
                        else:
                            m += a-x
                            l = [x,a]
                    elif a < l[0]:
                        m += x-a
                        x = l[0]
                        l = [l[0],x]
                    else:
                        m += a-x
                        l = [x,l[1]]
    return

#G
def G():
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 46576
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m, d;
    cin >> m >> d;
    int ans = 0;
    for(int i = 1; i <= m; ++i){
        for(int j = 1; j <= d; ++j){
            if(j < 10) continue;
            int d1 = j%10, d2 = j/10;
            //cout << i << " " << j << " " << d1 << " " << d2;
            if(d1 >= 2 && d2 >= 2 && d1*d2 == i){
                ++ans;
                //cout << " o";
            }
            //cout << endl;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,a,b,co=0;
	cin>>n>>a>>b;
	loop(i,1,n+1){
		int sum=0;
		int c=i;
		while(c){
			sum+=c%10;
			c/=10;
		}
		if(a<=sum&&sum<=b)co+=i;
	}
	cout<<co<<endl;
}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main()
{
  ll x,ans=0;
  cin>>x;

  ans+=(x/11)*2;
  if(x%11>=7) ans+=2;
  else if(x%11>=1) ans++;

  cout<<ans<<endl;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

// vector<int> A(3010), B(3010);
// vector<P> C(3010);
// int dp[3010][3010];

#define chmax(x, y) x = max(x, y)

int dp[3005][3005];

int main()
{
    int n, t;
    cin >> n >> t;
    vector<P> p(n);
    rep(i, n)
    {
        cin >> p[i].first >> p[i].second;
    }
    sort(p.begin(), p.end());

    int ans = 0;

    rep(i, n)
    {
        rep(j, t)
        {
            chmax(dp[i + 1][j], dp[i][j]);
            int nj = j + p[i].first;
            if (nj < t)
                chmax(dp[i + 1][nj], dp[i][j] + p[i].second);
        }
        int now = dp[i][t - 1] + p[i].second;
        chmax(ans, now);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 35456
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


func getABDiff(a, b int) []int {
	x := make([]int, 2)
	i := 1
	for {
		if i == 1 {
			x[0] = 1
			x[1] = 3
		} else {
			x[0] = x[1]
			x[1] = x[1] + i + 1
		}
		if b-a == x[1]-x[0] {
			break
		}
		i++
	}
	return x
}

func main() {
	ab := strings.Split(readLine(), " ")
	a, _ := strconv.Atoi(ab[0])
	b,_  := strconv.Atoi(ab[1])
	x := getABDiff(a,b)
	fmt.Println(x[0] - a)
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
 
int main(){
    
string s,t;
cin >> s >> t;
int s_len, t_len;
int flag=0;
s_len = (int)(s.length());
t_len = (int)(t.length());
if(s_len+1!=t_len){
flag=1;
}
  for(int i=0;i<s_len;i++){
    if(s[i] != t[i]){
      flag=1;
    }
  }
 if(flag==1){
cout << "No" << endl;
 }else{
cout << "Yes" << endl;
 }
}

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

int main()
{
    double a,b;
    double i;
    int flag=1;
    
    scanf("%lf %lf",&a,&b);
    
    for(i=b*10;i<(b+1)*10;i++)
    {
        if(floor(i*0.08)==a)
        {
            flag=0;
            printf("%.0lf\n",i);
            return 0;
        }
    }
    printf("-1\n");
    return 0;
}


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

typedef long long ll;

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

int main() {
    int n;cin>>n;
    int a[4];
    rep(i,4){
        a[3-i]=n%10;
        n/=10;
    }
    int ans = 7 - a[0];
//    int tmp;
    char s1,s2,s3;

    rep(i,2){
        rep(j,2){
            rep(k,2){
        int tmp = 0;
            if(i==0){
                tmp+=a[1];
                s1 = '+';
            }
            else {
                tmp-=a[1];
                s1 = '-';
            }


           if(j==0){
                tmp+=a[2];
                s2 = '+';
            }
            else {
                tmp-=a[2];
                s2 = '-';
            }

           if(k==0){
                tmp+=a[3];
                s3 = '+';
            }
            else {
                tmp-=a[3];
                s3 = '-';
            }

             if(tmp==ans){
                cout<<a[0]<<s1<<a[1]<<s2<<a[2]<<s3<<a[3]<<"=7"<<endl;
                return 0;
            }              
             else tmp = 0;

            }
        }
    }
    
	return 0;
}



Measured memory_bytes: 3616
// ABC 159-D
// 2020.3.24 bal4u

#include <stdio.h>

typedef long long ll;

#define gc() getchar()//getchar_unlocked()
#define pc(c) putchar(c)//putchar_unlocked(c)

int in() {   // 非負整数の入力
	int n = 0; int c;
	c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
	//(c & 0xf)：字符0-9 Ascii码0x30-0x39 与0xf（即00001111）按位与运算 只保留个位数（0x0-0x9）
}

void out(ll n) { // 非負整数の表示（出力）
	int i; char b[30];

	if (!n) pc('0');
	else {
		//		if (n < 0) pc('-'), n = -n;
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}

int f[200005];
int A[200005];

int main()
{
	int i, N, a, ma;
	ll s;

	N = in();
	ma = 0;
	for (i = 0; i < N; ++i) {
		A[i] = a = in(), f[a]++;
		if (a > ma) ma = a;
	}
	s = 0; for (i = 1; i <= ma; ++i) s += (ll)f[i] * (f[i] - 1) >> 1;// >> 1:右移运算符 将其二进制右移1位 即/2
	for (i = 0; i < N; ++i) out(s - (f[A[i]]-1));
	return 0;
}

Measured memory_bytes: 3584
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

#[cfg(debug_assertions)]
macro_rules! debug {
    ($( $args:expr ),*) => { eprintln!( $( $args ),* ); }
}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($( $args:expr ),*) => {
        ()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize);
    let mut count = HashMap::<String, usize>::new();
    for _ in 0..n {
        let si = it.next().unwrap();
        *count.entry(si.to_owned()).or_default() += 1;
    }
    for k in &["AC", "WA", "TLE", "RE"] {
        println!("{} x {}", k, count.get(k.to_owned()).unwrap_or(&0));
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 2508