akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	ll a,b,c,k;
	ll ans=0LL;
	cin >>a>>b>>c>>k;
	ans+=min(k,a);
	k=max(k-a,0LL);
	k=max(k-b,0LL);
	ans-=max(min(c,k),0LL);
	cout<<ans<<endl;
}

Measured memory_bytes: 3592
N, W = map(int, input().split())
items = [None] * N
for n in range(N):
    w, v = map(int, input().split())
    items[n] = (w, v)

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(N):
    for j in range(W + 1):
        w, v = items[i]
        if j >= w:
            dp[i + 1][j] = max(dp[i][j - w] + v, dp[i][j])
        else:
            dp[i + 1][j] = dp[i][j]
print(dp[N][W])


Measured memory_bytes: 120044
#include<cstdio>
int main(){
	int n,a,b,c,i,j,ans=0;
	scanf("%d%d%d%d",&a,&b,&c,&n);
	for(i=0;i<=n/a;++i)
		for(j=0;j<=(n-a*i)/b;++j)if(!((n-a*i-b*j)%c))++ans;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <cmath>         // sqrt
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;
typedef tuple<ll, ll, string> Tlls;

// Greatest Common Divisor (最大公約数)
ll gcd(ll a, ll b)
{
  // Eucledean algorithm
  while (a)
  {
    if (a < b)
    {
      std::swap(a, b);
    }
    a %= b;
  }
  return b;
}

// Least Common Multiple 最小公倍数
ll lcm(ll a, ll b)
{
  return a / gcd(a, b) * b;
}

// key: value of prime factor素因数分解
// value: number of prime factor
map<ll, ll> prime_factorization(ll n)
{
  map<ll, ll> prime_factors;
  for (ll i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      prime_factors[i]++;
      n /= i;
    }
  }
  if (n != 1)
    prime_factors[n] = 1;
  return prime_factors;
}

// 約数リスト約数の列挙
vector<ll> get_divisors(const ll n)
{
  vector<ll> divs;
  for (ll i = 1; i < (ll)sqrt((ld)n) + 1; i++)
  {
    if (n % i == 0)
    {
      divs.push_back(i);
      if (i != n / i)
      {
        divs.push_back(n / i);
      }
    }
  }

  // 必要に応じてソート
  // sort(divs.begin(), divs.end());

  return divs;
}

int main()
{
  ll N, K;
  ll ans = 0;
  cin >> N >> K;
  vector<ll> ANS(N);
  rep(i, K)
  {
    ll d = 0;
    cin >> d;
    rep(j, d)
    {
      ll tmp = 0;
      cin >> tmp;
      tmp--;
      ANS.at(tmp)++;
    }
  }
  rep(i, N)
  {
    if (ANS.at(i) == 0)
    {
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String a = scan.nextLine();
        String b = scan.nextLine();
        String c = scan.nextLine();

        char turn = 'a';

        while (true) {
            if (turn == 'a') {

                if (a.length() == 0) {
                    System.out.println('A');
                    System.exit(0);
                }
                turn = a.charAt(0);
                a = a.substring(1);

            } else if (turn == 'b') {

                if (b.length() == 0) {
                    System.out.println('B');
                    System.exit(0);
                }
                turn = b.charAt(0);
                b = b.substring(1);

            } else {

                if (c.length() == 0) {
                    System.out.println('C');
                    System.exit(0);
                }
                turn = c.charAt(0);
                c = c.substring(1);

            }
        }
    }
}


Measured memory_bytes: 22996
#include <iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<queue>
#include<algorithm>
#define N 200500
#define LL long long
#define mem(a,b) memset(a,b,sizeof(a));
using namespace std;
LL sum[N],t[N];
LL tree[N];
int n,k,a,m,nn;
void add(int x)
{
    while(x<=nn)
    {
        tree[x]++;
        x+=x&-x;
    }
}
LL query(int x)
{
    LL num=0;
    while(x)
    {
        num+=tree[x];
        x-=x&-x;
    }
    return num;
}
int main()
{
    mem(t,0);
    mem(tree,0);
    mem(sum,0);
    scanf("%d%d",&n,&k);
    nn=n+10;
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&a);
        t[i]=sum[i]=sum[i-1]+a-k;
    }
    sort(t,t+n+1);
    m=unique(t,t+n+1)-t;
    for(int i=0; i<=n; i++)
        sum[i]=lower_bound(t,t+m+1,sum[i])-t+1;
    LL ans=0;
    for(int i=0;i<=n;i++)
    {
        ans+=query(sum[i]);
        add(sum[i]);
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 5120
object Main extends App {
  val src = io.Source.stdin.getLines.map(_.toInt)

  def func(stack: List[Int], num: Int): List[Int] = {
      if (num == 0) { println(stack.head); stack.tail }
      else num :: stack
  }

  (Nil /:[List[Int]] src)(func)
}



Measured memory_bytes: 44048
#include <iostream>
#include <string>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, s, n) for(int i = s; i < n; i++)
using namespace std;

int main(){
  int n;
  cin >> n;
  int ans = 0;
  rep2(i, 1, n+1){
    string s = to_string(i);
    if (s.size() % 2 == 1) ans++;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3728
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        while(true){
        int H = scan.nextInt();
        int W = scan.nextInt();
        if(H == 0 && W == 0){
            break;
        }
        for(int i = 0;i < H; i++){
            for(int j =0;j < W; j++){
                System.out.print("#");
            }
            System.out.println("");
        }
        System.out.println("");
    }
        scan.close();
    }
}


Measured memory_bytes: 33012
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<iostream>
using namespace std;


int main(){
    int n,t;
    scanf("%d%d",&n,&t);
    int cost,tmp,res=0x3f3f3f3f;
    for(int i=0;i<n;i++){
        scanf("%d%d",&cost,&tmp);
        if(tmp<=t){
            res=min(res,cost);
        }
    }
    if(res==0x3f3f3f3f) printf("TLE\n");
    else printf("%d\n",res);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a,b;
  cin >>a>>b;
  if(a == b){
    cout<<"Draw"<<endl;
    return 0;
  }else if(a == 1 ){
    cout<<"Alice"<<endl;
    return 0;
  }else if(b == 1){
    cout<<"Bob"<<endl;
    return 0;
  }else if(a>b){
    cout<<"Alice"<<endl;
    return 0;
  }else {
    cout<<"Bob"<<endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include<algorithm>
#include<math.h>
using namespace std;
int main(){
	int a,b;
	char c;
	cin>>a>>c>>b;
	if(c=='+')
		cout<<a+b;
	else 
		cout<<a-b;
	return 0;
}


Measured memory_bytes: 256
import sys
import random

def rd():
        return sys.stdin.readline().rstrip()

def rdi():
        return [ int(x) for x in rd().split() ]

n = rdi()[0]

def f(n):
        s = 0
        a = n
        b = 0
        t = ""
        while a >= 10:
                b = a % 10
                a = a / 10
                if b <= 8 and a >= 1:
                        s = s + 9
                        a = a - 1
                        b = 9
                else:
                        s = s + b
                t = str(b) + t
        s += a
        t = str(a) + t
        #print t
        #print s
        return int(t)

#print n
t = f(n)
#print t
s = sum([ int(a) for a in str(t) ])
print s

Measured memory_bytes: 4332
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N, M;
    cin >> N >> M;
    int days = 0;
    for (int i=0; i<M; i++){
        int a;
        cin >> a;
        days += a;
    }

    if (N - days >= 0 ){
        cout << N - days << endl;
    }
    else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){

int n,m;
int x,y;

while(1){
cin>>n;
cin>>m;
if(n==0&&m==0)break;
int N[502][502]={};
for(int i=0;i<m;i++)
{cin>>x>>y;
N[x][y]=1;N[y][x]=1;
}
int c=0;bool f[502]={};
for(int i=1;i<=n;i++){
	bool F=false;
for(int j=1;j<=n;j++){
	if(N[i][1]==1){F=true;f[i]=true;}
if(N[i][j]==1&&F==true)f[j]=true;
}
}
for(int i=2;i<=n;i++){
if(f[i]==true){c++;}}
cout<<c<<endl;

}
return 0;
}

Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 998244353;


int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> es(n+1);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        es[a].push_back(b);
        es[b].push_back(a);
    }

    queue<int> q;
    q.push(1);
    vector<int> ret(n+1, -1);
    while (!q.empty()) {
        int c = q.front(); q.pop();
        for (int c2 : es[c]) {
            if (ret[c2] != -1) continue;
            ret[c2] = c;
            q.push(c2);
        }
    }
    cout << "Yes" << endl;
    rng(i, 2, n+1) {
        cout << ret[i] << endl; 
    } 
    return 0;
}

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

#define INF_LL 1e18
#define INF 1e9

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()

using namespace std;

using ll = long long;
using PII = pair<int, int>;

template<typename T>
void chmax(T &a, T &b){
	a = max(a, b);
}

template<typename T>
void chmin(T &a, T &b){
	a = min(a, b);
}

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

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

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

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

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	cin >>a >> b;
	cout << (a+b)%24 << endl;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;
	
void Main()
{
	std::int64_t N;
	std::cin >> N;
	auto min = std::numeric_limits<std::int64_t>::max();
	for (std::int64_t i = 1; i * i <= N; ++i)
	{
		if (N % i != 0)
		{
			continue;
		}
		min = std::min(min, i + (N / i) - 2);
	}
	std::cout << min << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 256
/*
 * Code be weshen zyk :'(
 */
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include "bits/stdc++.h"

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define F first
#define S second

using ll = long long;
using ii = pair<int, int>;
using db = long double;

#ifdef ONLINE_JUDGE
#define cerr if(0)cerr
#endif

template<class C> void amin(C &a4, C b4) {
	a4 = min(a4, b4);
}
template<class C> void amax(C &a4, C b4) {
	a4 = max(a4, b4);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
	os << "[";
	for (auto vv : V)
		os << vv << ",";
	return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) {
	return os << "(" << P.first << "," << P.second << ")";
}

const int N = 1e5 + 5;
int n, m;
ll dp[N];
int main() {
#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif

	int n, c;
	cin >> n >> c;
	for(int i = 1; i <= n; i++){
		int w, v;
		cin >> w >> v;
		for(int j = c; j >= w; --j)
			dp[j] = max(dp[j], dp[j-w] + v);
	}

	cout << dp[c] << '\n';

	return 0;
}


Measured memory_bytes: 1024
# coding: utf-8
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(1, n - 1):
    if (p[i-1] < p[i] and p[i] < p[i+1]) or (p[i-1] > p[i] and p[i] > p[i+1]):
        ans += 1
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <string>

class Baseball{
private:
	int first;
	int second;
	int third;
	int score;
	int count;
public:
	Baseball(){
		first=0;
		second=0;
		third=0;
		score=0;
		count=0;
	}
	int getScore(){
		return score;
	}
	void hit(){
		score+=third;
		third=second;
		second=first;
		first=1;
	}
	void homerun(){
		score+=third+second+first+1;
		first=0;
		second=0;
		third=0;
	}
	void out(){
		count++;
	}
	int getCount(){
		return count;
	}
};

int main(){
	int inning;
	std::cin >> inning;

	for(int i=0;i<inning;i++){
		Baseball attack;
		std::string result;
		while(attack.getCount()<3){
			std::cin >> result;

			if(result == "HIT"){
				attack.hit();
			} else if(result == "HOMERUN"){
				attack.homerun();
			} else if(result == "OUT"){
				attack.out();
			}
		}
		std::cout << attack.getScore() <<std::endl;
	}

    return 0;
}


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

int main(){
    string S; cin >> S;
    bool flag = false;

    if(S.at(0) == 'A' && islower(S.at(1)) && islower(S.at(S.size() - 1)) && S.at(S.size() - 1) != 'C') {
        int count = 0;
        for(int i = 2; i < S.size() - 1; ++i) {
            if(S.at(i) == 'C') {
                count++;
            }
        }

        if(count > 1 || count == 0) {
            flag = true;
        }
    } else {
        flag = true;
    }

    if(flag == true) {
        cout << "WA" << endl;
    } else {
        cout << "AC" << endl;
    }
}

Measured memory_bytes: 256
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():


    class UnionFind(object):
        def __init__(self, n=1):
            # 木の親要素を管理するリストparをつくります。
            # par[x] == xの場合には、そのノードが根であることを示します。
            # 初期状態では一切グループ化されていないので、すべてのノードが根になりますね。
            self.par = [i for i in range(n)]
            # 木の高さを持っておき、あとで低い方を高い方につなげる。初期状態は0
            self.rank = [0 for _ in range(n)]
            self.size = [1 for _ in range(n)]

        def find(self, x):
            """
            x が属するグループを探索：
            ある２つの要素が属する木の根が同じかどうかをチェックすればよい。
            つまり、親の親の親の・・・と根にたどり着くまで走査すればよい。
            再帰。
            """
            # 根ならその番号を返す
            if self.par[x] == x:
                return x
            # 根でないなら、親の要素で再検索
            else:
                # 一度見た値については根に直接繋いで経路圧縮
                # 親を書き換えるということ
                self.par[x] = self.find(self.par[x])
                return self.par[x]

        def union(self, x, y):
            """
            x と y のグループを結合
            """
            # 根を探す
            x = self.find(x)
            y = self.find(y)
            # 小さい木に結合して経路圧縮
            if x != y:
                if self.rank[x] < self.rank[y]:
                    x, y = y, x
                # 同じ長さの場合rankが1増える
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1
                # 低い方の木の根を高い方の根とする
                self.par[y] = x
                self.size[x] += self.size[y]

        def is_same(self, x, y):
            """
            x と y が同じグループか否か
            """
            return self.find(x) == self.find(y)

        def get_size(self, x):
            """
            x が属するグループの要素数
            """
            x = self.find(x)
            return self.size[x]

    N, M = map(int, input().split())
    uf = UnionFind(N)  # ノード数Nでクラス継承
    l=list(map(int,input().split()))

    for i in range(M):
        # A,Bはノード
        A, B = map(int, input().split())
        A,B=A-1,B-1
        uf.union(A, B)
    cnt=0
    for i in range(N):
        if uf.is_same(l[i]-1,i):
            cnt+=1
    print(cnt)

resolve()

Measured memory_bytes: 97584
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int gcd(int n,int m)
{
	if(n==0)
	{
		return m;
	}
	else
	{
		return gcd(m%n,n);
	}
}
int a[N];
int prime[1000005];
int mp[1000005];
int ans[1000005];
int fre[N];
int32_t main()
{
	IOS;
	int n;
	cin>>n;
	int a[n+5];
	int x=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		x=gcd(x,a[i]);
		mp[a[i]]++;
	}
	int mx=0;
	for(int i=2;i<=1000000;i++)
	{
		if(prime[i]==0)
		{
			for(int j=i;j<=1000000;j+=i)
			{
				ans[i]+=mp[j];
				prime[j]=1;
				//vp[j].pb(i);
			}
		}
	}
	if(x!=1)
	{
		cout<<"not coprime"<<endl;
		return 0;
	}
	int flag=0;
	for(int i=2;i<=1000000;i++)
	{
		if(ans[i]>1)
		{
			flag=1;
			break;
		}
	}
	if(!flag)
	{
		cout<<"pairwise coprime"<<endl;
	}
	else
	{
			cout<<"setwise coprime"<<endl;
		
	}


}

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

bool t[200];

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    t[s[i]] = 1;
  }
  for (int i = 'a'; i <= 'z'; i++) {
    if (t[i] == 0) {
      cout << char(i) << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}


Measured memory_bytes: 512
#include<stdio.h>
#define MAX 2000000

int H;

int parent(int i){ return i/2; }
int left(int i){ return 2*i; }
int right(int i){ return (2*i)+1; }

void maxHeapify(int A[], int i){
  int l, r, largest, tmp;
  l = left(i);
  r = right(i);
  if( l <= H && A[l] > A[i] ) largest = l;
  else largest = i;
  
  if( r <= H && A[r] > A[largest] ) largest = r;

  if( largest != i ){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(A, largest);
  }
}

void buildMaxHeap(int A[]){
  int i;
  for( i = H/2 ; i >= 1 ; i-- ) maxHeapify(A,i);
}

int main(){
  int i, A[MAX+1];

  scanf("%d", &H);

  for( i = 1 ; i <= H ; i++ ) scanf("%d", &A[i]);

  buildMaxHeap(A);

  for( i = 1 ; i <= H ; i++ ) printf(" %d",A[i]);
  printf("\n");

  return 0;
}



Measured memory_bytes: 3692
#include <stdio.h>
int main(){
	int a=0, b=0, c=0, d=0, e=0, f=0, g=0, h=0, j=0;
	int ans = 0;
	int n, rate;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &rate);
		if(rate < 400) a++;
		else if(rate < 800) b++;
		else if(rate < 1200) c++;
		else if(rate < 1600) d++;
		else if(rate < 2000) e++;
		else if(rate < 2400) f++;
		else if(rate < 2800) g++;
		else if(rate < 3200) h++;
		else j++;
	}
	if(a) ans++;
	if(b) ans++;
	if(c) ans++;
	if(d) ans++;
	if(e) ans++;
	if(f) ans++;
	if(g) ans++;
	if(h) ans++;
	printf("%d %d\n", (ans ? ans : 1), ans + j);
}

Measured memory_bytes: 128
// 2020-07-11 21:01:59
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int ans = 0;
  rep(i, n) {
    if((i+1)%2 && (a[i]%2)) ans++;
  }
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
int main(void){
    int a, b;
	scanf("%d%d", &a, &b);
	if(a == 1 && b == 1){
        printf("Draw");
    }else if(a == 1){
	    printf("Alice");
	}else if(b == 1){
	    printf("Bob");
	}else if(a > b){
	    printf("Alice");
	}else if(a < b){
	    printf("Bob");
	}else{
	    printf("Draw");
	}
    
}


Measured memory_bytes: 1696
import java.awt.*;
import java.util.*;
import java.util.List;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        sc.next();
        int m = sc.nextInt();
        List<Point> list = new ArrayList<>();
        IntStream.range(0, m).forEach(value -> list.add(new Point(sc.nextInt(), sc.nextInt())));
        Collections.sort(list, Comparator.comparingInt(o -> o.y));

        int ans = 0, lastIndex = -1;
        for (int i = 0; i < m; i++) {
            if(list.get(i).x > lastIndex) {
                ans++;
                lastIndex = list.get(i).y-1;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 93748
N = int(input())
A = list(map(int,input().split()))
#A.reverse()
ans = [0 for _ in range(N)]
for i in reversed(range(N-1)):
  #今i番目(0index)の社員
  boss = A[i]-1 #0index
  ans[boss] += 1
  #print(ans,i,boss)
for x in ans:
  print(x)

Measured memory_bytes: 32268
#include <stdio.h>

int main(void){
    int n;
    int a,b;
    scanf("%d", &n);
    if(n == 1){
        printf("Hello World");
    }else if ( n == 2){
        scanf("%d", &a);
        scanf("%d", &b);
        printf("%d",a+b);
    }
   
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
vector<int> v;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()),v.end());
  cout << v.size() << endl;
}

/*　【提出前に確認すること】
・コンパイルできるか
・テストケース試したか
・オーバーフローあるか
*/

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

int main() {
    int K, A, B;
    cin >> K;
    cin >> A >> B;
    for (int i=A; i<=B; i++) {
        if (i % K == 0) {
            cout << "OK";
            return 0;
        }
    }
    cout << "NG";
}

Measured memory_bytes: 3624
function main(input) {
   input = input.trim();
  const a = input.split("\n");
  const b = a[0].split(" ").map(Number);
  const c = a[1].split("");
  console.log(a[1].substring(0, b[1]-1) 
              + a[1].charAt(b[1]-1).toLowerCase() 
              + a[1].substring(b[1]));
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29584
n=int(input())
a=list(map(int,input().split()))
a=[0]+a
s=[0]*(n+1)
for i in range(n,0,-1):
    if sum(s[i::i])%2==a[i]:
        s[i]=0
    else:
        s[i]=1
print(sum(s))
b=''
for i in range(1,n+1):
    if s[i]==1:
        b+=str(i)+' '
if b:
    print(b)

Measured memory_bytes: 9132
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

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

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

// End of template.

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin.read(buf, sizeof buf); // 注意: ./a.out < in か pbp | ./a.out で入力すること

    int h, n, a[100100];
    cin >> h >> n;
    rep(i, n) cin >> a[i];

    int64 t = 0;
    rep(i, n) t += a[i];
    if (t >= h)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}



Measured memory_bytes: 640
#include <stdio.h>
int main(void){
char a[2];
  scanf("%s",a);
  if(a[0]=='a'||a[0]=='i'||a[0]=='u'||a[0]=='o'||a[0]=='e'){
  printf("vowel");
  }
  else{
  printf("consonant");
  }
  
return 0;
}

Measured memory_bytes: 128
import java.util.*;


public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			while(true){
				if(a+1 == b){
					System.out.println("Borys");
					break;
				}
				a++;
				if(a+1 == b){
					System.out.println("Alice");
					break;
				}
				b--;
			}
		}
	}



	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

}


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

int main(){
	string str, op, p;
	int q, a, b;
	cin >> str >> q;
	for(int i=0;i<q;i++){
		cin >> op >> a >> b;
		if(op == "print"){
			cout << str.substr(a,b-a+1) << endl;
		}
		if(op == "reverse"){
			p = str.substr(a,b-a+1);
			reverse(p.begin(),p.end());
			str.replace(a,b-a+1,p);
			
		}
		if(op == "replace"){
			cin >> p;
			str.replace(a,b-a+1,p);
		}
	}
	return 0;
}

Measured memory_bytes: 1224
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;

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 (IOException 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;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); 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() {
    	return (int)nextLong();
    }
}

public class Main {

	public static void main(String[] args) {
		long curtime=System.currentTimeMillis();
		new Main().run();
		System.err.println(System.currentTimeMillis()-curtime);
	}
	
	final long MOD=(long)1e9+7;

	void run() {
		FastScanner sc=new FastScanner();
		int N=sc.nextInt();
		System.out.println((N+999)/1000*1000-N);
	}
	
	
	
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}



Measured memory_bytes: 32504
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int n;
	cin>>n;
	vi a(n);
	rep(i,n)cin>>a[i];
	cout<<accumulate(all(a),-n)<<endl;
	return 0;
}


Measured memory_bytes: 256
/**
 *       Author:  kulubat
 *       Written on Tuesday, 14 April 2020.
 **/


#include <iostream>
#include <vector>


using namespace std;
using ll = long long;

const int mod = 1e9+7;
const int MAXN = 2e5 + 5;


ll modpow(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b&1)
            res = (res * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}


ll f[MAXN];
ll invf[MAXN];


ll Cr(int n, int r) {
    if (r == 0 || n == r) return 1;
    return (((f[n] * invf[n-r]) % mod) * invf[r]) % mod;
}


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


    int H, W, A, B;

    cin >> H >> W >> A >> B;

    int C = H-A-1;
    int C2 = A-1;
    ll ans = 0;

    f[0] = f[1] = 1;
    for(int i = 1; i < MAXN; ++i) {
        f[i] = (i * f[i-1]) % mod;
        invf[i] = modpow(f[i], mod-2);
    }



    for(int i = 0; i < W-B; ++i) {
        int R = B+i;
        int R2 = W-B-i-1;
        ll cnt = (Cr(R+C, R) * Cr(R2+C2, R2)) % mod;
        ans = (ans + cnt)  % mod;
        
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(){
  int N;
  long cnt=0;
  string S,T;
  cin>>N>>S;
  	for(int i=0;i<1000;i++){
      T=to_string(i);
      while(T.size()!=3){
        T='0'+T;
      }
      int k=0;
      	for(int j=0;j<N;j++){
          if(T[k]==S[j]){
            k++;
          }
             if(k==3){
               cnt++;
               break;
             }
               
    }
    }
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
h,w,K=map(int,input().split())
import collections
import itertools
import copy
c = [list(map(str,input().split())) for _ in range(h)]
cc = [[]for i in range(h)]
for i,j in enumerate(c):
    cc[i]=list(c[i][0])

    # print(list(j))

# for i in range(h):
#     for j in range(h):
h_ = 2**h-1
# h_ = bin(h_)
w_ = 2**w-1
# w_ = bin(w_)
count = 0
for i in range(h_):
    for j in range(w_):
        c_ =copy.deepcopy(cc)
        x  = bin(i)[2:].zfill(h)
        y = bin(j)[2:].zfill(w)
        for k in range(h):
            for l in range(w):
                # print(x)
                if x[k]=="1":
                    c_[k]=["."]*w
                    # print("a")

                if y[l]=="1":
                    if y=="000000":
                        print("koko")
                    for m in range(h):
                        # print(m,l)
                        c_[m][l]="."
                # print(c_)
        f = list(itertools.chain.from_iterable(c_))
        z = collections.Counter(f)
        # if x=="100100" and y== "000000":
        #     print(c_)
        # print(z,x,y)
        if h*w-z["."]==K:
                    
            count +=1
print(count)


Measured memory_bytes: 9640
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define int long long
signed main(){
    int k,s;
    cin>>k>>s;
    int count=0;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            if(s-i-j>=0&&s-i-j<=k)count++;
        }
    }
    cout<<count<<endl;
    return 0;
}





Measured memory_bytes: 256
mod=10**9+7
h=w=0
n,m=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
for i in range(n-1):
	h=(h+(x[i+1]-x[i])*(n-i-1)*(i+1))%mod
for i in range(m-1):
	w=(w+(y[i+1]-y[i])*(m-i-1)*(i+1))%mod
print(h*w%mod)


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

using namespace std;

int main() {
    int diffMax = 0;
    int ans = 0;
    for (int i = 0; i < 5; ++i) {
        int a;
        cin >> a;

        int aa = ((a + 9) / 10) * 10;
        ans += aa;
        diffMax = max(diffMax, aa - a);
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b;
  cin>>a>>b;
  if(a==1||b==1)
    cout<<1<<endl;
  else if(b%2==0){
  	  long long s=a*b/2; 
      cout<<s<<endl;
    }
  else{
    if(a%2==1){
  	  long long s=a*b/2+1; 
      cout<<s<<endl;
    }
    else{
  	  long long s=a*b/2; 
      cout<<s<<endl;
    }
  }
  return 0;
}

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



int main()
{
     int n,i=0,c=0,num;
     scanf("%d",&n);
     vector<pair<int, int> >v,s;
     while(n>0)
     {
         scanf("%d",&num);
         v.push_back(make_pair(num,i));
         i++;
          n--;
     }
     s=v;
     sort(s.begin(),s.end());
     for(i=0;i<v.size();i++)
     {
         if(v[i].first!=s[i].first)
         {
             c++;
         }
     }
     if(c==2 || c==0)
     {
         printf("YES");
     }
     else
     {
         printf("NO");
     }
     
     
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion

int fpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1) {
            res = res * a % MFFT;
        }
        a = a * a % MFFT;
        b /= 2;
    }
    return res;
}

int inv(int a) {
    return fpow(a, MFFT - 2);
}

int32_t main() {
    make(int, n, m, k);
    VI f(n);
    f[0] = 1;
    for (int i = 1; i < n; ++i) {
        f[i] = f[i - 1] * i % MFFT;
    }
    auto C = [&](int n, int k) {
        return f[n] * inv(f[k]) % MFFT * inv(f[n - k]) % MFFT;
    };
    int ans = 0;
    for (int i = 0; i <= k; ++i) {
        ans = (ans + C(n - 1, i) * m % MFFT * fpow(m - 1, n - 1 - i)) % MFFT;
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 4820
#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;

template <typename T> using order_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll         long long int
#define endl       '\n'
#define pii        pair <int, int>
#define mk         make_pair

static const int maxn = 3e5 + 5;
static const int logn = 19;

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

      

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


Measured memory_bytes: 3628
n = int(input())
cardsS = []
cardsH = []
cardsC = []
cardsD = []
for i in range(0, 13):
    cardsS.append(False)
    cardsH.append(False)
    cardsC.append(False)
    cardsD.append(False)
for i in range(0, n):
    mark, num = input().split()
    if mark == "S":   cardsS[int(num) - 1] = True
    elif mark == "H": cardsH[int(num) - 1] = True
    elif mark == "C": cardsC[int(num) - 1] = True
    elif mark == "D": cardsD[int(num) - 1] = True
for i in range(0, 13):
    if not cardsS[i]: print("S", (i + 1))
for i in range(0, 13):
    if not cardsH[i]: print("H", (i + 1)) 
for i in range(0, 13):
    if not cardsC[i]: print("C", (i + 1)) 
for i in range(0, 13):
    if not cardsD[i]: print("D", (i + 1)) 


Measured memory_bytes: 5616
#include<iostream>
#include<climits>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
ll kaijou(ll n){
	if(n==1){
		return 1;
	}else{
		return kaijou(n-1);
	}
}
int main(){

	int n;
	cin >> n;
	vector< ll > a(n);
	
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	sort(a.begin(), a.end());
	
	ll ans1 = a.back();
	ll ans2 = a.front();
	ll tmp = abs(2* a[0] - ans1);
	for(int i = 0; i < n; i++)
	{
		if(abs(2*a[i] - ans1) < tmp){
			tmp = abs(2*a[i] - ans1);
			ans2 = a[i];
		}
	}

	cout << ans1 << " " << ans2 << endl;
	
	
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main()
{
	int a, b, c;
	int max, min, total;
	
	
	scanf("%d %d %d", &a, &b, &c);
	total = a + b + c;
	if(c < a && b < a)
	{
		max = a;
	}
	else if (a < b && c < b)
	{
		max = b;
	}
	else
	{
		max = c;
	}
	
	if(a < b && a < c)
	{
		min = a;
	}
	else if (b < a && b < c)
	{
		min = b;
	}
	else
	{
		min = c;
	}
	printf("%d %d %d\n", min, total - max - min, max);
	
	return 0;
}


Measured memory_bytes: 2732
/* ex 9_2
   yy8332 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//リストのノード（スタック内の各データ）の定義
typedef struct node{
  char elem;
  struct node *next;
} node;

//スタックにデータを追加
void push(node **first, char elem){
  //追加する分の領域を確保
  node *new = calloc(1, sizeof(node));
  if(new == NULL) exit(1);
  new->elem = elem;
  new->next = *first;
  *first = new;
}

//スタックからデータを取り出す
char pop(node **first){
  char elem;
  node *tmp = *first;
  if(tmp == NULL) exit(1);
  elem = tmp->elem;
  *first = tmp->next;
  //取り出したノードのメモリを解放
  free(tmp);
  return elem;
}

int main(void){
  char input[100001], tmp;
  int len, i, count = 0;

  //最初のノードの指す先
  node *first = NULL;

  //入力読み取り
  scanf("%s", input);
  //入力文字列の長さ取得
  len = strlen(input);

  for(i = 0; i < len; i++){
    if(first != NULL){
      //スタックからノードを取り出す
      tmp = pop(&first);
      //2つのキューブの色で場合分け
      if(tmp != input[i]){
        count++;
      }
      else{
        //スタックにノードを追加
        push(&first, tmp);
        push(&first, input[i]);
      }
    }
    else{
      //スタックにノードを追加
      push(&first, input[i]);
    }
  }

  count = count * 2;

  //出力
  printf("%d\n", count);

  return 0;
}


Measured memory_bytes: 4884
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int N = 1000000;
const ll INF = std::numeric_limits<long long>::max();
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define sz size
string YN(bool b) { return(b ? "YES" : "NO"); }
string yn(bool b) { return(b ? "Yes" : "No"); }ll a[100000], b[100000];
int main() {
	ll n,mn=INF,mn2=INF,t=0,d=INF;
	cin >> n;
	rep(i, n) {  cin >> a[i] >> b[i]; t = max(t, a[i]); d = min(d, a[i]);mn = min(b[i], mn); mn2 = min(mn2, a[i]); }
	cout << (t-d+1) + mn-1 + mn2<<endl;
	return 0;
}

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

const int N = 1000009;
const int mod = 1000000007;

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);
#define int long long int
#define endl "\n"
#define sz(a) (int)((a).size())
#define all(a) a.begin(), a.end()
inline int add(int a, int b)
{
	a += b;
	if (a >= mod)
		a -= mod;
	return a;
}
inline int sub(int a, int b)
{
	a -= b;
	if (a < 0)
		a += mod;
	return a;
}
inline int mul(int a, int b) { return (int)((long long)a * b % mod); }
inline int binpow(int a, int b)
{
	int res = 1;
	while (b > 0)
	{
		if (b & 1)
			res = mul(res, a);
		a = mul(a, a);
		b /= 2;
	}
	return res;
}
inline int inv(int a) { return binpow(a, mod - 2); }

int x, y;
vector<int> fac;

void pre()
{
}

int32_t main()
{
	IOS;
	pre();
	cin >> x >> y;
	if (((2 * x - y) % 3) != 0 || ((2 * y - x) % 3) != 0 || (x > (2 * y)) || (y > (2 * x)))
	{
		cout << "0\n";
		return 0;
	}
	int X = (2 * x - y) / 3;
	int Y = (2 * y - x) / 3;
	int ek = 1;
	for (int i = 2; i <= (X + Y); i++)
		ek = (ek * i) % mod;
	int doo = 1;
	for (int i = 2; i <= (X); i++)
		doo = (doo * i) % mod;
	int teen = 1;
	for (int i = 2; i <= (Y); i++)
		teen = (teen * i) % mod;
	int ans = mul(ek, inv(doo));
	ans = mul(ans, inv(teen));
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
using ll = long long;
const ll MOD = 1000000007;

using cplx = complex<double>;
const double pi = atan2(0, -1);

double dat[62][3];
pair<cplx, double> niku[62];

double dist(cplx x, cplx y) {
	double xd = x.real() - y.real();
	double yd = x.imag() - y.imag();
	return sqrt(xd * xd + yd * yd);
}

int main() {
	int N, K;
	double x, y, c;
	cin >> N >> K;
	cplx P;
	for (int i = 0;i < N;i++) {
		cin >> x >> y >> c;
		P = { x,y };
		niku[i] = { P,c };
	}

	double ok = 500000, ng = 0, mid;
	vector<pair<double, bool>> cross, SS;
	double dd, xr, nr, mr, otr;

	int din, mxi, amx;
	for (int zzz = 0;zzz < 80;zzz++) {
		mid = (ok + ng) / 2;
		amx = 0;
		for (int i = 0;i < N;i++) {
			din = 1;
			for (int j = 0;j < N;j++) {
				if (i == j)continue;
				dd = dist(niku[i].first, niku[j].first);
				mr = mid / niku[i].second;
				otr = mid / niku[j].second;
				xr = max(mr, otr);
				nr = min(mr, otr);

				if (dd <= mr + otr) {
					if (dd + mr < otr) {
						//内包関係
						din++;
					}
					else if (dd + otr < mr) {
						//自分が含んでしまっている内包
					} 
					else {
						//2点で交わる
						//cout << mr << " " << otr << " " << dd << endl;
						double ct = (mr * mr + dd * dd - otr * otr) / (2 * mr * dd);
						//cout << ct << endl;
						double ag = acos(ct);
						//cout << i << " " << j << " " << ag << endl;
						double ags = arg(niku[j].first - niku[i].first) - ag;
						double agb = arg(niku[j].first - niku[i].first) + ag;
						if (ags < 0 && agb > 0)din++;


						cross.push_back({ ags,0 });
						cross.push_back({ agb,1 });
						cross.push_back({ ags + 2 * pi,0 });
						cross.push_back({ agb + 2 * pi,1 });
						cross.push_back({ ags + 4 * pi,0 });
						cross.push_back({ agb + 4 * pi,1 });
					}
				}
			}

			sort(all(cross));

			mxi = din;
			for (auto th : cross) {
				if (th.first < 0)continue;
				if (th.first > 2 * pi)break;
				if (th.second) {
					din--;
				}
				else {
					din++;
				}
				mxi = max(din, mxi);
			}
			amx = max(amx, mxi);
			cross = SS;
		}

		if (amx < K)ng = mid;
		else ok = mid;
	}
	printf("%.10f\n", ok);
}

Measured memory_bytes: 512