akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int h, w;
    cin >> h >> w;
    string s[h];
    rep(i, h) cin >> s[i];

    int res = 0;
    rep(i, h) {
        rep(j, w) {
            if (s[i][j] == '#') continue;
            int tmp = 0;
            vector<vector<int>> dist(h, vector<int>(w, -1));
            queue<pair<int, int>> que;
            que.push(make_pair(i, j));
            dist[i][j] = 0;
            while(!que.empty()) {
                int x = que.front().second;
                int y = que.front().first;
                que.pop();
                rep(k, 4) {
                    int nx = x + dx[k];
                    int ny = y + dy[k];
                    if (nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
                    if (s[ny][nx] == '#') continue;
                    if (dist[ny][nx] != -1) continue;
                    dist[ny][nx] = dist[y][x] + 1;
                    chmax(tmp, dist[ny][nx]);
                    que.push(make_pair(ny, nx));
                }
            }
            chmax(res, tmp);
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <time.h>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;
using std::next_permutation;
using std::lower_bound;

long long max(long long a, long long b)
{
    if (a > b)
        return a;
    return b;
}
long long min(long long a, long long b)
{
    if (a > b)
        return b;
    return a;
}
typedef long long ll;
typedef pair<long long, long long> pii;
typedef pair<ll, ll> pll;

namespace MySpace{

};

#define forn(i, n) for (long long (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define int long long
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
ll W, H, x, y;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    cin >> W >> H >> x >> y;
    ll s = W * H / 2;
    cout << s;
    if (s * 2 == W*H)
    {
    	cout << ".0 ";
    }
    else
    {
    	cout << ".5 ";
    }
    if (2 * x == W && 2 * y == H)
    {
        cout << 1;
    }
    else
    {
        cout << 0;
    }
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	final long m = (long) 1e9 + 7;

	void run() {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		if (N % 2 == 1) {// N,N-2,N-4,...,1が全て奇数
			System.out.println(0);
			return;
		}
		// N:=2m
		// f(N)=2m * 2(m-1) * ... * 2 * 1=2^m m!
		long c2 = (N / 2) + f(N / 2, 2);
		long c5 = f(N / 2, 5);
		System.out.println(Math.min(c2, c5));
	}

	long f(long n, long d) {
		long ret = 0;
		while (n > 0) {
			ret += n / d;
			n /= d;
		}
		return ret;
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

#ifdef _VSCODE_DEBUG
    #include <fstream>
#endif

using ll = long long;
using P = std::pair<ll,ll>;
static const ll INF = 1e15;
struct edge {int to; int cost;};

class Graph {
private:
    std::vector<std::vector<edge>> nodes;
    std::vector<ll> d;
    int node_num;
public:
    Graph(int N) {
        node_num = N;
        nodes.resize(N);
        d.resize(N);
        for (int i=0; i<N; ++i) d[i] = INF;
    }
    void add_edge(int st, int to, int cost) {
        nodes[st].emplace_back(edge{to,cost});
    }
    void dijkstra(int st) {
        // init
        for (int i=0; i<node_num; ++i) d[i] = INF;
        d[st] = 0;
        std::priority_queue<P, std::vector<P>, std::greater<P>> que;
        que.push(P(0, st)); // 最短距離、頂点の番号

        // search
        while (!que.empty()) {
            P p = que.top(); que.pop();
            int node = p.second;
            if (d[node] < p.first) continue;
            for (int i=0; i<nodes[node].size(); ++i) {
                edge e = nodes[node][i];
                if (d[e.to] > d[node] + e.cost) {
                    d[e.to] = d[node] + e.cost;
                    que.emplace(P(d[e.to], e.to));
                }
            }
        }
    }
    ll get_d(int n) {return d[n];}
};

int main() {
    #ifdef _VSCODE_DEBUG
        std::ifstream in("input.txt");
        std::cin.rdbuf(in.rdbuf());
    #endif
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    // input data
    int n, m, s, t;
    ll u, v, a, b;
    std::cin >> n >> m >> s >> t;
    --s; --t;
    Graph yen_graph(n);
    Graph snuuk_graph(n);
    for (int i=0; i<m; ++i) {
        std::cin >> u >> v >> a >> b;
        --u; --v;
        yen_graph.add_edge(u, v, a);
        yen_graph.add_edge(v, u, a);
        snuuk_graph.add_edge(u, v, b);
        snuuk_graph.add_edge(v, u, b);
    }

    // dijkstra
    yen_graph.dijkstra(s);
    snuuk_graph.dijkstra(t);
    std::vector<ll> ans(n+1, -1);
    ll res = 1LL << 60;
    for(int i = n-1; i>=0; --i){
        res = std::min(res, yen_graph.get_d(i)+snuuk_graph.get_d(i));
        ans[i] = res;
    }
    
    for(int i=0; i<n; ++i) std::cout << (ll)1e15 - ans[i] << "\n";
    return 0;
}

Measured memory_bytes: 16124
#include <stdio.h>

int main(void) {
  int i, n, j, k;
  scanf("%d", &n);
  int a[5][4][11];
  for(i = 0; i < 5; ++i) for(j = 0; j < 4; ++j) for(k = 0; k < 11; ++k) a[i][j][k] = 0;
  for(i = 0; i < n; ++i) {
    int b, f, r, w;
    scanf("%d%d%d%d", &b, &f, &r, &w);
    a[b][f][r] += w;
  }
  for(i = 1; i < 5; ++i) {
    for(j = 1; j < 4; ++j) {
      for(k = 1; k < 11; ++k) 
        printf(" %d", a[i][j][k]);
      printf("\n");
    }
    if(i != 4) {
      for(j = 0; j < 20; ++j) printf("#");
      printf("\n");
    }
  }
  return 0;
}


Measured memory_bytes: 2664
import math
s=list(map(int,input().split()))
a=0
b=0
c=0
if s[0]*s[0]*s[1]<2*s[2]:
  a=(s[0]*s[0]*s[1]-s[2])*2
  b=s[0]*s[0]*s[0]
  c=math.degrees(math.atan(a/b))
else:
  a=s[0]*s[1]*s[1]
  b=2*s[2]
  c=math.degrees(math.atan(a/b))
print(c)

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

#define ll long long
#define INF 1000000000
int n,m,k,p=1;

ll dp[100003],h[100003];
int arr[12];

ll solve(int i){
    if(i==0) return 0;
    if(dp[i]!=-1) return dp[i];
    if(i==1) return dp[i]=solve(i-1)+abs(h[i]-h[i-1]);
    return dp[i]=min(solve(i-1)+abs(h[i]-h[i-1]),solve(i-2)+abs(h[i]-h[i-2]));
}

int main(){
    int t=1,tn=1;
//    scanf("%d",&t);
    while(t--){
        int n;
        scanf("%d",&n);
        fill(dp,dp+n,-1);
        for(int i=0;i<n;i++)
            scanf("%lld",&h[i]);
        solve(n-1);
//        ll s=min(dp[1]+abs(h[1]-h[0]),dp[2]+abs(h[2]-h[0]));
        printf("%lld",dp[n-1]);
    }
    return 0;
}


Measured memory_bytes: 3328
A, B, K = map(int, input().split())

if B - A < 2 * K:
    for i in range(A, B + 1):
        print(i)
else:
    for a in range(A, A + K):
        print(a)
    for b in range(B - K + 1, B + 1):
        print(b)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,p;
    cin >> n >> p;

    vector<pair<ll,ll>> x;
    x.push_back(make_pair(1,1));

    ll t = 2;
    ll tp = p;
    for(; t*t <= p; t++){
        if(tp%t == 0){
            if(x.back().first == t){
                x.back().second++;
            }else{
                x.push_back(make_pair(t,1));
            }
            tp /= t;
            t--;
        }
    }
    
    if(tp != 1){
        if(x.back().first == tp){
            x.back().second++;
        }else{
            x.push_back(make_pair(tp,1));
        }
    }

    ll ans = 1;

    for(int i = 0; i < x.size(); i++){
        while(x[i].second >= n){
            ans *= x[i].first;
            x[i].second -= n;
        }
    }

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

Measured memory_bytes: 256
#include <stdio.h>
 
class Dice3{
public:
    Dice3(){
        number = new int[6];
        checkTable = new int[101];
        for(int i = 0; i < 101; i++) checkTable[i] = -1;
    };
    ~Dice3(){
        delete[] number;
        delete[] checkTable;
    };
 
    void setLabel(int index,int num){
        number[index] = num;
        checkTable[num] = index;
    };
 
    void roll(char dst){
        switch(dst){
        case 'E':
            setNumber(number[3],number[1],number[0],number[5],number[4],number[2]);
            break;
        case 'N':
            setNumber(number[1],number[5],number[2],number[3],number[0],number[4]);
            break;
        case 'S':
            setNumber(number[4],number[0],number[2],number[3],number[5],number[1]);
            break;
        case 'W':
            setNumber(number[2],number[1],number[5],number[0],number[4],number[3]);
            break;
        }
    };
 
    bool isValidMember(int inputed[]){
        for(int i = 0; i < 6; i++)
        {
            if(checkTable[inputed[i]] == -1)
                return false;
        }
        return true;
    }
    bool isSameDice(int inputed[]){
        char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";
        for(int i = 0; i < 24; i++){
            roll(order[i]);
            for(int j = 0; j < 6; j++){
                if(inputed[j] != number[j])
                    break;
                if(j == 5)
                    return true;
            }
        }
        return false;
    }
 
private:
    void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
        number[0] = n0;
        number[1] = n1;
        number[2] = n2;
        number[3] = n3;
        number[4] = n4;
        number[5] = n5;
    }
 
private:
    int* number;
    int* checkTable;
};
 
int main(){
    Dice3 dice3;
    int tmp,inputed[6];
    for(int i = 0; i < 6; i++){
        scanf("%d",&tmp);
        dice3.setLabel(i,tmp);
    }
    for(int i = 0; i < 6; i++) scanf("%d",&inputed[i]);
 
    if(dice3.isValidMember(inputed) && dice3.isSameDice(inputed))
        printf("Yes\n");
    else{
        printf("No\n");
    }
}


Measured memory_bytes: 2696
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vec_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define vec_output(v) for(auto it=v.begin();it!=v.end();it++){if(it!=v.begin())cout<<" ";cout<<*it;}cout<<endl;
#define vec_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
template <typename T>T digitsum(T n);
template <typename T>bool isPrime(T n);
template <typename T>vector<pair<T, T>> prime_factor(T n);
long long int intpow(long long int,long long int);
template <typename T>T intlog(T);
long long int combination(long long int,long long int);
long long int arith_sum1(long long int,long long int,long long int);
long long int arith_sum2(long long int,long long int,long long int);
long long int series_sum(long long int);

/*int main(){
    int a;
    cin>>a;
    cout<<1<<" "<<a<<endl;
}*/

/*int main(){
    int t,a,b,sum;
    cin>>t;
    rep(l,t){
        cin>>a>>b;
        vector<int> vec(a);
        sum=0;
        rep(i,a){
            cin>>vec[i];
            sum+=vec[i];
        }
        cout<<(b<sum?b:sum)<<endl;
    }
}*/

int main(){
    ll n,k,a,b;
    set<ll> set;
    umap<ll,ll> map;
    cin>>n>>k;
    rep(l,n){
        scanf("%lld %lld",&a,&b);
        if(set.count(a)){
            map[a]+=b;
        }else{
            set.insert(a);
            map[a]=b;
        }
    }
    ll hikaku=0,ans;
    for(auto value:set){
        hikaku+=map[value];
        if(k<=hikaku){
            ans=value;
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 9664
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int main(void){
    int n;
    cin >> n;
    int ai;
    long long ans = 0;
    long long w = 1;
    for(int i=0; i<n; i++){
        cin >> ai;
        if(ai%w==0){
            ans += ai/w-1;
            if(ai/w-1>0 and w>1){
                w = w;
            }else{
                w += 1;
            }
        }else{
            ans += ai/w;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 101
using namespace std;
typedef pair<int,int> pi;
int N;
vector<pi> ans;
int main(){
    scanf("%d",&N);
    for(int i=1;i<=N;i++){
        for(int j=i+1;j<=N;j++){
            if(N&1){
                if(i + j == N) continue;
            }
            else{
                if(i+j==N+1) continue;
            }
            ans.push_back(pi(i,j));
        }
    }
    printf("%lld\n",ans.size());
    for(auto i : ans){
        printf("%d %d\n",i.first,i.second);
    }
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long n,k;cin>>n>>k;
    if(k%2){//kが奇数であるとき
        long long m = n/k;
        long long res = m*m*m;
        cout<<res<<endl;
    }else{
        long long kk = k/2;
        long long m = n/k;
        long long l = n/kk;
        l-=m;
        long long res = m*m*m + l*l*l;
        cout<<res<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define rrep(i,n) for (int i=(int)(n)-1; i>=0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using llGraph = vector<vl>;
using vb = vector<bool>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;

template<typename T>
struct is_vector : false_type{};

template<typename T>
struct is_vector<vector<T>> : true_type{};

template<typename T>
ostream &operator << (ostream &ostr, const vector<T> &vec) {
  if (vec.empty()) {
    return ostr;
  }
  ostr << vec.front();
  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
    if (is_vector<T>()) ostr << "\n" << *itr;
    else ostr << ' ' << *itr;
  }
  return ostr;
}

template<typename T>
bool CompareBySecond(pair<T, T> a, pair<T, T> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

template<typename T>
bool CompareBySlope(pair<T, T> a, pair<T, T> b) {
// counterclockwise from 12 o'clock direction
  if (a.first * b.first < 0) {
    return a.first < b.first;
  } else if (a.first == 0) {
    if (a.second >= 0) {
      return true;
    } else {
      return a.first < b.first;
    }
  } else if (b.first == 0) {
    if (b.second >= 0) {
      return false;
    } else {
      return a.first < b.first;
    }
  }
  return a.second * b.first < a.first * b.second;
}

template<typename T>
T GCD(T a, T b) {
  T c = a % b;
  while (c != 0) { a = b; b = c; c = a % b; }
  return b;
}


/* -------- <templates end> -------- */


void solve() {
  int n; cin >> n;
  vi arr(n);
  rep(i,n) cin >> arr[i];
  unordered_map<int, int> cards;
  rep(i,n) ++cards[arr[i]];
  map<int, int> numbers;
  for (auto &p : cards) ++numbers[p.second];
  int Kmax = cards.size();
  int Kmin = n / (*numbers.rbegin()).first;
  for (int i=1; i<=Kmin; ++i) {
    cout << n / i << "\n";
  }
  vi ans(Kmax-Kmin);
  int res = 0;
  for (int i=Kmax; i>Kmin; --i) {
    int num, cnt;
    auto itr = numbers.begin();
    tie(num, cnt) = *itr;
    int tmp = res;
    while (++itr != numbers.end()) {
      int newnum, newcnt;
      tie(newnum, newcnt) = *itr;
      if ((newnum-num)*cnt >= tmp) {
        num += tmp / cnt;
        break;
      }
      tmp -= (newnum-num)*cnt;
      num = newnum;
      cnt += newcnt;
    }
    ans[i-1-Kmin] = num;
    num = (*numbers.begin()).first;
    res += num;
    if (--numbers[num] == 0) numbers.erase(num);
  }
  for (auto v : ans) cout << v << "\n";
  for (int i=Kmax+1; i<=n; ++i) {
    cout << 0 << "\n";
  }
}


/* -------- <programs end> -------- */


int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


Measured memory_bytes: 15432
#include <stdio.h>

void call(int n);
int include3(int n);

int main(void){

    int num;
    scanf("%d",&num);

    call(num);

    return 0;
}

void call(int n){
    int i;

    for(i=1;i<=n;i++){
        if(i%3==0||include3(i)){
            printf(" %d",i);
        }
    }

    printf("\n");
}

int include3(int n){
    if(n%10==3){
        return 1;
    }else{
        if(n<10) return 0;
        return include3(n/10);
    }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define MAX_V 100100

const ull INF = 1e15;
const ull base = 1e15;

int V, E;

struct edge{int to; ll cost;};
typedef pair<ull, ull> P;

vector<edge> Gs[MAX_V];
vector<edge> Ge[MAX_V];
ull ds[MAX_V];
ull dt[MAX_V];


// O(E*logV)
void dijkstra(int s, ull d[], vector<edge> G[]){
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0,s));

    while(!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        for(int i = 0; i < G[v].size(); i++){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

pair<ull, int> dsum[MAX_V];

int main(){
    ll s, t;
    cin >> V >> E >> s >> t;
    s--, t--;
    REP(i,E){
        int u, v;
        ll  a, b;
        cin >> u >> v >> a >> b;
        u--, v--;
        Ge[u].push_back((edge){v, a});
        Ge[v].push_back((edge){u, a});
        Gs[u].push_back((edge){v, b});
        Gs[v].push_back((edge){u, b});
    }

    dijkstra(s, ds, Ge);
    dijkstra(t, dt, Gs);

    REP(i,V){
        dsum[i] = make_pair(ds[i]+dt[i], i);
    }

    sort(dsum, dsum+V);

    int idx = 0;
    for(int i = 0; i < V; i++){
        ull d;
        while(1){
            auto p = dsum[idx];
            int v = p.second;
            d = p.first;
            if(v < i) idx++;
            else break;
        }
        //cout << base - d << endl;
        printf("%llu\n", base-d);
    }

    return 0;
}


Measured memory_bytes: 19908
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int64_t sum = 0;
  for(int i=1; i<=N; i++){
    if(i %3 != 0 && i %5 != 0){
      sum += i;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int> pii;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int main(){
	string a,b;
	cin>>a>>b;
	int ans=0;
	rep(i,SZ(a)){
		if(a[i]!=b[i]){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3856
import bisect

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    N = int(input())
    l = [111, 222, 333, 444, 555, 666, 777, 888, 999]
    i = bisect.bisect_left(l, N)
    print(l[i])



if __name__ == '__main__':
    main()

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

int N, K;
vector<vector<int>> xy(2010, vector<int>(2010, 0));

int Get(int x1,int y1,int x2,int y2){ if(x1 > x2 || y1 > y2) return 0; return xy[x2][y2] - xy[x1 - 1][y2] - xy[x2][y1 - 1] + xy[x1 - 1][y1 - 1]; }

int main(void){
    
    scanf("%d %d", &N, &K);
    int KK = 2 * K;
    for(int i = 0; i < N; ++i){
        int a, b; char c; scanf("%d %d %c", &a, &b, &c);
        if(c == 'W') b += K;
        a %= KK, b %= KK; 
        ++xy[a + 1][b + 1];
    }
    
    for(int i = 1; i < KK + 2; ++i) for(int j = 1; j < KK + 2; ++j) xy[i][j + 1] += xy[i][j];
    for(int i = 1; i < KK + 2; ++i) for(int j = 1; j < KK + 2; ++j) xy[j + 1][i] += xy[j][i];
    
    int ans = 0;
    for(int x = 1; x <= K; ++x){
        for(int y = 1; y <= K; ++y){
            int temp = Get(x, y, x + K - 1, y + K - 1) + Get(x + K, y + K, KK, KK) + Get(1, 1, x - 1, y - 1) + Get(x + K, 1, KK, y - 1) + Get(1, y + K, x - 1, KK);
            ans = max(ans,max(temp,N-temp));
        }
    }
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 16128
stdin.ReadLine()
|> int
|> (fun n ->
    [1..n]
    |> List.map (fun _ -> stdin.ReadLine() |> int)
    |> fun list -> 0::list
    |> List.toArray
)
|> (fun list ->
    list
    |> Array.fold (
        fun (acc, i, found) _ ->
            match list.[i] with
            | 2 when found = -1 -> (acc + 1, 2, acc)
            | ai -> (acc + 1, ai, found)
    ) (1, 1, -1)
    |> fun (_, _, found) -> found
)
|> printfn "%d"


Measured memory_bytes: 27076
#define _USE_MATH_DEFINES

#include <bits/stdc++.h> 
 
using namespace std;
 
#define len(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second	
#define int long long
#define double long double       
#define vec vector            
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double> 
#define beg begin
 
#ifdef LOCAL
    #define dbg(x) cout << #x << " = " << x << endl;
#else 
    #define dbg(x)
#endif 
 
template<class T> istream& operator>>(istream &str, vector<T> &a) {
    for (auto &i : a) {
        str >> i; 
    }
    return str;
}
 
template<class T> ostream& operator<<(ostream &str, vector<T> &a) {
    for (auto &i : a) {
        str << i << " ";
    }
    return str;
}
 
template<class T> istream& operator>>(istream &str, pair<T, T> &a) {
    str >> a.x >> a.y;
    return str;
}
 
template<class T> ostream& operator<<(ostream &str, pair<T, T> &a) {
    str << a.x << " " << a.y;
    return str;
}
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);                                       
    freopen("output.txt", "w", stdout);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(6);
    solve();    
    return 0;
}
 
const int INF = 1e18, MAXN = 1e6, MOD = 1e9 + 7, BASE = 37;	

void solve() {
	int n;
	cin >> n;
	vec<int> l(2 * n);
	cin >> l;

	sort(all(l));

	int ans = 0;
	for (int i = 0; i < 2 * n; i += 2) {
		ans += l[i];
	}

	cout << ans << endl;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, number;
    list<int> l;
    cin >> N;
    for(int i=0; i<N; i++) {
        string command;
        cin >> command;
        if(command == "insert") {
            cin >> number;
            l.push_front(number);
        } else if(command == "delete") {
            cin >> number;
            auto itr = find(l.begin(), l.end(), number);
            if(itr!=l.end()) {
                l.erase(itr);
            }
        } else if(command == "deleteFirst") {
            l.pop_front();
        } else if(command == "deleteLast") {
            l.pop_back();
        }
    }

    ostringstream os;
    for(auto i: l) os << i << " ";
    auto s = os.str();
    s.pop_back();
    cout << s << endl;

}



Measured memory_bytes: 33852
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
#define def 0
template<class V, int NV> struct SegTree { //[l,r)
    V comp(V& l, V& r) { return l + r; };
    vector<V> val; SegTree() { val = vector<V>(NV * 2, def); }
    V get(int x,int y,int l=0,int r=NV,int k=1){if(r<=x||y<=l)return def;if(x<=l&&r<=y)return val[k];
    auto a=get(x,y,l,(l+r)/2,k*2);auto b=get(x,y,(l+r)/2,r,k*2+1);return comp(a,b);}
    void update(int i, V v) { i+=NV;val[i]=v;while(i>1)i>>=1,val[i]=comp(val[i*2],val[i*2+1]); }
    void add(int i, V v) { update(i, val[i + NV] + v); }};
/*---------------------------------------------------------------------------------------------------
????????????????????????????????? ??§?????§  
??????????????? ??§?????§ ???????´<_??? ?????? Welcome to My Coding Space!
???????????? ??? ?´_???`??????/??? ???i     
?????????????????????????????? ???  |???|     
????????? /?????? /??£??£??£??£/??????|  
??? ???_(__??????/???    ???/ .| .|????????????  
??? ????????????/????????????/??????u??????  
---------------------------------------------------------------------------------------------------*/



int N, Q;
SegTree<int, 1 << 17> st;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> Q;
    rep(i, 0, Q) {
        int c, x, y; cin >> c >> x >> y;
        if (c == 0) st.add(x - 1, y);
        else printf("%d\n", st.get(x - 1, y));
    }
}

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

int main() {
	
	string s; cin >> s;
	int ans = 0;
	for (int i = 1; i < s.size(); i++) {
		if (s[i] != s[i - 1]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3756
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		int a[] = fs.nextIntArray(n);
		int b[] = fs.nextIntArray(n);
		int c[] = fs.nextIntArray(n);
		Arrays.sort(a);
		Arrays.sort(b);
		Arrays.sort(c);
				
		int sumB[] = new int[n];
		int cnt = 0;
		for(int i=0;i<n;i++) {
			if(a[i]<b[cnt]) {
				sumB[cnt]++;
			}else {
				if(cnt+1>=n)break;
				sumB[cnt+1] = sumB[cnt];
				cnt++;
				i--;
			}			
		}
		for(int i=cnt+1;i<n;i++) {
			sumB[i]=sumB[i-1];
		}

		
		long sumC[] = new long[n];
		cnt = 0;
		for(int i=0;i<n;i++) {
			if(b[i]<c[cnt]) {
				sumC[cnt]+=sumB[i];
			}else {
				if(cnt+1>=n)break;
				sumC[cnt+1] = sumC[cnt];
				cnt++;
				i--;
			}			
		}
		for(int i=cnt+1;i<n;i++) {
			sumC[i]=sumC[i-1];
		}
		
		long ans = 0;
		for(int i=0;i<n;i++)ans+=sumC[i];
		System.out.println(ans);
	}
}

class UnionFind{
	int parent[];
	UnionFind(int N){
		parent = new int[N];
		Arrays.fill(parent, -1);
	}
	
	boolean same(int x, int y){
		return root(x)==root(y);
	}
	int root(int x) {
		if(parent[x]<0)return x;
		return parent[x] = root(parent[x]);
	}
	int size(int x) {
		return -parent[root(x)];
	}
	void unite(int x, int y) {
		if(size(x)<size(y)) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		int rx = root(x);
		int ry = root(y);
		if(rx==ry)return;
		parent[rx] += parent[ry];
		parent[ry] = rx;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

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

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

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

int main() {
	uint64_t n, k;
	cin >> n >> k;
	
	uint64_t res = 0;
	
	while (n > 0) {
		res++;
		n /= k;
	}

	cout << res << endl;

	return 0;
}

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

namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] input = new char[200000];
            int first=0;
            int last=0;
            int flag1 = 0;
            int flag2=0;
            string read =Console.ReadLine();
            input = read.ToCharArray();
            for (int c1 = 0; c1 < 200000; c1++)
            {
                if (input[c1] == 'A')
                {
                    first = c1;
                    flag1 = 1;
                    break;
                }
            }
            if (flag1 == 1)
            {
                for (int c2 = read.Length-1; c2 > 0; c2--)
                {
                    if (input[c2] == 'Z')
                    {
                        last = c2;
                        flag2 = 1;
                        break;
                    }
                }
            }

            if (flag2 == 0) Console.WriteLine(0);
            else Console.WriteLine(last - first + 1);

        }
    }
}


Measured memory_bytes: 4184
#include<stdio.h>
int main()
{

  long long int i,j,k,n,sum=0;

scanf("%lld",&n);
long long int s[n],f[200005]={0};

for(i=0;i<n;i++){
    scanf("%lld",&s[i]);
    ++f[s[i]];

}


for(i=1;i<=200000;i++){
    if(f[i]==2)
        {sum++;



        }
    else if(f[i]>2)
        {sum+=((f[i]*(f[i]-1))/2);


        }



}

for(i=0;i<n;i++){
    if(f[s[i]]==2)
        printf("%lld\n",sum-1);
    else if(f[s[i]]>2)
        printf("%lld\n",sum-(f[s[i]]-1));
    else
        printf("%lld\n",sum);


}





}



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


/* 
*    coder :: ATUL_PANDEY_2608
*        >>> INDIA <<<
*/
using namespace std;

// #define  part ..
#define listi vector<int >
#define listll vector< long long >
#define pii pair<int ,int >
#define pll pair<long long ,long long >
#define heap priority_queue<long long >
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define mod 1000000007
#define maxx 200006
#define ll long long
#define quick   ios_base::sync_with_stdio(NULL),cin.tie(0),cout.tie(0);
#define rep(i,a,b) for(int i=a;i<b;i++)
long long gcd(long long a, long long b) {
  
  if(b==0){
    return a;

  }

  return gcd(b,a%b);
}
 


// end of #define 

// define globals ...


long long ni() {
  int c = getchar();
  while (c < '0' || c > '9') c = getchar();
  long long ret = 0.0;
  while (c >= '0' && c <= '9') {
    ret = ret * 10 + c - '0';
    c = getchar();
  }
  return ret;
}




int Main(){
  

ll n;
cin>>n;

ll temp = 1000- n%1000;
cout<<(temp==1000?0:temp);








  return 0;


}












// main function..
int main ()
{
  quick;



  Main ();


}


Measured memory_bytes: 3688
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
// #include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}
string trans(int N)
{
        string S;
        while (N != 0)
        {
                if (N % 2 == 1)
                {
                        N--;
                        S = '1' + S;
                }
                else
                {
                        S = '0' + S;
                }
                N /= 2;
        }
        return S;
}

int main() //input->compute->output
{
        int H, W;
        cin >> H >> W;

        vector<string> vec(H);
        rep(i, H) { cin >> vec[i]; }

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

        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)

vector<int> M;
int N;
int memo[20][(1<<13) + 1];
bool dfs(int idx, int s){
  int& res = memo[idx][s];
  if(res != -1) return res;
  if(idx % 2 == 0){
    if(s == 1) return false;
    if(s - M[idx] <= 1) return true;
    for(int x = M[idx]; x >= 1; x--){
      if(dfs((idx + 1) % (2*N), s - x)) return res = true;
    }
    return res = false;
  }else{
    if(s == 1) return true;
    if(s - M[idx] <= 1) return false;
    for(int x = M[idx]; x >= 1; x--){
      if(!dfs((idx + 1) % (2*N), s - x)) return res = false;
    }
    return res = true;
  }
}

int main(){
  while(cin>>N && N){
    int S; cin>>S;
    M = vector<int>(2 * N);
    REP(i, 2 * N) cin>>M[i];
    memset(memo, -1, sizeof(memo));
    if(dfs(0, S)) cout<<1<<endl;
    else cout<<0<<endl;
  }
  return 0;
}

Measured memory_bytes: 1900
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{
long long int n;
scanf("%lld",&n);
long long int arr[n],t=0,i;
for(i=0;i<n;i++)
{
    scanf("%lld",&arr[i]);
    
}
for(i=0;i<n-2;i++)
{
    if(arr[i+1]>arr[i] && arr[i+1]<arr[i+2])
    t++;
    else if(arr[i+1]<arr[i] && arr[i+1]>arr[i+2])
    t++;
}
printf("%lld",t);
return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>

#include<stdio.h>
#include<stdlib.h>

#define ll long long

using namespace std;

int cnt=0;
vector<vector<int>> ki;
vector<int> flag;

void dfs(int pos){
    if(ki[pos].size()==0||flag[pos]!=-1){
        return;
    }
    flag[pos]=1;
    for(int i=0;i<ki[pos].size();i++){
        dfs(ki[pos][i]);
    }
}

int main(){
    int N,M;
    cin >> N >> M;
    ki=vector<vector<int>>(N);
    flag=vector<int>(N,-1);
    int x,y,z;
    for(int i=0;i<M;i++){
        cin >> x >> y >>z;
        ki[x-1].push_back(y-1);
        ki[y-1].push_back(x-1);
    }
    for(int i=0;i<N;i++){
        if(flag[i]!=-1){
            continue;
        }
        dfs(i);
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 9216
x = int(input())

if x >= 400 and x <= 599:
    print(int(8))
if x >= 600 and x <= 799:
    print(int(7))
if x >= 800 and x <= 999:
    print(int(6))
if x >= 1000 and x <= 1199:
    print(int(5))
if x >= 1200 and x <= 1399:
    print(int(4))
if x >= 1400 and x <= 1599:
    print(int(3))
if x >= 1600 and x <= 1799:
    print(int(2))
if x >= 1800 and x <= 1999:
    print(int(1))

Measured memory_bytes: 9188
import java.util.Scanner;
import java.lang.Math;

class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    long a = Long.parseLong(stdIn.next());
    long b = Long.parseLong(stdIn.next());
    long k = Long.parseLong(stdIn.next());

    long ansA = 0;
    long ansB = 0;
    if (a <= k) {
      ansA = 0;
      ansB = b - (k - a);
      if (ansB < 0) ansB = 0;
    } else {
      ansA = a - k;
      ansB = b;
    }

    System.out.println(ansA + " " + ansB);
  }
}


Measured memory_bytes: 21972
import sys
input = sys.stdin.buffer.readline
import numpy as np

D = int(input())
c = np.array(input().split(), dtype=np.int32)
s = np.array([input().split() for _ in range(D)], dtype=np.int32)
t = [int(input()) for _ in range(D)]
last = np.zeros(26, dtype=np.int32)
# print(s)
# print(s.shape)

ans = []
point = 0
for i in range(D):
    last[t[i]-1] = i+1
    down = (i+1-last)*c
    point += s[i, t[i]-1] - down.sum()
    print(point)


Measured memory_bytes: 27508
/**
*    author:  boutarou
*    created: 21.06.2020 21:01:10
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define fcout cout << fixed << setprecision(15)
using lint = long long;
using P = pair<int, int>;

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

const double PI = 3.1415926535897932;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    char c;
    cin >> c;
    if ('A' <= c && c <= 'Z') {
        cout << 'A' << endl;
    }
    else cout << 'a' << endl;
    
    return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>

int main(void)
{
	int a,b,c,i;
	scanf("%d%d%d",&a,&b,&c);
	for(i;i<b;i++)
		{
		if(a*(b+i)%b==c){printf("YES"); break;}
		else if(i==b-1 && a*(b+i)%b!=c){printf("NO");}
		}
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define ii pair<int,int>
#define mod 1000000007
#define endl '\n'
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=((a%mod)*(a%mod))%mod;
		b>>=1;
	}
	return ans;
}

void sieve(int n){
	bool prime[n+1];
	memset(prime,true,sizeof(prime));
	for(int p=2;p*p<=n;p++){
		if(prime[p]){
			for(int i=p*p;i<=n;i+=p)
				prime[i]=false;
		}
	}
	for(int p=2;p<=n;p++){
		if(prime[p])
			cout<<p<<" ";
	}
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		int k,x;
		cin>>k>>x;
		for(int i=(x-k+1);i<=x+k-1;i++){
			cout<<i<<" ";
		}
	}
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define ii pair <int, int>
#define x first
#define y second
#define db(x) cerr << #x << " = " << x << endl;
#define _ << " _ " <<

using namespace std;

const int N = 1e5 + 7;

int m, n, u, v, g, res;
vector <int> adj[N];
bool vis[N];
int topo[N], f[N];

void dfs(int u){
	vis[u] = true;
	for (int v: adj[u])
		if (!vis[v])
			dfs(v);
	topo[g--] = u;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	if(fopen("test.inp", "r")) freopen("test.inp", "r", stdin), freopen("test.out", "w", stdout);
	cin >> n >> m;

	g = n;

	for (int i = 1; i <= m; i++){
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
	}
	for (int i = 1; i <= n; i++)
		if (!vis[i])
			dfs(i);

	for (int i = 1; i <= n; i++){
		int u;
		u = topo[i];
		for (int v: adj[u]){
			f[v] = max(f[v], f[u] + 1);
			res = max(res, f[v]);	
		}
	}
	cout << res;
}

Measured memory_bytes: 7936
# from https://twitter.com/wakuwinmail_C/status/950277218411855872

N, Y = gets.split.map(&:to_i)

x = Y / 10000
y = Y % 10000 / 5000
z = Y % 5000 / 1000

temp=N-(x+y+z)

if temp < 0 then
    x=-1
    y=-1
    z=-1
end
while temp>0
        if temp >= 4 and y > 0
                y-=1
                z+=5
                temp-=4
        elsif x > 0
            x-=1
            y+=2
            temp-=1
        else
            x=-1
            y=-1
            z=-1
            break
        end
end
puts "#{x} #{y} #{z}"


Measured memory_bytes: 1788
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<cstdlib>
#include<set>
#include<unordered_map>
#define l(x) (x<<1)
#define r(x) ((x<<1)|1)
#define low(x) (x&(-x))
#define IL inline
#define reg register
#define LL long long
#define N 1000010
#define MOD 998244353
#define MO 1000000007
#define INF 0x3f3f3f3f
using namespace std;

LL T,n,m,i,j,k,x,y,z,Ans,sum,cnt;
LL a[N],b[N],p[N],v[N];
char c[N];

struct Data{
	LL x,y;
}d[N];

IL LL Abs(LL x){return (x<0)?-x:x;}
IL void Swap(LL &a,LL &b){a^=b^=a^=b;}
IL LL Min(LL a,LL b){return (a<b)?a:b;}
IL LL Max(LL a,LL b){return (a>b)?a:b;}
IL bool cmp(const Data a,const Data b){return a.x<b.x;}

IL LL Mi(LL x,LL y){
	LL p=x,t=1,Res=1;
	for (;t<=y;(t&y)?Res=(Res*p)%MOD:0,p=(p*p)%MOD,t<<=1);
	return Res;
}

IL LL read(){
	LL p=0,f=1;	char	c=getchar();
	while (c<48||c>57)	{if (c=='-')	f=-1;	c=getchar();}
	while (c>=48&&c<=57)	p=(p<<1)+(p<<3)+c-48,c=getchar();
	return p*f;
}

inline int Gcd(int x,int y){return (y==0)?x:Gcd(y,x%y);}

int main(){
	#ifdef __Marvolo
	freopen("zht.in","r",stdin);
	freopen("zht.out","w",stdout);
	#endif
	n=read();
	for (i=1;i<=n;i++)	a[i]=read();
	a[0]=a[1];
	for (i=1;i<=n;i++)	a[0]=Gcd(a[0],a[i]);
	if (a[0]!=1){
		puts("not coprime");
		return 0;
	}

	for (i=2;i<=1000000;i++){
		if (v[i])	continue;
		++cnt;	p[cnt]=i;	v[i]=i;
		for (j=i*i;j<=1000000;j+=i)
			if (!v[j])	v[j]=i;
	}
	v[1]=1;
	for (i=1;i<=n;i++){
		x=a[i];
		while (v[x]>1){
			if (b[v[x]] && b[v[x]]!=i)	goto END;
			b[v[x]]=i;	x/=v[x];
		}
	}
	puts("pairwise coprime");
	return 0;
	END:;
	puts("setwise coprime");
	return 0;
}

Measured memory_bytes: 20496
-- extension section
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE BangPatterns      #-}
{-# LANGUAGE CPP               #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections     #-}
-- not supported extension
--{-# LANGUAGE Strict, StrictData #-}


module Main where

-- @@@@@@@@@@@@@@@@@--
-- import section   --
-- @@@@@@@@@@@@@@@@@--
--    import A.B.C( function name )  ...
-- or import A.B.C 

--
import Prelude hiding(
  getLine,
  getContents,
  lines,
  words
  )

-- standard library
import Control.Monad.ST
import Control.Applicative
import Data.Char

-- bytestring
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B

-- containers


-- deepseq


-- regex-posix


-- text
import Data.Text.Lazy.IO as TIO
import Data.Text.Lazy as T
import Data.Text.Lazy.Read as TR

-- import Data.Text.IO as TIO
-- import Data.Text as T
-- import Data.Text.Read as TR



-- unordered-containers


-- vectors
import Data.Vector.Unboxed as UV
import Data.Vector.Unboxed.Mutable as MV


-- mtl


-- @@@@@@@@@@@@@@@@@--
-- main section     --
-- @@@@@@@@@@@@@@@@@--

main :: IO ()
main = do
  input <- getInput
  Prelude.putStr . show . getAnswer $ input 

-- main :: IO()
-- main = do
--   answer <- getInputandanser
--   putStr . show $ answer


-- @@@@@@@@@@@@@@@@@@@@@--
-- I/O DataType section --
-- @@@@@@@@@@@@@@@@@@@@@--
data Input = I (Int,[Int])
  deriving(Show)

type Answer = Int



-- @@@@@@@@@@@@@@@@@--
-- answerSection    --
-- @@@@@@@@@@@@@@@@@--
getInput :: IO Input
getInput = do
  Right (n, _) <- getLine >>= ( return . TR.decimal )
  numTexts <- UV.unfoldrN n (B.readInt.B.dropWhile isSpace) <$> B.getLine
  return (I (n, UV.toList $ numTexts) )
  where 


getAnswer :: Input -> Answer 
getAnswer ( I (_ , nums) ) = occur
  where go !n ind (x:l@(x':l'@(x'':xs))) 
          | ind == x && (ind+1) == x' = go (n+1) (ind+2) l'
          | ind == x = go (n+1) (ind+1) l
          | (ind+1) == x' && (ind+2) == x''  = go (n + 1) (ind+3) xs
          | otherwise = go n (ind + 1) l
        go !n ind (x:x':xs) | ind == x && (ind+1) == x' = go (n+1) (ind+2) xs
                           | ind == x = go (n+1) (ind+1) (x':xs)
                           | otherwise = go n (ind+1) (x':xs)
        go !n ind (x:xs)  | ind == x = go (n+1) (ind+1) xs
                         | otherwise = go n (ind + 1) xs
        go !n _ [] = n
        occur = go 0 1 nums 

getInputAndAnser :: IO Answer
getInputAndAnser = undefined


-- @@@@@@@@@@@@@@@@@@@@@@@@@@--
-- question unique section    --
-- @@@@@@@@@@@@@@@@@@@@@@@@@@--





-- @@@@@@@@@@@@@@@@@--
-- util section     --
-- @@@@@@@@@@@@@@@@@--

-- standard Input Function
gLine :: IO Text
gLine = getLine

gContents :: IO Text
gContents = getContents



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

#pragma warning(disable:4996)
using namespace std;
string root_sts = "C ,C#,D ,D#,E ,F ,F#,G ,G#,A ,A#,B ";

int solve(int l, int r, const vector<int>&nums, vector<vector<int>>&dp) {
	if (dp[l][r] != -1) {
	}
	else {
		if(l==r)dp[l][r]=0;
		else if(l+1==r)dp[l][r]=0;
		else {
			vector<int>memo(r-l);
			memo[0]=0;
			for (int x = 0; x < r - l-1; ++x) {
				for (int num = 1; num <= r-l-x-1; ++num) {
					int plus=abs(nums[l]-nums[l+x+1])+
						solve(l+x+1,l+x+num+1,nums,dp);
					memo[x+num]=max(memo[x+num],
						memo[x]+plus);
				}
			}
			dp[l][r]=memo[r-l-1];
		}
	}
	return dp[l][r];
}

int main() {
	int Q;cin>>Q;
	while (Q--) {
		int N;cin>>N;
		vector<int>nums(N);
		for(int i=0;i<N;++i)cin>>nums[i];
		nums.insert(nums.end(),nums.begin(),nums.end());
		vector<vector<int>>dp(2*N,vector<int>(2*N,-1));
		int ans=0;
		for (int i = 0; i < N; ++i) {
			ans=max(ans,solve(i,i+N,nums,dp));
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3196