akhauriyash/Code-Regression huggingface dataset:
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

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

  int N, W;
  cin >> N >> W;

  ll w[110] = {};
  ll v[110] = {};
  REP(i, N) {
    cin >> w[i] >> v[i];
  }

  vector<vector<ll>> d = vector<vector<ll>>(4, vector<ll>());
  ll w0 = w[0];
  d[0].push_back(v[0]);
  for (int i = 1; i < N; i++) {
    d[w[i] - w[0]].push_back(v[i]);
  }
  REP(i, 4) {
    sort(d[i].begin(), d[i].end(), greater<ll>());
    // DEBUG(d[i]);
    for (int j = 1; j < d[i].size(); j++) {
      d[i][j] = d[i][j - 1] + d[i][j];
    }
  }

  ll mx = 0;
  REP(i, d[0].size() + 1) {
    REP(j, d[1].size() + 1) {
      REP(k, d[2].size() + 1) {
        REP(l, d[3].size() + 1) {
          ll w = w0 * i + (w0 + 1) * j + (w0 + 2) * k + (w0 + 3) * l;
          // cout << "weight: " << w << endl;
          if (w <= W) {
            ll total = 0;
            if (i > 0) total += d[0][i - 1];
            if (j > 0) total += d[1][j - 1];
            if (k > 0) total += d[2][k - 1];
            if (l > 0) total += d[3][l - 1];
            mx = max(mx, total);
          }
        }
      }
    }
  }

  cout << mx << endl;
  return 0;
}


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

using namespace std;

const int N = 1e5;
vector<int> g[N];
bool del[N];
int cost[N];
int dist[N];

void dfs(int u, int p) {
  for (int v : g[u]) if (v != p && !del[v]) {
    dist[v] = dist[u] + 1 + cost[u];
    dfs(v, u);
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
    d[u]++;
    d[v]++;
  }
  string s;
  cin >> s;

  if (n == 1) {
    cout << (s[0] == 'W') << endl;
    return 0;
  }

  queue<int> q;
  for (int i = 0; i < n; i++) {
    if (d[i] == 1 && s[i] == 'B') {
      q.push(i);
    }
  }
  int ans = (n - 1) * 2;
  while (!q.empty()) {
    int u = q.front(); q.pop();
    del[u] = true;
    dist[u] = -1e9;
    ans -= 2;
    for (int v : g[u]) {
      d[v]--;
      if (d[v] == 1 && s[v] == 'B') {
        q.push(v);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cost[i] = ((s[i] == 'W') + d[i]) % 2 == 0 ? -1 : 1;
  }
  int k = -1;
  for (int i = 0; i < n; i++) {
    if (!del[i]) {
      k = i;
      break;
    }
  }
  if (ans == 0) {
    cout << 1 << endl;
    return 0;
  }
  if (k == -1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if (!del[i]) {
      ans += ((s[i] == 'W') + d[i]) % 2;
    }
  }
  dfs(k, -1);
  int u = -1;
  int mx = -1;
  for (int i = 0; i < n; i++) {
    if (!del[i] && d[i] == 1 && mx < dist[i]) {
      mx = dist[i];
      u = i;
    }
  }
  dist[u] = 0;
  dfs(u, -1);
  mx = -1;
  for (int i = 0; i < n; i++) {
    if (!del[i] && d[i] == 1 && mx < dist[i]) {
      mx = dist[i];
    }
  }
  ans -= mx;
  cout << ans << endl;
}

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

#define fr(i, n)    for(int i=0; i<(int)n; ++i)
#define rfr(i, n)   for(int i=(int)n-1; i>=0; --i)
#define foor(i,a,n) for(int i=a; i<=(int)n; ++i)
#define rfoor(i,n,a)for(int i=(int)n; i>=a; --i)
#define foru(it, v) for(auto it : v)
#define si(n)       scanf("%d", &n)
#define si2(n,m)    scanf("%d%d", &n, &m)
#define si3(n,m,l)  scanf("%d%d%d", &n, &m, &l)
#define sl(n)       scanf("%lld", &n)
#define sl2(n,m)    scanf("%lld%lld", &n, &m)
#define sl3(n,m,l)  scanf("%lld%lld%lld", &n, &m, &l)
#define sd(n)       scanf("%lf", &n)
#define sld(n)      scanf("%Lf", &n)
#define sc(n)       scanf(" %c", &n)
#define sstr(n)     scanf("%s", n)
#define pi(n)       printf("%d\n", n)
#define pis(n)      printf("%d ", n)
#define pi2(n,m)    printf("%d %d\n", n, m)
#define pi3(n,m,l)  printf("%d %d %d\n", n, m, l)
#define pl(n)       printf("%lld\n", n)
#define pls(n)      printf("%lld ", n)
#define pl2(n,m)    printf("%lld %lld\n", n, m)
#define pl3(n,m,l)  printf("%lld %lld %lld\n", n, m, l)
#define pc(n)       printf("%c", n)
#define pstr(n)     printf("%s\n", n)
#define pstr2(n, m) printf("%s %s\n", n, m)
#define ff          first
#define ss          second
#define all(v)      v.begin(), v.end()
#define rall(v)     v.rbegin(), v.rend()
#define sz(v)       (int)v.size()
#define pub         push_back
#define pob         pop_back()
#define mmst(a, n)  memset(a, n, sizeof a);
#define ppcnt(n)    __builtin_popcountll(n);
#define leadingZ(n) __builtin_clz(n)
#define trailingZ(n)__builtin_ctz(n)
#define OO          0x3f3f3f3f
#define OOLL        0x3f3f3f3f3f3f3f3f
#define MOD         1000000007
#define EPS         0.000000001
#define ndl         "\n"
#define fastin      ios::sync_with_stdio(false); cin.tie(nullptr);
#define infile      freopen("input.txt", "r", stdin);
#define outfile     freopen("output.txt", "w", stdout);
#define PNO         printf("NO\n")
#define PYES        printf("YES\n")
#define pno         printf("No\n")
#define pyes        printf("Yes\n")
#define pln         printf("\n")

//#define row         vector<long long>
//#define matrix      vector<row>
//#define ROWS(v)     (v).size()
//#define COLS(v)     (v)[0].size()

#define DBG1(x)     cerr<<#x<<":"<<(x)<<'\n';
#define DBG2(x, y)  cerr<<#x<<":"<<(x)<<"  "<<#y<<":"<<(y)<<'\n';
#define DBG3(x,y,z) cerr<<#x<<":"<<(x)<<"  "<<#y<<":"<<(y)<<"  "<<#z<<":"<<(z)<<'\n';

using namespace std;

typedef long long lld;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vii;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<long long , long long>> vpll;
typedef complex<double> point;

const int N = 1e5 + 9;

int t, id, n, m, x, y, k, c, xx, yy, ans;
//int a[N], f[N], cu[N], b[N];
vii v, adj[N];
bool fl, ok;
lld res, tot, sum;
char ch;
string s, z;
//char s[3][N], z[N];

int main()
{
    //infile;
    //outfile;
    //fastin;
    int a, b;
    si2(a, b);
    if(b == 1) return !pi(0);
    ans = 1;
    b -= a; --a;
    if(b>0) ans += ((b+a-1)/a);
    pi(ans);
    return 0;
}


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

// 前から順に必要水やり回数を減らす
void mizuyari(int kaisu[], int sta, int end) {
  for(int i = sta; i < end; i++) {
    if(kaisu[i] == 0) {
      break;
    }
    kaisu[i] = kaisu[i] - 1;
  }

  return;
}

// 前から順に最初にゼロでない花を見つける
int get_not_zero(int kaisu[], int sta, int end) {
  for(int i = sta; i < end; i++) {
    if(kaisu[i] != 0) {
      return i;
    }
  }
  return end;
}


int main(void)
{
    int n;
  	cin >> n;
	
  	int kaisu[n];
  
  for(int i = 0; i < n; i++) {
    cin >> kaisu[i];
  }	  

  int num = 0;
  int sta = 0;

  while(1) {
    sta = get_not_zero(kaisu, sta, n);
    if(sta == n) {
      break;
    }
    num++;
    mizuyari(kaisu, sta, n);
  }

  cout << num;
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;
const int dy[] = {-1, 0, 1, 0}, dx[] = {0, -1, 0, 1};
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int h, w, k; cin >> h >> w >> k;
	vector<string> in(h);
	int sy, sx;
	rep(i, h){
		cin >> in[i];
		rep(j, w) if(in[i][j] == 'S') sy = i, sx = j;
	}
	set<int> vis;
	queue<pi> q; q.emplace(sy * w + sx, k);
	while(!q.empty()){
		pi cur = q.front(); q.pop();
		int y = cur.first / w, x = cur.first % w, r = cur.second;
		if(vis.count(cur.first)) continue;
		vis.insert(cur.first);
		if(r == 0) continue;
		rep(d, 4){
			int ny = y + dy[d], nx = x + dx[d];
			if(ny < 0 || ny >= h || nx < 0 || nx >= w || in[ny][nx] == '#') continue;
			if(!vis.count(ny * w + nx)) q.emplace(ny * w + nx, r - 1);
		}
	}
	int ans = inf;
	for(int i : vis){
		int y = i / w, x = i % w;
		int d = min({x, y, h - 1 - y, w - 1 - x});
		ans = min(ans, 1 + (d + k - 1) / k);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 30336
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> P;

void printVec(std::vector<int> &vec) {
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}

int main() {
  int n;
  cin >> n;
  vector <int> d(n);

  set <int> st;
  for (int i = 0; i < n; i++) {
    cin >> d[i];
    st.insert(d[i]);
  }
  cout << st.size() << endl;
	return 0;
}

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

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    string s;
    cin>>s;
    for(int x=0;x<s.length();x++){
      if(s[x]=='7'){
        cout<<"Yes\n";
        return 0;
      }
    }
    cout<<"No\n";
    return 0;
}
/*

*/


Measured memory_bytes: 3648
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  map<ll,ll>M;
  ll two=0,one=0;
  rep(i,3){
    ll a,b;cin>>a>>b;
    M[a]++;M[b]++;
  }
  for(auto p:M){
    if(p.second==2)two++;
    if(p.second==1)one++;
  }
  if(one==2&two==2)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
s = int(input())

i = 1
a = [s]
while True:
    i += 1
    n = a[-1]
    if n % 2 == 0:
        next = n // 2
    else:
        next = 3 * n + 1
    if next in a:
        break
    else:
        a.append(next)

print(i)

Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<limits>
using namespace std;
int main(){
  string S;
  int N;
  int x,count;
  cin >> N;
  cin >> S;

  count=0;
  x=0;

  for(int i=0;i<N;i++){
    if(S[i]=='I'){
      x += 1;
    }else if(S[i]=='D'){
      x -= 1;
    }
    if(count<x&&x>0){
      count=x;
    }
    //   cout << count << endl;                                                                                                                               
  }
  cout << count << endl;

  return 0;

}



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

int main(){
    long long X;
    cin >> X;

    long long dep = 100;
    int years = 0;

    while(dep < X){
        long long in;

        in = dep / 100;

        dep += in;

        years++;
    }

    cout << years << endl;
}

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

int main(void) {
    int K; cin >> K;
    string S; cin >> S;
    if(int(S.size()) <= K) cout << S << endl;
    else {
        string s = S.substr(0,K);
        s+="...";
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
int main(void){
	long x;
	long pows[1001]; 
	scanf("%ld", &x);
	for(long p=0; p<1001; p++){
		long tmp = 1;
		for(int q=0; q<5; q++){
			tmp *= p;
		}
		pows[p] = tmp;
	}
	int flg = 0;
	for(int i=1; i<=1000; i++){
		if(flg == 1){
			break;
		}
		for(int j=-1000; j<=1000; j++){
			long pow_i = pows[i];
			long pow_j;
			if(j < 0){
				pow_j = -1 * pows[-1*j];
			}
			else{
				pow_j = pows[j];
			}
			if(pow_i - pow_j == x){
				printf("%d %d\n", i, j);
				flg = 1;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
#define forn(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define FORR(i,a,b) for(int i = a; i >= b; i--)

using namespace std;

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;


void solve(){
    int m, k;
    cin >> m >> k;
    if(m == 1 && k == 0){
        printf("0 0 1 1\n");
    }else if(m == 1 && k != 0){
        cout << -1 << endl;
    }else if( k >= (1<<m) ){
        cout << -1 << endl;
    }else{
        for(int i = 0; i < (1<<m); i++){
            if(i == k) continue;
            printf("%d ", i);
        }
        printf("%d ", k);
        for(int i = (1<<m)-1; i >= 0; i--){
            if(i == k)continue;
            printf("%d ", i);
        }
        printf("%d\n", k);
    }
}

int main(){
    //int t; cin >> t;
    //while(t--) solve();

    solve();
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
#define For1(i,n) for(ll i=1;i<(n);i++)
#define MOD 1000000007
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
ll keta(ll i){
    ll t=0;
    while(i){
        i/=10;
        t++;
    }
    return t;
}
int main(){
    string s;cin>>s;
    ll n=s.size();
    vector<ll> bottom,top;
    vector<ll> ans(n,0);
    For1(i,n){
        if(s.at(i-1)=='R'&&s.at(i)=='L'){
            bottom.push_back(i-1);
        }
        if(s.at(i-1)=='L'&&s.at(i)=='R'){
            top.push_back(i-1);
        }
    }
    top.push_back(10000000);
    ll topi=0,bottomi=0;
    For(i,n){
        if(i<=top.at(topi)){
            ans.at(bottom.at(bottomi)+(bottom.at(bottomi)-i+10000000)%2)++;
        }
        else{
            topi++;bottomi++;
            ans.at(bottom.at(bottomi)+(bottom.at(bottomi)-i+10000000)%2)++;
        }
        //cout<<bottom.at(bottomi)+(bottom.at(bottomi)-i+10000000)%2<<" ";
    }
    //cout<<endl;
    For(i,n){
        cout<<ans.at(i)<<" ";
    }
    /*cout<<endl;
    For(i,bottom.size()){
        cout<<bottom.at(i)<<" ";
    }
    cout<<endl;
    For(i,top.size()){
        cout<<top.at(i)<<" ";
    }*/
}


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

int main() {
  string a,b,c;
  cin >> a >> b >> c;
  
  char ai=a.at(0)-32;
  char bi=b.at(0)-32;
  char ci=c.at(0)-32;
  cout << ai << bi << ci << endl;
}

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

#ifdef DEBUG
const int N = 20;
#else
const int N = 2e6;
#endif
int n, m, k;
string s, t;

auto naive() {
  vector<int> res(N);
  for(int i = 0; i < N; i++) {
    res[i] = ((s[i] - '0') << 1) + (t[i] - '0');
  }
  for(int t = 0; t < k; t++) {
    for(int i = 0; i < N; i++) {
      int inc = 0;
      if(res[i] == 3) res[i] = 0, inc = 3;
      for(int j = i - 1; j >= 0 && inc; j--) {
        int old = res[j];
        res[j] ^= inc;
        inc &= old;
      }
    }
  }
  return res;
}

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  cin >> n >> m >> k;
  cin >> s >> t;
  s = string(N - s.size(), '0') + s;
  t = string(N - t.size(), '0') + t;
  vector<int> data(N);
  stack<int> st;
  for(int i = 0; i < N; i++) {
    data[i] = ((s[i] - '0') << 1) + (t[i] - '0');
    int z = k;
    int inc = 0;
    if(z && data[i] == 3) inc = 3, data[i] = 0, z--;
    int now = i - 1;
    vector<int> v;
    if(data[i] == 1 || data[i] == 2) v.emplace_back(i);
    while(inc && now >= 0) {
      int nx = -1;
      if(st.size()) {
        nx = st.top();
        st.pop();
        // assert(data[nx] == 1 || data[nx] == 2);
        if(data[nx] == 1 || data[nx] == 2); else return 0;
      }
      assert(nx <= now);
      // if(nx <= now); else return 0;
      if(inc == 3) {
        int useZ = min(z, now - nx);
        z -= useZ;
        if(useZ == now - nx) {
          // assert(nx >= 0);
          if(nx >= 0); else return 0;
          inc = data[nx];
          data[nx] ^= 3; // inc
          v.emplace_back(nx);
          now = nx - 1;
        } else {
          data[now - useZ] = 3; // inc
          stack<int>().swap(st);
          break;
        }
      } else {
        if(now == nx) {
          // assert(nx >= 0);
          int old = data[nx];
          data[nx] = old ^ inc;
          if(z && data[nx] == 3) inc = 3, data[nx] = 0, z--;
          else {
            inc = old & inc;
          }
          if(data[nx] == 1 || data[nx] == 2) v.emplace_back(nx);
          now = nx - 1;
        } else {
          data[now] = inc;
          if(data[nx] == 1 || data[nx] == 2) st.push(nx);
          if(data[now] == 1 || data[now] == 2) st.push(now);
          break;
        }
      }
    }
    reverse((v).begin(), (v).end());
    for(int e : v) st.push(e);
  }
  int g = 0;
  for(int i = 0; i < N; i++) {
    int a;
    g |= a = !!(data[i] & 0b10);
    if(g) cout << a;
  }
  cout << endl;
  g = 0;
  for(int i = 0; i < N; i++) {
    int a;
    g |= a = (data[i] & 0b01);
    if(g) cout << a;
  }
  cout << endl;
#ifdef DEBUG
  assert(data == naive());
#endif
  return 0;
}


Measured memory_bytes: 18928
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
#define All(a) (a).begin(),(a).end()
#define RAll(a) (a).rbegin(),(a).rend()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define INFL 1e18
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数
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 (a > b) { a = b; return 1; }
	return 0;
}

int prime[500000] = { 0 };
int idx;

//numまでの素数を求める
void getPrime(int num) {
	if (num < 2) {
		idx = -1;
		return;
	}
	prime[0] = 2;
	if (num < 3) {
		idx = 0;
		return;
	}
	idx = 1;
	prime[0] = 2;
	prime[1] = 3;
	int i, j;
	int flag;
	for (i = prime[idx] + 2; i <= num; i += 2) {
		flag = 1;
		for (j = 0; prime[j] <= (int)sqrt(i); j++) {
			if (i%prime[j] == 0) {
				flag = 0;
				break;
			}
		}
		if (flag)prime[++idx] = i;
	}
}

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

	int n;
	cin >> n;
	vi a = vi(n);
	REP(i, n) {
		cin >> a[i];
	}
	sort(All(a));

	int ans = 0;
	vector<bool> f = vector<bool>(1000001, false);
	REP(i, n) {
		//cout << "i=" << i << endl;

		if (f[a[i]])continue;
		int x = 1;
		while (a[i] * x <= 1000000) {
			f[a[i] * x] = true;
			x++;
		}

		int ix = i;
		while (ix < n - 1) {
			if (a[ix + 1] != a[ix])break;
			ix++;
		}
		if (i != ix) {
			i = ix;
			continue;
		}
		ans++;
		//cout << ans << endl;
	}

	cout << ans << endl;
}

Measured memory_bytes: 4336
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    int h,w;
    cin >>h >>w;
    vector<vector<int>> a(h,vector<int>(w));
    rep(i,h)rep(j,w) cin >>a[i][j];

    int ans = 0;
    rep(i,h){
        int tmp = 0;
        rep(j,w+1)rep(lr,2){
            int aaa = 0;
            vector<int> v(a[i]);
            if(lr==0){
                rep(k,j){
                    aaa += v[k];
                    if(k+1<w) v[k+1] = !v[k+1];
                }
                for(int k=w-1; k>=j; --k){
                    aaa += v[k];
                    if(k-1>=0) v[k-1] = !v[k-1];
                }
            }
            else{
                for(int k=w-1; k>=j; --k){
                    aaa += v[k];
                    if(k-1>=0) v[k-1] = !v[k-1];
                }
                rep(k,j){
                    aaa += v[k];
                    if(k+1<w) v[k+1] = !v[k+1];
                }
            }

            tmp = max(tmp, aaa);
        }

        ans += tmp;

        if(i<h-1){
            rep(j,w) a[i+1][j] = !a[i+1][j];
        }
    }

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



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

using namespace std;

int main(){
	int n;
	int count = 0;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		}		
		
	std::sort(a.begin(), a.end());
	
	for(int i = 0; i < n; ++i){
		for(int j = i + 1; j < n; ++j){
			for(int k = j + 1; k < n; ++k){
				if(a[i] != a[j] && a[j] != a[k] && a[i] + a[j] > a[k]){
					count++;
					}
				}
			}
		}
	
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3620
from bisect import *
from operator import *
from statistics import *

n = int(input())
x = list(map(int, input().split()))
med_low = median_low(x)
med_high = median_high(x)
x_sorted = sorted(x)

for i in range(n):
    if bisect_left(x_sorted, x[i]) < n/2:
        print(med_high)
    else:
        print(med_low)


Measured memory_bytes: 27300
s = input()
f = False
l = False
for i in range(len(s)):
    if s[i] == 'C':
        for j in range(i, len(s)):
            if s[j] == 'F':
                print('Yes')
                f = True
                break
        if f == False:
            print('No')
        l = True
        break
if l == False:
    print('No')


Measured memory_bytes: 3060
# D - Partition
# Mの約数で、しかもN倍してもMを超えないもののうち、最大のものを探す

N, M = map(int, input().split())

if N == 1:
    print(M)
    exit()

x = M//N

while 1:
    if M % x == 0:
        ans = x
        break
    x -= 1
    
print(ans)

Measured memory_bytes: 40044
#!python3

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

# input
N, M = LI()
A, B = [None] * M, [None] * M
for i in range(M):
    A[i], B[i] = LI()
    A[i] -= 1
    B[i] -= 1


def solve(link):
    for i in link[0]:
        if N - 1 in link[i]:
            return "POSSIBLE"
    return "IMPOSSIBLE"


def main():
    link = [set() for _ in range(N)]
    for a, b in zip(A, B):
        link[a].add(b)
        link[b].add(a)
    
    ans = solve(link)
    print(ans)


if __name__ == "__main__":
    main()


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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)      (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define mod        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))


void solve(){
    ll n;cin>>n;
    vector<ll> a(n);
    rep(i,0,n)cin>>a[i];
    sort(rall(a));
    ll ans=1,j=0;
    for(int i=0;i<n-1;i++){
        if(j==2)break;
        if(a[i]==a[i+1]){
            ans*=a[i];
            j++;
            i++;
        }

    }
    ans=j==2?ans:0;
        cout<<ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int N, A, B;
	cin >> N >> A >> B;
	vector<int>X(N);
	rep(i, N)cin >> X[i];
	int ans = 0;
	rep(i, N - 1) {
		ans += min((X[i + 1] - X[i]) * A, B);
	}
	cout << ans << endl;
}

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

const long long MOD = (long long) 1e9 + 7;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  map<char, long long> mp;
  for (auto& c : s) {
    mp[c]++;
  }
  long long ans = 1;
  for (auto& x : mp) {
    ans = (ans * (x.second + 1)) % MOD;
  }
  ans--;
  if (ans < 0) {
    ans = MOD - 1;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
struct activity
{
    int A, B, C;
};
int solve(vector<activity>, int);

int main()
{
    int n;
    cin >> n;
    vector<activity> ar(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> ar[i].A;
        cin >> ar[i].B;
        cin >> ar[i].C;
    }
    cout << solve(ar, n);

    return 0;
}

int solve(vector<activity> ar, int n)
{
    int dp[n + 1][3];
    dp[1][0] = ar[1].A;
    dp[1][1] = ar[1].B;
    dp[1][2] = ar[1].C;

    for (int i = 2; i <= n; i++)
    {
        dp[i][0] = ar[i].A + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = ar[i].B + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = ar[i].C + max(dp[i - 1][0], dp[i - 1][1]);
    }
    return max({dp[n][0], dp[n][1], dp[n][2]});
}

Measured memory_bytes: 6680
n = gets.to_i
a = gets.split.map(&:to_i)

num = Hash.new(0)
a.each{|e| num[e] += 1}

case num.size
when 1
    puts num[0] == n ? "Yes" : "No"
when 2
    puts n % 3 == 0 && num[0] == n / 3 ? "Yes" : "No"
when 3
    a,b,c = num.keys
    puts n%3 == 0 && a^b^c == 0 && num.values.all?{|e| e == n/3} ? "Yes" : "No"
else
    puts "No"
end

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

long long x[1005],y[1005],z[1005],xyz[120000],X,Y,Z,K;

bool cmp(const long long &x, const long long &y)
{
	return x>y;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> X >> Y >> Z >> K;
	for(int i = 1; i <= X; i++) cin >> x[i];
	for(int i = 1; i <= Y; i++) cin >> y[i];
	for(int i = 1; i <= Z; i++) cin >> z[i];
	sort(x+1,x+X+1,cmp);
	sort(y+1,y+Y+1,cmp);
	sort(z+1,z+Z+1,cmp);
	int cnt = 0;
	for(int i = 1; i <= X; i++)
		for(int j = 1; j <= Y; j++)
			for(int k = 1; k <= Z; k++){
				if(i*j*k > K) break;
				cnt++;
				xyz[cnt] = x[i]+y[j]+z[k];
			}
	sort(xyz+1,xyz+cnt+1,cmp);
	for(int l = 1; l <= K; l++)
		cout<<xyz[l]<<"\n";

	return 0;
}

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

string a,b;

int main() {


        cin >> a >> b;
        bool flag=false;

        for(int i=1;i<=a.size();i++) {
                char c=a[a.size()-1];
                a.pop_back();
                a=c+a;

                if(a==b) flag=true;
        }

        if(flag) cout << "Yes\n";
        else     cout << "No\n";

}


Measured memory_bytes: 256
#include <unistd.h>
#include <cstdio>
#include <x86intrin.h>
#include <algorithm>

typedef long long ll;
ll mat[375][3072 * 8] __attribute((aligned(64)));;
ll dp0[3008];

char buf[1048576];
int lim = 0;
int cur = 0;

void refill()
{
    lim = read(STDIN_FILENO, buf, sizeof buf);
    cur = 0;
}

int rd()
{
    while (true) {
        if (cur == lim) {
            refill();
            if (lim == 0) return -1;
        } else {
            if (buf[cur] >= '0' && buf[cur] <= '9') break;
            cur++;
        }
    }
    int acc = buf[cur++] - '0';
    while (true) {
        if (cur == lim) {
            refill();
            if (lim == 0) return acc;
        } else {
            if (buf[cur] < '0' || buf[cur] > '9') return acc;
            acc = acc * 10 + buf[cur++] - '0';
        }
    }
}

#pragma clang attribute push(__attribute__((target("avx512vl"))), apply_to=function)
int main(int argc, char **argv)
{   
    int rr = rd();
    int cc = rd();
    int k  = rd();
    
    for (int i = 1; i <= k; i++) {
        int r = rd() - 1;
        int c = rd() - 1;
        int v = rd(); 
        mat[r / 8][(c + (r & 7)) * 8 + (r & 7)] = v;
    }
    int rlim = (rr + 7) / 8;
    int clim = cc + 7;
    
    for (int y = 0; y < rlim; y++) {
        __m512i work0 = _mm512_setzero_si512();
        __m512i work1 = _mm512_setzero_si512();
        __m512i work2 = _mm512_setzero_si512();
        __m512i work3 = _mm512_setzero_si512();
        __m512i prev  = _mm512_setzero_si512();
        __m512i *p = (__m512i *)&mat[y];
        ll *q = dp0;
        
        for (int x = 0; x < clim; x++) {
            prev = _mm512_mask_set1_epi64(prev, 1, q[7]);
            work0 = _mm512_max_epi64(work0, prev);
            __m512i v = _mm512_load_si512(p);
            __m512i tmp2 = _mm512_add_epi64(work2, v);
            work3 = _mm512_max_epi64(work3, tmp2); 
            __m512i tmp1 = _mm512_add_epi64(work1, v);
            work2 = _mm512_max_epi64(work2, tmp1); 
            __m512i tmp0 = _mm512_add_epi64(work0, v);
            work1 = _mm512_max_epi64(work1, tmp0);
            __m512i max32 = _mm512_max_epi64(work3, work2);
            __m512i max10 = _mm512_max_epi64(work1, work0);
            __m512i maxall = _mm512_max_epi64(max32, max10);
            prev = _mm512_alignr_epi64(maxall, maxall, 7);
            
            _mm512_mask_store_epi64(q, 1, prev);
            
            ++p;
            ++q;
        }
    }
    std::printf("%lld\n", dp0[clim - 1]);
    return 0;
}
#pragma clang attribute pop

Measured memory_bytes: 74620
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int K;
	cin >> K;
	VI A(K);
	REP(i, K)cin >> A[i];
	int ma = 2, mi = 2;
	for (int i = K - 1; i >= 0; i--) {
		
		mi = (mi+A[i]-1)/A[i]*A[i];
		ma = (ma/A[i])*A[i]+A[i]-1;


		//cout << mi << " " << ma << endl;
	}

	if (mi > ma)cout << -1 << endl;
	else cout << mi << " " << ma << endl;

	return 0;
}



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

int main() {
  int n, x;
  cin >> n >> x;
  int min = 10000000;
  int ret = n;
  for (int i = 0; i < n; i++) {
    int m;
    cin >> m;
    if (m < min) min = m;
    x -= m;
  }
  ret += (x / min);
  cout << ret << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[])
{
	int i, j, h, w;

	while(scanf("%d %d", &h, &w))
	{
		if(h == 0 && w == 0)
			break;
		for(i = 0; i < h; i++)
		{
			for (j = 0; j < w; j++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>

int main(){
	char a,b;
	scanf("%c %c",&a,&b);
	if(a==b){
		puts("H");
	}else{
		puts("D");
	}
	
    return 0;
}


Measured memory_bytes: 128
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>
#include <iomanip>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = n-1; i >= 0; --i)
#define REP(i, s, n) for (int i = s; i< (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
ll inf = ll(1e18);
using ll1d = vector<ll>;
using ll2d = vector<ll1d>;
using ll3d = vector<ll2d>;

void solve(istream &ccin = cin, ostream &ccout = cout) {
  ll h, w, n;
  ccin >> h >> w >> n;
  map<ll, map<ll, ll>> mp;
  rep(_, n) {
    ll a, b;
    ccin >> a >> b;
    REP(i, -1, 2) {
      REP(j, -1, 2) {
        if (1 < a + j and a + j < h and 1 < b + i and b + i < w) {
          ++mp[a + j][b + i];
        }
      }
    }

  }
  vector<ll> v(10, 0);
  for (auto i = mp.begin(); i != mp.end(); ++i) {
    for (auto j = i->second.begin(); j != i->second.end(); ++j) {
      ++v[j->second];
    }
  }
  ll sum = accumulate(all(v), 0);
  v[0] = (h - 2) * (w - 2) - sum;
  for (const auto &i: v) {
    ccout << i << endl;
  }

}

int main() {
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 84608
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <cmath>
#define PI 3.14159265358979
using namespace std;

int main(){
	double a,b,c;
	cin >> a >> b >> c;
	double rad = c * PI / 180.0;
	double s = a * b / 2 * sin(rad);
	double l = a + b + sqrt(a * a + b * b -2 * a * b * cos(rad));
	double h = 2 * s / a;
	printf("%lf\n",s);
	printf("%lf\n",l);
	printf("%lf\n",h);
	return 0;
}

Measured memory_bytes: 3444
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
char in[5100];
long long mod=1000000007;
long long d2=500000004;
long long dp[2][5010];
int main(){
	int a;scanf("%d",&a);
	scanf("%s",in);
	int n=strlen(in);
	long long ret=0;
	dp[0][0]=1;
	for(int i=0;i<a;i++){
		int t=i%2;
		for(int j=0;j<5010;j++)dp[!t][j]=0;
		for(int j=0;j<5010;j++){
			if(!dp[t][j])continue;
	//		printf("%d %d: %lld\n",i,j,dp[t][j]);
			dp[!t][max(0,j-1)]=(dp[!t][max(0,j-1)]+dp[t][j])%mod;
			dp[!t][j+1]=(dp[!t][j+1]+dp[t][j]*2)%mod;
		}
	}
	ret=dp[a%2][n];
	for(int i=0;i<n;i++)ret=ret*d2%mod;
	printf("%lld\n",ret);
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char masu[8][9];
  int n;
  int i=0,j=0;
  int x=0,y=0;

  while(1){
    if(scanf("%s",&masu[0])==EOF)
      break;

    for(i=1;i<8;i++){    
      scanf("%s",&masu[i]);
    }
   

   
  
    // printf("OK3\n");

    //printf("-----------------------\n");
    for(i=0;i<8;i++){
      for(j=0;j<8;j++){
	//printf("%d",masu[i][j]);
	if(masu[i][j]=='1'&&x==0&&y==0){
	  x=j+1;y=i+1;
	}
      }
      //printf("\n");
    }
      
    x--;y--;
    // printf("x=%d:y=%d\n",x,y);
    if(masu[y+1][x]=='1'&&masu[y][x+1]=='1'&&masu[y+1][x+1]=='1')printf("A\n");
    if(masu[y+3][x]=='1')printf("B\n");
    if(masu[y][x+3]=='1')printf("C\n");
    if(masu[y+2][x-1]=='1')printf("D\n");
    if(masu[y+1][x+2]=='1')printf("E\n");
    if(masu[y+2][x+1]=='1')printf("F\n");
    if(masu[y+1][x-1]=='1'&&masu[y][x+1]=='1')printf("G\n");
    x=0;y=0;
       

  }
  return 0;
}
  

Measured memory_bytes: 1664
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <ctime>
#include <climits>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <utility>
#include <cstdlib>

using namespace std;
long int pow107 = (int)pow(10, 9) + 7;
int ilimit = INT_MAX;
long int llimit = LONG_MAX;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

int Func2(int n,int m){
    long int s2 = 1,
        r = 1;


    for(int i = 1; i <= m; ++i){
        s2 = (s2*(n - (i - 1))/i) % pow107;
    }

    return s2;
}

//long intの最大llimit
//intの最大ilimit
//10^9+7    pow107
//素数pn
//n乗jou
//階乗factorial
//コンビネーションFunc2

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> v;
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(),v.end(),greater<int>());
    int t = 0;
    for(int i = 0; i < k; ++i){
        t += v[i];
    }
    cout << t << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{

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

    int i=0,j=0,k=0,l=0,m=0,n=0;
    int sum=0;

    for (int s = 1; s <= x;s++){
    
    i=0,j=0,k=0,l=0;

    n = s;

    if(n>=10000){
        i = n/10000;
        n -= i*10000;
    }

    if(n>=1000){
        j = n/1000;
        n -= j*1000;
    }
    if(n>=100){
        k = n/100;
        n -= k*100;
    }
    if(n>=10){
        l = n/10;
        n -= l*10;
    }

    m = n;
    if (a<=i+j+k+l+m && i+j+k+l+m <=b){
        sum += s;
    }


    }


    cout << sum;
    return 0;

}

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

from collections import deque

n = int(input())
edges = [list(map(int, input().split())) for i in range(n-1)]

tree = {}
node_in = [0 for i in range(n)] # 頂点に入る辺は1つ
node_out = [[0] for i in range(n)] # 頂点から出る辺は1つ以上
for edge in sorted(edges):
    a = edge[0] # 頂点a
    b = edge[1] # 頂点b

    color = 0
    if node_out[a-1][-1] == 0:
        if node_in[a-1] <= 1: # node_in[a-1] == 0の時1、1の時2なのでまとめて
            color = node_in[a-1] + 1
        else: # node_in[a-1] >= 2
            color = 1
    else:
        color = node_out[a-1][-1] + 1
        if node_in[a-1] == color:
            color += 1
            
    tree[(a, b)] = color
    node_out[a-1].append(color)
    node_in[b-1] = color

print(max(tree.values()))
for edge in edges:
    a = edge[0] # 頂点a
    b = edge[1] # 頂点b
    print(tree[(a, b)])

Measured memory_bytes: 51308
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
for i in range(1, 10):
    for j in range(1, 10):
        if i * j == n:
            print('Yes')
            exit()
print('No')


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	int t=1;
	//cin >> t;
	while(t--){
		ll int n,x,time,count=0;
      	string str;
      	cin >> str;
      	n = str.size();
      	for(int i=0;i<n;i++){
        	count+= str[i]-'0';
        }
      	if(count%9){cout << "No"<<endl;}
      else cout << "Yes"<<endl;
    }
}

Measured memory_bytes: 3748
#include <cstdio>
#define REP(I,n) for(int i=2;i<=n;i++)
using namespace std;
int main(){
  int n;
  int F[45]={0};
  scanf("%d",&n);
  F[0]=F[1]=1;
  REP(i,n) F[i]=F[i-1]+F[i-2];
  printf("%d\n",F[n]);
  return 0;
}

Measured memory_bytes: 2732
a, b = [1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11]
x, y = map(int, input().split())
if x in a and y in a:
    print('Yes')
elif x in b and y in b:
    print('Yes')
elif x == y:
    print('Yes')
else:
    print('No')

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

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int h[] = new int[10];
		for(int i=0;i<10;i++)h[i] = s.nextInt();
		Arrays.sort(h);
		System.out.println(h[9]);
		System.out.println(h[8]);
		System.out.println(h[7]);
	}
}

Measured memory_bytes: 12000
#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> bool chmax(T &a, const T& b) {if (a < b){a = b;return true;}return false;}
template <typename T> bool chmin(T &a, const T& b) {if (a > b){a = b;return true;}return false;}

struct IoSetup{
    IoSetup(){
      ios::sync_with_stdio(false);
      cin.tie(0);
      cout << fixed << setprecision(20);
      cerr << fixed << setprecision(20);
    }
} IoSetup;

int main() {
  int n, ssx=0; cin >> n;
  int sum = 0;
  int i=0, j=0;
  for (i = 0; i <= n; ++i) {
    sum += i;
    if (sum > n) break;
  }
  for (j = 1; j <= n; ++j) {
    if (sum - n == j) continue;
    if (ssx < n && j <= i) {
      cout << j << '\n';
    }
  }
}


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

namespace Satoshi
{
	class Program
	{
		public static void Main(string[] args)
		{
			int a, b, c, d;
			string[] s = Console.ReadLine().Split(' ');
			a = int.Parse(s[0]);
			b = int.Parse(s[1]);
			c = int.Parse(s[2]);
			d = int.Parse(s[3]);
			if (a * b > c * d)
				Console.WriteLine(a * b);
			else
				Console.WriteLine(c * d);
		}
	}
}

Measured memory_bytes: 2648
#include <stdio.h>
int main (){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a < b){
    if(b < c){
      printf("%d %d %d\n",a,b,c);
    }else if(a < c){
      printf("%d %d %d\n",a,c,b);
    }else {
      printf("%d %d %d\n",c,a,b);
    }
  }else {
    if(a < c){
      printf("%d %d %d\n",b,a,c);
    }else if(b < c){
      printf("%d %d %d\n",b,c,a);
    }else {
      printf("%d %d %d\n",c,b,a);
    }
  }
  return 0;
}





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

using namespace std; 
const int MAX_N = 10005; 
const int MOD = 1000000007; 

int dp[MAX_N][100][3]; 
string s; 
int d; 

int main () {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin >> s >> d; 
	int n = (int) s.size(); 
	for (int x = 1; x <= 9; x++) {
		if (x < s[0] - '0') {
			dp[1][x % d][0]++; 
		}
		else if (x == s[0] - '0') {
			dp[1][x % d][1]++; 
		}
		else {
			dp[1][x % d][2]++; 
		}
	}

	for (int i = 1; i < n; i++) {
		for (int r = 0; r < d; r++) {
			for (int sta = 0; sta < 3; sta++) {
				if (dp[i][r][sta] == 0) {
					continue; 
				}
				int cur = dp[i][r][sta]; 
				for (int x = 0; x <= 9; x++) {
					if (sta == 0) {
						(dp[i + 1][(r + x) % d][0] += cur) %= MOD; 
					}                                             
					else if (sta == 2) {
						(dp[i + 1][(r + x) % d][2] += cur) %= MOD; 
					}
					else {
						if (x < s[i] - '0') {
							(dp[i + 1][(r + x) % d][0] += cur) %= MOD; 
						}
						else if (x > s[i] - '0') {
							(dp[i + 1][(r + x) % d][2] += cur) %= MOD; 
						}
						else {
							(dp[i + 1][(r + x) % d][1] += cur) %= MOD; 
						}
					}
				}
			}
		}
	}

	int res = 0; 
	for (int i = 1; i <= n; i++) {
		for (int sta = 0; sta <= (i < n ? 2 : 1); sta++) {
			(res += dp[i][0][sta]) %= MOD; 
		}
	}

	cout << res; 
	return 0; 
}

Measured memory_bytes: 12032
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define input freopen("1.txt","r",stdin);
#define output freopen("output.txt","w",stdout);
#define ll long long int
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
#define pii pair<int, int>
#define pll pair<ll,ll>
#define mp make_pair
#define vpi vector<pii>
#define vpl vector<pll> 
#define ss second 
#define ff first

using namespace std;

const int p = 1e9 + 7;
const int maxn = 1e5 + 1;

void solve() {
    int n; cin >> n;
    int l[n];
    // vi psides;
    for(int i = 0; i < n; i++) cin >> l[i];
    int ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = i+1; j < n; j++) {
            for(int k = j+1; k < n; k++) {
                if(l[i] != l[j] && l[i] != l[k] && l[j] != l[k]) {
                    vi sides = {l[i], l[j], l[k]};
                    sort(sides.begin(), sides.end());
                    if(sides[0] + sides[1] > sides[2]) ans++;
                }
            }
        }
    }
    cout << ans;
}

int main() {
    fast
    int t = 1; 
    // cin >> t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vl a(n);
    vl rui(n+1);
    rep(i, n) {
        cin >> a[i];
        rui[i+1] = rui[i] + a[i];
    }

    map<ll, ll> mp;
    ll ans = 0;
    rep(i, n+1) {
        mp[rui[i]]++;
        ans += mp[rui[i]] - 1;
    }

    out(ans);
    re0;
}

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

int main() {
  int N;
  cin >> N;
  vector<long long int> H(N);
  for (int i = 0; i < N; i++){
    cin >> H.at(i);
  }
  bool ans = true;
  if (N > 1){
  for (int i = N-1; i > 0; i--){
    if(H.at(i-1) - H.at(i) >= 2){
      ans = false;
      break;
    } else if (H.at(i-1) - H.at(i) == 1){
      H.at(i-1)--;
    }
  }
  }
  
  if(ans){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
N = int(input())
C = list(map(int, input().split()))
MOD =  10 ** 9 + 7

P = [1] * (N + 1)
for i in range(1, N + 1):
  P[i] = P[i - 1] * 2 % MOD

C.sort(reverse = True)

ans = 0
k = P[N - 1] % MOD
for i in range(N):
  ans = (ans + k * C[i] * P[N]) % MOD
  k = (k + P[N - 2]) % MOD

print(ans)

Measured memory_bytes: 89164