akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define rep(i,n) for(ll i=0;i<n;i++)
#define vec vector<ll>
#define mat vector<vector<ll>>

using namespace std;
//using namespace atcoder;

const ll mod=1000000007;//998244353;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

ll powmod(ll a,ll n,ll m) {
    if(n == 0)
        return 1;

    if(n % 2 ==0){
        ll r = powmod(a,n/2,m);
        return r*r % m;
    }

    return a*powmod(a,n-1,m)%m;
}

ll factmod(ll a,ll b,ll m) {
  if(a<b)return 0;
  ll s=1;
  while(a>=b){
    s = s*a % m;
    a -= 1;
  }
  return s;
}

ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

ll combmod(ll a,ll b,ll m){
  if(b==0)return 1;
  ll c=factmod(a,a-b+1,m);
  ll d=modinv(factmod(b,1,m),m);
  ll e=(c*d)%m;
  return e;
}

void modsum(ll &a,ll b,ll m){
  a+=b;
  a%=m;
}

void modsub(ll &a,ll b,ll m){
  a-=b;
  a+=m;
  a%=m;
}

void modmul(ll &a,ll b,ll m){
  a*=b;
  a%=m;
}

void modquo(ll &a,ll b,ll m){
  a*=modinv(b,m);
  a%=m;
}

vector<vector<vector<vector<ll>>>> memo(100,vector<vector<vector<ll>>>(2,mat(2,vec(2,-1))));
ll l,r;

ll dfs(ll a,ll x,ll y,ll z){
  if(a==-1)return 1;
  if(memo[a][x][y][z]!=-1)return memo[a][x][y][z];

  ll ret=0;

  if(x==1 || !((1LL<<a)&l)){
    if(y==1 || !((1LL<<a)&r)){
      ret+=dfs(a-1,x,y,z);
    }
    else{
      ret+=dfs(a-1,x,1,z);
    }
  }

  if((x==1 || !((1LL<<a)&l)) && (y==1 || ((1LL<<a)&r)) && z==1){
    ret+=dfs(a-1,x,y,1);
  }

  if(y==1 || ((1LL<<a)&r)){
    if(x==1 || (1LL<<a)&l){
      ret+=dfs(a-1,x,y,1);
    }
    else{
      ret+=dfs(a-1,1,y,1);
    }
  }
  ret%=mod;
  memo[a][x][y][z]=ret;
  return ret;
}

int main(){

  cin >> l >> r;

  ll ans=0;
  
  ans=dfs(59,0,0,0);

  cout << ans << endl;


  //↓失敗の跡
  /*vec a(100);
  a[0]=1;
  for(ll i=0;i<70;i++)a[i+1]=a[i]*2;

  ll s=0;
  while(a[s]<=l)s++;//l=10のときs=4
  if(a[s]<=r){
    ll b=0;//高い位から見ていって、lのなかに0が何回現れたか
    for(ll i=s-2;i>=0;i--){
      if((1LL<<i)&l);
      else{
        modsum(ans,powmod(2,b,mod)*powmod(3,i,mod)%mod,mod);
        b++;
      }
    }
    //x=lのとき
    ll p=__builtin_popcountll(l);
    modsum(ans,powmod(2,s-p,mod),mod);
    
    //cout << 5 << endl;

    while(a[s+1]<=r){
      s++;
      modsum(ans,powmod(3,s-1,mod),mod);
    }
    s++;
    b=0;

    //cout << s << endl;

    for(ll i=s-2;i>=0;i--){
      if(!((1LL<<i)&r));
      else{
        modsum(ans,powmod(2,b,mod)*powmod(3,i,mod)%mod,mod);
        b++;
      }
    }
    p=__builtin_popcount(r)-1;
    modsum(ans,powmod(2,p,mod),mod);
  }
  else{
    
  }*/

  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int n;
	cin>>n;
	int a,b,c;
	a=n/100;b=n%100/10;c=n%10;
	if(a==9)a=1;
	else a=9; 
	if(b==9)b=1;
	else b=9; 
	if(c==9)c=1;
	else c=9;
	cout<<a*100+b*10+c<<endl; 
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    int four = 0;
    int odd = 0;
    for(int i = 0 ; i < N; i++){
      int tmp = sc.nextInt();
      if(tmp%4==0){
        four++;
      }else if(tmp%2!=0){
        odd++;
      }
    }
    
    boolean ans = false;
    if(four-odd >= 0){
        ans = true;
    }else{
      if(four+odd == N && four+1 == odd){
        ans = true;
      }
    }
    
    if(ans){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 58860
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define ALL(i) (i).begin(),(i).end()
#define RALL(i) (i).begin(),(i).end(),greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
#define TENFIVE2 200005
// #define int long long
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double EPS = 1e9 + 7;
const double PI = acos(-1);
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

inline int in(){int x;std::cin>>x;return x;}

using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
using vii = vector<vector<int> >;
using vl = vector<long long>;
using vp = vector<pint>;

template <typename T> void print(T x) { std::cout << x << '\n'; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  std::fill((T*)array, (T*)(array + N), val);
}
signed main(){
  int N;
  ll Y;
  cin>>N>>Y;
  rep(i,N+1){
    rep(j,N-i+1){
      if(Y == 10000*i+ 5000*j + 1000*(N-i-j) && (N-i-j) >=0){
         cout<<i<<" "<<j<<" "<<(N-i-j)<<endl;
         return 0;
      }
    }
  }
  cout<<-1<<" "<<-1<<" "<<-1<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int a = sc.nextInt();
        int b = sc.nextInt();
        String u = sc.next();
      if (s.equals(u)){
        a -= 1;
      }else{
        b -=1;
      }
      System.out.print(a);
      System.out.print(" ");
      System.out.println(b);
    }
}

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


def main():
    n, k = list(map(int, input().split()))
    x = list(map(int, input().split()))
    ans = float('inf')

    for i in range(n - k + 1):
        left = x[i]
        right = x[i + k - 1]
        abs_left = abs(left)
        abs_right = abs(right)

        if left * right >= 0:
            ans = min(ans, max(abs_left, abs_right))
        else:
            ans = min(ans, 2 * abs_left + abs_right, abs_left + 2 * abs_right)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14252
#pragma GCC optimize(3, "Ofast", "inline")

#include <bits/stdc++.h>

#define start ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define int ll
#define ls st<<1
#define rs st<<1|1
#define pii pair<int,int>
#define rep(z, x, y) for(int z=x;z<=y;++z)
#define com bool operator<(const node &b)
using namespace std;
const int maxn = (ll) 3e5 + 5;
const int mod = 1000000007;
const int inf = 0x3f3f3f3f;
int T = 1;
int cntb, cnta, cntab;
int fac[maxn];

void solve() {
    fac[0] = 1;
    rep(i, 1, 2e5 + 5)fac[i] = fac[i - 1] * 2 % mod;
    map<pii, int> mp;
    int n;
    cin >> n;
    rep(i, 1, n) {
        int a, b;
        cin >> a >> b;
        if (a * b == 0) {
            if (a == 0 && b == 0)
                ++cntab;
            else if (a == 0)
                ++cnta;
            else if (b == 0)
                ++cntb;
            continue;
        }

//        if (a * b > 0) {
//            a = abs(a), b = abs(b);
//            int gcd = __gcd(a, b);
//            ++mp[pair<int,int>(a / gcd, b / gcd)];
//            cout << a / gcd << '#' << b/gcd << endl;
//        } else {
//            a = abs(a), b = abs(b);
//            int gcd = __gcd(a, b);
//            ++mp[pair<int,int>(-a / gcd, b / gcd)];
//            cout << -a/gcd << '#' << b << endl;
//        }

        int gcd = __gcd(abs(a), abs(b));
        a /= gcd, b /= gcd;
        if (a * b > 0) {
            a = abs(a), b = abs(b);
            ++mp[pair<int, int>(a, b)];
            //cout << a << '#' << b << endl;
        } else {
            a = abs(a), b = abs(b);
            ++mp[pair<int, int>(-a, b)];
            //cout << -a << '#' << b << endl;
        }

    }
    int ans = (fac[cnta] + fac[cntb] - 1 + mod) % mod;
    for (auto &to:mp) {
        if (to.second == 0)
            continue;
        int a = to.first.first, b = to.first.second;
        int num = to.second;
        pii j = a > 0 ? pii(-b, a) : pii(b, -a);
        if (mp[j] == 0)
            ans = ans * fac[num] % mod;
        else
            ans = ans * (fac[num] + fac[mp[j]] - 1 + mod) % mod;
        //cout << a << ' ' << b << ' ' << ans << ' ' << mp[j] << endl;
        mp[j] = to.second = 0;
    }
    cout << (ans - 1 + cntab + mod) % mod;
}

signed main() {
    start;
    //cout<<__gcd(4,6)<<' '<<__gcd(-4,6)<<' '<<__gcd(4,-6)<<' '<<__gcd(-4,-6)<<endl;
    while (T--)
        solve();
    return 0;
}


Measured memory_bytes: 30168
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

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

	int a;
	string s;
	cin >> a >> s;
	cout << (a >= 3200? s : "red") << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		int a = in.nextInt();
		int b = in.nextInt();
		int h = in.nextInt();
		out.println((a+b)*h/2);
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

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

int main(){
  string S,T;
  cin >> S >> T;
  int a,b;cin >> a >> b;
  string U;cin >> U;
  if(U==S){
    cout << a-1 << " " << b << endl;
  }else{
    cout << a << " " << b-1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define nl "\n"
#define pb push_back
#define sp " "
typedef long long ll;
#define len(x) x.length()
#define vsort(x) sort(x.begin(), x.end();
using namespace std;
ll inf=2e18;

int main()

{

    ios::sync_with_stdio(false);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
   // freopen("bruh.txt","r",stdin);
    #endif
    double n;
    cin>>n;
    double ans=n*n*n/27;
    printf("%.8lf\n",ans);
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
    {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
    {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
    {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
    #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
    #define dump(...)
    #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
    int n, K; cin >> n >> K;
    vector<int> a(n); REP (i, n) cin >> a[i];
    vector<int> ps;
    int sum = accumulate(ALL(a), 0LL);
    for (int x = 1; x * x <= sum; x++) {
        if (sum % x) continue;
        int y = sum / x;
        ps.push_back(x);
        if (y != x) ps.push_back(y);
    }
    sort(RALL(ps));
    vector<int> b(n), acc(n + 1);
    for (int p : ps) {
        REP (i, n) b[i] = a[i] % p;
        sort(ALL(b));
        for (int i = n - 1; i >= 0; i--) {
            acc[i] = acc[i + 1] + (p - b[i]) % p;
        }
        dump(p, acc);
        int cur = 0;
        REP (i, n) {
            dump(i, cur);
            if (cur == acc[i]) {
                if (cur <= K) {
                    cout << p << endl;
                    return 0;
                } else break;
            }
            cur += b[i];
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
#define endl '\n'
#define max3(a,b,c) max(a,max(b,c))

const int q = 1e9+7;




int main()
{
    int n,a;
    cin>>n>>a;
    if(n>=a)cout<<"10"<<endl;
    else cout<<0<<endl;;


    return 0;
}
    // gotcha;


Measured memory_bytes: 256
#include<stdio.h>
#define N 2000
#define Q 2000
int solve(int,int);
int n,q,a[N],m[Q];
int main(){
  int i,j=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
  }
  for(i=0;i<q;i++){
    if(solve(j,m[i])==1) printf("yes\n");
    else if(solve(i,m[i])==0) printf("no\n");
    j=0;
  }
  return 0;
}

int solve(int i,int m){
  int res;
  if(m == 0)  return 1;
  else if(i>=n) return 0;
  res = solve(i + 1, m) || solve(i + 1, m - a[i]);
}

Measured memory_bytes: 588
#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f, MOD = 1000000007;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*-----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, m; cin >> n >> m;
  vector<pair<long long, int> > ab(n); REP(i, n) cin >> ab[i].first >> ab[i].second;
  sort(ALL(ab));
  int cnt = 0;
  long long ans = 0;
  REP(i, n) {
    if (cnt + ab[i].second <= m) {
      cnt += ab[i].second;
      ans += ab[i].first * ab[i].second;
    } else {
      int tmp = m - cnt;
      cnt = m;
      ans += ab[i].first * tmp;
    }
    if (cnt == m) break;
  }
  cout << ans << '\n';
  return 0;
}


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

int main(){
	int H, W;
	while (true){
		cin >> H >> W;
		if (H == 0 && W == 0){
			break;
		}
		//上のふた
		for (int i = 0; i < W; i++){
			cout << '#';
		}cout << endl;
		for (int j = 0; j < H - 2; j++){
			cout << '#';
			for (int k = 0; k < W - 2; k++){
				cout << '.';
			}cout <<'#'<< endl;
		}
		//下のふた
		for (int m = 0; m < W; m++){
			cout << '#';
		}cout << endl; 
		cout << endl;
	}
}


Measured memory_bytes: 3080
//By Akshay Koshy

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    long long int n;
    cin>>n;
    long long int i;long long int c;
 
    
    for(i=1;i<=ceil((float)n/3);i++)
    {
        if(i*i<=n)
        c=i*i;
    }
    cout<<c;
    
    
    return 0;
}


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

int N, G, i, j;
long long p[105], w[105], a[100005], b[100005];
int main() {
    //ifstream cin("rucsac.in");
    cin >> N >> G;
    for (i = 1; i <= N; i++) {
        cin >> w[i] >> p[i];
    }
    for (i = 1; i <= N; ++i) {
        for (j = 1; j <= G; ++j) {
            if (w[i] > j)a[j] = b[j];
            else {
                a[j] = max(b[j], b[j - w[i]] + p[i]);
            }
        }
        for (j = 1; j <= G; ++j)
            b[j] = a[j];
    }
    cout << a[G];
}

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

typedef long long ll;
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;

    vector<bool> ac(n);
    vector<int> wa(n);
    for (int i = 0; i < n; ++i) {
        ac[i] = false;
        wa[i] = 0;
    }

    for (int i = 0; i < m; ++i) {
        int p;
        string s;
        cin >> p >> s;
        if (s == "AC") {
            ac[p - 1] = true;
        } else if (!ac[p - 1]) {
            wa[p - 1]++;
        }
    }
    int acn = 0;
    int wan = 0;
    for (int i = 0; i < n; ++i) {
        if (ac[i]) {
            acn++;
            wan += wa[i];
        }
    }

    cout << acn << " " << wan;
    return 0;
}


Measured memory_bytes: 640
#MLE注意！0や1のケースに注意

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    x = int(input())
    n = 100
    res = 0
    while n < x:
        res += 1
        n = int(n*1.01)
    print(res)

if __name__ == '__main__':
    main()

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    vector<int> res;
    while (true) {
        int n, m;
        cin >> n >> m;
        if (n == 0) break;
        int r;
        cin >> r;
        vector<pair<int, int>> v[1001];
        vector<int> a(r), b(r), c(r), d(r);
        for (int i = 0; i < r; i++) {
            cin >> a[i] >> b[i] >> c[i] >> d[i];
            v[b[i]].emplace_back(a[i], c[i]);
        }
        int q;
        cin >> q;
        for (int i = 0; i < q; i++) {
            int a, b, c;
            cin >> a >> b >> c;
            vector<bool> time(60 * 24, false);
            vector<int> used;
            for (int j = 1; j <= n; j++) {
                for (int k = 0; k < (int)v[j].size(); k++) {
                    if (v[j][k].se == c) {
                        used.push_back(v[j][k].fi);
                    }
                }
            }
            for (int j = 0; j < (int)used.size() - 1; j+=2) {
                for (int k = used[j]; k < used[j + 1]; k++) {
                    time[k] = true;
                }                
            }
            int cnt = 0;
            for (int j = a; j < b; j++) {
                if (time[j]) {
                    cnt++;
                }
            }
            res.push_back(cnt);
        }
    }
    for (int i = 0; i < (int)res.size(); i++) {
        dump(res[i]);
    }
    return 0;
}



Measured memory_bytes: 3176
#[allow(unused_macros)]
macro_rules! invec {
    ( $t:ty ) => {{
        let mut s = String::new();
        match std::io::stdin().read_line(&mut s) {
            Ok(0) => Vec::<$t>::new(),
            Ok(n) => s.trim().split_whitespace().map(|s| s.parse::<$t>().unwrap()).collect::<Vec<$t>>(),
            Err(_) => Vec::<$t>::new(),
        }
    }}
}

#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($(
            {
                 splits.next().unwrap().parse::<$t>().unwrap()
            },
        )*)
    }}
}

fn is_palindrome(s: &str) -> bool {
    let v: Vec<char> = s.chars().collect();
    for i in 0..(s.len() / 2) as usize {
        if v[i] != v[s.len() - i - 1] {
            return false;
        }
    }

    return true;
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (a, b) = input!(usize, usize);

    let mut cnt = 0;
    for n in a..(b+1) {
        let s = &(n.to_string());
        if is_palindrome(s) {
            cnt += 1
        }
    }

        // let n = (a..(b+1)).map(|s| &(s.to_string())).filter(is_palindrome).len();

    println!("{}", cnt);
}

fn main() {
    solve();
}


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


#define li          long long int
#define uli         unsigned long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    li k,x;
    cin>>k>>x;
    cout<<(500*k>=x?"Yes":"No")<<endl;

    return 0;
}


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

int H,W,K;
int ans = 0x6FFFFF,tot[519];
bool s[19][1009],DGLGN[519];
bool cut[19];
int dp[519][1009],remain[519][1009][10];//remain[i][j][k] means status i, column j, group k remains k blocks;
struct group{int l[10],r[10];} grp[519];

void Transfer(int a)
{
	int cnt = 0,x = a;
	for(int i = 0;i<H;i++)grp[a].l[i] = grp[a].r[i] = 0;
	grp[a].l[0] = 1;
	for(int i = 1;x;i++)
	{
		cut[i] = x&1;
		if(cut[i])
		{
			grp[a].l[cnt+1] = i+1;
			grp[a].r[cnt] = i;
			cnt++;
		}
		x >>= 1;
	}
	//cout << cnt << endl;//
	grp[a].r[cnt] = H;
	//cout << a << ": ";//
	//for(int i = 0;i<H;i++)cout << grp[a].l[i] << "-" << grp[a].r[i] << "; ";//
	//cout << endl;//
	tot[a] = cnt;
}

int main()
{
	cin >> H >> W >> K;
	for(int x = 0;x<(1<<(H-1));x++)
	{
		Transfer(x);
		DGLGN[x] = true;
	}
	for(int i = 1;i<=H;i++)
	{
		string aaa;
		cin >> aaa;
		for(int j = 1;j<=W;j++)s[i][j] = aaa[j-1]-'0';
		//for(int j = 1;j<=W;j++)cout << s[i][j];//
		//cout << endl;//
	}
	for(int j = 1;j<=W;j++)//DP column j;
	{
		for(int i = 0;i<(1<<(H-1));i++)
		{
			bool ok = true;
			for(int k = 0;k<H;k++)
			{
				remain[i][j][k] = remain[i][j-1][k];
				for(int r = grp[i].l[k];r<=grp[i].r[k];r++)remain[i][j][k] += s[r][j];
				if(remain[i][j][k]>K){ok = false;break;}
			}
			if(ok==false)
			{
				for(int k = 0;k<H;k++)
				{
					remain[i][j][k] = 0;
					for(int r = grp[i].l[k];r<=grp[i].r[k];r++)remain[i][j][k] += s[r][j];
					if(remain[i][j][k]>K)DGLGN[i] = false;//Not OK!!!
				}
				dp[i][j] = dp[i][j-1]+1;
			}
			else dp[i][j] = dp[i][j-1];
		}
	}
	//cout << remain[0][3][0] << endl;//
	/*for(int i = 0;i<(1<<(H-1));i++)//
	{
		cout << i << ": \n";
		for(int k = 0;k<H;k++)
		{
			
			for(int j = 1;j<=W;j++)cout << remain[i][j][k] << " ";
			cout << endl;
		}
		cout << endl;
	}*/
	for(int i = 0;i<(1<<(H-1));i++)
	{
		//cout << i << " " << dp[i][W] << endl;//
		//cout << i << "-" << DGLGN[i] << " " << dp[i][W] << endl;
		if(DGLGN[i]==false)continue;
		ans = min(ans,dp[i][W]+tot[i]);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 22784
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
	int num,a=0,b=0,ab=0,o=0;
	char name[1024];
	while(scanf("%d,%s", &num, name) != EOF){
		string s(name);
		if(s=="A")++a;
		else if(s=="B")++b;
		else if(s=="AB")++ab;
		else if(s=="O")++o;
	}
	cout << a << "\n";
	cout << b << "\n";
	cout << ab << "\n";
	cout << o << "\n";
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	char s[100], t[100]; cin >> s >> t;
	ll s_len = 0;
	ll t_len = 0;

	while (s[s_len++]);
	while (t[t_len++]);
	s_len--; t_len--;
	sort(s, s + s_len);
	sort(t, t + t_len);
	reverse(t, t + t_len);

	ll i = 0;
	while (s[i]) {
		if (s[i] != t[i]) {
			break;
		}
		i++;
	}
	cout << ((s[i] < t[i]) ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
//#include <string.h>

int main(void){
  
  int n,k;
  int temp,sum=0;
  int p[1001];
  //int count = 0;
  scanf("%d %d", &n, &k);
  
  for(int i=1;i<n+1;i++){
    scanf("%d", &p[i]);
  }
  
  for(int i=1;i<n+1;i++){
    for(int j=n;j>i;j--){      
    if(p[i]>p[j]){
      temp = p[i];
      p[i] = p[j];
      p[j] = temp;
    }
    }
  }

    for(int i=1;i<k+1; i++){
      sum = p[i]+sum;
    }
    
  
  printf("%d", sum);
    
    
  return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=(ll)1e9+7;
ll dp[2][100005];
vector<vector<int>> v(100005);
void solve(ll x,ll k,ll pre){
  ll ans=1;
  if(dp[k][x]!=-1)return ;
  for(auto kk:v[x]){
    if(kk!=pre){
      solve(kk,0ll,x);
      ll tmp=dp[0][kk];
      if(k==0){
        solve(kk,1ll,x);
        tmp+=dp[1][kk];  
      }
      (ans*=tmp)%=mod;
    }
  }
  dp[k][x]=ans;
}  
int main(){
  ll i,n,x,y;
  cin>>n;
  for(i=1;i<n;i++){
    cin>>x>>y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  memset(dp,-1,sizeof(dp));
  solve(1,0,0); solve(1,1,0);
  cout<<(dp[0][1]+dp[1][1])%mod;
}

Measured memory_bytes: 14208
using System;
using System.Linq;
using System.Collections.Generic;
using System.Runtime.InteropServices;

class P
{
    static void Main()
    {
        int[] input = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        int sx = input[0];
        int sy = input[1];
        int tx = input[2];
        int ty = input[3];

        string res = "";

        for (int i = sx; i < tx; i++)
        {
            res += "R";
        }
        for (int i = sy; i < ty; i++)
        {
            res += "U";
        }
        for (int i = tx; i > sx; i--)
        {
            res += "L";
        }
        for (int i = ty; i > sy; i--)
        {
            res += "D";
        }

        res += "D";

        for (int i = sx; i < tx + 1; i++)
        {
            res += "R";
        }
        for (int i = sy - 1; i < ty; i++)
        {
            res += "U";
        }

        res += "L";
        res += "U";

        for (int i = tx; i > sx - 1; i--)
        {
            res += "L";
        }
        for (int i = ty + 1; i > sy; i--)
        {
            res += "D";
        }

        res += "R";
        Console.WriteLine(res);
    }
}



Measured memory_bytes: 35028
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 22 15:04:33 2020

@author: NEC-PCuser
"""

N, X, T = map(int, input().split())

ans = 0
kosu = 0

while True:
	kosu += X
	ans += T
	if kosu >= N:
		break

print(ans)

Measured memory_bytes: 9156
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0
#define MAX 55

int H,W;
typedef struct{
  int x;
  int y;
}dir;
dir d[4]={{0,1},{1,0},{-1,0},{0,-1}};

typedef struct{
  int x;
  int y;
  int d;
}cell;
cell que[MAX*MAX];
int head=0,tail=0;
cell go(cell p,int i){
  cell q;
  q.x=p.x+d[i].x;
  q.y=p.y+d[i].y;
  q.d=p.d+1;
  return q;
}
void enque(cell q){
  que[tail++]=q;
}
cell deque(){
  return que[head++];
}
int searched[MAX][MAX]={};

int main(){
  scanf("%d%d",&H,&W);
  int i,score=0;
  char g[MAX+2][MAX+3];
  for(i=0;i<=W+1;i++) g[0][i]=g[H+1][i]='#';
  for(i=1;i<=H;i++){
    g[i][0]='#';
    scanf(" %s",g[i]+1);
    g[i][W+1]='#';
    int j;
    for(j=1;j<=W;j++){
      if(g[i][j]=='.')score++;
    }
  }
  if(df){
    int j;
      printf("\n");
    for(i=0;i<=H+1;i++){
      for(j=0;j<=W+1;j++)
	printf("%c",g[i][j]);
      printf("\n");
    }
  }
  enque((cell){1,1,1});
  while(head-tail){
    cell p=deque();
    for(i=0;i<4;i++){
      cell q=go(p,i);
      if(q.x==H&&q.y==W){
	printf("%d",score-q.d);
	return 0;
      }
      if(g[q.x][q.y]=='#')continue;
      g[q.x][q.y]='#';
      enque(q);
      if(df && tail%20==0){
	int j;
	printf("\n");
	for(i=0;i<=H+1;i++){
	  for(j=0;j<=W+1;j++)
	    printf("%c",g[i][j]);
	  printf("\n");
	}
      }
      
    }
  }
  

  printf("-1");
  return 0;
}

/// confirm df==0 ///


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	string s1, s2;
	cin >> s1 >> s2;
	long long int min = 0;
	for (long long int i = 0; i < s1.size(); i++) {
		if (s1[i] != s2[i]) min++;
	}
	cout << min;
	return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

int main() {
    int N;
    int P[200005];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> P[i];
    }
    int minv = INF;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (minv >= P[i]) {
            cnt++;
            minv = min(minv, P[i]);
        }
    }
    cout << cnt << endl;
    return (0);
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
   int n;
   int x[3];
   cin >> n;
   
   
   for(int i=0;i<3;i++)
   {
       x[i]=n%10;
       n=n/10;
       if(x[i]==1){x[i]=9;}else{x[i]=1;}
       
   }
   for(int i=2;i>=0;i--){cout << x[i];}
   cout << endl; 
   
   return 0;
}

Measured memory_bytes: 256
a,b=map(int,input().split())
ans=0
if a==b:
  print(0)
  exit()  
if b>0:
  if abs(a)<abs(b):
    if a<0:
      ans+=1
      ans+=b+a  
    else:
      ans+=b-a  
  else:
    if a<0:
      ans+=abs(a)-b+1
    else:
      ans+=a-b+2
else:
  if abs(a)<abs(b):
    if a<0:  
      ans+=2
      ans+=a-b
    else:
      ans+=abs(b)-a
      ans+=1 
  else:
    if a<0:
      ans+=b-a
    else:
      ans+=a+b+1
print(ans) 

Measured memory_bytes: 3064
#intの場合
N = int(input()) #ここで標準入力

#String型にキャスト
moji= str(N)[-1]

if moji in['2','4','5','7','9']:
    print('hon')
elif moji in['0','1','6','8']:
    print('pon')
elif moji == '3':
    print('bon')

Measured memory_bytes: 9176
#include <stdio.h>
int main(){
    long h;
    int n,i,a[1000000];
   
    scanf("%d%d",&h,&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(i=0;i<n;i++)
        h-=a[i];
    
    if(h<=0)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1L << 30
#define long long long
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

long L;


int main(){
	cin >> L;
	double XX = L/3.0;
	double max = 0.0;
	//cout << "XX: " << XX << endl;
	double ZZ = L - (2*XX );
	cout << fixed;
	cout << setprecision(6) << XX*XX*ZZ << endl;
	//cout << "XX" << XX << endl;
	/*
	for (long i = 1; i<=XX; i+=1 ){
		
		for (long j = i; j<=XX ;j+=1){
			double k = L - i - j;
			chmax(max, i*j*k);
		}
		
	}
	

	cout << fixed;
	cout << setprecision(6) << max << endl;
	*/
	
}

Measured memory_bytes: 256
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0]
for i in range(1, n):
  tmp = float('inf')
  for j in range(k):
    if i-j > 0:
      tmp = min(tmp, dp[-1-j]+abs(h[i]-h[i-1-j]))
  dp.append(tmp)
print(dp[-1])

Measured memory_bytes: 82880
import sys
def decode(s):
    x=""
    for c in s:
        if c in " .":
            x+=c
        else:
            x+=chr(ord(c)+1)
    return x.replace(chr(ord("z")+1),"a")

for s in sys.stdin.readlines():
    for i in xrange(ord("z")-ord("a")+1):
        if "the" in s or "that" in s or "this" in s:
            print s[:-1]
            break
        s=decode(s)

Measured memory_bytes: 4216
#include <stdio.h>
#include <algorithm>
#include <tuple>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int s = 1 << 17;
ll stree[s*2], lazy[s*2];
void init() {
	for (int i = 0; i < 2 * s; i++)
		stree[i] = lazy[i] = 1e18;
}
void forward(int x) {
	stree[x * 2 + 1] = min(stree[x * 2 + 1], lazy[x]);
	stree[x * 2 + 2] = min(stree[x * 2 + 2], lazy[x]);
	lazy[x * 2 + 1] = min(lazy[x * 2 + 1], lazy[x]);
	lazy[x * 2 + 2] = min(lazy[x * 2 + 2], lazy[x]);
	lazy[x] = 1e18;
	stree[x] = min(stree[x * 2 + 1], stree[x * 2 + 2]);
}
ll rmin(int l, int r, int low = 0, int upp = s, int x = 0) {
	if (r <= low || upp <= l)
		return 1e18;
	if (l <= low && upp <= r)
		return min(stree[x], lazy[x]);
	forward(x);
	int cen = (low + upp) / 2;
	ll lv = rmin(l, r, low, cen, x * 2 + 1);
	ll rv = rmin(l, r, cen, upp, x * 2 + 2);
	return min(lv, rv);
}
void upd8(int l, int r, ll val, int low = 0, int upp = s, int x = 0) {
	if (r <= low || upp <= l)
		return;
	if (l <= low && upp <= r) {
		lazy[x] = min(lazy[x], val);
		stree[x] = min(stree[x], lazy[x]);
		return;
	}
	int cen = (low + upp) / 2;
	upd8(l, r, val, low, cen, x * 2 + 1);
	upd8(l, r, val, cen, upp, x * 2 + 2);
	stree[x] = min(stree[x * 2 + 1], stree[x * 2 + 2]);
}

using e = tuple<ll, ll, ll> ;
int n, m;
e ed[100010];
int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++) {
		int l, r, c;
		scanf("%d %d %d", &l, &r, &c);
		ed[i] = e(l, r, c);
	}
	sort(ed, ed + m);
	init();
	upd8(1, 2, 0);
	for (int i = 0; i < m; i++) {
		int l, r, c;
		tie(l, r, c) = ed[i];

		ll base = rmin(l, r + 1);
		upd8(l, r + 1, base + c);
	}
	ll r = rmin(n, n + 1);
	printf("%lld\n", r != 1e18 ? r : -1);
}

Measured memory_bytes: 6656
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> num = new ArrayList<Integer>();
		ArrayList<String> param = new ArrayList<String>();
		int system = 0; // 文字の空白区切り 0:ON 1:OFF

		while (sc.hasNext()) {
			if (sc.hasNextInt()) {
				num.add(sc.nextInt());
			} else {
				if (system == 0)
					param.add(sc.next());
				if (system == 1)
					param.add(sc.nextLine());
			}
		}
		Method(num, param);
	}

	static void Method(ArrayList<Integer> num, ArrayList<String> param) {
		
		Collections.sort(param);
		for(String mozi: param){
			System.out.print(mozi);
		}
		System.out.println();
	}
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  
  int ans = 0;
  int nxt = 1;
  rep(i,n) {
    if (a[i] != nxt) ans++;
    else nxt++;
  }

  cout << (ans == n ? -1 : ans) << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <stdio.h>
#include <list>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <memory.h>
#include <utility>
#include <cctype>
#include <complex>
#include <fstream>
#include <sstream>
#include <climits>
using namespace std;

#define ll long long
#define mod 1000000007
#define infinity (ll)1e8
#define epsilon 1e-6

#define pll pair<ll, ll>
#define pdd pair<double, double>
#define pii pair<int,int>
#define MP make_pair

#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(ll i = (b) - 1; i >= a; --i)
#define REPEAT(n) FOR(counter1488, 0, (n))

#define vi vector<int>
#define vvi vector<vi>
#define ALL(V) V.begin(), V.end()

int main()
{
	int n; cin >> n;
	
	vector<int> a(n);
	FOR(i, 0, n)
		cin >> a[i];

	int ind = 0;
	sort(ALL(a));
	vector<ll> ch_sum(n);
	ch_sum[0] = a[0];
	FOR(i, 1, n)
		ch_sum[i] = ch_sum[i - 1] + a[i];

	RFOR(i, n, 1)
	{
		if (a[i] > 2 * ch_sum[i - 1])
		{
			ind = i;
			break;
		}
	}
	cout << n - ind;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#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 all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;
typedef long long ll;

const int MOD = 1e9+7;
const int INF = 1e9;
double dp[3005][3005] = {};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    vector<double> p(N);
    rep(i,N)cin>>p[i];

    dp[0][0] = 1;
    rep(i,N)rep(j,N){
        dp[i+1][j+1] += dp[i][j] * p[i];
        dp[i+1][j] += dp[i][j] * (double)(1-p[i]);
    }
    double ans = 0;
    for(int j = (N+1)/2; j <= N; ++j){
        ans += dp[N][j];
    }
    cout<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 70656
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct Node {
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

Node *find(Node *u,int k){
	while(u != NIL && k != u->key){
		if(k < u->key) u = u->left;
		else u = u->right;
	}
	return u;
}

void insert(int k)
{
	Node *y = NIL;
	Node *x = root;
	Node *z;
	
	z = (Node *)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	
	while(x != NIL)
	{
		y = x;
		if(z->key < x->key){
			x = x->left;
		} else {
			x = x->right;
		}
	}
	z->parent = y;
	if(y == NIL){
		root = z;
	} else {
		if(z->key < y->key){
			y->left = z;
		} else {
			y->right = z;
		}
	}
}

void inorder(Node *u)
{
	if(u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}

void preorder(Node *u)
{
	if(u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}

int main()
{
	int n,i,x;
	string com;
	
	scanf("%d",&n);
	
	for(i = 0; i < n; i++)
	{
		cin >> com;
		if(com[0] == 'f')
		{
			scanf("%d",&x);
			Node *t = find(root,x);
			if(t != NIL) printf("yes\n");
			else printf("no\n");
		} else if(com == "insert"){
			scanf("%d",&x);
			insert(x);
		} else if(com == "print"){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
	
	return 0;
}


Measured memory_bytes: 21960
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; using ll = long long; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int A, B;
    cin >> A >> B;
    write(A * B);
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int x,y,n;
int X,Y;
string s,t;
int main(void){
	cin>>y>>x>>n;
	cin>>Y>>X;
	cin>>s>>t;
	//right
	int k=X;
	for(int i=0;i<n;i++){
		if(s[i]=='R'){
			k++;
			if(k>x){
				cout<<"NO"<<endl;
				return 0;
			}
		}
		if(t[i]=='L'&&k>1){
			k--;
		}
		//cout<<k<<endl;
	}
	//left
	k=X;
	for(int i=0;i<n;i++){
		if(s[i]=='L'){
			k--;
			if(k<=0){
				cout<<"NO"<<endl;
				return 0;
			}
		}
		if(t[i]=='R'&&k<x){
			k++;
		}
	}
	//down
	k=Y;
	for(int i=0;i<n;i++){
		if(s[i]=='D'){
			k++;
			if(k>y){
				cout<<"NO"<<endl;
				return 0;
			}
		}
		if(t[i]=='U'&&k>1){
			k--;
		}
	}
	//up
	k=Y;
	for(int i=0;i<n;i++){
		if(s[i]=='U'){
			k--;
			if(k<=0){
				cout<<"NO"<<endl;
				return 0;
			}
		}
		if(t[i]=='D'&&k<y){
			k++;
		}
	}
	cout<<"YES"<<endl;
	
}


Measured memory_bytes: 776
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
class Program
{
	static void Main(string[] args)
	{
		string S = Console.ReadLine();
		List<char> list = new List<char>();
		for (int i = 0; i < 4; i++)
		{
			list.Add(S[i]);
		}
		list.Sort();
		if (list[0] == list[1] && list[2] == list[3] && list[0]!=list[3])
		{
			Console.WriteLine("Yes");

		}
		else { Console.WriteLine("No"); }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <stack>
using namespace std;
char a[200];
int n;
stack<int> s;
int main(){
    string b;
    unsigned long long k;
    cin >> b >> k;
    n = b.length();
    for(int i = 0;i<b.length();i++){
        a[i] = b.at(i);
      //cout << a[i] << endl;
    }
    int count = 0;
  	int j = 0;
  	int c[100] = {};
    for(int i = 0;i<b.length() - 1;i++){
        /*if(i == s.length()){
            if(a[i] == a[0]){
                count++;
                s.push(count);
                count = 0;
            }else{
                s.push(count);
                count = 0;
            }
        }else{*/
            if(a[i] == a[i+1]){
              
                count++;
                //continue;
            }else{
              //cout << count << endl;
                c[j] = count;
              	j++;
                count = 0;
            }
        //}
    }
  
    c[j] = count;
    unsigned long long ans = 0;
    for(int i = 0;i<100;i++){
      	//cout << c[i] << endl;
        if (c[i] == 0){
            //s.pop();
            continue;
        }
        ans += (c[i]+ 1) / 2;
        //s.pop();
    }
  	
    ans *= k;
  	if(j == 0){
      if(c[0] % 2 == 0){
        ans = ((c[0]+1)*2) / 2 * (k/2) + (k%2) * ((c[0]+1) /2);
      }
    }else{
    if (c[0] % 2 == 0 && c[j] % 2 == 0 && a[0] == a[n-1]){
      ans += k-1;
    }}
    cout << ans << endl;
    

}


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

int main(void) {
   long long dp[10010];
   int n, m;
   int v, w, k=0, sum=0;
   cin >> n >> m;
   
   dp[0] = 0;
   for(int i=1; i<=10000; i++) dp[i] = 1000000010;
   
   for (int j = 0; j < n; j++){
       cin >> v >> w;
       sum += v;
       for(int i=sum; i>=v; i--){
       dp[i] = min(dp[i], dp[i-v]+w);
       }
   }
   
   for(int i=sum; i>=1; i--){
       if(dp[i] <= m){
          k = i;    break;
       }
   }
   
   cout << k << endl;

   return 0;
}


Measured memory_bytes: 3176
from collections import deque
n=int(input())
A=list(map(int,input().split()))
A.sort()
A.reverse()
conf=[A[0]]
ans=0
con=deque(conf)
A.pop(0)


for elem in A:
    ans+=con.popleft()
    
    for _ in range(2):
        con.append(elem)

print(ans)

Measured memory_bytes: 32296
//#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
using namespace std;
typedef long long ll;

#define INF 1000000000000
#define MOD 10000007
//#define int long long
#define pb push_back

void YesNo(bool b) { b ? cout << "Yes" << endl : cout << "No" << endl; return; }
void YESNO(bool b) { b ? cout << "YES" << endl : cout << "NO" << endl; return; }
void yesno(bool b) { b ? cout << "yes" << endl : cout << "no" << endl; return; }

int main() {
    int a;
	for (int i = 0; i < 5; i++)
	{
		cin >> a;
		if (a==0)
		{
			cout << i + 1 << endl;
		}
	}
}

Measured memory_bytes: 3628