akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
void read(long long &x)
{
	int i=1; x=0; char a=getchar();
	while(a<'0'||a>'9')
	{
		if(a=='-') i=-1;
		a=getchar();
	}
	while(a>='0'&&a<='9')
	{
		x=x*10+a-48;
		a=getchar();
	}
	x*=i;
}
void write(long long x)
{
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	if(x>9) write(x/10);
	putchar(x%10+48);
}
int main()
{
	long long a,b;
	read(a); read(b);
	if(a*b%2==0) printf("Even");
	else printf("Odd");
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(){
    int N,X,T;

    cin >> N >> X >> T;
    cout << (((N + X - 1) / X) * T) << endl;

    return 0;
}


Measured memory_bytes: 3188
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <functional>
 
using namespace std;
 
int main() {
    int n;
    string s;
    cin>>n;
    if (n<3){
        cout<<0;
        return 0;
    }
    cin>>s;
    long long r=0,g=0,b=0;
    for (char c : s) {
        r+=c=='R';
        g+=c=='G';
        b+=c=='B';
    }
    long long cnt=r*g*b;
    for (int p=1;p<n;++p){
        for (int i=0,j=p,k=2*p;k<n;++i,++j,++k){
            if (s[i]!=s[j]&&s[j]!=s[k]&&s[k]!=s[i])
                --cnt;
        }
    }
    cout<<cnt;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int x,t;
cin>>x>>t;
int res=x-t>0?x-t:0;
cout<<res<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define X first
#define Y second
#define pb push_back

void solve();

int main() {
    // freopen("schools.in", "r", stdin);
    // freopen("schools.out", "w", stdout);
	ios_base::sync_with_stdio(0), cin.tie(0);
	// cout << fixed << setprecision(10);
	int t;
	// cin >> t;
	t = 1;	
	while(t--) solve();
	return 0;
}

int dp[100005];
int n, k, a[100005];

bool dfs(int balance) {
	if (dp[balance] != -1) return dp[balance];
	int ans = 0;
	for (int i = 1; i <= n; ++i) if (a[i] <= balance) ans |= !dfs(balance - a[i]);
	return dp[balance] = ans;
}

void solve() {
	cin >> n >> k;
	memset(dp, -1, sizeof(dp));
	for (int i = 1; i <= n; ++i) cin >> a[i];
	cout << (dfs(k) ? "First\n" : "Second\n");
}

Measured memory_bytes: 5376
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		
		if(a + b == c || b + c == a || a + c == b) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
int main(){
    int n;
    cin>>n;
    double x[n],y[n],ans1=0,ans2=0,ans3=0,ans4=0;
    for(int i=0;i<n;++i){
        cin>>x[i];
    }
    for(int i=0;i<n;++i){
        cin>>y[i];
    }
    for(int i=0;i<n;++i){
        ans1+=abs(x[i]-y[i]);
    }
    for(int i=0;i<n;++i){
        ans2+=(x[i]-y[i])*(x[i]-y[i]);
    }
    ans2=sqrt(ans2);
    for(int i=0;i<n;++i){
        ans3+=pow(abs(x[i]-y[i]),3);
    }
    ans3=pow(ans3,0.333333333333333);
    for(int i=0;i<n;++i){
        if(ans4<abs(x[i]-y[i])){
            ans4=abs(x[i]-y[i]);
        }
    }
    cout<<setprecision(9)<<ans1<<endl<<ans2<<endl<<ans3<<endl<<ans4<<endl;
}



Measured memory_bytes: 3468
num = list(map(int, input().split()))

grid = []
del_i = []
del_n = []

for i in range(num[0]):
  grid.append(list(input()))

  if "#" in grid[i] and "." in grid[i]:
    continue
  elif "#" in grid[i]:
    continue
  else:
    del_i.append(i)

check_1, check_2 = 0, 0

for n in range(num[1]):
  check_1, check_2 = 0, 0
  for i in range(num[0]):
    if grid[i][n] == "#":
      check_1 += 1
      if check_2 > 0:
        break
      # if check_1 == num[0]:
      #   del_n.append(n)
    else:
      check_2 += 1
      if check_1 > 0:
        break
      if check_2 == num[0]:
        del_n.append(n)

for i in range(num[0]):
  if i in del_i:
    continue
  else:
    m = 0
    for n in del_n:
      n = n - m
      del grid[i][n]
      m += 1
    print(''.join(grid[i]))

Measured memory_bytes: 3188
main :: IO ()
main = do
    n <- readLn :: IO Int
    ns <- inputs :: IO [Int]
    print (f n ns)

inputs :: Read a => IO [a]
inputs = map read . words <$> getLine

f :: Int -> [Int] -> Int
f x xs = length [ () | n <- [1..x], maximum (take n xs) == xs !! (n - 1) ]


Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
vector<int> d1[200005], d2[200005];
int main(){
    int t;
    scanf("%d", &t);
    while(t--){
        int n;
        scanf("%d", &n);
        for(int i=1;i<=n;i++) d1[i].clear(), d2[i].clear();
        long long ans = 0;
        for(int i=0;i<n;i++){
            int l, r, k;
            scanf("%d%d%d", &k, &l, &r);
            if(l >= r){
                d1[k].emplace_back(l-r);
                ans += r;
            }
            else{
                d2[n-k].emplace_back(r-l);
                ans += l;
            }
        }

        multiset<int> cur;
        for(int i=1;i<=n;i++){
            for(int j=0;j<d1[i].size();j++){
                int val = d1[i][j];
                cur.insert(val);
                ans += val;

                if(cur.size() > i){
                    ans -= *cur.begin();
                    cur.erase(cur.begin());
                }
            }
        }

        cur.clear();
        for(int i=1;i<=n;i++){
            for(int j=0;j<d2[i].size();j++){
                int val = d2[i][j];
                cur.insert(val);
                ans += val;

                if(cur.size() > i){
                    ans -= *cur.begin();
                    cur.erase(cur.begin());
                }
            }
        }
        printf("%lld\n", ans);
    }
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 100005;
bool prime[N];
int cnt[N];

void pre(){
	for(int i = 2; i < N; i++){
		prime[i] = true;
	}
	prime[1] = false;
	for(int i = 2; i < N; i++){
		if(prime[i]){
			for(int j = 2*i; j < N; j += i){
				prime[j] = false;
			}
		}
	}
	cnt[0] = 0;
	for(int i = 1; i < N; i++){
		cnt[i] = (prime[i] && prime[(i + 1)/2]);
		cnt[i] += cnt[i - 1];
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	pre();
	int q;
	cin>>q;
	while(q--){
		int l, r;
		cin>>l>>r;
		cout<<cnt[r] - cnt[l - 1]<<'\n';
	}


	return 0;
}

Measured memory_bytes: 1152
import sys
readlines = sys.stdin.readlines
write = sys.stdout.write
def solve(C):
    d = {}
    for c in C:
        d[c] = d.get(c, 0) + 1
    *vs, = d.values()
    vs.sort()
    if vs[-1] == 4:
        return "four card"
    if vs == [2, 3]:
        return "full house"
    c0 = C[0]
    if C == list(range(c0, c0+5)) or C == [1, 10, 11, 12, 13]:
        return "straight"
    if vs == [1, 1, 3]:
        return "three card"
    if vs == [1, 2, 2]:
        return "two pair"
    if vs == [1, 1, 1, 2]:
        return "one pair"
    return "null"

for line in readlines():
    *C, = map(int, line.split(","))
    C.sort()
    write("%s\n" % solve(C))



Measured memory_bytes: 5604
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define pii pair<ll,ll>

using namespace :: std;

const ll mod=1e9+7;
const ll inf=1e17+500;
const ll maxn=5e5+500;

vector<pii> ger[maxn];
ll p[maxn];
ll minn[maxn];

int main(){
    ll n;
    cin>>n;
    vector<pii> yal;
    for(ll i=1;i<n;i++){
        ll a,b;
        cin>>a>>b;
        yal.pb(mp(a,b));
        ger[a].pb(mp(b,1));
        ger[b].pb(mp(a,1));
    }
    ll k;
    cin>>k;
    for(ll i=0;i<k;i++){
        ll v,w;
        cin>>v>>w;
        p[v]=w;
        ger[0].pb(mp(v,w));
        ger[v].pb(mp(0,w));
    }
    fill(minn,minn+maxn,inf);
    set<pii> st;
    st.insert(mp(0,0));
    while(st.size()){
        pii y=(*st.begin());
        st.erase(y);
        ll v=y.S;
        ll w=y.F;
        if(minn[v]==inf){
            minn[v]=w;
            for(auto e:ger[v]){
                st.insert(mp(e.S+w,e.F));
            }
        }
    }
    for(ll i=1;i<=n;i++){
        ll b=minn[i];
        if(p[i]!=0 && p[i]!=b){
            cout<<"No";
            return 0;
        }
        if(p[i]==0){
            p[i]=b;
        }
    }
    for(auto e:yal){
        if(abs(p[e.F]-p[e.S])!=1){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    for(ll i=1;i<=n;i++){
        cout<<p[i]<<endl;
    }
}




Measured memory_bytes: 37360
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,i,tot,ans=0;
	cin>>n;
	for(i=2;i*i<=n;i++)
		if(n%i==0)
		{
			tot=0;
			while(n%i==0)
			{
				tot++;
				n/=i;
			}
			long long x=sqrt(tot*2);
			if(x*(x+1)/2>tot)
				x--;
			ans+=x;
		}
	if(n>1)
		cout<<ans+1;
	else
		cout<<ans;
	return 0;
}

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

int main() {
  int N; cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  int M, m;
  M = m = A.at(0);
  for (int i = 1; i < N; i++) {
    M = max(M, A.at(i));
    m = min(m, A.at(i));
  }
  cout << M - m << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int w,h,x,y,r;
	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
	int xx=x+r;
	int yy=y+r;
	int xxx=x-r;
	int yyy=y-r;
	if(xx>w||yy>h||xxx<0||yyy<0){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 584
#A*B+C=N
#N-A*B>=1  AとBが決まれば、Cが決まる
#Aが0..N-1でBがそれぞれ何通りあるか
n = gets.to_i
ans = 0
(n-1).times{ |i|
  ans += (n-1)/(i+1)
}
puts ans

Measured memory_bytes: 14272
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)
#include <set>

using namespace std;
#define ll long long

struct data {
  ll time;
  bool start;
  ll x;
  data(ll t, bool start, ll x) : time(t), start(start), x(x) {}
};

bool comp(data d1, data d2) {
  if(d1.time == d2.time)
    return !(d1.start && !d2.start);
  else
    return d1.time < d2.time;
}

int main() {
  int N, Q;
  cin >> N >> Q;
  vector<ll> S(N), T(N), X(N);
  vector<data> A;
  for(int i=0; i<N; i++) {
    cin >> S[i] >> T[i] >> X[i];
    A.push_back(data(S[i]-X[i], true, X[i]));
    A.push_back(data(T[i]-X[i], false, X[i]));
  }
  sort(A.begin(), A.end(), comp);
  set<ll> Set;
  int tmp = 0;
  for(int i=0; i<Q; i++) {
    ll D;
    cin >> D;
    while(A[tmp].time <= D && tmp < A.size()) {
      if(A[tmp].start)
	Set.insert(A[tmp].x);
      else
	Set.erase(A[tmp].x);
      tmp++;
    }
    if(Set.empty())
      cout << -1 << endl;
    else
      cout << *Set.begin() << endl;
  }
  return 0;
}


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

using namespace std;

const int N=1e5+10;

int n,m,a[N],f[N],b[N],cntb;

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

void Solve()
{
	int cnt=0,t1,t2;
	for (int i=1;i<=m;++i) 
		if (a[i]&1) 
		{
			cnt++;
			if (cnt==1) t1=i;
			else if (cnt==2) t2=i;
			else break;
		}
	if (cnt>2) { printf("Impossible\n"); return ; }
	if (m==1) 
	{
		if (a[m]==1) printf("%d\n%d\n%d\n",1,1,1);
		else 
		{
			printf("%d\n%d\n",a[m],2);
			printf("%d %d\n",1,a[m]-1);
		}
		return ;
	}
	if (cnt>=1) swap(a[t1],a[1]); 
	if (cnt>=2) swap(a[t2],a[m]);
	if (a[m]==1) cntb=m-1;else cntb=m;
	
	
	for (int i=1;i<=m;++i) printf("%d%c",a[i],i==m?'\n':' ');
	printf("%d\n",cntb); a[1]++; a[m]--;
	for (int i=1;i<=cntb;++i) printf("%d%c",a[i],i==cntb?'\n':' ');
}

int main()
{
	Init();
	Solve();
	return 0;
}

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

int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if((a==b and b!=c) or (a==c and b!=c) or (b==c and a!=b)){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

	return 0;
}



Measured memory_bytes: 256
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Diagnostics;
using System.Threading;
using System.Runtime.CompilerServices;
using System.IO.Pipes;

namespace AtCoder
{
    class Program
    {

        struct Point
        {
            public int x;
            public int y;

            public Point(int x, int y)
            {

                this.x = x;
                this.y = y;

            }

        }


        const int BiggestMod = 1000000007;

        public static void Main()
        {

            var str = Console.ReadLine();
            var compare = Console.ReadLine();

            var difference = Math.Abs(compare.Length - str.Length) + 1;
            var ans = int.MaxValue;
            var l = compare.Length;

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

                int count = 0;

                for (int j = i, k = 0; k < l; ++k, ++j)
                    if (str[j] != compare[k])
                        count++;

                ans = Math.Min(ans, count);

            }

            Console.WriteLine(ans);
            

        }

    }

}

Measured memory_bytes: 25976
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
public static void main(String[] args) throws IOException {
 
BufferedReader br =new BufferedReader (new InputStreamReader (System.in));
 
String line = br.readLine( );
String[] list = line.split(" ");
int x = Integer.parseInt(list[0]);
int a = Integer.parseInt(list[1]);
int b = Integer.parseInt(list[2]);
 
 
int n=b-a;
String z = "p";
 
 
if(n>0&&x>=n){
z ="safe";
}else if(n<=0){
z="delicious";
}else if(x+1<=n){
z="dangerous";
}
System. out. println(z);
}}

Measured memory_bytes: 21204
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI(N);
  print((N * (N + 1) / 2));
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main a = new Main();
        a.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] prime_list = this.get_prime_list();
        List<Integer> answer = new ArrayList<Integer>();
        int count = 0;
        int i = 2;
        for (; i < prime_list.length && count < N; i++) {
            if (prime_list[i] % 5 == 1) {
                answer.add(prime_list[i]);
                count = count + 1;
            }
        }
        StringBuilder sb = new StringBuilder();

        for (int prime : answer) {
            sb.append(prime + " ");
        }
        System.out.println(sb.substring(0, sb.length() - 1));
    }
    private int[] get_prime_list() {
        boolean[] prime = new boolean[55556];
        Arrays.fill(prime, true);
        prime[0] = false;
        prime[1] = false;
        for (int i = 2; i <= 55555; i++) {
            if(!prime[i]) {
                continue;
            }
            for (int j = 2; i * j < 55555; j++) {
                if (55555 < i * j) {
                    break;
                }
                prime[i*j] = false;
            }
        }
        List<Integer> prime_list = new ArrayList<>();
        for (int i = 2; i < 55555; i++) {
            if (prime[i]) {
                prime_list.add(i);
            }
        }
        int[] list = new int[prime_list.size()];
        for (int i = 0; i < prime_list.size(); i++) {
            list[i] = prime_list.get(i);
        }
        return list;
    }
}


Measured memory_bytes: 21076
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <type_traits>
using namespace std;

#define INF 1e18
#define int long long

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

    int n = s.size();
    int ret = 0;
    int cnt = 0;
    for(int i = 0; i < n; i++) {
        if(s[i] == 'A') cnt++;
        else if(s[i] == 'B') {
            if(i + 1 < n && s[i + 1] == 'C') {
                ret += cnt;
                i++;
            }
            else cnt = 0;
        }
        else cnt = 0;
    }

    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int n, flag[101];
int main(){
    cin >> n;
    for(int i=0; i<n; i++){
        int d;
        cin >> d;
        flag[d] = 1;
    }

    int ans=0, n=101;
    for(int i=0; i<n; i++){
        ans += flag[i];
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
vector<int> parent;
vector<int> nodes;

int getParent(int x) {
  int y = x;
  while(y != parent[y]) {
    y = parent[y];
  }
  parent[x] = y;
  return y;
}

bool unite(int x, int y) {
  x = getParent(x);
  y = getParent(y);
  if(x == y) return false;

  if(nodes[x] < nodes[y]) swap(x, y);
  parent[y] = x;
  nodes[x] += nodes[y];
  return true;
}

bool isSame(int x, int y) {
  x = getParent(x);
  y = getParent(y);
  return (x == y);
}

int main(void) {
  int64_t N, M;
  cin >> N >> M;
  vector<int> P(N);
  unordered_map<int, int> pos;
  rep(i, N) {
    cin >> P[i];
    pos[P[i]] = i;
  }

  parent.resize(N);
  nodes.resize(N);
  rep(i, N) {
    parent[i] = i;
    nodes[i] = 1;
  }
  rep(i, M) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    unite(x, y);
  }

  int answer = 0;
  for(int i = 1; i <= N; ++i) {
    if(isSame(i - 1, pos[i]))
      ++answer;
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 5408
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Tree = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

ll dp[101][100001] = {};

int main(void){
	ll n, w;
	cin >> n >> w;
	VecP item(n+1);
	repn(i, n) cin >> item[i].fs >> item[i].sc;

	repn(i, n){
		repn(j, w){
			dp[i][j] = dp[i-1][j];
			if(j >= item[i].fs) chmax(dp[i][j], dp[i-1][j-item[i].fs]+item[i].sc);
		}
	}
	co(dp[n][w]);

	return 0;
}


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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;

int main() {
    int N;
    cin >> N;
    int p[N];
    REP(i, N) {
        cin >> p[i];
    }
    int count = 0;
    FOR(i, 1, N - 1) {
        int s = p[i - 1] + p[i] + p[i + 1] - max({p[i - 1], p[i], p[i + 1]}) - min({p[i - 1], p[i], p[i + 1]});
        count += s == p[i];
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=1024+10;

int n,m,a[N][N];

int main() {
	n=read(),m=read();
	for (int i=1;i<1<<n;++i)
		for (int j=1;j<1<<m;++j)
			a[i][j]=popcount(i&j)&1;
	for (int i=1;i<1<<n;++i) {
		for (int j=1;j<1<<m;++j)
			putchar((a[i][j]^a[i-1][j]^a[i][j-1]^a[i-1][j-1])+'0');
		puts("");
	}
	return 0;
}

Measured memory_bytes: 7720
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

using namespace std;

int main(void){
    long long a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a>=k){
        cout<<k<<endl;
        return 0;
    }
    k=k-a;
    if(b>=k){
        cout<<a<<endl;
        return 0;
    }
    k=k-b;
    cout<<a-k<<endl;


    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    int k;
    cin >> s >> k;
    vector<string> v;
    int n = s.size();
    rep(i,n) rep2(j,1,min(n-i+1,6)) {
        v.pb(s.substr(i,j));
    }
    sort(all(v));
    v.erase(unique(all(v)),v.end());
    cout << v[k-1] << endl;
}


Measured memory_bytes: 1660
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
public class Main {
    public static void main(String[]args) {
        FastScanner sc=new FastScanner();
        System.out.println(sc.nextInt()*2*Math.PI);
    }
}

//高速入力コピペ
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (Exception e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


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

ll lcm(ll a, ll b)
{
    ll t = __gcd(a, b);
    return t ? (a / t * b) : 0;
}
int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  ll a,b;cin>>a>>b;
  cout<<lcm(a,b)<<endl;

  return 0;
}


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

int N;

int main() {
    // 入力を受け取る
    int n;

    cin >> n;
    vector<int> a(n); // <T>でT型のvector
    for(int i = 0; i < n; i++)  cin >> a[i];

    //前のやつをみて，前のやつと値が一緒だったら，
    //次のやつを見て，つぎのやつと，前のやつではない色にする．

    int times = 0;
    // for(int i = 0; i < n; i++)  
        // printf("%d\n",a[i]);

    for(int i=1; i<n; i++){
        if(a[i-1] == a[i]){
            if(a[i+1] == (a[i]+1)){
                a[i] = a[i]+2;
                times++;
            }else{
                a[i] = a[i]+1;
                times++;
            }
        }
    }

    cout << times << '\n';

}


Measured memory_bytes: 256
/*Shivam Bhalla */
/* f2016941@pilani.bits-pilani.ac.in */



#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iostream>
#include <string>
#include <cmath>
#include <cassert>
#include <bits/stdc++.h>
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;
long long maxv = 1e9;

int main() {
  int N;
  cin>>N;
  vector<int>h(N);
  for(int i=0;i<N;i++)
    cin>>h[i];
  int ans=0;
  int flag=0;
  while(true){
    if(*max_element(h.begin(),h.end())==0)
      break;
    int i=0;
    while(i<N){
      if(h[i]==0)
        ++i;
      else{
        ans++;
        while(i<N && h[i]>0){
          --h[i];
          ++i;
        }
      }
    }
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vector<ll> a(n);
	vector<char> op(n);
	REP(i, n) {
		cin >> a[i];
		if(i != n - 1) cin >> op[i + 1];
	}
	vector<ll> revacm(n); revacm[n - 1] = a[n - 1];
	for(ll i = n - 2; i >= 0; i--) {
		revacm[i] = revacm[i + 1] + a[i];
	}
	ll ans = - INF * INF, sum = a[0];
	FOR(i, 1, n) {
		if(op[i] == '-') {
			sum += - a[i];
			ll tmp = 0, idx = -1;
			FOR(j, i + 1, n) {
				if(op[j] == '-') {
					idx = j;
					break;
				}
				tmp += a[j];
			}
			if(idx != -1) ans = max(ans, sum - tmp + revacm[idx]);
		} else {
			sum += a[i];
		}
	}
	ans = max(ans, sum);
	cout << ans << endl;
	return 0;
}

/* --------------------------------------- */


Measured memory_bytes: 1920
using System;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var array = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();
            int a = array[0], b = array[1];
            int ans = a * b / 2;
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int A, B;
	cin >> A >> B;
	cout << A * B - A - B + 1 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
  long long int criteria;
  scanf("%lld", &criteria);
  long long int cmoney=100;
  long long int n=0;
  for (;cmoney < criteria;n++,cmoney *= 1.01){}
  //printf("%lld\n", a);
  printf("%lld", n);
  return 0;
}

Measured memory_bytes: 1732
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		// 電源タップの口数
		int X = sc.nextInt();
		// 余った電源タップ
		int A = sc.nextInt();
		//タップの個数
		sc.close();

		if(X<A) {
			System.out.println(0);
		}else {
			System.out.println(10);
		}
		}

}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
vector<int> a;
int main(){
  int n,m,sum=0;
  cin>>n>>m;
  a.resize(n);
  for(int i=0;i<n;i++) cin>>a[i],sum+=a[i];
  int cnt=0;
  for(int i=0;i<n;i++) if(a[i]*4*m>=sum) cnt++;
  if(cnt>=m) cout<<"Yes\n";
  else cout<<"No\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define ll long long

const int maxn = 200000 + 5;
int a[maxn];
int b[maxn];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		b[i] = a[i];
	}
	sort(b, b + n);
	int cnt = 0;
	for (int i = 0; i < n; i++){
		if (a[i] != b[i]){
			cnt++;
		}
	}
	if (cnt == 2 || cnt == 0) {
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;
	//system("pause");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 (ll)1 << 60
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll n, m, ans[110000], in[110000];
vector<ll> e[110000];
queue <ll> q;
int main(){
	cin >> n >> m;
	REP(i, n - 1 + m) {
		ll a, b;
		cin >> a >> b;
		in[b]++;
		e[a].push_back(b);
	}
	REPO(i, n) {
		if (in[i] == 0)q.push(i);
	}
	while (!q.empty()) {
		ll now = q.front();
		q.pop();
		REP(i, e[now].size()) {
			in[e[now][i]]--;
			if (in[e[now][i]] == 0) {
				ans[e[now][i]] = now;
				q.push(e[now][i]);
			}
		}
	}
	REPO(i, n)cout << ans[i] << endl;
}


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

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

    for (int i = 0; i < n-1; i++)
    {
        for (int j = i+1; j < n; j++)
        {
            sum += d[i] * d[j];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
const int N=310;
int n,f[N][N],vi[N];
char s[N][N];
bool bl;
void dfs(int x)
{
	for (int i=1;i<=n;i++)
	{
		if (s[x][i]=='0') continue;
		if (vi[i]==vi[x])
		{
			bl=0;
			continue;
		}
		if (vi[i]) continue;
		vi[i]=3-vi[x];
		dfs(i);
	}
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%s",s[i]+1);
	vi[1]=1;bl=1;
	dfs(1);
	if (!bl)
	{
		printf("-1\n");
		return 0;
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=n;j++)
		{
			if (s[i][j]=='0') f[i][j]=inf;
			else f[i][j]=1;
		}
	}
	for (int i=1;i<=n;i++) f[i][i]=0;
	for (int k=1;k<=n;k++)
	{
		for (int i=1;i<=n;i++)
		{
			for (int j=1;j<=n;j++)
			  f[i][j]=min(f[i][j],f[i][k]+f[k][j]);
		}
	}
	int ans=0;
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=n;j++) ans=max(ans,f[i][j]);
	}
	ans++;
	printf("%d\n",ans);
}

Measured memory_bytes: 4140
X, Y = map(int, input().split())
ans = 0
if X == 1 and Y == 1:
    print(1000000)
else:
    if X == 1: ans += 300000
    if X == 2: ans += 200000
    if X == 3: ans += 100000
    if Y == 1: ans += 300000
    if Y == 2: ans += 200000
    if Y == 3: ans += 100000
    print(ans)

Measured memory_bytes: 38384
#include <iostream>

using namespace std;

int main()
{
    string color1,color2,color3;
    cin>>color1>>color2;
    int n1 , n2 ;
    cin>>n1>>n2;
    cin>>color3;
    if (color3==color1){
        n1--;
    }else{
    n2--;
    }
    cout << n1 <<" " <<  n2 ;

    return 0;
}


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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define debug(x) cerr << #x << " = " << (x) << endl;
template<typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
    for (auto& x : v) o << x << ' ';
    return o;
}
int n, m;
int u[100001], v[100001];
bool alive[401][401];

void solve(){
    for (int i = 0; i < n; i++){
        alive[i][i] = 1;
        for (int j = 0; j < m; j++){
            if (alive[i][u[j]]){
                if (alive[i][v[j]]){
                    alive[i][i] = 0;
                    break;
                } else {
                    alive[i][v[j]] = 1;
                }
            } else {
                if (alive[i][v[j]]){
                    alive[i][u[j]] = 1;
                }
            }
        }
    }
}

int main(){
    std::ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m;
    for (int i = 0; i < m; i++){
        cin >> u[i] >> v[i];
        u[i]--; v[i]--;
    }
    reverse(u, u+m);
    reverse(v, v+m);
    solve();


    int res = 0;
    for (int i = 0; i < n; i++)
        for (int j = i+1; j < n; j++)
            if (alive[i][i] & alive[j][j] & ~alive[i][j] & ~alive[j][i]){
                int c = 0;
                for (int k = 0; k < n; k++){
                    if (i != k && j != k && alive[i][k] && alive[j][k]) c++;
                }
                if (c < 2) res++;
            }
    cout << res << endl;
}


Measured memory_bytes: 1152
N,T = map(int,input().split())
min_cost = 10**3 + 1
for i in range(N):
    c, t = map(int,input().split())
    if t <= T and c < min_cost:
        min_cost = c
if min_cost != 10**3 + 1:
    print(min_cost)
else:
    print("TLE")

Measured memory_bytes: 3060
import java.util.*;


public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] c = {0,0,0,0,0,0,0,0,0};

    c[ 8 ] =                   N / 100_000_000 ;
    c[ 7 ] = ( N % 100_000_000 ) / 10_000_000  ;
    c[ 6 ] = ( N % 100_000_00 )  / 10_000_00   ;
    c[ 5 ] = ( N % 100_000_0 )   / 10_000_0    ;
    c[ 4 ] = ( N % 100_000 )     / 10_000      ;
    c[ 3 ] = ( N % 10_000 )      / 1_000       ;
    c[ 2 ] = ( N % 1_000 )       / 100         ;
    c[ 1 ] = ( N % 100 )         / 10          ;
    c[ 0 ] =   N % 10                          ;

    int digitSum = c[0] + c[1] + c[2] + c[3] +
                   c[4] + c[5] + c[6] + c[7] + c[8]  ;

    System.out.println( N % digitSum == 0 ? "Yes" : "No" );
  }
}


Measured memory_bytes: 21844
//A
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int a[N];


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	if(n<=m)puts("unsafe");
	else puts("safe");	
	return 0; 
}

Measured memory_bytes: 3656
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
using namespace std;

int main() {
	int m[101];
	for (int i = 1; i <= 100; i++) {
		m[i] = 0;
	}
	int a;
	int max = 0;
	while (cin >> a) {
		m[a]++;
		if (max < m[a]) {
			max = m[a];
		}
	}
	for (int i = 1; i <= 100; i++) {
		if (m[i] == max) {
			cout << i << endl;
		}
	}
}

Measured memory_bytes: 3080
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define ull unsigned long long

ull gcd(ull a, ull b) {
    if(a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

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

bool IsPrime(int num) {
    if(num < 2)
        return false;
    else if(num == 2)
        return true;
    else if(num % 2 == 0)
        return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for(int i = 3; i <= sqrtNum; i += 2) {
        if(num % i == 0) {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

#define MAX 100005

int main() {
    int x;
    cin >> x;
    for(int i = x; i <= MAX; i++) {
        if(IsPrime(i)) {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] d = new int[n];
		int count = 0;
		for (int i = 0; i < n; i++) {
			d[i] = sc.nextInt();
		}
		Arrays.sort(d);
		int min = d[n / 2 - 1];
		int max = d[n / 2];
		for (int i = min; i < max; i++) {
			count++;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 51572
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>

using namespace std;
int main(void){
   vector<int> w(10);
   vector<int> k(10);
   int sumw=0,sumk=0;
   
   for(int i=0;i<10;i++)cin>>w[i];
   for(int i=0;i<10;i++)cin>>k[i];
   
   sort(w.begin(),w.end());
   sort(k.begin(),k.end());
   
   for(int i=9;i>6;i--) {
       sumw+=w[i];
       sumk+=k[i];
   }
        
    cout<<sumw<<" "<<sumk<<endl;
    
    
    return 0;
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
int main(){
  long int n;
  cin>>n;
  
  long int p=n/500;
  long int s=n%500;
  long int t=s/5;
  cout<<(p*1000)+(t*5)<<"\n";
 return 0; 
}

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

int main(){
	char s[27];
	scanf("%s",s);

	for(int i = 0;s[i]!='\0'; i++){
		for(int j = 0; j < i; j++){
			if(s[i] == s[j]){
				cout << "no" << endl;
				return 0;
			}
		}
	}
	cout << "yes" << endl;

	return 0;
}

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

namespace Volume0_0017
{
	class Program
	{
		static void Main(string[] args)
		{
			List<string> ls = new List<string>();

			for(int i = 0; i < 20; i++) {
				string str = Console.ReadLine();
				if(str == null) {
					break;
				}

				ls.Add(str);
			}

			foreach(string str in ls) {
				string buf = str;
				string after = string.Empty;
				while(!IsDecrypt(buf)) {
					ShiftText(buf, out after);

					buf = after;
				}

				Console.WriteLine(IsDecrypt(buf) ? buf : str);
			}
		}

		// 1文字前にずらす
		private static void ShiftText(string text, out string after)
		{
			after = string.Empty;

			foreach(char c in text) {
				if('a' <= c && c <= 'z') {
					char b = c;
					if(b == 'a') {
						b = 'z';
					}
					else {
						b--;
					}
					after += b.ToString();
				}
				else {
					after += c;
				}
			}
		}

		// 複合判定
		private static bool IsDecrypt(string text)
		{
			string[] keywords = text.Split(new char[] { ' ', '.' });

			foreach(string word in keywords) {
				switch(word) {
				case "the":
				case "this":
				case "that":
					return true;
				}
			}

			return false;
		}
	}
}



Measured memory_bytes: 17944
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0225
//ユニオンファインド木
#include<iostream>
#include<vector>
#include<string>
using namespace std;




int par[26];
int r[26];//rank

void init(int n)//頂点の数を引数にして初期化
{
	for (int i = 0; i < n; i++)
	{
		r[i] = 0;
		par[i] = i;
	}
}

int root(int x)
{
	if (par[x] == x)
	{
		return x;
	}
	else
	{
		return par[x] = root(par[x]);
	}
}

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

void unite(int x, int y)
{
	x = root(x);
	y = root(y);
	if (x == y)
	{
		return;
	}
	if (r[x] < r[y])
	{
		par[x] = y;
	}
	else if (r[x] > r[y])
	{
		par[y] = x;
	}
	else if (r[x] == r[y])
	{
		par[x] = y;
		r[y]++;
	}
}



int main()
{
	int n;//単語の数

	while (cin >> n, n)
	{
		init(26);//グラフの頂点の数=アルファベットの数=26
		vector<string>word(n);
		for (auto& s : word)
		{
			cin >> s;
		}

		vector<int> in(26), out(26);
		for (auto& s : word)
		{
			const auto first = s[0] - 'a', last = s.back() - 'a';//最初と最後の文字を取り出す　-'a'はa-zを0-25に対応させている
			in[first]++;//入次数
			out[last]++;//出次数
			unite(first, last);//頂点(アルファべット)first,lastが同じ集合に属する
		}
		bool ok = true;
		int comp_num = 0;//集合の数
		for (int i = 0; i < 26; i++)
		{
			comp_num += (in[i] && root(i) == i);
			ok &= in[i] == out[i];
		}
		ok &= (comp_num == 1);
		if (ok)
		{
			cout << "OK" << endl;
		}
		else
		{
			cout << "NG" << endl;
		}
	}


	return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a, b, c;
  cin >> a >> b >> c;
  bool isok = a + b < c;
  if (isok) isok &= 4 * a * b < (c - a - b) * (c - a - b);
  cout << (isok ? "Yes" : "No") << '\n';
  return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

struct Edge{
    ll dst;
    ll weight;
    Edge(ll dst, ll weight): dst(dst), weight(weight) {}
};

struct TmpDist{
    ll vertex;
    ll dist;
    TmpDist(ll vertex, ll dist): vertex(vertex), dist(dist) {}
    bool operator< (const TmpDist& right)const{
        return dist > right.dist;
    }
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
const ll INFLL = LLONG_MAX/3;

vector<ll> dijkstra(Graph &G, ll r){
    ll V = G.size();
    vector<ll> dist(V, INFLL);
    priority_queue<TmpDist> pq;
    vector<bool> check(V, false);
    TmpDist init(r, 0);
    pq.push(init);
    while(!pq.empty()){
        TmpDist td = pq.top();pq.pop();
        ll now = td.vertex;
        if(!check[now]){
            check[now] = true;
            dist[now] = td.dist;
            for (int i=0;i<G[now].size();i++){
                if(dist[G[now][i].dst] > td.dist + G[now][i].weight){
                    TmpDist tdCandidate(G[now][i].dst, td.dist + G[now][i].weight);
                    pq.push(tdCandidate);
                }
            }
        }
    }
    return dist;
}

int main(){
	ll n, m, s, t;
	cin >> n >> m >> s >> t;
	s--;t--;
	Graph g1(n), g2(n);
	REP(i, m){
		ll u, v, a, b;
		cin >> u >> v >> a >> b;
		u--;v--;
		Edge e1(v, a), e2(u, a), e3(v, b), e4(u, b);
		g1[u].push_back(e1);
		g1[v].push_back(e2);
		g2[u].push_back(e3);
		g2[v].push_back(e4);
	}

	vector<ll> dist1, dist2;
	dist1 = dijkstra(g1, s);
	dist2 = dijkstra(g2, t);
	vector<ll> total(n), res(n);
	REP(i, n){
		total[i] = dist1[i] + dist2[i];
	}
	res[n-1] = total[n-1];
	REP(i, n-1){
		res[n-2-i] = min(total[n-2-i], res[n-1-i]);
	}
	REP(i, n) cout << ull(1e15) - res[i] << endl;
    return 0;
}

Measured memory_bytes: 19756
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
using namespace std;
int a = 0, b = 0, c = 0, d = 0, e[10000], f[10000], g[10000], h[10000], counto = 0, x[100] = { 0 }, y, z;
long long ab[100000], abc = 0;
pair<int, int>manji[100];
char rikka, toka[100000];
string saya, homu, kyok, mami[100], mado[100];
bool gg;

int main() {
	
	cin >> a ;
	for (int i = 0; i < a; i++) {
		cin >> f[i];
	}
	for (int i = 0; i < a; i++) {
		if (i != a - 1) {
			cout << f[a - 1 - i] << ' ';
		}
	}
	cout << f[0];
	cout << endl;
	return 0;
}


Measured memory_bytes: 3164
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int X = sc.nextInt();
    StringBuilder builder = new StringBuilder();
    for (int i = X - K + 1; i <= X + K - 1; i++)
      builder.append(i).append(' ');
    System.out.println(builder.toString().trim());
  }
}

Measured memory_bytes: 23252