akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#define inf 1<<30
using namespace std;

int b_search(vector<int> &dp,int k){
  int a=0;
  int b=dp.size();
  while(a+1<b){
    int m=(a+b)/2;
    if(k>dp.at(m)){
      a=m;
    }else if(k<=dp.at(m)){
      b=m;
    }
  }
  return a;
}

int main(){
  int N;
  cin >> N;
  vector<int> a(N),dp(N+2,inf);
  dp.at(0)=-1;
  for(int i=0;i<N;i++) cin >> a.at(i);
  for(int i=0;i<N;i++){
    int n=b_search(dp,a.at(i));
    dp.at(n+1)=a.at(i);
  }
  int ans;
  for(int i=0;i<N+2;i++){
    if(dp.at(i)==inf){
      ans=i-1;
      break;
    }
  }
  /*
  for(int i=0;i<N;i++){
    cout << a.at(i) << " ";
  }
  cout << endl;
  for(int i=0;i<N+2;i++){
    cout << dp.at(i) << " ";
  }
  cout << endl;
  */
  cout << ans << endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(a*n,b) << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include<cstdio>

char s[100001];

int main(){
	int _=fread(s+1,1,100000,stdin);
	if(s[_]=='\r'||s[_]=='\n')
		--_;
	const int n=_;

	for(int i=1;i<=n;++i)
		s[i]-=48;
	if(!s[1]||s[n])
		return puts("-1"),0;
	for(int i=1;i+i<=n;++i)
		if(s[i]!=s[n-i])
			return puts("-1"),0;

	int las=1;
	for(int i=2;i+i<=n;++i)
		if(s[i]){
			for(int j=las;j<i;++j)
				printf("%d %d\n",i,j);
			las=i;
		}
	for(int i=las;i<n;++i)
		printf("%d %d\n",i,n);

	return 0;
}


Measured memory_bytes: 1536
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<vector> 
#include<bits/stdc++.h>
using namespace std;
int q[510][510];
int n,m;
int ans;
struct data{
	int i,j;
	int x,y;
}qwq[1000010];
signed main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	  for(int j=1;j<=m;j++)
	    scanf("%d",&q[i][j]);
	for(int i=1;i<n;i++)
	  for(int j=1;j<=m;j++)
	  	{
	  	if(q[i][j]&1) 
		  	{
		  	q[i+1][j]++;
			qwq[++ans].i=i;
			qwq[ans].j=j;
			qwq[ans].x=i+1;
			qwq[ans].y=j;	
			}
		}
	  	
	for(int j=1;j<m;j++) 
		if(q[n][j]&1) 
			{
			q[n][j+1]++;
			qwq[++ans].i=n;
			qwq[ans].j=j;
			qwq[ans].x=n;
			qwq[ans].y=j+1;	
			}
	printf("%d\n",ans);
	for(int i=1;i<=ans;i++) printf("%d %d %d %d\n",qwq[i].i,qwq[i].j,qwq[i].x,qwq[i].y); 	
	return 0;
}

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

int main(){
    ll N, K; cin >> N >> K ;
    ll cnt;
    bool jud = false;
    
    if(K > (N-1)*(N-2)/2){
        cout << -1 << endl;
    }
    
    else{
        cout << N*(N-1)/2  - K << endl;

        cnt = (N-2)*(N-1)/2 - K;
        
        rep(i,N-1){
            cout << 1 << " " << i+2 << endl;
        }

        for(int i=2; i<N; i++){

            for(int j=i+1; j<=N; j++){

                if(cnt <=0 ){
                    jud = true;
                    break;
                }

                cout << i << " " << j << endl;
                cnt--;
               
            }
            if(jud){
                break;
            }
        }
            
        

    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const long long MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す//計算量は0(log(max(a,b))
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す//計算量は0(log(max(a,b))
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す//計算量は0(log(y))
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す//計算量は0(sqrt(a))
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  ll H,W,K,count=0,answer=0;
  cin>>H>>W>>K;
  vector<string> vec(H);
  for(int i=0;i<H;i++){
    cin>>vec.at(i);
    for(int j=0;j<W;j++){
      if(vec.at(i).at(j)=='#'){count++;}
    }
  }
  ll memo=count-K;
  if(memo<0){cout<<0<<endl;return 0;}
  for(int a=0;a<(1<<H);a++){
    unordered_map<ll,ll> mp1;
    ll rock1=0;
    for(int i=0;i<H;i++){
      if((1<<i)&a){
        mp1[i]=1;
      }
    }
    for(int b=0;b<(1<<W);b++){
      unordered_map<ll,ll> mp2;
      ll rock2=0;
      for(int j=0;j<W;j++){
        if((1<<j)&b){
          mp2[j]=1;
        }
      }
      ll check=0;
      for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
          //cout<<mp1[i]<<" " <<mp2[j]<<endl;
          if(mp1[i]==0 && mp2[j]==0 && vec.at(i).at(j)=='#'){
            check++;
          }
        }
      }
      //cout<<check<<endl;
      if(check==K){answer++;}
    }
  }
  cout<<answer<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44

using namespace std;



int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int n, m;
    ios::sync_with_stdio(false);
    cin >> n >> m;
    ll ans = 1LL * n * m;
    if(n == 1) {
        if(m > 1)
            ans -= 2;
    }
    else {
        if(m == 1)
            ans -= 2;
        else
            ans -= 1LL * 2 * (n + m - 2);
    }
    cout << ans;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

struct mint {
    constexpr static int mod = 1000000007;
    long long x;
    mint(long long x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    vector<ll> s(n), t(m);
    rep(i, n) cin >> s[i];
    rep(i, m) cin >> t[i];
    vector<vector<mint>> dp(n + 1, vector<mint>(m + 1, 1));
    rep(i, n) {
        rep(j, m) {
            dp[i + 1][j + 1] = dp[i][j + 1] + dp[i + 1][j];
            if (s[i] != t[j]) {
                dp[i + 1][j + 1] -= dp[i][j];
            }
        }
    }
    cout << dp[n][m].x << endl;
    return 0;
}


Measured memory_bytes: 34568
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int A, P;

int main(){

  cin >> A >> P;
  cout << (3 * A + P) / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[] k = new int[m];
        int[][] s = new int[m][];
        for (int i=0;i<m;i++){
            k[i] = scanner.nextInt();
            s[i] = new int[k[i]];
            for (int j=0;j<k[i];j++){
                s[i][j] = scanner.nextInt();
            }
        }
        int[] p = new int[m];
        for (int i=0;i<m;i++){
            p[i] = scanner.nextInt();
        }
        int countAnswer = 0;
        for (int i=0;i<Math.pow(2,n);i++){
            String str = Integer.toBinaryString(i);
            while (str.length()<n){
                str = "0" + str;
            }
            int count1 = 0;
            for (int j=0;j<m;j++){
                int count2 = 0;
                for (int a=0;a<n;a++){
                    boolean b = false;
                    for (int bo=0;bo<s[j].length&&!b;bo++){
                        if (s[j][bo]==a+1){
                            b = true;
                        }
                    }
                    if (str.charAt(a)=='1'&&b)count2++;
                }
                if (count2%2==p[j])count1++;
            }
            if (count1==m)countAnswer++;
        }
        System.out.println(countAnswer);
    }
}

Measured memory_bytes: 24020
#include<iostream>
using namespace std;
 
int main()
{
    int n,i,j,a[4][14],k;
    char c;
     
    for(j=0;j<4;j++){
        for(i=1;i<=13;i++){
            a[j][i]=0;
            }
        }
             
    cin>>n;
    for(i=0;i<n;i++){
    cin>>c>>k;
    if(c=='S')
        a[0][k]=1;
    else if(c=='H')
        a[1][k]=1;
    else if(c=='C')
        a[2][k]=1;
    else if(c=='D')
        a[3][k]=1;
    }
     
    for(j=0;j<4;j++){   
        for(i=1;i<=13;i++){
            if(a[j][i]==0){
                if(j==0)
                cout<<'S'<<" "<<i<<endl;
                else if(j==1)
                cout<<'H'<<" "<<i<<endl;
                else if(j==2)
                cout<<'C'<<" "<<i<<endl;
                else if(j==3)
                cout<<'D'<<" "<<i<<endl;
                }
            }
        }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
using namespace std;
int n,a,b;
bool is_suit(int x)
{
	int s=0;
	while(x>0)
	{
		s+=x%10;
		x=x/10;
	}
	if(s>=a&&s<=b)return true;
	else return false;
}
int main()
{
	int s=0;
	scanf("%d%d%d",&n,&a,&b);
	for(int i=1;i<=n;i++)
	{
		if(is_suit(i))s+=i;
		//printf("%d\n",is_suit(i));
	}
	printf("%d\n",s);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
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 (b<a) { a=b; return 1; } return 0; }

int n, m;
char a[100][100], b[100][100];

int main(){
  cin >> n >> m;
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];
  string res = "No";
  for(int i = 0; i < n - m + 1; i++){
    for(int j = 0; j < n - m + 1; j++){
      bool flag = true;
      rep(k, m){
        rep(l, m){
          if(b[k][l] != a[i + k][j + l]){
            flag = false;
          }
        }
      }
      if(flag) res = "Yes";
    }
  }
  cout << res << endl;
}


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

long int A, B;
vector<long int> List;
int main(){
    cin >> A >> B;
    if (A % 2 != 0){
        List.push_back(A);
        A += 1;
    }
    while (true){
        if (A + 4 > B){
            for (int i = 0; B >= A + i; i++){
                List.push_back(A + i);
            }
            break;
        }
        A += 4;
    }
    long int ans = 0;
    for (int i = 0; i < List.size(); i++){
        ans = ans ^ List[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var num int
	fmt.Scan(&num)
	all := 0
	arr := make([]int, num)
	var tmpNum int
	sc.Split(bufio.ScanWords)
	for i := 0; i < num; i++ {
		tmpNum = nextInt()
		arr[i] = tmpNum
		all = all ^ tmpNum
	}
	for _, a := range arr {
		fmt.Print(all ^ a)
		fmt.Print(" ")
	}
}
func nextLine() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func MySort(a []int) {
	sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })

}
func SortedBinaryAppend(sortedArr []int, targetValue int) []int {
	return []int{}
}
func SortedBinaryDelete(sortedArr []int, targetValue int) []int {
	return []int{}
}
func SortedBinarySearch(sortedArr []int, targetValue int) int {
	post := len(sortedArr) - 1
	pre := 0
	for {
		div := (post + pre) / 2
		tim := sortedArr[div]
		if tim == targetValue {
			return pre + div
		} else if tim > targetValue {
			post = tim
		} else {
			pre = tim
		}
		if pre == post {
			return -1
		}
	}
}
func Abs(i int) int {
	if i < 0 {
		return -1 * i
	}
	return i
}
func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func CalcNum(tate int, yoko int, A int, B int, dp *map[[2]int]int) int {
	if (*dp)[[2]int{tate, yoko}] != 0 {
		return (*dp)[[2]int{tate, yoko}]
	}
	return yoko*CalcNum(tate-1, yoko, A, B, dp) + tate*CalcNum(tate, yoko-1, A, B, dp)
}
func arrSum(arr []int) int {
	sum := 0
	for _, a := range arr {
		sum += a
	}
	return sum
}
func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}
func scanStrings(len int) (strings []string) {
	var str string
	for i := 0; i < len; i++ {
		fmt.Scanf("%s", &str)
		strings = append(strings, str)
	}
	return
}


Measured memory_bytes: 7280
import math
import bisect
N,K = list(map(int,input().split(" ")))
r,s,p = list(map(int,input().split(" ")))

di = {}
di["r"] = p
di["s"] = r
di["p"] = s
di["@"] = 0
T = input()
T = list(T)
for i in range(K,N):
    if T[i - K] == T[i]:
        T[i] = "@"
ans = 0
for temp in T:
    ans += di[temp]

print(ans)



Measured memory_bytes: 49392
#define N 10005
#define Q 505
#include <stdio.h>
int S[N], T[Q];

int isExist(int x, int n) {
    for (int i = 0; i < n; i++) {
        if (S[i] == x) {
            return 1;
        }
    }
    return 0;
}

int main() {
    int cnt = 0;
    int n, q;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &S[i]);
    }
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%d", &T[i]);
    }
    for (int i = 0; i < q; i++) {
        if (isExist(T[i], n)) {
            cnt++;
        }
    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int n;
	long long k;
	cin >> n >> k;

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

	sort(a.begin(), a.end());
	sort(f.begin(), f.end(), greater<int>());

	int N_BIT = 45;
	long long ans = (1LL << N_BIT) - 1;
	for (int bit = N_BIT - 1; bit >= 0; bit--) {
		long long tmp = ans - (1LL << bit);
		// printf("------ %lld\n", ans);
		// printf("tmp %lld\n", tmp);

		long long rest = k;
		bool ok = true;
		for (int i = 0; i < n; i++) {
			long long limit = tmp / f[i];
			// printf("%d: a %d f %d: limit %d, rest %d\n", i, a[i], f[i], limit, rest);
			if (a[i] <= limit) {
				continue;
			}

			if (a[i] - limit > rest) {
				ok = false;
				// printf("false\n");
				break;
			}

			rest -= a[i] - limit;
		}

		if (ok) {
			ans = tmp;
		}
	}

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


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

int main(){
    int n, m;
    cin >> n >> m;
    pair<int, int> p[100010];

    for(int i = 0;i < m;i++){
        cin >> p[i].second >> p[i].first;
    }

    sort(p, p+m);

    int broken = 0;
    int ans = 0;
    for(int i = 0;i < m;i++){
        if(broken < p[i].second){
            broken = p[i].first-1;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}




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

int main() {
	int N;
	cin >> N;
	vector<int> buttons(N, 0);
	for (int i = 0; i < N; i++) {
		int j;
		cin >> j;
		buttons[i] = j - 1;
	}
	vector<int> visited(N, 0);
	int start = 0;
	int step = 0;
	int found = 0;
	while (visited[start] == 0) {
		if (start == 1) {
			found = 1;
			break;
		}
		visited[start] = 1;
		start = buttons[start];
		step += 1;
	}
	if (found == 1) {
		cout << step << endl;
	}
	else {
		cout << -1 << endl;
	}
}

Measured memory_bytes: 1024
S = input()

C = S[::-1]
while C:
    if C[:5] == "maerd":
        C = C[5:]
    elif C[:7] == "remaerd":
        C = C[7:]
    elif C[:5] == "esare":
        C = C[5:]
    elif C[:6] == "resare":
        C = C[6:]
    else:
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	int ans=0;
	string s;
	while(cin>>s){
		//if(s=="0") break;
		bool f=0;
		rep(i,0,s.size()/2){
			if(s[i]!=s[s.size()-1-i]) f=1;
		}
		if(f==0) ans++;
	}
	o(ans);
}

Measured memory_bytes: 1184
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#define INF 10000000
using namespace std;
typedef pair<int,int> P;

int n;
int ba[10];

bool all(int,int,int);

int main(){
  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<10;j++){
      cin >> ba[j];
    }
    if(all(0,0,0)){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }

}

bool all(int end,int l,int r){
  if(end==10){
    return true;
  }else if(ba[end]>l){
    return all(end+1,ba[end],r);
  }else if(ba[end]>r){
    return all(end+1,l,ba[end]);
  }
  return false;
}

Measured memory_bytes: 1156
#include <iostream>
#include <cstdio>

using namespace std;

void call(int n) {

	for (int i = 1; i <= n; i++) {
		int x = i;
		if (x % 3 == 0) {
			printf(" %d", i);
		}
		else if (x % 10 == 3) {
			printf(" %d", i);
		}
		else {
			while(x) {
				x /= 10;
				if (x % 10 == 3) {
					printf(" %d", i);
					break;
				}
			}
		}
	}
	printf("\n");
}

int main() {
	int n;
	cin >> n;
	call(n);

	return 0;
}

Measured memory_bytes: 1148
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();
 
          if(op.equals("?"))break;
            int n = 0;
 
            switch(op){
            case "+":
                n = a+b;
                break;
            case "-":
                n = a-b;
                break;
            case "*":
                n = a*b;
                break;
            case "/":
                n = a/b;
                break;
            }
 
            System.out.printf("%d\n", n);
        }
    }
}


Measured memory_bytes: 26356
package main

import (
	"fmt"
)

func main() {
	var H, W int
	fmt.Scan(&H, &W)

	a := make([]string, H)
	for i := 0; i < H; i++ {
		fmt.Scan(&a[i])
	}

	row := make([]bool, H)
	col := make([]bool, W)

	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if a[i][j] == '#' {
				row[i] = true
				col[j] = true
			}
		}
	}

	for i := 0; i < H; i++ {
		if row[i] {
			for j := 0; j < W; j++ {
				if col[j] {
					fmt.Print(string(a[i][j]))
				}
			}
			fmt.Println()
		}
	}
}


Measured memory_bytes: 768
n,k=map(int,input().split())
ans=0
for i in range(k,n+2):
  maxs=i*(2*n-i+1)//2
  mins=i*(i-1)//2
  ans+=maxs-mins+1
  ans%=10**9+7
  #print('#####')
  #print(i)
  #print(ans)
print(ans%(10**9+7))


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

using namespace std;

const int N = 1e6;
map<string,long long int> mp;
string s[N];
map<string ,bool> mp1;

int main () {
    long long int n,ans=0;
    cin >> n;
    for(int i = 0 ; i < n ; i++ ) {
        cin >> s[i];
        sort(s[i].begin(),s[i].end());
        mp[s[i]]++;
    }
    for(int i = 0 ; i < n ; i++ ) {
        if(!mp1[s[i]]) {
            ans+=((mp[s[i]]-1)*mp[s[i]])/2;
        }
        mp1[s[i]]=true;
    }
    cout << ans;
}


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

void print_v(vector<int> vi){
	for(int i = 0; i < vi.size(); i++){
		cout << vi[i];
	}
	cout << endl;
}

vector<int> get_num(string &s, int k){
	vector<int> num;
	for(size_t i = 0; i < s.size(); i++){
		if(s[i] == 'X'){
			num.push_back(k);
		}else{
			num.push_back(s[i] - '0');
		}
	}
	return num;
}

vector<int> sum(vector<int> num1, vector<int> num2){
	vector<int> num3;
	reverse(num1.begin(), num1.end());
	reverse(num2.begin(), num2.end());
	while(num1.size() < num2.size()) num1.push_back(0);
	while(num2.size() < num1.size()) num2.push_back(0);
	int c = 0;
	int d = 0;
	for(size_t i = 0; i < num1.size(); i++){
		d = c + num1[i] + num2[i];
		c = d / 10;
		d %= 10;
		num3.push_back(d);
	}
	if(c == 1) num3.push_back(c);
	reverse(num3.begin(), num3.end());
	return num3;
}

int main(){
	string s;
	while(cin >> s){
		int i = 0, j;
		while(s[i] != '+') i++;
		string num1(s.begin(), s.begin() + i);
		i++;
		j = i;
		while(s[j] != '=') j++;
		string num2(s.begin() + i, s.begin() + j);
		j++;
		string num3(s.begin() + j, s.end());
		bool f = false;
		if((num1[0] == 'X' && num1.size() > 1) || (num2[0] == 'X' && 
			num2.size() > 1) || (num3[0] == 'X' && num3.size() > 1)) f = true;
		if((num1[0] == '0' && num1.size() > 1) || (num2[0] == '0' &&
			num2.size() > 1) || (num3[0] == '0' && num3.size() > 1)){
			cout << "NA" << endl;
			continue;
		}
		int k = 0;
		while(k < 10){
			if(f){
				k++;
				f = false;
				continue;
			}
			vector<int> n1, n2, n3, n4;
			n1 = get_num(num1, k);
			n2 = get_num(num2, k);
			n3 = get_num(num3, k);
			n4 = sum(n1, n2);
			bool ok = true;
			if(n3.size() != n4.size()){
				ok = false;
			}else{
				for(size_t i = 0; i < n3.size(); i++){
					if(n3[i] != n4[i]){
						ok = false;
						break;
					}
				}
			}
			if(ok) break;
			k++;
		}
		if(k < 10) cout << k << endl;
		else cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>

const int NIL = -1;
const int M =1046527; //M??????????????\?????????????????°???
const int L = 14;

char H[M][L];

//???????????°?????????????????????
int getChar(char ch){
  if(ch=='A') return 1;
  else if(ch=='C') return 2;
  else if(ch=='G') return 3;
  else if(ch=='T') return 4;
  else return 0;
}

//???????????????key??¨????????°???????????????
long long getKey(char str[]){
  long long sum=0,p=1,i;
  for(i=0;i<strlen(str);i++){
    sum+=p*getChar(str[i]);
    p*=5;
  }
  return sum;
}

int h1(int key){
  return key%M;
}

int h2(int key){
  return (1+key%(M-1));
}

int insert(char str[]){
  long long key,i,h;
  key=getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0)return 1; //?????§???????´????????????????????????§????????°????????????
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}



int find(char str[]){
  int key,i,h;
  key = getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0) return 1; //???????????\??????????????¨??????????????°???1?????????
    else if(strlen(H[h])==0) return 0; //?????????????????°???????????????????????????????????????
  }
  return 0;
}

int main(){
  int n,flag=0;
  char com[9],str[L];

  scanf("%d",&n);

  for(int i=0;i<n;i++){
  scanf("%s %s",com,str);
  if(com[0]=='i') insert(str);
  else if(com[0]=='f'){
    flag=find(str);
    if(flag) puts("yes");
    else puts("no");
    }
  }
  return 0;
}

Measured memory_bytes: 15492
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int k = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'R') {
				k++;
			}
		}

		int result = 0;
		for (int i = 0; i < k; i++) {
			if (s.charAt(i) == 'W') {
				result++;
			}
		}
		System.out.println(result);
	}

	//WRWWRWRR
	//RRRRWWWW

}


Measured memory_bytes: 40584
#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:102400000,102400000")
#include<iostream>  
#include<cstdio>  
#include<fstream>  
#include<iomanip>
#include<algorithm>  
#include<cmath>  
#include<deque>  
#include<vector>  
#include<assert.h>
#include<bitset>
#include<queue>  
#include<string>  
#include<cstring>  
#include<map>  
#include<stack>  
#include<set>
#include<functional>
#define pii pair<int, int>
#define mod 1000000007
#define mp make_pair
#define pi acos(-1)
#define eps 0.00000001
#define mst(a,i) memset(a,i,sizeof(a))
#define all(n) n.begin(),n.end()
#define lson(x) ((x<<1))  
#define rson(x) ((x<<1)|1) 
#define inf 0x3f3f3f3f
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int maxn = 1e4 + 5;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int i, j, k, m, n, T;
	string a;
	cin >> n >> a;
	int left = 0;
	int crt = 0;
	for(int i=0;i<a.size();++i)
	{
		if (a[i] == '(')crt++;
		else {
			if (crt > 0)crt--;
			else left++;
		}
	}
	for (int i = 1; i <= left; ++i)
		cout << '(';
	cout << a;
	for (int i = 1; i <= crt; ++i)
		cout << ')';
	cout << endl;
	return 0;
}

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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

struct UF{
  vector<int> par; //親
  vector<int> size; //集合の大きさ

  UF(int n){
    par.resize(n);
    size.resize(n);
    for(int i = 0; i < n; i++){
      par[i] = i;
      size[i] = 1;
    }
  }

  //木の根を求める
  int root(int x){
    if(par[x] == x){
      return x;
    }
    else {
      return par[x] = root(par[x]);
    }
  }

  //xとyの属する集合を併合
  void unite(int x,int y){
    x = root(x);
    y = root(y);
    if(x == y) return;

    if(size[x] < size[y]) swap(x,y);
    par[y] = x;
    size[x] += size[y];
  }

};

const int MAX = 1e5 + 10;

signed main(){

  int n; cin >> n;
  UF uf(MAX*2);
  for(int i = 0; i < n; i++){
    int x,y; cin >> x >> y;
    uf.unite(x,y + MAX);
  }

  vector<int> x(MAX*2,0),y(MAX*2,0);
  for(int i = 0; i < MAX; i++){
    x[uf.root(i)]++;
    y[uf.root(i + MAX)]++;
  }

  int ans = 0;
  for(int i = 0; i < MAX*2; i++){
    ans += x[i] * y[i];
  }
  cout << ans - n << endl;

  return 0;
}


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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

vector<int> tree[100005];
set<int> graph[100005];
vector<int> cnt(100005);
stack<int> st;
vector<P> ans;
vector<bool> used(100005);

std::vector<int> par;
std::vector<int> rak; // number of the vertices

void init(int n) {
  par.resize(n+1);
  rak.resize(n+1, 1);
  for(int i=1; i<=n; i++) {
    par[i] = i;
  }
}

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 (rak[x] < rak[y]) {
    rak[y] += rak[x];
    par[x] = y;
  } else {
    rak[x] += rak[y];
    par[y] = x;
  }
}

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

void dfs(int p) {
  st.push(p);
  used[p] = true;
  for(auto e: tree[p]) {
    if (used[e]) continue;
    dfs(e);
  }
}

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

  int n, m; cin >> n >> m;

  if (m%2!=0) {
    cout << -1 << endl;
    return 0;
  }
  init(n);

  rep(i, m) {
    int a, b; cin >> a >> b;
    a--; b--;
    if (!same(a, b)) {
      tree[a].push_back(b);
      tree[b].push_back(a);
      unite(a, b);
    } else {
      graph[a].emplace(b);
      graph[b].emplace(a);
    }
  }

  dfs(0); // topological sort of the tree
  while(!st.empty()) {
    auto p = st.top(); st.pop();
    debug(p);
    for(auto e: graph[p]) {
      ans.emplace_back(p, e);
      cnt[p]++;
      graph[e].erase(p);
    }
    // Never used. don't need to reset
    // graph[p].clear();
    used[p] = false;
    for(auto e: tree[p]) {
      if (!used[e]) continue;
      if (cnt[p]%2==1) {
        ans.emplace_back(p, e);
        cnt[p]++;
      } else {
        ans.emplace_back(e, p);
        cnt[e]++;
      }
    }
  }

  for(auto e: ans) {
    cout << e.first+1 << ' ' << e.second+1 << '\n';
  }

}

Measured memory_bytes: 21488
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <set>

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

using namespace std;
typedef long long ll;

int main()
{
    int n,m;
    while(cin >> n >> m) {
        if(n == 0 && m == 0) break;
        
        vector<pair<int,pair<int,int> > > v(m);
        rep(i,m) cin >> v[i].first >> v[i].second.first >> v[i].second.second;

        sort(v.begin(),v.end());

        bool T[20005];
        memset(T,0,sizeof(T));
        T[1] = true;
        set<int> st;
        st.insert(1);
        
        rep(i,m) {
            int time = v[i].first;
            int s = v[i].second.first;
            int t = v[i].second.second;

            if(T[s]) {
                T[t] = true;
                st.insert(t);
            }
        }
        
        cout << st.size() << endl;

    }

    return 0;
}

Measured memory_bytes: 2148
//Be Name Khoda, Besmellah Rahmane Rahim, In The Name Of God;
//#include<bits/std++.h>
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include <stdio.h>
#include <string.h>
#include<iomanip>
#include<unordered_map>
#include<unordered_set>
#include <fstream>

using namespace std;

const long long N = 6000 + 5;
long long mod;
long long fact[N];
long long inv[N];
long long r2[N];
long long r3[N];
long long n;
 
long long power(int a, int b)
{
    if (!b)
    {
        return 1;
    }
    long long ans = power(a, b / 2);
    ans = ans * ans;
    ans = ans % mod;
    if (b % 2)
    {
        ans = ans * a;
        ans = ans % mod;
    }
    return ans;
}

void pre()
{
    fact[0] = 1;
    for (int i = 1; i < 3 * n + 5; i++)
    {
        fact[i] = fact[i - 1] * i;
        fact[i] %= mod;
    }
    for (long long i = 0; i < 3 * n + 5; i ++)
    {
        int tmp2 = power(2, i);
        int tmp3 = power(3, i);
        r2[i] = power(tmp2, mod - 2);
        r3[i] = power(tmp3, mod - 2);
        inv[i] = power(fact[i], mod - 2);
    }
}
 
long long choose(long long a, long long b)
{
    long long ans = fact[b];
    ans = ans * inv[b - a];
    ans = ans % mod;
    ans = ans * inv[a];
    ans = ans % mod;
    return ans;
}
 
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> mod;
    pre();
    long long ans = 0;
    for (long long i = 0; i <= n; i ++)
    {
        for (long long j = i; i + (j - i) / 3 <= n; j += 3)
        {
            //cout << i + (j - i) / 3 << endl;
            long long k = n - i - (j - i) / 3;
            long long tmp = choose(j, 3 * n);
            tmp = tmp * choose(2 * i, 3 * n - j);
            tmp = tmp % mod;
            tmp = tmp * fact[2 * i];
            tmp = tmp % mod;
            tmp = tmp * r2[i];
            tmp = tmp % mod;
            tmp = tmp * inv[i];
            tmp = tmp % mod;
            tmp = tmp * fact[3 * k];
            tmp = tmp % mod;
            tmp = tmp * r3[k];
            tmp = tmp % mod;
            tmp = tmp * inv[k];
            tmp = tmp % mod;
            ans = (ans + tmp) % mod;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>

#define N 100
#define K 100

void main(){
  int n, k, d[K], a[K][N], trick_avoid[N]={0}, sum=0;
  scanf("%d %d",&n, &k);
  for(int i=0; i<k; i++){
    scanf("%d",&d[i]);
    for(int j=0; j<d[i]; j++){
      scanf("%d",&a[i][j]);
    }
  }
  
  for(int i=0; i<k; i++){
    for(int j=0; j<d[i]; j++){
      trick_avoid[a[i][j]-1] = 1;
//      printf("%d %d",a[i][j], trick_avoid[a[i][j]]-1);
    }
  }
//  for(int j=0; j<n; j++){
//    printf("%d ", trick_avoid[j]);
//  }
  
  for(int j=0; j<n; j++){
    if(trick_avoid[j] == 0){
      sum++;
    }
  }
  printf("%d",sum);
}

Measured memory_bytes: 1768
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1000000007;

int main(){
    string a,b;
    cin>>a>>b;
    int ans=0;//-1はbのほうが大きい,0は同じ,1はaのほうが大きい
    if(a.size()==b.size()){
        rep(i,a.size()){
            if(a[i]>b[i]){
                ans=1;
                break;
            }
            else if(a[i]<b[i]){
                ans=-1;
                break;
            }
        }
    }
    else{
        if(a.size()>b.size()) ans=1;
        else ans=-1;
    }
    if(ans==1) cout<<"GREATER"<<endl;
    else if(ans==-1) cout<<"LESS"<<endl;
    else cout<<"EQUAL"<<endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;

#define all(a) a.begin(), a.end()
#define mp make_pair
#define pb push_back

void solve() {
    int n; cin >> n;
    vi a(n);
    int res = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] % 2 == 1 && i % 2 == 0) res++;
    }
    cout << res;
}

int main() {
    solve();
}

Measured memory_bytes: 3624
N,M = map(int,input().split())
MAXL = -1
MINR = float("inf")
for _ in range(M):
    L,R = map(int,input().split())
    MAXL = max(MAXL, L)
    MINR = min(MINR, R)

print(max(0, MINR - MAXL + 1))

Measured memory_bytes: 3060
import java.io.*;

public class Main {
    private StreamTokenizer in;
    private PrintWriter out;

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

    int nextInt() throws IOException {
        in.nextToken();
        return (int) in.nval;
    }

    String nextString() throws IOException {
        in.nextToken();
        if (in.sval.isEmpty()) {
            in.nextToken();
        }
        return in.sval;
    }

    void run() throws IOException {
        out = new PrintWriter(new OutputStreamWriter(System.out));
        in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        solve();
        out.flush();
    }

    void solve() throws IOException {
        int n = nextInt();
        int answer = 1;
        int order = -1; // -1 unclear, 0 - decreasing, 1 - increasing
        int a = nextInt(), b;
        for (int i = 1; i < n; i++) {
            b = nextInt();
            if (a != b) {
                if (a < b) {
                    if (order == -1) {
                        order = 1;
                    } else if (order == 0) {
                        answer++;
                        order = -1;
                    }
                } else {
                    if (order == -1) {
                        order = 0;
                    } else if (order == 1) {
                        answer++;
                        order = -1;
                    }
                }
            }
            a = b;
        }
        out.print(answer);
    }
}

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

ll N, M, T, k, q, p, top;
char s[MAX_N], t[MAX_N];
// map<ll, char> ans;
map<ll, int> vis;

ll gcd (ll x, ll y) {return y == 0 ? x : gcd(y, x % y);}

int main () {
    scanf("%lld%lld", &N, &M);
    scanf("%s%s", s + 1, t + 1);
    T = gcd(N, M);
    k = N / T * M;
    // for (int i = 1;i * k <= 100000; ++k) {
    top = k;
    q = top / N, p = top / M;
    for (ll j = 0;j < N; ++j)
        vis[j * q + 1] = s[(int)j + 1] - 'a' + 1;
    for (ll j = 0;j < M; ++j) {
        if (vis[j * p + 1] != 0 && vis[j * p + 1] != t[(int)j + 1] - 'a' + 1) {
            puts("-1");
            return 0;
        }
    }
    // printf("%d\n", top);
    // if (can) break;
    // }
    printf("%lld\n", top);
    return 0;
}


Measured memory_bytes: 10880
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <cassert>
using namespace std;

//common
#define BR "\n"

#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long,long long> pll; typedef vector<pair<long long,long long> > vpll;
typedef vector<string> vs; typedef long double ld;

//config
#define MODE_DEBUG
//#define INF 1<<30
//#define EPS 1e-8
//const ll MOD =100000007;

//debug
#ifdef MODE_DEBUG
#define  DUMP(x)  cerr << #x << " = " << (x) <<endl
#define DEBUG(x) DUMP(x) << " (L" << __LINE__ << ")" << " " << __FILE__<<endl
#define CHECK(exp,act)  if(exp!=act){DUMP(exp);DEBUG(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#else
#define DUMP(x)
#define DEBUG(x)
#define CHECK(exp,act)
#define STOP(e)
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}
template<class T> inline string toString(const vector<vector<T>>& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

template<typename T,typename V> inline T mod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}

int encode(int h,int m,int s){
	return h*3600+m*60+s;
}
int getH(int t){
	return t/3600;
}
int getM(int t){
	return (t-getH(t)*3600)/60;
}
int getS(int t){
	return (t-getH(t)*3600-getM(t)*60)/1;
}

int main(){
	vector<int> w(10);
	REP(i,10)cin >> w[i];
	sort(ALL(w));
	vector<int> k(10);
	REP(i,10)cin >> k[i];
	sort(ALL(k));

	cout << w[7]+w[8]+w[9]<<" "<<k[7]+k[8]+k[9]<<endl;
	return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
const int N = 1005;
using namespace std;
int n,t,ans,tmp,T;
int con[N][N];
int spe[N][N],dis[N*N];
int head[N*N],in[N*N];
struct edge
{
	int to;
	int next;
}e[N*N*2];
queue<int> q;
void add(int x,int y)
{
	e[++t].to=y;
	e[t].next=head[x];
	head[x]=t;
	return;
}
void topsort()
{
	for(int i=1;i<=T;i++)
		if(!in[i])
		{
			tmp++;
			q.push(i);
			dis[i]=1;
		}
	while(!q.empty())
	{
		int j=q.front();
		q.pop();
		for(int i=head[j];i;i=e[i].next)
		{
			int k=e[i].to;
			dis[k]=dis[j]+1;
			in[k]--;
			if(!in[k])
			{
				tmp++;
				q.push(k);
			}
		}
	}
	return;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	for(int j=1;j<n;j++)
	{
		scanf("%d",&con[i][j]);
		if(!spe[i][j]&&!spe[j][i])
		spe[i][j]=spe[j][i]=++T;
	}
	for(int i=1;i<=n;i++)
	for(int j=2;j<n;j++)
	{
		add(spe[i][con[i][j-1]],spe[i][con[i][j]]);
		in[spe[i][con[i][j]]]++;
	}
	topsort();
	if(tmp<T)
	{
		printf("-1\n");
		return 0;
	}
	for(int i=1;i<=T;i++)
	ans=max(ans,dis[i]);
	printf("%d\n",ans);
	return 0;
}

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

int main(void)
{
	ios_base::sync_with_stdio(false);    
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n,k;
	cin>>n>>k;
	
	vector<int> dp(n,1e9);
	vector<int> h(n);
	
	for(int i=0;i<n;i++)
		cin>>h[i];
		
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	
	for(int i=2;i<n;i++)
	{
		for(int j=i-1;j>=max(0,i-k);j--)
		{
			dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
		}
	}
	
	cout<<dp[n-1]<<"\n";
	
	return 0;
}



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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


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


int main(){
  ll n,x;
  cin >> n >> x;
  VLL a(n);
  VLL b(n);

  rep(i,n){
    cin >> a[i];
    b[i] = a[i];
  }

  ll ans = 1e13;
  rep(i,n){
    ll cost = x * i;
    rep(k,n) b[k] = min(b[k],a[(k-i+n)%n]);
    rep(k,n) cost += b[k];
    ans = min(ans,cost);
  }
  cout << ans << endl;
  return 0;
}


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

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        int max = 0;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            int a = in.i();
            if (max < a) {
                max = a;
            }
            if (a < min) {
                min = a;
            }
        }
        System.out.println(max - min);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    int i() {
        int k = next() - '0';
        boolean minus = k == -3;
        int n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        int k = next() - '0';
        boolean minus = k == -3;
        long n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    char[] s(final int N) {
        char[] s = new char[N];
        for (int i = 0; i < N; i++) {
            s[i] = next();
        }
        next();
        return s;
    }

    public int read(char[] cbuf) {
        int i;
        char c;
        for (i = 0; (c = next()) != ' ' && c != '\n'; i++) cbuf[i] = c;
        return i;
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }
}


Measured memory_bytes: 32392
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

void solve(void){
	string S;
	cin >> S;
	string T = "CODEFESTIVAL2016";
	int ans = 0;
	rep(16, i) {
		ans += S[i] != T[i];
	}
	cout << ans << endl;
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int main(void){
int a[100][100];
int b[100];
int c[100];
int n,m;
scanf("%d %d",&n,&m);
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
scanf("%d",&a[i][j]);
}
}
for(int i=0;i<m;i++)scanf("%d",&b[i]);
for(int i=0;i<n;i++){
c[i]=0;
for(int j=0;j<m;j++){
c[i]=a[i][j]*b[j]+c[i];
}
printf("%d\n",c[i]);
}
}

Measured memory_bytes: 2748
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

struct mint {
	ll x;
	mint(ll x=0):x((x%MOD+MOD)%MOD){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
	if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += MOD-a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
	mint operator+(const mint a) const { return mint(*this) += a;}
	mint operator-(const mint a) const { return mint(*this) -= a;}
	mint operator*(const mint a) const { return mint(*this) *= a;}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}

	mint inv() const { return pow(MOD-2);}
	mint& operator/=(const mint a) { return *this *= a.inv();}
	mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint mpow(ll t, ll p) {
	if (p == 0) return 1;
	mint x = mpow(t, p/2);
	x *= x;
	if (p % 2 == 1) x *= t;
	return x;
}

int main() {
	int n;
	cin >> n;
	mint mx = mpow(10,n);
	mint sub1 = mpow(9,n);
	sub1 = mx - sub1;
	sub1 *= 2;
	mint sub2 = mpow(8,n);
	sub2 = mx - sub2;
	mint ans = sub1 - sub2;
	cout << ans << endl;
}

Measured memory_bytes: 3632