akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
typedef unsigned long long ll;
typedef unsigned int uint;
vector<pair<uint, uint>> d;
// vector<pair<ll, ll>> d;
 
int main(int, char**)
{
	unsigned int n;
	ll t = 0, s = 0;
	cin >> n;
	d.resize(n);
 
	for (unsigned int i = 0; i < n; i++) {
		ll a, b;
		cin >> a >> b;
		d[i].first = a + b;
		d[i].second = a;
	}
 
	sort(d.begin(), d.end(), greater<>());
 
	for (unsigned int i = 0; i < n; i++) {
		if (i % 2 == 0) t += d[i].second;
		else s += (d[i].first - d[i].second);
	}
 
    cout << (long long)t - (long long)s << endl;
	return 0;
}

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

bool check_finish(vector<int> ch, int n) {
  for ( int i = 0; i < ch.size(); i++ ) {
    if ( ch[i] == n ) { return true; }
  }
  return false;
}

int main() {
  int s;
  cin >> s;
  vector<int> ch;

  int ans = 1;
  while ( ! check_finish(ch, s) ) {
    ans++;
    ch.push_back(s);
    s = ( s%2 == 0 ) ? s/2 : 3*s+1;
  }

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


Measured memory_bytes: 256
import bisect
from itertools import accumulate
n, m, k, *AB = map(int, open(0).read().split())
A, B = [0] + AB[:n], AB[n:]

A_ = list(accumulate(A))
B_ = list(accumulate(B))
ans = 0
for i in range(n+1):
    if k < A_[i]:
        break
    t = i + bisect.bisect(B_, k-A_[i])
    ans = max(ans, t)
print(ans)

Measured memory_bytes: 55000
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        System.out.print(s.charAt(0));
        System.out.print(s.length() - 2);
        System.out.println(s.charAt(s.length() - 1));
    }
}


Measured memory_bytes: 21844
#include <cstdio>
#include <cstring>
int len,t1=0,t2 = 0;
int main(){
    int x,y,z;
    len = 0;
    t1 = 0;
    t2 = 0;
    int t = 0;
    while(scanf("%d,%d,%d",&x,&y,&z)!=EOF){
        if(x*x+y*y==z*z) t1++;
        if(x==y) t2++;
    }
    printf("%d\n%d\n",t1,t2);
}

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

using namespace std;
using ll = long long;

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

  int n;
  string s;
  cin >> n >> s;

  vector<int> r;
  vector<int> g;
  set<int> b;

  for (int i = 0; i < n; i++) {
    if (s[i] == 'R')
      r.push_back(i);
    else if (s[i] == 'G')
      g.push_back(i);
    else
      b.insert(i);
  }

  ll ans = 0;
  for (int i = 0; i < r.size(); i++) {
    for (int j = 0; j < g.size(); j++) {
      int x = b.size();

      // r g b
      // g r b
      {
        int m = max(r[i], g[j]);
        int d = abs(r[i] - g[j]);
        if (b.count(m + d) > 0)
          x--;
      }

      // r b g
      // g b r
      {
        int d = abs(r[i] - g[j]) / 2;
        int m = min(r[i], g[j]);
        if (r[i] % 2 == g[j] % 2 && b.count(m + d) > 0)
          x--;
      }

      // b r g
      // b g r
      {
        int m = min(r[i], g[j]);
        int d = abs(r[i] - g[j]);
        if (b.count(m - d) > 0)
          x--;
      }

      ans += x;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3656
# https://atcoder.jp/contests/abc158/tasks/abc158_d



S = gets.chomp
Q = gets.to_i

reverse = false
prefix = ''
suffix = ''
Q.times do
  arr = gets.chomp.split
  if arr[0] == '1'
    reverse = !reverse
  else
    if arr[1] == '1'
      if reverse
        suffix << arr[2]
      else
        prefix << arr[2]
      end
    else
      if reverse
        prefix << arr[2]
      else
        suffix << arr[2]
      end
    end
  end
end

str = prefix.reverse + S + suffix
puts reverse ? str.reverse : str


Measured memory_bytes: 3196
import sys
def main():
    input = sys.stdin.readline
    N = int(input())
    xyh = [tuple(map(int, input().split())) for _ in range(N)]
    xyh.sort(reverse=True, key=lambda x:x[2])

    def check(cx, cy):
        def dist(x, y): return abs(x-cx) + abs(y-cy)
        tmp = 0
        for x, y, h in xyh:
            d = dist(x,y)
            if h == 0:
                if tmp > d: return -1
            else:
                if tmp != 0 and tmp != h+d: return -1
                tmp = h+d
        return tmp
    
    for x in range(101):
        for y in range(101):
            H = check(x,y)
            if H >= 0:
                print('{} {} {}'.format(x,y,H))
                return

if __name__ == '__main__':
    main()

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

void solve(long long N, std::string S) {
    ll ans = 0;
    rep(i, N - 2) {
        if (S.substr(i, 3) == "ABC") {
            ans++;
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can
// remove this line by using your custom template)
int main() {
    long long N;
    scanf("%lld", &N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 3680
#include <stdio.h>
#include <algorithm>

using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(n, i) for (int i = n - 1; i > -1; --i)

int main() {
    int N;
    scanf("%d", &N);

    int A[N];
    REP(i, N) {
        scanf("%d", &A[i]);
    }
    sort(A, A + N);

    int B[N];
    REP(i, N) {
        scanf("%d", &B[i]);
    }
    sort(B, B + N);

    int C[N];
    REP(i, N) {
        scanf("%d", &C[i]);
    }
    sort(C, C + N);

    int OB[N];
    int a = N - 1;
    RREP(N, i) {
        OB[i] = 0;
        while (B[i] <= A[a] && a > -1) {
            a--;
        }
        OB[i] = a + 1;
    }

    int OC[N];
    int b = N - 1;
    RREP(N, i) {
        OC[i] = 0;
        while (C[i] <= B[b] && b > -1) {
            b--;
        }
        OC[i] = b + 1;
    }

    long acc[N];
    int ob = 0;
    REP(i, N) {
        acc[i] = 0;

        if (OC[i] == 0) continue;

        if (i != 0) acc[i] = acc[i - 1];

        while (ob < OC[i]) {
            acc[i] += OB[ob];
            ob++;
        }
    }

    long ans = 0;
    REP(i, N) {
        ans += acc[i];
    }

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

    return 0;
}


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

int main() {
	long long unsigned int x;
	cin >> x;
	long long unsigned start = 100;
	for(int it = 1;  ;it++){
	    start = start + start/100;
	    if(start >= x){
	        cout << it;
	        break;
	    }
	}
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  cin>>n;
  int f[n][5][2];
  REP(i,n){
    REP(j,5){
      cin>>f[i][j][0];
      cin>>f[i][j][1];
    }
  }
  int p[n][11];
  REP(i,n){
    REP(j,11){
      cin>>p[i][j];
    }
  }
  
  long long ans;
  long long temp=0;
  vector<int> count(n,0);
  int target;
  for(int i=1;i<1<<10;i++){
    REP(j,5){
      target = i>>2*j;
      if(target%2==1){
        REP(i,n){
          if(f[i][j][0]==1){
            count[i]++;
          }
        }
      }
      if((target%4)>=2){
        REP(i,n){
          if(f[i][j][1]==1){
            count[i]++;
          }
        }
      }
    }
    
    REP(k,n){
      temp += p[k][count[k]];
    }
    
    if(i==1){
      ans = temp;
    }else{
      ans = max(ans,temp);
    }
    
    temp=0;
    REP(k,n){
      count[k]=0;
    }
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int N, T, M = 1000000;
	cin >> N >> T;
	for (int a = 0; a < N; a++) {
		int c, t;
		cin >> c >> t;
		if (t > T) {
			continue;
		}
		if (c < M) {
			M = c;
		}
	}
	if (M == 1000000) {
		cout << "TLE" << endl;
	}
	else {
		cout << M << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		int count =0;
		int start,end;
		if (S<K) {
			end = S;
		} else {
			end = K;
		}
		if (S-2*K>0) {
			start = S-2*K;
		} else {
			start =0;
		}
		for (int x=start;x<=end;x++) {
			int temp = S-x;
			if (temp >K) {
				count += 2*K-temp+1;
			} else {
				count +=temp+1;
			}
		}
		System.out.println(count);
	}
}

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

int main() {
    int n, m, l, r, a=1, b=100000, ans;
    cin >> n >> m;
    for(int i=0; i<m; i++) {
        cin >> l >> r;
        a=max(a, l);
        b=min(b, r);
    }
    ans=max(0, b-a+1);
    cout << ans;
}

Measured memory_bytes: 256
from math import ceil
N,H=map(int,input().split())
A=[]
B=[]
for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort()
ans=0
for i in B[::-1]:
    if i<A[-1]:
        break
    H-=i
    ans+=1
    if H<=0:
        print(ans)
        quit()
ans+=ceil(H/A[-1])
print(ans)


Measured memory_bytes: 62424
#pragma comment(linker, "/stack:200000000")

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define int long long
#define ull unsigned long long
#define ld long double
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) return cout<<a,0;

using namespace std;
const int N = 2 * 1e5 + 123 , mod = 1e9 + 7;
int t[4 * N] , h[N] , a[N] , n;
void upd(int v , int tl , int tr , int pos , int x){
	if(tl == tr){
		t[v] = x;
		return;
	}
	int tm = (tl + tr) >> 1;
	if(pos <= tm)	
		upd(v << 1 , tl , tm , pos , x);
	else
		upd(v << 1 |1 , tm + 1 , tr , pos , x);
	t[v] = max(t[v<<1] , t[v<<1|1]);
}
int get(int v , int tl, int tr , int l , int r){
	if( l > r)
		return 0;
	if(tl == l && tr == r)
		return t[v];
	int tm = (tl + tr) >> 1;
	return max(get(v << 1 , tl , tm , l , min(r , tm)) , get(v << 1 | 1 , tm + 1 , tr , max(tm + 1 , l) , r));
}
	
main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	cin >> n;
	for(int i = 1 ; i <= n ; i++)
		cin >> h[i];
	for(int i = 1 ; i <= n ; i++)
		cin >> a[i];
		
	for(int i = 1 ; i <= n; i++){
		upd(1 , 1 , N , h[i] , get(1 , 1 , N , 1 , h[i]) + a[i]);
	}
	cout << get(1 , 1 , N , 1 , n);
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 1e18;
const ll fact_table = 5000000;
double Pi = 3.1415926535897932384626;
 
vector<ll> G[550010];
vector<ll> R[550010];
vector<pair<ll, double> > tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<"\n";
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 998244353;
//ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,f,g,h,w,i,j,q,r,l;
ll k,ans;
ll x[500005],y[500005],z[500005];
ll dp[5005][5005];
char s[500005];
char t[500005];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n;
    for(ll i=n;i<=1000000;i++){
        bool isprime = true;
        for(ll j=2;j*j<=i;j++){
            if(i % j == 0){
                isprime = false;
            }
        }
        if(isprime){
            p(i);
            break;
        }
    }
    return 0;
}















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

int main()
{
    int n;
    cin >> n;
    for(int i=0; i<n; i++)
    {
        double x1, x2, x3, x4;
        double y1, y2, y3, y4;
        cin >> x1 >>  y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
        if(abs((y2-y1)*(x4-x3) - (y4-y3)*(x2-x1)) < 1e-10)
        {
           cout << "YES" << endl; 
        }
        else
        {
            cout << "NO" << endl; 
        }
    }
    return 0;
}

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

using namespace std;


/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back


/*---  Type ---*/
typedef long long ll;


/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;


// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

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

bool solve(int a, int b, int c) {
  rep1(i, b) {
    if((a*i) % b == c) return true;
  }
  return false;
}

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

  if(solve(a, b, c)) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
n=gets.to_i
t=gets.split.map(&:to_i)
a=gets.split.map(&:to_i)
l,r=[],[]
tt=0
n.times do |i|
  if t[i]>tt
    tt=t[i]
    l[i]=tt
    r[i]=tt
  else
    l[i]=1
    r[i]=tt
  end
end
aa=0
(n-1).downto(0) do |i|
  if a[i]>aa
    if l[i]<=a[i]&&a[i]<=r[i]
      aa=a[i]
      l[i]=aa
      r[i]=aa
    else
      puts 0
      exit
    end
  else
    if l[i]==1
      r[i]=aa if r[i]>aa
    else
      if aa<l[i]
        puts 0
        exit
      end
    end
  end
end
ans=1
mod=1000000007
n.times do |i|
  ans=ans*(r[i]-l[i]+1)%mod
end
puts ans


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

int main(){
    int n;
    cin >> n;
    vector<int> b(n+1);
    for (int i = 0;i < n - 1;i++){
        cin >> b[i];
    }
    vector<int> a(n+1);
    int j = 1;
    a[0] = b[0];
    for (int i = 0;i < n-2;i++){
        a[i+1] = min(b[i],b[i+1]);
    }
    a[n-1] = b[n-2]; 

    int sum = 0;
    for (int i = 0;i < n;i++){
        sum += a[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    int[] a = {1,3,5,7,8,10,12};
    int[] b = {4,6,9,11};
    int[] c = {2};
    String xcheck="";
    String ycheck="";
    for (int v:a) {
      if (x == v) xcheck = "a";
      if (y == v) ycheck = "a"; 
    }
    for (int v:b) {
      if (x == v) xcheck = "b";
      if (y == v) ycheck = "b"; 
    }
    for (int v:c) {
      if (x == v) xcheck = "c";
      if (y == v) ycheck = "c"; 
    }
    if (xcheck.equals(ycheck)) {
      System.out.println("Yes");
    } else {
      System.out.println("No"); 
    }
   }
}

Measured memory_bytes: 22484
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

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

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class CAlchemist {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n;
        in >> n;
        vi V(n);
        in >> V;
        sort(all(V));
        double res = V[0];
        trav(x, V) {
            res = (res + x) / 2;
        }
        out << fixed << setprecision(6) << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    CAlchemist solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3856
package main

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

var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	return sc.Text()
}
func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	k := scanInt()
	n := scanInt()
	a := make([]int, n, n)
	max := 0
	sum := 0
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	for j := 0; j < n; j++ {
		var len int
		if j == n-1 {
			len = (k - a[j] + a[0])
		} else {
			len = a[j+1] - a[j]
		}
		if len > max {
			max = len
		}
		sum += len
	}
	fmt.Println(sum - max)
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > piii;
#define pb push_back
#define debug(x) cout << x << endl
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define PI acos(-1)
#define all(c) c.begin(), c.end()
#define SET(x, y) memset((x), y, sizeof(x))
const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const LL INF64 = 1e18;

const int N = 1e5 + 5;

LL a[1005], b[1005], c[1005];
LL x, y, z, k;
vector<LL> sum;
vector<LL> ans;

int main() {
	fastio;
	cin >> x >> y >> z >> k;
	for (int i = 0; i < x; i++)
		cin >> a[i];
	for (int i = 0; i < y; i++)
		cin >> b[i];
	for (int i = 0; i < z; i++)
		cin >> c[i];
	LL cnt = 0LL;
	for (int i = 0; i < x; i++) {
		for (int j = 0; j < y; j++) {
			LL tmp = a[i] + b[j];
			sum.pb(tmp);
			cnt++;
		}
	}
	sort(all(sum), greater<LL>());
	for (int i = 0; i < min(k + 1, (LL)sum.size()); i++) {
		for (int j = 0; j < z; j++) {
			LL tmp = sum[i] + c[j];
			ans.pb(tmp);
		}
	}
	sort(all(ans), greater<LL>());
	LL now = 0;
	while (k--) {
		cout << ans[now] << endl;
		now++;
	}
	return 0;
}

Measured memory_bytes: 43108
<?php
fscanf(STDIN, "%d %d", $d, $g);
$x[0] = 0;
for ($i = 1; $i <= $d; $i++) {
	fscanf(STDIN, "%d %d", $p, $c);
	foreach ($x as $k => $v) {
		for ($j = 1; $j <= $p; $j++) {
			$s = $v + $i * 100 * $j;
			if ($j == $p) $s += $c;
			if (isset($x[$k+$j])) {
				$x[$k+$j] = max($x[$k+$j], $s);
			} else {
				$x[$k+$j] = $s;
			}
		}
	}
}
$i = 1;
while ($x[$i] < $g) $i++;
echo $i;

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
int power(int num)
{
    int ans=1;
    for(int i=0;i<num;i++)ans*=10;
    return ans;
}
int main() {
    int n,m;
    while(cin>>m>>n,n,m){
        string str,fb[3]={"FizzBuzz","Fizz","Buzz"};
        bool player[1000]={};
        for(int i=1,now=0,out=m;i<=n;i++,now=(now+1)%m){
			cin>>str;
			int num=0,co=-1;
			if(out>1){
			while(player[now])now=(now+1)%m;
				if(i%15<1)co=0;
				else if(i%3<1)co=1;
				else if(i%5<1)co=2;
				else{
					for(int j=0;j<str.size();j++)num+=(str[j]-'0')*power(str.size()-1-j);
					if(num!=i)player[now]=1;
				}
				if(co>-1&&str!=fb[co]||co<0&&i!=num)player[now]=1;
				if(player[now])out--;
			}
		}
		for(int i=0,co=0;i<m;i++){
			if(co==0&&!player[i]){
				cout<<i+1;
				co++;
			}
			else if(!player[i])cout<<" "<<i+1;
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1220
z=int(input())
i=1
re=0
b=1
d=1
while z>i:
  b=1
  while True:
    x=i*(i+b)
    if z>x:
      re+=2
    else:
      break
    b+=1
  i+=1
while True:
  if d*d<z:
    d+=1
    re+=1
  else:
    break
print(re)

Measured memory_bytes: 9188
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

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

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

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

n,c,k = MI()
T = CI(n)

ls = []
for i in range(n):
    s = T[i]
    t = T[i] + k
    ls.append( [s,t] )

ls = mysort(ls,1,False)

# print(ls)

bt = -1*INF
bus = 0
m = 0
for i in range(n):
    s = ls[i][0]
    t = ls[i][1]
    if s>bt:
        bus += 1
        m = 1
        bt = t
    else:
        m += 1
        if m>c:
            bus += 1
            m = 1
            bt = t

print(bus)

Measured memory_bytes: 64344
n = int(input())

ans = [0] * (n+1)

for i in range(1, n+1):
    for j in range(1, n+1):
        for k in range(1, n+1):
            x = i*i+j*j+k*k+i*j+j*k+k*i
            if x <= n:
                ans[x] += 1
            if x > n:
                break
        x = i*i+j*j+i*j
        if x > n:
            break
    x = i*i
    if x > n:
        break

for i in range(1,n+1):
    print(ans[i])

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

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

const int MOD = 1000000007;
ll add(ll a, ll b){return (a + b) % MOD;}

const int MAXN = 100;
const int MAXK = 100000;
ll dp[MAXK + 5]; 
ll psum[MAXK + 5];

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

  int n, k;
  cin >> n >> k;
  vi a(n);
  trav(i, a) cin >> i;

  fill(all(psum), 1);
  auto sum = [&](int i, int j){return i ? (psum[j] - psum[i - 1] + MOD) % MOD : psum[j];};
  rep(i, 0, n) {
    rep(j, 0, k + 1) {
      dp[j] = sum(j - min(j, a[i]), j);
    }
    psum[0] = dp[0];
    rep(j, 1, k + 1)
      psum[j] = add(psum[j - 1], dp[j]);
  }
  cout << dp[k] << '\n';
}


Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T> using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
ll C;
vector<pair<ll, ll>> xy;
ll result;
int main() {
  cin >> N >> C;
  xy.resize(N);

  for (int i = 0; i < N; i++) {
    cin >> xy[i].first >> xy[i].second;
  }
  if (N == 1){
    result = max(result, xy[0].second - min(C - xy[0].first, xy[0].first));
    cout << result << endl;
    return 0;
  }
  vector<ll> lst, rst;
  ll lsum, rsum;
  lsum = rsum = 0;
  // right
  for (int i = N - 1; i >= 0; i--) {
    ll tmp = xy[i].second + rsum - (C - xy[i].first);
    if (not rst.empty()) {
      tmp = max(tmp, rst.back());
    }
    rst.emplace_back(tmp);
    rsum += xy[i].second;
  }
  // left
  for (int i = 0; i < N; i++) {
    ll tmp = xy[i].second - xy[i].first + lsum;
    if (not lst.empty()) {
      tmp = max(tmp, lst.back());
    }
    lst.emplace_back(tmp);
    lsum += xy[i].second;
  }
  lsum = 0;
  // 2 * left + right
  for (int i = 0; i < N; i++) {
    ll left, right;
    left = right = 0;
    left = xy[i].second - xy[i].first + lsum;
    if (i != N - 1) {
      right = max(0LL, rst[N - 2 - i] - xy[i].first);
    }
    result = max(result, left + right);
    lsum += xy[i].second;
  }
  // left + 2 * right
  rsum = 0;
  for (int i = 0; i < N; i++) {
    ll left, right;
    left = right = 0;
    right = xy[N - 1 - i].second + rsum -(C - xy[N - 1 - i].first);
    if (i != N - 1) {
      left = max(0LL, lst[N - 2 - i] - (C - xy[N - 1 - i].first));
    }
    result = max(result, left + right);
    rsum += xy[N - 1 - i].second;
  }
  cout << result << endl;
  return 0;
}


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

using namespace std;

typedef long long  ll;

#define SIZ 1000000000
#define mod 10000007

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	// D from 172
	ll n;
	cin >> n;
	vector<ll> sieve(n + 1, 2);
	sieve[1]--;
	for(ll i = 2; i <= n/2; i++){
		for(ll j = i*2; j <=n ; j += i){
			sieve[j]++;
		}
	}
	
	ll cnt = 0;
	for(ll i = 1; i <= n;i++){
		cnt += (i*sieve[i]);
	}
	
	cout << cnt << "\n";
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int a, b;cin >> a >> b;
    cout << (b%a == 0 ? a+b : b-a) << endl;
    return 0;
}


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

#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,a,b) for(int i=(a);i>=(b);i--)

#define LL long long
#define Ldouble long double
#define PI 3.14159265358979323846264338327950288419

#define PII pair<int,int>
#define PLL pair<LL,LL>
#define mp make_pair
#define fi first
#define se second

using namespace std;

char s[105];
bool app[4];
char str[6] = "NSEW";

int main(){
	cin.getline(s, 105);
	int len = strlen(s);
	FI(i, 0, len - 1){
		FI(j, 0, 3) if(s[i] == str[j]){
			app[j] = true;
			break;
		}
	}
	if(app[0] ^ app[1]){
		printf("No\n");
		return 0;
	}
	if(app[2] ^ app[3]){
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 256
// Why am I so dumb? :c
// chrono::system_clock::now().time_since_epoch().count()
#include<bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;   

const int MAXN = (int)1e5 + 5;

ll arr[MAXN], d[MAXN];

bool used[MAXN];

int perm[MAXN];

int conv[MAXN];

int id[MAXN];

int n, m;

ll k;

void solve() {
    scanf("%d", &n);

    for (int i = 1; i <= n; ++i) {
        scanf("%lld", &arr[i]);
    }

    for (int i = 1; i < n; ++i) {
        d[i] = arr[i + 1] - arr[i];
    }

    scanf("%d %lld", &m, &k);

    for (int i = 1; i <= m; ++i) {
        scanf("%d", &id[i]);
    }

    for (int i = 1; i < n; ++i) {
        conv[i] = i;
    }

    for (int i = 1; i <= m; ++i) {
        swap(conv[id[i] - 1], conv[id[i]]);
    }

    for (int i = 1; i < n; ++i) {
        if (!used[i]) {
            vector<int> cyc;
            int cur = i;

            for (int cur = i; !used[cur]; cur = conv[cur]) {
                used[cur] = 1;
                cyc.pb(cur);
            }               

            for (int j = 0; j < cyc.size(); ++j) {
                perm[cyc[j]] = cyc[(j + k) % cyc.size()];
            }            
        }
    }         

    for (int i = 2; i <= n; ++i) {
        arr[i] = arr[i - 1] + d[perm[i - 1]];
    }

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

int main() {
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 4208
#include<stdio.h>

int main(void)
{

int a,b,c,x;

scanf("%d\n",&a);
scanf("%d\n",&b);
scanf("%d\n",&c);

if(a>c){

x=c;
c=a;
a=x;

}


if(a>b){

x=a;
a=b;
b=x;

}

if(b>c){

x=c;
c=b;
b=x;

}

printf("%d %d %d\n",a,b,c);

return 0;

}

Measured memory_bytes: 2736
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling, digitDP//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal ,RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vpll path;
//***********//
int main() { 
	string S;
	cin >> S;
	N = S.length();
	if (S[0] != '1' || S[N - 1] != '0') {
		cout << -1;
		exit(0);
	}
	for (i = 0; i < N/2; i++) {
		if (S[i] != S[N - i - 2]) {
			cout << -1;
			exit(0);
		}
	}
	vl Ans(N-1);
	Ans[N - 2] = N - 1;
	for (i = N-3; i >= 0; i--) {
		if (S[i + 1] == '1') Ans[i] = i + 1;
		else Ans[i] = Ans[i+1];
	}
	for (i = 0; i < N-1; i++) {
		cout << i + 1 << " " << Ans[i] + 1 << endl;
	}
}

Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	int n, x, a[100000];
	cin >> n >> x;
	for(int i=0; i<n; i++) cin >> a[i];

    int w[100000];
    for(int i=0; i<n; i++) w[i] = a[i];

    for(int i=0; i<n-1; i++){
    	if(w[i] + w[i+1] <= x) continue;
    	if(w[i] > x) w[i] = x;
    	w[i+1] = x - w[i];
    }

    long long ans = 0;
    for(int i=0; i<n; i++){
    	ans += a[i] - w[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#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 d, n, ans;
  cin >> d >> n;
  
  if (n == 100) ans = 101 * pow(100, d);
  else {
    if (d == 0) ans = n;
    else if (d == 1) ans = n * 100;
    else if (d == 2) ans = n * 100 * 100;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3748
# 200216 C

import collections

N = int(input())
S = [""] * N
dic = {}
for i in range(N):
    S = input()
    if S in dic:
        dic[S] += 1
    else:
        dic[S] = 1

maxs = max(list(dic.values()))
ans = []
for i in dic:
    if dic[i] == maxs:
        ans.append(i)
ans = sorted(ans)
for i in ans:
    print(i,end=" ")
print("")        
    


Measured memory_bytes: 33788
# Strategy: smallest 1's digit at the last. Others don't matter.
time = [None] * 5
smallest = 10
smallest_i = -1 
for i in range(5):
    time[i] = int(input())
    if (time[i] - 1) % 10 < smallest:
        # order: 1,2,3...9,0
        smallest = (time[i] - 1) % 10 
        smallest_i = i
total = 0
for i, t in enumerate(time):
    if i == smallest_i:
        total += time[i]
    else:
        rem = time[i] % 10
        if rem == 0:
            total += time[i]
        else:
            total += time[i] - rem + 10
print(total)



Measured memory_bytes: 3064
a = []
b = []
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = []
min = 10**9
max = 0
cnt = 0
for i in 0..a[0]-1
  if min > b[i]
    min = b[i]
  end
  if max <= b[i] - min
    max = b[i] - min
    c.push(max)
  end
end
puts c.count(c.max)

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

int main(){
  int a,b,c;
  cin >> a;
  b = a / 100;
  c = a % 100;
  if(a / 1000 == b % 10|| b % 10 == c / 10|| c / 10 == a %  10)
    cout << "Bad" << endl;
  else
    cout << "Good" << endl;
}
             
            
          
      
    


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

int main() 
{
    int a, b;
    int aa, ab, bb;
    cin >> a >> b;

    // aa 
    aa = a + (a - 1);

    // ba
    ab = a + b;

    // bb
    bb = b + (b - 1);

    cout << max(max(aa, ab), bb) << endl;

}

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

int N, M;
int P[1 << 11][1 << 11];

void solve(int lx, int rx, int ly, int ry) {
	P[(lx + rx) / 2][(ly + ry) / 2] = 1;
	if (lx == rx && ly == ry) return;
	
	int mx = (lx + rx) / 2, my = (ly + ry) / 2;
	solve(lx, mx - 1, ly, my - 1);
	solve(lx, mx - 1, my + 1, ry);
	solve(mx + 1, rx, ly, my - 1);
	solve(mx + 1, rx, my + 1, ry);
}

int main() {
	cin >> N >> M;
	solve(1, 1023, 1, 1023);

	for (int i = 1; i <= (1 << N) - 1; i++) {
		for (int j = 1; j <= (1 << M) - 1; j++) cout << P[i][j];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 11520
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int x = 0;
		int max = x;
		for (int i = 0; i < n; i++) {
			if("I".equals(s.substring(i, i+1))) {
				x++;
				if (max < x) {
					max = x;
				}
			} else {
				x--;
			}
		}
		System.out.println(max);
		sc.close();
	}
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N, A[101010];
map<ll,ll> mk;
ll i,j,ans;
int main(){
    scanf("%lld", &N);
    fornum(i,0,N){
        scanf("%lld", &A[i]);
    }
    fornum(i,0,N){
        if(A[i]!=0)
            break;
    }
    if(i==N){
        printf("Yes");
        return 0;
    }
    if(N%3!=0){
        printf("No");
        return 0;
    }
    fornum(i,0,N){
        if(mk.find(A[i])==mk.end()){
            if(mk.size()==3){
                printf("No");
                return 0;
            }
        }
        mk[A[i]]++;
    }
    if(mk.size()==1)
    {
        printf("No");
        return 0;
    }
    if(mk.size()==2){
        auto it = mk.begin();
        auto a = *it;
        ++it;
        auto b = *it;
        if(0==a.first&&a.second*2==b.second){
            goto yes;
        }else if(0==b.first&&a.second==b.second*2){
            goto yes;
        }
        printf("No");
        return 0;
    }
    if(mk.size()==3){
        auto it = mk.begin();
        auto a = *it;
        ++it;
        auto b = *it;
        ++it;
        auto c = *it;
        if((a.first^b.first^c.first)!=0||a.second!=b.second||a.second!=c.second){
            printf("No");
            return 0;
        }
    }
    yes:
    printf("Yes");
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String [] args){
        Scanner sc =new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int ans =0;
        for (Integer i =A;i<=B;i++){
            String[] s = i.toString().split("");
            if (s[0].equals(s[4]) && s[1].equals(s[3])){
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 65648
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#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--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 9000000000000000000 //9e18:極めて大きい値
#define MOD 998244353
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define LOGMAXR 18 // floor(log2(10^5)) + 1: 配列の最大のrangeのlog
//略記
//#define PB push_back //vectorヘの挿入
//#define MP make_pair //pairのコンストラクタ
//#define F first //pairの一つ目の要素
//#define S second //pairの二つ目の要素

ll modpow(ll n, ll p, ll mod){
  ll ret = 1;
  while(p){
    if(p & 1){
      ret *= n;
      ret %= mod;
    }
    p >>= 1;
    n = n * n;
    n %= mod;
  }
  return ret;
}


int main(){
  ll N, S;
  cin >> N >> S;
  ll A[N];
  REP(n, N) cin >> A[n];

  ll memo[S+1];
  REP(s, S+1) memo[s] = 0;
  memo[0] = 1;
  for(auto& a : A){
    REPD(n, S + 1){
      if(n + a < S + 1){
	memo[n + a] += memo[n];
	memo[n + a] %= MOD;
      }
      memo[n] *= 2;
      memo[n] %= MOD;
    }
  }

  //for(auto& s : memo) cout << s << endl;

  ll ret = memo[S];
  cout << ret << endl;

  return 0;
}


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

using namespace std;

#define endl "\n"

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);cout.tie(NULL);

   int n,x,t,cnt=0;
   cin>>n>>x>>t;
   
   while(n>0)
   {
       n-=x;
       cnt++;
   }
   
   cout<<t*cnt;
   

     return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    ll n;
    cin >> n;
    n = n % 10;
    switch (n)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
    cout << "hon" << endl;
        break;
    case 0:
    case 1:
    case 6:
    case 8:
    cout << "pon" << endl;
        break;
    default:
    cout << "bon" << endl;
        break;
    }
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
  using namespace std;
 
int main(){
  string s;
  cin>>s;
  int count=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='+'){
     count++; 
    }else{
     count--; 
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
import itertools
import collections

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

n,m=getints()

values = [getints() for _ in range(m)]

dic = collections.defaultdict(list)

for a,b in values:
    dic[a].append(b)

mp = collections.defaultdict(collections.defaultdict)

for k in dic.keys():
    dic[k] = list(sorted(dic[k]))
    for i in range(len(dic[k])):
        mp[k][dic[k][i]] = i + 1


for a,b in values:
    d = mp[a][b]
    res1 = str(a)
    while len(res1) != 6:
        res1 = "0" + res1
    res2 = str(d)
    while len(res2) != 6:
        res2 = "0" + res2
    print(res1 + res2)


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

int main() {
    int K, S;
    cin >> K >> S;
    int res = 0;
    for(int i = 0; i<=K; i++) {
        for(int j = 0; j<=K; j++) {
            int z = S - (i + j);
            if( 0 <= z && z <= K && i + j + z == S) res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, n;
  in(n);
  rep2(i, -1000, 1001){
    rep2(j, -1000, 1001){
      a = i * i * i * i * i;
      b = j * j * j * j * j;
      if(a - b == n){
        out(i);
        hina;
        out(j);
        memi;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <vector>

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

using namespace std;

void make_map(vector<long> &sum, unordered_map<long, int> &map)
{
	for(int i=1; i<(int)sum.size(); i++){
		for(int j=0; i+j<(int)sum.size(); j++){
			if (map.count(sum[i+j]-sum[j]) == 0){
				map.insert(make_pair(sum[i+j]-sum[j], 1));
			}else{
				map[sum[i+j]-sum[j]]++;
			}
		}
	}
	return;
}

int main(void)
{
	int N, M;
	while(cin >> N >> M, N > 0){
		unordered_map<long, int> h_map;
		unordered_map<long, int> w_map;
		vector<long> h_sum;
		vector<long> w_sum;
		long result = 0;
		//hの累積和配列を作成
		h_sum.push_back(0);
		rep(i, N){
			int h;
			cin >> h;
			h_sum.push_back(h_sum.back() + h);
		}
		//h_mapの構成
		make_map(h_sum, h_map);
		//wの累積和配列を作成
		w_sum.push_back(0);
		rep(i, M){
			int w;
			cin >> w;
			w_sum.push_back(w_sum.back() + w);
		}
		//w_mapの構成
		make_map(w_sum, w_map);

		//h_mapのイテレータを回して，同じキー値をもつw_mapの要素数だけresultを加算
		for(auto itr = h_map.begin(); itr != h_map.end(); itr++){
			result += (*itr).second * w_map[(*itr).first];
		}

		//出力
		cout << result << endl;
	}
	return 0;
}


Measured memory_bytes: 31980
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <fstream>
long long int gcd(long long int a, long long int b) {
	return (b == 0) ? a : gcd(b, a % b);
}
int main() {
	std::cin.tie(0); std::cin.sync_with_stdio(false);
	while (true) {
		int a, b, d; std::cin >> a >> b >> d; if (a == 0 && b == 0 && d == 0) break;
		auto g = gcd(a, b);
		a /= g; b /= g; d /= g;
		int ar = b + d;
		int br = a + d;
		for (auto i = 0; i <= std::max(b, d); ++i) {
			if ((a * i - d) % b == 0) {
				auto j = std::abs((a * i - d) / b);
				if (i + j < ar + br) {
					ar = i; br = j;
				}
				else if (i + j == ar + br && i * a + j * b < ar * a + br * b) {
					ar = i; br = j;
				}
			}
			if ((a * i + d) % b == 0) {
				auto j = std::abs((a * i + d) / b);
				if (i + j < ar + br) {
					ar = i; br = j;
				}
				else if (i + j == ar + br && i * a + j * b < ar * a + br * b) {
					ar = i; br = j;
				}
			}
		}
		for (auto j = 0; j <= std::max(a, d); ++j) {
			if ((b * j - d) % a == 0) {
				auto i = std::abs((b * j - d) / a);
				if (i + j < ar + br) {
					ar = i; br = j;
				}
				else if (i + j == ar + br && i * a + j * b < ar * a + br * b) {
					ar = i; br = j;
				}
			}
			if ((b * j + d) % a == 0) {
				auto i = std::abs((b * j + d) / a);
				if (i + j < ar + br) {
					ar = i; br = j;
				}
				else if (i + j == ar + br && i * a + j * b < ar * a + br * b) {
					ar = i; br = j;
				}
			}
		}
		std::cout << ar << ' ' << br << '\n';
	}
}



Measured memory_bytes: 3140