akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
//import java.io.*;
//import java.util.Arrays;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		//InputStreamReader is = new InputStreamReader(System.in);
		//BufferedReader br = new BufferedReader(is);
		//String text = scan.next();
		int w = scan.nextInt();
		int n = scan.nextInt();
		String a[] = new String[n];
		int line[][] = new int[n][2];
		for(int i = 0 ; i< n ; i++){
			a[i] = scan.next();
			String mozi[] =  a[i].split(",", 0);
			for(int j = 0 ; j < 2 ; j++){
				line[i][j] = Integer.parseInt(mozi[j]);
			}
		}
		int answer[] = new int[w];
		for(int i = 0 ; i < w ; i++){
			answer[i] = i+1;
			for(int j = 0 ; j < n ; j++){
				if(line[j][0] == answer[i] || line[j][1] == answer[i]){
					if(line[j][0] == answer[i]){
						answer[i] = line[j][1];
					}else{
						answer[i] = line[j][0];
					}
				}
			}
		}
		int goal[] = new int[w];
		for(int i = 0 ; i < w ; i++){
			goal[answer[i]-1] = i+1;
		}
		for(int i = 0 ; i < w ; i++){
			System.out.println(goal[i]);
		}
	}
}

Measured memory_bytes: 26136
#include<stdio.h>

#define M 10000

int p(int c){
  return c/2;
}

int l(int c){
  return c*2;
}

int r(int c){
  return c*2 + 1;
}

int main(){
  int i;
  int n;
  int H[M],pk,lk,rk;

  scanf("%d",&n);

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

  for(i=1; i<=n; i++){
    printf("node %d: key = %d, ",i,H[i]);
    pk = p(i);
    lk = l(i);
    rk = r(i);
    if (pk >= 1) printf("parent key = %d, ",H[pk]);
    if (lk <= n) printf("left key = %d, ",H[lk]);
    if (rk <= n) printf("right key = %d, ",H[rk]);
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2148
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<int>a(n),b(n);
    ll cnt1=0,cnt2=0;
    rep(i,n){
        cin>>a[i];
        b[i]=a[i]-(i+1);
        cnt1+=a[i];
        cnt2+=i+1;
    }
    sort(b.begin(),b.end());
    int x;
    if(b.size()%2==0)x=(b[n/2-1]+b[n/2])/2;
    else x=b[n/2];
    ll ans=0;
    rep(i,n){
        ans+=abs(b[i]-x);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<math.h>

int main(void){

int N;
std::cin >> N;

int twoes = 0;
int a;
for (int i=0;i<N;i++)
{
    std::cin >> a;
    while(a%2==0)
    {
      a = a/2;
      twoes++;
    }
  
}
  
  std::cout << twoes << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int ans=0;
        while(n > 0)
        {
            n/=k;
            ans++;
        }
        System.out.println(ans);
	}
}


Measured memory_bytes: 21588
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

L, R = rl()

ans = float('inf')
for i in range(L, min(L+2020, R+1)):
	for j in range(i+1, min(i+2020, R+1)):
		ans = min(ans, (i*j)%2019)
print(ans)


Measured memory_bytes: 71068
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int dp[2*maxn];
int main()
{
    int n;
    while(scanf("%d",&n)==1)
    {
        int ans=0,x;
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&x);
            dp[x]=max(dp[x],dp[x-1]+1);
            ans=max(ans,dp[x]);
        }
        printf("%d\n",n-ans);
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define for0(n) for(i=0; i<(n); i++)
#define for1(n) for(i=1; i<=(n); i++)
#define M 1000000007


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll _,i,j,n,a,b,e,k,u,t,x=1,m,y,q,f=1,c=0,d=0,l,p,z,o,r,g;
    string ss,s;
    cin>>n;
    while(n--)
    {
        cin>>x>>y;
        if(x==y)c++;
        else c=0;
        if(c>=3)d=1;
    }
    cout<<(d?"Yes":"No")<<endl;
}



Measured memory_bytes: 3628
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 1e5 + 5;
int n, k;
int a[maxn];

int read() {
  if (scanf("%d%d", &n, &k) < 2) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  return true;
}

long long pref[maxn], suff[maxn], s[maxn];

void solve() {
  pref[0] = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] > 0) {
      pref[i + 1] = pref[i] + a[i];
    } else {
      pref[i + 1] = pref[i];
    }
  }
  suff[n] = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] > 0) {
      suff[i] = suff[i + 1] + a[i];
    } else {
      suff[i] = suff[i + 1];
    }
  }
  s[0] = 0;
  for (int i = 0; i < n; i++) {
    s[i + 1] = s[i] + a[i];
  }
  long long res = 0;
  for (int i = 0; i + k <= n; i++) {
    res = max(res, max(0ll, s[i + k] - s[i]) + pref[i] + suff[i + k]);
  }
  printf("%lld\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
using namespace std;
typedef long long int ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define FOREQ(i, a, b) for (int i = (a); i <= (b); i++)
#define REPEQ(i, n) FOREQ(i, 0, n)

int main()
{
    ll Min, Max;
    cin >> Min >> Max;
    int length = 0;
    for (ll i = Min; i <= Max; i *= 2)
    {
        length++;
    }

    cout << length << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,cnt=0,ans=0;
  cin >> n;
  for(int i=1; i<=n; i+=2) {
    cnt=0;
    for(int j=1; j<=i; j++) {
      if(i%j==0) {
        cnt++;
        if(cnt==8) {
          ans++;
        }
      }
    }
  }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
ll gcd(ll a, ll b)
{
	for (;;)
	{
		if (a < b)swap(a, b);
		a %= b;
		if (a == 0)return b;
	}
}
int d[2000];
int main()
{
	int num;
	scanf("%d", &num);
	fill(d, d + 2000, 1000);
	for (int i = 0; i < num; i++)
	{
		string s;
		cin >> s;
		int x[2000];
		fill(x, x + 2000, 0);
		for (int j = 0; j < s.size(); j++)x[s[j]]++;
		for (int j = 'a'; j <= 'z'; j++)d[j] = min(d[j], x[j]);
	}
	string r;
	for (int i = 'a'; i <= 'z'; i++)for (int j = 0; j < d[i]; j++)r.push_back(i);
	cout << r << endl;
}

Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int mod = 998244353;
int n;
const int maxN = 202;
int x[maxN], y[maxN];
ll pw2[maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n;
    pw2[0] = 1;
    for (int i = 1; i <= n; i++) pw2[i] = (2LL * pw2[i - 1]) % mod;
    for (int i = 1; i <= n; i++) {
        cin >> x[i] >> y[i];
    }
    ll tot = pw2[n];
    tot -= 1;
    tot -= n;
    map < vector < ll >, int > mp;
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            ll f1 = y[j] - y[i];
            ll f2 = x[i] - x[j];
            ll c = -f1 * x[i] - f2 * y[i];
            ll d = __gcd(abs(f1), abs(f2));
            f1 /= d;
            f2 /= d;
            c /= d;
            if (f1 < 0 || (f1 == 0 && f2 < 0)) {
                f1 *= -1;
                f2 *= -1;
                c *= -1;
            }
            mp[{f1, f2, c}]++;
        }
    }
    for (auto it : mp) {
        int f = (sqrt((8 * it.second + 1)) + 1) / 2;
        tot -= (pw2[f] - f - 1);
    }
    tot %= mod;
    if (tot < 0) tot += mod;
    cout << tot;
    return 0;
}

Measured memory_bytes: 2432
#include<iostream>
#include<math.h>
#include<iomanip>
using namespace std;

int main(){

int n;
cin>>n;

double x[n];
double y[n];

for(int i=0;i<n;i++){
cin>>x[i];
}
for(int i=0;i<n;i++){
cin>>y[i];
}

double p1=0;

for(int i=0;i<n;i++){
p1 = p1 + fabs(x[i]-y[i]);
}

double p2=0;

for(int i=0;i<n;i++){
p2 = p2 + pow(fabs(x[i]-y[i]),2);
}

p2 = sqrt(p2);

double p3=0;

for(int i=0;i<n;i++){
p3 = p3 + pow(fabs(x[i]-y[i]),3);
}

p3 = pow(p3,0.3333333333);

double pz=0;
double check=0;

for(int i=0;i<n;i++){
check=fabs(x[i]-y[i]);
if(pz<=check)pz=check;
}

cout<<fixed<<p1<<endl;
cout<<fixed<<p2<<endl;
cout<<fixed<<p3<<endl;
cout<<fixed<<pz<<endl;
}


Measured memory_bytes: 3472
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
  ll r,d,x;
  cin >> r >> d >> x;
  vector<ll> x2(11);
  x2[0] = x;
  for(int i=1; i<11; i++){
    x2[i] = x2[i-1]*r - d;
    cout << x2[i] << endl;
  }
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np


def solve(S):
    dp = np.zeros(2019, np.int64)
    pow10 = 1
    answer = 0
    for x in S[::-1]:
        dp[0] += 1
        x = x * pow10 % 2019
        newdp = np.zeros_like(dp)
        newdp[x:] += dp[:-x]
        newdp[:x] += dp[-x:]
        answer += newdp[0]
        pow10 *= 10
        pow10 %= 2019
        dp = newdp
    return answer


def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', '(i4[:],)')(solve)
    cc.compile()


try:
    from my_module import solve
except:
    cc_export()
    exit()

S = np.array(list(read().rstrip()), dtype=np.int32) - ord('0')
print(solve(S))


Measured memory_bytes: 29148
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
//#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF INT_MIN 
#define INF INT_MAX 
#define int ll int
#define OOK order_of_key  //no of elements less than
#define FBO find_by_order //iterator pointing kth element;indexing starts from 0
#define CK3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define CK4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef map<int,int>MII;
typedef vector<int> VI;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int mod;
int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}

//int modInverse(int a, int m) {return power(a, m-2);} //gcd(a,m)=1 
//int root(int x){return x==f[x]?x:f[x]=root(f[x]);}


signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{
   int n,p;int ans=0;
   cin>>n>>p;
   string s;
   cin>>s;
   MII mr;
   if(p==2)
   {   int rr=0;
       for(int i=0;i<s.size();i++)
       {
           if((s[i]-'0')%p==0)rr+=(i+1);
       }
       cout<<rr<<endl;return 0;
   }
   else if(p==5)
   {
       int rr=0;
       for(int i=0;i<s.size();i++)
       {
           if((s[i]-'0')%p==0)rr+=(i+1);
       }
       cout<<rr<<endl;return 0;
   }
   mod=p;
   int last=0;mr[0]++;
   for(int i=n-1;i>=0;i--)
   {
       int ch=s[i]-'0';int rem=power(10,n-i-1);
        
        mr[((last+rem*ch+p)%p)%p]++;
        last=((last+rem*ch+p)%p)%p;
        
       // cout<<last<<endl;
   }
   for(auto it:mr)
   {
       ans+=(it.SE*(it.SE-1))/2;
   }
   
   cout<<ans<<endl;
}


return 0;
}





Measured memory_bytes: 1044
#include <stdio.h>
#include <string.h>
#include <vector>
#include <assert.h>
#include <algorithm>
#include <math.h>

using namespace std;

const int MAX_N = 150;

struct stone
{
	int column;
	int slip;
	int dp[MAX_N / 2 + 1];
	stone(int c_, int s_) { column = c_; slip = s_; memset(dp, 127, sizeof(dp)); }
};

vector<stone>slist[MAX_N];

int n, m;

int main()
{
	for (;;)
	{
		for (auto& s : slist)s.clear();
		scanf("%d %d", &n, &m);
		if (n == 0)break;
		for (int i = 0; i < n; ++i)
		{
			int col; scanf("%d", &col);
			for (int j = 0; j < col; ++j)
			{
				int x, d;
				scanf("%d %d", &x, &d);
				slist[i].emplace_back(x, d);
			}
		}
		for (int i = 0; i < n; ++i)
		{
			for (stone &s : slist[i])
			{
				for (int j = 0; j <= m; ++j)
				{
					int q = 1234567890;
					if (i > 0)
					{
						//?????£??????
						for (stone sf : slist[i - 1])
						{
							q = min(q, sf.dp[j] + abs(sf.column - s.column) * (sf.slip + s.slip));
						}
						if (i > 1)
						{
							//??????????????£??????
							if (j > 0)
							{
								for (stone sf : slist[i - 2])
								{
									q = min(q, sf.dp[j - 1] + abs(sf.column - s.column) * (sf.slip + s.slip));
								}
							}
						}
						else
						{
							if (j == 1)q = 0;
						}
					}
					else
					{
						if (j == 0) q = 0;
					}
					s.dp[j] = q;
				}
			}
		}
		int ans = 1234567890;
		for (stone s : slist[n - 1])
		{
			for (int i = 0; i <= m; ++i)
			{
				ans = min(s.dp[i], ans);
			}
		}
		for (stone s : slist[n - 2])
		{
			for (int i = 0; i <= m - 1; ++i)
			{
				ans = min(s.dp[i], ans);
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
bool judge(int a,int b,int L,int R)
{
	if(R<a || R<b)
		return false;
	int L1=(L-a+2018)/2019,R1=(R-a)/2019;
	int L2=(L-b+2018)/2019,R2=(R-b)/2019;
	if(L1>R1 || L2>R2)
		return false;
	if(a<b)
		return L1<=R2;
	else
		return L1<R2;
}
int main()
{
	int L=read(),R=read();
	int ans=2019;
	for(int i=0;i<2019;++i)
		for(int j=0;j<2019;++j)
			if(judge(i,j,L,R))
			{
				ans=min(ans,i*j%2019);
			}	
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
ans = 0
for _ in range(n):
    a = list(map(int,input().split()))
    x = 0
    for i in range(m):
        x += a[i]*b[i]
    if 0 < x + c:
        ans += 1

print (ans)


Measured memory_bytes: 3060
#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 repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
#define INF 100000000
#define IINF 9999999999999;
using vint = std::vector<int>;
using ll = long long;
using vll = std::vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = std::min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = std::max(a, b); }
#define output(x) cout << x << endl;
typedef pair<int, int> P;

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

bool mass[51][51] = {false};
int walk[51][51];
int H, W;
vector<pair<int, int>> pa;

int walking() {
    queue<P> que;
    rep(i, H) rep(j, W) walk[i][j] = INF;
    que.push(P(0, 0));
    walk[0][0] = 0;

    while (!que.empty()) {
        P get = que.front(); que.pop();

        if (get.first == (H - 1) && get.second == (W - 1)) break;
        rep(i, 4) {
            int nx = get.first + dx[i], ny = get.second + dy[i];

            if (0 <= nx && nx < H && 0 <= ny && ny < W && walk[nx][ny] == INF && !mass[nx][ny]) {
                que.push(P(nx, ny));
                walk[nx][ny] = walk[get.first][get.second] + 1;
            }
        }
    }

    return walk[H - 1][W - 1];
}

int main() {
    cin >> H >> W;
    char temp;
    int black = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> temp;
            if (temp == '#') {mass[i][j] = true; ++black;}
        }
    }

    int ans = walking();
    if (ans == INF) cout << -1 << endl;
    else cout << H * W - ans - black - 1 << endl;
}

Measured memory_bytes: 256
H, N = map(int, input().split())
Alist = []
Blist = []

for _ in range(N):
    a, b = map(int, input().split())
    Alist.append(a)
    Blist.append(b)

ans = [0]
for i in range(H):
    nlist = []
    for j in range(N):
        idx = i+1-Alist[j]
        if idx<0:
            nlist.append(Blist[j])
        else:
            nlist.append(ans[idx] + Blist[j])
    ans.append(min(nlist))

print(ans[-1])

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = 0; i < (a); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define fst first
#define snd second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template<typename T>
void combTable(vector<vector<T> > &c){
  for(int i = 0; i < c.size(); ++i){
    for(int j = 0; j <= i; ++j){
      if(j == 0 || i == j) c[i][j] = (T)1;
      else c[i][j] = (c[i-1][j-1] + c[i-1][j]);
    }
  }
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, a, b;
  cin >> n >> a >> b;
  VL v(n);
  rep(i,n) cin >> v[i];
  VL u(v);
  sort(v.rbegin(), v.rend());
  sort(all(u));
  ll sum = 0;
  rep(i, a){
    sum += v[i];
  }
  double avg = (double)sum / a;
  ll ans = 0;
  VVL c(n+1, VL(n+1, 0));
  combTable<ll>(c);
  if (v[0] == v[a-1]) {
    int k = upper_bound(all(u), v[0]) - lower_bound(all(u), v[0]);
    for(int i = a; i <= min(k, b); ++i){
      ans += c[k][i];
    }
  }
  else {
    int k = upper_bound(all(u), v[a-1]) - lower_bound(all(u), v[a-1]);
    int l = u.end() - upper_bound(all(u), v[a-1]);
    ans = c[k][a-l];
  }
  cout.precision(20);
  out(avg);
  out(ans);
  return 0;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
S = ["."*(W+2)]
for i in range(H):
    x=input().strip()
    x = "."+x+"."
    S.append(x)
S.append("."*(W+2))
A = [[0 for _ in range(W+1)] for _ in range(H+1)]
for i in range(1,H+1):
    for j in range(1,W+1):
        if S[i][j]=="#":
            A[i][j] = "#"
        else:
            cnt = 0
            if S[i][j+1]=="#":
                cnt += 1
            if S[i-1][j+1]=="#":
                cnt += 1
            if S[i-1][j]=="#":
                cnt += 1
            if S[i-1][j-1]=="#":
                cnt += 1
            if S[i][j-1]=="#":
                cnt += 1
            if S[i+1][j-1]=="#":
                cnt += 1
            if S[i+1][j]=="#":
                cnt += 1
            if S[i+1][j+1]=="#":
                cnt += 1
            A[i][j]=str(cnt)
    print("".join(A[i][1:W+1]))

Measured memory_bytes: 71676
#include <iostream>
#include <cstdio>
#include <vector>
#include <math.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end());

const int MOD = 1000000007;
const int INF = INT_MAX;

int dig(ll a){
    int cnt = 0;
    while(a > 0){
        cnt++;
        a /= 10;
    }

    return cnt;
}


int main()
{

    ll n;
    cin >> n;

    int res = 11;
    for (ll i=1; i <= pow(n, 0.5); i++){
        if (n%i == 0 && res > max(dig(i), dig(n/i)) ){
            res = max(dig(i), dig(n/i));
        }
    }


    cout << res << endl;
    



    return 0;
}




//              g++ -std=c++1z  

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

#define ff first
#define endl '\n'
#define ss second
#define ll long long
#define pb push_back
#define ld long double
#define pii pair <int, int>
#define pll pair <long long, long long>

using namespace std;
const int N = 1e5 + 15;
int cnt1[N], cnt2[N], X = 0, XX = -1, Y = 0, P = 0, PP = -1, Q = 0, n, x, y;
int main(){
  //ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for(int i = 0; i < n / 2; i++){
    cin >> x >> y;
    cnt1[x]++;
    cnt2[y]++;
  }
  for(int i = 1; i < N; i++){
    if(cnt1[i] > X){
      Y = X;
      X = cnt1[i], XX = i;
    }
    else if(cnt1[i] > Y) Y = cnt1[i];

    if(cnt2[i] > P){
      Q = P;
      P = cnt2[i], PP = i;
    }
    else if(cnt2[i] > Q) Q = cnt2[i];
  }
  if(X > 0 && Y > 0 && P > 0 && Q > 0){
    if(XX != PP) return cout << n - X - P << endl, 0;
    else return cout << n - max(X + Q, Y + P) << endl, 0;
  }
  if(X > 0 && Y > 0 && P > 0 && Q <= 0){
    if(XX != PP) return cout << n - X - P << endl, 0;
    else return cout << n - Y - P << endl, 0;
  }
  if(X > 0 && Y <= 0 && P > 0 && Q > 0){
    if(XX != PP) return cout << n - X - P << endl, 0;
    else return cout << n - X - Q << endl, 0;
  }
  if(XX != PP) return cout << n - X - P << endl, 0;
  return cout << n / 2 << endl, 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
 
#define mp make_pair
#define fi first
#define se second
 
//mt19937 rng(time(NULL)); //int
//mt19937_64 rng(time(NULL)); //Long Long
//shuffle(a.begin(),a.end(),rng); //shuffle
//rng(); //random
 
vector<int>adj[200050];
 
priority_queue<int, vector<int>, greater<int> > jaw;
vector<int> sim;
long long getv(int a, int m) {
	while (!jaw.empty()) jaw.pop();
	sim.clear();
	for (int i = 1; i <= m; i++) {
		for (auto it : adj[i]) jaw.push(it);
		if (i >= m - a + 1) {
			if (jaw.empty()) return -1e18;
			jaw.pop();
		}
	}
	for (auto it : adj[m + 1]) jaw.push(it);
	while (!jaw.empty()) {
		sim.push_back(jaw.top());
		jaw.pop();
	}
 
	int st = 1, en = min((int)sim.size(), m - a), mi, rv = 0;
	while (st <= en) {
		mi = (st + en) / 2;
 		int i;
		for (i = 0; i < mi; i++) if (sim[sim.size() - mi + i] < i + 1) break;
		if (i >= mi) {
			rv = mi;
			st = mi + 1;
		}
		else en = mi - 1;
	}
	return a + rv;
}
int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i= 1; i <= n; i++) {
		int t1, t2;
		scanf("%d %d", &t1, &t2);
		//t1 = 1, t2 = 2;
		adj[t2].push_back(t1);
	}
 
	int st = 0, en = min(n, m), mi;
	while (st < en) {
		int mi1 = (st + en) / 2;
		int mi2 = mi1 + 1;
 
		long long v1 = getv(mi1, m);
		long long v2 = getv(mi2, m);
		if (v1 >= v2) en = mi2 - 1;
		else st = mi1 + 1;
	}
	long long v = getv(st, m);
	return !printf("%lld\n", n - v);
}

Measured memory_bytes: 10232
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define int long long
#define loop(i,s,e) for(int i=s;i<e;i++)
#define rloop(i,s,e) for(int i=e;i>=s;i--)
#define fr first
#define sc second
#define pb push_back
#define  vii vector<int>
#define vll vector<ll>
#define vpii vector<pair<int ,int >>
#define vpll vector<pair<ll, ll> >
#define  pii pair<int,int>
#define lb(v,x) lower_bound(v.begin(),v.end(),x);
#define ub(v,x) upper_bound(v.begin(),v.end(),x);
const long mod =1e9+7;
const int N = 2e5+10;
const long long inf= 1e18;
 
ll gcd(ll a ,ll b){if(b==0) return a;return gcd(b,a%b);}
ll mul(ll a ,ll b){return (a%mod * b%mod )%mod;}
ll mpower(ll a, ll b){if(b==0) return 1;ll temp=mpower(a,b/2);if(b%2==0){return mul(temp,temp);}else{	return mul(mul(temp,temp) , a);}}
ll inv(ll a){return mpower(a,mod-2);}
ll ncr(ll n, ll r){if(r==0)return 1;ll ans=n%mod;ans=mul(ans,ncr(n-1,r-1));ans=mul(ans,inv(r));	return ans;}
ll power(ll a, ll b){if(b==0) return 1;ll temp=power(a,b/2);if(b%2==0)return temp*temp;else return temp*temp*a;}
ll add(ll a, ll b){return (a%mod + b%mod)%mod;}
 
 
void solve()
{
   int x;cin>>x;
   int f=0;
   loop(i,-700,700)
   {
       loop(j,-700,700)
       {
           if(power(i,5)-power(j,5)==x)
           {
               cout<<i<<" "<<j;
               f=1;
               break;
           }
       }
       if(f)break;
   }
   
 
    
}
 
int32_t main()
{
	ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1;//cin>>t;
	while(t--){
        solve();
	}
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5, INF = 0x3f3f3f3f, M = 2e6 + 5;
const ll LNF = 0x3f3f3f3f3f3f3f3f;
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, r, l) for (int i = r; i >= l; i--)
#define repe(i, u) for (int i = head[u]; i; i = nxt[i])
int n, a[1025][1025], vis[1025];
bool flag;
bool ok() {
  rep(i, 1, n)
    if (a[i][0] != n) return 0;
  return 1;
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  rep(i, 1, n) {
    rep(j, 1, n - 1) cin >> a[i][j];
    a[i][0] = 1;
  }
  rep(z, 0, INF) {
    if (ok()) {
      cout << z << '\n';
      return 0;
    }
    flag = 0;
    memset(vis, 0, sizeof vis);
    rep(i, 1, n) {
      if (vis[i] || a[i][0] == n) continue;
      int x = a[i][a[i][0]];
      if (!vis[i] && !vis[x] && a[x][a[x][0]] == i) {
        a[i][0]++;
        a[x][0]++;
        vis[i] = vis[x] = 1;
        flag = 1;
      }
    }
    if (!flag) {
      cout << -1 << '\n';
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxx=28;
const int NIL=-1;
struct node{
	int parent,left,right;
};
node tree[maxx];

void print_preorder(int x){
	if(x==NIL) return ;
	printf(" %d",x);
	print_preorder(tree[x].left);
	print_preorder(tree[x].right);
	return ;
}

void print_inorder(int x){
	if(x==NIL) return ;
	print_inorder(tree[x].left);
	printf(" %d",x);
	print_inorder(tree[x].right);
	return ;
}

void print_postorder(int x){
	if(x==NIL) return ;
	print_postorder(tree[x].left);
	print_postorder(tree[x].right);
	printf(" %d",x);
	return ;
}

int main (){
	int n;
	cin>>n;
	for(int i=0;i<maxx;i++) tree[i].parent=tree[i].left=tree[i].right=NIL;
	int a,b,c,root;
	for(int i=0;i<n;i++){
		cin>>a>>b>>c;
		tree[a].left=b;
		tree[a].right=c;
		if(b!=NIL) tree[b].parent=a;
		if(c!=NIL) tree[c].parent=a;
	}
	for(int i=0;i<n;i++){
		if(tree[i].parent==NIL) root=i;
	}
	printf("Preorder\n");
	print_preorder(root);
	printf("\nInorder\n");
	print_inorder(root);
	printf("\nPostorder\n");
	print_postorder(root);
	printf("\n");
	return 0;
}


Measured memory_bytes: 3216
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String tes = null;
		char c = 0;


		ArrayList<Double> al = new ArrayList<Double>();
		ArrayList<Integer> al2 = new ArrayList<Integer>();

		while(true){
			try {
				tes = br.readLine();
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
			if(tes == null){
				break;
			}
			if(tes.equals("")){
				break;
			}
			try{
				String[] fruit = tes.split(" ", 0);
				al.add(Double.parseDouble(fruit[0])/Double.parseDouble(fruit[1]));
				al2.add(Integer.parseInt(fruit[2]));
			}catch(NumberFormatException e){
				break;
			}

			
			//al.add(a);
		}
		
		for(int r=0;r<al.size();r++){
			String sss = String.valueOf(al.get(r));
			int e = -1;
			int pri = 0;
			for(int i=0;i<sss.length();i++){
				if(e == al2.get(r)){
					break;
				}
				if(e >= 0){
					pri += Integer.parseInt(String.valueOf(sss.charAt(i))); 
					e++;
				}
				if(sss.charAt(i) == '.'){
					e = 0;
				}
			}
			
			System.out.println(pri);
		}
		
		
	}

}

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

int main(){
  int A,B,C,D = 0;
  cin >> A >> B >> C >> D;
  if(A+B<C+D)
    cout << "Right" << endl;
  else if(A+B==C+D)
    cout << "Balanced" << endl;
  else
    cout << "Left" << endl;
}

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 A,B;
    cin >> A >> B;
    cout << 100 << " " << 100 << endl;

    int X[100][100] = {0};
    A--;
    
    int a = 0;
    bool end = a == A;
    if ( !end ) { B--; }
    for ( int y = 99; y >= 0; y -=2 ) {
        if ( end ) { break; }
        for ( int x = 0; x < 100; x += 2 ) {
            X[x+1][y] = X[x][y-1] = X[x+1][y-1] = 1;
            a++;
            if ( a == A ) { end = true; break; }
        }
    }

    a = 0;
    end = a == B;
    for ( int y = 0; y < 100; y += 2 ) {
        if ( end ) { break; }
        for ( int x = 0; x < 100; x += 2 ) {
            X[x][y] = 1;
            a++;
            if ( a == B ) { end = true; break; }
        }        
    }
    

    for ( int y = 0; y < 100; y++ ) {
        for ( int x = 0; x < 100; x++ ) {
            cout << ( X[x][y] ? '#' : '.' );
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
while True:
    try:
        s = raw_input()
    except EOFError:
        break
        
    i=0
    hirabun = ''
    while i <len(s):
        if s[i] != '@':
            hirabun += s[i]
            i += 1
        elif s[i] == '@' and i+2 < len(s):
            hira_part = s[i+2]*int(s[i+1])
            hirabun += hira_part
            i += 3 
    print hirabun

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

int main(){
    double n,k,sum=0,sum1,kcnt=0;
    cin >> n >> k;
    double kaku=1.0/n;
    //cout << kaku << endl;

for (double i = 1;i <= n;i++){
    sum = i;
    //double kaku=1.0/n;
    while(sum<=k-1){
        //cout << sum << endl;
        sum += sum;
        kaku *= 1.0/2.0;
        //cout << kaku << endl;
    }
    kcnt += kaku; 
    kaku = 1.0/n;
}
cout << scientific << setprecision(11)<< kcnt << endl;

}

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

int main() {
    int x;
    cin >> x;
    if (x % 10 == 2 || x % 10 == 4 || x % 10 == 5 || x % 10 == 7 || x % 10 == 9) {
        cout << "hon";
    } else if (x % 10 == 0 || x % 10 == 1 || x % 10 == 6 || x % 10 == 8) {
        cout << "pon";
    } else {
        cout << "bon";
    }
}

Measured memory_bytes: 3588
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner inp = new Scanner(System.in);

        int total = inp.nextInt();

        ArrayList<Integer> s = new ArrayList<>();
        ArrayList<Integer> c = new ArrayList<>();
        ArrayList<Integer> d = new ArrayList<>();
        ArrayList<Integer> h = new ArrayList<>();

        int count = 0;

        while (count != total) {
            String ch = inp.next();
            int num = inp.nextInt();

            if (ch.equals("S")) {
                s.add(num);
            }

            if (ch.equals("H")) {
                h.add(num);
            }

            if (ch.equals("D")) {
                d.add(num);
            }

            if (ch.equals("C")) {
                c.add(num);
            }

            count++;
        }

        ArrayList<Integer> sMissing = new ArrayList<>();
        ArrayList<Integer> cMissing = new ArrayList<>();
        ArrayList<Integer> dMissing = new ArrayList<>();
        ArrayList<Integer> hMissing = new ArrayList<>();

        for (int i = 1; i <= 13; i++) {
            if (!(s.contains(i))) {
                sMissing.add(i);
            }

            if (!(h.contains(i))) {
                hMissing.add(i);
            }

            if (!(d.contains(i))) {
                dMissing.add(i);
            }

            if (!(c.contains(i))) {
                cMissing.add(i);
            }
        }

        for (int i : sMissing) {
            System.out.println("S " + i);
        }
        for (int i : hMissing) {
            System.out.println("H " + i);
        }
        for (int i : cMissing) {
            System.out.println("C " + i);
        }
        for (int i : dMissing) {
            System.out.println("D " + i);
        }
    }
}



Measured memory_bytes: 26168
N, K = map(int, input().split())
if K > (N-1)*(N-2)//2:
    print(-1)
    exit()
A = []
for i in range(1, N):
    A.append([i, N])
k = (N-1)*(N-2)//2
f = False
for i in range(1, N):
    for j in range(i+1, N):
        if k == K:
            f = True
            break
        A.append([i, j])
        k -= 1
    if f:
        break
print(len(A))
for v, u in A:
    print(v, u)


Measured memory_bytes: 4128
#include<bits/stdc++.h>
using namespace std;
long long int f[101],e[101][101],n,m,ans=0,u,v;
inline int ff(int a)
{
    if(f[a]==a)
        return a;
    return f[a]=ff(f[a]);
}
int main(int argc, char** argv)
{
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>u>>v;
        e[u][v]=1,e[v][u]=1;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            if(e[i][j]==0)
                continue;
            e[i][j]=0;
            for(int k=1;k<=n;k++)
                f[k]=k;
            for(int k=1;k<=n;k++)
            {
                for(int l=k+1;l<=n;l++)
                {
                    if(e[k][l]!=0)
                        f[ff(l)]=ff(k);
                }
            }
            for(int k=2;k<=n;k++)
            {
                if((ff(k)-ff(k-1))!=0)
                {
                    ans++;
                    break;
                }
            }
            e[i][j]=1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

Int N;
vector<Int> A;

Int used[200010][100];
Int mem[200010][100];
Int dfs(Int idx, Int passed, Int num){
  if(num > N / 2) return -INF;
  if(idx >= N) return num < N/2? -INF: 0;
  if(num + (N - idx + 1) / 2 < N/2) return -INF;
  if(used[idx][passed]++) return mem[idx][passed];
  Int a = dfs(idx + 2, passed, num + 1) + A[idx];
  Int b = dfs(idx + 1, passed + 1, num);
  Int res = max(a, b);
  return mem[idx][passed] = res;
}

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

  cin>>N;
  A.resize(N);
  cin>>A;

  Int ans = dfs(0, 0, 0);
  cout<<ans<<endl;


  return 0;
}


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

#define f(i, a, b, c) for(int i = a ; i < b ; i += c)
#define fr(i, a, b, c) for(int i = a ; i >= b ; i -= c)
#define fit(it, v) for(auto it = v.begin() ; it != v.end() ; ++it)
#define frit(it, v) for(auto it = v.rbegin() ; it != v.rend() ; ++it)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define NL '\n'
#define modn 1000000007
#define EPS 1e-9

using namespace std;

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< lli > vli;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< char > vc;
typedef vector< string > vs;
typedef vector< bool > vb;
typedef set< int > si;
typedef set< ii > sii;

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

	#ifdef LOCAL_TEST
		ifstream h("in");
		ofstream g("out");
		clock_t z = clock();
	#else
		#define h cin
		#define g cout
	#endif//LOCAL_TEST

	int d, t, s;
	h >> d >> t >> s;
	g << (s * t >= d ? "Yes" : "No");

	#ifdef LOCAL_TEST
		cerr << "Time taken is: " << double(clock() - z) / CLOCKS_PER_SEC << NL;
		h.close();
		g.close();
	#endif//LOCAL_TEST
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int a[2*n];
  for(int i=0;i<2*n;i++)cin>>a[i];
  sort(a,a+2*n);
  int ans=0;
  for(int i=0;i<2*n;i+=2){
    ans+=a[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<lint,lint> P;
#define rep(i, n) for (lint i = 0; i < (n); i++)
#define INF LLONG_MAX
#define MAX_V 100005
struct edge{lint to,cost;};
lint n;
vector<edge> vec[MAX_V];
lint d[MAX_V];
void dijkstra(lint k);
signed main(){
    cin>>n;
    rep(i,n-1){  
        lint a,b,c;
        cin>>a>>b>>c;
        a--;
        b--;
        vec[a].push_back({b,c});
        vec[b].push_back({a,c});
    }          
    lint q,k;
    cin>>q>>k;
    k--;
    dijkstra(k);
    rep(i,q){
        lint x,y;
        cin>>x>>y; 
        x--;
        y--;
         cout<<d[x]+d[y]<<endl;
    }
    return 0;
}
void dijkstra(lint k){
    priority_queue<P, vector<P>,greater<P> >que;
    fill(d,d+n,INF);
    d[k]=0;
    que.push(P(0,k));
    while(!que.empty()){
        P p=que.top();
        que.pop();
        lint v= p.second;
        if(d[v]<p.first)continue;
        for(lint i=0;i<vec[v].size();i++){
            edge temp=vec[v][i];
            if(d[temp.to]>d[v]+temp.cost){
                d[temp.to]=d[v]+temp.cost;
                que.push(P(d[temp.to],temp.to));
            }
        }
    }
}


Measured memory_bytes: 11120
#include<bits/stdc++.h>
using namespace std;
const int MAXN=2e5+10;
int b[MAXN];
int val[MAXN*4];
int dp[MAXN];
int build(int l,int r,int idx){
	if(l==r){
		val[idx]=1e9;
		return val[idx];
	}
	int mid=(l+r)>>1;
	return val[idx]=min(build(l,mid,idx*2),build(mid+1,r,idx*2+1));
}
int modify(int l,int r,int idx,int x,int mod){
	if(l==r)
		return val[idx]=min(val[idx],mod);
	int mid=(l+r)>>1;
	if(x<=mid)
		return val[idx]=min(val[idx],modify(l,mid,idx*2,x,mod));
	else
		return val[idx]=min(val[idx],modify(mid+1,r,idx*2+1,x,mod));
}

int query(int l,int r,int idx,int L,int R){
	if(l>R||r<L)	return 1e9;
	if(L<=l&&r<=R)	return val[idx];
	int mid=(l+r)>>1;
	return min(query(l,mid,idx*2,L,R),query(mid+1,r,idx*2+1,L,R));
}
vector<int> event[MAXN];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	int base=0;
	int cnt=0;
	for(int i=1;i<=n;i++){
		cin>>b[i];
		if(!b[i])	cnt++;
	}
	int q;
	cin>>q;
	for(int i=1,l,r;i<=q;i++){
		cin>>l>>r;
		event[l].push_back(r);
	}
	build(1,n+1,1);
	modify(1,n+1,1,1,0);
	for(int i=1;i<=n;i++){
		sort(event[i].begin(),event[i].end(),greater<int>());
		for(int r:event[i])
			modify(1,n+1,1,r+1,query(1,n+1,1,i,r));
		modify(1,n+1,1,i+1,query(1,n+1,1,i,i)+(b[i]==0?-1:1));
	}
	cout<<cnt+query(1,n+1,1,n+1,n+1)<<endl;
}


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

int main() {
  int park_time;    // 駐車時間
  int fee_per_hour; // 時間ごとの駐車料金
  int flat_fee;     // 一律料金
  
  cin >> park_time >> fee_per_hour >> flat_fee;
  
  int variable_fee = park_time * fee_per_hour;
  if (variable_fee >= flat_fee) {
  	cout << flat_fee << endl;
  } else {
  	cout << variable_fee << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int ans1,ans2;
int sumt,sumh;
int n,m;
int t[101],h[101];
int main(){
	while(1){
		cin >>n >>m;
		if(n==0&&m==0)break;
		sumt=sumh=0;
		for(int i=0;i<n;i++){
			cin >>t[i];
			sumt+=t[i];
		}
		for(int i=0;i<m;i++){
			cin >>h[i];
			sumh+=h[i];
		}
		ans1=-1;
		ans2=101;
		int a=abs(sumt-sumh);
		if((a%2)==1){
			cout <<ans1<<endl;
		}else{
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					if( ((sumt-sumh)/2)==(t[i]-h[j])){
						if(ans2>h[j]){
							ans1=t[i];
							ans2=h[j];
						}
					}
				}
			}
			if(ans1==-1){
				cout << ans1<<endl;
			}else{
				cout <<ans1 << " "<<ans2 <<endl;
			}

		}
	}
	return 0;
}

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

int main() {
	std::string a{ "AtCoder" }, c{"Contest"};
	std::string n,s;
	std::cin >>n>> s>>n;
	//std::cout << a << s << c << "\n";
	std::cout << a[0] << s[0] << c[0] << "\n";
	return 0;
}

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

int main() {
  while(1) {
    int n;
    cin >> n;
    if(n == 0) break;
    int num[10];
    fill(&num[0], &num[10], 0);
    for(int i = 0; i < n; i++) {
      int kind;
      cin >> kind;
      num[kind]++;
    }
    for(int j = 0; j < 10; j++) {
      if(num[j] == 0) cout << '-';
      for(int i = 0; i < num[j]; i++) {
	cout << '*';
      }
      cout << endl;
    }
  }
  return 0;
}

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

int main()
{
        ll X, N; cin >> X >> N;
        vector<ll> p(106, 0);
        for (int i = 0; i < N; ++i) {
                ll tmp; cin >>tmp;
                p[tmp]++;
        }


        ll ans = 1000;
        ll j = 0;
        for (int i = 0; i <= 105; ++i) {

                ll tmp = p[i];
                if (tmp == 0) {
                        ll t =  abs(X - i);
                        if (ans > t) {
                                ans = t;
                                j = i;
                        }
                }



        }
        cout << j << endl;





}


Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
#define LL long long
#define R register
char s[500];
int n,ans,now;
int main()
{
	scanf("%d",&n);cin>>s;
	for(R int i=0;i<n;i++)
	{
		if(s[i]=='I')now++;
		else now--;
		ans=max(ans,now);
	}
	cout<<ans<<endl;
	return 0;
}

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

int32_t main()
{
    int n;
    cin>>n;
    int xo=0;
    int a[n];
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        a[i]=x;
        xo^=x;
    }
    for(int i=0;i<n;i++)
    cout<<(xo^a[i])<<" ";
    cout<<endl;
    
}

Measured memory_bytes: 4416
N = int(input())
A = list(map(int,input().split()))

minus_cnt = 0
abs_sum = 0
min_abs_val = 1000000000
for i in range(N):
    abs_val = abs(A[i])
    abs_sum = abs_sum + abs_val
    if abs_val < min_abs_val:
        min_abs_val = abs_val
    if A[i] < 0:
        minus_cnt = minus_cnt + 1

B_max_sum = 0
if (minus_cnt % 2 == 0) or (min_abs_val == 0):
    B_max_sum = abs_sum
else:
    B_max_sum = abs_sum - min_abs_val * 2

print(B_max_sum)


Measured memory_bytes: 19892
def main():
    K = int(input())

    su = 0
    for a in range(1, K+1):
        for b in range(1, a+1):
            for c in range(1, b+1):
                tmp = dgcd(a, b, c)
                if a == b and b == c:
                    tmp *= 1
                elif a == b or b == c or a == c:
                    tmp *= 3
                else:
                    tmp *= 6

                su += tmp
    print(su)


def dgcd(a, b, c):
    return gcd(gcd(a, b), c)


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9200
<?php

fscanf(STDIN, '%d %d %d', $a, $b, $c);
fscanf(STDIN, '%d', $inputCount);

$minCount = 0;
while($a >= $b) {
    $b *= 2;
    $minCount++;
}
while($b >= $c) {
    $c *= 2;
    $minCount++;
}


echo $inputCount >= $minCount ? 'Yes' : 'No';


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

int main() {
	int a, b, i;
	while (cin >> a) {
		cin >> b;
		a += b;
		for (i = 0; a > 0; i++) {
			a /= 10;
		}
		cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
 
using namespace std;
 
typedef long long LL;
 
const int inf = 1 << 30;
 
int n,m;
int a[100005];
int b[200005],c[100005],cnt=0;
 
void s0(){
	int s=n;
	b[++cnt]=1;-- s;
	for(int i=1;i<=m-1;i++)b[++cnt]=a[i], s -= a[i];
	if(s==0)return ;
	-- s; s>>=1;
	
	for(int i=1;i<=s/2;i++)b[++cnt]=2;b[++cnt]=1;
	for(int i=s/2+1;i<=s;i++)b[++cnt]=2;
} // 1 a[1] .. a[m-1] 2 2 .. 2 1 2 .. 2 2
 
void s1(){
	for(int i=1;i<=a[1]/2;i++)b[++cnt]=2;
	for(int i=2;i<=m;i++)b[++cnt]=a[i];
	b[++cnt]=1;
} // 2 2 .. 2 a[2] .. a[m] 1
 
void s2(){
	b[++cnt]=a[1]+1;
	for(int i=2;i<m;i++)b[++cnt]=a[i];
	for(int i=1;i<=a[m]/2;i++)b[++cnt]=2;
} // a[1]+1 a[2] .. a[m] 2 2 .. 2 2
 
int main(){
	int od=0;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)scanf("%d",&a[i]), od += (a[i]&1);
	if(od>2)return puts("Impossible"),0;
	
	int cnt2=0;
	for(int i=1;i<=m;i++)
		if(a[i]&1)c[++ cnt2]=i;
	if(cnt2>=1)swap(a[1],a[c[1]]);
	if(cnt2>=2)swap(a[m],a[c[2]]);
	for(int i=1;i<=m;i++)printf("%d ",a[i]);puts("");
		
	if(cnt2==0)s0();
	if(cnt2==1)s1();
	if(cnt2==2)s2();
	
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;i++)printf("%d ",b[i]);puts("");
 
	return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <set>
using namespace std;
typedef long long int LL;

const int MAX = 100+24;

int main(){
    int n,m;
    while(~scanf("%d %d",&n,&m)){
        printf("%d\n", n+1-m);
    }
    return 0;
}


Measured memory_bytes: 256