akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    vi D(n); for(auto& e : D) cin >> e;
    vi cnt(24);
    for(auto& d : D){
        if(d == 0 or cnt[d] == 2){
            cout << 0 << endl;
            return 0;
        }
        cnt[d]++;
    }
    sort(_all(D));

    int res = 0;
    rep(i, 1 << n){
        [&](){
            const int N = 24;
            vi used(N + 1);
            rep(j, n){
                int ni = D[j];
                if((i >> j) & 1){
                    ni = N - D[j];
                }
                if(used[ni]) return;
                used[ni] = true;
            }
            used[0] = used[N] = true;

            int cur = 24, tm = 0;
            rep(j, 1, N + 1){
                if(used[j]) chmin(cur, j - tm), tm = j;
            }
            cur %= 24;
            chmax(res, cur);
        }();
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
n = int(input())
s = list(map(int, sys.stdin.readline().split()))

s.sort()#popするのでreverseしない
#print(s)
P = [s[-1]]
P_next = []

Rem = s[:-1]
Rem_next = []
for _ in range(n):
    while P:
        p = P.pop()
        P_next.append(p)
        while Rem:
            r = Rem.pop()
            if p>r:
                P_next.append(r)
                break
            Rem_next.append(r)
        """
        while p == Rem[-1]:
            r = Rem.pop()
            Rem_next.append(r)
        if Rem:
            P_next.append(Rem.pop())
        """
    P = P_next
    P_next = []
    Rem += Rem_next
    Rem_next = []
    #不自然な置き換えに見えるがlistからremoveするよりはマシか
    P.sort()
    Rem.sort()
if len(P) == 2**n:
    print("Yes")
else:
    print("No")
        


Measured memory_bytes: 119584
#include <stdio.h>
#include <string.h>
int main(){
	char b[101];
	int a, c;
	scanf ("%d", &a);
	getchar();
	scanf("%[^\n]", &b);
	c= strlen(b);
	if (c>a){
		for (int i=0; i<a; i++){
			printf("%c", b[i]);
		}
		printf("...\n");
	}
	else{
		for(int i=0; i<c; i++){
			printf("%c", b[i]);
		}
	}
	
	return 0;
}

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

int main() {
    int a,b,k;
    cin >> a >> b >> k;
    int count = 0;
    for(int i=min(a,b);i>0;i--){
        if(a%i==0 && b%i==0){
            count++;
        }
        if(count == k){
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
   char a;
   cin >> a;
   if(isupper(a)){
      cout << 'A' << endl;
   }
   else{
      cout << 'a' << endl;
   }
   return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main(void){
    while(1){
        int n,i,j,g,x,y=0;
        scanf("%d %d",&n,&x);
        if(n==0&&x==0)
            break ;
        for(i=1;i<=n-2;i++){
            for(j=i+1;j<=n-1;j++){
                for( g=j+1;g<=n;g++){
                    if(i+j+g==x)
                        y++;
                }
            }
        }
        printf("%d\n",y);
    }
    return 0;
}

Measured memory_bytes: 1744
INF=Float::INFINITY
n = gets.chomp.to_i
w = gets.chomp.split.map(&:to_i)

ans = INF
1.upto(n-1).each do |t|
  can = (w.slice(0,t).inject(:+) - w.slice(t, 1000).inject(:+)).abs
  ans = can if ans > can
end

puts ans



Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>
#include <unordered_map>
#include <stack>

using namespace std;
typedef long long  ll;
const ll INF = 1000000007;
const ll mod = 1000000007;


int main()
{
	ll N, K;
	cin >> N >> K;
	vector<ll> h(N);
	for (ll i = 0; i < N; i++)
	{
		cin >> h[i];
	}
	vector<ll> dp(100001, INF);
	dp[0] = 0;
	for (ll i = 0; i < N; i++)
	{

		for (ll k = 1; k <= K; k++)
		{
			if (i < k) break;
			dp[i] = min(dp[i], dp[i - k] + abs(h[i - k] - h[i]));
		}
	}
	cout << dp[N - 1] << endl;
	return 0;

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, W;
	cin>>n>>W;
	vector<int> dp(W+1);
	dp[W]=0;
	for(int i=1; i<=n; ++i)
	{
		int w,v;
		cin>>w>>v;

		vector<int> newdp(W+1);
		for(int i=0; i<=W; ++i)
		{
			int k=0;
			if(i+w<=W)
			{
				k=v+dp[i+w];
			}
			newdp[i] = max(k, dp[i]);
		}
		dp=newdp;
	}
	int ans=0;
	for(int i:dp)
	{
		ans=max(ans, i);
	}
	cout<<ans;

	return 0;	
}

Measured memory_bytes: 4712
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
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;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

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

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

    if(b==1){
        cout<<0<<endl; return 0;
    }

    int sum = 0;
    int ans;
    REP(i,20){
        sum += a-1;
        if(i==0){
            sum += 1;
        }
        if(sum >= b){
            ans = i + 1;
            break;
        }
    }
    cout<<ans<<endl;

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

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

ifstream ifs("in.txt");

void inp(vector<pair<char, int> > &a){
    while (1){
        char c;
        cin >> c;
        if (c == '$') break;
        int x;
        cin >> x;
        a.push_back(make_pair(c, x));
    }
}

int main() {
    vector<pair<char, int> > a, b, c, res, ans;
    inp(a);
    inp(b);
    inp(c);
    REP(i,(int)a.size() - (int)b.size() + 1){
        bool f = true;
        REP(j,b.size()){
            if (a[i+j].first != b[j].first){
                f = false;
                break;
            }
            if (j == 0 || j == b.size()-1){
                if (a[i+j].second < b[j].second){
                    f = false;
                    break;
                }
            }else{
                if (a[i+j].second != b[j].second){
                    f = false;
                    break;
                }
            }
        }
        if (f){
            REP(j,i) res.push_back(a[j]);
            if (b.size() > 1){
                a[i].second -= b[0].second;
                res.push_back(a[i]);
            }
            REP(j,c.size()) res.push_back(c[j]);
            a[i+b.size()-1].second -= b[b.size()-1].second;
            res.push_back(a[i+b.size()-1]);
            FOR(j,i+b.size(),a.size()-1) res.push_back(a[j]);
            break;
        }
    }
    if (res.empty()){
        REP(i,a.size()){
            printf("%c %d ", a[i].first, a[i].second);
        }
        printf("$\n");
    }else{
        REP(i,res.size()){
            if (!ans.empty() && ans[ans.size()-1].first == res[i].first){
                ans[ans.size()-1].second += res[i].second;
            }else if (res[i].second > 0){
                ans.push_back(res[i]);
            }
        }
        REP(i,ans.size()){
            printf("%c %d ", ans[i].first, ans[i].second);
        }
        printf("$\n");
    }
    return 0;
}

Measured memory_bytes: 3292
#include<bits/stdc++.h>
#define    ll   long long int
#define    sz   200010

using namespace std;


int main()
{
    double x;
    ll d,n;

    cin>>n;
    d=n/2+n%2;

    x=(d*1.0)/(n*1.0);

    printf("%0.10lf\n",x);

    return 0;
}


Measured memory_bytes: 256
function main(input){
    input=input.split(' ');
    x=parseInt(input[0],10)
    if (x==3 ||x==5 || x==7){
        console.log("YES")
    }else{
        console.log("NO")
    }


}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pi pair<int,int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<": "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define dblout(x) cout << setprecision(x) << fixed;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int MAXN = 1e6 + 5;

vector<int> prime;
int lp[MAXN];
void init()
{
    lp[1] = 1;
    for(int i = 2; i < MAXN; i++)
    {
        if(!lp[i])
            lp[i] = i, prime.pb(i);
        for(int j = 0; j < sz(prime) && i * 1LL * prime[j] < 1LL * MAXN; j++)
        {
            lp[i * prime[j]] = prime[j];
            if(i % prime[j] == 0)
                break;
        }
    }
}
void cp()
{
    int n;
    cin >> n;
    int cnt = 0;
    for(int i = 1; i <= n; i++)
    {
        int temp = n - i;
        int me = 1;
        map<int, int> freq;
        while(temp > 1)
            freq[lp[temp]]++, temp /= lp[temp];
        for(auto &x : freq)
            me *= (x.ss + 1);
        cnt += me;
    }
    cout << cnt-1 << endl;
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    init();
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}

Measured memory_bytes: 7724
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main(){
	int a,b;cin>>a>>b;
	if((b+a)%2==1){
		puts("IMPOSSIBLE");
	}
	else cout<<(a+b)/2<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;

void call(int n) {
	int i = 1;
	do {
		int x = i;
		bool END_CHECK_NUM = false;
		if (x % 3 == 0) {
			cout << " " << i;
			END_CHECK_NUM = true;
		}
		do {
			if (!END_CHECK_NUM && x % 10 == 3) {
				cout << " " << i;
				END_CHECK_NUM = true;
			}
			x /= 10;
		} while (!END_CHECK_NUM && x);
	} while (++i <= n);

	cout << endl;
}

int main() {
	int n;
	cin >> n;
	call(n);
	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
#define F(a,b) for(register int (a)(0);(a)^(b);(a)++)
using namespace std;
string s("UNRESTORABLE"),s1,s2;
signed main()
{
	getline(cin,s1),getline(cin,s2);int l1(s1.length()),l2(s2.length());bool f1(1);
	if(l1<l2){cout<<s;goto endreturn;}
	for(register int i(l1-l2);i>=0;i--){bool f2(1);F(j,l2){f2=(((s1[i+j]-s2[j])&&(s1[i+j]-'?'))?(0):(f2));}if(f2){F(j,l2){s1[i+j]=s2[j];}F(j,l1){s1[j]=((!(s1[j]-'?'))?(97):(s1[j]));}f1=0,cout<<s1;goto endreturn;}}
	if(f1){cout<<s;}endreturn:return putchar(10),0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char[] c = s.toCharArray();
    
    String t = "abcdefghijklmnopqrstuvwxyz";
    char[] al = t.toCharArray();
    
    for(int i = 0; i < t.length(); i++){
      if(c[0] == al[i]){
        System.out.println(al[i+1]);
      }
    }
    
  }
}


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

int main() {
  int A, B;
  cin >> A >> B;
  
  int ans = 0;
  for (int i = A; i <= B; i++) {
    int x = 0;
    for (int j = i; j > 0; j /= 10) {
      x = 10 * x + j % 10;
    }
    
    if (x == i) {
      ans++;
    }
  }
  
  cout << ans << endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> c(n), v(n), r(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  for (int i = 0; i < n; i++) {
    cin >> c.at(i);
  }
  for (int i = 0; i < n; i++) {
    r.at(i) = v.at(i) - c.at(i);
  }
  int res = 0;
  for (int bit = 0; bit < (1<<n); bit++) {
    int sum = 0;
    for (int i = 0; i < n; i++) {
      if ((1<<i) & bit) {
        sum += r.at(i);
      }
    }
    res = max(res, sum);
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n, m, x;
  cin >> n >> m >> x;
  ll ans = INF;
  ll bitN = 1LL << n;
  vll c(n);
  vvll a(n, vll(m));
  rep(i, n){
    cin >> c[i];
    rep(j, m){
      cin >> a[i][j];
    }
  }
  rep(i, bitN){
    ll tmp = 0;
    vll und(m, 0);
    rep(j, n){
      if((i >> j) & 1){
        tmp += c[j];
        rep(k, m){
          und[k] += a[j][k];
        }
      }
    }
    if(*min_element(ALL(und)) >= x){
      chmin(ans, tmp);
    }
  }
  print(ans == INF ? -1 : ans);
}


Measured memory_bytes: 3524
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<cmath>
using namespace std;

int main(void)
{
	long long N, P;
	cin >> N >> P;

	if(N == 1){
		cout << P << endl;

		return 0;
	}
	
	long long ans = 1;
	for(long long i=2; i*i<=P; i++){
		long long cnt = 0;
		long long p = P;
		while(p%i == 0){
			cnt++;
			p /= i;
		}

		if(cnt >= N)
			ans = i;
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	n := 0
	fmt.Scan(&n)
	var curr int
	var numbers []int
	for i := 0; i < 2*n; i++ {
		fmt.Scan(&curr)
		numbers = append(numbers, curr)
	}
	sort.Ints(numbers)
	sum := 0
	for i := 0; i < 2*n; i += 2 {
		sum += numbers[i]
	}
	fmt.Println(sum)
}


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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n;
    cin >> n;
    int ans = (n/500)*1000;
    n%=500;
    ans += (n/5)*5;
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cassert>
#include <deque>
#include <map>
#include <queue>
#include <climits>
#include <set>
#include <stack>

using namespace std;

#define ll long long
#define MAX 200000
#define MAX1 10000
#define MAX2 100000
#define inf 1000000000
#define eps 1e-12
#define MOD 1000000007

int a[MAX + 5];

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    int n, i;
    ll ans = 0;
    priority_queue<pair<int, int>> pq;
    cin >> n;
    for (i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a, a + n);
    pq.push({a[n - 2], a[n - 1]});
    ans += a[n - 1];
    for (i = n - 3; i >= 0; --i) {
        auto z = pq.top();
        ans += z.first;
        if (i < n - 3) {
            pq.pop();
        }
        pq.push({a[i], z.first});
        pq.push({a[i], z.second});
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 5644
#include <iostream>

using namespace std;

const int INF = 1e9;

int N, M, L, S, T;
int dp[20][1<<17];

int bc(int x){
  int res = 0;
  while(x > 0){
	if(x&1) ++res;
	x >>= 1;
  }
  return res;
}

int main(){
  while(cin>>N>>M>>L>>S>>T,N){
	--S;
	int dist[310][310];
	fill((int*)dist, (int*)dist+310*310, INF);
	for(int i=0;i<M;++i){
	  int a, b, t; cin >> a >> b >> t;
	  --a, --b;
	  dist[a][b] = dist[b][a] = t;
	}
	
	int pl[20], ct[20];
	for(int i=0;i<L;++i){
	  cin >> pl[i+1] >> ct[i+1];
	  --pl[i+1];
	}
	  
	++L;
	pl[0] = S;
	ct[0] = 0;

	for(int i=0;i<N;++i)
	  dist[i][i] = 0;
	for(int k=0;k<N;++k)
	  for(int i=0;i<N;++i)
		for(int j=0;j<N;++j)
		  dist[i][j] = dist[j][i] = min(dist[i][j], dist[i][k] + dist[k][j]);

	fill((int*)dp, (int*)dp+20*(1<<17), INF);
	dp[0][1] = 0;
	for(int b=0;b<(1<<L);++b){
	  for(int i=0;i<L;++i){
		if((b>>i&1) == 0) continue;
		for(int j=0;j<L;++j){
		  if(b>>j&1) continue;
		  dp[j][b|(1<<j)] = min(dp[j][b|(1<<j)], dp[i][b] + dist[pl[i]][pl[j]] + ct[j]);
		}
	  }
	}

	int ans = 0;
	for(int i=0;i<L;++i)
	  for(int b=0;b<(1<<L);++b)
		if(dp[i][b] + dist[pl[i]][pl[0]] <= T)
		  ans = max(ans, bc(b)-1);
	cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 11776
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define vsort(v) sort(v.begin(),v.end())
#define asort(a,n) sort(a, a + n)
#define vi vector<int>
#define vd vector<double>

//ここからAtCoder向けdefine
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;

using namespace std;

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

    char c[27];
    string s;
    cin >> s;
    rep(i, s.size()){
        c[i] = s.at(i);
        rep(j, i){
            if(c[j] == c[i]){
                cout << "no" << endl;
                return 0;
            }
        }
    }
    cout << "yes" << endl;

    return 0;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline
from collections import Counter
def main():
    S = list(map(int, input().rstrip("\r\n")))
    N = len(S)
    P = 2019
    S.reverse()
    ans = 0
    if P == 2 or P == 5:
        for i in range(N):
            if S[i] % P == 0:ans += N-i
    else:
        D = [0] * (N+1)
        tenpow = 1
        for i in range(N):
            S[i] = S[i] * tenpow % P
            tenpow *= 10
            tenpow %= P
            D[i+1] = (S[i] + D[i]) % P
        c = Counter(D)
        for v in c.values():
            ans += v*(v-1)//2
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 78396
#include<stdio.h>
int main(void)
{
	int n,x,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		x=i*1.08;
		if(n==x){
			printf("%d\n",i);
			break;
		}
		if(n<x){
			printf(":(\n");
			break;
		}
	}
	return 0;
}

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

int N, L;
string s[110];

int main(){
  cin >> N >> L;
  for(int i=0; i<N; ++i){
    cin >> s[i];
  }
  sort(s, s+N);
  for(int i=0; i<N; ++i){
    cout << s[i];
  }
  return 0;
}

Measured memory_bytes: 764
#include <stdio.h>
typedef struct{
	int num,ans,rank;
}Pair;
void swap(Pair *a,Pair *b){
	Pair tmp=*a;
	*a=*b;*b=tmp;
}
int main(){
	int num,ans,i=0;
	Pair a[256];
	while(1){
		scanf("%d,%d",&num,&ans);
		if(!num&&!ans) break;
		a[i].num=num;
		a[i].ans=ans;
		i++;
	}
	for(int j=0;j<i;j++){
		for(int k=j+1;k<i;k++) if(a[k].ans>a[j].ans) swap(&a[k],&a[j]);
	}
	int tmp=a[0].ans,k=1;
	for(int j=0;j<i;j++){
		if(a[j].ans==tmp) a[j].rank=k;
		else{
			k++;
			tmp=a[j].ans;
			a[j].rank=k;
		}
	}
	while(~scanf("%d",&num)){
		for(int j=0;j<i;j++) if(num==a[j].num) printf("%d\n",a[j].rank);
	}
	return 0;
}

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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#define db(x) cout << "> " << #x << " = " \
	<< (x) << '\n'
#define db2(x, y) cout << "> " << #x << " = " \
	<< (x) << ", " << #y << " = " << (y) << '\n'
#define db3(x, y, z) cout << "> " << #x << \
	" = " << (x) << ", " << #y << " = " << \
	(y) << ", " << #z << " = " << (z) << '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<vector<int>> vvi;
typedef map<int, int> mii;
typedef set<int> si;

int l, r;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cin >> l >> r;
	vi vals;
	for (int i = l; i <= min(r, l + 2 * 2019); ++i)
		vals.pb(i % 2019);
	int ans = 2019;
	for (int i = 0; i < sz(vals); ++i) {
		for (int j = i + 1; j < sz(vals); ++j) {
			ans = min(ans, (vals[i] * vals[j]) % 2019);
		}
	}
	cout << ans << '\n';
	return 0;
}



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

string solve() {
    ll A;
    string S;
    cin >> A >> S;
    if ( A >= 3200 ) return S;
    else return "red";
    
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,k; cin>>n>>k;
    vector<int> p(n,0);
    rep(i,n) cin>>p[i];
    sort(al(p));
    int ans=0;
    rep(i,k) ans+=p[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 3680
N, M = gets.split.map(&:to_i)

max_l = 0
min_r = 10**6
M.times do
  l, r = gets.split.map(&:to_i)
  max_l = [max_l, l].max
  min_r = [min_r, r].min
end

if min_r < max_l
  puts 0
else
  puts min_r - max_l + 1
end


Measured memory_bytes: 1788
#include <math.h>
#include <stdio.h>
int main() {
	int n;
	scanf("%d", &n);
	int x = ((sqrt(1 + 8 * n) - 1.0) + 1.0) / 2;
	if ((x + 1) * x / 2 < n) {
		x++;
	}
	for (int i = x; i > 0; i--) {
		if (n - i >= 0) {
			n -= i;
			printf("%d\n", i);
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

class UnionFind {

public:
    vector<int> par;
    vector<int> rank;
    vector<int> relative_diff;
    
    UnionFind( int n ) {
	par.resize( n );
	rank.resize( n );
	relative_diff.resize( n );
	for ( int i=0; i<n; ++i ) par[i] = i;
    }

    int Root( int x ) {

	if ( x == par[x] ) return x;

	int r = Root( par[x] );
	relative_diff[x] += relative_diff[par[x]];
	par[x] = r;
	return r;
    }
    
    bool IsSame( int x, int y ) {
	return Root( x ) == Root( y );
    }

    void Merge( int x, int y, int w ) {

	w += TotalDiff( x );
	w -= TotalDiff( y );	
	
	x = Root( x );
	y = Root( y );

	if ( x == y ) return;

	if ( rank[x] < rank[y] ) {//yの方が深い
	    relative_diff[x] = -w;
	    par[x] = y;//xをyのグループのルートにつなぐ
	}
	else {//xの方が深いか 同じ深さ
	    relative_diff[y] = w;
	    par[y] = x;//yをxのグループのルートにつなぐ
	    if ( rank[x] == rank[y] ) ++rank[x];
	}
	
    }

    int TotalDiff( int x ) {
	Root( x );
	return relative_diff[x];
    }
    
    int Diff( int x, int y ) {
	return TotalDiff( y ) - TotalDiff( x );
    }
};

int main() {

    int n, l;
    cin >> n >> l;
    
    UnionFind un(n);

    for ( int i=0; i<l; ++i ) {
	int type, a, b;
	cin >> type >> a >> b;
	if ( type == 0 ) {
	    int w;
	    cin >> w;
	    un.Merge( a, b, w );
	}
	else {
	    if ( un.IsSame( a, b ) )
		cout << un.Diff( a, b ) << endl;
	    else
		cout << "?" << endl;
	}
    }

    
    return 0;
}



Measured memory_bytes: 3844
import java.util.*;
 
public class Main {
	
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n1= sc.nextInt();
		int n2=sc.nextInt();
		cout(gcd(n1,n2));
	}
	
	public static int gcd(int a,int b){
		if(a%b==0) return b;
		else return gcd(b,a%b);
	}
	
	public static void showary(int[] ary){
		for(int i=0;i<ary.length-1;i++){
			System.out.print(ary[i]+" ");
		}
		cout(ary[ary.length-1]);
	}
	
	public static void cout(String n){
		System.out.println(n);
	}
	
	public static void cout(int n){
		System.out.println(n);
	}
}

Measured memory_bytes: 26296
#include<iostream>
#include<vector>
#define F first
#define S second
#define MOD 1000000007
using namespace std;

vector<pair<long long,long long>>dp;

void dfs(int i, int par, vector<int>adj[] )
{
	dp[i]={1ll,1ll};//{w,b}
	
	for(int x:adj[i])
	{
		if(x!=par)
		{
			dfs(x,i,adj);
			dp[i].F = ((dp[i].F*dp[x].F)%MOD + (dp[i].F*dp[x].S)%MOD)%MOD;
			dp[i].S = (dp[i].S*dp[x].F)%MOD;
		}
	}
	//cout<<i<<" "<<dp[i].F<<" "<<dp[i].S<<endl;
}

int main()
{
	int n;
	cin>>n;
	vector<int>v[n+1];
	
	for(int i=0;i<n-1;i++)
	{
		int x,y;
		cin>>x>>y;
		v[x-1].push_back(y-1);
		v[y-1].push_back(x-1);
	}
	dp.assign(n,{0,0});
	
	dfs(0,-1,v);
	cout<<((dp[0].F+dp[0].S)%MOD);
	
	
	
	return 0;
}



Measured memory_bytes: 16968
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    string S;
    cin >> S;
    if(S == "Sunny") S = "Cloudy";
    else if(S =="Cloudy") S ="Rainy";
    else S = "Sunny";
    cout << S << endl;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))


dp = [0 for _ in range(N)]
dp[1] = abs(H[1] - H[0])
# dp[i] = i+1につくまでの最小のコスト
for i in range(2, N):
    dp[i] = min((dp[i-1]+abs(H[i-1]-H[i])), (dp[i-2]+abs(H[i-2]-H[i])))


print(dp[-1])

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

struct Edge {
    int to;
    ull weight;
    Edge (int t, ull w) : to(t), weight(w) {};
};
using Tree = vector<vector<Edge>>;

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

    Tree T(N);
    int ai, bi;
    ull ci;
    rep(i, N-1) {
        cin >> ai >> bi >> ci;
        ai--, bi--;
        T[ai].push_back(Edge(bi, ci));
        T[bi].push_back(Edge(ai, ci));
    }

    int Q, K;
    cin >> Q >> K;

    ull dist[N];
    bool seen[N];
    rep(i, N) dist[i] = 0, seen[i] = false;
    queue<int> que;
    que.push(--K);

    while (que.size() > 0) {
        int v;
        v = que.front(), que.pop();
        seen[v] = true;
        for (auto e : T[v]) {
            if (seen[e.to] == false) {
                dist[e.to] = dist[v] + e.weight;
                que.push(e.to);
            }
        }
    }

    int xi, yi;
    rep(i, Q) {
        cin >> xi >> yi;
        xi--, yi--;
        cout << dist[xi] + dist[yi] << endl;
    }

    return 0;
}



Measured memory_bytes: 11264
import scala.io.StdIn

object Main extends App {
  val source = StdIn.readLine.split(" ").map(_.toInt)
  val m = source.max
  val k = StdIn.readLine.toInt
  val mk = m << k
  val res = source.sorted.updated(source.length-1, mk)
  println(res.sum)
}

Measured memory_bytes: 25416
#include<bits/stdc++.h>
using namespace std;
vector<long long> v;
int k;
void dfs(long long x,int sz){
	v.push_back(x);
	if(sz>=10)
		return;
	long long y=x%10;
	dfs(x*10+y,sz+1);
	if(y!=0)
		dfs(x*10+y-1,sz+1);
	if(y!=9)
		dfs(x*10+y+1,sz+1);
}
int main(){
	for(long long i=1;i<10;i++)
		dfs(i,1);
	sort(v.begin(),v.end());
	cin>>k;
	cout<<v[k-1];
	return 0;
}

Measured memory_bytes: 2420
n = int(input())
a = list(map(int,input().split()))
check = [0]*((10**5)+1)
for i in a:check[i] += 1
ans = check[0] + check[1]
for i in range(len(check)-2):ans = max(ans,check[i]+check[i+1]+check[i+2])
print(ans)

Measured memory_bytes: 14008
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
#endif

	string s;
	cin>>s;
	cout<<s.substr(0,3)<<endl;
	return 0;
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main{

	public static void main (String[] args) {

		Main main = new Main ();
		main.solve();
	}

	private void solve(){

		Scanner scanner = new Scanner (System.in);

		long A = scanner.nextLong();
		long B = scanner.nextLong();
		long answer = 0;
		long C = 0;

		if (A%2==0) {

			if (B%2==0) {

				C=(B-A)/2;

				if (C%2==0) {
					answer = B;
				} else {
					answer = B^1;
				}

			} else {

				C=(B-A)/2;

				if (C%2==0) {
					answer = 1;
				} else {
					answer = 0;
				}
			}

		} else {

			if (B%2==0) {

				C = (B-A-1)/2;

				if (C%2==0) {
					answer = A^B;
				} else {
					answer = A^B^1;
				}
			} else {

				C = (B-A)/2;

				if (C%2==0) {
					answer = A;
				} else {
					answer = A^1;
				}
			}

		}

		System.out.println(answer);
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)



int main() {
	string s;
	int road[6][2] = {{1, 2}, {-1, 3}, {1, -1}, {4, 5}, {5, 2}, {2, 1}};
	while(cin >> s, s != "#") {
		int cur = 0;
		bool f = 1;
		rep(i,s.size()) {
			if(s[i] == '0') cur = road[cur][0];
			else cur = road[cur][1];
			if(cur == -1) {
				f = 0;
				break;
			}
		}
		if(f && cur == 5) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}
	

Measured memory_bytes: 1180
while True:
    n=int(input())
    if n==0:
        break
    i=1
    sum=0
    max=0
    min=1000
    while i<=n:
        a=int(input())
        if max<a:
            max=a
        if min>a:
            min=a
        sum+=a
        
        
        i+=1
    sum=sum-max-min
    print(int(sum/(n-2)))


Measured memory_bytes: 5592
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    n,k=map(int,input().split())
    ans=0
    for i in range(1,n+1):
        cnt=0
        while i<k:
            i*=2
            cnt+=1
        ans+=1/(n*(2**cnt))
    print(ans)

    
resolve()

Measured memory_bytes: 39024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define MAX_N 5001
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<string, ll> PS;
typedef vector<ll> V;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int co[110];
char k;
int a;

int main(){
	while (cin >> a){
		REP(i, 100){
			co[i] = -1;
		}
		co[a] = 1;
		REP(i, 4){
			cin >> k >> a;
			if (co[a] == -1){
				co[a] = 1;
			}
			else co[a]++;
		}

		bool f = 0;
		for (int i = 1; i <= 9; i++){
			if (co[i]==1 && co[i + 1]==1 && co[i + 2]==1 && co[i + 3]==1 && co[i + 4]==1){
				cout << "straight" << endl;
				f = 1;
				break;
			}
		}
		if (f)continue;
		if (co[1]==1 && co[10]==1 && co[11]==1 && co[12]==1 && co[13]==1){
			cout << "straight" << endl;
			continue;
		}

		int p2 = 0, p3 = 0, p4 = 0;
		REP(i, 14){
			if (co[i] == 4)p4++;
			if (co[i] == 3)p3++;
			if (co[i] == 2)p2++;
		}
		if (p4)	cout << "four card" << endl;
		else if (p3&&p2)cout << "full house" << endl;
		else if (p3)cout << "three card" << endl;
		else if (p2 == 2)cout << "two pair" << endl;
		else if (p2)cout << "one pair" << endl;
		else cout << "null" << endl;
	}
}

Measured memory_bytes: 1156
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String strArr[] = br.readLine().split(" ");
            int a = Integer.parseInt(strArr[0]);
            int b = Integer.parseInt(strArr[1]);
            int count = 0;
            for (int i = a; i <= b; i++) {
                String str = String.valueOf(i);
                if (str.charAt(0) == str.charAt(4) && str.charAt(1) == str.charAt(3)) {
                    count++;
                }
            }
            System.out.println(count);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}


Measured memory_bytes: 26452
#include <cstdint>
#include <cstddef>

using i32 = std::int_fast32_t;
using u32 = std::uint_fast32_t;
using i64 = std::int_fast64_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

#include <iostream>
#include <cmath>

template<class Tp>
Tp digits_sum (Tp x, Tp base = Tp(10)) {
	Tp value = Tp(0);
	while (x > 0) {
		value += (x % base);
		x /= base;
	}
	return value;
}


template<class Tp>
inline void chmin (Tp &a, const Tp &b) {
	if (a > b) a = b;
}

constexpr i64 INF = (1LL << 60);

int main() {
	i64 n, s;
	std::cin >> n >> s;

	const i64 sqrt = std::max<i64>(2, std::sqrt(n));
	i64 ans = (n == s ? n + 1 : INF);
	
	for (i64 b = 2; b <= sqrt; b++) {
		if (digits_sum(n, b) == s) chmin(ans, b);
	}
	
	for (i64 i = sqrt; i > 1; i--) {
		i64 ng = std::max<i64>(2, n / i);
		i64 ok = std::max<i64>(2, n / (i - 1));
		while (std::abs(ok - ng) > 1) {
			const i64 b = (ok + ng) >> 1;
			if (digits_sum(n, b) > s) ng = b;
			else ok = b;
		}
		if (digits_sum(n, ok) == s) chmin(ans, ok);
	}
	
	if (ans == INF) ans = -1;
	std::cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 3684
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#define ASIZE (1000000 / 2)
int compare(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
void enum_prime(int *list) {
	int i;
	list[0] = 2;
	for (i = 1; i < ASIZE; i++) {
		list[i] = 2 * i + 1;
	}
	list[ASIZE-1] = INT_MAX;
	int j, p, plidx, idx;
	size_t data_cnt = ASIZE;
	for (plidx = 1;;) {
		p = list[plidx];
		idx = plidx;
		for (j = plidx + 1; list[j] < INT_MAX; j++) {
			if (list[j] % p == 0) {
				list[j] = INT_MAX;
			} else {
				idx++;
			}
		}
		qsort(list, data_cnt, sizeof(int), compare);
		data_cnt = idx + 1;
		plidx++;
		if (list[idx] < list[plidx] * list[plidx])
			return;
	}
}
int main() {
	int *prime_list = (int*)malloc(sizeof(int) * ASIZE);
	if (prime_list == NULL)
		return 1;
	enum_prime(prime_list);

	int i, n, cnt;
	while (scanf(" %d", &n) != EOF) {
		cnt = 0;
		for (i = 0; prime_list[i] <= n; i++)
			cnt++;
		printf("%d\n", cnt);
	}
	free(prime_list);
	prime_list = NULL;
	return 0;
}

Measured memory_bytes: 4128
N = int(input())
a = list(map(int, input().split()))
print(*a)
for i in range(1, N):
  v = a[i]
  j = i - 1
  while j >= 0 and a[j] > v:
    a[j + 1] = a[j]
    j -= 1
  a[j + 1] = v
  print(*a)

Measured memory_bytes: 8124
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x,y;
  cin >> x >> y;
  if((y%2==0)&&(x*2<=y)&&(x*4>=y)){
    cout << "Yes" << endl;
  }else{
    cout << "No"  << endl;
  }
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int flag1,i;
    string s;
    cin >>s;
    flag1=1;
        for (i=1;i<s.length();i++)
        {
            if(s[i]!=s[0])
            {
                 flag1=0;
                 break;
            }
        }
    if(flag1==1)cout<<"No";
    else cout<<"Yes";
}


Measured memory_bytes: 256
#include <iostream> 
#include <fstream> 
#include <stdlib.h> 
#include <stdio.h>
using namespace std;

// data typically into global variables here

int main () { 
  // string fname = "input";
  int input [3] = {0, 0, 0};
  int N, i, j, max, maxj, c;
  cin >> N;
  for(; i<N; i++){
    max = maxj = 0;
    for (j=0; j < 3; j++){
      cin >> input[j];
      if (input[j] > max){
	max = input[j];
	maxj = j;
      }
    }
    //check pythagorus
    c = 0;
    for (j=0; j<3; j++){
      if (j != maxj){
	c += input[j]*input[j];
      }
    }
    if (max*max == c){
      cout << "YES" << endl;
    }
    else{
      cout << "NO" << endl;
    }
  }
  // printf("top 3: %d %d %d\n", top[0], top[1], top[2]);
  return 0; 
} 
  
 

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

int main(){
    int n;
    cin>>n;
    vector<string>w(n);
    set<string>s;
    rep(i,n){
        cin>>w[i];
        s.insert(w[i]);
    }
    rep(i,n-1){
        for(int j=n-1;j>i;j--){
           if(w[i]==w[j]){
               cout<<"No"<<endl;
               return 0;
           }
        }
    }
        
    bool ok=true;
    for(int i=1;i<n;i++){
        if(w[i-1][w[i-1].size()-1]==w[i][0])continue;
        else{
            ok=false;
            break;
        }
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;

class Program {
    static void Main (string[] args) {
        string S = Console.ReadLine ();
        string result = "Yes";
        int j = 0;
        int[] cnt = new int[4] { 0, 0, 0, 0 };

        foreach (var s in S) {

            for (int i = 0; i < 4; i++) {
                if (s == S[i]) cnt[j]++;
            }
            if (cnt[j] != 2) result = "No";
            j++;
        }
        Console.WriteLine (result);

    }
}

Measured memory_bytes: 11092
import heapq
from fractions import gcd
from functools import reduce
from collections import deque
# from math import factorial
import itertools
import collections
import math
import sys
sys.setrecursionlimit(2000000)
# import statistics
# import numpy as np
# n = int(input())
# a, b, c, k = list(map(int, input().split()))
# a = list(map(int, input().split()))
# abc = [int(input()) for i in range(5)]
# n = int(input())
a, b, h, m = list(map(int, input().split()))
if h >= 12:
    h -= 12
ms = 360*(m/60)
ns = 360*(h/12) + 30*(m/60)

mx = b*math.cos(math.radians(ms))
my = b*math.sin(math.radians(ms))
hx = a*math.cos(math.radians(ns))
hy = a*math.sin(math.radians(ns))

ans = math.sqrt((mx-hx)**2 + (my-hy)**2)
print(ans)



Measured memory_bytes: 10844
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, n) for(int i=n; i>=0; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> T vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> T adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


int dp[100010];

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

    int n, tmpa;
    vector<int> a;

    cin >> n;
    rep(i, n){
        cin >> tmpa;
        a.push_back(tmpa);
    }

    ll res = 0;
    rep(i, n){
        res += a[i]-1;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,L;
    cin >> N >> L;
    int ans = ((2*L+N-1)*N)/2;
    if(L>0){
        ans -= L;
    }else if(L<0 && L+N-1<0){
        ans -= (L+N-1);
    }else{
        ans -= 0;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int
const static long long int MOD = 1000000000 + 7;

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string S;
    cin >> S;
    int cnt = 0, res = 0;
    for (int i = 0; i < S.size(); ++i) {
        if (S[i] == 'S') {
            ++cnt;
        } else {
            if (cnt > 0) --cnt;
            else  ++res;
        }
    }

    cout << cnt + res << endl;

    return 0;
}

Measured memory_bytes: 720