akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i, n)for(int i=0; i<n; i++)

int main(){
  int N;
  cin >> N;
  int s[N];
  rep(i, N)
    cin >> s[i];
  //

  sort(s, s+N);
  
  int sum = 0;
  rep(i, N)
    sum += s[i];

  if(sum%10 != 0){
    cout << sum << endl;
    return 0;
  }
  
  rep(i, N){
    sum -= s[i];
    if(sum%10 != 0){
      cout << sum <<endl;
      return 0;
    }
    sum += s[i];
  }
  
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define printYes() printf("Yes\n")
#define printNo() printf("No\n")
#define scanll(a) scanf("%lld", &a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scan4Int(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
typedef long long ll;
const int INF = 1001001001;
using namespace std;
void swap(int *a, int *b) {
    int tmp = *a;
    *a = *b;
    *b = tmp;
    return;
}
int gdc(int a, int b) {
    int r;
    if (a < b)
        swap(&a, &b);
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main() {
    int n;
    scanInt(n);
    int takos[n];
    rep(i, n) cin >> takos[i];
    int total = 0;
    rep(i, n) {
        for (int j = i + 1; j < n; ++j) {
            total += takos[i] * takos[j];
        }
    }
    printInt(total);
    return 0;
}

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

int mod = 1e9+7;
struct modular {
    int value;
    modular(long long v = 0) { value = v % mod; if (value < 0) value += mod;}
    modular(long long a, long long b) : value(0){ *this += a; *this /= b;}
    modular& operator+=(modular const& b) {value += b.value; if (value >= mod) value -= mod; return *this;}
    modular& operator-=(modular const& b) {value -= b.value; if (value < 0) value += mod;return *this;}
    modular& operator*=(modular const& b) {value = (long long)value * b.value % mod;return *this;}
    //其他函数调用mexp(modular(10),3);
    friend modular mexp(modular a, long long e) {
        modular res = 1; while (e) { if (e&1) res *= a; a *= a; e >>= 1; }
        return res;
    }
    friend modular inverse(modular a) { return mexp(a, mod - 2); }
    modular& operator/=(modular const& b) { return *this *= inverse(b); }
    friend modular operator+(modular a, modular const b) { return a += b; }
    friend modular operator-(modular a, modular const b) { return a -= b; }
    friend modular operator-(modular const a) { return 0 - a; }
    friend modular operator*(modular a, modular const b) { return a *= b; }
    //除法只有在mod是素数可用;
    friend modular operator/(modular a, modular const b) { return a /= b; }
    friend ostream& operator<<(ostream& os, modular const& a) {return os << a.value;}
    friend istream& operator>>(istream& is, modular & a){long long value; is >> value;a.value = 0; a += value;  return is;}
    friend bool operator==(modular const& a, modular const& b) {return a.value == b.value;}
    friend bool operator!=(modular const& a, modular const& b) {return a.value != b.value;}
};



ll quick_pow(ll a, ll b) {
    ll res = 1;
    a %= mod;
    while (b) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}




int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n,k;
    cin >> n >> k;
    
    int zero_max = min(n-1, k);
    
    if(k == 1){
        modular ans = 1;
        cout << ans * n *(n-1) << "\n";
    }
    
    vector<int> fac(n+1), finv(n+1);
    fac[0] = finv[0] = 1;
    for(int i = 1; i <= n; ++i)fac[i]=(ll)fac[i-1]*i%mod;
    finv[n] = quick_pow(fac[n], mod-2);
    for(int i = n-1; i; --i)finv[i] = (ll)finv[i+1]*(i+1)%mod;
    
    
    auto comb= [&](int n, int m){
        //n!/(m!(n-m)!)
        return (ll)fac[n] * finv[m] % mod * finv[n - m]% mod;
    };

    
    modular ans = 1;
    for (int i = 1; i <= zero_max; i++){
        ans += (modular)comb(n, i) * comb(n-1, i);
    }
    
    cout << ans << "\n";
    
    return 0;
}


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

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

  vector<string> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());

  int res=1;
  for (int i = 1; i < N; i++) {
    if (vec.at(i-1)!=vec.at(i)) res+=1 ;
  }

  cout << res << endl;
  return 0;
}

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

int main(){
	int K, T, x = -1;
	cin >> K >> T;
	vector<int> a(T);
	for(int i=0; i<T; i++){
		cin >> a[i];
		x = max(x, a[i]);
	}
	x = 2 * x - 1;
	for(int v : a){
		x -= v;
	}
	cout << max(0, x) << endl;
	return 0;
}

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

namespace atcorder_BeginnerContest_122
{
    class Program
    {

        static void Main(string[] args)
        {

            int[] cntArr = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            int len = cntArr[0];
            int cnt = cntArr[1];
            string data = Console.ReadLine();

            //ACの位置を取得
            int[] acCntArr = new int[len];
            for (int i = 0; i < len - 1; i++)
            {
                acCntArr[i + 1] = acCntArr[i];
                if (('A' == data[i]) && ('C' == data[i + 1]))
                {
                    acCntArr[i + 1]++;
                }
            }

            for (int i = 0; i < cnt; i++)
            {
                int[] idxArr = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

                Console.WriteLine(acCntArr[idxArr[1] - 1] - acCntArr[idxArr[0] - 1]);

            }

        }
    }
}



Measured memory_bytes: 17812
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    int64_t x;
    mint(int64_t x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(int64_t t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    //for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int k;
    cin >> k;
    vi a(n);
    rep(i, n) {
        int al;
        cin >> al;
        a[i] = al;
    }
    vi b = a;
    sort(all(b));
    mint ans, jj = mint(k-1) * k / 2;

    rep(i, n) {
        int j = i;
        while(j != n-1 and b[j] == b[j+1]) j++;
        ans += mint(n-1-j) * (j-i+1);
        i = j;
    }
    ans *= jj;

    multiset<int> mst;
    rep(i, n) {
        mst.insert(a[i]);
        auto itr = mst.upper_bound(a[i]);
        ans += (mint)distance(itr, mst.end()) * k;
    }

    cout << ans << endl;
}

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

using namespace std;

int main()
{
    int n;

    scanf("%d",&n);
    int a[n];
    for (int i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }


    sort(a,a+n);
    int start = a[n/2-1];
    int finish =a[(n/2)];
    int k;
    k=finish-start;
    printf("%d",k);

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
 long long int n;
  cin>>n;
  long long int c=0;
  int a[n+1];
  for(int i=0;i<n+1;i++)
  {
  cin>>a[i];
  }
  int bi[n+1],b[n+1];
   for(int i=0;i<n;i++)
   {
     cin>>bi[i];
   }
  bi[n]=0;
  int co[n+2]={0};
for(int i=0;i<n+1;i++)
{
  b[i]=co[i]+bi[i];
  if(b[i]-a[i]==0)
  {
    c+=b[i];
  }
  else if(b[i]-a[i]<0)
  {
    c+=b[i];
  }
  else
  { c+=a[i];
    a[i]=max(0,a[i]-co[i]);
    if(bi[i]-a[i]>0)
  co[i+1]=bi[i]-a[i];
  }
}
  cout<<c;
}

Measured memory_bytes: 1792
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

template<typename V>
constexpr string join(const V &v, const string &sep) {
  stringstream ss;
  if (v.size()) ss << v[0];
  loop(i, 1, v.size()) ss << sep << v[i];
  return ss.str();
}

void solve() {
  int n;
  while (cin >> n, n) {
    string s;
    cin >> s;
    vi t(n);
    int f = 0;
    rep(i, s.size()) {
      switch (s[i]) {
        case 'S':
          f += t[i % n] + 1;
          t[i % n] = 0;
          break;
        case 'L':
          t[i % n] += f + 1;
          f = 0;
          break;
        case 'M':
          t[i % n]++;
          break;
      }
    }
    sort(all(t));
    t.pb(f);
    cout << join(t, " ") << endl;
  }
}

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

int main(){
    int N; std::cin >> N;
    std::vector<int>V;
    std::vector<int>C;
    int ref;
    for (int i = 0; i < N; i++)
    {
        std::cin >> ref;
        V.push_back(ref);
    }
    
    for (int i = 0; i < N; i++)
    {
        std::cin >> ref;
        C.push_back(ref);
    }

    int Ans = 0;
    std::vector<int>diff;
    for (int i = 0; i < N; i++)
    {
        ref = V[i] - C[i];
        diff.push_back(ref);
    }
    std::sort(diff.begin(),diff.end());
    int tmp = 0;
    for (int i = N; i>=0  ; --i)
    {
        tmp += diff[i];
        if(Ans <= tmp)Ans = tmp;
      //cout << "i="<<i << endl;

    }
    std::cout << Ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll powmod(ll n, ll k, ll m) {
ll r=1;
 for(; k>0; k >>=1) {
   if(k&1) r=(r*n)%m;
   n=(n*n)%m;
 }
  return r;
}

ll fact(ll n) {
ll a=1;
rep(i,n) {
a=a*(n-i);
}
return a;
}

ll pow(ll a, ll b) {
ll x=1;
rep(i,b) {
x=x*a;
}
return x;
}
ll P[9]={0,1,2,3,4,5,6,7,8};
int main() {
  ll N;
  ll M;
    cin >>N>>M;
  vl a(M);
  vl b(M);
  rep(i,M) {
    ll aaa;
    ll bbb;
    cin >>aaa>>bbb;
    a.at(i)=aaa-1;
    b.at(i)=bbb-1;
  }

  ll count=0;
  do{
    bool psps=false;
    ll c=0;
    rep(i,N-1) {//startfirstrep
      bool pp=false;
      rep(j,M) {
        if((P[i]==a.at(j)) &&(P[i+1]==b.at(j))) {
          pp=true;
          break;
        }
      }
      
          rep(j,M) {
        if((P[i]==b.at(j)) &&(P[i+1]==a.at(j))) {
          pp=true;
          break;
        }
      }
    
    if(pp) {
      c++;
    }
    
      
    
    
      
      
      
      
      
      
      
    }//endfirstrep 
    
    if((c==N-1)&&(P[0]==0)) {
      count++;
    }
    
    
    
  }
  while(next_permutation(P,P+N));
  
  
  cout<<count<<endl;
}



  
      
  

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 1000000007
#define LINF 8000000000000000007
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
struct edge{int from,to,cost;};
int pow2(int n,int i){if(i==1)return n;return n*pow(n,i-1);};

typedef long long ll;

using namespace std;


int ans,ans2;
int n,m;

signed main(){  
    
    int a[111111];
    cin>>n>>m;
    rep(i,n){
        cin>>a[i];
        if(a[i]>=m)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    int A[N];
    rep(i, N) cin >> A[i];
    vector<int> es[N];
    rep(i, N-1){
        int u, v; cin >> u >> v; u--, v--;
        es[u].pb(v), es[v].pb(u);
    }
    int res[N];
    fill(res, res+N, -1);
    int cnt = 0;
    while(cnt < N){
        int m = inf;
        rep(i, N){
            if(res[i] == -1) chmin(m, A[i]);
        }
        rep(i, N){
            if(res[i] == -1 && A[i] == m){
                res[i] = 0, cnt++;
                for(auto &e: es[i]){
                    if(res[e] == -1 && A[e] > m) res[e] = 1, cnt++;
                }
            }
        }
    }
    rep(i, N){
        if(res[i]) cout << i+1 << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 3828
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <iostream>
#include <bitset>
#include <map>

#define db double
#define vi vector<int>
#define pb push_back
#define popb pop_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv vector<vector<int> >
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
#define pp pair<int,int>
#define fix(n) fixed << setprecision(n)
#define gmax(a,b) __gcd(a,b)
#define gmin(a,b) a/__gcd(a,b)*b
using namespace std;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}



int main(){

ll n;cin>>n;
ll a=sqrt(n);
  //cout<<a<<endl;
ll b=a;
ll ans=1000000000;
//int ans2=0;
if(a*a==n){
  ans=floor(log10(a)+1);
 
}else{
  while(a>=1){
    if(n%a==0){
      ll aa=n/a;
      ll hu=max(aa,a);
       hu=floor(log10(hu)+1);
      ans=min(ans,hu);
      
    }
    a--;
  }

  
  
}
 cout<<ans<<endl;

return 0;
}

Measured memory_bytes: 3900
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;

import com.sun.org.apache.xalan.internal.xsltc.compiler.Pattern;

import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			int answer = 0;
			int max = 0;
			for(int i = 0; i < N; i++) {
				final int H = sc.nextInt();
				answer += H >= max ? 1 : 0;
				max = Math.max(max, H);
			}
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21204
#include <stdio.h>

int main(){
int a,b;
char op;
while(1){
   scanf("%d %c %d",&a,&op,&b);
   if(op=='?') break;
   else if(op=='+') printf("%d\n",a+b);
   else if(op=='-') printf("%d\n",a-b);
   else if(op=='/') printf("%d\n",a/b);
   else if(op=='*') printf("%d\n",a*b);
}
return 0;
}
   
   

Measured memory_bytes: 2712
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC omodtimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long ,long long> ii; 	
typedef complex<long double> com;
 
const ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
    cin >> s;
    vector <ll> power3(s.size()+1);
    vector <ll> power2(s.size()+1);
    power2[0] = 1;
    power3[0] = 1;
    for (int z=1;z<=s.size();z++){
        power2[z] = power2[z-1]*2;
        power3[z] = power3[z-1]*3;
        power2[z] %= mod;
        power3[z] %= mod;
    }
    ll ans = 0;
    ll c = 0;
    for (int z=0;z<s.size();z++){
        if (s[z] == '1'){
            ans += power2[c]*power3[s.size()-z-1];
            ans %= mod;
            c++;
        }
    }
    ans += power2[c];
    ans %= mod;
    cout << ans << endl;
}

Measured memory_bytes: 2000
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &e: a) cin >> e;

    int cnt = count_if(a.begin(), a.end(), [](int e){return e < 0;});

    ll ans = 0;
    for (auto &e: a) ans += abs(e);
    if (cnt % 2 == 1) {
        int d = 1e9+1;
        for (auto &e: a) d = min(d, abs(e));
        ans -= d * 2;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define pb push_back
#define ppb pop_back
#define vi vector<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define ren(i,n) for(int i=n-1;i>=0;i--)
#define iter(it,v) for(auto it:v)
#define iterp(it,v) for(auto it=v.begin(),it!=v.end();it++)
#define itern(it,v) for(auto it=v.rbegin();it!=v.rend();it++)
#define w(n) while(n--)
#define forp(i,a,b) for(int i=a;i<=b;i++)
#define forn(i,a,b) for(int i=a;i>=b;i--)
#define sc(a) scanf("%d",&a)
#define pf(a) printf("%d",a)
#define init(a,r) for(auto&i:a) i=r;
#define initi(a,r) memset(a,r,sizeof(a))
#define inpt(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define inp(a) for(int&i:a) cin>>i;
#define diss(a) for(int i:a) cout<<i<<' ';
#define disn(a) for(int i:a) cout<<i<<'\n';
#define debug(a) cout<<#a<<": ";for(auto i:a)cout<<i<<" ";cout<<'\n';
#define mpii map<int,int>
#define sii set<int>
#define ub upper_bound
#define lb lower_bound
#define bs binary_search
#define all(v) v.begin(),v.end()
#define bitc __builtin_popcount
#define fst ios::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define pq priority_queue
#define pii pair<int,int>
#define cs(a) cout<<a<<' '
#define cn(a) cout<<a<<'\n'
#define deb(a,b) cout<<a<<' '<<b<<endl;
#define yy "YES"
#define nn "NO"
#define ff first
#define ss second
typedef long long ll;
const int mod=1e9+7,mod1=998244353;
const int N=3e3+6;
int ar[N];
int dp[N][N];
string s1,s2;
int n,m;
int solve(int i,int j){
    if(i>=n||j>=m)
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    if(s1[i]==s2[j]){
        return dp[i][j]=1+solve(i+1,j+1);
    }
    return dp[i][j]=max(solve(i+1,j),solve(i,j+1));
}
void a_b_l(){
    cin>>s1>>s2;
    n=s1.length(),m=s2.length();
    initi(dp,-1);
    solve(0,0);
    string ans="";
    int i=0,j=0;
    while(i<n&&j<m){
        if(s1[i]==s2[j]){
            ans.pb(s1[i]);
            i++;
            j++;
            continue;
        }
        if(i+1==n){
            j++;
            continue;
        }
        if(j+1==m){
            i++;
            continue;
        }
        if(dp[i+1][j]>dp[i][j+1])
            i++;
        else if(dp[i][j+1]>dp[i+1][j])
            j++;
        else{
            //i++;
            j++;
        }
    }
    cn(ans);
}
signed main(){
    fst;
    int t=1;
    //cin>>t;
    w(t)
    	a_b_l();
}

Measured memory_bytes: 71040
import java.util.Scanner;

public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a > b) {
            System.out.println(b);
        } else {
            System.out.println(a);
        }

        if (n - a - b < 0) {
            System.out.println(-1 * (n - a - b));
        } else {
            System.out.println(0);
        }
    }
}

Measured memory_bytes: 21972
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]


n = int(input())
a = int(input())

print(n*n-a)



Measured memory_bytes: 8992
import sys
from collections import Counter
sys.setrecursionlimit(10000)

N = int(input())
a = list(map(int, input().split()))
dp = [[[-1 for i in range(N+1)] for j in range(N+1)] for k in range(N+1)]

def rec(i, j, k):
    if dp[i][j][k] >= 0:
        return dp[i][j][k]
    if i == 0 and j == 0 and k == 0:
        return 0.0
    res = 0.0
    if i > 0:
        res += rec(i-1, j, k) * i
    if j > 0:
        res += rec(i+1, j-1, k) * j
    if k > 0:
        res += rec(i, j+1, k-1) * k
    res += N
    res *= 1.0/(i+j+k)

    dp[i][j][k] = res
    return res

c = Counter(a)
one, two, three = c[1], c[2], c[3]
print(rec(one, two, three))


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

using namespace std;

typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, K, C;
    string S;
    cin >> N >> K >> C;
    cin >> S;
    
    vector<int> fromFront(K);
    vector<int> fromBack(K);
    int last = -C-1;
    int frontIndex = 0;
    for(int i = 0 ; i < S.size(); ++i){
        if(S[i] == 'o' && i-last > C){
            fromFront[frontIndex] = i;
            ++frontIndex;
            last = i;
        }
        if(frontIndex == K){
            break;
        }
    }
    last = N + C;
    int backIndex = K - 1;
    for(int i = S.size() - 1 ; i >= 0; --i){
        if(S[i] == 'o' && last - i > C){
            fromBack[backIndex] = i;
            --backIndex;
            last = i;
        }
        if(backIndex == -1){
            break;
        }
    }

    for(int i = 0 ; i < K ; ++i){
        if(fromFront[i] == fromBack[i]){
            cout << fromFront[i] + 1 << endl;
        }
    }
    return 0;

}

Measured memory_bytes: 3348
from math import sqrt
from bisect import bisect_right

def eratos(n):
    L = [True for _ in range(n+1)]
    L[0],L[1] = False,False

    for i in range(2,int(sqrt(n))+1):
        if L[i]:
            for j in range(2,n//i+1):
                L[i*j] = False

    P = []
    for i in range(n+1):
        if L[i]:
            P.append(i)

    return P

def isPrime(n):
    if n == 1:
        return False

    for i in range(2,int(sqrt(n))+1):
        if n % i == 0:
            return False
    return True

def sim(P):
    #ソート済み素数リストを受け取って後半の条件も満たすやつのリストを計算
    P_sim = []
    for i in range(len(P)):
        if isPrime((P[i]+1)//2):
            P_sim.append(P[i])

    return P_sim

def main():
    Q = int(input())

    P = eratos(10**5)
    P_sim = sim(P)

    ans_L = []
    for i in range(Q):
        l,r = map(int,input().split())
        ans = bisect_right(P_sim,r)-bisect_right(P_sim,l-1)
        ans_L.append(ans)

    for i in range(Q):
        print(ans_L[i])

if __name__ == "__main__":
    main()


Measured memory_bytes: 8220
import sys
from string import ascii_lowercase

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    
    ans = []
    while N:
        N, r = divmod(N, 26)
        if r == 0:
            r = 26
            N -= 1
        ans.append(ascii_lowercase[r-1])
    
    print(''.join(reversed(ans)))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9968
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define mod 1000000007
const int N=22;

ll n;
vector<vector<ll> > compat(N,vector<ll>(N));
ll dp[N][(1<<N)];

ll solve(ll i,ll wom_sub){
	if(i==n+1){
		if(wom_sub==0)
		return 1;
	    return 0;
	}
	
	if(dp[i][wom_sub]!=-1)
	return dp[i][wom_sub];
	
	ll ans=0;
	
	for(ll wom=0;wom<n;wom++){
		bool avail = (((1<<wom)&(wom_sub))==0)?0:1;
		if(avail && compat[i][wom+1]){
			ans=(ans+solve(i+1,wom_sub ^ (1<<wom)))%mod;
		}
	}
	return dp[i][wom_sub]=ans;
}

int main(){
	cin>>n;
	
	for(ll i=1;i<=n;i++){
		for(ll j=1;j<=n;j++){
			cin>>compat[i][j];
		}
	}
	memset(dp,-1,sizeof(dp));
	cout<<solve(1,(1<<n) - 1)<<endl;
	
}

Measured memory_bytes: 721152
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String S = sc.next();

		String ans = "AC";

		int c = 0;
		for (int i = 2; i < S.length() - 1; i++) {
			if (S.substring(i, i + 1).equals("C")) {
				c++;
			} else if (Character.isUpperCase(S.charAt(i))) {
				c = 2;
			}
		}

		if (Character.isUpperCase(S.charAt(1)) || Character.isUpperCase(S.charAt(S.length() - 1))
				|| !S.substring(0, 1).equals("A")
				|| S.substring(1, 2).equals("C")
				|| S.substring(S.length() - 1, S.length()).equals("C") || c != 1) {
			ans = "WA";
		}

		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 23124
#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    int s = 0, maxi = 0;
    for (int i = 0; i < n; ++i)
    {
        int x;
        cin >> x;
        s += x;
        maxi = max(maxi, x);
    }
    if (maxi < s - maxi)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


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

int main(){
  string s;
  cin >> s;

  int n = s.size();
  reverse(s.begin(),s.end());

  string dream = "dream";
  string dreamer = "dreamer";
  string erase = "erase";
  string eraser = "eraser";
  reverse(dream.begin(),dream.end());
  reverse(dreamer.begin(),dreamer.end());
  reverse(erase.begin(),erase.end());
  reverse(eraser.begin(),eraser.end());

  int i = 0;
  while(i<n){
    if(n-i<5){
      cout << "NO" << endl;
      return 0;
    }
    string sub = s.substr(i,5);
    if(sub==dream || sub==erase){
      i+=5;
      continue;
    }
    if(n-i<6){
      cout << "NO" << endl;
      return 0;
    }
    sub = s.substr(i,6);
    if(sub==eraser){
      i+=6;
      continue;
    }
    if(n-i<7){
      cout << "NO" << endl;
      return 0;
    }
    sub = s.substr(i,7);
    if(sub==dreamer){
      i+=7;
      continue;
    }
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;  
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int n;
	int i;
	int s = 0;
	
	while (scanf("%d %d %d", &a, &b, &n) != EOF){
		for( i = 0; i < n; i++){
			a *= 10;
			s += (a / b) % 10;
			a %= b;
		}
		
		printf("%d\n", s);
		s = 0;
	}
	
	return (0);
}

Measured memory_bytes: 596
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

int main(){
    int k,a,b; cin >> k >> a >> b;
    for(int i=a;i<=b;i++){
        if(i % k == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

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

int main(){
    int N ;
    cin >> N ;
    ll X[N] ,A[N] , R[N] , L[N] ;
    rep(i,N) cin >> X[i] >> A[i] ;
    rep(i,N){
        L[i] = X[i] - A[i] ;
        R[i] = X[i] + A[i] ;
    } 
    vector<pair< ll , ll >> P ;
    rep(i,N) P.push_back(make_pair(R[i],L[i])) ;
    sort(P.begin(),P.end()) ;
    ll ans = P[0].first;
    ll count = 1 ;
    for(int i = 1 ; i < N ; i++ ){
        if( ans <= P[i].second ){
            ans = P[i].first ;
            count++ ;
        }
        else continue ;
    }
    cout << count << endl;
}

Measured memory_bytes: 5492
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <algorithm>

using namespace std;

typedef pair<int,int>P;

int N;
deque<P>card;

int main(){
  while(scanf("%d", &N) && N){
    card.clear();
    card.push_back(P(1,N));
    int m,p,q,r;
    scanf("%d%d%d%d",&m,&p,&q,&r);
    for(int i=0;i<m;i++){
      int x,y; scanf("%d%d",&x,&y);
      deque<P>A,B,C;
      int pos = 0;
      while(pos <= x){
	if(pos + (card[0].second-card[0].first+1) > x){
	  A.push_back(P(card[0].first, card[0].first+x-pos-1));
	  card[0].first += x-pos;
	  pos = x+1;
	  break;
	}
	pos += card[0].second-card[0].first+1;
	A.push_back(card[0]);
	card.pop_front();
      }
      while(pos <= y){
	if(pos + (card[0].second-card[0].first+1) > y){
	  B.push_back(P(card[0].first, card[0].first+y-pos));
	  card[0].first += y-pos+1;
	  pos = y+1;
	  break;
	}
 	pos += card[0].second-card[0].first+1;
	B.push_back(card[0]);
	card.pop_front();
      }    
      card.insert(card.end(), B.begin(), B.end());
      card.insert(card.end(), A.begin(), A.end());
    }
    
    //    for(int i=0;i<card.size();i++) printf("%d %d\n", card[i].first, card[i].second);
    int pos = 1;
    int res = 0;
    for(int i=0;i<card.size();i++){
      if(p <= pos && pos <= q){
	//	printf("%d 1\n", i);
	if(pos + card[i].second-card[i].first+1 < q){
	  if(card[i].first <= r && card[i].second <= r) res += card[i].second-card[i].first+1;
	  else if(card[i].first <= r) res += r-card[i].first+1;
	}else if(pos + card[i].second-card[i].first+1 >= q){
	  int vl = card[i].first, vr = card[i].first+q-pos;
	  //	  printf("%d %d %d\n",pos, vl ,vr);
	  if(vl <= r && vr <= r) res += vr-vl+1;
	  else if(vl <= r) res += r-vl+1;
	}
	//	printf("%d\n", res);
      }else if(pos + card[i].second-card[i].first+1 > p && pos <= q){
	//	printf("%d 2\n", i);
	int vl = card[i].first + p-pos;
	//	printf("vl %d\n", vl);
	if(pos + card[i].second-card[i].first+1 < q){
	  if(vl <= r && card[i].second <= r) res += card[i].second-vl+1;
	  else if(vl <= r) res += r - vl + 1;
	}else if(pos + card[i].second - card[i].first+ 1 >= q){
	  int vr = vl + q - pos;
	  if(vl <= r && vr <= r) res += vr-vl+1;
	  else if(vl <= r) res += r-vl+1;
	}
	//	printf("%d\n", res);
      }
      pos += card[i].second-card[i].first+1;
    }
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

vector<P> g[55];
vector<int> dfs(int from, int to, int pre = -1){
  for (auto p : g[from]) {
    if (p.first == pre) continue;
    if (to == p.first) {
      return {p.second};
    }
    vector<int> ans = dfs(p.first,to,from);
    if (!ans.empty()) {
      ans.push_back(p.second);
      return ans;
    }
  }
  return {};
}

int main() {
  int n,m;
  cin >> n;
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    --a; --b;
    g[a].emplace_back(b,i);
    g[b].emplace_back(a,i);
  }

  cin >> m;
  vector<ll> eset(m);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    --a; --b;
    vector<int> v = dfs(a,b);
    for (int e : v) eset[i] |= 1ll << e;
  }

  ll ans = 0;
  rep(i,1<<m){
    ll mask = 0;
    rep(j,m) if (i>>j&1) mask |= eset[j];
    
    int white = __builtin_popcountll(mask);
    ll cnt = 1ll << (n-1-white);
    if (__builtin_popcountll(i)%2==0) {
      ans += cnt;
    } else {
      ans -= cnt;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll n,c[4]={};
  string s;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> s;
    if(s=="AC") c[0]++;
    if(s=="WA") c[1]++;
    if(s=="TLE") c[2]++;
    if(s=="RE") c[3]++;
  }
  cout << "AC x "<<c[0]<<endl;
  cout << "WA x "<<c[1]<<endl;
  cout << "TLE x "<<c[2]<<endl;
  cout << "RE x "<<c[3]<<endl;
}


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

int main() {
  int N; cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N);
  
  for(int i = 0; i < N; ++i){
    cin >> A.at(i);
  }
  
  for(int i = 0; i < N; ++i){
    cin >> B.at(i);
  }
  
  for(int i = 0; i < N; ++i){
    cin >> C.at(i);
  }
  
  int res = 0;
  
  for(int i = 0; i < N; ++i){
    res += B.at(A.at(i)-1);
    if(i != 0){
      if(A.at(i) - A.at(i-1) == 1){
        res += C.at(A.at(i-1)-1);
      }
    }
  }
  
  cout << res << endl;
}

Measured memory_bytes: 256
n=int(input())
a=[int(input()) for i in range(n)]
max1=sorted(a)[-1]
if n==2:
    print(a[1])
    print(a[0])
elif sorted(a)[-2]!=max1:
    max=sorted(a)
    max2=0
    for i in range(2,n):
        if max[-i]!=max1:
            max2=max[-i]
            break
    for i in range(n):
        if a[i]==max1:
            print(max2)
        else:
            print(max1)
else:
    for i in range(n):
        print(max1)


Measured memory_bytes: 14676
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
  fio();
  string s, t; 
 	cin>>s>>t;
  forn(i,s.size()){
  	if(s[i]!=t[i]){
  		cout<<"No"<<endl;
  		return 0;
  	}
  }
  if(s.size()==t.size()-1) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}

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

#define  int        long long int
 #define    sp(x)                 setprecision(x)
#define    bp(x)           __builtin_popcount(x)
 #define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff             first
#define  ss             second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
 #define  endl    "\n"
#define  mod  1000000007
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0)  
    {     
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res; 
}
int a[1000005];
int32_t main()
{
    fast
    f(i,1,100)
        f(j,1,100)
            f(k,1,100)
                a[i*i +j*j +k*k +i*j +j*k +k*i]++;
    int n;
    cin>>n;
    f(i,1,n)
        cout<<a[i]<<endl;
}

Measured memory_bytes: 4052
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

class UnionFind {
  vector<ll> par, rank; // par > 0: number, par < 0: -par
public:
  void init(ll n) {
    par.resize(n, 1); rank.resize(n, 0);
  }
  ll getSize(ll x) {
    return par[find(x)];
  }
  ll find(ll x) {
    if (par[x] > 0) return x;
    return -(par[x] = -find(-par[x]));
  }
  void merge(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (rank[x] < rank[y]) {
      par[y] += par[x];
      par[x] = -y;
    } else {
      par[x] += par[y];
      par[y] = -x;
      if (rank[x] == rank[y]) rank[x]++;
    }
  }
  bool isSame(ll x, ll y) {
    return find(x) == find(y);
  }
};
ll N,K,L;
map<P,ll> cnt;
int main(){
    cin>>N>>K>>L;
    UnionFind uf1,uf2;
    uf1.init(N);uf2.init(N);
    for(ll i=0;i<K;i++){
        ll p,q;
        cin>>p>>q;
        p--;q--;
        uf1.merge(p,q);        
    }
    for(ll i=0;i<L;i++){
        ll r,s;cin>>r>>s;r--;s--;
        uf2.merge(r,s);
    }
    for(ll i=0;i<N;i++){
        cnt[P(uf1.find(i),uf2.find(i))]++;
    }
    for(ll i=0;i<N;i++){
        cout<<cnt[P(uf1.find(i),uf2.find(i))]<<endl;
    }
    return 0;
}

Measured memory_bytes: 18048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios :: sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    vector <int> a(n);
    for (int i = 0; i < n; ++ i) cin >> a[i];
    vector <int> ps;
    for (int i = 0; i < n; ++ i) if (a[i] == i + 1) ps.push_back(i);
    int ans = ps.size();
    vector <int> use(ps.size(), 1);
    for (int i = 1; i < ps.size(); ++ i) {
        if (ps[i] == ps[i - 1] + 1 && use[i - 1]) -- ans, use[i] = 0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1528
#include <iostream>
#include <algorithm>
#include <cstdio>
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
using namespace std;

int main() {
	while(true){
		int h, w;
		cin >> h >> w;
		if(h == 0 && w == 0)break;
		REP(i, h){
			REP(j, w){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3108
a,b = map(int,input().split())
set1 = [1,3,5,7,8,10,12]
set2 = [4,6,9,11]
set3 = [2]
if a in set1 and b in set1:
  print("Yes")
  exit()
if a in set2 and b in set2:
  print("Yes")
  exit()
if a in set3 and b in set3:
  print("Yes")
  exit()
print("No")

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

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

    long long w[n];

    for(long long i = 0; i < n; i++) cin >> w[i];

    long long minv = 1e9;
    for(long long t = 1; t < n; t++){
        long long s1 = 0, s2 = 0;
        for(long long i = 0; i < n; i++){
            if(i <= t) s1 += w[i];
            else s2 += w[i];
        }
        minv = min(minv, abs(s1-s2));
    }

    cout << minv << endl;
    return 0;
}

Measured memory_bytes: 3616
x , y = map(int,input().split())
list1 = [1,3,5,7,8,10,12]
list2 = [4,6,9,11]
list3 = [2]

if x in list1:
	print('Yes' if y in list1 else 'No')
if x in list2:
	print('Yes' if y in list2 else 'No')
if x in list3:
	print('Yes' if y in list3 else 'No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repc(i, b, e) for(auto i = (b); i != (e); i++)

int main() {
    string S;
    ll N, K;
    cin >> N;
    cin >> S;
    cin >> K;
    repc(i, S.begin(), S.end()) {
        if(*i != S.at(K - 1)) {
            *i = '*';
        }
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

int main()
{
	int K,S;
	cin>>K>>S;
	int X,Y,Z,Xcrit,Ycrit,Zcrit;
	int ans = 0;
	Xcrit = min(K,S);
	for(X=0; X <= Xcrit; X++){
		Ycrit = min(S-X,K);
		for(Y=0; Y <= Ycrit; Y++){
			Z = (S - X - Y);
			if( Z <= K){
				ans++;
				//cout<<"X= "<<X<<" Y="<<Y<<" Z="<<Z<<endl;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>


using namespace std;

int main() {
    long long int ans = 0;
    vector<long long int> D(3);
    cin >> D[0] >> D[1] >> D[2];

    sort(D.begin(), D.end());

    if (D[0] * D[1] * D[2] % 2 == 0) {
        ans = 0;
    }
    else {
        ans = D[0] * D[1];
    }

    cout << ans;

    return 0;
}

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

int main() {
	int i, j, a, n, c=0;
	int min=0, max=0, iroin[8], iroax[8];
	scanf("%d", &n);
	memset(iroin, 0, sizeof(iroin));
	memset(iroax, 0, sizeof(iroax));

	for (i=0; i < n ;i++) {
		scanf("%d", &a);
		if (a/400 >= 8) {
			c++;
		} else {
			if (!iroax[a/400]) {
				max++;min++;
				iroax[a/400] = 1;
				iroin[a/400] = 1;
			}
		}
	}

	for (i=0; i < c ;i++) {
		max++;
		for (j=0; j < 8 ;j++) if (iroin[j]) break;
		if (j == 8) {
			iroin[0] = 1;
			min++;
		}
	}
	printf("%d %d\n", min, max);
	return 0;
}

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

int main()
{
    int a,b,k;
    cin>>a>>b>>k;
    for(int i=1; i<=k; i++)
    {
        if(i%2)
        {
            if(a&1)
                a-=1;
            b+=a/2;
            a-=a/2;
        }
        else
        {
            if(b&1)
                b-=1;
            a+=b/2;
            b-=b/2;
        }
    }
    printf("%d %d\n",a,b);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    cout << min(c, b/a) << endl;
}

Measured memory_bytes: 256