akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define int int64_t
#define watch(x) cout << (#x) << " is " << (x) << endl

const int32_t MAX=1e9+7;
typedef vector<int> vi;
typedef vector<int64_t> vll;

int32_t main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed;

    //Problem code start

    int n,k;
    cin >> n >> k;
    vi h(n+1);
    for(int i=1;i<=n;i++) cin >> h[i];
    vi dp(n+1);
    dp[n]=0;
    for(int i=n-1;i>0;i--){
        int current=MAX, ans=MAX;
        for(int j=1;j<=k;j++){
            if(i+j<=n){
                current=dp[i+j] + abs(h[i]-h[j+i]);
            }
            ans=min(ans,current);
        }
        dp[i]=ans;
    }
    cout << dp[1];
    return 0;
}

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

int main() {
  int N,ans=0,cnt=0;
  cin >> N;
  for(int i=1;i<=N;i+=2){
    cnt=0;
    for(int j=1;j<=N;j++){
      if(i%j==0) cnt++;
    }
    if(cnt==8) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class P
{
    static void Main()
    {
        long[] qhsd = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long n = long.Parse(Console.ReadLine());
        if (qhsd[1] > qhsd[0] * 2)
        {
            qhsd[1] = qhsd[0] * 2;
        }
        if (qhsd[2] > qhsd[1] * 2)
        {
            qhsd[2] = qhsd[1] * 2;
        }
        if (qhsd[3] > qhsd[2] * 2)
        {
            qhsd[3] = qhsd[2] * 2;
        }
        Console.WriteLine(qhsd[3] * (n/2) + qhsd[2] * (n % 2));
    }
}

Measured memory_bytes: 13268
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
# inf = float('inf') ;mod = 10**9+7
# mans = inf ;ans = 0 ;count = 0 ;pro = 1
from heapq import heappush,heappop

n,q=map(int,input().split())
STX=[tuple(map(int,input().split())) for i in range(n)]
D=[int(input()) for i in range(q)]
event=[]
for si,ti,xi in STX:
  event.append((si-xi,0,xi))
  event.append((ti-xi,-1,xi))
for di in D:
  event.append((di,1,di))
event.sort()
hq=[]; S=set()
for time, query, number in event:
  if query == 0:
    heappush(hq,number)
    S.add(number)
  elif query == -1:
    S.remove(number)
  else:
    while hq and hq[0] not in S:
      heappop(hq)
    if not hq:
      print(-1)
    else:
      print(hq[0])




Measured memory_bytes: 120128
h, w = (int(x) for x in input().split())
ab=[]
ab.append(['#']*(w+2))
for _ in range(h):
    s=input()
    s=list(s)
    s =['#'] + s + ['#']
    ab.append(s)
ab.append(['#']*(w+2))

for i in range(h+2):
    k=ab[i]
    print(''.join(map(str,k)))


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

int main() {
  int a, b;
  int counter = 0;
  cin >> a >> b;
  for (int i = a; i <= b; i++) {
    int digit1 = i % 10;
    int digit2 = (i % 100) / 10;
    int digit4 = (i % 10000) / 1000;
    int digit5 = i / 10000;
    if (digit1 == digit5 && digit2 == digit4) counter++;
  }
  cout << counter << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
/* TLEだった orz 
int main() {
  ll N; cin >> N;
  ll val = 357, cnt = 0;
  while (N >= val) {
    string s = to_string(val);
    bool three=false,five=false,seven=false,ok=true;
    for(int i=0; i < s.size(); i++) {
      if(s[i]=='3')three=true;
      else if(s[i]=='5')five=true;
      else if(s[i]=='7')seven=true;
      else ok = false;
    }
    if(three&&five&&seven&&ok){
      cnt++;
      //cout<<"s = "<<s<<endl;
      //printf("cnt=%d\n",cnt);
    }
    val++;
  }
  cout << cnt << endl;
} 
*/
int N, ans;
void dfs(ll x,bool flag3,bool flag5,bool flag7) {
    if(x > N) {
        return ;
    }
    if(flag3 && flag5 && flag7) {
        ans++;
    }
    dfs(x*10+3, true, flag5, flag7);
    dfs(x*10+5, flag3, true, flag7);
    dfs(x*10+7, flag3, flag5, true);
}
int main() {
    cin >> N;
    dfs(0,0,0,0);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int a[12][12];
int main(){
    int n, m, x;
    cin >> n >> m >> x;
    vector<int>c(n);
    rep(i,n){
        cin >> c[i];
        rep(j,m){
            cin >> a[i][j];
        }
    }
    int ans = INT_MAX;
    for(int i = 0; i < 1 << n; i++){
        vector<int> d(m);
        int temp = 0;
        for(int j = 0; j < n; j++){
            if(i>>j&1){
                temp += c[j];
                for(int k = 0; k < m; k++){
                    d[k] += a[j][k];
                }
            }
        }
        bool f = true;
        
        for(int j = 0; j < m; j++){
            if(d[j]<x)f = false;
        }
        if(f)ans = min(ans, temp);
    }
    if(ans == INT_MAX)ans = -1;
    cout << ans << endl;
}


Measured memory_bytes: 3616
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    Queue<Double> pq = new PriorityQueue<>();
    for(int i = 0; i < N; i++){
      pq.add(Double.parseDouble(sc.next()));
    }
    
    while(pq.size() > 1){
      double a = pq.poll();
      double b = pq.poll();
      pq.add((a+b)/2);
    }
    
    System.out.println(pq.poll());
  }
}

Measured memory_bytes: 23764
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int K;

signed main(){
    cin >> K;
    rep(i, K) cout << "ACL";
}

Measured memory_bytes: 3584
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
ll fact[N];
ll invfact[N];
ll inv[N];
void factorialsComputation()
{
    inv[0]=inv[1]=1;
    fact[0]=fact[1]=1;
    invfact[0]=invfact[1]=1;
    for(int i=2;i<N;i++)
    {
        inv[i]=(inv[mod%i]*(mod-mod/i))%mod;
        fact[i]=(fact[i-1]*i)%mod;
        invfact[i]=(invfact[i-1]*inv[i])%mod;
    }
}
ll ncr(ll n,ll r)
{
    ll ans=fact[n];
    ans*=invfact[r];
    ans%=mod;
    ans*=invfact[n-r];
    ans%=mod;
    return ans;
}
void solve()
{
    ll n,a,b,c;
    cin>>n>>a>>b>>c;
    ll ans=0;
    ll sum=a+b;
    a=(a*100*inv[sum]);
    a%=mod;
    b=(b*100*inv[sum]);
    b%=mod;
    for(ll m=n;m<=2*n-1;m++)
    {
        ll temp=ncr(m-1,n-1);
        temp*=(100*m);
        temp%=mod;
        temp*=inv[100-c];
        temp%=mod;
        ll mult1=power(a,n)*power(b,m-n);
        mult1%=mod;
        mult1*=modInverse(power(100,m));
        mult1%=mod;
        ll mult2=power(a,m-n)*power(b,n);
        mult2%=mod;
        mult2*=modInverse(power(100,m));
        mult2%=mod;
        temp*=(mult2+mult1);
        temp%=mod;
        ans+=temp;
        ans%=mod;
    }
    cout<<ans<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    factorialsComputation();
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 27240
import itertools
import numpy as np

N = int(input())
P = [int(n) for n in input().split(' ')]
Q = [int(n) for n in input().split(' ')]

R = [n for n in range(1, N+1)]
R_P = itertools.permutations(R)

a = 0
for i, temp in enumerate(R_P):
    if P == list(temp):
        a = i+1
    if Q == list(temp):
        b = i+1
ans = np.abs(a-b)

print(ans)

Measured memory_bytes: 21204
cond = [int(n) for n in input().split(" ")]

while True:
    case = []
    cards = [n for n in range(1,cond[0] + 1)]
    cards.sort(reverse = True)
    for c in range(cond[1]):
        case = [int(n) for n in input().split(" ")]
        case[0] -= 1
        #print(cards[case[0]:case[0]+case[1]],cards[case[1]:case[0]+case[1]],cards[:case[1]],cards[:case[1]])
        disp = cards[case[0]:case[0]+case[1]]
        cards[case[1]:case[0]+case[1]] = cards[0:case[0]]
        cards[0:case[1]] = disp
    else:
        print(cards[0])
        cond = [int(n) for n in input().split(" ")]
        if cond[0] == 0 and cond[1] == 0:
            break
        else:
            continue

Measured memory_bytes: 7664
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////


void solve(){
    ll a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    set<ll> se;
    rp(i,1500){
        rp(j,1500){
            se.insert(i*c+j*d);
        }
    }
    double ratio=0.0;
    ll ans_gro=100*a;
    ll ans_sug=0;
    for(ll i=0; i<=f/100; i++){
        for(ll j=0; j<=f/100-i*a; j++){
            ll rest=f-100*(i*a+j*b);
            if(rest<0) continue;
            auto it=se.upper_bound(min(rest,(i*a+j*b)*e));
            if(it==se.begin()) continue;
            it--;
            if(chmax(ratio,(double)*it/(double)(100*(i*a+j*b)+*it))){
                ans_gro=100*(i*a+j*b)+*it;
                ans_sug=*it;
            }
        }
    }
    cout << ans_gro << " " << ans_sug << endl;
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 7184
import sys
input = sys.stdin.readline

n, l = map(int, input().split())
sum = 0
ans = [0]*n
apple = [0]*n
for i in range(n):
    apple[i] = l+i
    sum += apple[i]
    ans[i] = abs(apple[i])
print(sum-apple[ans.index(min(ans))])

Measured memory_bytes: 3064
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;

typedef long long ll;

// is_prime[i] が true なら i は月曜土曜素数
bool prime_table[300005];

void sieve(int n) {
  for (int i = 0; i <= n; i++) { prime_table[i] = false; }
  for (int i = 7; i <= n; i+=7) {
    prime_table[i-1] = true;
    prime_table[i+1] = true;
  }

  for (int i = 7; i <= n; i += 7) {
    if (prime_table[i-1]) {
      for ( int j = 2 * (i-1); j <= n; j += (i-1) ) {
        prime_table[j] = false;
      }
    }
    if (prime_table[i+1]) {
      for ( int j = 2 * (i+1); j <= n; j += (i+1) ) {
        prime_table[j] = false;
      }
    }
  }
}

int main() {
  sieve(300003);

  int n;
  while (cin >> n) {
    if (n == 1) { break; }
    cout << n << ":";
    rep(i, n+1) {
      if (prime_table[i] && n % i == 0) {
        cout << " " << i;
      }
    }
    cout << endl;
  }

  return 0;
}



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

int main (){
    int H, W;
    cin >> H >> W;
    vector<vector<char>> masu(H, vector<char>(W));
    for(int i=0; i<H; ++i){
        for(int j=0; j<W; ++j){
            char temp;
            cin >> temp;
            if(temp=='#') masu.at(i).at(j)='#';
            else masu.at(i).at(j) = '0';
        }
    }
    
    for(int i=0; i<H; ++i){
        for(int j=0; j<W; ++j){
            if(masu.at(i).at(j)=='#') continue;
            for(int x=i-1; x<=i+1; ++x){
                for(int y=j-1; y<=j+1; ++y){
                    if(0<=x && x<H && 0<=y && y<W){
                        if(masu.at(x).at(y)=='#')
                            ++masu.at(i).at(j);
                    }
                }
            }
        }
    }

    for(int i=0; i<H; ++i){
        for(int j=0; j<W; ++j){
            cout << masu.at(i).at(j);
        }
        cout << endl;
    }
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
 
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  
  if (b/a >= c) {
    cout << c << endl;
  }else{
    cout << b/a << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    long long r,d,init;
    cin >> r >>d >>init;
    int  ans,tmp;
    tmp=init;
    for (int i=0;i<10;i++){
        ans=r*tmp-d;
        cout << ans <<endl;
        tmp=ans;
    }



    return 0;
}


Measured memory_bytes: 256
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,a[20]={},x[20][20]={},y[20][20]={},ans=0,f;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    for(int j=0; j<a[i]; j++) {
      cin >> x[i][j] >> y[i][j];
    }
  }
  for(int i=0; i<(1<<n); i++) {
    f=1;
    for(int j=0; j<n; j++) {
      if(i&(1<<j)) {
        for(int k=0; k<a[j]; k++) {
         if(!y[j][k]&&i&(1<<x[j][k]-1)) {
            f=0;
          }
          if(y[j][k]&&!(i&(1<<x[j][k]-1))) {
            f=0;
          }
        }
      }
    }
    if(f) {
      ans=max(ans,__builtin_popcount(i));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#define ll long long
#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
using namespace std;

string str;
vector<string> v;

std::vector<std::string> split(const std::string &str, char sep)
{
            std::vector<std::string> v;
                std::stringstream ss(str);
                    std::string buffer;
                        while( std::getline(ss, buffer, sep) ) {
                                        v.push_back(buffer);
                                            }
                            return v;
}



int main(){
        cin >> str;
        v=split(str,'/');
        //cout << stoi(v[0]) << stoi(v[1]) << stoi(v[2]) << endl;
        if(stoi(v[0]) > 2019){
                cout << "TBD" << endl;
        }else if(stoi(v[0]) == 2019){
                if(stoi(v[1]) >= 5){
                cout << "TBD" << endl;
                }else{
                cout << "Heisei" << endl;
                }
        }else{
                cout << "Heisei" << endl;
        }

       
        return 0;
}


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

typedef long long LL;
typedef pair<int, int> II;

const int MAXN = (int) 1e5 + 10;
int n, a[MAXN];

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

    map<int, int> cnt;
    for (int i = 1; i <= n; ++i) cnt[a[i]]++;

    int ans = 0;
    for (map<int, int>::iterator it = cnt.begin(); it != cnt.end(); ++it) {
        int val = it->first;
        int frq = it->second;
        if (frq >= val) ans += frq - val; else ans += frq;
    }
    printf("%d\n", ans);
    return 0;
}

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

int main()
{
  string sss;
  int ans=1000;
  cin>>sss;
  for(int i=0;i<sss.size()-2;i++){
    ans = min(ans,abs((sss.at(i) -'0') * 100 + (sss.at(i+1)-'0') *10 +(sss.at(i+2)-'0') - 753));
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
X = gets.to_i

if X < 600
  puts 8
elsif X < 800
  puts 7
elsif X < 1000
  puts 6
elsif X < 1200
  puts 5
elsif X < 1400
  puts 4
elsif X < 1600
  puts 3
elsif X < 1800
  puts 2
else
  puts 1
end


Measured memory_bytes: 14372
#include <iostream>

using namespace std;

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

	if (a < b)
	{
		cout << "a < b" << endl;
	}
	else if (a > b)
	{
		cout << "a > b" << endl;
	}
	else
	{
		cout << "a == b" << endl;
	}
}


Measured memory_bytes: 3076
#include <iostream>
using namespace std;
int main(void){
    
    char moji[3][3];
    
    cin>>moji[0][0]>>moji[0][1]>>moji[0][2];
    cin>>moji[1][0]>>moji[1][1]>>moji[1][2];
    cin>>moji[2][0]>>moji[2][1]>>moji[2][2];
    
    cout<<moji[0][0]<<moji[1][1]<<moji[2][2]<<endl;
    
    return 0;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
constexpr int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
using ld= long double;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vi v(n);
	REP(i, n)cin >> v[i];
	sort(ALL(v));
	
	ld ans= 0, t = 2;
	RREP(i, n) {
		ans += v[i] / t;
		t *= 2;
	}
	ans += 2 * v[0] / t;
	cout << fixed << setprecision(12) << ans << endl;
}

Measured memory_bytes: 256
//============================================================================
// Name        : ABC_A.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
	int A,B,Max;
	cin >> A;
	cin >> B;
	Max =max(A*B, A+B);
	Max = max(Max, A-B);

	cout << Max << endl; // prints !!!Hello World!!!
	return 0;
}


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

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


long N;
int main(){
	cin >> N;
	vector<long> a(N);
	rep(i, N) cin >> a.at(i);
	long idx = 1;
	long unbroken_num = 0;
	rep(i, N){
		if (a.at(i) == idx){
			unbroken_num++;
			idx++;
		}
	}
	//cout << "unbroken_num: " << unbroken_num << endl;
	if (unbroken_num ==0){
		cout << -1 << endl;
	}
	else{
		cout << N - unbroken_num << endl;
	}
	
}

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

int main(){
  string taps;
  cin >> taps;
  
  //奇数文字目
  for(int i=0; i < taps.size(); i+=2){
  	if(taps.at(i) =='L'){
      cout << "No" ;
      return 0;
    }
  }
  
  //偶数文字目
  for(int i=1; i< taps.size(); i+=2){
    
    if(taps.at(i) =='R'){
      cout << "No" ;
      return 0;
    }
  }
  
  cout <<"Yes";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;

int main()
{
    int n;
    cin >> n;
    int count = 0;
    for(int i = 0; i < n; ++i)
    {
        int p;
        cin >> p;
        if(i+1 != p) count += 1;
        if(count > 2)
        {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
    return 0;
}


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

// a^n mod を計算する                                                                                                 
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

// a^{-1} mod を計算する                                                                                              
long long modinv(long long a, long long mod) {
  return modpow(a, mod - 2, mod);
}

int main(){
  int N, K;
  scanf("%d",&N);
  scanf("%d",&K);
  std::vector<long long > C(K+5), D(K+5), E(K+5);
  long long mod = 1000000007;
  C[0] = 1;
  for (int i=1; i<=K; i++){
    C[i] = ((C[i-1]*(N-K+2-i))%mod)*modinv((long long)i,mod);
    C[i] %= mod;
    if (i==1){
      D[i] = 1;
    } else {
      D[i] = (D[i-1]*(K+1-i)%mod)*modinv(i-1,mod);
      D[i] %= mod;
    }
  }
  for (int i=1; i<=K; i++){
    printf("%lld\n",(C[i]*D[i])%mod);
  }
  return 0;
}


Measured memory_bytes: 384
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#define mod 1000000007
using namespace std;
int dp[310][310][310];
bool visited[310][310][310];
int n, m;
int ma(int x, int y, int z) {
	return max(max(x, y), z);
}
int func(int x, int y, int z) {
	int &ret = dp[x][y][z];
	if (ret != -1)return ret;
	if (ma(x, y, z) == n)return 1;
	ret = 0;
	int ch = ma(x, y, z);
	ret += func(ch+1, y, z);
	ret %= mod;
	ret += func(x, ch+1, z);
	ret %= mod;
	ret += func(x, y, ch+1);
	ret %= mod;
	return ret;
}
int main()
{
	memset(dp, -1, sizeof(dp));
	scanf("%d %d", &n, &m);
	while(m--){
		int q, w, e;
		scanf("%d %d %d", &q, &w, &e);
		if (e == 1) {
			for (int i = 0; i <= w; i++) {
				for (int y = 0; y <= w; y++) {
					if (i < q&&y < q)continue;
					dp[w][i][y] = 0;
					dp[i][w][y] = 0;
					dp[i][y][w] = 0;
				}
			}
		}
		else if (e==2)
		{
			for(int i = 0; i <= w; i++) {
				for (int y = 0; y <= w; y++) {
					if ((i >= q && y < q) || (i < q&&y >= q))continue;
					dp[w][i][y] = 0;
					dp[y][w][i] = 0;
					dp[y][i][w] = 0;
				}
			}
		}
		else {
			for (int i = 0; i <=w; i++) {
				for (int y = 0; y <= w; y++) {
					if (i >= q && y >= q)continue;
					dp[w][i][y] = 0;
					dp[i][w][y] = 0;
					dp[i][y][w] = 0;
				}
			}
		}
	}
	printf("%d\n", func(0, 0, 0));
}

Measured memory_bytes: 116992
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

constexpr double EPS = 1e-7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
#define PI (acos(-1))

constexpr int MOD = 1e9 + 7;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}

	bool unionSet(int x, int y) {
		x = root(x);
		y = root(y);
		if (x != y) {
			if (data[y] < data[x]) {
				swap(x, y);
			}
			data[x] += data[y];
			data[y] = x;
		}
		return x != y;
	}

	bool findSet(int x, int y) {
		return root(x) == root(y);
	}

	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}

	int size(int x) {
		return -data[root(x)];
	}
};

int main(int argc, char const *argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int N, K, L;
	cin >> N >> K >> L;

	UnionFind road(N);
	UnionFind rail(N);

	for (int i = 0; i < K; i++) {
		int p, q;
		cin >> p >> q;
		road.unionSet(p - 1, q - 1);
	}

	for (int i = 0; i < L; i++) {
		int r, s;
		cin >> r >> s;
		rail.unionSet(r - 1, s - 1);
	}

	vector<pint> p(N);
	for (int i = 0; i < N; i++) {
		p[i] = make_pair(road.root(i), rail.root(i));
	}

	map<pint, int> m;
	for (auto &&i : p) {
		if (m.count(i)) {
			m[i]++;
		} else {
			m[i] = 1;
		}
	}

	for (int i = 0; i < N - 1; i++) {
		cout << m[p[i]] << " ";
	}
	cout << m[p[N - 1]] << endl;

	return 0;
}


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

using namespace std;

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for (int i = 0; i < H; i++) cin >> S[i];

  vector<vector<int>> dp(H + 1, vector<int>(W + 1, numeric_limits<int>::max()));
  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      int current = numeric_limits<int>::max();
      if (y > 0) {
	if (S[y][x] == '.') {
	  current = min(current, dp[y - 1][x]);
	} else if (S[y - 1][x] == '#') {
	  current = min(current, dp[y - 1][x]);
	} else {
	  current = min(current, dp[y - 1][x] + 1);
	}
      }

      if (x > 0) {
	if (S[y][x] == '.') {
	  current = min(current, dp[y][x - 1]);
	} else if (S[y][x - 1] == '#') {
	  current = min(current, dp[y][x - 1]);
	} else {
	  current = min(current, dp[y][x - 1] + 1);
	}
      }

      if (y == 0 && x == 0) {
	current = (S[y][x] == '.') ? 0 : 1;
      }

      dp[y][x] = current;
    }
  }

  cout << dp[H - 1][W - 1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll gcd(ll a,ll b){
    if(a<b) gcd(b,a);
    ll r;
    while(r=a%b){
        a=b;
        b=r;
    }
    return b;
}

int main(){
    ll n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll ans;
    rep(i,n){
        if(i==0) ans=a[i];
        else ans=gcd(ans,a[i]);
    }
    cout<<ans<<endl;
}

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

struct item {
    long long int value;
    long long int weight;
};

long long int dp[101][100001];

long long int knapsack(item items[], long long int i, long long int w) {
    if (i < 0) {
        return 0;
    }
    if (dp[i][w] != -1) {
        return dp[i][w];
    }
    if (items[i].weight > w) {
        return dp[i][w] = knapsack(items, i - 1, w);
    }
    return dp[i][w] = max(knapsack(items, i - 1, w - items[i].weight) + items[i].value,
                          knapsack(items, i - 1, w));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, w;
    cin >> n >> w;
    item items[n + 1];
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= w; j++) {
            dp[i][j] = -1;
        }
    }
    for (int i = 1; i <= n; ++i) {
        cin >> items[i].weight >> items[i].value;
    }
    cout << knapsack(items, n, w) << endl;
    return 0;
}

Measured memory_bytes: 78336
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

#define INF INFINITY

int N;
float dat[10][10];
int a,b,c,M;

int main(){
    while(scanf("%d",&N),N){
        memset(dat,0,sizeof(dat));
        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                if(i!=j)dat[i][j]=INF;
            }
        }
        M=0;
        for(int i=0;i<N;i++){
            scanf("%d%d%d",&a,&b,&c);
            dat[a][b]=dat[b][a]=c;
            M=max(M,max(a,b)+1);
        }
        for(int k=0;k<10;k++){
            for(int i=0;i<10;i++){
                for(int j=0;j<10;j++){
                    dat[i][j]=min(dat[i][j],dat[i][k]+dat[k][j]);
                }
            }
        }
        int S;float T=INF;
        for(int s=0;s<M;s++){
            float t=0;
            for(int i=0;i<M;i++){
                t+=dat[s][i];
            }
            if(T>t){
                S=s;
                T=t;
            }
        }
        printf("%d %d\n",S,(int)T);
    }
}
 

Measured memory_bytes: 0
N = int(input())
S = input()
T = input()
mod = 10**9+7
lis = []
ans = 1
if N==1:
  print(3)
  exit()
if S[0]!=S[1]:
  lis.append(1)
for i in range(1,N-1):
  if S[i]!=S[i-1] and S[i]!=S[i+1]:
    lis.append(1)
  elif S[i]==S[i-1]:
    lis.append(2)
if S[-1]==S[-2]:
  lis.append(2)
else:
  lis.append(1)
ans = 3
if lis[0]==2:
  ans *= 2
for i in range(1,len(lis)):
  if lis[i-1]==1:
    ans *= 2
    ans %= mod
  elif lis[i]==2:
    ans *= 3
    ans %= mod
print(ans)

Measured memory_bytes: 78792
#include<stdio.h>

int main(void){
	int a,b,c,x=0,y=0,z=0,i;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
		x=a;
		a=b;
		b=x;
	}
	if(b>c){
		y=b;
		b=c;
		c=y;
	}
	if(a>c){
		z=a;
		a=c;
		c=z;
	}
	if(a>b){
		x=a;
		a=b;
		b=x;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(void){
	ll n,l,i,t,a[100002],x[100002],mx;
	cin>>n>>l;
	a[0]=l; a[n+1]=l;
	for(i=1;i<=n;i++){
		cin>>t;
		a[i]=l-t; x[i]=a[i];
	}
	for(i=1;i<=n;i++){
		if(a[i]>a[i-1]) x[i]=max(x[i],a[i]+x[i-1]);
		if(a[i]>a[i+1]) x[i]=max(x[i],a[i]+x[i+1]);
	}
	for(i=n;i>=1;i--){
		if(a[i]>a[i-1]) x[i]=max(x[i],a[i]+x[i-1]);
		if(a[i]>a[i+1]) x[i]=max(x[i],a[i]+x[i+1]);
	}
	mx=0;
	for(i=1;i<=n;i++) mx=max(mx,x[i]);
	cout<<mx<<endl;
	return 0;
}


Measured memory_bytes: 4652
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
typedef long long int ll;
const int MAX=100000;
const int INFTY=1<<30;

int n,col[MAX],d[MAX];
vector<pair<int,int>> Q[MAX];//target,weight

void dijkstra(int s)
{
	priority_queue<pair<int,int>> PQ;//weight,id
	for(int i=0;i<n;i++)
	{
		d[i]=INFTY;
		col[i]=0;
	}
	d[s]=0;
	PQ.push(make_pair(0,s));
	col[s]=1;
	
	while(!PQ.empty())
	{
		pair<int,int> f=PQ.top();PQ.pop();
		int u=f.second;
		col[u]=2;
		if(d[u]<f.first*(-1))continue;
		for(int j=0;j<Q[u].size();j++)
		{
			int v=Q[u][j].first;
			if(col[v]==2)continue;
			if(d[u]+Q[u][j].second<d[v])
			{
				d[v]=d[u]+Q[u][j].second;
				PQ.push(make_pair(d[v]*(-1),v));
				col[v]=1;
			}
		}
	}
	
	for(int i=0;i<n;i++)
	{
		if(d[i]==INFTY)cout<<"INF"<<endl;
		else cout<<d[i]<<endl;
	}
	
	return;
}

int main()
{
	cin>>n;
	int u;int m;cin>>m>>u;
	int s,t,w;
	for(int i=0;i<m;i++)
	{
		cin>>s>>t>>w;
		Q[s].push_back(make_pair(t,w));
	}
	dijkstra(u);
	return 0;
}

Measured memory_bytes: 13320
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

int main() {
    string S;
    cin >> S;
    int cnt1 = 0, cnt2 = 0;
    for(int i = 0; i < S.size(); i++) {
        char c = S[i];
        if (i % 2 == 0) {
            if (c == '0') cnt1++;
            else cnt2++;
        } else {
            if (c == '1') cnt1++;
            else cnt2++;
        }
    }

    int ans = min(cnt1, cnt2);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main() {
    int x, a, b = 0;
    scanf("%d %d %d", &x, &a, &b);
    x = x-a;
    while(x >= b) {
        x = x - b;
        if(x <= 0) break;
    }
    printf("%d", x);
    return 0;
}

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

#define rep(i,n) for(int i =0; i <n; ++i)

#define rrep(i,n) for(int i =n; i >=0; --i)

#define rep_(i,m,n) for(int i =m; i <n; ++i)

#define INF 2e9

#define ll long long

//const ll MOD = 1000000007;

//const  long double PI=(acos(-1));

//const  long double EPS=0.0000000001;

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

    char ans = (int)s +1;
    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	int i, j, m, n, **A, *v, c;
	scanf("%d %d", &n, &m);

	A = (int **)malloc(sizeof(int *) * n);
	for (i = 0; i < n; i++) {
		A[i] = (int *)malloc(sizeof(int) * m);
	}
	v = (int *)malloc(sizeof(int) * m);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			scanf("%d", &A[i][j]);
		}
	}
	for (i = 0; i < m; i++) {
		scanf("%d", &v[i]);
	}
	for (i = 0; i < n; i++) {
		c = 0;
		for (j = 0; j < m; j++) {
			c += A[i][j] * v[j];
		}
		printf("%d\n", c);
	}
	return 0;
}



Measured memory_bytes: 2104
x,n = map(int,input().split())
if n==0:
  print(x)
else:
  p = list(map(int,input().split()))
  numberset = set()
  for i in range(0,102):
    numberset.add(i)
  for s in p:
    numberset.remove(s)
  diff = 100
  mindifint = 101
  for s in numberset:
    if abs(s-x)<diff:
      diff = abs(s-x)
      mindifint = s
    elif abs(s-x)==diff:
      mindifint = min(mindifint,s)
  print(mindifint)

Measured memory_bytes: 9236
#define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#pragma comment (linker, "/STACK:526000000")

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(10);
}

#define int ll
void solve() {
	int hoge = 0;
	while (true) {
		int n;
		cin >> n;
		if (n == 0) return;
		if (hoge != 0)
			cout << endl;
		hoge++;
		n = -n;
		vector<int> go;
		int cnt[4] = { 10,50,100,500 };
		REP(i, 4) {
			int a;
			cin >> a;
			go.push_back(a);
			n += a * cnt[i];
		}
		int going[4] = {};
		for (int i = 3; i >= 0; --i) {
			going[i] = n / cnt[i];
			n %= cnt[i];
		}
		for (int i = 3; i >= 0; --i) {
			int hoge = min(going[i], go[i]);
			go[i] -= hoge;
		}
		REP(q, 4) {
			if (go[q] != 0) {
				cout << cnt[q] << " " << go[q] << endl;
			}
		}
	}
	
}
#undef int

int main() {
	init();
	solve();
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> A;
  vector<int> B;
  vector<int> C;

  for (int i = 0; i < N; i++)
  {
    int a;
    cin >> a;
    A.push_back(a);
    A.at(i)--;
  }
  for (int i = 0; i < N; i++)
  {
    int a;
    cin >> a;
    B.push_back(a);
  }
  for (int i = 0; i < N - 1; i++)
  {
    int a;
    cin >> a;
    C.push_back(a);
  }
  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    ans += B.at(A.at(i));
    if (i > 0 && A.at(i) == A.at(i - 1) + 1)
    {
      ans += C.at(A.at(i - 1));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        String x = sc.next();
        String y = sc.next();
        String[] str1 = new String[3];
        String[] str2 = new String[3];
        str1 = x.split("");
        str2 = y.split("");
        if (str1[0].equals(str2[2]) && str1[1].equals(str2[1]) && str1[2].equals(str2[0]))
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
signed main() {
    int a,b;cin>>a>>b;
    cout<<abs(a-b)<<endl;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> ans(N + 1, 0);
    for(int x = 1; x * x <= N; x++) {
        for(int y = 1; x * x + y * y <= N; y++) {
            for(int z = 1; x * x + y * y + z * z <= N; z++) {
                int tmp = x * x + y * y + z * z + x * y + y * z + z * x;
                if(1 <= tmp && tmp <= N) {
                    ans[tmp]++;
                }
            }
        }
    }
    for(int i = 1; i <= N; i++) {
        cout << ans[i] << "\n";
    }
}

Measured memory_bytes: 3620
A=int(input())
B=int(input())
C=int(input())
X=int(input())
ans=0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if i*500+j*100+k*50==X:
        ans+=1
print(ans)
#これでよかったの!?TLEすると思った

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

int main() {
	int x,y;
  	cin >> hex >> x >> y;
    if(x == y){
      cout << "=" << endl;
    }else if(x > y){
      cout << ">" << endl;
    }else{
      cout << "<" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef pair< double,double> dd;
#define pb push_back
#define eb emplace_back
#define sz(a) (int)a.size()
#define all(c) c.begin(),c.end()
#define FOR(i,a,b) for(i=a; i<b; i++)
#define FORR(i,a,b) for(i=a;i>=b;i--)
#define REP(i,n) FOR(i,0,n)
#define x first
#define y second
#define mp make_pair

const int INF = 1000000007;
const long long INFLL = (ll)INF * (ll)INF;

void solve()
{
	int x,y,j,val;
	cin>>x>>y;
	for(int i=0;i<=x;i++)
	{
		j=x-i;
		val = 2*i + 4*j;
		if(val==y)
		{
			cout<<"Yes";
			return;
		}
	}
	cout<<"No";
}
int32_t main()
{
	IOS;
	//int t;
	//cin>>t;
	//for(int i=0;i<t;i++)
	{
		solve();
		cout<<endl;
	}
	return 0;
}


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

//cmdで g++ test.cpp とするとコンパイルできる
typedef long long ll;
typedef pair<int,int> pii;

const int MOD=1000000007;

int main() {
    int N,M;
    vector<int> V(N,-1); //V.at(0)が最上位桁
    bool muri=false;
    cin>>N>>M;
    for(int i=0;i<M;i++){
        int s,c;
        cin>>s>>c;
        s--;
        if(V.at(s)==-1){
            V.at(s)=c;
        }else if(V.at(s)!=c){ //同じ桁に複数の値
            muri=true;
            break;
        }
    }
    if(muri){
        cout<<-1<<endl;
    }else{
        if(N==1){
            if(V.at(0)==-1)V.at(0)=0;
            cout<<V.at(0)<<endl;
        }else{
            if(V.at(0)==0){
                cout<<-1<<endl;
            }else{
                for(int i=0;i<N;i++){
                    if(V.at(i)==-1){
                        V.at(i)=(i==0)?1:0;
                    }
                    cout<<V.at(i);
                }
                cout<<endl;
            }
        }
    }
}


Measured memory_bytes: 256
//“ In order to be irreplaceable, one must always be different”
#include <bits/stdc++.h>
using namespace std;
# define ll long long
#define endl "\n"
# define pi 3.14159265359
# define str string
# define vll vector<ll>
# define vstr vector<str>
# define vchar vector<char>
# define pb push_back
# define popb pop_back
# define pf push_front
# define popf pop_front
# define sll set<ll>
# define schar set<char>
//find()
//erase(x) removes element x
//erase(position,position)
# define qll queue<ll>
# define qstr queue<str>
//front(),back()
# define stll stack<ll>
# define ststr stack<str>
//top()
# define dll deque<ll>
//at()
# define mll map<ll,ll>
#define mchar map<char, ll>
# define mstr map<str,ll>
# define mss map<str,str>
# define mci map<char,ll>
# define vp vector< pair<ll,ll> >
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
# define f(x,y) for(int x=0;x<y;x++)
# define r(x,y) for(int x=y;x>=0;x--)
# define fr(x,y,z) for(int x=y;x<z;x++)
# define rr(x,y,z) for(int x=y;x>z;x--)
ll power(ll a , ll b){ll res=1;for(ll i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll gcd(ll a, ll b){
    if(b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a, b);
}
void print(vll a){
    for(int i=0;i<a.size();i++){
        cout<<a[i]<<' ';
    }
    cout<<endl;
}
vll inp(int n){
    vll a;
    ll x;
    f(i,n){
        cin>>x;
        a.pb(x);
    }
    return a;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll x,y;
    cin>>x>>y;
    ll k=0;
    x--;y--;
    k=k+((x)*(x+1))/2;
    k+=((y)*(y+1))/2;
    cout<<k;
}




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

int main() {
  int N; cin >> N;
  vector<int> A(3,0);
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    if (a % 4 == 0) A[2]++;
    else if (a % 2 == 0) A[1]++;
  }
  
  bool can = false;
  if (A[2] >= N / 2) can = true;
  else if (A[1] >= N - 2 * A[2]) can = true;
  
  if (can) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using long_t = int64_t;

struct Solver {
	Solver() {
		ios::sync_with_stdio( false );
		cout << fixed << setprecision( 10 );
	}

	void solve() {
		int n;
		cin >> n;
		vector<int> a( n );
		for( auto& v: a ) { cin >> v; }

		int m;
		cin >> m;
		vector<int> b( m );
		for( auto& v: b ) { cin >> v; }

		vector<int> c;
		set_union( a.begin(), a.end(), b.begin(), b.end(), back_inserter( c ) );
		for( auto v: c ) { cout << v << '\n'; }
	}
};

int main() {
	Solver().solve();
	return 0;
}



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

int main(){   
   ll n,k; cin >> n >> k;
   ll r = n%k;
   ll ans = min(r, k-r);
   cout << ans << endl;
}


Measured memory_bytes: 3568
use std::collections::HashMap;
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let (n,p) = {
        let t = read_vec::<i64>();
        (t[0],t[1])
    };
    let ans:i64 = if n == 1 {
        p
    } else {
        let res = trivial_division(p as u64);
        res.into_iter().fold(HashMap::new(),|mut map,x| {
            let y = map.get(&x).map(|t| t+1).unwrap_or(1);
            map.insert(x,y);
            map
            })
            .into_iter()
            .filter(|&(x,y)|{
                y >= n
            }).fold(1,|y,(i,v)|{
                y *  i.pow((v/n) as u32) as i64
            })
    };
    println!("{}",ans);

}

fn trivial_division(n: u64) -> Vec<u64> {
    let mut result = n;
    for i in 2..((n as f64).sqrt() as u64)+1 {
        if n % i == 0 {
            result = i;
            break;
        }
    }

    if result == n {
        return vec![n];
    } else {
        let mut v1 = vec![result];
        let mut v2 = trivial_division(n / result);

        v1.append(&mut v2);

        return v1;
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define mod 998244353
using namespace std;
int n,S,a[3005],ans,F[3005][3005],g[3005][3005];

int main(){
	scanf("%d %d",&n,&S);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	F[0][0]=0,g[0][0]=1;
	for(int i=1;i<=n;i++){
		if(a[i]==S) (ans+=1ll*i*(n-i+1)%mod)%=mod;
		else if(a[i]<S) (ans+=1ll*F[i-1][S-a[i]]*(n-i+1)%mod)%=mod;
		for(int j=0;j<=S;j++){
			(F[i][j]+=F[i-1][j])%=mod;
			(g[i][j]+=g[i-1][j])%=mod;
			if(j>=a[i]){
				if(j==a[i]) (F[i][j]+=(F[i-1][j-a[i]]+1ll*i*g[i-1][j-a[i]]%mod)%mod)%=mod;
				else (F[i][j]+=F[i-1][j-a[i]])%=mod;
				(g[i][j]+=g[i-1][j-a[i]])%=mod;
			}
		}
	}
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 70784