akhauriyash/Code-Regression huggingface dataset:
// you can use includes, for example:
#include <iostream>
#include <vector>
#include <algorithm>
#include <memory>
#include <unordered_map>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <sstream>
#include <set>
#include <cassert>
#include <map>

using namespace std;

int main(void) {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  std::vector<std::string> ss(n);
  for (auto& el : ss) {
    cin >> el;
  }

  for (char cur_c = 'a'; cur_c <= 'z'; cur_c++) {
    int mn = 10000;
    for (const auto& el : ss) {
      int cnt = 0;
      for (const auto& c : el) {
        if (c == cur_c) {
          cnt++;
        }
      }
      mn = min(mn, cnt);
    }
    for (int i = 0; i < mn; i++) {
      cout << cur_c;
    }
  }
  cout << endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
w = [int(input()) for _ in range(n)]
s = max(w)-1
w.append(10**13)
t = sum(w)

while s+1 < t:
	m = (s + t) // 2
	x = 0
	c = 0
	for i in range(n+1):
		c += w[i]
		if c > m:
			x += 1
			c = w[i]
		elif c == m:
			if i != n-1:
				x += 1
				c = 0
	if x > k:
		s = m
	else:
		t = m

print(t)


Measured memory_bytes: 9564
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<cstdio>
#include<algorithm>

using namespace std;

struct pool{
  int idx;
  int area;
};

void print_stack(stack<pool> s){

  printf("print stack\n");
  while(s.size() > 0){
    pool& p = s.top();
    printf("idx:%d area:%d\n", p.idx, p.area);
    s.pop();
  }
  printf("\n");
}

int main(){
  stack<int> S1;
  stack<pool> S2;
  char c;
  int sum = 0;

  for(int i = 0; cin >> c; i++){
//    fprintf(stderr, "%d\n",i);
    if(c == '\\'){
      S1.push(i);
    }else if(c== '/' && S1.size() > 0){
      int j = S1.top();
      S1.pop();
      sum += i - j;

      int tmp=0;
      if(S2.size() > 0){
        bool flag = false;
        while(S2.size()>0){
          pool& p = S2.top();
          if(p.idx > j){
            S2.pop();
            tmp += p.area;
            flag = true;
          }else{
            pool p2 = {j, tmp+i-j};
            S2.push(p2);
            flag = false;
            break;
          }
        }
        if(flag){
          pool p2 = {j, tmp+i-j};
          S2.push(p2);
        }
      }else{
        pool p2 = {j, i-j};
        S2.push(p2);
      }
//      print_stack(S2);
    }
  }

  printf("%d\n", sum);

  printf("%d", (int)S2.size());

  vector<int> v;

  while(S2.size() > 1){
    pool& p = S2.top();
//    printf("%d(%d) ", p.area, p.idx);
    v.push_back(p.area);
    S2.pop();
  }
  if(S2.size() == 1){
    pool& p = S2.top();
//    printf("%d(%d)\n", p.area, p.idx);
    v.push_back(p.area);
  }
  std::reverse(v.begin(), v.end());
  for(int x: v){
    printf(" %d",x);
  }
  printf("\n");
}



Measured memory_bytes: 3284
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e15;
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
  ll n;
  cin >> n;
  vector<vector<ll>> v(n);
  map<P, ll> ans;
  vector<P> tmp(n - 1);
  REP(i, n - 1) {
    ll a, b;
    cin >> a >> b;
    --a, --b;
    tmp[i] = P(a, b);
    v[a].push_back(b);
    v[b].push_back(a);
  }

  queue<P> que;
  que.push(P(0, 0));

  bool visited[n];
  REP(i, n) visited[i] = false;

  ll mx = 0;
  REP(i, n) {
    ll s = v[i].size();
    mx = max(mx, s);
  }

  while (!que.empty()) {
    ll p = que.front().first;
    ll num = que.front().second;
    que.pop();
    visited[p] = true;

    ll cnt = 1;
    for (auto x : v[p]) {
      if (visited[x]) continue;

      if (cnt == num) cnt++;

      ans[P(x, p)] = ans[P(p, x)] = cnt;

      que.push(P(x, cnt));
      cnt++;
    }
  }

  cout << mx << endl;
  REP(i, n - 1) { cout << ans[tmp[i]] << endl; }
  return 0;
}

Measured memory_bytes: 20736
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

using namespace std;

bool kaibun(string s){
    size_t len = s.length();
    for(int i = 0; i < len/2; i++){
        if(s[i] != s[len-i-1]) return false;
    }
    return true;
}

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

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug { 
    ($($a: expr),*) => { 
        println!(concat!($(stringify!($a)," = {:?}, "),*), $($a),*);
    } 
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

fn fx(x: u64) -> u64 {
    (((x+1)/2)%2) ^ if x % 2 == 0 {
        x
    } else {
        0
    }
}

fn solve() {
    let (a, b) = get!(u64, u64);
    
    println!("{}", fx(b) ^ fx(a) ^ a);
}


Measured memory_bytes: 8572
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n-1)]
c = list(map(int,input().split()))

edge_num = [0] * (n+1)
edge = {}
for i in range(1,n+1):
    edge[i] = set()

for a,b in ab:
    edge_num[a] += 1
    edge_num[b] += 1
    edge[a].add(b)
    edge[b].add(a)

edge_num2 = {}
for i in range(max(edge_num) + 1):
    edge_num2[i] = set()

for i in range(1,n+1):
    edge_num2[edge_num[i]].add(i)

c = sorted(c)
c_num = 0
ans = [0] * (n+1)
while(len(edge_num2[1]) > 0):
    tmp = edge_num2[1].pop()
    ans[tmp] = c[c_num]
    c_num += 1

    neigh = edge[tmp].pop()
    edge_num2[edge_num[neigh]].discard(neigh)
    edge_num[neigh] -= 1
    edge_num2[edge_num[neigh]].add(neigh)
    edge[neigh].discard(tmp)
    if(edge_num[neigh] == 0):
        ans[neigh] = c[c_num]
        break

print(sum(c) - max(c))
print(' '.join(map(str, ans[1:])))

Measured memory_bytes: 53592
#include<bits/stdc++.h>
using namespace std;
const int N = 300+ 10;
int arr[N];
const double eps = 1e-10;
char s[N], x[N], ans[N];
int cnt1[30], cnt2[30];
int cmp(char a, char b)
{
    return a>b;

}
int main()
{
    int path[N][N];
    memset(path, 0, sizeof(path));
    int n, m;
    cin>>n>>m;
    for(int i = 0; i<m; i++)
    {
        int u, v;
        scanf("%d%d", &u, &v);
        path[u][v] ++, path[v][u]++;
    }
    for(int i = 1; i<=n; i++)
    {
        int sum = 0;
        for(int j = 1; j<=n; j++)
            if(path[i][j])
            sum+=path[i][j];
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 640
// parameter "input" gets all data
function Main(input) {
   // the first line is assigned to input[0], the second line is assigned to input[1] similarly.
    input = input.split("\n");
    // convert string from integer using "parseInt"
    let tmp = input[0].split(' ')

   const [a,b,h,m]=tmp
   let hangle=  (30*Number(h)+30*((m/60).toFixed(15)))*Math.PI/180
   let mangle =  6*Number(m)*Math.PI/180
   let ax= Number(a)*Math.sin(hangle).toFixed(20)
   let ay= Number(a)*Math.cos(hangle).toFixed(20)

   let bx= Number(b)*Math.sin(mangle).toFixed(20)
   let by= Number(b)*Math.cos(mangle).toFixed(20)
   let cx=bx-ax
   let cy=by-ay
   let ans=cx*cx+cy*cy
   console.log(Math.sqrt(ans))

}
// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29500
/*
* @Author: _dp95
* @Date:   2020-04-03 05:37:13
*/
#include "bits/stdc++.h"
using namespace std ;

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end() 
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};

const int MAX = 2*1000*1000 + 10 ;
const ll INF = 1e18 ;
const int MOD = 1e9 + 7 ;

signed main( ){
  timesaver ;
  string s ;
  cin >> s ;
  cout << (((s[2]==s[3])and(s[4]==s[5]))?"Yes":"No") << nl ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

#define eps (1e-10)
struct Point{
    double x,y;
    Point(){}
    Point(double x,double y):x(x),y(y){}
    Point operator+(Point p) {return Point(x+p.x,y+p.y);}
    Point operator-(Point p) {return Point(x-p.x,y-p.y);}
    Point operator*(double k){return Point(x*k,y*k);}
    double norm(){return x*x+y*y;}
    double abs(){return sqrt(norm());}
    bool operator == (const Point &p) const{
    return fabs(x-p.x)<eps && fabs(y-p.y)<eps;
  }
  double dot(Point p){return x*p.x+y*p.y;}
  double det(Point p){return x*p.y-y*p.x;}
};
bool cmp_x(const Point& p,const Point& q){
  if(p.x!=q.x) return p.x<q.x;
  return p.y<q.y;
}
bool cmp_y(const Point& p,const Point& q){
  if(p.y!=q.y) return p.y<q.y;
  return p.x<q.x;
}
vector<Point> convex_hull(Point* ps,int n){
    sort(ps,ps+n,cmp_x);
    int k=0;
    vector<Point> qs(n*2);
    rep(i,n){
        while(k>1&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<0) --k;//<=:exclusion online
        qs[k++]=ps[i];
    }
    for(int i=n-2,t=k;i>=0;--i){
        while(k>t&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<0) --k;// <=
        qs[k++]=ps[i];
    }
    qs.resize(k-1);
    return qs;
}
double distance(Point p,Point q){
    return (p-q).abs();
}
//convex_diameter
int main(){
    int n;
    //vector<Point> qs=convex_hull(ps,n);
    cin>>n;
    double xi,yi;
    vector<Point> qs(n);
    rep(i,n){
        cin>>xi>>yi;
        qs[i]=Point(xi,yi);
    }
    if(n==2){
        cout<<fixed<<setprecision(12)<<distance(qs[0],qs[1])<<endl;
        return 0;
    }
    int i=0,j=0;
    rep(k,n){
        if(!cmp_x(qs[i],qs[k])) i=k;
        if(cmp_x(qs[j],qs[k])) j=k;
    }
    double res=0;
    int si=i,sj=j;
    while(i!=sj||j!=si){
        res=max(res,distance(qs[i],qs[j]));
        if((qs[(i+1)%n]-qs[i]).det(qs[(j+1)%n]-qs[j])<0){
            i=(i+1)%n;
        }
        else{
            j=(j+1)%n;
        }
    }
    cout<<fixed<<setprecision(12)<<res<<endl;
    return 0;
}


Measured memory_bytes: 4204
#include <bits/stdc++.h>
#include<string>
using namespace std;
typedef long long int ll;
#define mp make_pair
#define pb push_back

void solve(){
    int n,x,t;
    int count=0;
    cin>>n;
    cin>>x;
    cin>>t;
    while(n>0){
        n=n-x;
        count+=t;
      

    }
    cout<<count<<endl;
   
   }
       

    
    
int main() {
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    solve();
   
    
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
long long dp[3005][3005];
long long a[3005];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	int flag=((n&1)?1:-1);
	for(int i=0;i<n;i++) dp[i][i]=a[i]*flag;
	for(int i=1;i<n;i++,flag=-flag){
		for(int l=0;l+i<n;l++){
			int r=l+i;
			if(~flag){
				dp[l][r]=min(dp[l+1][r]-a[l],dp[l][r-1]-a[r]);
			}
			else{
				dp[l][r]=max(dp[l+1][r]+a[l],dp[l][r-1]+a[r]);
			}
		}
	}
	cout<<dp[0][n-1];
	return 0;
}

Measured memory_bytes: 70016
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();
		sc.close();

		double area = Math.PI * r * r;
		double circle = 2 * Math.PI * r;

		System.out.printf("%f %f", area, circle);
	}
}

Measured memory_bytes: 18908
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int a[100005];
int main(){
    std::ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min(b/a,c)<<endl;
}



Measured memory_bytes: 256
package main

import "fmt"

func main()  {
	var n, q int
	fmt.Scan(&n, &q)
	var s string
	t := make([]int, n)
	fmt.Scan(&s)
	for i:=1; i<n; i++ {
		t[i] = t[i-1]
		if s[i-1] == 'A' && s[i] == 'C' {
			t[i]++
		}
	}
	//fmt.Println(t)
	l, r := make([]int, q), make([]int, q)
	for i:=0; i<q; i++ {
		fmt.Scan(&l[i], &r[i])
	}
	for i:=0; i<q; i++ {
		fmt.Println(t[r[i]-1] - t[l[i]-1])
	}
}

Measured memory_bytes: 6144
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int maxn=100005;
struct tree
{
    int parent;
    vector<int>child;
    int depth;
};
tree node[maxn];
int n;
void init()
{
    for (int i=0;i<n;i++)
        node[i].depth=node[i].parent=-1;
}
int Find (int x)
{
    if(node[x].parent==-1)
        return node[x].depth=0;
    else if(node[x].depth!=-1)
        return node[x].depth;
    else
        return Find(node[x].parent)+1;
}
int main()
{
    scanf("%d",&n);
    init();
    for (int i=0;i<n;i++)
    {
        int x,num;
        scanf("%d%d",&x,&num);
        while (num--)
        {
            int y;
            scanf("%d",&y);
            node[y].parent=x;
            node[x].child.push_back(y);
        }
    }
    for (int i=0;i<n;i++)
    {
        printf("node %d: parent = %d, depth = %d, ",i,node[i].parent,node[i].depth=Find(i));
        if(node[i].parent==-1)
            printf("root, ");
        else if(!node[i].child.size())
            printf("leaf, ");
        else
            printf("internal node, ");
        printf("[");
        for (int j=0;j<node[i].child.size();j++)
        {
            printf("%d",node[i].child[j]);
            if(j<node[i].child.size()-1)
                printf(", ");
        }
        printf("]\n");
    }
    return 0;
}



Measured memory_bytes: 7828
#include<stdio.h>
#include<math.h>
int isprime();
int main()
{
  int a,b[10000],i,l,m=0;
  scanf("%d",&a);
  for(l=0;l<a;l++)
    {
      scanf("%d",&b[l]);
    }
  
  
  for(i=0;i<a;i++){
    if(isprime(b[i])==1)m++;
  } 
    printf("%d\n",m);
    
    return 0;
 }
  
  int isprime(x)
  {
    int i;
    if(x==2) return 1;
    
    else if(x<2||x%2==0) return 0;
    
    i=3;
    while(i<=sqrt(x)){
      if(x%i==0) return 0;
      i=i+2;
    }
    
    return 1  ;
} 

Measured memory_bytes: 632
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
 
typedef struct node{
    int p;
    int left;
    int right;
} Node;
 
int searchHight(int);
 
Node *node;
 
int main(){
     
    int n,i,id,depth,tmp,deg,sibling;
    int now;
    scanf("%d", &n);
 
    node = (int *)malloc(sizeof(Node)*n);
 
    for (i = 0; i < n; ++i){
        node[i].p = -1;
    }
 
    for (i = 0; i < n; i++){
        scanf("%d",&id);
        scanf("%d%d",&node[id].left,&node[id].right);
        node[node[id].left].p = id;
        node[node[id].right].p = id;
    }
 
    now = 0;
    while(1){
        if (node[now].left != -1 && node[now].right != -1)
        {
            break;
        } else if (node[now].left == -1)
        {
            now = node[now].right;
        } else {
            now = node[now].left;
        }
    }
 
    //Search
    for (i = 0; i < n; ++i){
         
        //sibling
        tmp = node[i].p;
        if (tmp == -1) sibling = -1;
        else if(node[tmp].left == i) sibling = node[tmp].right;
        else sibling = node[tmp].left;
 
        //depth
        depth = 0;
        while(tmp != -1){
            tmp = node[tmp].p;
            depth++;
        }
 
        //degree
        deg = 0;
        if (node[i].left != -1) deg++;
        if (node[i].right != -1) deg++;
 
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, "
            ,i,node[i].p,sibling,deg,depth,searchHight(i));
 
        if(node[i].p == -1) printf("root\n");
        else if(node[i].left == -1 && node[i].right == -1) printf("leaf\n");
        else printf("internal node\n");
    }
 
    return 0;
}
 
int searchHight(int index){
    int hLeft = 0;
    int hRight = 0;
 
    if (node[index].left != -1){
        hLeft = searchHight(node[index].left) +1;
    }
    if (node[index].right != -1){
        hRight = searchHight(node[index].right) +1;
    }
    if (hLeft < hRight) return hRight;
    else return hLeft;
}

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

int main(){
  int A,B,K;  cin >> A >> B >> K;
  int count = 0;
  for(int i = min(A,B);i >= 1;i--){
    if(A % i == 0 and B % i == 0)count++;
    if(count == K){
      cout << i << endl;
      break;
    }
  }

}

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

ll INF = 1e18L + 5;
ll dp[500][500];
 
ll sum(vector<int>& ar, int Left, int Right) {
    ll sum = 0;
    for(int i = Left; i <= Right; i++) {
        sum += ar[i];
    }
    return sum;
};
 
int main() {
	int n;
    cin>>n;
    vector<int> ar(n);
    
    for(int i=0; i<n; i++) cin>>ar[i];
    
    for(int i = n-1; i >= 0; i--) {
        for(int j = i; j < n ; j++) {
            if(i == j) {
                dp[i][j] = 0;
            }
            else {
                dp[i][j] = INF;
                ll s = sum(ar, i, j);
                for(int k = i; k <= j-1; k++) {
                    dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + s);
                }
            }
        }
    } 
    cout<<dp[0][n-1];
    return 0;
}


Measured memory_bytes: 1792
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).unwrap();
    word.trim().to_owned()
}

fn sort_hash(a: &(String, i64, usize), b: &(String, i64, usize)) -> std::cmp::Ordering {
    if a.0.gt(&b.0) {
        std::cmp::Ordering::Greater
    } else if a.0.eq(&b.0) {
        if a.1 > b.1 {
            std::cmp::Ordering::Less
        } else if a.1 == b.1 {
            std::cmp::Ordering::Equal
        } else {
            std::cmp::Ordering::Greater
        }
    } else {
        std::cmp::Ordering::Less
    }
}

fn main() {
    let n: usize = get_input().parse().unwrap();
    let mut rx: Vec<(String, i64, usize)> = Vec::new();

    for i in 0..n {
        let line = get_input();
        let mut split = line.split_whitespace();
        let s = split.next().unwrap().chars().collect();
        let p = split.next().unwrap().parse().unwrap();
        rx.push((s, p, i + 1));
    }

    rx.sort_by(|a, b| sort_hash(a, b));

    for r in rx {
        println!("{}", r.2);
    }
}

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

#define roop(i, n) for(int i = 0;i < n;i++)

int main(void){

    int k, s;
    cin >> k >> s;

    int ans = 0;

    for(int x = 0;x <= k;x++){
        for(int y = 0;y <= k;y++){
            if(0 <= s-x-y && s-x-y <= k) ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  string N;
  cin >> N;
  if(N[N.size()-1] == '0' || N[N.size()-1] == '1' || N[N.size()-1] == '6' || N[N.size()-1] == '8')cout << "pon" <<endl;
  else if(N[N.size()-1] ==  '3')cout << "bon" <<endl;
  else cout << "hon" <<endl;
}

Measured memory_bytes: 3588
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int H, W;
vector<string> A;
vector<vector<int>> cnt;
vector<int> dx = {1, 0, -1, 0};
vector<int> dy = {0, 1, 0, -1};
typedef pair<int, int> P;
queue<P> que;

void bfs() {
    while (!que.empty()) {
        auto now = que.front();
        que.pop();
        REP(mov, 4) {
            int nx = now.first + dx[mov];
            int ny = now.second + dy[mov];

            if (nx < 0 || H <= nx || ny < 0 || W <= ny) {
                continue;
            }

            if (cnt[nx][ny] == -1) {
                cnt[nx][ny] = cnt[now.first][now.second] + 1;
                que.push(P(nx, ny));
            }
        }
    }
}

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

    cin >> H >> W;
    A.resize(H);
    // '#'までの距離を初期化する。初期値は -1
    cnt.resize(H, vector<int>(W, -1));
    REP(i, H) cin >> A[i];

    // '#' のとき、距離を 0 にして、キューに入れる
    REP(i, H) {
        REP(j, W) {
            if (A[i][j] == '#') {
                cnt[i][j] = 0;
                que.push(P(i, j));
            }
        }
    }
    bfs();

    int ans = 0;
    REP(i, H) {
        REP(j, W) { chmax(ans, cnt[i][j]); }
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 13456
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d %d", &v[i].second, &v[i].first);
    }
    ll s = 0;
    sort(v.begin(),v.end());
    for (int i = 0; i < n; ++i) {
        s += v[i].second;
        if(s > v[i].first){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 1792
// AOJ 1529: Cheat Case
// 2019.2.21 bal4u

#include <stdio.h>
#include <stdlib.h>

#define gc() getchar()
int in()
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

char exp[1000], *bp;

int factor()
{
	int n = 0;
	while (*bp >= '0' && *bp <= '9') n = 10 * n + (*bp++ - '0');
	return n;
}

int term()
{
	int x, y;
	x = factor();
	while (1) {
		if (*bp != '*') break;
		bp++;
		y = factor();
		x *= y;
	}
	return x;
}

int expr()
{
	int x, y, op;
	x = term();
	while (1) {
		if (*bp == '+') op = 1;
		else if (*bp == '-') op = 0;
		else break;
		bp++;
		y = term();
		if (op) x += y; else x -= y;
	}
	return x;
}

char pat[13][5][3] = {
/*0*/ {{1,1,1},{1,0,1},{1,0,1},{1,0,1},{1,1,1}},
/*1*/ {{1,0,2},{1,0,2},{1,0,2},{1,0,2},{1,0,2}},
/*2*/ {{1,1,1},{0,0,1},{1,1,1},{1,0,0},{1,1,1}},
/*3*/ {{1,1,1},{0,0,1},{1,1,1},{0,0,1},{1,1,1}},
/*4*/ {{1,0,1},{1,0,1},{1,1,1},{0,0,1},{2,0,1}},
/*5*/ {{1,1,1},{1,0,0},{1,1,1},{0,0,1},{1,1,1}},
/*6*/ {{1,1,1},{1,0,0},{1,1,1},{1,0,1},{1,1,1}},
/*7*/ {{1,1,1},{0,0,1},{2,0,1},{2,0,1},{2,0,1}},
/*8*/ {{1,1,1},{1,0,1},{1,1,1},{1,0,1},{1,1,1}},
/*9*/ {{1,1,1},{1,0,1},{1,1,1},{0,0,1},{1,1,1}},
/*+*/ {{0,1,0},{1,1,1},{0,1,0}},
/*-*/ {{1,1,1}},
/*.*/ {{1,0,0}}
};

char a[210][210];

int match(int r0, int c0, int id, int h, int w)
{
	int r, c;
	for (r = 0; r < h; r++) for (c = 0; c < w; c++)
		if (pat[id][r][c] != 2 && a[r0 + r][c0 + c] != pat[id][r][c]) return 0;
	for (r = 0; r < h; r++) for (c = 0; c < w; c++)
		if (pat[id][r][c] == 1) a[r0 + r][c0 + c] = 0;
	return 1;
}

int main()
{
	int i, r, c, N, H, W;
	int t, x1, y1, x2, y2;

	N = in(), H = W = 0;
	for (i = 0; i < N; i++) {
		x1 = in(), y1 = in(), x2 = in(), y2 = in();
		if (x1 > W) W = x1;
		if (x2 > W) W = x2;
		if (y1 > H) H = y1;
		if (y2 > H) H = y2;
		if (x1 == x2) {
			if (y1 > y2) t = y1, y1 = y2, y2 = t;
			while (y1 <= y2) a[y1++][x1] = 1;
		}
		else {
			if (x1 > x2) t = x1, x1 = x2, x2 = t;
			while (x1 <= x2) a[y1][x1++] = 1;
		}
	}

	bp = exp;
	for (c = 0; c <= W; c++) for (r = 0; r <= H; r++) {
		if (a[r][c] == 0) continue;
		for (i = 0; i <= 9; i++) {
			if (match(r, c, i, 5, 3)) {
				*bp++ = i + '0';
				break;
			}
		}
		if (i > 9) {
			if (r > 0 && match(r-1, c, 10, 3, 3)) *bp++ = '+';
			else if (match(r, c, 11, 1, 3)) *bp++ = '-';
			else if (match(r, c, 12, 1, 1)) *bp++ = '*';
			else {
				printf("Panic!!!\n"); return -1;
			}
		}
	}
	*bp = 0, bp = exp;
	printf("%d\n", expr());
	return 0;
}


Measured memory_bytes: 2064
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define inl(a) cin >> a
#define prl(a) cout << a << " "
#define outl(a) cout << a << endl
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
typedef long long int ll;
#define N 200005
int main()
{
    int n,i,j,t,q;
    ll a,b,s;
    in(q);
    n=0;
    multiset<int> st;
    multiset<int> :: iterator itr;
    while(q--)
    {
        in(t);
        if(t==1)
        {
            in2(i,j);
            a=i,b=j,s=i,n++;
            st.insert(i);
            itr=st.find(i);
        }
        if(t==2)
            out(0);
        if(n==1)
            break;
    }
    while(q--)
    {
        in(t);
        if(t==1)
        {
            in2(i,j);
            b+=j,s+=i,n++;
            st.insert(i);
            if(n&1)
            {
                if(i<(*itr))
                    a+=i;
                else
                    itr++,a+=(*itr);
            }
            else
            {
                if(i<(*itr))
                    a-=(*itr),itr--,a+=i;
            }
        }
        else
        {
            i=(*itr);
            pr(i);
            if(n&1)
                outl(b+s+i-2*a);
            else
                outl(b+s-2*a);
        }
    }


}


Measured memory_bytes: 9600
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
typedef pair<pii,pair<int,string> > P;
int main(){
	int n;
	while(cin>>n,n){
		int t =n;
		priority_queue<P> data;
		//while(!data.empty())data.pop();
		while(t--){
			string str;
			cin>>str;
			int v,l,d;
			v = l = d= 0;
			for(int i =1;i < n;i++){
				int x;
				cin>>x;
				if(x==0){
					v++;
				}else if(x==1){
					l++;
				}else{
					d++;
				}
			}
			data.push(P(mp(v,-l),mp(t,str)));
		}
		while(!data.empty()){
			cout <<data.top().second.second<<endl;
			data.pop();
		}
	}
	return 0;
}

Measured memory_bytes: 1208
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), d = scanner.nextInt();
			System.out.println(IntStream.range(0, n).filter(i -> {
				int x = scanner.nextInt(), y = scanner.nextInt();
				return (Math.sqrt((double) x * x + (double) y * y) <= d);
			}).count());
		}
	}
}


Measured memory_bytes: 60304
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll INF = 1e18L+5;
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n,wt;
    cin>>n>>wt;

    vector<ll> v(n),w(n);

    for(int i=0 ; i<n ; i++)
        cin>>w[i]>>v[i];

    ll sum_v=0;
    for(auto i:v)
        sum_v+=i;

    vector<ll> dp(sum_v+1,INF);
    dp[0]=0;
// dp[i] = the min tot wei of item with tot val exactly i
    for(int i=0 ; i<n ; i++)
    {
        for(int j=sum_v - v[i] , k=sum_v ; j>=0 ; j-- , k-- )
        {
            dp[k] = min(dp[k] , dp[j] + w[i]);
            //for(auto i:dp)                cout<<i<<" ";            cout<<endl;
        }
    }
//for(auto i:dp)    cout<<i<<" ";

ll ans = 0;
    for(int i=0 ; i<=sum_v ; i++)
    {
        if(dp[i]<=wt)
            ans=max(ans,(ll)i);
    }
    cout<<ans;



}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

main() {
  int N, K; cin >> N >> K;
  vector<int> x(N), y(N);
  vector<P> p(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i];
    p[i] = {x[i], y[i]};
  }

  sort(x.begin(), x.end());
  sort(y.begin(), y.end());

  ll ans = 1LL * (x[N - 1] - x[0]) * (y[N - 1] - y[0]);
  for (int xi = 0; xi < N; xi++) {
    for (int xj = xi + 1; xj < N; xj++) {
      for (int yi = 0; yi < N; yi++) {
        for (int yj = yi + 1; yj < N; yj++) {
          int cnt = 0;
          ll lx = x[xi], rx = x[xj];
          ll ly = y[yi], uy = y[yj];
          for (int i = 0; i < N; i++) {
            if (lx <= p[i].first && p[i].first <= rx && ly <= p[i].second && p[i].second <= uy) cnt++;
          }
          if (cnt >= K) ans = min(ans, 1LL * (rx - lx) * (uy - ly));
        }
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int x=a*b; int y=c*d;
  int ans =x;
  if(x<y) ans=y;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).
*/

main :-
    get_number(A),
    get_number(B),
    X is max(max(A+A-1,B+B-1), A+B),
    writeln(X).


Measured memory_bytes: 7968
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int a,b,c,k,ans=0;
    cin>>a>>b>>c>>k;
    
     if(a<k)
     {
         k=k-a;
         ans+=a;
         k=k-b;
         if(k>0)
         {
             ans=ans-k;
         }
       
     }
     else{
         ans=k;
         }
  cout<<ans;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define REP(i, n) for(int i=0; i<n; i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const ll INF = 1LL << 60;
vector<vector<ll>> dp(100010, vector<ll>(3, 0));

int main() {
    int N;
    cin >> N;
    vector<vector<ll>> a(N, vector<ll>(3));
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> a[i][j];
        }
        
    }
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];
    for (int i = 1; i < N; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            for (int k = 0; k < 3; k++)
            {
                if(j!=k)chmax(dp[i][k], dp[i-1][j] + a[i][k]);
            }
            
        }
        
    }
    ll ans = 0;
    for (int i = 0; i < 3; i++)
    {
        chmax(ans, dp[N-1][i]);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 14088
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int n = sc.nextInt();
			int list[] = new int[n];
			for(int i = 0;i < list.length;i++){
				list[i] = sc.nextInt();
			}
			for(int j = list.length - 1;j >= 0;j--){
				System.out.print(list[j]);
				if(j!=0)
					System.out.print(" ");
			}
			System.out.println();
		}
	}
}



Measured memory_bytes: 26268
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265


void f(int n){
  int x[1000]={},y[1000]={};
  FOR(i,1,n){
    int b,c;
    cin>>b>>c;
    if(c==0){
      x[i]=x[b]-1;
      y[i]=y[b];
    }
    if(c==1){
      x[i]=x[b];
      y[i]=y[b]-1;
    }
    if(c==2){
      x[i]=x[b]+1;
      y[i]=y[b];
    }
    if(c==3){
      x[i]=x[b];
      y[i]=y[b]+1;
    }
  }
  sort(x,x+n);
  sort(y,y+n);
  
  cout<<x[n-1]-x[0]+1<<' ';
  cout<<y[n-1]-y[0]+1<<endl;
}



int main(){
  int n;
  while(1){
    cin>>n;
    if(n==0) break;
    f(n);
  }

}


Measured memory_bytes: 3088
#include <stdio.h>

int main(void)
{
    int x, a, b, c, d ;
    while (1) {
        scanf("%d%d", & a, & b) ;
        if ((c = a + b) == 0) {
            break ;
        }
        d = 0 ;
        for (x = 1 ; x < 5 ; x ++) {
            scanf("%d%d", & a, & b) ;
            if (a + b > c) {
                c = a + b;
                d = x ;
            }
        }
        printf("%c %d\n", 'A' + d, c) ;
    }
    return 0 ;
}



Measured memory_bytes: 1924
#include<stdio.h>
int main(void)
{
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	printf("%d\n",(a+b+c+d)/60);
	printf("%d\n",(a+b+c+d)%60);
	return 0;
}


Measured memory_bytes: 2080
#include<cstdio>
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a!=b&&b!=c&&c!=a) printf("3");
	else if(a==b&&b==c&&c==a) printf("1");
	else printf("2");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int r,g,b;
    cin >> r >> g >> b;
    int x = r*100+g*10+b;
    if(x%4){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

ll memo[110000];

ll roop(ll n){
    if(n==0) return 0;
    if(memo[n]!=-1) return memo[n];
    ll res=n;
    for(int pow6=1;pow6<=n;pow6*=6) res=min(res,roop(n-pow6)+1);
    for(int pow9=1;pow9<=n;pow9*=9) res=min(res,roop(n-pow9)+1);
    return memo[n]=res;
}

int main()
{
    ll n;
    cin >> n;
    rep(i,110000) memo[i]=-1;
    cout << roop(n) << endl;
    return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100010;
const double eps = 1e-6;

int n;
int a[N];
vector<int> d;

int main()
{
    cin >> n >> a[0];
    for(int i = 1; i <= n; i++) cin >> a[i];
    sort(a, a + 1 + n);

    int res = 0;
    for(int i = 1; i <= n; i++) res = __gcd(res, a[i] - a[i - 1]);

    cout << res << endl;
    return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  vint L(2*N);
  rep(i, 2*N) cin >> L[i];
  sort(all(L));
  int ans = 0;
  rep(i, N) {
    ans += min(L[2*i], L[2*i+1]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
using namespace std;

int main(int argc, char* argv[]){
        int A=0, B=0, C=0, D=0;

        cin >> A;
        cin >> B;
        cin >> C;
        cin >> D;

        int taka = A;
        int aoki = C;

        while(taka>0 && aoki>0){
                aoki -= B;
                if(aoki<=0) break;
                taka -= D;
                if(taka<=0) break;
        }
        if(taka>0){
                printf("Yes\n");
        }
        else{
                printf("No\n");
        }
        return 0;

}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

int N;
char S[1000][1000];
bool sym[1000][1000];

signed main(){
    cin >> N;
    REP(i, N) REP(j, N) cin >> S[i][j];
    REP(i, 2 * N) REP(j, 2 * N) S[i][j] = S[i % N][j % N];
    int ans = 0;
    REP(B, N){
        bool ok = true;
        REP(i, N){
            REP(j, N){
                if(S[i][B + j] != S[j][B + i]){
                    ok = false;
                    break;
                }
            }
            if(!ok) break;
        }
        if(ok) ans++;
    }
    PRINT(ans * N);
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(N * A, B) << endl;
}


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




int main(){
#ifdef debug
    freopen("a.in", "r", stdin);
#endif
    int a, b, c;
    cin>>a>>b>>c;
    bool flag=false;
    if(c>=a&&c<=b)
        flag=true;
    if(flag)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int l = scan.nextInt();
		int[][] A = new int[n][m];
		int[][] B = new int[m][l];
		long[][] C = new long[n][l];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				A[i][j] = scan.nextInt();
			}
		}
		for (int i = 0; i < m; i++) {
		for (int j = 0; j < l; j++) {
			B[i][j] = scan.nextInt();
		}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < l; j++) {
				for (int k = 0; k < m; k++) {
					C[i][j] += A[i][k] * B[k][j];
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < l; j++) {
				System.out.print(C[i][j]);
				if (j != l - 1) {
					System.out.print(" ");
				} else {
					System.out.println();
				}
			}
		}
	}

}

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

typedef struct
{
    char s[11];
    int p,n;
}data;

void swap(int i,int j,data d[])
{
    data tmp;
    tmp = d[i];
    d[i] = d[j];
    d[j] = tmp;
}

void sorts(data d[],int n)
{
    for (int i = 0; i < n - 1; i++)
    {
        for (int j = n - 1; j >= i + 1; j--)
        {
            if (strcmp(d[j - 1].s,d[j].s) > 0)
            {
                swap(j,j - 1,d);
            }
        }
        
    }
    
    return;
}

void sortp(data d[], int n)
{
    for (int i = 0; i < n - 1; i++)
    {
        for (int j = n - 1; j >= i + 1; j--)
        {
            if (d[j].p > d[j - 1].p)
            {
                swap(j,j - 1,d);
            }
        }
        
    }
}

void sort(data d[],int n)
{
    sortp(d,n);
    sorts(d,n);
    return;
}


int main()
{
    int n;
    data d[100];

    scanf("%d",&n);
    for (int i = 0; i < n; i++)
    {
        scanf("%s %d",d[i].s,&d[i].p);
        d[i].n = i + 1;
    }

    sort(d,n);
    for (int i = 0; i < n; i++)
    {
        //printf("%s %d %d\n",d[i].s,d[i].p,d[i].n);
      	printf("%d\n",d[i].n);
    }
    
}

Measured memory_bytes: 128
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<cmath>
#include<cstring>
#include<climits>
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 21) + 1], *p1 = buf, *p2 = buf;
inline int read() {
	bool f=0;int x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c==EOF)exit(0);if(c=='-')f=1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return !f?x:-x;
}
#define MAXN 100000
#define INF 0x3f3f3f3f
#define Mod (int)(1e9+7)
struct Matrix{
	#define MAXC 4
	int r,c;
	LL m[MAXC+5][MAXC+5];
	void Init(int R,int C){
		r=R,c=C;
		for(int i=0;i<r;i++)
			for(int j=0;j<c;j++)
				m[i][j]=0;
		return ;
	}
	friend Matrix operator * (Matrix A,Matrix B){
		Matrix C;C.Init(A.r,B.c);
		for(int i=0;i<A.r;i++)
			for(int j=0;j<B.c;j++)
				for(int k=0;k<A.c;k++)
					C.m[i][j]=(C.m[i][j]+A.m[i][k]*B.m[k][j])%Mod;
		return C;
	}
	void Print(){
		puts("");
		for(int i=0;i<r;i++,puts(""))
			for(int j=0;j<c;j++)
				printf("%lld ",m[i][j]);
		puts("");
		return ;
	}
};
Matrix Pow(Matrix x,int y){
	Matrix ret;ret.Init(x.r,x.c);
	for(int i=0;i<ret.r;i++)
		ret.m[i][i]=1;
	while(y){
		if(y&1) ret=ret*x;
		x=x*x,y>>=1;
	}
	return ret;
}
Matrix A,B,C;
void Init(){
	A.Init(1,3),A.m[0][0]=1,A.m[0][1]=2,A.m[0][2]=1;
	B.Init(3,3);
	B.m[0][0]=1,B.m[0][1]=2,B.m[0][2]=1,
	B.m[1][0]=0,B.m[1][1]=1,B.m[1][2]=1,
	B.m[2][0]=1,B.m[2][1]=2,B.m[2][2]=2;
	C.Init(3,3);
	C.m[0][0]=1,C.m[0][1]=2,C.m[0][2]=1,
	C.m[1][0]=0,C.m[1][1]=1,C.m[1][2]=1,
	C.m[2][0]=0,C.m[2][1]=0,C.m[2][2]=1;
	return ;
}
int main(){
	int n=read(),m=read();
	Init();
	int lst=1;
	for(int i=1;i<=m;i++){
		int x=read();
		A=A*Pow(B,x-lst);
		A=A*C;
		lst=x+1;
	}
	A=A*Pow(B,n-lst);
	printf("%lld\n",A.m[0][2]);
	return 0;
}
//

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;


int main() {
  int n; cin >> n; n-=1;
  vector<int> a(200000);
  vector<int> b(200000);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  for(int i = 0; i < n; i++){
    b[a[i]-1]++;
  }
  for (int i = 0; i <= n; i++){
    cout << b[i] << endl;
  }
}

Measured memory_bytes: 4408
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    bool can = false;
    for(int i = 1; i <= 9; i++) {
        for(int j = 1; j <= 9; j++) {
            can |= i * j == n;
        }
    }
    cout << (can ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256