akhauriyash/Code-Regression huggingface dataset:
import java.util.*;


public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();
    int add = 0;
    int i,j;
    if(n - k > 0){
      for(i = 0;i < k;i++){
        add = add + x;
      }
    }
    else{
      for(i = 0;i < n;i++){
        add = add + x;
      }
    }
    for(j = 0;j < n-k;j++){
      add = add + y;
    }
    System.out.println(add);
  }
}


Measured memory_bytes: 21204
#include<stdio.h>

int main(void){
	int i,j,a[100]={},b[100]={},A[100]={},B[100]={},C[100]={},x,y;
	x=0;
	y=0;
	for(i=0;i<100;i++){
	scanf("%d %d",&a[i],&b[i]);
		A[i]=a[i];
		B[i]=b[i];
	}
	for(i=0;i<100;i++){
		if(a[i] == 0 && b[i] == 0){
		y=i;
		break;
		}
		if(a[i] < b[i]){
	x=a[i];
	a[i]=b[i];
	b[i]=x;
	}
	}
	i=0;
	while(1){
		if(i==y){
		break;
		}
	while(1){
		if(i==y){
		break;
		}
		a[i]=a[i]%b[i];
		x=a[i];
		a[i]=b[i];
		b[i]=x;
		if(x == 0){
			C[i]=a[i];
			i++;
		}
		}
		}
		for(i=0;i<y;i++){
			printf("%d %d\n",C[i],B[i]/C[i]*A[i]);
		}
return 0;
}

Measured memory_bytes: 596
n = int(input())
b_list = list(map(int, input().split()))

def main(n, b_list):
    b_list.append(b_list[-1])
    result = b_list[0] + b_list[-1]
    for i in range(n-2):
        result += min(b_list[i], b_list[i+1])
    return result

print(main(n, b_list))

Measured memory_bytes: 3060
use std::io;

fn next_int() -> i64 {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

fn next_vec() -> Vec<i64> {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace().map(|n| n.parse().unwrap()).collect()
}

fn main() {
    let n = next_int();
    let a = next_vec();

    let mut cnt = 0;

    for i in 0..n {
        let idx = i as usize;
        let idx2 = a[idx] as usize;
        cnt += if a[idx2-1] == i + 1 {1} else {0};
    }

    println!("{:?}", cnt/2);
}


Measured memory_bytes: 6396
#include <stdio.h>
#include <string.h>
int h,w,k,len,len2;
char s[10][10];
int a[10],b[10],r[10],c[10],tot;
void dfs2(int step)
{
    if(step==len2+1)
    {
        for(int j=1; j<=w; j++)
            c[j]=0;
        for(int j=1; j<step; j++)
            c[b[j]]=1;
        int cnt=0;
        for(int i=1; i<=h; i++)
            for(int j=1; j<=w; j++)
            {
                if(r[i]==0&&c[j]==0&&s[i][j]=='#')
                    cnt++;
            }
        if(cnt==k)
            tot++;
        return;
    }
    for(int i=b[step-1]+1; i<=w; i++)
    {
        b[step]=i;
        dfs2(step+1);
    }
}
void dfs1(int step)
{
    if(step==len+1)
    {
        for(int  j=1; j<=h; j++)
            r[j]=0;
        for(int j=1; j<step; j++)
            r[a[j]]=1;
        for(len2=0; len2<=w; len2++)
            dfs2(1);
        return ;
    }
    for(int i=a[step-1]+1; i<=h; i++)
    {
        a[step]=i;
        dfs1(step+1);
    }
}
int main()
{
    scanf("%d%d%d",&h,&w,&k);
    for(int i=1; i<=h; i++)
        scanf("%s",s[i]+1);
    tot=0;
    for(len=0; len<=h; len++)
        dfs1(1);
    printf("%d\n",tot);
    return 0;
}


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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define REP64(i, s,  n) for(int64 i = s;i < (n);i++)
#define INF 999999999
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

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 dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

//---------------------------------------------------------------
//---------------------------------------------------------------

int N, H, W;

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

	cin >> N;
	cin >> H;
	cin >> W;

	cout << ( (N - H + 1) * (N - W + 1) ) << endl;
		
	return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
int main(void) {
    int n;
    cin >> n;
    int a[n];
    REP(i,n) {
        cin >> a[i];
    }

    int count=0;
    bool p=false;
    bool up;
    if(a[0]<a[1]) {
        up=true;
    } else if(a[0]>a[1]) {
        up=false;
    } else {
        p=true;
    }
    for(int i=1;i<n-1;i++) {
        if(p) {
            if(a[i]<a[i+1]) {
                up = true;
                p = false;
            } else if(a[i]>a[i+1]){
                up = false;
                p = false;
            }
        } else {
            if(up && a[i]>a[i+1] || !up && a[i] < a[i+1]) {
                count++;
                p = true;
            }
        }
    }

    cout << count+1 << endl;
}


Measured memory_bytes: 640
n, k = map(int, input().split())
p = [0] + list(map(int, input().split()))
c = [0] + list(map(int, input().split()))

g = [v for v in range(n + 1)]
s = [0] * (n + 1)
r = [0] * (n + 1)
seen = set()
for i in range(1, n + 1):
    if i in seen:
        s[i] = s[g[i]]
        r[i] = r[g[i]]
        continue
    ni = i
    sm = 0
    cnt = 0
    while True:
        ni = p[ni]
        sm += c[ni]
        cnt += 1
        g[ni] = i
        seen.add(ni)
        if ni == i:
            break
    s[i] = sm
    r[i] = cnt

ans = -(10 ** 9 + 1)
for i in range(1, n + 1):
    ni = i
    sm = 0
    cnt = 0
    while True:
        ni = p[ni]
        sm += c[ni]
        cnt += 1
        ans = max(ans, sm, sm + (k - cnt) // r[i] * s[i])
        if ni == i or cnt == k:
            break
print(ans)


Measured memory_bytes: 74436
#include <iostream>
#include <math.h>
#define N 10000
using namespace std;

bool is_prime(int x){
    if (x < 1) {
        return false;
    } else {
        int sq = (int)(sqrt(x));
        for (int i = 2; i <= sq; i++){
            if (x%i == 0) return false;
        }
        return true;
    }
}

int main(int argc, char const *argv[]) {
    int n;
    int x;
    cin >> n;
    int cnt = 0;
    for (int i = 0; i < n; i++){
        cin >> x;
        if (is_prime(x)){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
int main() {
    ll d, t, s;
    ll ans = 0;
    cin >> d >> t >> s;
    if (s*t >= d) {
        cout<< "Yes" << endl;
    }else {
        cout<< "No" << endl;
    }
    
    //cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
char s[100010];
bool ok[100010];
int main() {
  scanf("%s", s);
  int n = strlen(s);
  ok[0] = true;
  for (int i = 0; i <= n; i++) {
    if (!ok[i]) continue;
    if (strncmp(s + i, "dream", 5) == 0) ok[i + 5] = true;
    if (strncmp(s + i, "erase", 5) == 0) ok[i + 5] = true;
    if (strncmp(s + i, "eraser", 6) == 0) ok[i + 6] = true;
    if (strncmp(s + i, "dreamer", 7) == 0) ok[i + 7] = true;
  }
  printf(ok[n] ? "YES\n" : "NO\n");
  return 0;
}


Measured memory_bytes: 512
import java.util.*;

/**
 * @author mix
 */
public class Main {

    public static void main(String[] args) {
        // TODO code application logic here
        Scanner s1 = new Scanner(System.in);
        int N = s1.nextInt();
        int L = s1.nextInt();
        String[] stringArray = new String[N];
        for (int i = 0; i < N; i++) {
            stringArray[i] = s1.next();
        }
        Arrays.sort(stringArray);
        for (String s : stringArray) {
            System.out.print(s);
        }
        System.out.println("");
    }

}


Measured memory_bytes: 23380
#include<map>
#include<set>
#include<list>
#include<ctime>
#include<cmath>
#include<deque>
#include<queue>
#include<stack>
#include<string>
#include<vector>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define rep(i,s,t) for(register int i=s;i<=t;++i)
#define _rep(i,s,t) for(register int i=s;i>=t;--i)
#define Rep(i,s,t) for(register int i=s;i<t;++i)
#define go(x) for(register int e=las[x];e;e=nxt[e])
#define re register
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define insert is
#define erase es
#define pii pair<int,int>
#define ms(f,x) memset(f,x,sizeof f)
#define mc(f,x) memcpy(f,x,sizeof f)
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
#define gi(x) read(x)
#define gii(x,y) read(x),read(y)
#define giii(x,y,z) read(x),read(y),read(z)
namespace IO{
    #define gc getchar()
    #define pc(x) putchar(x)
    template<typename T>inline void read(T &x){
        x=0;int f=1;char ch=gc;while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=gc;}
        while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=gc;x*=f;return;
    }
    template<typename T>inline void write(T x=0){
        T wr[51];wr[0]=0;if(x<0)pc('-'),x=-x;if(!x)pc(48);
        while(x)wr[++wr[0]]=x%10,x/=10;while(wr[0])pc(48+wr[wr[0]--]);return;
    }
}
using IO::read;
using IO::write;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
const int N=1e6+11;
int n,m,x,y,ans;
int a[711][711];
bool vis[711];
int A,B,tot,sum;
int nxt[N],las[N],to[N],col[N];
int t[5];
inline void add(int x,int y){
	nxt[++tot]=las[x];
	las[x]=tot;to[tot]=y;
}
inline void dfs(int x,int c){
	col[x]=c;
	++t[c];
	for(re int e=las[x];e;e=nxt[e]){
		if(col[to[e]]==0){
			dfs(to[e],c^1);
			continue;
		}
		if(col[to[e]]!=c^1){
			puts("-1");
			exit(0);
		}
	}	
}
struct node{
	int x,y;
}p[N];
int dp[711][711];
int main(){
	gii(n,m);
	rep(i,1,m){
		gii(x,y);
		a[x][y]=a[y][x]=1;
	}
	rep(i,1,n)
		rep(j,1,n)
			if(i!=j)
				if(!a[i][j])
					add(i,j);
	tot=0;
	dp[0][0]=1;
	rep(i,1,n)
		if(col[i]==0){
			t[2]=t[3]=0;
			dfs(i,2);
			++tot;
			//printf("%d %d %d\n",tot,t[2],t[3]);
			rep(j,0,n){
				if(t[2]<=j)
					dp[tot][j]|=dp[tot-1][j-t[2]];
				if(t[3]<=j)
					dp[tot][j]|=dp[tot-1][j-t[3]];
			}
			//rep(j,0,n)
			//	printf("%d ",dp[tot][j]);puts("");
		}
	_rep(i,n/2,0)
		if(dp[tot][i]){
			printf("%d\n",i*(i-1)/2+(n-i)*(n-i-1)/2);
			return 0;
		}
	return 0;
}

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

int main(void){
    ll x, k, d;
    cin >> x >> k >> d;
    if(x < 0) x *= -1;
    ll xpd = (x + d - 1) / d;
    if(xpd <= k){
        ll xd = x - xpd * d, kd = k - xpd;
        if(kd & 1) cout << abs(xd + d) << endl;
        else cout << abs(xd) << endl;
    }
    else cout << abs(x - k * d) << endl;
    return 0;
}

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

int main() {
	string S,T;cin >> S>>T;
	int length = S.length();
	char back;
	bool ans = 0;
	for (int i = 0;i < length;i++) {
		if (S == T) {
			ans = 1;
			break;
		}
		back = S[length-1];
		S = back + S;
		S.pop_back();
	}
	if (ans)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>

#define MAX 2000001

static int H;
static int A[MAX];

static void maxHeapify(int i)
{
    int left = 2 * i;
    int right = 2 * i + 1;
    int largest;
    
    if (left <= H && A[left] > A[i]) {
        largest = left;
    } else {
        largest = i;
    }
    
    if (right <= H && A[right] > A[largest]) {
        largest = right;
    }
    
    if (largest != i) {
        int tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        maxHeapify(largest);
    }
}

static void increaseKey(int i, int key)
{
    A[i] = key;
    while (i > 1 && A[i / 2] < A[i]) {
        int tmp = A[i / 2];
        A[i / 2] = A[i];
        A[i] = tmp;
        i /= 2;
    }
}

static void insert(int key)
{
    H++;
    A[H] = INT_MIN;
    increaseKey(H, key);
}

static int extract()
{
    int max;

    if (H < 1) {
        max = INT_MIN;
    } else {
        max = A[1];
        A[1] = A[H--];
        maxHeapify(1);
    }

    return max;
}

int main()
{
    int key;
    char command[10];

    for (;;) {
        scanf("%s", command);
        if (command[0] == 'e' && command[1] == 'n') {
            break;
        } else if (command[0] == 'i') {
            scanf("%d", &key);
            insert(key);
        } else {
            printf("%d\n", extract());
        }
    }

    return 0;
}


Measured memory_bytes: 5600
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	ll n, k;
	cin >> n >> k;
	cout << min(n % k, abs(n % k - k)) << endl;
	return 0;
}


Measured memory_bytes: 256
/*
 * ITP1_5A.c
 *
 *  Created on: 2016/05/28
 *      Author: TakaakiShogaki
 */

#include<stdio.h>

int main(){
	int H,W,i,j;

	while(1){
		scanf("%d %d",&H,&W);
		if(H==0 &&W==0)
			break;
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
return 0;
}

Measured memory_bytes: 572
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main(){
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    if(A-B>=C){
        printf("0\n");
    }
    else{
        C=C-(A-B);
        printf("%d\n",C);
    }
    return 0;
}

Measured memory_bytes: 128
/* ***********************************************
Author        :axp
Created Time  :2016/9/24 20:12:21
TASK		  :C.cpp
LANG          :C++
************************************************ */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;

typedef long long ll;
const int inf = 1<<30;
const int md = 1e9+7;
const int N = 1e6+10;
const int M = 10;

ll p26[M];
int n;
int len;
int T;
string s;
int lst;
int ar[N];

void work()
{
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='a')continue;
		int t='z'-s[i]+1;
		if(n>=t)
		{
			s[i]='a';
			n-=t;
		}
	}
	n%=26;
	s[s.size()-1]+=n;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    cin>>s>>n;
	work();
	cout<<s<<endl;
	return 0;
}


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

using namespace std;

void next(pair<int, int>& curr, int W) {
    int i = curr.first;
    int j = curr.second;
    if (i % 2 == 0) {
        if (j == W - 1) {
            curr.first = i + 1;
            curr.second = j;
        }
        else {
            curr.first = i;
            curr.second = j + 1;
        }
    }
    else {
        if (j == 0) {
            curr.first = i + 1;
            curr.second = j;
        }
        else {
            curr.first = i;
            curr.second = j - 1;
        }
    }
}

void Main() {
    int H, W;
    cin >> H >> W;
    int N;
    cin >> N;
    vector<pair<int, int> > a(N, make_pair(0, 0));
    for (int i = 0; i < N; ++i) {
        a[i].first = i + 1;
        cin >> a[i].second;
    }

    vector<vector<int> > ans(H, vector<int>(W, 0));
    pair<int, int> curr = make_pair(-1, 0);
    for (int i = 0; i < N; ++i) {
        int color = a[i].first;
        int nc = a[i].second;
        for (int j = 0; j < nc; ++j) {
            next(curr, W);
            ans[curr.first][curr.second] = color;
        }
    }

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (j > 0) {
                cout << " ";
            }
            cout << ans[i][j];
        }
        cout << endl;
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3672
'use strict'
function Main(input) {

  const tmp = input.split("\n");
  let Arr = tmp[0].split(" ").map(Number);

  // console.log({ Arr });
  let CountCoin = 0;
  if (Arr[0] === Arr[1]) {
    CountCoin = Arr[0] + Arr[1];
  } else if (Arr[0] < Arr[1]) {
    CountCoin = Arr[1] + Arr[1] - 1;
  } else if (Arr[0] > Arr[1]) {
    CountCoin = Arr[0] + Arr[0] - 1;
  }

  console.log(CountCoin);


}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include<iostream>

using namespace std;

int count[26];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	char ch;
	while(cin.get(ch)) {
		if('A'<=ch&&ch<='Z') ++count[ch-'A'];
		else if('a'<=ch&&ch<='z') ++count[ch-'a'];
	}
	for(int i=0; i<26; ++i) {
		cout<<(char)(i+'a')<<" : "<<count[i]<<'\n';
	}
	return 0;
}



Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define at(x,i) get<i>(x);
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
void solve(int v,const vector<vector<int>> &G,vector<bool> &seen,vector<int> &cost){
    seen[v]=true;
    for(auto nv:G[v]){
        if(seen[nv])continue;
        cost[nv]+=cost[v];
        solve(nv,G,seen,cost);
    }
}
int main(){
    int N,Q;cin >> N >>Q;
    vector<vector<int>> G(N);
    for(int i=0;i<N-1;i++){
        int a,b;cin >> a >>b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> cost(N,0);
    for(int i=0;i<Q;i++){
        int a,b;cin>>a>>b;
        a--;
        cost[a]+=b;
    }
    vector<bool> seen(N,false);
    solve(0,G,seen,cost);
    for(int i=0;i<N;i++){
        if(i)cout << " ";
        cout << cost[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 29696
#include<stdio.h>
#define MAX 250

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

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

    scanf("%d", &H);
    for (i = 1; i < H+1; i++) scanf("%d", &A[i]);
    
    for (i=1; i < H+1; i++) {
	printf("node %d: key = %d, ", i, A[i]);
	if (parent(i) >= 1) printf("parent key = %d, ", A[parent(i)]);
	if (left(i) <= H) printf("left key = %d, ", A[left(i)]);
	if (right(i) <= H) printf("right key = %d, ", A[right(i)]);
	printf("\n");
    }
    return 0;
}

Measured memory_bytes: 600
//   __                    .__              ________ .________ ________   ______  
//  |  | __  ____    ______|  |__   __ __  /  _____/ |   ____//   __   \ /  __  \ 
//  |  |/ /_/ __ \  /  ___/|  |  \ |  |  \/   __  \  |____  \ \____    / >      < 
//  |    < \  ___/  \___ \ |   Y  \|  |  /\  |__\  \ /       \   /    / /   --   \
//  |__|_ \ \___  >/____  >|___|  /|____/  \_____  //______  /  /____/  \______  /
//       \/     \/      \/      \/               \/        \/                  \/ 

#include<bits/stdc++.h>
#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

ii a[200000];

int n;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i].fi;
		a[i].se = i;
	}
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++)
		cout<<a[i].se<<" ";
	return 0;
}


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

const int INF = 0x3f3f3f3f, MAX_N =  2e5+10;
int N;
int P[MAX_N];
int dp[MAX_N];

void solve()
{
	int ans = 0;
	for(int i=0;i<N;++i){
		dp[P[i]] = max(dp[P[i]], dp[P[i]-1]+1);
		ans =  max(ans, dp[P[i]]);
	}
	cout << N-ans << '\n';
}

int main()
{
	cin >> N;
	for(int i=0;i<N;++i) cin >> P[i];
	solve();
	return 0;
}

Measured memory_bytes: 5168
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  if (A + B < 2 * C) {
    cout << X * A + Y * B << endl;
  } else {
    ll comb_cnt_min = min(X, Y);
    ll comb_cnt_max = max(X, Y);
    X = X - comb_cnt_min;
    Y = Y - comb_cnt_min;
    cout << min(X * A + Y * B + 2 * C * comb_cnt_min, 2 * comb_cnt_max * C)
         << endl;
  }
  return 0;
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

int main() {
    READ(0);
    int n;
    cin >> n;
    vvi a(3, vi(n));
    FOR(j, 3) {
        FOR(i, n) cin >> a[j][i];
    }
    int ant=-10;
    int sat=0;
    FOR(i,n){
        sat += a[1][a[0][i]-1];
        if (a[0][i]==ant+1) sat += a[2][ant-1];
        ant=a[0][i];
    }
    cout << sat;

    return 0;
}



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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

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

    for(int i = 1; i <= 9; i++)
    {
        for(int j = i; j <= 9; j++)
        {
            if(i * j == n)
            {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";

    return 0;
}


Measured memory_bytes: 256
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define cps CLOCKS_PER_SEC
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
#define MOD 1000000007
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
int power(int x,int y){ int res = 1; while(y>0){   if(y&1) res = (res*x)%MOD;
        y >>= 1; x = (x*x)%MOD; } return res; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// struct chash { int operator()(int x) const { return x ^ RANDOM; }};
// cc_hash_table<int, int, hash<int>> cnt;

bool check(int mid,int x,int y){
    int ret = 0;
    for(int i=max(mid/2-1,1LL);i<=min(mid/2+1,mid);i++){
        int a = i,b = mid-i+1;
        if(a >= x) a++;
        if(b >= y) b++;
        ret = max(ret,a*b);
    }
    return ret < x*y;
}

void solve(){
    int q; cin>>q;

    while(q--){
        int x,y; cin>>x>>y;

        int s = 1,e = 3e9;
        int ans = 0;

        while(s <= e){
            int mid = (s+e)>>1;
            if(check(mid,x,y)) ans = mid,s = mid+1;
            else e = mid-1;
        }

        cout<<ans<<endl;
    }
}
 
signed main(){

    FastRead; 


    int t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,d,ans;
vector<int> x[21];
bool g(int a)
{
	for(int i=0;i*i<=a;i++)
	if(i*i==a)
	return true;
	return false;
}
int main()
{
	cin >>n>>d;
	for(int i=0;i<n;i++)
	for(int j=0;j<d;j++)
	{
		int k;
		cin >>k;
		x[i].push_back(k);
	}
	for(int i=0;i<n;i++)
	for(int j=i+1;j<n;j++)
	{
		int cnt=0;
		for(int l=0;l<d;l++)
		{
			cnt+=(abs(x[i][l]-x[j][l]))*(abs(x[i][l]-x[j][l]));
		}
		if(g(cnt))
		{
		    ans++;
//			puts("Y");
		}
		else
		{
//			puts("N");
		}
	}
	cout <<ans<<endl;
	return 0;
}

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

int main() {
	long n;
	long total = 0;
	cin >> n;
	vector<long> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
		total += a.at(i);
	}
	sort(a.begin(), a.end());
	cout << a.at(0) << " " << a.at(n - 1) << " " << total << endl;
}


Measured memory_bytes: 3244
S = input()
prev = S[0]
S = S[1:]
ans = 1
while len(S)>0:
    i = 1
    while True:
        if prev == S[:i] and len(S) > 1:
            i += 1
        else:
            break
    if prev != S[:i]:
        ans += 1
        prev = S[:i]
    S = S[i:]
print(ans)

Measured memory_bytes: 3500
#include<iostream>
using namespace std;
int isPrime[10001],t[10001],ts;
int n,sum,cnt,a,b;
void prime(){
  for(int i=0;i<10001;i++)isPrime[i]=1;
  isPrime[0]=isPrime[1]=0;
  for(int i=4;i<10001;i+=2)isPrime[i]=0;
  for(int i=3;i*i<=10001;i++){
    if(isPrime[i]){
      for(int j=i+i;j<10001;j+=i)isPrime[j]=0;
    }
  }
  t[0]=2;
  ts=1;
  for(int i=3;i<10001;i+=2)if(isPrime[i])t[ts++]=i;
}
int main(){
  prime();
  while(cin>>n&&n){
    sum=0;a=0;cnt=0;
    for(int i=0;i<ts;i++){
     
      sum+=t[i];
      // cout<<t[i]<<' '<<sum<<endl;
      while(sum>=n){
	if(sum==n)cnt++;
	sum-=t[a];
	//	cout<<t[a]<<' '<<sum<<endl;
	a++;
      }
    }//for i
    cout<<cnt<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
//#include <boost/multiprecision/cpp_int.hpp>

#define BIT(a) (1 << (a))
#define EPS (1e-10)

using namespace std;
//using namespace boost::multiprecision;

const long long MOD = 1000000007;
const int COUNTER_CLOCKWISE = 1;
const int CLOCKWISE = -1;
const int ONLINE_BACK = 2;
const int ONLINE_FRONT = -2;
const int ON_SEGMENT = 0;

class Point{
    public:
    double x, y;

    Point(double x = 0, double y = 0): 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 a){return Point(a * x, a * y);}
    Point operator/(double a){return Point(x / a, y / a);}

    bool operator < (const Point &p) const {
        return y != p.y ? y < p.y : x < p.x;
    }

    double norm(){return x * x + y * y;}
};
typedef Point Vector;
typedef vector<Vector> Polygon;

double cross(Vector a, Vector b){
    return a.x*b.y - a.y*b.x;
}

double dot(Vector a, Vector b){
    return a.x * b.x + a.y * b.y;
}

int ccw(Point p0, Point p1, Point p2){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if (cross(a, b) > EPS)return COUNTER_CLOCKWISE;
    if (cross(a, b) > -EPS)return CLOCKWISE;
    if (dot(a, b) < -EPS)return ONLINE_BACK;
    if (a.norm() < b.norm())return ONLINE_FRONT;

    return ON_SEGMENT;
}

Polygon andrewScan(Polygon s){
    Polygon u, l;
    if (s.size() < 3) return s;
    sort(s.begin(), s.end());
    u.push_back(s[0]);
    u.push_back(s[1]);
    l.push_back(s[s.size()-1]);
    l.push_back(s[s.size()-2]);
    
    for (size_t i = 2; i < s.size(); i++){
        for (size_t n = u.size(); n >= 2 && ccw(u[n-2], u[n-1], s[i]) == COUNTER_CLOCKWISE; n--){
            u.pop_back();
        }
        u.push_back(s[i]);
    }

    for (int i = (int)s.size() - 3; i >= 0; i--){
        for (size_t n = l.size(); n >= 2 && ccw(l[n-2], l[n-1], s[i]) == COUNTER_CLOCKWISE; n--){
            l.pop_back();
        }
        l.push_back(s[i]);
    }

    reverse(l.begin(), l.end());
    for (size_t i = u.size() - 2; i >= 1; i--) l.push_back(u[i]);

    return l;
}

long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}



int main(void){
    int N;
    cin >> N;
    if (!N){
        cout << 0 << endl;
        return 0;
    }
    long long total = 0;
    for (int i = 0; i < N; i++){
        long long x;
        cin >> x;
        total += x;
    }
    cout << total/N << endl;


    return 0;
}   



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

ll fep(ll x, ll y, ll m)
{
	//base cases
	if (x == 0)
		return 0;
	if (y == 0)
		return 1;

	//terminating condition
	if (y == 1)
		return (x % m);

	if (y % 2)
		return ((fep(x, y - 1, m) * fep(x, 1, m)) % m);
	else
	{
		ll t = fep(x, y / 2, m);
		return (t * t) % m;
	}
}

ll solve()
{
	ll n;
	cin >> n;
	if (n < 2)
		return 0;

	ll t1 = fep(10, n, M);
	ll t2 = fep(8, n, M);
	t1 = (t1 + t2) % M;
	t2 = 2 * fep(9, n, M);
	t2 = ((M - 1) * t2) % M;
	return (t1 + t2) % M;
}

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

	ll t;
	// cin >> t;
	t = 1;
	for (ll i = 1; i <= t; i++)
		cout << solve() << "\n";

	return 0;
}


Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		int limit=0;
		str=bfr.readLine();
		String[] wa=str.split(" ");
		limit=Integer.parseInt(wa[0]);
		int min=Integer.parseInt(wa[1]);
		int max=Integer.parseInt(wa[2]);
		int sum=0;
		int tmp=0;
		int jyoukenniauwa=0;
		for(int i=1; i<=limit; i++) {
			tmp=i;
			while(tmp>=1) {
				sum+=tmp%10;
				tmp=tmp/10;
			}
			if(min<=sum && sum<=max) {
				jyoukenniauwa+=i;
			}
			sum=0;
		}
		System.out.println(jyoukenniauwa);
	}
}

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

using namespace std;
using ll=long long;

int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> s(n,pair<int,int>(0,0));
    for (int i = 0; i < m; ++i) {
        int p;
        string t;
        cin>>p>>t;
        if(t=="AC")s[p-1].second++;
        else if(s[p-1].second<1)s[p-1].first++;
    }
    int ac=0,pan=0;
    for (int i = 0; i < n; ++i) {
        if(s[i].second>=1){
            ++ac;
            pan+=s[i].first;
        }
    }
    cout<<ac<<" "<<pan<<endl;
    return 0;
}

Measured memory_bytes: 1024
import bisect,collections,copy,heapq,itertools,math,string
import sys
def I():
    # 1 line 1 int
    return int(sys.stdin.readline().rstrip())
def LI():
    # 1 line n ints
    return list(map(int,sys.stdin.readline().rstrip().split()))
def S():
    # 1 line 1 string
    return sys.stdin.readline().rstrip()
def LS():
    # 1 line n strings
    return list(sys.stdin.readline().rstrip().split())

x = S()

count = 0
for s in x:
    if s == "1":
        count += 1

print(count)

Measured memory_bytes: 9920
#import<bits/stdc++.h>
using namespace std;typedef priority_queue<long long> P;long long N,d[8<<14],a[5<<16],i,m;P q;main(){cin>>N;for(;i<N*3;++i){cin>>a[i];q.push(-a[i]);m+=a[i];(i^N-1)?(i/N^1)?0:(m+=q.top(),q.pop(),d[i-N+1]=m):*d=m;}q=P();m=0;for(i=N*3;--i+1;){q.push(a[i]);m+=a[i];(i^(N*2))?(i/N^1)?0:(m-=q.top(),q.pop(),d[i-N]-=m):d[i-N]-=m;}cout<<*max_element(d,d+N+1);}

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

int gcd(int x, int y) {
  int r;
  while (r = x % y) {
    x = y;
    y = r;
  }
  return y;
}

int main() {
  int x, y;
  cin >> x >> y;
  cout << x + y + 1 - gcd(x, y) << "\n";
}


Measured memory_bytes: 3100
n,q = map(int,input().split())
s = input()
ans = []
a = [0]*(10**5+1)
add = 0
check = False
for i in range(n):
    if check and s[i] == 'C':
        add +=1
    if s[i] == 'A':
        check = True
    else:
        check = False
    
    a[i] += add
for i in range(q):
    b,c = map(int,input().split())
    ans.append(a[c-1]-a[b-1])
for i in range(q):
    print(ans[i])

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

ll dp[55][55];

ll nCr(ll n, ll r) {
       if(n==r) return dp[n][r] = 1ll;
       if(r==0) return dp[n][r] = 1ll;
       if(r==1) return dp[n][r] = n;
       if(dp[n][r]) return dp[n][r];
       return dp[n][r] = nCr(n-1,r) + nCr(n-1,r-1);
}

int main() {
  ll n,p;
  cin>>n>>p;
  int x;
  ll odd=0,even=0;
  for (int i=0; i<n; i++) {
    scanf("%d",&x);
    if(x%2) odd++;
    else even++;
  }
  ll ans=1;
  for (int i=0; i<even; i++) {
    ans*=2;
  }
  ll ans2=0;
  if (p)
    for (ll i=1; i<=(odd+1)/2*2-1; i+=2) {
      ans2+=nCr(odd,i);
    }
  else
    for (ll i=0; i<=odd/2*2; i+=2) {
      ans2+=nCr(odd,i);
    }
  
  cout<<ans*ans2<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int i,j,h;
  int H, W;

  for(h=0;;h++){
    scanf("%d %d", &H, &W);
    if(H == 0 && W == 0){
      break;
    }

    for(i=0; i<H; i++){
      for(j=0; j<W; j++){

        if(i == 0 || j == 0){
          printf("#");
        }

        else if(i == H-1 || j == W-1){
          printf("#");
        }

        else if((0 < i && i < H) && (0 < j && j < W-1)){
          printf(".");
        }

      }
    printf("\n");
    }
    printf("\n");
  }

  return 0;

}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N;

int hoge(ll v) {
	int d=0;
	while(v) {
		d++;
		v/=10;
	}
	return d;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	int mi=101010;
	cin>>N;
	for(ll a=1;a*a<=N;a++) {
		if(N%a==0) {
			mi=min(mi,max(hoge(a),hoge(N/a)));
		}
	}
	cout<<mi<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

double eps = 1e-9;

string ccw(P a,P b,P c){
  P ab=b-a;
  P ac=c-a;
  P k=ac/ab;
  if( k.imag() > eps ){
    return "COUNTER_CLOCKWISE";
  }
  if( k.imag() < -eps ){
    return "CLOCKWISE";
  }
  if( k.real() < -eps ){
    return "ONLINE_BACK";
  }
  if( (ac/ac).real()+eps < k.real() ){
    return "ONLINE_FRONT";
  }
  return "ON_SEGMENT";
}

int main(){

  double x0,y0,x1,y1,x2,y2;
  cin>>x0>>y0>>x1>>y1;
  P a(x0,y0);
  P b(x1,y1);
  int n;
  cin>>n;
  while(n--){
    cin>>x2>>y2;
    P c(x2,y2);
    cout<< ccw(a,b,c) <<endl;
  }
  return 0;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int a=0,b=0,c=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='0'){
      a++;
    }
    else if(s.at(i)=='1'){
      b++;
    }
  }
  c=min(a,b);
  cout<<c*2<<endl;
}


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

void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}

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

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int fibonacci(int);
int dp[45];
int main(){
  int n,result,i;
  for(i=0;i<45;i++) dp[i]=0;
  cin >> n;
  result=fibonacci(n);
  cout << result << endl;
  return 0;
}
int fibonacci(int n){
  if(n==0||n==1) return dp[n]=1;
  if(dp[n]!=0) return dp[n];
  return dp[n]=fibonacci(n-1)+fibonacci(n-2);
}

Measured memory_bytes: 1160
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

int main() {
  int N;
  cin >> N;

  int amax = 0, bmin = 0;
  rep(i, N) {
    int a, b;
    cin >> a >> b;
    if (a > amax) {
      amax = a;
      bmin = b;
    }
  }

  cout << amax + bmin << endl;

  return 0;
}

Measured memory_bytes: 3168
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

template <class T>
void VecRowShow(vector<T> vec) {
	rep(i, vec.size()) {
		if (i != vec.size() - 1) cout << vec[i] << " ";
		else cout << vec[i] << endl;
	}
}


vector<vector<int>> listo(14);


//k桁　a(以降)から始まるもののなかでb番目に大きい
string f(int a, int b, int k) {
	if (k == 0) {
		return to_string(a + b - 1);
	}
	int sum = 0;
	FOR(i, a, 10) {
		sum += listo[k][i];
		if (b <= sum) {
			if (i == 0) {
				return to_string(i) + f(i, b - (sum - listo[k][i]), k - 1);
			}
			else {
				return to_string(i) + f(i - 1, b - (sum - listo[k][i]), k - 1);
			}
		}
	}
}

int main() {
	int k;
	cin >> k;
	vector<int> sum(14);
	rep(i, 14) {
		listo[i].resize(10);
		if (i == 0) {
			rep(j, 10) {
				listo[i][j] = 1;
			}
			int a0 = SUM(listo[i]);
			sum[i] = a0 - listo[0][0];
		}
		else {
			rep(j, 10) {
				if (j == 0) {
					listo[i][j] = listo[i - 1][0] + listo[i - 1][1];
				}
				else if (j == 9) {
					listo[i][j] = listo[i - 1][8] + listo[i - 1][9];
				}
				else {
					listo[i][j] = listo[i - 1][j - 1] + listo[i - 1][j] + listo[i - 1][j + 1];
				}
			}
			int sum0 = SUM(listo[i]);
			sum[i] = sum0 + sum[i - 1] - listo[i][0];
		}

	}

	if (k < 10) {
		cout << k << endl;
		return 0;
	}

	rep(i, 14) {
		if (k <= sum[i]) {
			auto ans = f(1, k - sum[i - 1], i);
			cout << ans << endl;
			return 0;
		}
	}

}



Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define PI acos(-1)
#define fs first
#define sc second
#define debug freopen("1.in", "r", stdin), freopen("1.out", "w", stdout);
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MAX = 0x7fffffff;
const int MIN = 0x80000000;
const ll maxn = 1e6 + 10;

ll k, x;

int main() {
    ios;
    cin >> k >> x;
    if (k * 500 >= x)
        cout << "Yes" << '\n';
    else cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 3080
#include <iostream>
#include <stdio.h>

#define MAX_N 100

using namespace std;

int A[MAX_N];

int main() {
  int N, D, X;
  cin >> N >> D >> X;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }

  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    int j = 1;
    int d = 1;
    while (d <= D) {
      ++cnt;
      d = j++ * A[i] + 1;
    }
  }
  printf("%d\n", cnt + X);
}

Measured memory_bytes: 3204
#include <iostream>
#include <algorithm>
#include <vector>
#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;
    vector<ll>h(n);
    rep(i, n)   cin >> h[i];
    sort(h.begin(), h.end());
    if(k >= n){
        cout << 0 << endl;
    }else{
        ll ans = 0;
        rep(i, n-k){
            ans += h[i];
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007;
vector<vector<vector<long long>>>dp; // dp(i,j) probablity of coming j heads when i coins
vector<int>v;

long long winner(int l,int r,int player){
    if(l>r){
        return 0;
    }
    if(dp[l][r][player]!=-1){
        return dp[l][r][player];
    }
    long long x;
    if(player==0){
         x = max(v[l]+winner(l+1,r,1-player),v[r]+winner(l,r-1,1-player));
    }else{
        x = min(winner(l+1,r,1-player)-v[l],winner(l,r-1,1-player)-v[r]);
    }
    return dp[l][r][player]=x;
}

void solve(){
    int n;cin>>n;
    v.resize(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    dp.resize(n,vector<vector<long long> >(n,vector<long long>(2,-1)));
    int l=0,r=n-1;
    long long x = winner(l,r,0);
    cout<<x<<"\n";
}

int main(){
    //cin.tie(0);
    //cout.tie(0);
    //cin.sync_with_stdio(0);
    //cout.sync_with_stdio(0);

    cout.precision(10);
    int t=1;//cin>>t;
    while(t--){

        solve();
    }
    return 0;
}


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

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll a,b;
    char ch;
    cin>>a>>ch>>b;
    if(ch=='+')cout<<a+b<<endl;
    else cout<<a-b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int N;
    cin >> N;
    vector<long long> A(N),B(N),C(N);
        
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }    
    for ( int i = 0; i < N; i++ ) {
        cin >> B[i];
    }    
    for ( int i = 0; i < N; i++ ) {
        cin >> C[i];
    }
    sort( A.begin(), A.end() );
    sort( B.begin(), B.end() );
    sort( C.begin(), C.end() );
    

    vector<long long> X(N);
    for ( int i = 0; i < N; i++ ) {
        decltype(C)::iterator it = upper_bound(C.begin(), C.end(), B[i]);
        
        X[i] = C.end() - it;
    }    
    for ( int i = N-2; i >= 0; i-- ) {
        X[i] = X[i] + X[i+1];
    }
    
    long long ans = 0;
    for ( int i = 0; i < N; i++ ) {
        decltype(B)::iterator it = upper_bound(B.begin(), B.end(), A[i]);
        // cout <<  it - B.begin()  << endl;
        if ( it != B.end() ) { ans += X[ it - B.begin() ]; }
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3328
#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)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  rep(i, n) {
    cin >> a[i].first;
    a[i].second = i+1;
  }
  sort(a.begin(), a.end());
  rep(i, n) {
    cout << a[i].second << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1536
using System;
    using System.Collections.Generic;
    using System.Linq;

    class Program
    {
        static int size;
        int[] array = new int[size];

        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            var ans = input.Contains("7") == true ? "Yes" : "No";
            Console.WriteLine(ans);
        }
    }

Measured memory_bytes: 25780
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
#define ALL(a)  (a).begin(),(a).end()
const int MOD = 1000000007;
ll l,x,y,s = 0,d,n,m;
int main() {
    cin >> n; deque<ll> a(n);
    rep(i, n) {
        cin >> a[i];
        if (i != 0) s += abs(a[i] - a[i - 1]);
        else s += abs(a[i]);
    }
    s += abs(a[n - 1]);
    a.push_back(0); a.push_front(0);
    for(int i = 1;i <= n ;i++) {
        cout << s + abs(a[i - 1] - a[i + 1]) - abs(a[i - 1] - a[i]) - abs(a[i] - a[i + 1])<< endl;
    }
}

Measured memory_bytes: 2048