akhauriyash/Code-Regression huggingface dataset:
(n, m) = [int(i) for i in input().split()]
arr = [[] for i in range(n)]
for i in range(n):
    arr[i] = [int(i) for i in input().split()]
res = -1


def vo(fn):
    global res
    global arr
    gue = []
    for a in arr:
        gue.append(fn(*a))
    gue.sort(reverse=True)
    res = max(res, sum(gue[:m]))

vo(lambda x, y, z: x + y + z)
vo(lambda x, y, z: - x + y + z)
vo(lambda x, y, z: x - y + z)
vo(lambda x, y, z: x + y - z)
vo(lambda x, y, z: - x + y - z)
vo(lambda x, y, z: x - y - z)
vo(lambda x, y, z: - x - y + z)
vo(lambda x, y, z: - x - y - z)
print(res)


Measured memory_bytes: 3300
#include<iostream>
#include<cstdio>
#include<cmath>
#define _USE_MATH_DEFINES
#include<math.h>
using namespace std;


void kock(int n, double p1x,double p1y,double p2x,double p2y){
    double sx,sy,tx,ty,ux,uy;
    if (n == 0){
        return;
    }
    sx=(2*p1x + p2x)/3;
    sy=(2*p1y + p2y)/3;
    tx=(p1x + 2*p2x)/3;
    ty=(p1y + 2*p2y)/3;
    ux=(tx-sx)*cos(M_PI/3)-(ty-sy)*sin(M_PI/3)+sx;
    uy=(tx-sx)*sin(M_PI/3)+(ty-sy)*cos(M_PI/3)+sy;
    
    
    kock(n-1, p1x,p1y,sx,sy);
    printf("%lf %lf",sx,sy);
    cout<<endl;
    kock(n-1, sx,sy,ux,uy);
    printf("%lf %lf",ux,uy);
    cout<<endl;
    kock(n-1, ux,uy,tx,ty);
    printf("%lf %lf",tx,ty);
    cout<<endl;
    kock(n-1, tx,ty,p2x,p2y);
}

int main(){
    int n;
    double p1x=0,p1y=0,p2x=100,p2y=0;
    cin>>n;
    printf("%lf %lf",p1x,p2y);
    cout<<endl;
    kock( n, p1x,p1y,p2x,p2y);
    printf("%lf %lf",p2x,p2y);
    cout<<endl;
    return 0;
}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define int long long
using namespace std;
using Graph = vector<vector<int>>;
const int MOD = 998244353;

const int MAX = 510000;
int fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
int COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main() {
  
  COMinit();
  
  int N, A, B, K;
  cin >> N >> A >> B >> K;
  
  int ans = 0;
  for( int a = 0; a <= N; a++ ){
    if( a*A > K ) break;
    //割り切れないときは0組
    if( (K-A*a)%B != 0 ) continue;
    int b = (K-A*a)/B;
    //bがN以上になるときも0組
    if( b > N ) continue; 
    ans += (COM(N, a)%MOD*COM(N, b)%MOD)%MOD;
    ans %= MOD;
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 12160
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <boost/range/adaptors.hpp>
#include <iomanip>

int main() {
    int N;
    int X;
    int Y;
    std::cin >> N >> X >> Y;

    std::vector<int> distance_table(N, 0);
    for (int start = 1; start < N; ++start) {
        for (int goal = start + 1; goal <= N; ++goal) {
            int distance;
            if (Y <= start) {
                distance = goal - start;
            } else if (X <= start) {
                distance = std::min(goal - start,
                                    start - X + 1 + static_cast<int>(std::abs(Y - goal)));
            } else {
                distance = std::min(goal -start,
                                    X - start + 1 + static_cast<int>(std::abs(Y - goal)));
            }
            // } else if (goal <= X) {
            //     distance = goal - start;
            // } else if (goal <= (X + Y) / 2.0) {
            //     distance = goal - start;
            // } else if (goal <= Y) {
            //     distance = X - start + 1 + Y - goal;
            // } else {
            //     distance = X - start + 1 + goal - Y;
            // }
            distance_table[distance] += 1;
            // std::cout << start << ", " << goal << ", " << distance << std::endl;
        }
    }
    for (int i = 1; i <= N - 1; ++i) {
        std::cout << distance_table[i] << std::endl;
    }


    // std::vector<int> A(N, 0);
    // for (int i = 0; i < N; ++i) {
    //     std::cin >> A[i];
    // }
    // // std::vector<int> distance(N, 0);
    // int max_distance = -1;
    // for (int i = 1; i < N; ++i) {
    //     // distance[i - 1] = A[i] - A[i - 1];
    //     max_distance = std::max(max_distance, A[i] - A[i - 1]);
    // }
    //     max_distance = std::max(max_distance,K + A[0] - A[N - 1]);
    // // distance[N - 1] = K + A[0] - A[N - 1];
    // // for (int i = 0; i < N; ++i) {
    // //     std::cout << distance[i] << std::endl;
    // // }
    // std::cout << K - max_distance << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
bool bo[100];
#define ll long long int
int main()
{
	ll n;
	cin>>n;
	ll a[n+10],b[n+10];
	for(ll i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
	}
	ll q=a[0],w=b[0];
	for(ll i=1;i<n;i++)
	{
		ll mi=max(q/a[i],w/b[i]);
		ll d=mi;
		ll q1=mi*a[i],q2=mi*b[i];
		//cout<<q<<" "<<w<<endl;
		//cout<<d<<endl;
		while(1)
		{
			if(q1>=q&&q2>=w)
			{
				break;
			}
			q1+=a[i];
			q2+=b[i];
			d++;
		}
		//cout<<d<<endl;
		q=a[i]*d;
		w=b[i]*d;
		//cout<<q<<" "<<w<<endl;
	}
	cout<<q+w<<endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
res = True
for n in range(N):
    if A[n] % 2 == 0:
        if A[n] % 3 != 0 and A[n] % 5 != 0:
            res = False
if res:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define the_flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
 
using namespace std;
 
int main()
{
    the_flash;
    int count = 0, max = 0;
    string s;
    cin >> s;

    for (int i = 0; i < 3; i++)
    {
        if (s[i] == 'R')
        {
            while (s[i] == 'R')
            {
                count++;
                i++;
            }
        }

        if (count > max)
        {
            max = count;
            count = 0;
        }
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 3632
D = [[-1, 0], [1, 0], [0, -1], [0, 1]]

def puyo_rensa(cnt, fld)
  erase = 8.times.map{ [false] * 14 }
  visit = 8.times.map{ [false] * 14 }
  res = 0
  (1..6).each do |i|
    (1..12).each do |j|
      if !visit[i][j] && fld[i][j] =~ /[^O.]/
        puyo_connector(i, j, fld, visit){ |arr|
          arr.each do |s, t|
            D.each do |x, y|
              p, q = s + x, t + y
              erase[p][q] = true if fld[p][q] == 'O'
            end
            erase[s][t] = true
          end
          res = 1
        }
      end
    end
  end
  (1..6).each do |i|
    fld[i].map!.with_index{ |c, j| c unless erase[i][j] }.compact!
    (14 - fld[i].size).times{ fld[i].unshift('.') }
  end
  if res == 1 then puyo_rensa(cnt + 1, fld)
  else cnt
  end
end

def puyo_connector(i, j, fld, visit)
  arr = [[i, j]]
  ret = [[i, j]]
  visit[i][j] = true
  until arr.empty?
    i, j = arr.shift
    D.each do |x, y|
      p, q = i + x,  j + y
      if !visit[p][q] && fld[i][j] == fld[p][q]
        visit[p][q] = true
        arr << [p, q]
        ret << [p, q]
      end
    end
  end
  yield(ret) if ret.size >= 4
end

gets.to_i.times do
  fld = 8.times.map{ ['.'] * 14 }
  12.times do |i|
    gets.chomp.split('').each_with_index do |c, j|
      fld[j+1][i+1] = c
    end
  end
  p puyo_rensa(0, fld)
end

Measured memory_bytes: 9160
import sys, random
input = sys.stdin.readline
def main():
    D = int(input())
    c = list(map(int, input().split()))
    s = []
    for _ in range(D):
        si = list(map(int, input().split()))
        s.append(si)
    last_list = [0] * 26
    minus_sat_list = [0] * 26
    for i in range(D):
        for j in range(26):
            minus_sat_list[j] += c[j] * (i+1-last_list[j])
        best_idx = 0
        worst_sat, worst_sat_idx  = 0, -1
        worst2_sat, worst2_sat_idx  = 0, -1
        worst3_sat, worst3_sat_idx  = 0, -1
        worst4_sat, worst4_sat_idx  = 0, -1
        worst5_sat, worst5_sat_idx  = 0, -1
        for j in range(26):
            if (minus_sat_list[j] > worst_sat) or (minus_sat_list[j] == worst_sat and s[i][j] > s[i][worst_sat_idx]):
                worst_sat = minus_sat_list[j]
                worst_sat_idx = j
            elif (minus_sat_list[j] > worst2_sat) or (minus_sat_list[j] == worst2_sat and s[i][j] > s[i][worst2_sat_idx]):
                worst2_sat = minus_sat_list[j]
                worst2_sat_idx = j
            elif (minus_sat_list[j] > worst3_sat) or (minus_sat_list[j] == worst3_sat and s[i][j] > s[i][worst3_sat_idx]):
                worst3_sat = minus_sat_list[j]
                worst3_sat_idx = j
            elif (minus_sat_list[j] > worst4_sat) or (minus_sat_list[j] == worst4_sat and s[i][j] > s[i][worst4_sat_idx]):
                worst4_sat = minus_sat_list[j]
                worst4_sat_idx = j
            elif (minus_sat_list[j] > worst5_sat) or (minus_sat_list[j] == worst5_sat and s[i][j] > s[i][worst5_sat_idx]):
                worst5_sat = minus_sat_list[j]
                worst5_sat_idx = j
        worst_val = s[i][worst_sat_idx] * 2 - 10000 + worst_sat
        worst2_val = s[i][worst2_sat_idx] * 2 - 10000 + worst2_sat
        worst3_val = s[i][worst3_sat_idx] * 2 - 10000 + worst3_sat
        worst4_val = s[i][worst4_sat_idx] * 2 - 10000 + worst4_sat
        worst5_val = s[i][worst5_sat_idx] * 2 - 10000 + worst5_sat
        best_val = max(worst_val, worst2_val, worst3_val, worst4_val, worst5_val)
        if best_val == worst_val:
            best_idx = worst_sat_idx
        elif best_val == worst2_val:
            best_idx = worst2_sat_idx
        elif best_val == worst3_val:
            best_idx = worst3_sat_idx
        elif best_val == worst4_val:
            best_idx = worst4_sat_idx
        elif best_val == worst5_val:
            best_idx = worst5_sat_idx
        minus_sat_list[best_idx] = 0
        last_list[best_idx] = i + 1
        print(best_idx+1)
if __name__ == "__main__":
    main()

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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

template<typename T>
bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>
bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

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

	auto N=in(),B=in();

	out(N*B);
	return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>

int main(){
	int a,b;
	while(1){
		scanf("%d %d", &a, &b);
		if(a == 0 && b == 0)break;
		if(a<b)printf("%d %d\n", a, b);
		else   printf("%d %d\n", b, a);
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<long int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  int four = 0;
  for(int i = 0; i < n; i++){
    if(a.at(i) % 4 == 0) four++;
  }
  if(four >= n / 2){
    cout << "Yes";
    return 0;
  }
  int sa;
  sa = (n / 2) - four;
  int two = 0;
  for(int i = 0; i < n; i++){
    if(a.at(i) % 4 != 0){
      if(a.at(i) % 2 == 0){
        two++;
      }
    }
  }
  if(n % 2 == 0){
    if(sa == 1){
      if(two > 1){
        cout << "Yes";
        return 0;
      }
    }
  }
  if(two >= sa * 2){
    cout << "Yes";
  }else{
    cout << "No";
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define FPEN2 freopen("out.txt", "w", stdout);
#else
#define FPEN
#define FPEN2
#endif
const int maxn = 200009;
const int MOD = 1e9 + 7;
int A[1111], B[1111], C[1111], D[1111], E[1111], F[1111];
bool vis[3333][3333];
bool dir[3333][3333][4];
int main() {
  FPEN FPEN2;
  ios_base::sync_with_stdio(false), cout.tie(0), cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<int> X, Y;
  for (int i = 0; i < N; ++i) {
    cin >> A[i] >> B[i] >> C[i];
    X.push_back(A[i]);
    X.push_back(B[i]);
    Y.push_back(C[i]);
  }
  for (int i = 0; i < M; ++i) {
    cin >> D[i] >> E[i] >> F[i];
    X.push_back(D[i]);
    Y.push_back(E[i]);
    Y.push_back(F[i]);
  }
  X.push_back(MOD), Y.push_back(MOD), X.push_back(-MOD), Y.push_back(-MOD), X.push_back(0), Y.push_back(0);
  sort(X.begin(), X.end());
  sort(Y.begin(), Y.end());
  X.erase(unique(X.begin(), X.end()), X.end());
  Y.erase(unique(Y.begin(), Y.end()), Y.end());
  for (int i = 0; i < N; ++i) {
    A[i] = lower_bound(X.begin(), X.end(), A[i]) - X.begin();
    B[i] = lower_bound(X.begin(), X.end(), B[i]) - X.begin();
    C[i] = lower_bound(Y.begin(), Y.end(), C[i]) - Y.begin();
    for (int j = A[i]; j < B[i]; ++j) {
      dir[j][C[i]][0] = 1;
      dir[j][C[i] - 1][1] = 1;
    }
  }
  for (int i = 0; i < M; ++i) {
    D[i] = lower_bound(X.begin(), X.end(), D[i]) - X.begin();
    E[i] = lower_bound(Y.begin(), Y.end(), E[i]) - Y.begin();
    F[i] = lower_bound(Y.begin(), Y.end(), F[i]) - Y.begin();
    for (int j = E[i]; j < F[i]; ++j) {
      dir[D[i]][j][2] = 1;
      dir[D[i] - 1][j][3] = 1;
    }
  }
  vector<pair<int, int>> que;
  long long ans = 0;
  que.emplace_back(lower_bound(X.begin(), X.end(), 0) - X.begin(), lower_bound(Y.begin(), Y.end(), 0) - Y.begin());
  for (int i = 0; i < que.size(); ++i) {
    int x = que[i].first, y = que[i].second;
    if (x == 0 || x == X.size() - 1 || y == 0 || y == Y.size() - 1) {
      cout << "INF";
      return 0;
    }
    ans += 1ll * (X[x + 1] - X[x]) * (Y[y + 1] - Y[y]);
    vis[x][y] = 1;
    if (!dir[x][y][0] && !vis[x][y - 1]) {
      vis[x][y - 1] = 1;
      que.emplace_back(x, y - 1);
    }
    if (!dir[x][y][1] && !vis[x][y + 1]) {
      vis[x][y + 1] = 1;
      que.emplace_back(x, y + 1);
    }
    if (!dir[x][y][2] && !vis[x - 1][y]) {
      vis[x - 1][y] = 1;
      que.emplace_back(x - 1, y);
    }
    if (!dir[x][y][3] && !vis[x + 1][y]) {
      vis[x + 1][y] = 1;
      que.emplace_back(x + 1, y);
    }
  }
  cout << ans << '\n';
  return 0;
}
// <-:0 ->:1 ^:2 v:3

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

int main()
{
    int n;
    cin >> n;
    vector <long long> v;
    while (n--) {
        int d;
        cin >> d;
        if (d == 0) {
            long long x;
            cin >> x;
            v.push_back(x);
        }
        else if (d == 1) {
            int q;
            cin >> q;
            cout << v[q] << endl;
        }
        else {
            v.pop_back();
        }
    }
}

// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单

// 入门使用技巧: 
//   1. 使用解决方案资源管理器窗口添加/管理文件
//   2. 使用团队资源管理器窗口连接到源代码管理
//   3. 使用输出窗口查看生成输出和其他消息
//   4. 使用错误列表窗口查看错误
//   5. 转到“项目”>“添加新项”以创建新的代码文件，或转到“项目”>“添加现有项”以将现有代码文件添加到项目
//   6. 将来，若要再次打开此项目，请转到“文件”>“打开”>“项目”并选择 .sln 文件



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

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

  vector<int> H(N);
  for(int i = 0; i < N; i++){
    cin >> H[i];
  }
  sort(H.begin(), H.end());

  long long ans = 0;
  //ans += min(N, K);
  for(int i = 0; i < N - K; i++){
    ans += H[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

int main() {
    ll N;
    cin >> N;
    vector<ll> Ais;
    for (int i = 0; i < N; i++) {
        ll Ai;
        cin >> Ai;
        Ais.push_back(Ai);
    }
    auto dp = make_vec_nd((ll)0, N, 2); // dp[n][f] = (n番目まで使うときの最大値、ただしi=1のときはAis[n]を一つ減らした問題に対する解)
    dp[0][0] = Ais[0]/2;
    dp[0][1] = max((ll)0, Ais[0]-1)/2;
    for (int n = 1; n < N; n++) {
        dp[n][0] = dp[n-1][0] + Ais[n]/2;
        if (Ais[n] > 0 && Ais[n-1] > 0) {
            dp[n][0] = max(dp[n][0], dp[n-1][1] + (Ais[n]-1)/2 + 1);
        }
        dp[n][1] = dp[n-1][0] + max((ll)0, Ais[n]-1)/2;
        if (Ais[n] - 1 > 0 && Ais[n-1] > 0) {
            dp[n][1] = max(dp[n][1], dp[n-1][1] + (Ais[n]-2)/2 + 1);
        }
    }
    cout << dp[N-1][0] << endl;
}

Measured memory_bytes: 6516
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <memory>        // unique_ptr, shared_ptr, weak_ptr

using namespace std;

int main() {
    int x, y, d, r;
    double f, dx, dy;
    cin >> x >> y;
    
    d = x / y;
    r = x % y;
    
    dx = x;
    dy = y;
    f = dx / dy;
    
    
    cout << d << " " << r << " ";
    printf("%.5f\n", f);
    return 0;		 
}


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

int main() {
  int n;
  cin >> n;
  vector<int> list(n);
  for(int i=0;i<n;i++) {
    cin >> list.at(i);
  }
  int temp=0;
  int ans=0;
  for(int i=n-2;i>-1;i--) {
    if(list.at(i)>=list.at(i+1)) {
      temp++;
      ans=max(ans,temp);
    }
    else {
      temp=0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
use std::str::FromStr;
use std::cmp::max;
use std::cmp::min;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let n : i32 = get_one();
    let k : i32 = get_one();
    let x : i32 = get_one();
    let y : i32 = get_one();
    println!("{}", min(k, n) * x + max(0, n-k) * y);
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = int.Parse(ReadLine());
        var a = new int[n];
        var sum = 0;
        for(int i = 0; i < n; i++)
        {
            a[i] = int.Parse(ReadLine());
            sum += a[i];
        }
        if(sum % 10 == 0)
        {
            if(a.Where(x => x % 10 != 0).ToArray().Length > 0)
                sum -= a.Where(x => x % 10 != 0).Min();
            else
                sum = 0;
        }
        WriteLine(sum);
    }
}


Measured memory_bytes: 18776
#include <iostream>
using namespace std;
#include<bits/stdc++.h>
int ans(string s,string t){
  if(s==t)return 0;
  int a=0;
  for(int i=0;i<s.length();i++){
    if(s[i] !=t[i]) a++;
  }
  return a;
}
int main() {
	string s,t;
    cin>>s>>t;
    cout<<ans(s,t);
	return 0;
}

Measured memory_bytes: 4044
a=list(map(int,input().split()))
b=[]
c=0
r=0
for i in range(a[1]):
  b.append(list(map(int,input().split())))
b=sorted(b,key=lambda b:b[1])

for i in range(a[1]):
  if b[i][0]<=r:
    continue
  else:
    c=c+1
    r=b[i][1]-1

print(c)

Measured memory_bytes: 29840
#include<bits/stdc++.h>
using namespace std;
typedef int64_t LL;
const int MOD=1e9+7;
int main()
{
  int N,K;
  LL A=1;
  cin>>N>>K;
  for(LL i=K;i<N+1;i++)A=(A+i*(N-i+1)+1)%MOD;
  return cout<<A<<endl,0;
}

Measured memory_bytes: 3624
import qualified Data.ByteString.Char8 as BS
import Data.Array
import Data.List
import Control.Monad

calc :: Array Int (Double,Double) -> [Int] -> Double
calc a xs = let xs' = zip xs (tail xs)
             in foldl' f 0 xs'
  where
    f ac (i,j) = let (ix,iy) = a!i
                     (jx,jy) = a!j
                  in ac + (sqrt (((ix-jx)^2) + ((iy-jy)^2)))

main :: IO ()
main = do
    n <- readLn :: IO Int
    xy <- map ((\[a,b] -> (a,b)) . map ((read :: String -> Double) . BS.unpack) . BS.words)
        . BS.lines <$> BS.getContents :: IO [(Double,Double)]

    let p = permutations [1..n]
        a = listArray (1,n) xy
    print $ (foldl' (\ac x -> ac + calc a x) 0 p) / (fromIntegral (length p) :: Double)

Measured memory_bytes: 11644
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
int main()
{
    lint N, A, B;
    cin >> N >> A >> B;
    lint x = N / (A + B);
    lint y = N % (A + B);
    lint ans = x * A + min(y, A);
    cout << ans << endl;
}

Measured memory_bytes: 256
S=list(input())
N=len(S)

li=[S[0]]

for i in range(1,N):
    f=[]
    for j in li:
        f.append(j+S[i])
        f.append(j+"+"+S[i])
        li=f
ans=0
for s in li:
    sum1=0
    temp=0
    for i in range(len(s)):
        if s[i]=="+":
            sum1+=temp
            temp=0
        else:
            temp=temp*10+int(s[i])
    sum1+=temp
    ans+=sum1

print(ans)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int MOD = 1e9+7;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	int sum=0;
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	int k,c=1;
	if(n%2==0)
	{
	k=1;
	for(int i=0;i<n;i+=2)
	{
		if(a[i]==k && a[i+1]==k)
		{
			c*=2;
			c%=MOD;
		}
		else
		{
			cout << 0; return 0;
		}
		k+=2;
	}
	}
	else
	{
		k=2;
		for(int i=1;i<n;i+=2)
		{
			if(a[i]==k && a[i+1]==k)
			{
				c*=2;
				c%=MOD;
			}
			else
			{
				cout << 0; return 0;
			}
			k+=2;
		}
	}
	cout << c%MOD;
	return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), l = sc.nextInt();
		sc.close();
		int sum = n * (l - 1) + ((n + 1) * n / 2);
		if (l >= 0)
			sum -= l;
		else {
			if (Math.abs(l) >= n)
				sum -= (l + n - 1);
		}

		System.out.println(sum);
	}
}


Measured memory_bytes: 22612
const main = (arg) => {
  const lines = arg.trim().split('\n');
  const R = Number.parseInt(lines[0]);
  console.log(R < 1200 ? 'ABC' : R < 2800 ? 'ARC' : 'AGC');
};
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29472
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = stdIn.nextInt();
		
		int d = 10*b + c;
		
		if (d % 4 == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}
		

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    cout << pow(n,2) << endl;



}

Measured memory_bytes: 256
def check(a,b):
    cnt=0
    for x in range(len(a)):
        if a[x]!=b[x]:
            cnt+=1
    return cnt        
s=input()
t=input()
k=len(t)
ans=k
for x in range(len(s)-len(t)+1):
    ans=min(ans,check(s[x:x+k],t))
print(ans)    

    

Measured memory_bytes: 9112
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
using namespace std;

long long a[100010][3]; //a[i],b[i],c[i]をそれぞれまとめてa[i][0],a[i][1],a[i][2]にしてしまう

//DPテーブル
long long dp[100010][3];

int main(){
    int n; cin >> n;
    for ( int i = 0 ; i < n ; i++ ){
        for ( int j = 0 ; j< 3 ; j++ ) cin >> a[i] [j];
    }

    //初期化は既に0に初期化される
    //初期条件も既に0でOK

    //ループ
    for ( int i = 0 ; i < n; i++){
        for ( int j = 0 ; j < 3 ; j++ ){
            for ( int k = 0 ; k < 3 ; k++ ){
                if ( j == k ) continue;
                dp[i+1][k] = max(dp[i+1][k],dp[i][j] + a[i][k]);
            }

        }
    }
    //答え
    long long ans = 0 ;
    for ( int j = 0 ; j < 3 ; j++) ans = max(ans,dp[n][j]);
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
 
#define sec second
#define fir first
#define mo  998244353
#define inf 1e18
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rrep(i,s,n) for(ll i=s;i>=n;i--)
#define adiii\                               
  ios_base::sync_with_stdio(false);\                                      
  cin.tie(NULL);\
  cout.tie(NULL);									
 
ll mod(ll n) { return (n % (ll)mo + (ll)mo)%(ll)mo;}
ll gcd(ll a,ll b) {if (b == 0) return a;return gcd(b, a % b);}

int main(){
	adiii
	string s;cin>>s;
	ll n = s.length();
	vector <ll> cnt(2019,0);
	cnt[0]=1;
	ll ans=0;
	ll t=1;
	ll num=0;
	rrep(i,n-1,0){
		num += (t*(s[i] - '0'));
		num = num%2019;
		t = (t*10)%2019;
		ans += cnt[num]++;
		
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3744
#include <stdio.h>
using namespace std;

int n, q;
char s[200001], t[200000], d[200000];

char last_place(int index){
    for(int i=0; i<q; i++){
        if(s[index]==t[i]){
            if(d[i]=='R') index++;
            else index--;
        }
        if(index==-1) return 'l'; // lift
        else if(index==n) return 'r'; // right
    }
    return 'i'; // inside
}

int l_limit(int l, int r){
    int mid = (r + l) / 2;
    if(mid == r) return mid-1;
    else if(mid == l) return mid;

    char result = last_place(mid);
    if(result == 'l') return l_limit(mid, r);
    return l_limit(l, mid);
}

int r_limit(int l, int r){
    int mid = (r + l) / 2;
    if(mid == r) return mid;
    else if(mid == l) return mid + 1;

    char result = last_place(mid);
    if(result == 'r') return r_limit(l, mid);
    return r_limit(mid, r);
}

int main(){
    scanf("%d%d", &n, &q);
    scanf("%s", s);
    for(int i=0; i<q; i++){
        scanf(" %c %c", &t[i], &d[i]);
    }

    int vanish_left = l_limit(-1, n) + 1;
    int vanish_right = n - r_limit(-1, n);

    printf("%d\n", n - vanish_left - vanish_right);
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define inf (long long)(1e16)
using namespace std;

struct node {
  int n;
  long long time, change;
  bool operator<(const node &r) const {
    if(time != r.time) return time > r.time;
    return change > r.change;
  }
  bool operator!=(const node &r) const {
    return n != r.n || time != r.time || change != r.change;
  }
};

struct edge {
  long long to, time;
};

long long n, t, cnt = 0, stations = 2;
string a, b;
map<string, int> mp;
vector<int> smemo;
vector<vector<int>> id;
vector<vector<edge>> edges;
vector<bool> added;
vector<node> dist;
priority_queue<node> pq;

void solve();

int main() {
  cin >> n >> t >> a >> b;
  mp[a] = 0;
  mp[b] = 1;
  id.resize(2);
  for(int i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    for(int j = 0; j < x; ++j) {
      string str;
      cin >> str;
      if(mp.find(str) == mp.end()) {
        ++stations;
        mp[str] = id.size();
        id.push_back(vector<int>(0));
        assert(mp.size() == id.size());
      }
      edges.push_back(vector<edge>(0));
      smemo.push_back(mp[str]);
      id[mp[str]].push_back(cnt++);
      assert(smemo.size() == cnt);
    }
    for(int j = 0; j < x - 1; ++j) {
      long long nt;
      cin >> nt;
      edges[cnt - x + j].push_back({cnt - x + j + 1, nt});
      edges[cnt - x + j + 1].push_back({cnt - x + j, nt});
    }
  }
  solve();
  return 0;
}

void solve() {
  node res = {-1, inf, inf};
  added.assign(stations, 0);
  added[0] = 1;
  dist.assign(cnt, res);
  for(auto p : id[0]) {
    pq.push({p, 0, 0});
    dist[p] = {p, 0, 0};
  }
  while(pq.size()) {
    node now = pq.top();
    pq.pop();
    if(dist[now.n] != now) continue;
    if(!added[smemo[now.n]]) {
      added[smemo[now.n]] = 1;
      node nextp = now;
      ++nextp.change;
      nextp.time += t;
      for(auto p : id[smemo[now.n]])
        if(dist[p] < nextp) {
          nextp.n = p;
          dist[p] = nextp;
          pq.push(nextp);
        }
    }
    for(auto e : edges[now.n]) {
      node nextp = now;
      nextp.n = e.to;
      nextp.time += e.time;
      if(dist[nextp.n] < nextp) {
        dist[nextp.n] = nextp;
        pq.push(nextp);
      }
    }
  }
  for(auto p : id[1]) res = max(res, dist[p]);
  if(res.n == -1)
    cout << -1 << endl;
  else
    cout << res.time << " " << res.change << endl;
}


Measured memory_bytes: 24428
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};


#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


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


int N;
int a[200010];



void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N;
    for(int i = 0; i < N; i++) cin >> a[i];
    
    
    int checkIdx = 1;
    bool isOneExist = false;
    for (int i = 0; i < N; i++) {
        if(a[i]==checkIdx){
            isOneExist = true;
            checkIdx++;
        }
    }
    
    if(isOneExist){
        cout << N - (checkIdx-1)  << endl;
    }else{
        cout << -1 << endl;
    }
    
    
    
    
}



signed main() {
    solve();
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>

using namespace std;


int main() {
	int n, h, w;

	cin >> n >> h >> w;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		if (a >= h && b >= w) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
toInt x = read x ::Int

main = do
  s <- getLine
  let [a, b] = map toInt . words $ s
  if a == 0 && b == 0 then
    return ()
  else do
    if a <= b then
      putStrLn (show a ++ " " ++ show b)
    else do
      putStrLn (show b ++ " " ++ show a)
    main

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

#define SIZE_OF_ARRAY(array) sizeof(array)/sizeof(array[0])

int main() {
    string S;
    cin >> S;
    if( S == "ABC"){
        cout << "ARC" << endl;
    } else if(S == "ARC" ){
        cout << "ABC" <<  endl;
    }
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl;
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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 prime_map(map<ll, ll> &m, ll num) {

    if (num == 1) {
        return;
    }
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }
    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }

        return;
    }
    prime_map(m, num);
    return;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

class Main {

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

	public void surprise() {
		Scanner scanner = new Scanner(System.in);
		int numOps = scanner.nextInt();
		int key, pri;
		Node root = null;

		for(int i = 0; i < numOps; i++) {
			String op = scanner.next();

			if(op.equals("insert")) {
				key = scanner.nextInt();
				pri = scanner.nextInt();
				root = insert(root, key, pri);
			} else if(op.equals("find")) {
				key = scanner.nextInt();
				System.out.println(find(root, key) ? "yes" : "no");
			} else if(op.equals("delete")) {
				key = scanner.nextInt();
				root = erase(root, key);
			} else if(op.equals("print")) {
				printTreap(root);
			}
		}
	}

	public Node rightRotate(Node t) {
		Node s = t.left;
		t.left = s.right;
		s.right = t;
		return s;
	}

	public Node leftRotate(Node t) {
		Node s = t.right;
		t.right = s.left;
		s.left = t;
		return s;
	}

	public Node insert(Node t, int key, int pri) {
		if(t == null)
			return new Node(key, pri);

		if(key == t.key)
			return t;

		if(key < t.key) {
			t.left = insert(t.left, key, pri);
			if(t.pri < t.left.pri)
				t = rightRotate(t);
		} else {
			t.right = insert(t.right, key, pri);
			if(t.pri < t.right.pri)
				t = leftRotate(t);
		}

		return t;
	}

	public Node erase(Node t, int key) {
		if(t == null)
			return null;

		if(key == t.key) {
			if(t.left == null && t.right == null)
				return null;
			else if(t.left == null)
				t = leftRotate(t);
			else if(t.right == null)
				t = rightRotate(t);
			else {
				if(t.left.pri > t.right.pri)
					t = rightRotate(t);
				else 
					t = leftRotate(t);
			}

			return erase(t, key);
		}

		if(key < t.key)
			t.left = erase(t.left, key);
		else
			t.right = erase(t.right, key);

		return t;
	}

	public boolean find(Node root, int target) {
		if(root == null)
			return false;

		if(root.key == target)
			return true;
		else if(root.key < target)
			return find(root.right, target);
		else
			return find(root.left, target);
	}

	public void printTreap(Node root) {
		inorderTraverse(root);
		System.out.println();
		preorderTraverse(root);
		System.out.println();
	}

	private void inorderTraverse(Node root) {
		if(root != null) {
			inorderTraverse(root.left);
			System.out.print(" " + root.key);
			inorderTraverse(root.right);
		}
	}

	private void preorderTraverse(Node root) {
		if(root != null) {
			System.out.print(" " + root.key);
			preorderTraverse(root.left);
			preorderTraverse(root.right);
		}
	}

	class Node {
		int key;
		int pri;
		Node left;
		Node right;

		public Node(int k, int p) {
			key = k;
			pri = p;
			left = null;
			right = null;
		}
	}
}



Measured memory_bytes: 184860
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N;
  cin >> N;
  vector<ll> a(N);
  for (ll i = 0; i < N; ++i) {
    cin >> a.at(i);
    a.at(i) -= 1;
  }
  ll ans = 0;
  for (ll i = 0; i < N; ++i) {
    if (a.at(a.at(i)) == i) {
      ans += 1;
    }
  }
  cout << ans / 2 << "\n";
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef vector< lli > vec;
typedef vector< vec > mat;
 
/*
lli modmul(lli a,lli b,lli m){
  lli r=0;
  for(;b;b>>=1,a=(a<<1)%m)
    if(b&1)
      r=(r+a)%m;
  return r;
}
*/
lli modmul(lli a,lli b,lli m){
  return (((a*(b>>20)%m)<<20)+a*(b&((1<<20)-1)))%m;
}
 
mat matmul(mat &a,mat &b,lli m){
  mat res(a.size(),vec(b[0].size()));
  for(int i=0;i<(int)res.size();i++){
    for(int j=0;j<(int)res[i].size();j++){
      res[i][j]=0;
      for(int k=0;k<(int)b.size();k++){
    res[i][j]+= modmul(a[i][k],b[k][j],m);
    res[i][j]%=m;
      }
    }
  }
  return res;
}
 
mat matpow(mat &a,lli n,lli m){
  mat res(a.size(),vec(a.size()));
  mat x(a.size(),vec(a.size()));
 
  for(int i=0;i<(int)res.size();i++)
    for(int j=0;j<(int)res.size();j++)
      res[i][j]=(i==j?1:0);
 
  for(x=a ; n ; n>>=1,x=matmul(x,x,m) )
    if(n&1)res=matmul(res,x,m);
  return res;
}
 
 
 
 
lli N,M,A,B,C,T;
 
void solve(){
  mat base(N,vec(N));
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++)base[i][j]=0;
    if(i>0)base[i][i-1]=A%M;
    base[i][i]=B%M;
    if(i+1<N)base[i][i+1]=C%M;
  }
  base = matpow(base,T,M);
  mat ans(N,vec(1));
  for(int i=0;i<N;i++)cin>>ans[i][0];
  ans=matmul(base,ans,M);
  for(int i=0;i<N;i++){
    if(i)cout<<' ';
    cout<<ans[i][0];
  }
  cout<<endl;
}
 
int main(){
  while(cin>>N>>M>>A>>B>>C>>T){
    if(N==0&&M==0&&A==0&&B==0&&C==0&&T==0)break;
    solve();
  }
  return 0;
}

Measured memory_bytes: 1304
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int first = (c+b-1)/b;
	int second = (a+d-1)/d;
	if(first <= second){
		cout << "Yes";
	}else{
		cout << "No";
	}
	return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int N; cin >> N;
  int64_t C, K; cin >> C >> K;
  vector<int64_t> T(N);
  rep(i, N) {
    cin >> T[i];
  }
  sort(T.begin(), T.end());
  int first = 0;
  int ans = 1;
  int landing = 1;
  REP(i, 1, N) {
    if (T[i] > T[first] + K || landing == C) {
      first = i;
      ans++;
      landing = 1;
    } else {
      landing++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int main(void)
{
  int n;
  cin >> n;
  if(n==0||n==2) cout << 1 << endl;
  else if(n==1) cout << 2 << endl;
  else cout << 0 << endl;
  return 0;

}

Measured memory_bytes: 3116
s = list(input())
sr = list(reversed(s))
t = len(s)//2
for i in range(t+1):
    if not (s[i] == "b" and sr[i] == "d" or s[i] == "d" and sr[i] == "b" or s[i] == "p" and sr[i] == "q" or s[i] == "q" and sr[i] == "p"):
        print("No")
        break
else:
    print("Yes")


Measured memory_bytes: 4652
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	ans := 0
	prev := -1
	c := 0
	for i := 0; i < n; i++ {
		a := getNextInt(scanner)
		if prev != a {
			ans += c >> 1
			c = 0
		}
		c++
		prev = a
	}
	ans += c >> 1
	fmt.Fprintln(writer, ans)
	writer.Flush()
}


Measured memory_bytes: 640
import java.util.Scanner;

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

		int a[] = { 6000, 4000, 3000, 2000 };

		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			int t = sc.nextInt();
			int n = sc.nextInt();
			System.out.println(a[t - 1] * n);
		}
	}
}

Measured memory_bytes: 17168
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
#define ld long double
using namespace std;

int main()
{ 


fast;

ll n,k;
cin>>n>>k;

ll a[n+1];
for(ll i=1;i<=n;i++)
	cin>>a[i];


map<ll,ll> mapp;
vector<ll> v;

ll st=1;
ll step=0;

while(mapp.find(st)==mapp.end() and step<k)
{
	//cout<<st<<" "<<step<<endl;

	mapp[st]++;
	step++;
	v.pb(st);
	st=a[st];
	

}


if(step==k)
	cout<<st<<endl;
else
{
	ll rem=k-step;
	//cout<<rem<<endl;


	ll idx=0;

	for( idx=0;idx<v.size();idx++)
		if(v[idx]==st)
		break;

	ll pd=v.size()-idx;

	rem=rem%pd;
	cout<<v[idx+rem]<<endl;
}


}

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

int main() {
  int N,L;
  cin >> N >> L;
  vector<string> S(N);
  for(int i;i<N;++i){
    cin >> S[i];
  }
  sort(S.begin(),S.end());
  for(int i;i<N;++i){
    cout << S[i];
  }
}


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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<end
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  string s;
  cin>>s;
  ll res=0;
  FOR(i,0,3){
    if(s[i]=='1') res++;
  }
  cout<<res<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){

   int a, b, c, x, y, z;

   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 > b){
     z = a;
     a = b;
     b = z;
   }

  
   printf("%d %d %d\n", a, b, c);
   
   return 0;
   
   }

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

#define fast ios::sync_with_stdio(false);cin.tie(NULL)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INF = 1e18;
const int inf = 1e9;

int n;
vector<int> v;
vector<int> a;
multiset<int> S;

int main() {
	fast;

	cin >> n;

	for(int i=0; i<(1<<n); i++) {
		int t;
		cin >> t;
		v.eb(t);
		S.insert(t);
	}

	sort(all(v));
	reverse(all(v));

	a.eb(v[0]);
	S.erase(v[0]);

	for(int i=1; i<=n; i++) {
		int x = a.size();
		for(int j=0; j<x; j++) {
			multiset<int>::iterator it = S.lower_bound(a[j]);
			if(it == S.begin()) {
				cout << "No";
				return 0;
			}
			it--;

			a.eb(*it);
			S.erase(it);
		}
	}

	cout << "Yes";
}

Measured memory_bytes: 15092
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <math.h>
#include <iomanip>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;


int const static N = 10;
int l[N];
int n,A,B,C;

int INF = int(pow(10, 9));


int dfs(int idx ,int a,int b, int c){

  if(idx == N){
    if (min(a,min(b,c)) > 0) return abs(a-A) + abs(b-B) + abs(c-C) - 30;
    else return INF;
  }

  int ret0 = dfs(idx + 1, a, b, c);
  int ret1 = dfs(idx + 1, a + l[idx], b, c) + 10;
  int ret2 = dfs(idx + 1, a, b + l[idx], c) + 10;
  int ret3 = dfs(idx + 1, a, b, c + l[idx]) + 10;

  return min(ret0, min(ret1,min(ret2, ret3)));
  
}

int main(){
  cin>>n>>A>>B>>C;
  rep(i,n) cin>>l[i];
  cout << dfs(0,0,0,0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string> 
#include <algorithm>
#include <climits>
 
using namespace std;
     
int main() 
{
	int n;
	cin>>n;
	vector<int> v(n);
	for(int i = 0; i < n; i++)
		cin>>v[i];
		
	int mn = *min_element(v.begin(), v.end());
	int mx = *max_element(v.begin(), v.end());
	
	int ans = INT_MAX;
	for(int i = mn; i <= mx; i++) {
		int sum = 0;
		for(int j = 0; j < v.size(); j++)
			sum += (v[j]-i)*(v[j]-i);
		ans = min(ans, sum);
	}
	cout<<ans;
}

Measured memory_bytes: 3608