akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)//rep(i,回数){処理}
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
	//入力
	int n, m, k; cin >> n >> m >> k;
	vector<int> a(n); rep(i, n)cin >> a[i];
	vector<int> b(m); rep(i, m)cin >> b[i];
	//計算
	ll t = 0;
	rep(i, m) t=t+b[i];
	int j = m; int ans = 0;
	rep(i, n + 1) {
		while (j > 0 && t > k) {
			j = j - 1; t = t - b[j];
		}
		if (t > k) { break; }
		ans = max(ans, i + j);
		if (i == n) { break; }
		t = t + a[i];
	}
	//答えを出力
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4744
#include<stdio.h>
int main()
{
      char s[4];
      scanf("%s",s);
      if(s[0]=='R' && s[1]=='R' && s[2]=='R') printf("3");
      else if(s[0]=='R' && s[1]=='R' || s[1]=='R' && s[2]=='R') printf("2");
      else if(s[0]=='R' || s[1]=='R' || s[2]=='R') printf("1");
      else printf("0");
}


Measured memory_bytes: 1656
#include<stdio.h>
#include<math.h>
 
struct Point { double x,y;};
 
void koch(int n, Point a,Point b){
    if(n==0)return;
     
    Point s,t,u;
    double th=M_PI*60.0/180.0;
     
    s.x=(2.0*a.x+1.0*b.x)/3.0;
    s.y=(2.0*a.y+1.0*b.y)/3.0;
    t.x=(1.0*a.x+2.0*b.x)/3.0;
    t.y=(1.0*a.y+2.0*b.y)/3.0;
    u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
    u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;
     
    koch(n-1,a,s);
    printf("%.8f %.8f\n",s.x,s.y);
    koch(n-1,s,u);
    printf("%.8f %.8f\n",u.x,u.y);
    koch(n-1,u,t);
    printf("%.8f %.8f\n",t.x,t.y);
    koch(n-1,t,b);
}
 
int main(){
    Point a,b;
    int n;
    scanf("%d",&n);
     
    a.x=0;
    a.y=0;
    b.x=100;
    b.y=0;
     
    printf("%.8f %.8f\n",a.x,a.y);
    koch(n,a,b);
    printf("%.8f %.8f\n",b.x,b.y);
     
    return 0;
}

Measured memory_bytes: 2680
#include<bits/stdc++.h>
#include <typeinfo>
using namespace std;
#define rep(i,N) for(ll i=0;i<N;++i)
typedef long long int ll;
ll INF = (1LL<<31)-1;

int main(){
    ll x; cin >> x;
    ll ans = 2 * (x/11); x -= ((ans/2) * 11);
    if(x == 0){
    }else if(x <= 6){
        ans++;
    }else if(x < 11) ans += 2;
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int n,d1,d2,a[1000][1000];

void solve(int d)
{
    int sum=0;
    while(d % 4 == 0){
        sum++;
        d/=4;
    }
    if(d & 1){
        for(int i=0;i<n+n;i++)
            for(int j=0;j<n+n;j++)
                if(((i>>sum)+(j>>sum)) & 1) a[i][j]=1;     //101010  010101
    }
    else{
        for(int i=0;i<n+n;i++)
            for(int j=0;j<n+n;j++)
                if((i>>sum) & 1) a[i][j]=1;   //111111 000000
    }
}

int main()
{
    scanf("%d%d%d",&n,&d1,&d2);
    solve(d1);
    solve(d2);
    int cnt=0;
    for(int i=0;i<n+n;i++){
        if(cnt==n*n) break;
        for(int j=0;j<n+n;j++)
            if(!a[i][j]){printf("%d %d\n",i,j);if(++cnt==n*n) break;}
    }
    return 0;
}

Measured memory_bytes: 3200
#include<stdio.h>
#include<utility>
#include<algorithm>

using namespace std;

int a[100000];

int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }

    int x = a[n-1];
    int i = -1;
    for(int j = 0; j < n - 1; j++){
        if(a[j] <= x){
            i++;
            swap(a[i], a[j]);
        }
    }
    swap(a[i+1], a[n-1]);

    for(int j = 0; j < n; j++){
        if(j){
            if(j == i + 1){
                printf(" [%d]", a[j]);
            }
            else{
                printf(" %d", a[j]);
            }
        }
        else{
            if(j == i + 1){
                printf("[%d]", a[j]);
            }
            else{
                printf("%d", a[j]);
            }
        }
    }
    printf("\n");
}


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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素


int main(){
    int n,m,k;
    cin>>n>>m>>k;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
    }
    vector<int> b(m);
    rep(i,m){
        cin>>b[i];
    }
    vector<ll> sumb(m+1);
    int i;
    sumb[0]=0;
    int indexb;
    for(i=0;i<m;i++){
        if(sumb[i]>k){ 
            indexb=i-1;
            break;
            }
        sumb[i+1]+=sumb[i]+b[i];
        indexb=i+1;
    }
    int ans=indexb;
    ll suma=0;
    for(i=0;i<n+1;i++){
        if(suma>k)break;
        while(suma+sumb[indexb]>k) indexb--;
//        cout<<i<<" "<<indexb<<" "<<suma+sumb[indexb]<<endl;
        ans=max(ans,indexb+i);
        if(i==n) break;
        suma+=a[i];
    }
    cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 6392
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,m,sx,sy,tx,ty;
  cin >> n >> m >> sx >> sy >> tx >> ty;
  sx--,sy--,tx--,ty--;
  string s[n];
  rep(i,n) R s[i];
  int d[n][m];
  rep(i,n)rep(j,m) d[i][j]=MAX;
  d[sx][sy]=0;
  deque<P> que;
  que.pb(P(sx,sy));
  while(!que.empty()) {
    P p=que.front();que.pop_front();
    if(p==P(tx,ty)) break;
    rep(i,4) {
      int x=p.F+dx[i],y=p.S+dy[i];
      if(check(n,m,x,y)&&s[x][y]=='.'&&d[x][y]>d[p.F][p.S]) {
        d[x][y]=d[p.F][p.S];
        que.push_front(P(x,y));
      }
    }
    REP(i,-2,3) {
      REP(j,-2,3) {
        int x=p.F+i,y=p.S+j;
        if(check(n,m,x,y)&&s[x][y]=='.'&&d[x][y]>d[p.F][p.S]+1) {
          d[x][y]=d[p.F][p.S]+1;
          que.pb(P(x,y));
        }
      }
    }
  }
  if(d[tx][ty]==MAX) d[tx][ty]=-1;
  pr(d[tx][ty]);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

int n, l, odp;

int main(){
	cin>>n;
	for(int k=1; k<=n; k++){
		l=0;
		for(int i=1; i<=k; i+=2){
			if(k%i==0) l++;
		}
		if(l==8) odp++;
	}
	cout<<odp;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
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] = SR()
    return l
mod = 1000000007

#A
a,b,c = LI()
if b-a == c-b:
    print("YES")
else:
    print("NO")
#B

#C
"""
n = I()
s = SR(n)
for i in range(n):
    for j in range(len(s[i])):
        while s[i][j] in s[i][:j]:
            s[i][j] = "0"+s[i][j]
ans = set(s[0])
for i in range(1,n):
    ans &= set(s[i])
ans = sorted(list(ans))
if len(ans) == 0:print()
else:
    for i in range(len(ans)):
        ans[i] = ans[i][-1]
    ans.sort()
    for i in range(len(ans)-1):
        print(ans[i],end = "")
    print(ans[-1])
"""

#D
"""
n,m = LI()
ln = [n-1]
lm = [m-1]
a = n-1
b = m-1
while a > 2:
    a -= 2
    ln.append(ln[-1]+a)
while b > 2:
    b -= 2
    lm.append(lm[-1]+b)
la = len(ln)
lb = len(lm)
for i in range(la):
    if i or a == 2:
        ln.append(ln[la-i-1])
for i in range(lb):
    if i or b == 2:
        lm.append(lm[lb-i-1])
x,y = LIR(2)
lx = 0
ly = 0
for i in range(n-1):
    lx += ln[i]*(x[i+1]-x[i])%mod
    lx %= mod
for i in range(m-1):
    ly += lm[i]*(y[i+1]-y[i])%mod
    ly %= mod
ans = lx*ly%mod
print(ans)
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 38512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int m = sc.NextInt();
        int[] x = sc.IntArray();

        x = x.OrderBy(i => i).ToArray();

        int[] d = new int[m - 1];
        for (int i = 0; i < m - 1; i++)
        {
            d[i] = x[i + 1] - x[i];
        }
        d = d.OrderBy(i => i).ToArray();

        int remove = n - 1;
        int count = m - 1 - remove;

        int answer = 0;

        for (int i = 0; i < count; i++)
        {
            answer += d[i];
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 24160
#define _GLIBCXX_DEBUG //test only

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;
  cin >> n;
  vector<int> p(n);
  int i;
  rep(i,n) cin >> p[i];
  vector<int> ind(n);
  rep(i,n)
  {
    ind[p[i]-1] = i;
  }
  multiset<int> s;
  s.insert(-1);
  s.insert(-1);
  s.insert(n);
  s.insert(n);
  ll ans = 0;
  int num;
  for(num=n-1;num>=0;num--)
  {
    int j = ind[num];
    auto it = s.upper_bound(j);
    int a,b,c,d;
    it++;
    d = *it;
    it--;
    c = *it;
    it--;
    b = *it;
    it--;
    a = *it;
    ll ks = 0;
    ll kans = b-a;
    kans *= (c-j);
    ks += kans;
    kans = j-b;
    kans *= (d-c);
    ks += kans;
    ans += ks*(num+1);
    s.insert(j);
  }
  cout << ans << endl;
}


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

int main(){
  int n, m, b[120], A[120][120], i, j;
  cin>>n>>m;
  for(i=0; i<n; i++){
    for(j=0; j<m; j++) cin>>A[i][j];
  }
  for(j=0; j<m; j++) cin>>b[j];
  int c[120] = {};
  for(i=0;i<n;i++){
    for(j=0;j<m;j++) c[i] += A[i][j] * b[j];
    cout<<c[i]<<endl;
  }
  return 0;
}



Measured memory_bytes: 3132
#include <iostream>

using namespace std;

int main(void){
  int a[7]={1,3,5,7,8,10,12};
  int b[4]={4,6,9,11};
  int c=2;
  int x,y;
  int xa=0;
  int ya=0;
  cin >> x >> y;
  for(int i=0; i<7; i++){
    if(a[i]==x) xa=1;
    if(a[i]==y) ya=1;
  }
  for(int i=0; i<4; i++){
    if(b[i]==x) xa=2;
    if(b[i]==y) ya=2;
  }
  if(c==x) xa=3;
  if(c==y) ya=3;
  if(xa==ya) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;
template <typename T>
T sq(T x){
  return x * x;
}

signed main (){
  string S;
  cin >> S;
vector<int> cnt(27);

rep(i,SZ(S)){
cnt.at(int(S.at(i)) - int('a'))++;
}
rep(i,27){

if(cnt.at(i) > 1){
cout << "no" << endl;
return 0;
}
}

cout << "yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MAXN 200009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int arr[MAXN];
int main(){
	//~ #ifndef ONLINE_JUDGE
    //~ freopen("file.in", "r", stdin);
	//~ #endif	
	int n;
	scanf("%d",&n);
	ll sum=0,now=0;
	for(int i=1;i<=n;i++)
		scanf("%d",arr+i),sum+=arr[i];
	ll ans=LONG_LONG_MAX;	
	for(int i=1;i<n;i++){
		now+=arr[i];
		umin(ans,abs(now-(sum-now)));
	}	
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>

#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)

using namespace std;
typedef long long ll;
const ll N=12e4;

ll a[N];
ll ans[N],xs[N];
  
int d=0,n,q;

inline void solve(ll xx,int k,ll ti)
{
	if(k==1){
		ll cs=ti/a[k]; xs[1]=xs[1]+xx*cs;
		int sy=ti%a[k];
		ans[1]+=xx; ans[sy+1]-=xx;
		return;
	}
	ll op=ti/a[k];
	xs[k]+=op*xx;
	ti=ti%a[k];
	int l=1,r=k;
	while(l+1<r){
		int mid=l+r>>1;
		if(a[mid]<=ti)l=mid;
		else r=mid;
	}
	solve(xx,l,ti);
}

int main()
{
	scanf("%d%d",&n,&q);
	a[1]=n; a[0]=1;
	fo(i,1,q){
		++a[0]; scanf("%lld",&a[a[0]]);
		while(a[0]>1&&a[a[0]]<=a[a[0]-1])a[a[0]-1]=a[a[0]],--a[0];
	}
	q=a[0]; xs[q]=1;
	fd(i,q,2)
	solve(xs[i],i-1,a[i]);
	fo(i,1,n)ans[i]=ans[i-1]+ans[i];
	fo(i,1,a[1])ans[i]=ans[i]+xs[1];
	fo(i,1,n)printf("%lld\n",ans[i]);
}

Measured memory_bytes: 4096
#include<stdio.h>

int main(void){
  int i,L,n[13],m[13],sum;

  while(scanf("%d",&L),L){
    
    sum=0;
    for(i=1;i<=12;i++){
      scanf("%d %d",&m[i],&n[i]);
    }
    for(i=1;i<=12;i++){
      sum+=m[i]-n[i];
      if(sum>=L)break;
    }
    
    if(sum<L)printf("NA\n");
    else printf("%d\n",i);

  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
struct UF {
	vi e;
	UF(int n) : e(n, -1) {}
	bool same_set(int a, int b) { return find(a) == find(b); }
	int size(int x) { return -e[find(x)]; }
	int find(int x) { return e[x] < 0 ? x : e[x] = find(e[x]); }
	void join(int a, int b) {
		a = find(a), b = find(b);
		if (a == b) return;
		if (e[a] > e[b]) swap(a, b);
		e[a] += e[b]; e[b] = a;
	}
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vector<ll> a(n), b(n);
    rep(i,0,n) cin >> a[i] >> b[i];
    vector<vi> g(n);
    rep(i,0,m) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<tuple<ll,ll,int>> os;
    rep(i,0,n) os.emplace_back(a[i],-b[i],i);
    sort(all(os));
    UF uf(n);
    vector<ll> sum(n), ans(n);
    int last=-1;
    vector<bool> vis(n);
    rep(t,0,n) {
        int u = get<2>(os[t]);
        vis[u]=true;
        int r = u;
        vi cs;
        {
            set<int> ch;
            for(int v:g[r]) {
                if(vis[v]) ch.insert(uf.find(v));
            }
            for(int v:ch) cs.push_back(v);
        }
        for(int v:cs) uf.join(r,v);
        r = uf.find(r);
        ll su = b[u];
        for(int v:cs) su += sum[v];
        ll best=max(a[u],b[u])+su-b[u];
        for(int i:cs) {
            best=min(best,su-b[u]-sum[i]+max(a[u],b[u]+ans[i]));
        }
        ans[r]=best;
        sum[r]=su;
        last=r;
    }
    cout<<ans[last]<<"\n";
}


Measured memory_bytes: 14184
N,M = map(int,input().split())
A = []
for i in range(M):
    p,y = map(int,input().split())
    A.append([p,y,i,0])
A.sort(key = lambda x:x[1])
D = dict()
for a in A:
    if a[0] not in D:
        D[a[0]] = 1
    else:
        D[a[0]] += 1
    a[3] = D[a[0]]
A.sort(key=lambda x:x[2])
for a in A:
    print(str(a[0]).zfill(6)+str(a[3]).zfill(6))


Measured memory_bytes: 33620
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

int main() {
  vi grp{0,1,3,1,2,1,2,1,1,2,1,2,1};
  int x,y;
  cin >> x >> y;
  if(grp[x]==grp[y]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

const long long INF = 1e15;

using namespace std;

template<typename T>
bool chmax(T& a, const T& b){
  if(a < b){
    a = b;
    return true;
  }else return false;
}

int main(){
  int N;
  cin >> N;
  
  vector<int> A(N + 1);
  A[0] = 0;
  for(int i = 1; i <= N; i++){
    cin >> A[i];
  }
  
  vector<vector<long long>> dp(N + 10, vector<long long>(3, -INF));
  
  dp[0][1] = 0;
  dp[1][0] = A[1];
  for(int i = 0; i <= N; i++){
    for(int j = 0; j <= 2; j++){
      if(i + 2 <= N) chmax(dp[i + 2][j], dp[i][j] + A[i + 2]);
      if(i + 1 <= N && j + 1 <= 2) chmax(dp[i + 1][j + 1], dp[i][j]);
    }
  }
  
  cout << dp[N][(N & 1) + 1] << endl;
  
  return 0;
}

Measured memory_bytes: 14816
#include<iostream>'
using namespace std;
int main()
{
	int N,i,j,k,count=0;
	cin>>N;
	int arr[N];
	for(i=0;i<N;i++)
	{
		cin>>arr[i];
	}
	for(i=0;i<N;i++)
	{
		for(j=i+1;j<N;j++)
		{
			for(k=j+1;k<N;k++)
			{
				if((arr[i]+arr[j]>arr[k])&&(arr[j]+arr[k]>arr[i])&&(arr[i]+arr[k]>arr[j])&&((arr[i]!=arr[j])&&(arr[j]!=arr[k])&&(arr[i]!=arr[k])))
				count++;
			}
		}
	}
	cout<<count;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int a, b, c=0;
	cin >> a >> b;
	for (int i = 1; i <= b - a; i++) {
		c += i;
	}
	cout << c - b << endl;
	int x;
	cin >> x;
}

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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 2 * N;

int n, m;
int h[N], e[M], ne[M], idx;
int d[N];

void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ;
}

void dfs(int u, int v)
{
	d[u] = v;
	for (int i = h[u]; ~i; i = ne[i])
	{
		int j = e[i];
		if (d[j]) continue;
		
		dfs(j, v);
	}
}

int main()
{
	memset(h, -1, sizeof h);
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i ++ )
	{
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		add(a, b), add(b, a);
	}
	
	for (int i = 1, j = 1; i <= n; i ++ )
		if (!d[i])
		{
			dfs(i, j);
			j ++ ;
		}
			
	int res = 0;
	for (int i = 1; i <= n; i ++ ) res = max(res, d[i]);
	printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 10604
#include <iostream>
#include <iomanip>
#include <cmath>


using namespace std;

int main(){
    double r;
    cin >> r;
    cout << fixed;
    cout << setprecision(6);
    cout << r*r*M_PI << " " << 2*r*M_PI << endl;
    return 0;
    
}


Measured memory_bytes: 3280
n = input()
a = list(map(int,input().split()))
ans = 1
for i in range(int(n)):
  ans *= a[i]
  if ans>1000000000000000000:
    ans = -1
    break
for i in range(int(n)):
  if a[i] == 0:
    ans = 0
print(ans) 

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

using namespace std;

int main(void) {
    int n;
    cin >> n;
    long long ans = 1;
    int flag = 0;
    int flag0 = 0;
    for(int i = 0; i < n; i++){
        long long a;
        cin >> a;
        if(a == 0){
            flag0 = 1;
            break;
        }
        if(a <= 1000000000000000000 / ans){
            ans *= a;
        }
        else{
            flag = 1;
            //break;
        }
    }
    if(flag0 == 1){
        cout << 0 << endl;
    }
    else if(flag == 1){
        cout << -1 << endl;
    }
    else{
        cout << ans << endl;
    }
    return 0;
}


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



int main(){
	

	int N;
	cin>>N;
	long long x;
	cin>>x;
	vector<long long> a(N);
	
	for(int i=0;i<N;i++)cin>>a[i];
	
	long long ans = 0;
	
	for(int i=1;i<N;i++){
		long long A = a[i]+a[i-1];
		if(A<=x)continue;
		
		if(A-x<a[i]){
			ans += A-x;
			a[i] -= A-x;
		}
		else{
			ans += A-x;
			a[i]=0;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}


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

int main() {

  // 配列
  vector<vector<int>> A(3, vector<int>(3));
//  vector<int> A(3,3); // int型の配列変数vecを宣言
  
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
    	cin >> A.at(i).at(j);
    }
  }

  int N;
  cin >> N;
  vector<int> b(N);
  for (int k = 0; k < N; k++) {
   	cin >> b.at(k);
  }
  
  //
  vector<vector<int>> C(3, vector<int>(3));
//  vector<int> C(3,3); // 判定
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < N; k++) {
    	if(A.at(i).at(j) == b.at(k)){
          C.at(i).at(j) = 1;
        }
      }
    }
  }
  
  string ANS = "No";
  if(C.at(0).at(0)*C.at(0).at(1)*C.at(0).at(2) == 1){
    ANS = "Yes";
  }
  if(C.at(1).at(0)*C.at(1).at(1)*C.at(1).at(2) == 1){
    ANS = "Yes";
  }    
  if(C.at(2).at(0)*C.at(2).at(1)*C.at(2).at(2) == 1){
    ANS = "Yes";
  }

  if(C.at(0).at(0)*C.at(1).at(0)*C.at(2).at(0) == 1){
    ANS = "Yes";
  }
  if(C.at(0).at(1)*C.at(1).at(1)*C.at(2).at(1) == 1){
    ANS = "Yes";
  }    
  if(C.at(0).at(2)*C.at(1).at(2)*C.at(2).at(2) == 1){
    ANS = "Yes";
  }
 
  if(C.at(0).at(0)*C.at(1).at(1)*C.at(2).at(2) == 1){
    ANS = "Yes";
  }
  if(C.at(0).at(2)*C.at(1).at(1)*C.at(2).at(0) == 1){
    ANS = "Yes";
  }    

  cout << ANS << endl;


}


Measured memory_bytes: 256
import math
h, w = map(int,input().split())
if w == 1 or h == 1:
    print(1)
    quit()
if h % 2 != 0:
    ans = w * (h-1) / 2 + math.ceil(w / 2)
    print(int(ans))
else:
    ans = w * h / 2
    print(int(ans))

Measured memory_bytes: 3060
def b_SomeSums(N, A, B):
    def sum_digit(N):
        # Nの各桁の和を計算
        ret = 0
        N = str(N)
        for i in range(len(N)):
            ret += int(N[i])
        return ret

    ans = 0
    for i in range(1, N + 1):
        tmp = sum_digit(i)
        if A <= tmp <= B:
            ans += i
    return ans

N,A,B = [int(i) for i in input().split()]
print(b_SomeSums(N, A, B))

Measured memory_bytes: 3064
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Set<Integer>[] positive = new HashSet[n];
		Set<Integer>[] negative = new HashSet[n];

		for (int i = 0; i < n; i++) {
			positive[i] = new HashSet<>();
			negative[i] = new HashSet<>();
			int m = sc.nextInt();
			while (m-- > 0) {
				int x = sc.nextInt() - 1;
				if (sc.nextInt() == 1) {
					positive[i].add(x);
				} else {
					negative[i].add(x);
				}
			}
		}

		long answer = 0;
		for (int i = (1 << n) - 1; i >= 0; i--) {
			Set<Integer> p = new HashSet<>();
			int t = 1;
			for (int j = 0; j < n; j++) {
				if ((t & i) > 0) p.add(j);
				t <<= 1;
			}

			boolean valid = true;
			for (int j = 0; j < n; j++) {
				if (!p.contains(j)) continue;
				for (int x : positive[j]) {
					if (!p.contains(x)) {
						valid = false;
					}
				}
				for (int x : negative[j]) {
					if (p.contains(x)) {
						valid = false;
					}
				}
			}
			if (valid) answer = Math.max(answer, p.size());
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 45440
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const int inf = numeric_limits<int>::max();
const ll mod = 1e9 + 7;

ll fact[100100];
ll ifact[100100];

ll comb(int n, int k){
  ll calc = fact[n];
  calc *= ifact[n-k];
  calc %= mod;
  calc *= ifact[k];
  calc %= mod;
  return calc;
}


void init(){
  fact[0] = 1;
  for(int i = 1;i < 100100;++i){
    fact[i] = fact[i-1] * i;
    fact[i] %= mod;
  }
  ll inv = 1;
  ll x = fact[100100-1];
  ll cnt = mod-2;
  while(cnt > 0){
    if(cnt & 1)
      inv = inv * x % mod;
    x = x * x % mod;
    cnt >>= 1;
  }
  for(int i = 100100-1;i >= 0;--i){
    ifact[i] = inv;
    inv *= i;
    inv %= mod;
  }
}

int main(void){
  init();
  ll n;
  vector< ll > a;
  int index[100100];
  int dupel,duper;
  fill(index,index+100100,-1);
  cin >> n;
  a.resize(n+1);
  for(int i = 0;i < n+1;++i){
    cin >> a[i];
    if(index[a[i]] != -1){
      dupel = index[a[i]];
      duper = i;
    }else{
      index[a[i]] = i;
    }
  }
  ll m = dupel + (n - duper);
  for(int k = 1;k <= n+1;++k){
    ll res = comb(n+1,k);
    if(m >= k-1)res -= comb(m,k-1);
    res = (res + mod) % mod;
    cout << res << endl;
  }
  return 0;
}


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll r;
ll D;
ll x;
int main() {
	cin >> r >> D;
	cin >> x;

	REP(i,0,10){
		x *= r;
		x -= D;
		cout << x << endl;
	}
	return 0;
}


Measured memory_bytes: 256
N, A, B = map(int, input().split())

res = 0
for i in range(1, N+1):
    n = i
    sums = 0
    while i > 0:
      sums += i % 10
      i = int(i / 10)

    if A <= sums and sums <= B:
        res += n

print(res)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <utility>
#define llint long long
#define mod 1000000009

using namespace std;

llint W, H, N;
pair<llint, llint> p[35];

void getmatE(llint A[80][80])
{
	for(int i = 0; i < W; i++){
		for(int j = 0; j < W; j++){
			A[i][j] = (i == j);
		}
	}
}

void matcopy(llint A[80][80], llint B[80][80])
{
	for(int i = 0; i < W; i++){
		for(int j = 0; j < W; j++){
			B[i][j] = A[i][j];
		}
	}
}

void matmul(llint A[80][80], llint B[80][80], llint C[80][80])
{
	llint tmp[80][80];
	for(int i = 0; i < W; i++){
		for(int j = 0; j < W; j++){
			tmp[i][j] = 0;
		}
	}
	
	for(int i = 0; i < W; i++){
		for(int k = 0; k < W; k++){
			if(A[i][k] == 0) continue;
			for(int j = 0; j < W; j++){
				tmp[i][j] += (A[i][k] * B[k][j]) % mod;
				tmp[i][j] %= mod;
			}
		}
	}
	matcopy(tmp, C);
}

void matpow(llint A[80][80], llint n, llint B[80][80])
{
	if(n == 0){
		getmatE(B);
		return;
	}
	if(n % 2){
		matpow(A, n-1, B);
		matmul(B, A, B);
	}
	else{
		matpow(A, n/2, B);
		matmul(B, B, B);
	}
}

void matvec(llint A[80][80], llint v[80], llint vd[80])
{
	llint tmp[80];
	for(int i = 0; i < W; i++){
		llint sum = 0;
		for(int j = 0; j < W; j++){
			sum += (A[i][j] * v[j]) % mod;
			sum %= mod;
		}
		tmp[i] = sum;
	}
	for(int i = 0; i < W; i++) vd[i] = tmp[i];
}

int main(void)
{
	for(int c = 1; ; c++){
		cin >> W >> H >> N;
		if(W == 0 && H == 0 && N == 0) break;
		for(int i = 0; i < N; i++){
			cin >> p[i].second >> p[i].first;
			p[i].second--, p[i].first--;
		}
		sort(p, p+N);
		
		llint transmat[80][80];
		for(int i = 0; i < W; i++){
			for(int j = 0; j < W; j++){
				if(abs(i-j) <= 1) transmat[i][j] = 1;
				else transmat[i][j] = 0;
			}
		}
		llint vec[80];
		for(int i = 0; i < W; i++) vec[i] = 0;
		vec[0] = 1;
		
		llint dy, prev_y = 0, mat[80][80];
		for(int i = 0; i < N; i++){
			dy = p[i].first - prev_y;
			matpow(transmat, dy, mat);
			matvec(mat, vec, vec);
			
			prev_y = p[i].first;
			while(i < N && p[i].first == prev_y){
				vec[p[i].second] = 0;
				i++;
			}
			i--;
		}
		
		matpow(transmat, (H-1)-prev_y, mat);
		matvec(mat, vec, vec);
		
		cout << "Case " << c << ": " << vec[W-1] << endl;
	}
	
	return 0;
}

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

int main(){
  ll n,m;
  priority_queue <int> PQ;
  pair <int,int> a[100006];

  scanf("%lld %lld", &n ,&m);

  int i;
  for(i = 0;i < n;i++){
    scanf("%d %d", &a[i].first, &a[i].second);
  }

  sort(a,a + n);

  int j;

  j = 0;
  int t;
  ll ans = 0;

  for(i = 1;i <= m;i++){
    while(a[j].first == i){
      t = a[j].second;
      j++;
      PQ.push(t);
    }

    if(!(PQ.empty())){
      ans += PQ.top(); PQ.pop();
    }
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 1660
#include<iostream>
#include <math.h>

using namespace std;

main(){
    int d, n, c;
    cin >> d >> n;
    c = double(d);
    if(n == 0) {
        cout << n <<endl;
    }
    else {
        if(n == 100) cout << int((n + 1)*pow(100, d)) << endl;
        else cout << int(n*pow(100, d)) << endl;
    }
}

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

bool check(bool bingo[3][3]){
	for(int i = 0; i < 3; i++){
		if(bingo[0][i] && bingo[1][i] && bingo[2][i]) return true;
	}
	for(int i = 0; i < 3; i++){
		if(bingo[i][0] && bingo[i][1] && bingo[i][2]) return true;
	}
	if(bingo[0][0] && bingo[1][1] && bingo[2][2]) return true;
	else if(bingo[0][2] && bingo[1][1] && bingo[2][0]) return true;
	return false;
}

int main(){
	int A[3][3];
	bool bingo[3][3];
	int N;
	vector<int> b;
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			int tmp;
			cin >> tmp;
			A[i][j] = tmp;
			bingo[i][j] = false;
		}
	}
	cin >> N;
	for(int i = 0; i < N; i++){
		int b;
		cin >> b;
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 3; k++){
				if(A[j][k] == b)	bingo[j][k] = true;
			}
		}
	}
	
	if(check(bingo)) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e16;

/*
<url:>
問題文============================================================

=================================================================

解説=============================================================

================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> s(N);
    for(auto &in:s) cin >> in;
    sort(s.begin(),s.end());
    ll sum = 0;
    for(auto v:s) sum += v;
    ll ans = 0;
    if(sum % 10 != 0){
        ans = max(ans,sum);
    }
    for(auto v:s){
        if((sum - v)%10 != 0){
            ans = max(ans,sum - v);
        }
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
#define vv(a,b) vector< vector<int> > v(a,vector<int>(b,0));
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    string s;
    cin>>s;
    int n=s.length();
    string ans=string(n,'x');
    cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;

int main()
{
    ll n;
    cin >> n;
    vl a(n, 0);
    rep(i, n)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    ll amax = a[n - 1] + 1;
    vector<ll> dp(amax, 0);
    rep(i, n)
    {
        if (dp[a[i]] != 0)
        {
            dp[a[i]] = 2;
            continue;
        }
        for (ll j = 1; a[i] * j <= amax; j++)
        {
            dp[a[i] * j]++;
        }
    }
    ll ans = 0;
    rep(i, n)
    {
        if (dp[a[i]] == 1)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12684
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;



const int N = 105;
char str[N];

int main(int,  char **)
{
#ifdef LOCAL
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    scanf("%s", str);
    if (string(str, str + 4) == "YAKI")
        printf("Yes\n");
    else
        printf("No\n");




	return 0;
}



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

int main(){
    using namespace std;

    unsigned long N;
    cin >> N;

    vector<unsigned long> A(N), B(N);
    for(auto&& i : A)cin >> i;
    for(auto&& i : B)cin >> i;
    unsigned long t{static_cast<unsigned long>(max_element(begin(A), end(A)) - begin(A))};
    rotate(begin(A), begin(A) + t, end(A));
    rotate(begin(B), begin(B) + t, end(B));
    A.push_back(A[0]);
    B.push_back(B[0]);

    vector<unsigned long> C(N + 1);
    vector<unsigned long> convex_hull{0, 1};
    const auto& is_convex = [&A](unsigned long i, unsigned long j, unsigned long k) -> bool {
        return j * A[k] + k * A[i] + i * A[j] < j * A[i] + k * A[j] + i * A[k];
    };
    C[0] = 10000000000000;
    C[1] = 10000000000000;

    for(unsigned long i{2}; i <= N; ++i)C[i] = 2 * C[i - 1] - 2 * B[i - 1] - C[i - 2];

    for(unsigned long i{0}; i <= N; ++i){
        A[i] += C[i] -= C.back();
        while(convex_hull.size() >= 2 && !is_convex(convex_hull.end()[-2], convex_hull.end()[-1], i))convex_hull.pop_back();
        convex_hull.push_back(i);
    }
    unsigned long ans{0};
    for(unsigned long i{0}; i + 1 < convex_hull.size(); ++i)ans += (convex_hull[i + 1] - convex_hull[i] + 1) * A[convex_hull[i]] + (convex_hull[i + 1] - convex_hull[i] - 1) * A[convex_hull[i + 1]];

    unsigned long g{ans - 2 * accumulate(C.begin(), C.end(), 0UL)};
    string S;
    {
        stringstream ss;
        ss << setprecision(12) << (g % (2 * N)) / (2.0L * N);
        S = ss.str();
        S.erase(S.begin());
    }
    cout << g / (2 * N) << S << endl;

    return 0;
}

Measured memory_bytes: 11352
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;

int a[9];
int dp[9][1<<10][30];

int dfs(int p, int s, int c) {
	if (p == 9) return c == 0 && s == (1<<10)-2;
	if (~dp[p][s][c]) return dp[p][s][c];
	
	if (p == 3 || p == 6 || p == 8) {
		int q = c % 10;
		if (s >> q & 1) return 0;
		if (a[p] != -1 && a[p] != q) return 0;
		return dp[p][s][c] = dfs(p + 1, s | 1<<q, c / 10);
	}
	
	int res = 0;
	
	FOR(i, 1, 10) {
		if (s >> i & 1) continue;
		if (a[p] != -1 && a[p] != i) continue;
		res += dfs(p + 1, s | 1<<i, c + i);
	}
	return dp[p][s][c] = res;
}

int main() {
	cin >> a[0] >> a[4] >> a[1] >> a[7] >> a[5] >> a[2] >> a[8] >> a[6] >> a[3];
	memset(dp, -1, sizeof(dp));
	cout << dfs(0, 0, 0) << endl;
	
	
	return 0;
}

Measured memory_bytes: 4176
k = int(input())
sevens = 7 % k

if k % 2 ==0:
    print(-1)
else:
    for i in range(k):
        if sevens % k ==0:
            print(i+1)
            break
        else:
            sevens = (sevens*10 + 7) % k
    else:
        print(-1)

Measured memory_bytes: 9172
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
int a, b;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
    cin >> a >> b;
    int ans = 0;
    for (int i = a; i <= b; ++i) {
        string tmp_s = to_string(i);
        string forward = tmp_s.substr(0, 3);
        string back = tmp_s.substr(2, 3);
        reverse(back.begin(), back.end());
        if (forward.compare(back) == 0) {
            ans++;
        }
    }
    cout << ans << endl;
    return;
}

int main() {
    solve();
    return 0;
}



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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int a[100];
int cells[100][100]; // r * c

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

  vector<vector<char>> S(N, vector<char>(N));

  rep0(i, N) {
    string s; cin >> s;
    rep0(j, N) {
      S[i][j] = s[j];
    }
  }

  ll ans = 0;
  rep(X, -(N-1), N) {
    bool check = true;
    rep0(i, N) {
      if (!check) break;
      rep0(j, N) {
        if ((i - j - X) % N == 0) continue;
        if (S[i][j] != S[(j + X + N) % N][(i - X + N) % N]) {
          check = false;
        }
        if (!check) break;
      }
    }
    if (check) {
      ans += (N - abs(X));
    }
  }

  cout << ans << BR;
  return 0;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-

def main():
    n, y = map(int, input().split())

    for a in range(n + 1):
        if (a * 10000 > y):
            continue
        for b in range((n + 1) - a):
            c = n - (a + b)
            if ((a * 10000 + b * 5000 + c * 1000) == y):
                print('{} {} {}'.format(a, b, c))
                exit()

    print(-1, -1, -1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define req(i, c) for(int i=0; i<(int)c; i++)
const int inf = 1000000000; //10^9

int main(){
  int N;
  cin >> N;
  vector<int> X(N);
  req(i, N) cin >> X[i];
  int ans = inf;
  for(int i= 1; i<101; i++){
    int cost = 0;
    req(j, N) cost += (X[j]-i)*(X[j]-i);
    ans = min(cost, ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/**

Idea
----

dp(i,j) = dp(i-1,j-1) * p(j) +dp(i,j-1) * (1-p(j))

Both cases we only need to know about "j-1" th column that is the previous column.
So , we can get rid of 1 dimension .

But , we must build the rows from Bottom to Top , so that the ones we will need later don't get overlapped .

**/

/** Which of the favors of your Lord will you deny ? **/

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

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define MP make_pair
#define F first
#define S second

#define ALL(x) (x).begin(), (x).end()
#define DBG(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << endl
#define READ        freopen("alu.txt", "r", stdin)
#define WRITE       freopen("vorta.txt", "w", stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class TIn>using indexed_set = tree<TIn, null_type, less<TIn>,rb_tree_tag, tree_order_statistics_node_update>;

/**

PBDS
-------------------------------------------------
1) insert(value)
2) erase(value)
3) order_of_key(value) // 0 based indexing
4) *find_by_order(position) // 0 based indexing

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);

inline void optimizeIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int nmax = 3e3+7;
const LL LINF = 1e17;

template <class T>
string to_str(T x)
{
    stringstream ss;
    ss<<x;
    return ss.str();
}

//bool cmp(const PII &A,const PII &B)
//{
//
//}

double p[nmax];
double dp[nmax];

int main()
{
    optimizeIO();

    int n;
    cin>>n;

    for(int i=1;i<=n;i++)
        cin>>p[i];

    dp[0] = 1;

    for(int c=1;c<=n;c++)
    {
        for(int h=n;h>=0;h--) /** MUST BE Bottom to Top row **/
        {
            double p1 = 0 , p2 = 0;

            if(h>0) p1 = dp[h-1] * p[c];
            p2 = dp[h] * (1-p[c]);

            dp[h] = p1 + p2;
        }
    }

    double ans = 0;

    for(int h=0;h<=n;h++)
    {
        int t = n-h;

        if(h>t)
            ans += dp[h];
    }

    cout << setprecision(9) << ans<<endl;;

    return 0;
}

/**

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}




Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	char ch;
	map<char, int> mp;
	while (cin >> ch) {
		if (0x41 <= ch && ch <= 0x5a) {
			mp[ch + 0x20] += 1;
	    } else if (0x61 <= ch && ch <= 0x7a) {
	    	mp[ch] += 1;
	    }
	}

	FOR(i, 0x61, 0x7b) {
		printf("%c : %d\n", i, mp[i]);
	}
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}



Measured memory_bytes: 3232
/*
				C++
				encoding: UTF-8
				Last Modified: 29/Aug/20 06:21:23 PM
*/

#include <bits/stdc++.h>
#ifdef H4wk3ye
#	include <prettypr.hpp>
#endif

using namespace std;

#define int int64_t

template < typename T > void print (const T& t) {
	cout << t << '\n';
}

template < typename T, typename U, typename... ARGS >
void print (const T& t, const U& u, const ARGS&... args) {
	cout << t << " ";
	print (u, args...);
}

const int MAXN = 1e6 + 5;
bool prime[MAXN];
set< int > indexes[MAXN];

int spf[MAXN];
bool flag = 0;

void sieve () {
	spf[1] = 1;
	for (int i = 2; i < MAXN; i++)
		spf[i] = i;

	for (int i = 4; i < MAXN; i += 2)
		spf[i] = 2;

	for (int i = 3; i * i < MAXN; i++) {
		if (spf[i] == i) {
			for (int j = i * i; j < MAXN; j += i)
				if (spf[j] == j) spf[j] = i;
		}
	}
}

void factorize (int n, int idx) {
	while (n != 1) {
		indexes[spf[n]].insert (idx);
		if (indexes[spf[n]].size () > 1) {
			flag = 1;
			break;
		}
		n = n / spf[n];
	}
}

signed main () {
	ios_base::sync_with_stdio (false), cin.tie (nullptr);
	int n;
	cin >> n;
	vector< int > arr (n);
	int g = 0;

	sieve ();
	for (int i = 0; i < n; ++i) {
		cin >> arr[i];
		g = __gcd (arr[i], g);
		if (!flag) factorize (arr[i], i);
	}

	if (flag) {
		if (g == 1)
			print ("setwise coprime");
		else
			print ("not coprime");
	} else {
		print ("pairwise coprime");
	}

	return 0;
}

Measured memory_bytes: 65704
n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))

s = 1

for i in range(n):
    if s < sum(l1[:(i + 1):]) + sum(l2[i::]):
        s = sum(l1[:(i + 1):]) + sum(l2[i::])
print(s)

Measured memory_bytes: 3060
h,w=map(int,input().split())
g=[list(input()) for _ in range(h)]
gg=[]
for l in zip(*g):
	if not all(x=="." for x in l):
		gg.append(l)
ggg=[]
for l in zip(*gg):
	if not all(x=="." for x in l):
		print("".join(l))

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

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

typedef long long LL;
typedef unsigned long long ULL;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

void solve() {
  int socket = 1;
  int ans = 0;
  int A, B; cin >> A >> B;
  while (socket < B) {
    socket += A-1;
    ans++;
  }
  cout << ans << endl;
}

int main(int argc, char const *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout<<std::fixed<<std::setprecision(10);
  solve();
  return 0;
}

Measured memory_bytes: 256