akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n;

	cin>>n;

	vi score(101);
	vector<pair<string, int>> sp(n);

	rep(i, n){
		cin>>sp[i].first>>sp[i].second;
		sp[i].second=100-sp[i].second;
		score[sp[i].second]=i+1;
	}

	sort(all(sp));

	rep(i, n){
		cout<<score[sp[i].second]<<endl;
	}
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=1000000000000;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}


//////////////////////////////////////
#define MAX_N 300000//調節！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
int par[MAX_N],dep[MAX_N];//depはrankのこと
//n要素で初期化//忘れないように！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
void init(int n){
    for(int i=0;i<=n-1;i++){//頂点番号は0~n-1
        par[i]=i;
        dep[i]=0;
    }
}
//木の根を求める
int find(int x){
    return par[x]==x?x:par[x]=find(par[x]);
}
//xとyの属する集合を併合
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
    if(dep[x]<dep[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(dep[x]==dep[y])dep[x]++;
    }
}
//xとyが同じ集合に属するか否か
bool same(int x,int y){
    return find(x)==find(y);
}

//////////////////////////////////////

struct po{
    i_i da;
    int num;
};

bool comp(po a,po b){
    if(a.da.first<b.da.first)return true;
    else if(a.da.first==b.da.first&&a.da.second<b.da.second)return true;
    else return false;
}


int main(){
    int n,k,l;cin>>n>>k>>l;
    po data[n];
    init(n);
    while(k--){
        int a,b;cin>>a>>b;a--;b--;
        unite(a,b);
    }
    rep(i,0,n-1){
        data[i].da.first=find(i);
    }
    init(n);
    while(l--){
        int a,b;cin>>a>>b;a--;b--;
        unite(a,b);
    }
    rep(i,0,n-1){
        data[i].da.second=find(i);
    }
    rep(i,0,n-1)data[i].num=i;
    sort(data,data+n,comp);
    
    int ans[n];
    int pos=0;
    while(pos<=n-1){
        vector<int>v;
        v.push_back(data[pos].num);
        while(pos<=n-2&&data[pos].da==data[pos+1].da){
            pos++;
            v.push_back(data[pos].num);
        }
        int size=v.size();
        for(auto x:v){
            ans[x]=size;
        }
        pos++;
    }
    rep(i,0,n-1){
        cout<<ans[i]<<" ";
    }
    
    return 0;
}


Measured memory_bytes: 5512
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
 
int main() {
  int n;
  while(cin >> n && n) {
    vector<P> a;
    a.resize(n);
    string s;
    getline(cin,s);
    for(int j=0; j<n; j++) {
      getline(cin,s);
      stringstream ss;
      ss << s;
      ss >> a[j].second;
      a[j].second*=-1;
      a[j].first=0;
      vector<int> b;
      int x;
      while(ss >> x) b.push_back(x);
      int i=0,k=0;
      vector<int> c;
      c.resize(b.size()+1);
      fill(c.begin(),c.end(),0);
      while(i<b.size()) {
        k++;
        a[j].first+=b[i];
        if(i&&c[i-1]) a[j].first+=b[i];
        if(i>=2&&c[i-2]==2) a[j].first+=b[i];
        if(b[i]==10) {
          if(k<10)c[i]=2;
          i++;
          continue;
        }
        i++;
        if(i>=b.size()) break;
        a[j].first+=b[i];
        if(i>=2&&c[i-2]==2) a[j].first+=b[i];
        if(b[i-1]+b[i]==10) {
          if(k<10)c[i]=1;
          i++;
          continue;
        }
        i++;
      }
    }
    sort(a.rbegin(),a.rend());
    for(int i=0; i<n; i++) cout << -a[i].second << " " << a[i].first << endl;
  }
  return 0;
}


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

int main() {
  vector<int> ans(26);
  string s;

  cin >> s;

  for (int i = 0; i < (int)s.size(); i++) {
    ans.at(s.at(i) - 97)++;
  }

  for (int i = 0; i < 26; i++) {
    if (ans.at(i) % 2) {
      cout << "No";
      return 0;
    }
  }

  cout << "Yes";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
const int MOD = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

//-------------------ここから回答する-----------------------

void solve(void)
{
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    int res = 0;
    rep(i, s.length())
    {
        if (s[i] == 'I')
            res++;
        else
            res--;
        ans = max(ans, res);
    }
    cout << ans << endl;
}
int main(void)
{
    solve();
}


Measured memory_bytes: 3628
/**
 *
 * Contest - Problema X: Nome (link)
 *
 * Abridge version.
 *
 * Solution: text
 */
#include <iostream>

#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstring>
#include <algorithm>

using namespace std;

using ll = long long;
using ii = pair<ll, ll>;

#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))
#define LOGM(msg) (cerr << (msg))
#define LOGV(vec, sep) { cerr << #vec << " ="; for (const auto& v : vec) cerr << " " << v; cerr << (sep); }
#define LOGA(arr, N, sep) { cerr << #arr << " ="; for (int i = 0; i < N; ++i) cerr << " " << (arr)[i]; cerr << (sep); }
#define LOGA2(arr, N, M, sep) { cerr << #arr << " =\n"; for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) cerr << (arr)[i][j] << " "; cerr << endl; } cerr << (sep); }

ostream& operator<<(ostream& os, const ii& p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

const int MAX { 110 };
const ll oo { 1LL << 62 };
const int MOD { 1000000007 };

void precomp()
{
}

bool possible[MAX];

void solve(int N)
{
    possible[0] = true;

    for (int i = 1; i < MAX; ++i)
        possible[i] = (possible[i - 4] | possible[i - 7]);

    cout << (possible[N] ? "Yes" : "No") << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    precomp();

    int N;
    cin >> N;

    solve(N);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}

//typedef long long ll;
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

//配列のSIZEは問題ごとに定義する必要がある。
const int SIZE = 100'010;
long long inv[SIZE+1];//各iの逆元を格納する配列。
long long kai[SIZE+1];//i!のmodを格納する配列。
long long invkai[SIZE+1];//各i!の逆元を格納する配列。
const int MOD=i_7;
void invinit(){//上の配列を初期化する関数。
    inv[1]=1;
    for(int i=2;i<=SIZE;i++){
        inv[i] = MOD - ((MOD/i)*inv[MOD%i])%MOD;
    }
    
    kai[0]=invkai[0]=1;
    for(int i=1;i<=SIZE;i++){
        kai[i]=(kai[i-1]*i)%MOD;
        invkai[i]=(invkai[i-1]*inv[i])%MOD;
    }
}

long long comb(long long a, long long b){
    if(b<0 || a<b){
        return 0;
    }
    return mod(kai[a]*mod(invkai[b]*invkai[a-b]));
}

int main(){
  invinit();
  using namespace std;
  long long n;
  cin>>n;
  long long x[n];
  REP(i,n){
    cin>>x[i];
  }
  long long c[n-1];
  c[0] = 1;
  REP(i,n-1){
    if(i == 0)continue;
    c[i] = c[i-1] + inv[i+1];
    c[i] = mod(c[i]);
  }
  long long ans = 0;
  REP(i, n-1){
    ans += mod(c[i] * mod(x[i+1] - x[i]));
    ans = mod(ans);
  }
  for(long long i = 1; i<n; i++){
    ans *= i;
    ans = mod(ans);
  }
  cout<<ans<<endl;
  return 0;
}


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

const int MAX_N = 1e5 + 5;
int n, ans;
int Arr[MAX_N];
unordered_map <int, int> cnt[2][2], Mark;
unordered_map <int, int>::iterator it;

void calc(int x) {
	for (int i = 0; i < n; i++)
		cnt[x][i & 1][Arr[i]]++;
}

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

	calc(0);
	sort(Arr, Arr + n);
	calc(1);

	for (it = Mark.begin(); it != Mark.end(); it++)
		ans += abs(cnt[0][0][it->first] - cnt[1][0][it->first]);

	printf("%d", ans >> 1);
	return 0;
}
//f 

Measured memory_bytes: 17060
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iomanip>

int main()
{
	int n;
	std::cin >> n;
	std::vector<int> city;
	std::vector<std::pair<double, double> > XY;
	double dist = 0.0;
	int count = 0;
	for (int i = 0; i < n; i++)
	{
		double x, y;
		std::cin >> x >> y;
		XY.push_back(std::make_pair(x, y));
		city.push_back(i);
	}
	
	do
	{
		++count;
		for (int i = 0; i < n - 1; i++)
		{
			int now = city.at(i);
			int next = city.at(i + 1);
			dist += sqrt((XY.at(now).first - XY.at(next).first)*(XY.at(now).first - XY.at(next).first) + (XY.at(now).second - XY.at(next).second)*(XY.at(now).second - XY.at(next).second));
		}
	}while (std::next_permutation(city.begin(), city.end()));
	dist /= count;
	std::cout << std::fixed << std::setprecision(10) << dist << '\n';

	return 0;
}


Measured memory_bytes: 256
/* BISMILLAHIR RAHMANIR RAHIM */
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define FasterIO ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define F first
#define S second
#define pb push_back
#define pk pop_back
#define PQ priority_queue

typedef long long ll;
typedef queue<int> qi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<pii> vii;

//typedef tree<
//  int, null_type,
//  less<int>, rb_tree_tag,
//  tree_order_statistics_node_update > ordered_set;

#define sc scanf
#define pf printf
#define sc1(x) scanf("%d", &x)
#define sc2(x, y) scanf("%d %d", &x, &y)
#define sc3(x, y, z) scanf("%d %d %d", &x, &y, &z)
#define scl1(x) scanf("%lld", &x)
#define scl2(x, y) scanf("%lld %lld", &x, &y)
#define scl3(x, y, z) scanf("%lld %lld %lld", &x, &y, &z)
#define pf1(x) printf("%d", x)
#define pf2(x, y) printf("%d %d", x, y)
#define pf3(x, y, z) printf("%d %d %d", x, y, z)
#define pfl1(x) printf("%lld", x)
#define pfl2(x, y) printf("%lld %lld", x, y)
#define pfl3(x, y, z) printf("%lld %lld %lld", x, y, z)
#define NL printf("\n")
#define FK printf(" ")
#define bug printf("ok :: ")

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define MEM(a, x) memset(a, x, sizeof(a))
#define MEMV(a, n, x) for(int i = 0; i <= n; a[i] = x, i++)

#define Fr(i, a, b, x) for(int i = a; i <= b; i += x)
#define Rv(i, a, b, x) for(int i = a; i >= b; i -= x)
#define seg_mid_L_R int mid = l + (r - l) / 2, lft = nd << 1, rgt = lft | 1

/* 6291469, 12582917, 402653189, 1610612741 */

#define read freopen("INPUT.txt", "r", stdin)
#define write freopen("OUTPUT.txt", "w", stdout)

#define inf 1e14
#define MOD 1000000007
#define MX_N 50005
#define LG 11
/*---------------------------------------------------------------------------------*/
int n, m;
vector<piii> E;

int P[MX_N];
vii used;

int Root( int u ) {
  while( u != P[u] ) {
    P[u] = P[P[u]];
    u = P[u];
  }
  return P[u];
}

ll krushkal_MST( int bad, int ok ) {
  Fr(i, 0, n, 1) P[i] = i;
  ll cost = 0, cnt = 0;
  Fr(i, 0, m - 1, 1) {
    if( i == bad ) continue;
    piii e = E[i];
    int u = e.S.F;
    int v = e.S.S;
    if( Root(u) != Root(v) ) {
      u = Root(u);
      v = Root(v);
      P[u] = P[v];
      cost += e.F, cnt++;
      if( ok ) used.pb({i, e.F});
    }
  }
  return (cnt == n - 1) ? cost : inf;
}

int main() {
  sc2(n, m);
  Fr(i, 1, m, 1) {
    int u, v, w;
    sc3(u, v, w);
    E.pb({w, {u, v}});
  }
  sort(E.begin(), E.end());

  ll C = krushkal_MST( -1, 1 ), res = 0LL, cnt = 0LL;

  for(auto& b : used) {
    ll tC = krushkal_MST( b.F, 0 );
    if( C != tC ) {
      res += b.S, cnt++;
    }
  }

  pfl2(cnt, res), NL;
  return 0;
}




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

int main(void) {
    i64 r, g, b, n, ans = 0;
    cin >> r >> g >> b >> n;
    for (i64 i = 0; i <= 3000; i++) {
        for (i64 j = 0; j <= 3000; j++) {
            i64 rem = n - r * i - g * j;
            if (rem >= 0 && rem % b == 0) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int, int>;
#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: 3228
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    cout << n * n << endl;
}

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

int main()
{
    string s;
    cin >> s;
    int total = 700;
    if (s[0] == 'o') {
        total += 100;
    }
    if (s[1] == 'o') {
        total += 100;
    }
    if (s[2] == 'o') {
        total += 100;
    }
    cout << total << endl;
    return 0;
}

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

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = sc.nextInt();

      Map<Integer, Long> freqMap = new HashMap<>();
      for(int i = 0; i < n; i++) {
        int a = sc.nextInt();
        freqMap.put(a, freqMap.getOrDefault(a, 0L) + 1);
      }

      Map<Integer, Long> replaceMap = new HashMap<>();
      for(int i = 0; i < m; i++) {
        int b = sc.nextInt();
        int c = sc.nextInt();
        replaceMap.put(c, replaceMap.getOrDefault(c, 0L) + b);
      }

      List<Integer> list = new ArrayList<>(freqMap.keySet());
      Collections.sort(list);

      List<Integer> list2 = new ArrayList<>(replaceMap.keySet());
      Collections.sort(list2, (a, b) -> b - a);
      for(int i = 0, j = 0; i < list2.size() && j < list.size();) {
        int oldKey = list.get(j);
        long oldCnt = freqMap.get(oldKey);

        int replaceKey = list2.get(i);
        long replaceCnt = replaceMap.get(replaceKey);

        if(oldKey >= replaceKey) break;
        
        long minCnt = Math.min(oldCnt, replaceCnt);
        oldCnt -= minCnt;
        replaceCnt -= minCnt;
        
        freqMap.put(oldKey, oldCnt);
        replaceMap.put(replaceKey, replaceCnt);
        
        freqMap.put(replaceKey, freqMap.getOrDefault(replaceKey, 0L) + minCnt);
        
        if(oldCnt == 0 && replaceCnt == 0) {
          i++;
          j++;
        } else if(replaceCnt == 0)
          i++;
        else j++;
      }
      long sum = 0;
      for(Map.Entry<Integer, Long> entry : freqMap.entrySet()) {
        sum += entry.getKey() * entry.getValue();
      }
      System.out.println(sum);
  }
}

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

int main() {
  int N; cin >> N;
  vector<int> A(N), B(N), C(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) cin >> B[i];
  for (int i = 0; i < N; i++) cin >> C[i];

  sort(A.begin(), A.end()), sort(B.begin(), B.end()), sort(C.begin(), C.end());

  long long n, ans = 0;
  for (int i = 0; i < N; i++) {
    n = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
    n *= C.end() - upper_bound(C.begin(), C.end(), B[i]);
    ans += n;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    unsigned long N; cin >> N;
    vector <unsigned long> vec(5);

    for (int i = 0; i < 5; i++){
        cin >> vec.at(i);
    }

    sort(vec.begin(),vec.end());
    unsigned long output = vec.at(0);

    unsigned long t = N/output;

    if (N % output == 0){
        cout << 4 + t << endl;
    }else{
        cout << 4 + t + 1 << endl;
    }

    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <list>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/


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

	int a, b;
	cin >> a >> b;

	int ans = 0;

	Rep(i, a, b + 1) {
		int tmp = i;
		vector<int> a;
		while (tmp > 0) {
			a.push_back(tmp % 10);
			tmp /= 10;
			//cout << tmp << endl;
		}
		if (a[0] == a[4] && a[1] == a[3]) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <bitset>
#include <queue>
#include <iomanip>
#include <stack>

#define pb push_back
#define ins insert
#define pob pop_back
#define er erase
#define emp empty
#define f first
#define s second
#define ff f.f
#define fs f.s
#define sf s.f
#define ss s.s
#define var auto
#define M int main()
#define For(itr,max) for(int itr = 0;itr <= max;itr++)

using namespace std;
template<typename  T>
using s = set<T>;
template<typename T>
using  v = vector<T>;
template<typename T1, typename  T2>
using p = pair < T1, T2>;
typedef long long ll;
typedef p<int, int> pii;
typedef v<int> vi;
typedef v<pii> vpii;
typedef s<int> si;
typedef s<pii> spii;


const int Max = 1e5 + 100;
const int MOD = 1e9 + 7;

ll dp[Max][110];
int w[Max];
int val[Max];
int main()
{
	int n, W; cin >> n >> W;
	for (int i = 1; i <= n; i++)
	{
		cin >> w[i] >> val[i];
	}

	for (int j = 1; j <= n; j++)
	{
		for (int i = 1; i <= W; i++)
		{
			if (i >= w[j])
				dp[i][j] = max(dp[i][j - 1], dp[i - w[j]][j - 1] + val[j]);
			else
				dp[i][j] = dp[i][j - 1];
		}
	}

	cout << dp[W][n];
}

Measured memory_bytes: 86144
#include <bits/stdc++.h>
    #define pb push_back
    #define F first
    #define S second
    #define int ll

    using namespace std;
    typedef long long ll;
    const int maxn = 1e5 + 1;
    int32_t main(){
        int n;
        int a[2 * maxn];
        int sum = 0;
        cin >> n;
        for (int i = 0;i < n;i++){
            cin >> a[i];
            sum += a[i];
        }
        int ssum=0,smin = 1e18;
        for (int i = 0;i < n;i++){
            ssum += a[i];
            smin = min(abs(ssum - (sum - ssum)),smin);
        }
        cout << smin << endl;




        return 0;
    }


Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N];
		for(int i = 0; i < N; i++) A[i] = sc.nextInt() - i - 1;
		Arrays.sort(A);
		long ans = 0, b = A[N / 2];
		for(int i = 0; i < N; i++) ans += Math.abs(A[i] - b);
		System.out.println(ans);
	}
}

Measured memory_bytes: 95228
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, N, answer = 0;
  map<int,int> B;
  for (cin >> N; N; B[A]++, B[A] %= 2, N--) {
    cin >> A;
  }
  for (auto p : B) {
    answer += p.second;
  }
  cout << answer;
}

Measured memory_bytes: 8288
N=int(input())
Y=input()#1行に沢山の数値(または文字)が並んでいる場合にリストに格納していく
X=[]
X=Y.split(" ") #数値YをリストXに格納
Z=[int(i) for i in X] #リストXの要素を"文字"から"数値"に変換
Z=sorted(Z,reverse=True) #リスト内の要素を大→小にソート
a=0
for i in range(1,N):
     a=a+Z[i]
if a>Z[0]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline LL read()
{
    LL x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

const int maxn=2e5+7;
LL cnt[maxn];

int main()
{
    int n=read(),k=read();
    LL ans=0;
    for(int i=1;i<=n;i++){
        cnt[i%k]++;
    }
    LL as=cnt[0];
//    if(as>=3)ans+=as*(as-1)*(as-2)*3;
    ans+=as*as*as;
//    printf("test %lld %lld\n",ans,cnt[k/2]);
//    for(int i=1;i<k;i++){
        if(k%2==0){
            LL qw=cnt[k/2];
            if(qw>=3)ans+=qw*qw*qw;
            if(qw==2)ans+=8;
            if(qw==1)ans+=1;
        }
//        else{
//            ans+=cnt[i]*cnt[k-i]*3;
//        }
//    }
    //    for(int i=0;i<k;i++){
    //        printf("%d ",cnt[i]);
    //    }
    //    puts("");
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <iomanip>


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

using namespace std;
int main()
{
  int A, B;
  cin >> A >> B;

  if (A - B * 2 < 0) cout << 0 << endl;
  else cout << A - B * 2 << endl;
}


Measured memory_bytes: 256
def main():
  ## IMPORT MODULE
  #import sys

  #sys.setrecursionlimit(100000)
  #input=lambda :sys.stdin.readline().rstrip()

  #f_inf=float("inf")
  #MOD=10**9+7
  
  if 'get_ipython' in globals(): 
    ## SAMPLE INPUT
    X=[0, 2, 3, 4, 5]

  else:
    ##INPUT 
    #n = input()
    X = list(map(int, input().split()))

  ## SUBMITION CODES HERE
  for idx, x in enumerate(X):
    if x == 0:
        print(idx+1)

main()

Measured memory_bytes: 9164
import random

N,K=map(int,input().split())
V=list(map(int,input().split()))

if K==0:
    print(0)
    exit()

if 0:
    V=[random.randint(-10**7,10**7) for i in range(N)]

ans=-float("inf")

for i in range(N+1):
    for j in range(N-i+1):
        if i+j>K:
            continue
        tmp=[V[k] for k in range(i)]
        for k in range(j):
            tmp.append(V[-1-k])
        tmp.sort()
        rest=K-i-j
        minus=0
        base=sum(tmp)
        for k in range(min(rest,len(tmp))):
            if tmp[k]<0:
                minus+=tmp[k]
            else:
                break
        test=base-minus
        ans=max(ans,test)

print(ans)


Measured memory_bytes: 83572
#import<iostream>
#import<vector>
#import<algorithm>
using namespace std;typedef pair<int,int>P;typedef vector<P>::iterator I;vector<P>q,r;I i,l,e;int m[132],w,h,t,n,c,s;void S(int d){for(i=q.begin(),e=q.end();i!=e;++i)for(int s=i->first,b=s&~255,p=s&255,t=1;t;)if(t=m[p+=d],~t&&b&256<<t){if(t)b^=256<<t,r.push_back(P(b+p,i->second));t=0;}}main(){for(;cin>>w>>h,w++;){fill(m,m+132,n=0);for(h=w*h+w;w-h--;)h%w?cin>>t,m[h]=t-1?-1:++n,c=t-2?c:h:0;for(q.assign(1,P(-1&~255|c,1));n--;q.erase(l,e)){r.clear();r.reserve(q.size()*4);S(1),S(w),S(-1),S(-w);q.swap(r);sort(l=i=q.begin(),e=q.end());for(s=0;i!=e;++i)i->first-s?*l++=*i,s=i->first:l[-1].second+=i->second;}h=0;for(i=q.begin();i!=q.end();++i){int p=i->first&255;if(p/w==c/w||p%w==c%w)h+=i->second;}cout<<h<<endl;}}

Measured memory_bytes: 6244
from sys import stdin

x,y = [int(x) for x in stdin.readline().rstrip().split()]

mi = 10**10
point = 0
li = []
for i in range(2):
    for j in range(2):
        point = 0
        yai = y
        eku = x
        if i == 0:
            eku *= -1
            point += 1
        if j == 0:
            yai *= -1
            point += 1
        if yai >= eku:
            point += yai-eku
            li.append(point)

print(min(li))

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

int main(){
    int a,b,c,k;
    k=0;
    cin >> a >> b >> c;
    if (a==b){
        k+=1;
    }
    if (a==c){
        k+=1;
    }
    if (c==b){
        k+=1;
    }
    if (k==1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    

    return 0;
}

Measured memory_bytes: 256
using System;

namespace C___Snack
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var a = int.Parse (input[0]);
            var b = int.Parse (input[1]);
            var max=Math.Max(a,b);
            var min=Math.Min(a,b);
            for (var i = 1L; i <= b; i++)
            {
                if ((max * i) % min == 0)
                {
                    Console.WriteLine (max * i);
                    break;
                }
            }
        }
    }
}

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

int main(int argc, char const *argv[])
{
    int r, d;
    cin >> r >> d;
    int val;
    cin >> val;   
    for(int i = 0; i < 10; i++){
        val = r*val -d;
        cout << val << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
const int MaxN=100010,MaxM=200010;
int N,M,fa[MaxN],dep[MaxN];
struct edge{int to;edge*next;}E[MaxM*2],*ne=E,*fir[MaxN];
void link(int u,int v){*ne=(edge){v,fir[u]};fir[u]=ne++;}
int dfs(int v){
	int c=1,d;
	dep[v]=dep[fa[v]]+1;
	for(edge*e=fir[v];e;e=e->next){
		if(!dep[e->to]){
			fa[e->to]=v;
			if((d=dfs(e->to))>c)c=d;
		}
		else if((dep[v]-dep[e->to])%2==0)c=3;
		if(c<2)c=2;
	}
	return c;
}
int main(){
	scanf("%d%d",&N,&M);
	for(int i=0,u,v;i<M;i++)scanf("%d%d",&u,&v),link(u,v),link(v,u);
	int c[4]={0};
	for(int i=1;i<=N;i++)if(!dep[i])c[dfs(i)]++;
	printf("%lld\n",c[1]*(N*2ll-c[1])+1ll*(c[2]+c[3])*(c[2]+c[3])+1ll*c[2]*c[2]);
}

Measured memory_bytes: 10752
import sys

S = str(input())
N = len(S)

for i in range(N):
    if S[i] != S[N-1-i]:
        print('No')
        sys.exit()

NN = (N-1)//2
for i in range(NN):
    if S[i] != S[NN-1-i]:
        print('No')
        sys.exit()

NNN = (N+3)//2
j = 0
for i in range(NNN-1,N):
    if S[i] != S[N-j-1]:
        print('No')
        sys.exit()
    j += 1

print('Yes')

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i=0;i<n;i++) cin >> p[i];
  sort(p.begin(),p.end());
  int ans=0;
  for(int i=0;i<n-1;i++) ans+=p[i];
  cout << ans+p[n-1]/2 << endl;
  return 0;
}


Measured memory_bytes: 256
H,W = map(int, input().split())
lis = [input() for i in range(H)]
flag = False
for i in range(H):
    for j in range(W):
        if lis[i][j] == "#":
            if i != 0:
                if lis[i-1][j] == "#":
                    continue
            if i != H-1:
                if lis[i+1][j] == "#":
                    continue
            if j != 0:
                if lis[i][j-1] == "#":
                    continue
            if j != W-1:
                if lis[i][j+1] == "#":
                    continue
            flag = True
    if flag:
        break
print("No" if flag else "Yes")


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
int a[7];
int n,s,num;
char out(int x){
	if(x==1)return '+';
	else return '-';
}
int main(){
    scanf("%d",&n);
    while(n){
    	a[++s]=n%10;
    	n/=10;
	}
	for(int i=1;i<=2;i++){
		swap(a[i],a[5-i]);
	}
	for(int i=-1;i<=1;i+=2){
		int ans;
		for(int j=-1;j<=1;j+=2){
			for(int l=-1;l<=1;l+=2){
				ans=a[1]+i*a[2]+j*a[3]+l*a[4];
				if(ans==7){
					printf("%d%c%d%c%d%c%d=7",a[1],out(i),a[2],out(j),a[3],out(l),a[4]);
					return 0; 
				}
			}
		}
	}
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        while(true){
        	int n=sc.nextInt();
            int x=sc.nextInt();
            if(n==0&&x==0)
            	break;
            int i,j,k,v=0;
            for(i=1;i<=n;i++){
            	for(j=i+1;j<=n;j++){
            		for(k=j+1;k<=n;k++){
            			if(i+j+k==x){
            				v++;
            			}
            		}
            	}
            }
            System.out.println(v);
        }
        
    }
}



Measured memory_bytes: 26488
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <cstring>

using namespace std;
int n;
int a[101];
int m=1000000001,M=0;
int main(){
  cin >> n;
  for(int i=0;i<n;i++)cin >> a[i];
  for(int i=0;i<n;i++){
    if(a[i]<m)m=a[i];
    if(a[i]>M)M=a[i];
  }
  cout << M-m << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  string s;
  cin >> s;
  cout << s[0] << s.size()-2 << s[s.size()-1] << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 3608
#include<queue>
#include<cstdio>

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

using namespace std;

enum {IN,OUT};
struct event{
	int id,io,t,pid; // 車の番号, 駐車か発車か, 時刻, 駐車スペースの番号
	bool operator<(const event &e)const{ // priority_queue に入れるので逆順
		if(t!=e.t)   return t>e.t;
		if(io!=e.io) return io==IN;
		if(io==IN) return id>e.id; // 駐車待ちをしている順に取り出す ( 車の番号の小さい順と一致する )
		else       return pid>e.pid; // 駐車スペースの番号が小さい順に取り出す
	}
};

int main(){
	for(int m,n;scanf("%d%d",&m,&n),m;){
		priority_queue<event> Q;
		int T[100]; // 駐車している時間
		rep(i,n){
			scanf("%d",T+i);
			Q.push((event){i,IN,10*i});
		}

		int park[10][2],dep[10][2]; // 駐車している車の番号, 出発時刻
		bool wait[10]={}; // 上段の車が待っているかどうか
		rep(i,m) rep(j,2) park[i][j]=-1;

		vector<int> ans;
		while(!Q.empty()){
			event e=Q.top(); Q.pop();
			if(e.io==IN){
				int i_opt=-1;
				rep(i,m) if(park[i][0]==-1) { i_opt=i; break; }
				if(i_opt!=-1){ // 一台も駐車されていないスペースがあるとき
					park[i_opt][0]=e.id;
					dep[i_opt][0]=e.t+T[e.id];
					Q.push((event){e.id,OUT,e.t+T[e.id],i_opt});
					continue;
				}

				i_opt=-1;
				rep(i,m) if(park[i][1]==-1 && dep[i][0]>=e.t+T[e.id]) {
					if(i_opt==-1 || dep[i_opt][0]>=dep[i][0]) i_opt=i;
				}
				if(i_opt==-1){
					rep(i,m) if(park[i][1]==-1) {
						if(i_opt==-1 || dep[i_opt][0]<=dep[i][0]) i_opt=i;
					}
				}
				if(i_opt!=-1){ // 上段に車がある駐車スペースのみ空いているとき
					park[i_opt][1]=park[i_opt][0];
					dep[i_opt][1]=dep[i_opt][0];
					park[i_opt][0]=e.id;
					dep[i_opt][0]=e.t+T[e.id];
					Q.push((event){e.id,OUT,e.t+T[e.id],i_opt});
					continue;
				}

				// 満車のとき
				Q.push((event){e.id,IN,e.t+1});
			}
			else{ // OUT
				if(park[e.pid][0]==e.id){ // 下段の車が発車するとき
					park[e.pid][0]=-1;
					ans.push_back(e.id);

					// 上段に車があれば下段に下ろす
					if(park[e.pid][1]!=-1){
						park[e.pid][0]=park[e.pid][1];
						dep[e.pid][0]=dep[e.pid][1];
						park[e.pid][1]=-1;
					}
					if(wait[e.pid]){ // 上段だった車がすでに待っていたとき
						wait[e.pid]=false;
						ans.push_back(park[e.pid][0]);
						park[e.pid][0]=-1;
					}
				}
				else{ // 上段の車が発車するとき
					wait[e.pid]=true;
				}
			}
		}

		rep(i,ans.size()) printf("%d%c",ans[i]+1,i<(int)ans.size()-1?' ':'\n');
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
  string str;
  cin >> str;
  int count = 0;
  for(int i = 0; i < str.size(); i++){
    if(str.at(i) == '1'){
      count ++;
    }
  }
  cout << count << endl;
 
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using Pair = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;

/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/
int main(){
   int x,y;
   cin >> x >> y;
   for(int i=0;i<=x;i++){
     if((i*2 + (x-i)* 4) == y) {cout << "Yes" << endl;return 0;}
   }
   cout << "No" << endl;
}

Measured memory_bytes: 3632
s = input()
n = len(s)
hikaku10 = ""
hikaku01 = ""
if n % 2 == 0:
    for i in range(int(n/2)):
        hikaku10 += "10"
        hikaku01 += "01"
else:
    for i in range(int((n-1)/2)):
        hikaku10 += "10"
        hikaku01 += "01"
    hikaku10 += "1"
    hikaku01 += "0"
#print(hikaku10)
#print(hikaku01)
#print(int(hikaku10,2)^int(s,2))
#print(int(hikaku01,2)^int(s,2))
#print(str(bin(int(hikaku10,2)^int(s,2)).count("1")))
#print(str(bin(int(hikaku01,2)^int(s,2))).count("1")))

print(min(str(bin(int(hikaku10,2)^int(s,2))).count("1"),str(bin(int(hikaku01,2)^int(s,2))).count("1")))


Measured memory_bytes: 3444
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define ALL(v) (v).begin(),(v).end()
const ll MOD = 1e9 + 7;
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;
}
ll f(ll x, ll C, ll D) {
	ll sum = x / C + x / D - x / lcm(C, D);
	return x - sum;
}
int main() {
	ll A, B, C, D;
	cin >> A >> B >> C >> D;
	cout << f(B, C, D) - f(A - 1, C, D) << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>

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

using namespace std;

typedef	vector<int>	vi;

const int INF=1<<29;

struct Edge{
	int u,v,cost;
	Edge(){}
	Edge(int U,int V,int C):u(U),v(V),cost(C){}
	bool operator<(const Edge &e)const{ return cost<e.cost; }
};

class UnionFind{
	vi a;
	int root(int x){ return ~a[x]?a[x]=root(a[x]):x; }
public:
	UnionFind(int n):a(n,-1){}
	bool find(int x,int y){ return root(x)==root(y); }
	bool unite(int x,int y){ return find(x,y)?0:(a[root(y)]=root(x),1); }
};

int Kruskal(int n,vector<Edge> e){
	int m=e.size(),ans=0,cnt=1;
	UnionFind uf(n);
	rep(i,m){
		if(uf.unite(e[i].u,e[i].v)){
			ans=e[i].cost;
			if(++cnt==n)	return ans;
		}
	}
	return -1;
}

int main(){
	for(int m,n;scanf("%d%d",&n,&m),n;){
		vector<Edge> e(m);
		rep(i,m){
			scanf("%d%d%d",&e[i].u,&e[i].v,&e[i].cost);
			e[i].u--,e[i].v--;
		}
		sort(e.begin(),e.end());

		int ans=INF;
		rep(i,m){
			int res=Kruskal(n,vector<Edge>(e.begin()+i,e.end()));
			if(~res)	ans=min(ans,res-e[i].cost);
		}

		printf("%d\n",ans<INF?ans:-1);
	}

	return 0;
}

Measured memory_bytes: 932
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
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;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



// n/2まで調べれば十分
int n;
string s;

signed main() {
	cin >> s;
	n = s.size();
	if (s[0]=='0' || s[n-1]=='1') return cout << -1 << endl, 0;
	reps(i,1,n-1) if (s[i-1]!=s[n-i-1]) return cout << -1 << endl, 0;
	if (n==3) return cout << "1 2\n2 3" << endl, 0;
	vector<int> ne;
	ne.push_back(0);
	reps(i,1,n/2+1) if (s[i-1]=='1') ne.push_back(i);
	int p = 1, v = 2;
	vector<int> vs;
	rep(i,ne.size()-1) {
		vs.push_back(v);
		cout << v-1 << ' ' << v << endl;
		v++;
	}
	reverse(all(vs));
	reps(i,1,ne.size()) {
		rep(j,ne[i]-ne[i-1]-1) cout << vs[i-1] << ' ' << v++ << endl;
	}
	while (v!=n+1) cout << 1 << ' ' << v++ << endl;
}


Measured memory_bytes: 1868
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;


void eating_symbols_easy()
{
  string s;
  cin >> s;

  int cnt = 0;
  for (int i = 0; i < 4; ++i)
  {
    if (s[i] == '+') ++cnt;
    else --cnt;
  }
  cout << cnt << "\n";
}


void multiple_of_2_and_n()
{
  int n;
  cin >> n;

  if (n % 2 == 0) cout << n << "\n";
  else cout << 2 * n << "\n";
}


void task_scheduling_problem()
{
  vector<int> a(3);
  for (int i = 0; i < 3; ++i) cin >> a[i];

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

  cout << a[2] - a[0] << "\n";
}


int main()
{
  //eating_symbols_easy();
  //multiple_of_2_and_n();
  task_scheduling_problem();
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a,b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {
	
	int N;
	cin >>N;
	vector<string> A(N);
	int a, b, c,s;
	a = 0;
	b = 0;
	c = 0;
	s = 0;

	rep(i, N) {
		cin >> A.at(i);
		rep(j, A.at(i).size() - 1) {
			if (A.at(i).at(j) == 'A' && A.at(i).at(j + 1) == 'B') {
				s++;
			}
		}
		if (A.at(i).at(0) == 'B' && A.at(i).at(A.at(i).size() - 1) == 'A') {
			a++;
		}
		else if (A.at(i).at(0) == 'B') {
			b++;
		}
		else if (A.at(i).at(A.at(i).size() - 1) == 'A') {
			c++;
		}
	}

	if (b+c == 0&&a!=0) {
		s +=(a - 1);
	}
	else {
		s += (a + min(b, c));
	}
	cout << s << endl;

}


Measured memory_bytes: 768
import java.io.*;
class Main
{
    public static void main(String args[])throws IOException
    {
BufferedReader input=new BufferedReader (new InputStreamReader (System.in));
	while(true)
	    {
		
		int sum=0;
		String str=input.readLine();
		if(str.equals("0"))break;
		for(int i=0;i<str.length();i++)
		    {
			
			sum+=str.charAt(i)-'0';
		    }
		System.out.println(sum);
	    }
    }
}

Measured memory_bytes: 16888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MOD = 1e9+7;


int main(){
    ll N; cin >> N;
    vector<ll> A(N); for(int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    ll Max = A[N-1];
    ll r = -1;
    ll id;
    for(int i = 0; i < N-1; i++) {
        if(r < min(A[i], Max-A[i])){
            r = min(A[i], Max-A[i]);
            id = i;
        }        
    }
    cout << Max << " " << A[id] << endl;
}



Measured memory_bytes: 1024
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>

#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
#ifdef local
#define dbg(a) cout << #a": " << a << endl;
#else
#define dbg(a)
#endif // loacl


using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const ll inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-6;
const int mod=1e9+7;
const int maxn=20;
const int N=1e5+10;
const int M=N<<1;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll MOD)
{
    ll ans=1;
    while(b)
    {
        if(b&1) ans=(ans*a)%MOD;
        b>>=1;
        a=(a*a)%MOD;
    }
    return ans;
}

int a[1005][1005];
int b[1005];
queue<int>Q[1005];
int main()
{
#ifdef local
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif // local
    IOS;
    int n;cin>>n;
    rep1(i,n) rep1(j,n-1) cin>>a[i][j],Q[i].push(a[i][j]);
    while(1)
    {
        bool flag=0;
        rep1(i,n)
        {
            if(Q[i].empty()) continue;
            if(Q[Q[i].front()].front()==i)
            {
                b[i]=b[Q[i].front()]=max(b[i],b[Q[i].front()])+1;
                Q[Q[i].front()].pop();Q[i].pop();
                flag=1;
            }
        }
        if(!flag) {cout<<-1<<endl;return 0;}
        int num=0;
        rep1(i,n) num+=Q[i].size();
        if(!num) break;
    }
    int ans=0;
    rep1(i,n) ans=max(ans,b[i]);
    cout<<ans<<endl;
    return 0;
}



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

int N;
int B[100];

int main(){
    cin>>N;
    rep(i,N-1) cin>>B[i];

    B[N-1]=100100;
    int ans=B[0];
    rep(i,N-2){
        ans+=min(B[i],B[i+1]);
    }
    ans+=B[N-2];

    cout<<ans<<endl;
}

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

int main()
{
    int N,M,X,A;
    cin>>N>>M>>X;
    int c = 0;
    int rem = 0;
    for (int i = 1; i <= M; i++)
    {
        cin>>A;
        (A < X)?c++:rem++;
    }
    cout<<min(c, rem)<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
if n<105:
  print(0)
  exit()

ans = 1
for i in range(107, n+1, 2):
  count = 0
  for j in range(1, i+1):
    if i % j == 0:
      count += 1
  if count == 8:
    ans += 1

print(ans)


Measured memory_bytes: 2940