akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;

int main(){
  int n, x;
  cin >> n >> x;
  vector<int> v(n);
  rep(i,n) cin >> v[i];

  int min = 1e5;
  int sum = 0;
  rep(i,n){
    sum += v[i];
    if (v[i] < min) min = v[i];
  }

  cout << n + (x - sum) / min << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{
    int N,T;
    cin >> N >> T;
    
    vi A(N);
    in(N,A);
    
    
    
    reverse(all(A));
    int maxA = 0;
    int maxd = 0;
    rep(i,N){
        maxA = max(maxA,A[i]);
        maxd = max(maxd, maxA-A[i]);
    }
    maxA = 0;
    int max_a = 0,min_a = 0;
    map<int,int> m;
    rep(i,N){
        m[A[i]]++;
        maxA = max(maxA,A[i]);
        if(maxA-A[i] == maxd){
            min_a++;
            max_a += m[maxA];
            m[maxA] = 0;
        }
    }
    
    cout << max(max_a,min_a) << endl;
    
    
    
    

    return 0;
}


Measured memory_bytes: 5376
N,M=map(int,input().split())
xyz=[list(map(int,input().split())) for _ in range(N)]

ans=-1
for a in 1,-1:
  for b in 1,-1:
    for c in 1,-1:
      S=sorted(map(lambda x:x[0]*a+x[1]*b+x[2]*c,xyz),reverse=True)
      ans=max(ans,sum(S[:M]))
      
print(ans)

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

int main()
{
  int N;
  cin >> N;
  int s[N] = {};
  for (auto & _s : s)
    cin >> _s;
  auto sum = accumulate(s, s + N, 0);
  if (0 != sum%10)
  {
    cout << sum;
    return 0;
  }
  sort(s, s + N);
  for (auto & _s : s)
  {
    if (0 != _s%10)
    {
      cout << sum - _s;
      return 0;
    }
  }
  cout << 0;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>

using namespace std;

const ll N = 3e5+100;
const ll MOD = 1e9+7;

int main()
{

	ll n,k;
	cin>>n>>k;
	ll h[n+1];
	for(int i =1;i<=n;i++)cin>>h[i];

	if(k>=n)return cout<<"0\n",0;
	sort(h+1,h+n+1);
	reverse(h+1,h+n+1);ll ans=0;
	for(int i =k+1;i<=n;i++){
		ans += h[i];
	}
	cout<<ans<<"\n";

	return 0;
	
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N; cin >> N;
  vector<int> b(N); REP(i, N) cin >> b[i];
  vector<int> a; bool flag = false;
  for(int i = b.size() - 1; i >= 0; --i) {
    if(i + 1 == b[i]) {
      a.push_back(b[i]);
      b.erase(b.begin() + i);
      i = b.size();
    }
    if(b.size() != 0 && i == 0) {
      flag = true;
    }
  }
  reverse(all(a));
  if(flag) cout << -1 << endl;
  else REP(i, a.size()) cout << a[i] << endl;
}


Measured memory_bytes: 3632
N=io.read("n")
Y=io.read("n")
local x=-1
local y=-1
local z=-1
local I=Y//10000
local J=Y//5000
for i=0,I do
  for j=0,J do
    if i+j<=N and i*10000+j*5000+(N-i-j)*1000==Y then
      x=i
      y=j
      z=N-i-j
      break
    end
  end
end
print(string.format("%d %d %d",x,y,z))
      

Measured memory_bytes: 888
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
AB = [LIST() for _ in range(N)]

AB.sort(key=lambda x:x[1])

sum_time = 0
for A, B in AB:
	sum_time += A
	if sum_time <= B:  # 間に合う
		continue
	else:
		print("No")
		break
else:
	print("Yes")


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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n){
        cin >> a[i];
    }
    ll out = a[0];
    for (auto ai: a){
        if (ai == 0) out = 0;
    }
    if (out != 0){
        for (int i = 1; i < n; i++){
            if (a[i] <= upper/out){
                out *= a[i];
            }
            else{
                out = upper + 1;
                break;
            }
        }
    }
    if (out - 1 == upper) cout << -1 << endl;
    else cout << out << endl;
    return 0;
}   


Measured memory_bytes: 3948
s = list(input())

out = 0

if len(s) % 2 != 0:
    print("No")
else:
    for i in range(0, len(s), 2):
        if s[i] == 'h' and s[i+1] == 'i':
            continue
        else:
            out = 1

    if out:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 61908
N=int(input())
h=list(map(int,input().split()))
a=[0]*N
for j in range(1,N):
    if j==1:
        a[1]=a[0]+abs(h[1]-h[0])
    else:
        a[j]=min(a[j-1]+abs(h[j]-h[j-1]),a[j-2]+abs(h[j]-h[j-2]))
print(a[-1])

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

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }


#define int long long
const int INF = 1001001001;


int rec(int i, vector<int> &dp, vector<int> &h){
    if(i == 0) return 0;
    if(dp[i] < INF) return dp[i];

    int ans = INF;
    amin(ans, rec(i-1, dp, h) + abs(h[i] - h[i-1]));
    amin(ans, rec(i-2, dp, h) + abs(h[i] - h[i-2]));

    return dp[i] = ans;
}

signed main(){

    int n;cin >> n;
    vector<int> h(n);
    for(int i = 0, i_len = (int)n; i < i_len; ++i) cin >> h[i];

    vector<int> dp(n+1, INF);

    dp[0] = 0;
    dp[1] = (int)abs(h[0] - h[1]);
cout << rec(n-1, dp, h) << endl;
    return 0;
}

Measured memory_bytes: 6528
N, K = map(int, input().split())

F = [0] * N
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        F[a-1] += 1

c = 0
for x in F:
    if x == 0:
        c += 1
print(c)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 

  int main(){
     lint x,k,d;
     cin>>x>>k>>d;
        lint y=abs(x)/d;
        if(x<0)x+=min(y,k)*d;
        else x-=min(y,k)*d;
        k-=min(y,k);
        if(x<0){
            if(k%2==0)cout<<abs(x);
            else if(k%2==1)cout<<abs(x+d);
        }else{
             if(k%2==0)cout<<abs(x);
            else if(k%2==1)cout<<abs(x-d);
        }

    }
      
    
  

Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 9223372036854775807
#define mini 9223372036854775807
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};
ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	ll c=power(a,b/2);
	if(b%2==0)
		return ((c%mod)*(c%mod))%mod;
	else
		return ((((c%mod)*(c%mod))%mod)*a)%mod;
}
int main()
{
	boost
	ll a,b;
	cin>>a>>b;
	ll ans=ceil((b-1)/((a-1)*1.0));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n,a,b; cin >> n >> a >> b;
    ll ret = 0;
    if(abs(a-b) % 2 == 0)ret = abs(a-b)/2;
    else{
        ll t = min(min(a,b)-1, n-max(a,b));
        ret = (abs(a-b)+1)/2 + t;
    }

    cout << ret << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cstring>
#include <math.h>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,a,b;
int main(void){
    cin>>n>>a>>b;
    b=abs(a-b);
    if(b%2==0)cout<<"Alice\n";
    else cout<<"Borys\n";
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

constexpr long long int MOD = 1000000007;
//const int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;

constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

struct Node {
	int y, x, dis, cost;
	Node(const int yy, const int xx, const int d, const int c) {
		y = yy, x = xx, dis = d, cost = c;
		return;
	}
	bool operator<(const Node&n)const {
		return cost > n.cost;
	}
};

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

	cin >> H >> W;
	vector<vector<int>>v(H, vector<int>(W));
	for (auto &i : v)for (auto &j : i)cin >> j;
	vector<vector<vector<int>>>dp(H, vector<vector<int>>(W, vector<int>(H*W, MOD)));
	dp[0][0][0] = 0;
	priority_queue<Node>PQ;
	PQ.push(Node(0, 0, 0, 0));
	int dir[] = { 1,0,-1,0,1 };
	while (!PQ.empty()) {
		auto cn = PQ.top();
		//cout << cn.y << " " << cn.x << " " << cn.dis << " " << cn.cost << endl;
		PQ.pop();
		if (cn.dis == H * W - 1)continue;
		for (int i = 0; i < 4; i++) {
			int ny = cn.y + dir[i];
			int nx = cn.x + dir[i + 1];
			if (ny < 0 || nx < 0 || ny >= H || nx >= W)continue;
			if (dp[ny][nx][cn.dis + 1] > cn.cost + v[ny][nx] * ((cn.dis + 0) * 2 + 1)) {
				dp[ny][nx][cn.dis + 1] = cn.cost + v[ny][nx] * ((cn.dis + 0) * 2 + 1);
				PQ.push(Node(ny, nx, cn.dis + 1, dp[ny][nx][cn.dis + 1]));
			}
		}
	}
	int ans = MOD;
	for (int i = 0; i < H*W; i++)ans = min(ans, dp.back().back()[i]);
	cout << ans << endl;
}


Measured memory_bytes: 10132
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)
#pragma GCC optimize("O3")
#pragma GCC target("bmi,bmi2,lzcnt")
// 1 - indexed
template <typename T>
struct BIT
{
   vector<T> bit;

   BIT(int sz) : bit(sz + 1, 0) {}

   // sum of [1, k]
   T sum(int k)
   {
      T res = 0;
      for (int x = k; x > 0; x -= x & -x)
         res += bit[x];
      return res;
   }

   void add(int k, T w)
   {
      for (int x = k; x < bit.size(); x += x & -x)
         bit[x] += w;
   }

   // sum of [x, y)
   T getSum(int x, int y)
   {
      return sum(y - 1) - sum(x - 1);
   }

   // find an index i s.t. a[1] + a[2] + ⋯ + a[x] ≧ w
   T lower_bound(T w)
   {
      if (w <= 0)
         return 0;

      T x = 0;
      int p = 1, N = bit.size();

      while (2 * p <= N)
         p *= 2;

      for (T k = p; k > 0; k /= 2)
      {
         if (x + k <= N && bit[x + k] < w)
         {
            w -= bit[x + k];
            x += k;
         }
      }

      return x + 1;
   }
};

int main()
{
   fast();

   int N, Q;
   cin >> N >> Q;
   vector<int> c(N + 1);
   for (int i = 0; i < N; i++)
      cin >> c[i + 1];

   vector<vector<pair<int, int>>> queries(N + 1, vector<pair<int, int>>());

   for (int i = 0, l, r; i < Q; i++)
   {
      cin >> l >> r;
      queries[l].emplace_back(r, i);
   }

   vector<priority_queue<int, vector<int>, greater<int>>> pos(N + 1);

   for (int i = 1; i <= N; i++)
      pos[c[i]].push(i);

   BIT<int> bit(N);

   for (int i = 1; i <= N; i++)
   {
      if (pos[i].empty())
         continue;
      bit.add(pos[i].top(), 1);
      pos[i].pop();
   }

   vector<int> ans(Q);

   for (int l = 1; l <= N; l++)
   {
      for (auto q : queries[l])
      { // 左端がlのクエリ
         int R = q.first + 1, ind = q.second;
         ans[ind] = bit.getSum(l, R);
      }

      if (pos[c[l]].empty())
         continue;

      int nxt = pos[c[l]].top();
      pos[c[l]].pop();
      bit.add(nxt, 1);
   }

   for (int i = 0; i < Q; i++)
      cout << ans[i] << "\n";
}

Measured memory_bytes: 62580
#include<iostream>
using namespace std;
int main() {
    int n, m, xx, yy;
    cin >> n >> m >> xx >> yy;
    int x[101];
    int maxx = -100;
    for (int i = 0; i < n; ++i) {
        cin >> x[i];
        if (maxx < x[i]) {
            maxx = x[i];
        }
    }
    int y[101];
    int miny = 100;
    for (int i = 0; i < m; ++i) {
        cin >> y[i];
        if (miny > y[i]) {
            miny = y[i];
        }
    }
    for (int z = xx + 1; z <= yy; ++z) {
        if (maxx < z && miny >= z) {
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
    return 0;
}


Measured memory_bytes: 256
let
  input = split(readline())
  seconds::Int = parse(Int, input[1])
  biscuits::Int = parse(Int, input[2])
  time::Float64 = parse(Int, input[3]) + 0.5
  progress_time::Int = seconds
  created_biscuits::Int = 0

  while progress_time ≤ time
    created_biscuits += biscuits
    progress_time += seconds
  end

  println(created_biscuits)
end  


Measured memory_bytes: 110080
#include <iomanip>
#include <iostream>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int N, Q;
string S;
vector<char> T;
vector<char> D;

bool isOut(int mid, bool zero) {
  int pos = mid;
  bool out = false;
  rep(i, Q) {
    if (S[pos] == T[i]) {
      pos += (D[i] == 'L') ? -1 : +1;
    }
    if (zero) {
      if (pos < 0) {
        out = true;
        break;
      }
    } else {
      if (N <= pos) {
        out = true;
        break;
      }
    }
  }
  return out;
}

int main(void) {
  ios::sync_with_stdio(false);
  cin >> N >> Q;
  cin >> S;
  T.resize(Q);
  D.resize(Q);
  rep(i, Q) { cin >> T[i] >> D[i]; }

  int left = 0;
  int right = min(Q, N);
  while (left < right) {
    int mid = left + (right - left) / 2;
    if (isOut(mid, true)) {
      left = mid + 1;
    } else {
      right = mid;
    }
  }
  int answer = N;
  answer -= left;

  left = N - min(Q, N);
  right = N;
  while (left < right) {
    int mid = left + (right - left) / 2;
    if (isOut(mid, false)) {
      right = mid;
    } else {
      left = mid + 1;
    }
  }
  answer -= (N - left);
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3900
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int n;
  cin >> n;
  int t=0,x=0,y=0;
  rep(i,n){
    int nt,nx,ny;
    cin >> nt >> nx >> ny;
    int d = abs(nx - x) + abs(ny - y);
    if(d % 2 != (nt - t)%2 || d > (nt - t)){
      cout << "No" << endl;
      return 0;
    }
    x = nx;
    y = ny;
    t = nt;
  }
  cout << "Yes" << endl;
}


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

int main()
{
  int n, m;
  cin >> n >> m;
  int a,b;
  int i, j;
  int road[n];
  
  i = 0;
  while(i < n)
  {
    road[i] = 0;
    i++;
  }
  
  i = 0;
  while(i < m)
  {
    cin >> a >> b;
    j = 1;
    while(j <= n)
    {
      if(a == j)
        road[j-1]++;
      if(b == j)
        road[j-1]++;
      j++;
    }
    i++;
  }
  
  j = 0;
  while(j < n)
  {
    cout << road[j] << endl;;
    j++;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
int c[444][4],n;
int num[4][444];
void fd(int*num,int A,int B,int C,int D,int from,int no){
	long long int W = ((((((long long int)A << 10) + B) <<10) + C) <<10) + D;
	for(int i=from+1; i<n; i++){
		num[i] = 0;
		if(i == no)continue;
		int E = c[i][0], F = c[i][1], G = c[i][2], H = c[i][3];
		long long int hash = ((((((long long int)E << 10) + F) <<10) + G) <<10) + H;

		if(hash == W)num[i] ++;
		hash = ((hash & ((1<<30)-1))<<10) + E;
		if(hash == W)num[i] ++;
		hash = ((hash & ((1<<30)-1))<<10) + F;
		if(hash == W)num[i] ++;
		hash = ((hash & ((1<<30)-1))<<10) + G;
		if(hash == W)num[i] ++;
	}
}
long long int add(long long int x,long long int y){
	return x+y;
}
long long int sub(long long int x,long long int y){
	return x-y;
}
long long int mul(long long int x,long long int y){
	return x*y;
}
int calc(int id1,int from){
	int res=0;
	for(int i=from+1; i<n; i++)
		res += num[id1][i];
	return res;
}
int calc(int id1,int id2,int from){
	int res=0;
	for(int i=from+1; i<n; i++)
		res += num[id1][i]*num[id2][i];
	return res;
}
int calc(int id1,int id2,int id3,int from){
	int res=0;
	for(int i=from+1; i<n; i++)
		res += num[id1][i]*num[id2][i]*num[id3][i];
	return res;
}
int calc(int id1,int id2,int id3,int id4,int from){
	int res=0;
	for(int i=from+1; i<n; i++)
		res += num[id1][i]*num[id2][i]*num[id3][i]*num[id4][i];
	return res;
}
int main(){

	scanf("%d",&n);
	for(int i=0; i<n; i++)
		for(int j=0; j<4; j++)
			scanf("%d",&c[i][j]);

	long long int res=0;
	for(int i=0; i<n; i++)
	for(int j=i+1; j<n; j++)
	for(int k=0; k<4; k++){
		int A = c[i][0];
		int B = c[i][1];
		int C = c[i][2];
		int D = c[i][3];
		int E = c[j][k%4];
		int F = c[j][(k+1)%4];
		int G = c[j][(k+2)%4];
		int H = c[j][(k+3)%4];
		fd(num[0], B, E, H, C, i, j);
		fd(num[1], A, D, G, F, i, j);
		fd(num[2], F, E, B, A, i, j);
		fd(num[3], H, G, D, C, i, j);

		long long int A0 = calc(0,i);
		long long int A1 = calc(1,i);
		long long int A2 = calc(2,i);
		long long int A3 = calc(3,i);
		long long int A01 = calc(0,1,i);
		long long int A02 = calc(0,2,i);
		long long int A03 = calc(0,3,i);
		long long int A12 = calc(1,2,i);
		long long int A13 = calc(1,3,i);
		long long int A23 = calc(2,3,i);
		long long int A012 = calc(0,1,2,i);
		long long int A013 = calc(0,1,3,i);
		long long int A023 = calc(0,2,3,i);
		long long int A123 = calc(1,2,3,i);
		long long int A0123 = calc(0,1,2,3,i);

		res = add(res, mul(mul(A0,A1),mul(A2,A3)));
		res = sub(res, mul(mul(A2,A3),A01));
		res = sub(res, mul(mul(A1,A3),A02));
		res = sub(res, mul(mul(A1,A2),A03));
		res = sub(res, mul(mul(A0,A3),A12));
		res = sub(res, mul(mul(A0,A2),A13));
		res = sub(res, mul(mul(A0,A1),A23));
		res = add(res, mul(A01,A23));
		res = add(res, mul(A02,A13));
		res = add(res, mul(A03,A12));
		res = add(res, mul(mul(A0,A123),2));
		res = add(res, mul(mul(A1,A023),2));
		res = add(res, mul(mul(A2,A013),2));
		res = add(res, mul(mul(A3,A012),2));
		res = sub(res, mul(A0123,6));
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);

		while (true) {
			int n = s.nextInt();

			if (n == 0)
				break;

			int[] a = new int[n];
			int max = 0;
			int min = 0;
			int sum = 0;
			int ave = 0;

			for (int t = 0; t < n; t++) {
				a[t] = s.nextInt();
			}

			max = a[0];
			min = a[0];

			for (int i = 0; i < n; i++) {
				if (max <= a[i])
					max = a[i];

				if (min >= a[i])
					min = a[i];

				sum += a[i];
			}

			sum = sum - max - min;
			ave = sum / (n - 2);

			System.out.println(ave);
		}
		s.close();
	}
}

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

long long int  factorial(int n) {
	if (n == 0) {
		return 1L;
	}
	else {
		return n * factorial(n - 1);
	}
}

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

	cout << factorial(n) << endl;

	return 0;
}


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

//int _; 
 
int a,b;
string s,t,u; 

int main()
{
	//for(scanf("%d",&_);_;_--)
	cin >> s >> t >> a >> b >> u;
	if(u == s)
		a--;
	else
		b--;
	cout << a << ' ' << b << endl;
	return 0;
}

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

int main() {
    string a, b;
    cin >> a >> b;
    if (a == b) cout << "EQUAL" << endl;
    else if (a.size() < b.size()) cout << "LESS" << endl;
    else if (a.size() > b.size()) cout << "GREATER" << endl;
    else {
        for (int i = 0; i < a.size(); i++) {
            if (a[i] < b[i]) {
                cout << "LESS" << endl;
                return 0;
            } else if (a[i] > b[i]) {
                cout << "GREATER" << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int x,y;
	while(1){
		cin >>x>>y;
		
		if(x == 0 && y == 0)break;
		if (x>y){
		    cout << y <<" "<< x << endl;
		     
		}else{
		    cout << x <<" "<< y << endl;
		}

	}
	

	return 0;

}
	

Measured memory_bytes: 1160
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val a = IntArray(n)
    val b = IntArray(n)
    val c = IntArray(n-1)
    for(i in 0..n-1) {
        a[i] = scanner.nextInt()
    }
    for(i in 0..n-1) {
        b[i] = scanner.nextInt()
    }
    for(i in 0..n-2) {
        c[i] = scanner.nextInt()
    }
    var sum = 0
    var index = 99
    for(i in 0..n-1){
        sum += b[a[i]-1]
        if(a[i]-1 ===  index) sum += c[a[i]-2]
        index = a[i]
    }
    println(sum)
}

Measured memory_bytes: 31264
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i=0;i<(int)(n);++i)
template <typename T> lint gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> lint lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> inline void chmin(T &a, const T& b){if(a>b)a=b;}
template <typename T> inline void chmax(T &a, const T& b){if(a<b)a=b;}
const int mod = 1e9 + 7;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<lint> vec(n+10);
  vector<bool> valid(n+10, true);
  vec[0] = 1;
  for (int i = 0; i < m; ++i) {
    int a; cin >> a;
    valid[a] = false;
  }
  for (int i = 0; i < n+1; ++i) {
    if (vec[i] > 1e9+7) vec[i] -= 1e9+7;
    
    if (valid[i]) {
      for (int j = 1; j <= 2; ++j) {
        if (i + j < n + 1) {
          vec[i+j] += vec[i];
          if (vec[i+j] > 1e9+7) vec[i+j] -= 1e9 + 7;
        }
      }
    }
  }
  cout << vec[n] << '\n';
}


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

using namespace std;

int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	if (n > long(a)*b || n < a + b - 1) {
		cout << -1 << endl;
		return 0;
	}
	for (int i = b; i; i--)
		cout << i << ' ';
	for (int m = b; --a;) {
		int l = m + (n - m + a - 1) / a;
		for (int i = l; i > m; i--)
			cout << i << ' ';
		m = l;
	}
	cout << endl;
	return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int64 N, P;

int64 powp(int64 a, int64 b){
	if(b == 0) return 1;
	if(b%2) return a*powp(a, b-1);
	int64 ret = powp(a, b/2);
	return ret*ret;
}

int main(void){
	cin >> N >> P;
	if(N == 1){
		cout << P << endl;
		return 0;
	}
	int64 res = 1;
	for(int64 i = 2;i*i <= P;i++){
		int32 cnt = 0;
		while(P%i == 0){
			cnt++;
			P /= i;
		}
		if(cnt >= N) res *= powp(i, cnt/N);
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> prl;
typedef vector<ll> vcl;
typedef map<ll,ll> mapl;
typedef unordered_map<ll,ll> umap;
#define pb push_back
#define all(v) v.begin(), v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

int main() {
    // your code goes here
    ll d,t,s;
    cin >> d >> t >> s;
    if(s*t>=d) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main(){
  int a, b;
  std::cin >> a >> b;
  int ans = 0;
  if(a >= 13){
    ans = b;
  }
  else if(a < 13 && a >= 6){
    ans = b / 2;
  }
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 764
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int 
#define ar array
#define pb push_back
#define fi(a,b) for(int i=a;i<(b);i++)
#define fj(a,b) for(int j=a;j<(b);j++)
#define fk(a,b) for(int k=a;k<(b);k++)
#define lb lower_bound
#define ub upper_bound
//hash base 177013

const int mod=1e9+7;


int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	//ll testcase;
	//cin>>testcase;
	//while(testcase--)
	{
		ll x,k,d;
		cin>>x>>k>>d;
		x=abs(x);
		if(k<=x/d)
		{
			ll ch=min(k,x/d);
			cout<<x-ch*d;
			//cout<<"h\n";
			return 0;
		}
		else
		{
			if((k-x/d)%2==0)
			{
				cout<<x-x/d*d;
				//cout<<"h\n";
			}
			else
			{
				cout<<min(x-x/d*d+d,abs(x-x/d*d-d))<<'\n';
			}
		}
		
		
	}
}


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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(),x.end()
auto& errStream=cerr;
#ifdef LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%"  SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

signed main(){
	int n=read();
	vi a(n);
	REP(i,n){
		a[i]=read();
	}
	int sum=accumulate(ALL(a),int(0));
	for(auto&v:a)
		v*=n;
	pi ans(inf,-1);
	REP(i,n){
		chmin(ans,pi(abs(sum-a[i]),i));
	}
	print(ans.second);
}


Measured memory_bytes: 256
from math import ceil
K=int(input())
A=[int(i) for i in input().split()]
A.reverse()
n_range=[2,2]
for a in A:
  if a*ceil(n_range[0]/a)<=n_range[1]:
    n_range[0]=a*ceil(n_range[0]/a)
  else:
    print(-1)
    exit()
  if a*(n_range[1]//a)>=n_range[0]:
    n_range[1]=a*(n_range[1]//a)+a-1
    
print(n_range[0],n_range[1])
    

Measured memory_bytes: 63984
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,X,Y,Z;
  cin>>N>>X>>Y>>Z;
  
  ll L=X+Y+Z-1;
  ll mask=(1<<L)-1;
  ll forbidden=(1<<(X+Y+Z-1) | 1<<(Y+Z-1) | 1<<(Z-1));
  
  ll DP[N+1][1<<L];
  REP(i,N+1) REP(j,1<<L) DP[i][j]=0;
  DP[0][0]=1;
  
  REP(i,N){
    RREP(j,10){
      REP(k,1<<L){
        ll T=(k<<j)|(1<<(j-1));
        if((forbidden&T)==forbidden) continue;
        DP[i+1][T&mask]+=DP[i][k];
      }
    }
    REP(k,1<<L) DP[i+1][k]%=MOD;
  }
  
  ll ans=1;
  REP(i,N) ans*=10,ans%=MOD;
  REP(k,1<<L) ans-=DP[N][k];
  ans=(ans%MOD+MOD)%MOD;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 24632
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
using MIte = multimap<vector<long>, int>::iterator;

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

	vector<int> vW(N, 0);
	for (int i = 0; i != N; ++i) {
		int w = 0;
		cin >> w;
		vW[i] = w;
	}

	vector<int> vSum(N, 0);
	vSum[0] = vW[0];
	for (int i = 1; i != N; ++i) {
		vSum[i] = vSum[i - 1] + vW[i];
	}

	const int allsum = vSum[N - 1];
	int mindiff = 100000000;
	for (int i = 0; i != N; ++i) {
		int nokori = allsum - vSum[i];
		if (mindiff > abs(nokori - vSum[i])) {
			mindiff = abs(nokori - vSum[i]);
		}
	}

	cout << mindiff << endl;


	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int a[n+1],b[n+1];
  for(int i=1;i<=n;i++){
    cin >> a[i] >> b[i];
  }
  sort(a+1,a+n+1);sort(b+1,b+n+1);
  if(n%2==1){cout << b[(n+1)/2] - a[(n+1)/2] + 1 << endl;return 0;}
  else{
    cout << b[n/2+1]+b[n/2]-a[n/2+1]-a[n/2]+1 << endl;return 0;
  }
}


Measured memory_bytes: 5160
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long ll;
#define rep(i,s,t) for(ll i=s ; i<t ; i++)
typedef pair<ll,ll> P;
const int max_n = 1e5;
const ll mod = 1e9+7;
int main(){
  long double l;  cin >> l;
  long double x = l/3;
  cout << printf("%.6Lf",x*x*x) << endl;
  return 0;
}


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

int main()
{
  int H, W;
  cin >> H >> W;

  vector<vector<char>> S(H + 2, vector<char>(W + 2));

  for (int i = 1; i < H + 1; i++)
  {
    for (int j = 1; j < W + 1; j++)
    {
      cin >> S[i][j];
    }
  }

  for (int i = 1; i < H + 1; i++)
  {
    for (int j = 1; j < W + 1; j++)
    {
      if (S[i][j] == '#')
        cout << '#';
      else
      {
        int result = 0;
        for (int k = i - 1; k < i + 2; k++)
        {
          for (int l = j - 1; l < j + 2; l++)
          {
            if (S[k][l] == '#')
              result++;
          }
        }
        cout << result;
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	long ans, min;
	scanf("%d", &n);
	long r[n];
	for(int i = 0; i < n; i++){
		scanf("%ld", &r[i]);
	}
	ans = r[1] - r[0];
	min = r[0];
	for(int i = 1; i < n; i++){
		if(min > r[i]){
			min = r[i];
		}else{
			long temp = r[i] - min;
			if(ans < temp){
				ans = temp;
			}
		}
	}
	printf("%ld\n", ans);
	return 0;
}

Measured memory_bytes: 2584
#include<bits/stdc++.h>
using namespace std;
#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define ll long long
typedef pair<int, int> P;

int main(){
  int h, w;
  cin >> h >> w;
  string c[h+10];
  rep(i, h) {
    cin >> c[i];
  }
  rep(i, h){
    cout << c[i] << endl;
    cout << c[i] << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int N,A,B;

int main()
{
    int sum=0;
    scanf("%d %d %d",&N,&A,&B);

    for(int i=1;i<=N;i++){
	if(i%10+i/10%10+i/10/10%10+i/10/10/10%10+i/10/10/10/10%10<=B && i%10+i/10%10+i/10/10%10+i/10/10/10%10+i/10/10/10/10%10>=A)
	    sum+=i;
    }


    printf("%d\n",sum);
    return 0;
}



Measured memory_bytes: 128
#include <stdio.h>
#define WMAX 10000

int dp[WMAX+1], deq[WMAX+1], deqv[WMAX+1];

int main(void)
{
  int i, j, a, n, w, value, weight, limit;
  scanf("%d %d", &n, &w);
  for (i = 0; i < n; i++) {
    scanf("%d %d %d", &value, &weight, &limit);
    for (a = 0; a < weight; a++) {
      int s = 0, t = 0;
      for (j = 0; j * weight + a <= w; j++) {
        int val = dp[j*weight+a] - j * value;
        while (s < t && deqv[t-1] <= val) t--;
        deq[t] = j;
        deqv[t++] = val;
        dp[j*weight+a] = deqv[s] + j * value;
        if (j == deq[s] + limit) s++;
      }
    }
  }
  printf("%d\n", dp[w]);
}


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

int n,k,a,b;
string s,t;

int main() {
  cin >> s;
  int cnt=0;
  for(auto c:s){
    if(c=='o') cnt++;
  }
  cout << (15-(int)s.size()+cnt>=8?"YES":"NO") << endl;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BC
import qualified Data.IntMap as M
import Data.List

main = do
  input <- BC.unpack <$> BC.getLine
  let grouped = group . sort $ input
      h = head input
      l = last input
      num = (length input) - 2
  if length grouped == 2
    then putStrLn "Second"
    else if judge h l num then putStrLn "First"
                          else putStrLn "Second"

judge :: Char -> Char -> Int -> Bool
judge h l num
  | h == l    = even num
  | otherwise = odd num


Measured memory_bytes: 19836
#include<iostream>
#include<vector>
#include<string>
#include<stdlib.h>
#include<algorithm>
#include<math.h>
#include<queue>
#include <forward_list>
using namespace std;

int main() {

	double W, H, x, y;

	cin >> W >> H >> x >> y;
	cout << fixed;

	cout << (double)(W * H / 2.0) << " ";

	if (W/2.0==x && H/2.0==y)
		cout << 1;
	else
		cout << 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll,ll>
#define PP pair<P,P>
using namespace std;

int main(){
    int n,k; cin >> n >> k;
    vector<P> sushi;
    rep(i,n){
        ll d,t; cin >> t >> d;
        sushi.push_back(P(d,t));
    }
    sort(all(sushi));
    reverse(all(sushi));

    priority_queue<ll, vector<ll>, greater<ll> > p;
    vector<bool> check(n+1,true);
    ll ans=0;
    ll kind=0;
    ll oishi,neta;

    rep(i,k){
        oishi=sushi[i].first;
        neta=sushi[i].second;
        ans+=oishi;
        if(check[neta]==false){
            p.push(oishi);
            continue;
        }
        kind++;
        check[neta]=false;
    }

    ans+=kind*kind;
    //cout << ans << endl;
    ll tans=ans;
    for(int i=k; i<n; i++){
        oishi=sushi[i].first;
        neta=sushi[i].second;
        if(p.empty()) continue;
        if(check[neta]==false) continue;
        ll mi=p.top();
        ans-=mi;
        ans+=oishi+2*kind+1;
        kind++;
        p.pop();
        check[neta]=false;
        tans=max(ans,tans);
    }
    cout << tans << endl;
return 0;
}


Measured memory_bytes: 2672
import sys
input_data = input()
input_numbers = input_data.split()

if __name__ == '__main__':
    a = int(input_numbers[0])
    b = int(input_numbers[1])
    c = int(input_numbers[2])

    if (a < b) and (b < c) :
        print('Yes')
    else :
        print('No')


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<int,int>;
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF (2e9)
#define EPS (1e-6)
#ifdef LOCAL_TEST
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<endl;}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
#else
#define debug(...)
#endif

void INIT(){
#ifdef LOCAL_TEST
	freopen("D:\\input.in","r",stdin);
	freopen("D:\\output.out","w",stdout);
	freopen("D:\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
}

ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll fpow(ll b,ll p){
	b%=MOD;
	ll ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

ll inv[500010];
ll fac[500010];
void build(int n){
	fac[0]=fac[1]=1;
	For(i,2,n) fac[i]=(i*fac[i-1])%MOD;
	inv[0]=inv[1]=1;
	For(i,2,n) inv[i]=fpow(fac[i],MOD-2);
}

ll C(int n,int m){
	return (fac[n]*inv[m]%MOD)*inv[n-m]%MOD;
}

ll P(int n,int m){
	return fac[n]*inv[n-m]%MOD;
}

int32_t main() {
	INIT();
	//code...
	ll n,m; cin>>n>>m;
	build(m);
	ll ans=0;
	For(i,0,n){
		ll t=((C(n,i)*P(m,i)%MOD)*P(m-i,n-i)%MOD)*P(m-i,n-i)%MOD;
		if(i%2) ans=(ans-t)%MOD;
		else ans=(ans+t)%MOD;
		if(ans<0){
			//debug(i);
		}
	}
	cout<<(ans+MOD)%MOD<<"\n";
	return 0;
}


Measured memory_bytes: 11348
#include <iostream>
#include <string>

using namespace std;

int main() {

   int n;
   cin >> n;

   int point[2]{};

   while (n--) {
      string card[2];
      cin >> card[0] >> card[1];

      if (card[0] > card[1]) {
         point[0] += 3;
      } else if (card[0] < card[1]) {
         point[1] += 3;
      } else {
         ++point[0];
         ++point[1];
      }
   }

   cout << point[0] << " " << point[1] << endl;

   return 0;

}

Measured memory_bytes: 3120
K = int(input())

numlist = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(numlist[K-1])

Measured memory_bytes: 61712
def main():
    s=input()
    t=input()
    n=len(s)

    dic={}
    for i in range(n):
        if s[i] not in dic:
            dic[s[i]]=t[i]
        else:
            if dic[s[i]]!=t[i]:
                print('No')
                exit()
    if len(set(dic.values()))!=len(dic.values()):
        print('No')
    else:
        print('Yes')
if __name__=='__main__':
    main()

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384626433832795

int main() {
	int n;
	cin >> n;
	cout << n*n*n << endl;
}


Measured memory_bytes: 3088
#include<stdio.h>
#include<string>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    long long int w,h,x,y;
    scanf("%lld%lld%lld%lld",&w,&h,&x,&y);
    double ans=(double)w*(double)h/2;
    double hw=(double)w/2;
    double hh=(double)h/2;
    int judge;
    if(hw==(double)x && hh==(double)y)judge=1;
    else judge=0;
    printf("%lf %d\n",ans,judge);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using lint = long long;
using ldouble = long double;

void solve() {
    int n, k;
    std::cin >> n >> k;

    std::vector<int> xs(n);
    for (auto& x : xs) {
        int p;
        std::cin >> p;
        x = p + 1;
    }

    int ans = 0, sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += xs[i];
        if (i - k >= 0) sum -= xs[i - k];
        ans = std::max(ans, sum);
    }

    std::cout << (ans / 2) << (ans % 2 == 0 ? ".0" : ".5") << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

char str[100005];

int main(int argc, char* argv[])
{
    scanf("%s", str);

    long len=strlen(str);
    long i;
    long cnt=0;
    for(i=1; i<len; i++) {
        if(str[i-1]!=str[i]) {
            cnt++;
        }
    }
    printf("%ld\n", cnt);
    return 0;
}



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

int memo[100005];

int main(){
    int n;
    cin >> n;
    int x[n];
    int y[n];
    int z[n];
    for(int i = 0;i < n;i++){
        cin >> x[i] >> y[i] >> z[i];
    }
    for(int i = 1; i < n;i++){
        x[i] = x[i] + max(y[i-1],z[i-1]);
        y[i] = y[i] + max(z[i-1],x[i-1]);
        z[i] = z[i] + max(x[i-1],y[i-1]);
    }
    int m = max(x[n-1],max(y[n-1],z[n-1]));
    cout << m << endl;
    
    return 0;
}

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

int main(void) {
    int N;
    cin >> N;
    int res = 0;
    for (int k = 1; k < N; k++) {
        int q = N / k;

        res += N / k;
        if (!(N % k)) {
            res--;
        }
    }

    cout << res;
}

Measured memory_bytes: 3632