akhauriyash/Code-Regression huggingface dataset:
// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 04/19/20 20:43:13
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  vector<int> cnt(n);
  for (int i = 0; i < n-1; i++) {
    int a; cin>>a;
    cnt[a-1]++;
  }
  for (auto c:cnt) {
    cout << c << endl;
  }

  return 0;
}


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

typedef long long ll;

#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define clr(a, b) memset(a, b, sizeof(a))
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define FOR(it,c) for ( __typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++ )
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, q;
string s;
set<int> st[26];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef LOCAL
    clock_t tStart = clock();
#endif
    cin >> n >> s >> q;
    forn(i, n)
        st[s[i]-'a'].insert(i+1);
    while(q--) {
        int t;
        cin >> t;
        if(t == 1) {
            int pos; char c;
            cin >> pos >> c;
            forn(i, 26) {
                auto it = st[i].find(pos);
                if(it != st[i].end()) {
                    st[i].erase(it);
                    break;
                }
            }
            st[c-'a'].insert(pos);
        } else {
            int l, r;
            cin >> l >> r;
            int res = 0;
            forn(i, 26) {
                auto it = st[i].lower_bound(l);
                if(it != st[i].end() && *it <= r)
                   ++res; 
            }
            cout << res << "\n";
        }
    }
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * (clock() - tStart)/ CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}



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

struct edge {
	int to;
	int64_t cost;
	edge(int x=0, int64_t y=0):to(x), cost(y) {}
};

vector<vector<edge> > G; // resizeの必要あり

struct dijkstra {
	vector<int64_t> d;
	dijkstra(int s, int n):d(n, INT64_MAX/3) { // sはスタート,nは頂点数
		d[s] = 0LL;
		priority_queue<pair<int64_t, int>, vector<pair<int64_t, int> >, greater<pair<int64_t, int> > > que;
		que.push(make_pair(0LL, s));
		while(!que.empty()) {
			pair<int64_t, int> now = que.top();
			que.pop();
			if(now.first != d[now.second]) continue;
			for(edge next:G[now.second]) {
				if(d[next.to] > d[now.second] + next.cost) {
					d[next.to] = d[now.second] + next.cost;
					que.push(make_pair(d[next.to], next.to));
				}
			}
		}
	}
	int64_t &operator[](int idx) {return d[idx];}
	const int64_t &operator[](int idx) const {return d[idx];}
};


//head

int n, m, s;

inline int num(int money, int place) {
	return money*n+place;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m >> s;
	chmin(s, 50*(n-1));
	G.resize(num(50*(n-1)+1, 0));
	rep(i, m) {
		int u, v, a, b;
		cin >> u >> v >> a >> b;
		u--; v--;
		rep(i, 50*(n-1)+1-a) {
			G[num(i+a, u)].emplace_back(num(i, v), b);
			G[num(i+a, v)].emplace_back(num(i, u), b);
		}
	}
	rep(i, n) {
		int c, d;
		cin >> c >> d;
		rep(j, 50*(n-1)) {
			G[num(j, i)].emplace_back(num(min(j+c, 50*(n-1)), i), d);
		}
	}

	dijkstra D(num(s, 0), G.size());
	for(int i = 1; i < n; i++) {
		ll res = LINF;
		rep(j, 50*(n-1)) chmin(res, D[num(j, i)]);
		cout << res << '\n';
	}

}

Measured memory_bytes: 23220
k = int(input())
a, b = map(int, input().split())

aa = a//k
bb = b//k
# print(aa, bb, a%k, b%k)

if a%k == 0 or b%k == 0:
    print("OK")
elif aa == bb:
    print("NG")
else:
    print("OK")


Measured memory_bytes: 61636
#include <bits/stdc++.h>
using namespace std;
const int N = 3000 + 5;
struct point{
	int time,w;
}a[N];
bool cmp(point i,point j){
	return i.time < j.time;
}
int n,t;
int vis[N];

int main()
{
	scanf("%d %d",&n,&t); 
	for(int i = 0;i < n; i++)
		cin >> a[i].time >> a[i].w;
	sort(a,a+n,cmp);
  	int sum = 0;
  	for(int j = 0; j < n; j++){
    	for(int i = t-1; i >= 0; i--){
      		if((i + a[j].time) < t)
				vis[i+a[j].time] = max(vis[i+a[j].time], vis[i] + a[j].w);
      		sum = max(sum, vis[i] + a[j].w);
    	}
  	}
  	cout << sum << endl;
	return 0;
}

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

const ll inf = 1LL << 60;

int main(){ 
  
  ll N,M; cin >> N >> M;
  
  vector<ll> A(N);
  vector<ll> B(N+1);
  
  for(ll i = 0; i < N; i++){ cin >> A[i];}
  
  sort(A.begin(),A.end());
  
  B[N] = 0;
  B[N-1] = A[N-1];
  
  for(ll i = N-2; i >= 0; i--){ 
    B[i] = B[i+1]+A[i];
  }
 
  
  //ソート
  
  ll l = 0; ll r = inf;
  
  while( r - l > 1 ){ 
    
    ll d = l+(r-l)/2;
    
    ll cnt = 0;
    
    for(ll i = 0; i < N; i++){ 
      
      // d-A[i]以上となるような人数を求める
      
      int itr = lower_bound(A.begin(),A.end(),d-A[i])-A.begin();
      
      cnt += N-itr;
     
      
      
    }
    
   if(cnt >= M){ //　もっと下限を上げていい
      l = d;
    }
    else{
      r = d;
    }
  }
  // 最大の下限l発見
  
  r = l;
  
  ll ans = 0;
  ll howmany = 0;
  
 
  for(ll i = 0; i < N; i++){
    //値がr-A[i](=x)以上となるような要素の和をansにたす
    
    ll x = r-A[i];
    
    int itr = lower_bound(A.begin(),A.end(),x)-A.begin();
    
    // A[itr],,A[N-1]までの和
    
    if( itr == N ){ continue;}
    
    howmany += N-itr;
    
    ans += B[itr]+A[i]*(N-itr);
      
  }
  
  //howmany-r個分はもっとも小さい要素を除いて調整
  
  
  if( howmany > M){ ans -= r*(howmany-M);}

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

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        string s; cin >> s;
        cout << s.substr(0, 4) << " " << s.substr(4) << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 0x3f3f3f3f
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, M, A, B;

  std::cin >> N >> M;

  std::vector<std::vector<int>> G(N);

  for (int i = 0; i < M; i ++) {
    std::cin >> A >> B;

    A --;
    B --;

    G[A].push_back(B);
    G[B].push_back(A);
  }

  std::queue<int> queue;

  queue.push(0);

  int parent[222222];

  memset(parent, 0x3f, sizeof(parent));

  parent[0] = -1;

  while (! queue.empty()) {
    int x = queue.front(); queue.pop();

    int d = parent[x];

    assert(parent[x] < INF);

    for (const auto& y : G[x]) {
      if (parent[y] < INF)
        continue;

      parent[y] = x;

      queue.push(y);
    }
  }

  for (int i = 0; i < N; i ++)
    if (parent[i] == INF) {
      std::cout << "No" << std::endl;

      exit(0);
    }

  std::cout << "Yes" << std::endl;
  
  for (int i = 1; i < N; i ++)
    std::cout << parent[i] + 1 << std::endl;

  return 0;
}


Measured memory_bytes: 10624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    int n = 4;
    vector<int> e(n);
    for(int i = 0; i < n; i++){
        scanf("%d", &e[i]);
    }
    sort(e.begin(), e.end());
    string result = "no";
    if(e[0] == e[1] && e[2] == e[3]){
        result = "yes";
    }
    printf("%s\n", result.c_str());
    return 0;
}


Measured memory_bytes: 3268
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 3e18+7
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-10;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<ll> a(N),b(N);
    priority_queue<pair<ll,ll>> pq;
    REP(i,N) cin >> a[i];
    REP(i,N){
        cin >> b[i];
        pq.push({b[i],i});
    }
    ll ans = 0;
    while(!pq.empty()){
        ll now = pq.top().first;
        ll idx = pq.top().second;
        pq.pop();

        if(now == a[idx]) continue;
        else if(a[idx] > now){
            cout << -1 << endl;
            return 0;
        }
        else{
            ll sa = b[idx] - a[idx];
            ll wa = b[(idx-1+N)%N] + b[(idx+1)%N];
            if(sa / wa <= 0){
                cout << -1 << endl;
                return 0;
            }
            ans += sa / wa;
            now -= (sa / wa) * wa;
            b[idx] = now;
            pq.push({b[idx],idx});
        }
    }
    REP(i,N) if(a[i] != b[i]){
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 9584
def gcd(a,b):
  while b:a,b=b,a%b
  return a
def lcm(a,b):
  return a*b//gcd(a,b)
mod = 10**9+7

n = int(input())
a = list(map(int,input().split()))
l = 1
for i in range(n):
    l = lcm(l,a[i])
l %= mod

ans=0
for i in range(n):
    ans += l*pow(a[i],mod-2,mod)
    ans %= mod
print(ans)

Measured memory_bytes: 4084
while True:
  try:
    data_set = map(int, raw_input().split())
  except EOFError:
    break
  count = 0
  a = data_set[0]
  b = data_set[1]
  sum = a + b
  while sum > 0:
    sum /= 10
    count += 1
  print count

Measured memory_bytes: 6368
from copy import deepcopy
import numpy as np
H, W, K = map(int, input().split())
matrix = []
for i in range(H):
    matrix.append(input())

matrix_int = np.ones((H, W), dtype=np.uint8)
# 1 == 黒、 0 == 白
for row in range(H):
    for column in range(W):
        if matrix[row][column] == ".":
            matrix_int[row, column] = 0

count = 0
for row_options in range(2**H):
    for col_options in range(2**W):
        tmp_matrix_int = deepcopy(matrix_int)
        tmp_row_options = row_options
        tmp_col_options = col_options

        for row in range(H):
            mod = tmp_row_options % 2
            if mod == 0:
                tmp_matrix_int[row,:] = 0
            tmp_row_options = tmp_row_options // 2
        
        for col in range(W):
            mod = tmp_col_options % 2
            if mod == 0:
                tmp_matrix_int[:,col] = 0
            tmp_col_options = tmp_col_options // 2
        # print(tmp_matrix_int.sum())
        if tmp_matrix_int.sum() == K:
            count += 1
print(count)

Measured memory_bytes: 27312
#include <bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define me0(a) memset(a,0,sizeof(a))
#define me1(a) memset(a,-1,sizeof(a))
#define op freopen("in.txt", "r", stdin)
#define op1 freopen("C:\\acm\\Cproj\\in.txt","r",stdin);
#define pr freopen("C:\\acm\\Cproj\\out.txt","w",stdout)
#define pr2 freopen("C:\\acm\\Cproj\\std.txt","w",stdout)
#define pii pair<int,int>
using namespace std;
const int INF = 0x3f3f3f3f;
typedef long long LL;
template <class T>
void read(T &val) { T x = 0; T bz = 1; char c; for (c = getchar(); (c<'0' || c>'9') && c != '-'; c = getchar()); if (c == '-') { bz = -1; c = getchar(); }for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - 48; val = x * bz; }
const int maxn = 1e6 + 11;
const int mod=1e9+7;
int n,m,x,y,t;
int a[maxn],b[maxn];
int tmp[maxn];

int mi[maxn],lz[maxn],mi2[maxn];
void up(int root){
    mi[root]=min(mi[root<<1],mi[root<<1|1]);
    mi2[root]=min(mi2[root<<1],mi2[root<<1|1]);
}
void pd(int root){
    if(lz[root]==-1) return ;
    mi2[root<<1]=mi2[root<<1|1]=lz[root];//区间更新只有赋值为-INF
    mi[root<<1]=mi[root<<1|1]=lz[root];
    lz[root<<1]=lz[root<<1|1]=lz[root];
    lz[root]=-1;
}
void bd(int root,int l,int r){
    lz[root]=-1;
    if(l==r) {
        mi2[root]=-l;return;
    }
    int mid = l+r>>1;
    bd(root<<1,l,mid);
    bd(root<<1|1,mid+1,r);
    up(root);
}
void upd(int root,int l,int r,int L,int R,int v){
    if(L<=l&&r<=R){
        mi2[root]=v;
        if(l==r) mi2[root]=v-l;
        mi[root]=lz[root]=v;return;
    }
    int mid=l+r>>1;
    pd(root);
    if(L<=mid) upd(root<<1,l,mid,L,R,v);
    if(mid<R) upd(root<<1|1,mid+1,r,L,R,v);
    up(root);
}
int qu(int root,int l,int r,int pos){
    if(l==r) return mi[root];
    pd(root);
    int mid=l+r>>1;
    if(pos<=mid) return qu(root<<1,l,mid,pos);
    else return qu(root<<1|1,mid+1,r,pos);
}
int qu2(int root,int l,int r,int L,int R){
    if(L<=l&&r<=R){
        return mi2[root];
    }
    pd(root);
    int mid=l+r>>1;
    int res = INF;
    if(L<=mid)  res = qu2(root<<1,l,mid,L,R);
    if(mid<R) res = min(res,qu2(root<<1|1,mid+1,r,L,R));
    return res;
}

int main(){
//    op;
    read(n);read(m);
    bd(1,1,m);

    fo(i,1,n){

        int l,r;read(l);read(r);
        int res = qu2(1,1,m,l,r)+r+1;
        int res2 = 0;
        upd(1,1,m,l,r,INF);
        if(r!=m) res2 = qu(1,1,m,r+1);
        if(res<res2) upd(1,1,m,r+1,r+1,res);
        res = mi[1];
        if(res>=INF)  puts("-1");
        else printf("%d\n",res+i);
    }
    return 0;
}


Measured memory_bytes: 9872
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;

#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

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

  while (true) {
    if (S.size() < 5) {
      cout << "YES" << endl;
      return 0;
    }

    string end;
    end = S.substr(S.size()-5, 5);
    if (end == "dream" or end == "erase") {
      S.erase(S.size()-5, 5);
      continue;
    }

    end = S.substr(S.size()-6, 6);
    if (end == "eraser") {
      S.erase(S.size()-6, 6);
      continue;
    }

    end = S.substr(S.size()-7, 7);
    if (end == "dreamer") {
      S.erase(S.size()-7, 7);
      continue;
    }

    cout << "NO" << endl;
    return 0;
  }
}

Measured memory_bytes: 512
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

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

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  string S, T;
  cin >> S >> T;
  sort(S.begin(), S.end(), less<>());
  sort(T.begin(), T.end(), greater<>());

  ll minlen = min(S.size(), T.size());
  REP(i, 0, minlen) {
    if (S[i] < T[i]) {
      cout << "Yes" << endl;
      return 0;
    }
    if (S[i] > T[i]) {
      cout << "No" << endl;
      return 0;
    }
  }

  if (S.size() < T.size()) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
from fractions import gcd
N, K = map(int, input().split())
A = list(map(int, input().split()))

t = A[0]
for a in A:
    t = gcd(a, t)

if K % t == 0 and K < max(A) or K in A:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 16240
import math

a,b,x = map(int, input().split())

if x==a**2*b:
    print(0)
    exit()

if a**2*b/2<=x:
    ans = 90-math.degrees(math.atan(a**3/2/(a**2*b-x)))
else:
    ans = 90-math.degrees(math.atan(2*x/a/b**2))
print(ans)

Measured memory_bytes: 38640
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var s string
	fmt.Fscan(r, &s)

	if isLooksLike(s) {
		fmt.Fprintln(w, "Yes")
	} else {
		fmt.Fprintln(w, "No")
	}
}

func isLooksLike(s string) bool {
	three := s[2]
	four := s[3]
	five := s[4]
	six := s[5]
	if three == four && five == six {
		return true
	}
	return false
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
ll INF = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};

int main(){
    ll N,W; cin >> N >> W;
    ll w[101],v[101];
    for(ll i = 1; i <= N; i++){
        cin >> w[i] >> v[i];
    }
    ll dp[101][100100];
    for(ll i = 0; i < N; i++){
        for(ll j = 1; j <= W; j++){
            dp[i+1][j] = dp[i][j];
            if(j >= w[i+1]){
                dp[i+1][j] = max(dp[i][j-w[i+1]] + v[i+1], dp[i+1][j]);
            } else {
                dp[i+1][j] = dp[i][j];
            }
        }
    }
    ll ans = 0;
    for(ll i = W; i >= 0; i--){
        ans = max(ans, dp[N][i]);
    }
    cout << ans << endl;
}



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

int main()
{
    int X, Y, Z;
    cin >> X >> Y >> Z;
    swap(X, Y);
    swap(X, Z);
    cout << X << " " << Y << " " << Z << endl;
}

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

int main() {
  int n, l;
  cin >> n >> l;
  int sum = 0;
  vector<int> aji(n);
  for (int i = 0; i < n; i++) {
    aji[i] = l + i;
    sum += aji[i];
  }

  int mn  = INT_MAX;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int sm = 0;
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      sm += aji[j];
    }
    if (mn > abs(sum - sm)) {
      mn  = abs(sum - sm);
      ans = sm;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int n;
  while (cin >> n) {
    int ans = 0;
    for (int i = 0; i <= 9; i++) {
      for (int j = 0; j <= 9; j++) {
        for (int k = 0; k <= 9; k++) {
          for (int l = 0; l <= 9; l++) {
            if (i + j + k + l == n) {
              ans++;
            }
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 2984
#include <stdio.h>

#define N_MAX 1000000

char is_sosuu[N_MAX+1];

void make_sosuu_list(void) {
	int i,j;
	for(i=0;i<=N_MAX;i++)is_sosuu[i]=1;
	is_sosuu[0]=is_sosuu[1]=0;
	for(i=2;i<=N_MAX;i++) {
		if(is_sosuu[i]) {
			for(j=i+i;j<=N_MAX;j+=i)is_sosuu[j]=0;
		}
	}
}

int main(void) {
	int input,hinput;
	int i,count;
	make_sosuu_list();
	while(1) {
		scanf("%d",&input);
		if(input==0)break;
		hinput=input/2;
		count=0;
		for(i=1;i<=hinput;i++) {
			if(is_sosuu[i] && is_sosuu[input-i])count++;
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main{

    public static List<Integer> P;
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int sum = 0;
        for(int i=0; i<M; i++){
            sum +=scanner.nextInt();
        }
        if(N-sum >= 0){
            System.out.println(N-sum);
        }else{
            System.out.println(-1);
        }
    }
}

Measured memory_bytes: 46452
/**
 *   author: sahushivam
 *   created: 23 January 2019  09:22:56
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

#define REP(i, a, b) for(int i = a; i < b; i++)
#define RREP(i, a, b) for(int i = a-1; i >= b; i--)
#define PB push_back
#define MP make_pair
#define MOD 1000000007
#define INF 0x7fffffff

void optimizeIO(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
}

int main(){
    optimizeIO();
    int n,k,j;
    cin>>n>>k;
    int *h=new int[n];
    int *dp=new int[n];
    REP(i,0,n)cin>>h[i];
    dp[0]=0;
    dp[1]=abs(h[0]-h[1]);
    REP(i,2,n){
    	dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
    	for(j=1;j<=k;j++)
    	{
    		if(i-j>=0)
    		dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));

    	}
    }
    cout<<dp[n-1];
return 0;
}

Measured memory_bytes: 1024
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

int main() {
	int N, P;

	vi p(110000, 1);
	p[0] = 0;
	p[1] = 0;

	vi prime;
	
	FOR(i, 2, 110000) {
		if(p[i]) {
			prime.push_back(i);
			for(int j = i; j < 110000; j += i) {
				p[j] = 0;
			}
		}
	}

	while(cin >> N >> P, N != -1) {
		int a = 0;

		while(prime[a] <= N) {
			a++;
		}

		vi ans;

		REP(i, P) {
			FOR(j, i, P) {
				ans.push_back(prime[a+i]+prime[a+j]);
			}
		}

		sort(ALL(ans));

		cout << ans[P-1] << endl;
	}

	return 0;
}

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

	#define ll long long
	#define vvi vector< vector<int> >
	#define vi vector<int>
	#define All(X) X.begin(),X.end()
	#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
	#define REP(i,n) for(int i=0;i<(int)(n);i++)
	#define pb push_back
	#define pii pair<int,int>
	#define mp make_pair
	#define pi 3.14159265359
	#define shosu(X) fixed << setprecision(X)
	ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
	ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

	int main(){
		int a,b,c;
		cin >> a >> b >> c;
		cout << (a+b)*c/2 << endl;	
	}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] color = new int[8];
    int strong = 0;
    for(int i = 0; i < N; i++) {
      int a = sc.nextInt();
      int c = -1;
      if(a < 400) c = 0;
      if((a >= 400) && (a < 800)) c = 1;
      if((a >= 800) && (a < 1200)) c = 2;
      if((a >= 1200) && (a < 1600)) c = 3;
      if((a >= 1600) && (a < 2000)) c = 4;
      if((a >= 2000) && (a < 2400)) c = 5;
      if((a >= 2400) && (a < 2800)) c = 6;
      if((a >= 2800) && (a < 3200)) c = 7;
      if(c != -1) color[c]++;
      if(c == -1) strong++;
    }
    int vari = 0;
    for(int i = 0; i < 8; i++) {
      if(color[i] > 0) vari++;
    }
    int min = 0;
    int max = 0;
    if(vari == 0) {
      min = 1;
      max = N;
    } else {
      min = vari;
      max = vari + strong;
    }
    System.out.println(min + " " + max);
  }
}

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

int main() {
  long long n, p;
  cin>>n>>p;
  string s;
  cin>>s;
  if (p == 2) {
    long long ans = 0;
    for (int i=0; i<n; i++) {
      if ((s[i] - '0') % 2 == 0) {
        ans += i + 1;
      }
    }
    cout<<ans<<endl;
    return 0;
  } else if (p == 5) {
    long long ans = 0;
    for (int i=0; i<n; i++) {
      if ((s[i] - '0') % 5 == 0) {
        ans += i + 1;
      }
    }
    cout<<ans<<endl;
    return 0;
  }
  int mod[n];
  long long pow10 = 1;
  // for (int i=n-1; i>=0; i--) {
  //   mod[i] = ((s[i] - '0') * pow10) % p;
  // }
  for (int i=n-1; i>=0; i--) {
    mod[i] = (1LL * (s[i] - '0') * pow10) % p;
    pow10 *= 10;
    pow10 %= p;
  }
  long long acc[n+1];
  acc[0] = 0;
  for (int i=0; i<n; i++) {
    acc[i+1] = acc[i] + mod[i];
  }
  map<int, long long> m;
  for (int i=0; i<=n; i++) {
    ++m[acc[i] % p];
  }
  long long ans = 0;
  for (auto e: m) {
    if (e.second >= 2) {
      ans += e.second * (e.second - 1) / 2;
    }
  }
  cout<<ans<<endl;
}

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

#define f(i, a, b, c) for(int i = a ; i < b ; i += c)
#define fr(i, a, b, c) for(int i = a ; i >= b ; i -= c)
#define fit(it, v) for(auto it = v.begin() ; it != v.end() ; ++it)
#define frit(it, v) for(auto it = v.rbegin() ; it != v.rend() ; ++it)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define NL '\n'
#define modn 1000000007
#define EPS 1e-9

using namespace std;

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< lli > vli;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< char > vc;
typedef vector< string > vs;
typedef vector< bool > vb;
typedef set< int > si;
typedef set< ii > sii;

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

	#ifdef LOCAL_TEST
		ifstream h("in");
		ofstream g("out");
		clock_t z = clock();
	#else
		#define h cin
		#define g cout
	#endif//LOCAL_TEST

	int a, b, m;
	h >> a >> b >> m;
	vii s;
	vi r(a + 1), c(b + 1);
	f(i, 0, m, 1){
		int x, y;
		h >> x >> y;
		s.pb({x, y});
		r[x]++;
		c[y]++;
	}
	int mr = *max_element(all(r)), mc = *max_element(all(c));
	vi tr, tc;
	f(i, 1, a + 1, 1){
		if (r[i] == mr)
			tr.eb(i);
	}
	f(i, 1, b + 1, 1){
		if (c[i] == mc)
			tc.eb(i);
	}
	lli cnt = 0;
	f(i, 0, m, 1){
		if (r[s[i].first] == mr && c[s[i].second] == mc)
			cnt++;
	}
	lli temp = (lli)tr.size() * tc.size();
	g << mr + mc - (cnt < temp ? 0 : 1);

	#ifdef LOCAL_TEST
		cerr << "Time taken is: " << double(clock() - z) / CLOCKS_PER_SEC << NL;
		h.close();
		g.close();
	#endif//LOCAL_TEST
}


Measured memory_bytes: 12296
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
  unsigned long long q,h,s,d,n,ans;
  cin>>q>>h>>s>>d>>n;
  int n2=min({(q*8),(h*4),(2*s),d}),n1=min({(q*4),(h*2),s});
  ans=(n/2)*n2+n%2*n1;
  cout<<ans;
  return 0;
}

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

typedef long long ll;

int main() {
    //freopen("in.txt", "r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    const int modulo = 1e9 + 7;
    string s;
    cin>>s;
    int n = (int)s.size();

    int dp[n][13];
    memset(dp, 0, sizeof(dp));

    if (s[0]=='?'){
        for (int d=0;d<=9;++d)
            dp[0][d] = 1;
    }
    else {
        int digit = s[0] - '0';
        dp[0][digit%13] = 1;
    }
    
    for (int i=0;i<n-1;++i){
        for (int m=0;m<13;++m){
            if (dp[i][m] == 0) continue;
            if (s[i+1]=='?'){   
                for (int d=0;d<=9;++d){
                    dp[i+1][(m*10 + d)%13] += (dp[i][m]);
                    dp[i+1][(m*10 + d)%13] %= modulo;
                }
            }
            else {
                int digit = s[i+1] - '0';
                dp[i+1][(m*10 + digit)%13] += dp[i][m];
                dp[i+1][(m*10 + digit)%13] %= modulo;
            }
        }
    }

    cout<<dp[n-1][5]<<endl;

    return 0;
}

Measured memory_bytes: 5584
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}	


signed main()
{
    showoff;
    int a,b,c;
    cin >> a >> b >> c;
    if(c > a+b && (c-a-b)*(c-a-b) > 4*a*b)cout << "Yes";
    else cout << "No";
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...#include <bits/stdc++.h>
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fastio cin.sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main(){
  fastio;
  string a[3];
  cin>>a[0]>>a[1]>>a[2];
  int pos[3]={};
  int curr=0;
  while (pos[curr]<a[curr].size()){
    pos[curr]++;
    curr=a[curr][pos[curr]-1]-'a';
  }
  cout<<(char)(curr+'A')<<endl;
  return 0;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int N;
    cin >> N;
    cout << N * (N + 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d long double
#define pii pair<int,int>
#define pb push_back
#define pf push_front
#define cases int t;cin>>t;while(t--)
#define N 100003
#define M 103
#define inf LLONG_MAX
//int mod=1e9+7;
//int mod=998244353;

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    string s;
    cin>>s;
    int n=s.length(),i,j;
    int ans=0;
    for(i=1;i<n;++i)
    {
        if(s[i]==s[i-1])
        {
            ++ans,s[i]='1'+'0'-s[i];
        }
    }
    cout<<ans;



    return 0;
}


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

int main() {
  int N;
  string ans = "No";
  
  cin >> N;
  
  int D1[N], D2[N];
  
  for(int i = 0; i<N; i++){
    cin >> D1[i] >> D2[i];
  }

  for(int j = 0; j < N; j++){
    if(D1[j]==D2[j]){
      if(D1[j+1]==D2[j+1]){
        if(D1[j+2] == D2[j+2]){
          ans = "Yes";
          break;
        }
      } 
    }
  }
      
  cout << ans << endl;
}


Measured memory_bytes: 3588
from heapq import*
n,_,*t=map(int,open(0).read().split())
e=[[]for _ in'_'*n]
for l,r,c in zip(*[iter(t)]*3):e[l-1]+=(c,r-1),
for i in range(n-1):e[i+1]+=(0,i),
d=[0]+[1e18]*n
q=[(0,0)]
while q:
  c,v=heappop(q)
  for b,w in e[v]:
    if b+c<d[w]:
      d[w]=b+c
      heappush(q,(b+c,w))
print(-(d[-2]>1e17)or d[-2])

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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

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

    string S; cin >>S;

    YES(count(all(S), 'x') < 8);
}


Measured memory_bytes: 256
package main

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

type City struct {
	Index      int
	Prefecture int
	Year       int
}

type Cities []City

func (cs Cities) Len() int {
	return len(cs)
}

func (cs Cities) Swap(i, j int) {
	cs[i], cs[j] = cs[j], cs[i]
}

func (cs Cities) Less(i, j int) bool {
	if cs[i].Prefecture == cs[j].Prefecture {
		return cs[i].Year < cs[j].Year
	}
	return cs[i].Prefecture < cs[j].Prefecture
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	var cs Cities = make([]City, m)
	for i := range cs {
		cs[i].Index = i
		sc.Scan()
		cs[i].Prefecture, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		cs[i].Year, _ = strconv.Atoi(sc.Text())
	}

	sort.Sort(cs)

	xs := make([]string, m)
	p, c := 0, 0
	for _, v := range cs {
		if p != v.Prefecture {
			p = v.Prefecture
			c = 0
		}
		c++
		xs[v.Index] = fmt.Sprintf("%06d%06d", p, c)
	}

	for _, v := range xs {
		fmt.Println(v)
	}
}


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

#define rep(i, n) for(ll i=0; i<n; i++)
#define all(v) v.begin(), v.end()
#define vec vector

typedef long long ll;

/*  <<bit全探索>>

    for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
      bitset<ビット数> s(tmp);
    }
*/

/*　<<stringで読み込んだ数列を一桁ずつint型へ変換>>

    string str;
    int N[桁数];

    cin >> str;

    for (int i = 0; i < 15; ++i) {

        N[i] = (int)(str[i] - '0');  //str[i]　はchar型なのでchar→intへ変換

        //cout << N[i] << endl;  //確認のため表示
    }
*/

int main(){

    string str;
    int N[4];

    cin >> str;

    for (int i = 0; i < 4; ++i) {

        N[i] = (int)(str[i] - '0');  //str[i]　はchar型なのでchar→intへ変換

        //cout << N[i] << endl;  //確認のため表示
    }

    for (int tmp = 0; tmp < (1 << 3); tmp++) {
    bitset<3> s(tmp);
    
    ll ans = N[0];

        rep(i, 3){
           if(s.test(i)){
                ans += N[i + 1];
            }
            else{
                ans -= N[i + 1];
            }
        
          if(ans == 7){
                cout << N[0];

                if(s.test(0)){
                    cout << "+";
                }
                else{
                    cout << "-";
                }

                cout << N[1];

                if(s.test(1)){
                    cout << "+";
                }
                else{
                    cout << "-";
                }

                cout << N[2];

                if(s.test(2)){
                    cout << "+";
                }
                else{
                    cout << "-";
                }

                cout << N[3] << "=7" << endl;

                break;
            }
        }

        if(ans == 7){
            break;
        }
    }
}

Measured memory_bytes: 256
def main():
    x, y = map(int, input().split())
    if y == 0:
        if x <= 0: return -x
        elif x > 0: return 1+x
    elif y > 0:
        if x <= -y: return (-y-x) + 1
        elif -y < x < 0: return 1 + (y+x)
        elif 0 <= x <= y: return (y-x)
        else: return 1 + (-y-(-x)) + 1
    else:
        if x <= y: return (y-x)
        elif y < x < 0: return 1 + (-y-(-x)) + 1
        elif 0 <= x <= -y: return (-y-x) + 1
        else: return 1 + (y-(-x))

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        int sum = 0;
        List<Integer> prices = new ArrayList<Integer>();
        while (scanner.hasNext()){
          prices.add(scanner.nextInt());
        }
        prices.sort(Comparator.naturalOrder());
        for (int i = 0; i < K; i++) {
            sum += prices.get(i);
        }
        System.out.println(sum);



        scanner.close();
    }
}


Measured memory_bytes: 38896
import java.util.*;

public class Main {

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

  private void exec() {
    Scanner scan = new Scanner(System.in);

    int n = scan.nextInt();
    int sum = 0;
    int tmp = n;
    do {
      sum += tmp % 10;
      tmp = tmp / 10;
    } while (tmp != 0);

    if (n % sum == 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");      
    }

    scan.close();
  }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
ll mulmod(ll a,ll b,ll c) 
{ 
    if (b==0) 
        return 0; 
    ll s = mulmod(a, b/2, c); 
    if (b%2==1) 
        return (a%c+2*(s%c)) % c; 
 
    else
        return (2*(s%c)) % c; 
} 
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
int main()
{
ll int t;
t=1;
while(t--)
{ int n;cin>>n; string s[n];int a[n],ans,i;
    for(i=0;i<n;i++)
    {
        cin>>s[i];
        cin>>a[i];
        if(i>0)
        a[i]+=a[i-1];
    }
    string X;
    cin>>X;
    for(i=0;i<n;i++)
    {
        if(s[i]==X)
        {
            ans=a[n-1]-a[i];
        }
    }
cout<<ans<<endl;
}
 
    return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for i in range(A + 1):
    for j in range(B + 1):
        if 500 * i + 100 * j > X:
            break
        rem = X - 500 * i - 100 * j
        if rem // 50 <= C:
            ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define LL long long
using namespace std;
vector <int> A,B;
const LL O=1000000000;
int w,N,K; char c,S[3];
char go(LL n){
	/*A.clear(); B.clear(); LL x=n,y=N;
	while (x) A.push_back(x%10),x/=10;
	while (y) B.push_back(y%10),y/=10;
	for (int i=0;i<A.size()/2;++i) swap(A[i],A[A.size()-i-1]);
	for (int i=0;i<B.size()/2;++i) swap(B[i],B[B.size()-i-1]);
	if (n<=N^A<=B) return 'N'; return 'Y';*/
	printf("? %lld\n",n);
	fflush(stdout);
	scanf("%s",S);
	return S[0];
}
int fuck(int l,int r){
	if (l==r) return l;
	return go(O*(w*10+(l+r>>1))+O-1)=='N'?
	fuck((l+r>>1)+1,r):fuck(l,l+r>>1);
}
int main(){
	//scanf("%d",&N);
	for (int i=1,x=10;i<=9;++i,x*=10){
		c=go(x);
		if (c=='N') {K=i; break;}
	}
	if (!K)
	for (int i=9,x=O-1;i;--i,x/=10){
		c=go(x);
		if (c=='N') {K=i+1; break;}
	}
	if (!K) {puts("! 1"); return 0;}
	if (K==10) {printf("! %lld\n",O); fflush(stdout);return 0;}
	w=w*10+fuck(1,9);
	for (int i=2;i<=K;++i) w=w*10+fuck(0,9);
	printf("! %d\n",w);
	fflush(stdout);
	return 0;
}

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

int check(string s){
  int k=s.size();
  for(int i=0;i<k/2;i++){
    if(s.at(i)!=s.at(i+k/2)){
      return 0;
    }
  }
  return 1;
}
int main(){
  string S;
  cin >> S;
  for(int i=2;;i+=2){
    S.pop_back();
    S.pop_back();
    if(check(S)==1){
      cout << S.size() << endl;
      return 0;
    }
  }
}
    
  
    
  

Measured memory_bytes: 256
N = int(input())
xs, ss = [], []
for _ in range(N):
    x, s = map(int, input().split())
    xs.append(x)
    ss.append(s)

As = [ss[0]]
for i in range(1, N):
    As += [-(xs[i]-xs[i-1]), ss[i]]

accA = 0
ans = 0
for A in As:
    accA += A
    if accA < 0:
        accA = 0
    ans = max(ans, accA)

print(ans)


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

int N;
int S[2];

int main() {
  cin >> N;
  for (int i=0; i<N; i++) {
    int a; cin >> a;
    S[a%2]++;
  }
  S[0] += S[1]/2;
  S[1] %= 2;
  int c = 0;
  if (S[0] > 0) c++;
  if (S[1] > 0) c++;
  if (c <= 1) cout << "YES\n";
  else cout << "NO\n";
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, r;
    cin>>n>>r;
    if(n >= 10) {
    	cout<<r<<"\n";
    } else {
    	cout<<r + 100 * (10 - n)<<"\n";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n, c=0;
    cin>>n;
    if(n>=500)
    {
        c=n/500;
        n%=500;
    }
    cout<<c*1000+(n/5)*5<<endl;
    return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
s=[]
for i in range(N):
    s.append([int(x) for x in input().split()])
s.sort(key=lambda x:x[0])

c=i=0
while M:
    if (s[i][1]<M):
        c += s[i][0]*s[i][1]
        M -= s[i][1]
    else:
        c += s[i][0]*M
        M = 0
    i+=1
print(c)


Measured memory_bytes: 22752
import sys
n = int(input())
A=[]
for _ in range(n):
    A.append(int(input()))

left = [0 for i in range(n+1)]
right = [0 for i in range(n+1)]

for i in range(n+1):
    if i == 0:
        left[i] = -10000000000
        continue
    if A[i-1] > left[i-1]:
        left[i] = A[i-1]
    else:
        left[i] = left[i-1]

for i in reversed(range(n+1)):
    if i == n:
        right[i] = -10000000000
        continue
    if A[i] > right[i+1]:
        right[i] = A[i]
    else:
        right[i] = right[i+1]

for i in range(n):
    print(max(left[i], right[i+1]))



Measured memory_bytes: 15680
#!/usr/bin/python
import sys

def f(a,n):
	a=[list(e) for e in a]
	for j in range(len(a)):
		for i in range(n):
			if n+i>=len(a[j]):
				a[j].append(a[j][n-1-i])
			else:
				a[j][n+i]+=a[j][n-1-i]
		a[j]=a[j][n:]
	return a
def g(a,n):
	return list(zip(*f(list(zip(*a)),n)))

while True:
	n,m,t,p=map(int,sys.stdin.readline().split())
	a=[[1]*n for _ in range(m)]
	if n==0: break
	for _ in range(t):
		d,c=map(int,sys.stdin.readline().split())
		a=(f if d==1 else g)(a,c)
	for _ in range(p):
		x,y=map(int,sys.stdin.readline().split())
		print(a[y][x])



Measured memory_bytes: 5784
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  ll n,m,k;
  cin>>n>>m>>k;
  vi a(n),b(m);
  rep(i,n) cin>>a[i];
  rep(i,m) cin>>b[i];
  REP(i,1,n) a[i]+=a[i-1];
  REP(i,1,m) b[i]+=b[i-1];
  ll ans=ub(b,k);
  rep(i,n){
    if(k<a[i]) break;
    chmax(ans,i+1+ub(b,k-a[i])); //+1-1
  }
  out(ans);
}

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


Measured memory_bytes: 6376