akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
public class Main{
	static String[][] map;
	static int count;
	static int w, h;
	public static void main(String[] args){
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] linearr;
		String[] linearr2;
		int i;
		int j;
		
		try{
			while(null != (line=reader.readLine())){
				count = 0;
				linearr = line.split(" ");
				w = Integer.parseInt(linearr[0]);
				h = Integer.parseInt(linearr[1]);
				if(w==0 && h==0){
					break;
				}
				//??¨????????????map????????????
				map = new String[h][w];
				for(i=0; i<h; i++){
					line = reader.readLine();
					linearr2 = line.split(" ");
					System.arraycopy(linearr2, 0, map[i], 0, w);
				}
				//map?????????????????§??¢?´¢??????
				for(i=0; i<h; i++){
					for(j=0; j<w; j++){
						search(i, j, true);
					}
				}
				System.out.println(count);
			}
		}catch(IOException e){
			System.out.println(e);
		}
		
		
	}
	public static void search(int ii, int jj){
		search(ii, jj, false);
	}
	public static void search(int ii, int jj, boolean f){
		//??¨?????¢???????????? or ???
		if(ii<0 || jj<0 || ii>=h || jj>=w
		|| map[ii][jj].equals("0") ){
			return;
		}
		//??¶
		if(f){
			count ++;
		}
		//??¢?´¢????????§???
		map[ii][jj] = "0";
		//???????????????count?????\?????????
		search(ii-1, jj-1);
		search(ii-1, jj);
		search(ii-1, jj+1);
		search(ii, jj-1);
		search(ii, jj+1);
		search(ii+1, jj-1);
		search(ii+1, jj);
		search(ii+1, jj+1);
		//??????????????¨?????£??????????????¨????????§???????????£???
	}
}

Measured memory_bytes: 37936
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n,sen,hyaku,jyu,ichi;
  	cin >> n;
  	sen 	= n/1000;
  	hyaku 	= (n-sen*1000)/100;
  	jyu		= (n-sen*1000-hyaku*100)/10;
    ichi	= n-sen*1000-hyaku*100-jyu*10;
  	if(sen == hyaku && sen == jyu){
    	cout << "Yes" <<endl; 
    } else {
   	if(hyaku == jyu && hyaku == ichi){
        cout<< "Yes" << endl;
    	} else {
      	cout<< "No" << endl;
    	}
    }
}

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

long long gcd(long long a,long long b)
{
  if(a<b)swap(a,b);
  if(a%b==0)return b;
  else return gcd(b,a%b);
}

int main()
{
  long long a,b;cin>>a>>b;
  long long ans;
  ans=a*b/gcd(a,b);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	double[] data = new double[8];
	String[] input;
	while (scan.hasNext()) {
	    input = scan.nextLine().split(",");
	    for (int i = 0; i < 8; i++) {
		data[i] = Double.parseDouble(input[i]);
	    }
	    if (isConvex(data)) {
		System.out.println("NO");
	    } else {
		System.out.println("YES");
	    }
	}
    }
    static boolean isConvex (double[] data) {
	double xa = data[0];
	double ya = data[1];
	double xb = data[2];
	double yb = data[3];
	double xc = data[4];
	double yc = data[5];
	double xd = data[6];
	double yd = data[7];
	double tb = closs (xa, ya, xc, yc, xb, yb);
	double td = closs (xa, ya, xc, yc, xd, yd);
	double ta = closs (xb, yb, xd, yd, xa, ya);
	double tc = closs (xb, yb, xd, yd, xc, yc);
	if (tb * td > 0.0 || ta * tc > 0.0) {
	    return true;
	} else {
	    return false;
	}
    }
    static double closs (double xa, double ya, double xb, double yb, double xc, double yc) {
	return (xa - xb) * (yc - ya) + (ya - yb) * (xa - xc);
    }
    
}

Measured memory_bytes: 26088
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <numeric>//iota头文件
#include <stdio.h>
#include <string.h>
#include <vector>
using namespace std;

int N;
int arr[100005];
int main(){
    cin>>N;
    for(int i = 0;i<N;i++){
        scanf("%d",&arr[i]);
    }
    sort(arr,arr+N);
    if(arr[N/2-1] != arr[N/2]){
        cout<<arr[N/2] - arr[N/2-1]<<endl;
    } else{
        cout<<0<<endl;
    }
    return 0;
}

Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

c = [abs(a[i] - b[i]) for i in range(n)]

for p in range(1, 4):
    ans = 0
    for d in c:
        ans += d ** p
    print(ans ** (1 / p))

print(max(c))



Measured memory_bytes: 5648
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <fstream>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
#include <cassert>
#pragma warning (disable: 4996)
using namespace std;

using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

struct UnionFind {
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    if (n < 0)return 0;
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

ll merge_cnt(vector<ll>& a) {
    int n = a.size();
    if (n <= 1) { return 0; }

    ll cnt = 0;
    vector<ll> b(a.begin(), a.begin() + n / 2);
    vector<ll> c(a.begin() + n / 2, a.end());

    cnt += merge_cnt(b);
    cnt += merge_cnt(c);

    int ai = 0, bi = 0, ci = 0;
    while (ai < n) {
        if (bi < b.size() && (ci == c.size() || b[bi] <= c[ci])) {
            a[ai++] = b[bi++];
        }
        else {
            cnt += n / 2 - bi;
            a[ai++] = c[ci++];
        }
    }
    return cnt;
}

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({ a * c,b * c,a * d,b * d }) << endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int answer = 0;

		if (n >= 15) {
			answer = (n * 800) - ((n / 15) * 200);
		} else {
			answer = n * 800;
		}System.out.println(answer);
	}

}


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

using namespace std;

bool hate[10];

bool hate_number(int num) {
  while (num) {
    if (hate[num % 10]) {
      return 1;
    }
    num /= 10;
  }
  return 0;
}

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

  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= k; i++) {
    int cif;
    cin >> cif;
    hate[cif] = 1;
  }
  while (hate_number(n)) {
    n++;
  }
  cout << n << "\n";
}


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

int main()
{
  string a,b;
  cin >> a >> b;
  b += a;
  cout << b << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
static const int N = 100;

int main() {
	int M[N][N];
	int n, u, k, v;

	cin >> n;

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) M[i][j] = 0;
	}

	for (int i = 0; i < n; ++i) {
		cin >> u >> k;
		u--;
		for (int j = 0; j < k; ++j) {
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (j) cout << " ";
			cout << M[i][j];
		}
		cout << endl;
	}
}


Measured memory_bytes: 3100
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

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

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

int main() {
  int n, r = numeric_limits<int>::max();
  cin >> n;
  for (int a = 1; a <= n / 2; ++a) {
    int b = n - a, k = 0;
    for (char c : to_string(a)) k += c - '0';
    for (char c : to_string(b)) k += c - '0';
    chmin(r, k);
  }
  cout << r << endl;
}



Measured memory_bytes: 256
import math
n = int(input())
x = []
y = []
d = 0
for i in range(n):
    tmp1, tmp2 = map(int, input().split())
    x.append(tmp1)
    y.append(tmp2)
for i in range(n):
    for j in range(i + 1, n):
        d += math.sqrt((x[i] - x[j]) ** 2 + ((y[i] - y[j]) ** 2))
print(d*2/n)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N, M;
  cin >> N >> M;
  char mat[55][55];
  char mbt[55][55];
  for (int i = 0; i < N; i ++) {
    for (int j = 0; j < N; j ++) {
      cin >> mat[i][j];
    }
  }
  for (int i = 0; i < M; i ++) {
    for (int j = 0; j < M; j ++) {
      cin >> mbt[i][j];
    }
  }
  for (int i = 0; i <= N - M; i ++) {
    for (int j = 0; j <= N - M; j ++) {
      bool ok = true;
      for (int p = 0; p < M; p ++) {
        for (int q = 0; q < M; q ++) {
          if (mat[i + p][j + q] != mbt[p][q]) ok = false;
        }
      }
      if (ok) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


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

typedef long long int ll;
typedef string str;

int main ()
{
	// ios::sync_with_stdio(0);
 //    cin.tie(0);
 //    cout.tie(0);
	ll t,n,m,k,i,a,b,j;
	for(i=1;i<=5;i++)
	{
		cin >> a;
		if(a==0)
		b=i;
	}
	cout << b << "\n"; 
	return 0;
}

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

using namespace std;

typedef long long ll;

struct knapsack:vector<vector<ll>>
{
    ll max_value;
    
    knapsack(int n, int W) 
    { 
        vector<int> weight(n), value(n); ll v; 
        
        for(int i = 0; i < n; ++i)
            cin >> weight[i] >> value[i];
      
        resize(n+1); int W1 = W+1;
         
        for(auto&dp:*this)
            dp.resize(W1,0);
            
        for (int i = 0, j = 1; i < n; i = j++) 
	        for (int w = 1; w < W1; ++w) 
	            if ((at(j).at(w) = at(i).at(w),weight[i]) <= w) 
	                if( (v = at(i).at(w-weight[i])+value[i]) > at(j).at(w))
	                    at(j).at(w) = v; 
     
        max_value = at(n).at(W); 
    }
};

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

    int n, W; cin >> n >> W; cout << knapsack(n,W).max_value; 
}

Measured memory_bytes: 79488
#include<stdio.h>
int main(void){
  int i = 0,scan = 0;

  for(i = 0;1;i++){
    scanf("%d",&scan);
    if(scan == 0){
      break;
    }
    printf("Case %d: %d\n",i + 1,scan);
  }


  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define maxn 100002
#define met(a, b) memset(a, b, sizeof(a))
int sum = 0;
int now = 1;

void judge(string s)
{
    now = 1;
    int cnt = 0;
    int len = s.length();
    if(len < 3 )
    {
        return;
    }
    for(int i = 1; i <= len - 2; i++)
    {
        if(s[now - 1] != s[now + 1])
        {
            s.erase(now, 1);
            sum++;
            cnt++;
        }
        else now++;
    }
    if(cnt == 0)
        return;
    else
        judge(s);
}
int main()
{
    string s;
    cin >> s;
    int len = s.length();
    judge(s);
    //cout << sum << endl;
//    if(sum == 0)
//    {
//        printf("Second\n");
//        return 0;
//    }
    if(sum % 2 == 0)
    {
        printf("Second\n");
    }
    else printf("First\n");
    return 0;
}


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

int main(){
  string s;
  char bnow = 'A';
  while (cin >> s) {
    if (bnow == s.at(0)) {
      bnow = s.at(2);
      continue;
    }
    if (bnow == s.at(2)) {
      bnow = s.at(0);
      continue;
    }
  }
  cout << bnow << endl;
}



Measured memory_bytes: 3144
from collections import Counter
import sys
input = sys.stdin.readline
n=int(input())
s=[]
for _ in range(n):
    s.append(input().rstrip())
c = Counter(s)
ans=[]
max_vote = max(c.values())
for i,j in c.items():
    if j == max_vote:
        ans.append(i)
print("\n".join(sorted(ans)))

Measured memory_bytes: 35944
#include <iostream>
#include <stdio.h>
#include <vector>

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector< vector<int> > Vec(n, vector<int>(n));
		int x = n / 2;
		int y = n / 2;
		++y;
		int count = 1;
		Vec[y][x] = count;
		int square = n * n;
		while(count < square)
		{
			++count;
			++x;
			++y;
			if(x >= n)
			{
				x = 0;
			}
			if(y >= n)
			{
				y = 0;
			}
			while(Vec[y][x] != 0)
			{
				--x;
				++y;
				if(x < 0)
				{
					x = n - 1;
				}
				if(y >= n)
				{
					y = 0;
				}
			}
			Vec[y][x] = count;
		}
		for(int i = 0; i < n; ++i)
		{
			for(int j = 0; j < n; ++j)
			{
				printf("%4d", Vec[i][j]);
			}
			cout << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1248
function Main(input) {
    input = input.split("\n")[0];
    tmp = input.split(" ");
    an = Number(tmp[0])/2 + Number(tmp[1])/2;
    if(!Number.isInteger(an)) console.log("IMPOSSIBLE");
    else console.log(an);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using vector2d = vector<vector<T>>;
template<class S, class T> void map_init(map<S, T> &m, S k, T v){if(!m.count(k)) m[k] = v;}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    int N;
    cin >> N;
    vector<int> A(N * N, -1);
    vector<pair<int, int>> X;
    vector<bool> complete(N, false);
    for (int n = 1; n <= N; n++) {
        int x;
        cin >> x;
        x--;
        X.push_back({x, n});
        A[x] = n;
    }
    sort(WHOLE(X));

    int j = 0;
    for(int i = 0; i < N; i++) {
        int x, n;
        tie(x, n) = X[i];
        for(int k = n; k > 1; j++) {
            if(A[j] < 0) {
                A[j] = n;
                k--;
            } else if(j == x) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    j = 0;
    for(int i = 0; i < N; i++) {
        int x, n;
        tie(x, n) = X[i];
        for(int k = N + 1 - n; k > 1; j++) {
            if(A[j] < 0) {
                if(x < j) {
                    A[j] = n;
                    k--;
                } else {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;

    string delim = "";
    for(auto a : A) {
        cout << delim << a;
        delim = " ";
    }
    return 0;
}

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


void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

#define ll long long
#define ld long double
#define ull unsigned long long
#define ull unsigned long long
#define mod 1000000007
#define pi (3.1415926)

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

#define scd(a)  scanf("%lld",&a)
#define scdd(a,b)	scanf("%lld%lld",&a,&b)
#define scddd(a,b,c)	scanf("%lld%lld%lld",&a,&b,&c)
#define ptab(a)	printf("%lld ",a)
#define pdn(a)	printf("%lld\n",a)
#define pddn(a,b)	printf("%lld %lld\n",a,b)
#define pdddn(a,b,c)	printf("%lld %lld %lld\n",a,b,c)

#define Filein(N) freopen("N.txt", "r", stdin);
#define Fileout(N) freopen("N.txt", "w", stdout);

#define forr(n) for(ll i=0;i<n;i++)
#define rev(n) for(ll i=n-1;i>=0;i--)
#define forp(x, y) for(ll i=x;i<y;i++)
#define loop( j, k, in) for (ll i=j ; i<k ; i+=in)

#define en "\n"
#define sp " "
#define eps 1.0E-14
#define l length()
#define preci(x) cout << fixed<<setprecision(x)
#define inf LONG_LONG_MAX
#define ninf LONG_LONG_MIN

ull fastpow(ull a,ull b)
{
  ull wynik=1;
  while (b)
  {
    if (b&1)wynik=(wynik*a)%mod;
    a=(a*a)%mod;
    b>>=1;
  }
  return wynik;
}

bool odd(int n)
    {
        int x = sqrt(n);
    for (int i=2 ; i<=x ; ++i)

    {
        if(n%i == 0)return false;
    }

    return true;
    }
ll fact(int n ){

long long fact =1;

for (int i =2 ;i<=n;++i)

{
    fact*=i;
}
return fact;
}

bool prim(long long a){

long long s = sqrt(a);

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

    if (a % i == 0)return false;
}
return true;
}

ll sum (int n ){return ((n*(n+1)) / 2) ;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

bool myfunction (string i,string j) /* this function to check who is grater in
sorting strings as numbers ////////
int n;
    cin>>n;
    vector <string> arr(n);
    for(int i=0;i<n;i++)
        cin>>arr[i];


    sort(arr.begin(),arr.end(),myfunction);

    for(int i=0;i<n;i++)1
        cout<<arr[i]<<endl;
*/
{
    int n=i.length();
    int m=j.length();
    if(n==m)
        return (i<j);

    return n<m;
}
long long solve (int a, int b)
{
    return min(a,min(b , (a+b) / 3));
}

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

    long long n; cin>>n;

    cout << fastpow(n , 1) + fastpow(n , 2) + fastpow(n , 3);
}




Measured memory_bytes: 3644
n,m = map(int,input().split())
dp = [-10**5]*(n+1)
dp[0] = 0
t = [0,2,5,5,4,5,6,3,7,6]
a = set(map(int,input().split()))
for i in range(2,n+1):
  for x in a:
    if i-t[x] >= 0 and dp[i] < dp[i-t[x]] + 1:
      dp[i] = dp[i-t[x]] + 1
a = list(a)
a.sort(reverse=True)
cur = ""
idx = n
while idx:
  for x in a:
    if idx - t[x] >= 0 and dp[idx] == dp[idx-t[x]] + 1:
      cur += str(x)
      idx -= t[x]
      break
print(cur)

Measured memory_bytes: 3380
a,b,c,d,e,k=[int(input()) for i in range(6)]
print("Yay!" if abs(a-b)<=k and abs(a-c)<=k and abs(a-d)<=k and abs(a-e)<=k and abs(b-c)<=k and abs(b-d)<=k and abs(b-e)<=k and abs(c-d)<=k and abs(c-e)<=k and abs(d-e) else ":(")

Measured memory_bytes: 3064
#include <stdio.h>

void merge(int *,int,int,int);
void mergeSort(int *,int,int);

int count=0;

int main(){
  int n,A[500000],i;

    scanf("%d",&n);

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

      mergeSort(A,0,n);

      for(i=0;i<n;i++){
	if(i != 0)printf(" ");
	printf("%d",A[i]);
      }
      printf("\n%d\n",count);

      return 0;
}

void merge(int A[],int left,int mid,int right)
{
  int n1,n2,i,j,k;
  int L[500000],R[500000];
 
  n1 = mid -left;
  n2 = right -mid;
  
  for(i=0;i<n1;i++){
    L[i] = A[left + i];
  }
  for(i=0;i<n2;i++){
    R[i] = A[mid + i];
}
  L[n1] = 1000000005;
  R[n2] = 1000000005;
  i = 0;
  j = 0;
  
for(k=left;k<right;k++){
  if(L[i] <= R[j]){
    A[k] = L[i];
    i = i + 1;
}
  else{
    A[k] = R[j];
    j = j + 1;
  }
count++;
 }
}

void mergeSort(int A[],int left,int right)
{
int mid;
 if((left+1) < right){
   mid = (left + right)/2;
   mergeSort(A, left, mid);
   mergeSort(A, mid, right);
   merge(A, left, mid, right);
 }
}

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

#define INF 99999999

int n, k;
int dis[100][100];
int t, a, b, c, d, e;

signed main()
{
	while (true) {
		cin >> n >> k;
		if (n == 0 && k == 0) break;

		rep(i,n) rep(j,n) if (i == j) {
			dis[i][j] = 0;
		} else {
			dis[i][j] = INF;
		}

		rep(i,k) {
			cin >> t;
			if (t == 0) {
				cin >> a >> b;
				a--; b--;
				
				if (dis[a][b] == INF) {
					cout << -1 << endl;
				} else {
					cout << dis[a][b] << endl;
				}
			} else if (t == 1) {
				cin >> c >> d >> e;
				c--; d--;

				dis[c][d] = min(dis[c][d], e);
				dis[d][c] = min(dis[d][c], e);

				rep(i,n) rep(j,n) {
					dis[i][j] = min(dis[i][j], min(dis[i][c] + dis[c][d] + dis[d][j], dis[i][d] + dis[d][c] + dis[c][j]));
					dis[j][i] = min(dis[j][i], min(dis[j][c] + dis[c][d] + dis[d][i], dis[j][d] + dis[d][c] + dis[c][i]));
				}
			}
		}
	}
}

Measured memory_bytes: 1204
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;

int main(){
    double in;
    int ans;
    
    while(scanf("%lf",&in)!=EOF){
        ans=ceil(in*in/98);
        printf("%d\n",ans+1);
    }
    
    return 0;
}

Measured memory_bytes: 1216
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int N,Q;
ll A[100001];
ll Asum[100001]={};
ll Aksum[100001]={},Agsum[100001]={};
ll Tbigans[100001]={};
int nibutan(int low,int up,int X){
	int mid=(low+up)/2;
	if(low+1==up){
		return mid;
	}
	if(abs(A[N-mid]-X)>abs(A[N-(mid/2+mid%2)]-X)) return nibutan(low,mid,X);
	else return nibutan(mid,up,X);
}
int main(){
	scan(N);scan(Q);
	rep(i,N){
		scan(A[i]);
		Asum[i+1]=Asum[i]+A[i];
		Agsum[i+1]=Agsum[i];
		Aksum[i+1]=Aksum[i];
		if(i%2==0) Agsum[i+1]+=A[i];
		else Aksum[i+1]+=A[i];
	}
	rep1(i,N/2+N%2){
		Tbigans[i]=Asum[N]-Asum[N-i];
		if(N%2){
			Tbigans[i]+=Agsum[N-2*i];
		}
		else{
			Tbigans[i]+=Aksum[N-2*i];
		}
	}
	rep(q,Q){
		int X;
		scan(X);
		int correcti;
		if(N==2) prin(A[1]);
		else{
			correcti=(nibutan(1,N+1,X)+1)/2;
			prin(Tbigans[correcti]);
		}
	}
	return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ss(x) (int) x.size()
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define per(i, l, r) for (int i = r; l <= i; --i)
 
using ll = long long;
using namespace std;

const int mod = 924844033;
const int gen = 5;

int pt(int a, int b)
{
	int res = 1;
	while(b)
	{
		if(b & 1)
			res = (ll) res * a % mod;
		a = (ll) a * a % mod;
		b /= 2;
	}
	return res;
}

void nnt(vector <int> &a, bool inv)
{
	int n = (int)a.size();
	for(int i = 1, j = 0; n > i; ++i)
	{
		int bit = n / 2;
		while(bit & j)
		{
			j ^= bit;
			bit /= 2;
		}
		j ^= bit;
		if(j > i)
			swap(a[i], a[j]);
	}
	
	for(int len = 2; n >= len; len *= 2)
	{
		int root = pt(gen, (mod - 1) / len);
		if(inv)
			root = pt(root, mod - 2);
		for(int pocz = 0; n > pocz; pocz += len)
		{
			int W = 1;
			for(int j = 0; len  / 2 > j; ++j)
			{
				int u = a[pocz + j];
				int w = 1ll * W * a[pocz + j + len / 2] % mod;
				a[pocz + j] = (u + w < mod ? u + w : u + w - mod);
				a[pocz + j + len / 2] = (u - w >= 0 ? u - w : u - w + mod);
				W = 1ll * W * root % mod;
			}
		}
	}
	int odw = pt(n, mod - 2);
	if(inv)
	{
		for(auto &it: a)
			it = (ll) it * odw % mod;
	}	
}

vector <int> mul(vector <int> a, vector <int> b) {
	int p = 0;
	while(ss(a) + ss(b) >= (1 << p))
		p++;
	a.resize((1 << p));
	b.resize((1 << p));
	nnt(a, 0);
	nnt(b, 0);
	for(int i = 0; i < (1 << p); ++i)
		a[i] = 1ll * a[i] * b[i] % mod;
	nnt(a, 1);
	return a;
}

const int N = 2e5 + 100;

int n, fac[N], rev[N], siz[N];
vector <int> G[N];

int dfs(int v, int p) {
	siz[v] = 1;
	for (auto u : G[v])
		if (u != p)
			siz[v] += dfs(u, v);
	return siz[v];
}

int main() {
	fac[0] = rev[0] = 1;
	rep(i, 1, N - 1) {
		fac[i] = 1LL * fac[i - 1] * i % mod;
		rev[i] = pt(fac[i], mod - 2);
	}
	scanf ("%d", &n);
	rep(i, 2, n) {
		int a, b;
		scanf ("%d%d", &a, &b);
		G[a].pb(b);
		G[b].pb(a);
	}
	dfs(1, 0);
	vector <int> A(n + 1, 0);
	rep(i, 2, n) {
		A[siz[i]]++;
		A[n - siz[i]]++;
	}
	rep(i, 0, n)
		A[i] = 1LL * fac[i] * A[i] % mod;
	vector <int> B(n + 1, 0);
	rep(i, 0, n)
		B[n - i] = rev[i];
	vector <int> C = mul(A, B);
	rep(i, 1, n) 
		printf ("%lld\n", (1LL * n * fac[n] % mod * rev[n - i] % mod * rev[i] % mod - 1LL * rev[i] * C[n + i] % mod + mod) % mod);
	return 0;
}



Measured memory_bytes: 33536
#include<bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
 
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is >> a.first >> a.second; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os << a.first << " "<<a.second; }
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; }
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; }
  
#define ForEach(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)
#define ALL(v) (v).begin(), (v).end()
#define UNQ(s) { sort(ALL(s)); (s).erase( unique( ALL(s)), (s).end());}
#define fr first
#define sc second
  
typedef pair< int , int > Pi;
typedef pair< bool, Pi > Pii;
  
typedef long long int64;
 
int UF[40000];
int BF[40000];
int chg[400000];
int siz;
int FIND(int a){
	if(UF[a]<0)return a;
	return FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);
	b=FIND(b);
	if(a==b)return;
	if(UF[a]>UF[b])swap(a,b);
	chg[siz++]=a;
	chg[siz++]=b;
	UF[a]+=UF[b];
	UF[b]=a;
}

const int SQR = 200;
set< Pi > T; // 変化があった辺
set< Pi > S; // 存在する辺
 
int main(){
  int n, Q;
  int x[40000], y[40000], z[40000];
 
  scanf("%d %d", &n, &Q);
  for(int i = 0; i < Q; i++){
    scanf("%d %d %d", &x[i], &y[i], &z[i]);
  }
  for(int i = 0; i < Q; i++){
    if(i % SQR == 0){
      T.clear();
      for(int j = 0; j < n; ++j) UF[j] = BF[j] = -1;
      for(int j = 0; j < SQR && i + j < Q; j++){
        if(x[i + j] != 3){
          T.insert( make_pair( y[i + j], z[i + j]));
          if(x[i + j] == 1) S.insert( make_pair( y[i + j], z[i + j]));
          else if(x[i + j] == 2) S.erase( make_pair( y[i + j], z[i + j]));
        }
      }
      siz = 0;
      ForEach( it, S){
        if(T.find(*it) == T.end()){ // 以前に追加されていて変化がない辺を結合
          UNION( it -> first, it -> second);
        }
      }
      for(int j = 0; j < n; ++j) BF[j] = UF[j];
    }
    if(x[i] == 3){
      set< Pi > u;
      int N = i / SQR * SQR;
      for(int k = 0; k < i % SQR; k++){ // それ以前
        if(x[k + N] == 1) u.insert( make_pair( y[N + k], z[N + k]));
        else if(x[k + N] == 2) u.erase( make_pair( y[N + k], z[N + k]));
      }
      for(int k = min( SQR - 1, Q - N - 1); k > i % SQR; k--){ // それ以後
        if(x[k + N] == 1) u.erase( make_pair( y[N + k], z[N + k]));
        else if(x[k + N] == 2) u.insert( make_pair( y[N + k], z[N + k]));    
      }
      siz = 0;
      ForEach( it, u){
        UNION( it -> first, it -> second);
      }
      puts(FIND(y[i]) == FIND(z[i]) ? "YES" : "NO");
      for(int j = 0; j < siz; j++) UF[chg[j]] = BF[chg[j]];
    }
  }
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
//#define MOD 1000000007
#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false

int main(void){
    char a;
    cin >> a;
    if('A'<=a&&a<='Z'){
        cout << "A";
    }else{
        cout << "a";
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3632
a,b=map(int,input().split())
x=(a+b)/2
# print(x*10)
if x*10%10 == 0:
    answer = (a+b)//2
elif 1 <= x*10%10 and x*10%10 < 5:
    answer = (a+b)//2
else:
    answer = (a+b)//2 + 1

print(answer)

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

double dp[1000][1000];
int N,T,L,B,A;
int x[1000];

int main(){
	while(true){
		for(int i=0;i<1000;i++){for(int j=0;j<1000;j++){dp[i][j]=0.0;}}
		for(int i=0;i<1000;i++){x[i]=0;}
		cin>>N>>T>>L>>B;
		if(N==0 && T==0 && L==0 && B==0){break;}
		for(int i=0;i<L;i++){cin>>A;x[A]=1;}
		for(int i=0;i<B;i++){cin>>A;x[A]=2;}
		dp[0][0]=1.0;
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				for(int k=1;k<=6;k++){
					int masu=j+k;
					if(masu>N){masu=N*2-masu;}
					if(x[masu]==0){dp[i+1][masu]+=dp[i][j]*1/6;}
					if(x[masu]==1){dp[i+2][masu]+=dp[i][j]*1/6;}
					if(x[masu]==2){dp[i+1][0]+=dp[i][j]*1/6;}
				}
			}
		}
		double sum=0.0;
		for(int i=0;i<=T;i++){sum+=dp[i][N];}
		cout<<fixed<<setprecision(15)<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 9052
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define prique priority_queue
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.1415926
#define coutdb cout<<fixed<<setprecision(15)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef int_fast64_t ll;
#define int int_fast64_t

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  string S, T; cin >> S >> T;
  int ans = 0;
  REP(i, 3) if(S[i]==T[i]) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	ll j=1,k;
	for(ll i=1;i*i<=n;++i){
		if(n%i==0) j=max(j,i);
	}
	k=n/j;
	cout<<j-1+k-1<<"\n";
	return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 m, nmin, nmax;
	while (cin >> m >> nmin >> nmax && m+nmin+nmax) {
	  vector<int64> P(m);
	  REP(i, m) {
	    cin >> P[i];
	  }

	  sort(all(P), greater<int64>());
	  int64 res = -1, diff = -1;
	  FOR(i, nmin-1, nmax) {
	    if (diff <= P[i]-P[i+1]) {
	      res = i;
	      diff = P[i]-P[i+1];
	    }
	  }
	  cout << res+1 << endl;
	}
}



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

int check_ab(char *s, int len) {
    int count = 0;
    int flag = 0;
    for (int i=0; i<len; i++) {
        if (s[i] == 'A') flag = 1;
        else if (s[i] == 'B') {
            if (flag) {
                count++;
                flag = 0;
            }
        }
        else flag = 0;
    }
    return count;
}

int main() {
    int n = 0;
    scanf("%d\n", &n);
    int ans = 0;
    int count1=0, count2=0, count3=0;
    for (int i=0; i<n; i++) {
        char s[12];
        int len = 0;
        fgets(s, 12, stdin);
        if (s[strlen(s)-1] != '\n') len = strlen(s);
        else len = strlen(s) - 1;
        ans += check_ab(s, len);
        if (s[0] == 'B') {
            if (s[len-1] == 'A') count1++;
            else count3++;
        }
        else if (s[len-1] == 'A') count2++;
    }
    int a = count1 + count2;
    int b = count1 + count3;
    if (a > b) printf("%d\n", ans + b);
    else if (b > a) printf("%d\n", ans + a);
    else {
        if (a == 0) printf("%d\n", ans);
        else if (count2 == 0) printf("%d\n", count1 - 1 + ans);
        else printf("%d\n", ans + a );
    }
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
typedef long long ll;
bool isPrime(ll n);
int count(ll n);
int main(void)
{
	ll n;
	scanf("%lld", &n);
	if (isPrime(n))
		printf("%d\n", count(n));
	else
	{
		for (int i = sqrt(n); i >= 1; i--)
			if (n % i == 0) {
				int a = count(i), b = count(n / i);
				printf("%d\n", a > b ? a : b);
				break;
			}
	}
	return 0;
}
bool isPrime(ll n)
{
	if (n < 5)return n == 2 || n == 3 ? true : false;
	if ((n + 1) % 6 != 0 && (n - 1) % 6 != 0)return false;
	if (n % 2 == 0)return false;
	for (int i = 3; i <= sqrt(n); i += 2)
		if (n % i == 0)
			return false;
	return true;
}
int count(ll n)
{
	int cnt = 0;
	while (n)
		n /= 10, cnt++;
	return cnt;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define fi first
#define se second
#define pt(num) cout << num << "\n"
#define mCalc(a, s, b) (a)=((a)s(b))%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll H, W, K;

ll valid(ll i) {
    ll j;
    ll r=0;
    for(j=0; j<W-1; j++) {
        if(r==1 && i>>j&1) return 0;
        if(i>>j&1) r=1;
        else r=0;
    }
    return 1;
}

int main(void) {
    cin >> H >> W >> K;
    K--;
    ll i, j, k;
    ll dp[111][11]={};
    
    dp[0][0]=1;
    for(i=0; i<H; i++) {
        for(j=0; j<W; j++) {
            for(k=0; k<1<<(W-1); k++) {
                if(!valid(k)) continue;
                if(!(k>>(j-1)&1) && !(k>>j&1)) mCalc(dp[i+1][j], +, dp[i][j]);
                if(k>>(j-1)&1) mCalc(dp[i+1][j-1], +, dp[i][j]);
                if(k>>j&1) mCalc(dp[i+1][j+1], +, dp[i][j]);
            }
        }
    }
        
    pt(dp[H][K]);
    
}




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

typedef long long ll;

using namespace std;

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

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    string s;

    cin >> s;

    for(int i=0; i<s.size(); i++)
    {
        cout << "x";
    }

    printf("\n");

}

Measured memory_bytes: 3600
program probC
  implicit none
  integer :: a(0:100010)
  integer i,ans1,n,del1,del2

  read(*,*) n
!  allocate(a(0:n+1))
  a=0
  read(*,*) a(1:n)

  ans1=0
  do i =1,n+1
     ans1 = ans1 + abs(a(i-1)-a(i))
  end do

  do i = 1,n
     del1 = abs(a(i-1)-a(i))+abs(a(i)-a(i+1))
     del2 = abs(a(i-1)-a(i+1))

     write(*,*) ans1+del2-del1
  end do
  
end program probC


Measured memory_bytes: 2432
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
#define ll long long
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int s;
    cin >> s;
    int h = s / 3600, m = (s%3600) / 60;
    s %= 60;
    cout << h <<':' << m << ':' << s << endl;
	return 0;
}


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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}


inline int addmod(int x ,int y){return (x%mod + y%mod)%mod;}
inline int submod(int x ,int y){return (x%mod - y%mod + mod)%mod;}
inline int mulmod(int x ,int y){return (x%mod *1LL* y%mod)%mod;}
inline int nextSubMask(int i , int mask) {return (i-1)&mask;} /// returns next smallest submask

void we_r_done(){cout<<"NO"; exit(0);}

void debug(bool ok , string mssg)
{
    if(ok)return;
    cout<<mssg;
    exit(0);
}

int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    FastIO;

    int n;
    cin>>n;

    double a[n];

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



    sort(a,a+n);

    long double ans = a[0]+a[1] , tp = 2;

    for(int i=2; i<n; i++ , tp *= 2){
        ans += a[i]*tp;
    }
    cout<<ans/tp;


    return 0;

}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

struct Rest
{
    char nm[18];
    int p;
    int id;
};

Rest r[108];


bool cmp(Rest x, Rest y)
{
    int c = strcmp(x.nm, y.nm);
    if(c < 0)
        return true;
    else if(c > 0)
        return false;
    else
    {
        if(x.p > y.p)
            return true;
        else
            return false;
    }
}

int main()
{
    //freopen("1.in", "r", stdin);
    //freopen("1.out", "w", stdout);
    
    int n, i;
    cin >> n;
    for(i = 1; i <= n; i++)
    {
        cin >> r[i].nm;
        cin >> r[i].p;
        r[i].id = i;
    }
    
    //r[1]~r[n]
    sort(r+1, r+n+1, cmp);
    
    for(i = 1; i <= n; i++)
        cout << r[i].id << endl;
    
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a,b,c,result int
	fmt.Scan(&a,&b,&c)
	
	result = 0
	if (a - b) >= c {
		result = 0
	} else {	// (a - b) < c
		result = c - (a - b)
	}
	fmt.Printf("%d", result)
}

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

int main() {
  
  string A, B; cin >> A >> B;
  
  if (A == B) {
    cout << "EQUAL" << endl;
    return 0;
  }
  
  int lengthA = A.size(); int lengthB = B.size();
  
  if (lengthA < lengthB) {
    cout << "LESS" << endl;
    return 0;
  }
  
  if (lengthB < lengthA) {
    cout << "GREATER" << endl;
    return 0;
  }
  
  for (int i = 0; i < lengthA; i++) {
    
    if (A.at(i) < B.at(i)) {
      cout << "LESS" << endl;
      return 0;
    }
    
    if (B.at(i) < A.at(i)) {
      cout << "GREATER" << endl;
      return 0;
    }
    
  }
  
}

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

int main(void){
    long long N,K; cin >> N >> K;
    long long id=0;
    vector<pair<int, int>> pairs(N);
    for(int i=0; i<N; i++){
        int a,b; scanf("%d %d", &a, &b);
        pairs[i] = make_pair(a,b);
    }

    sort(pairs.begin(), pairs.end());
    for(int i=0; i<N; i++){
        id+=pairs[i].second;
        if(id>=K){
            cout << pairs[i].first << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int x, i=0;
    while(1)
    {
        scanf("%d", &x);
        if(x == 0) break;
        i++;
        printf("Case %d: %d\n", i, x);
    }
    return 0;
}



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

int main() {
 int s;
 cin >> s;
 int s1 = s / 100, s2 = (s - 100 * s1) / 10, s3 = s - s1 * 100 - s2 * 10;
 cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>

using namespace std;

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

    vector<set<int>> s(n, set<int>());
    for (int i = 0; i < k; i++) {
        int d;
        cin >> d;

        for (int j = 0; j < d; j++) {
            int a;
            cin >> a;
            s[a - 1].insert(i);
        }
    }

    int res = 0;
    for (int i = 0; i < n; i++) {
        if (s[i].size() == 0) {
            res++;
        }
    }

    cout << res << endl;
}


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

int main(){
  string s, t;
  int cnt = 0;
  cin >> s >> t;
  for(int i = 0; i < 3; ++i){
    if(s[i] == t[i]){
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


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

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define ll long long
#define OK puts("OK")
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 1e5 + 5;

int dp[N], n, m, x, y, u[N], ans;

vector < vector <int> > g;

void dfs (int v)
{
    u[v] = 1;

    for (auto to : g[v])
    {
        if (!u[to])
            dfs(to);

        dp[v] = max( dp[v], dp[to] + 1 );
    }
    ans = max(ans, dp[v]);
}

main()
{
    cin >> n >> m;
    g.resize(n + 1);

    for (int i = 1; i <= m; i++)
    {
        scanf("%d%d", &x, &y);
        g[x].pb(y);
    }
    for (int i = 1; i <= n; i++)
    {
        if (u[i]) continue;
        dfs(i);
    }
    cout << ans << endl;
}




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

int dp[10][2][10][10][10];

int main()
{
	string S;
	cin >> S;
	int n = S.size();
	for (int i = 0; i < n; i++) {
		dp[i][i != 0][0][0][0] += 1;
		for (int b = 0; b < 2; b++) {
			int lim = b ? 9 : (S[i] - '0');
			if (3 <= lim) {
				int t = b || 3 < lim;
				for (int j = 0; j + 1 < 10; j++) {
					for (int k = 0; k < 10; k++) {
						for (int l = 0; l < 10; l++) {
							dp[i + 1][t][j + 1][k][l] += dp[i][b][j][k][l];
						}
					}
				}
			}
			if (5 <= lim) {
				int t = b || 5 < lim;
				for (int j = 0; j < 10; j++) {
					for (int k = 0; k + 1 < 10; k++) {
						for (int l = 0; l < 10; l++) {
							dp[i + 1][t][j][k + 1][l] += dp[i][b][j][k][l];
						}
					}
				}
			}
			if (7 <= lim) {
				int t = b || 7 < lim;
				for (int j = 0; j < 10; j++) {
					for (int k = 0; k < 10; k++) {
						for (int l = 0; l + 1 < 10; l++) {
							dp[i + 1][t][j][k][l + 1] += dp[i][b][j][k][l];
						}
					}
				}
			}
		}
	}
	int res = 0;
	for (int i = 0; i < 2; i++) {
		for (int j = 1; j <= 9; j++) {
			for (int k = 1; k <= 9; k++) {
				for (int l = 1; l <= 9; l++) {
					res += dp[n][i][j][k][l];
				}
			}
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n;
ll t[1005],a[1005];
ll T,A;
long long gcd(long long a,long long b){
      if(b%a==0) return a;
      else return gcd(b%a,a);
  }
int main(void){
    cin>>n;
    cin>>T>>A;
    for(ll i=1;i<n;i++){
        cin>>t[i]>>a[i];
        ll G=gcd(t[i],a[i]);
        t[i]=t[i]/G;
        a[i]=a[i]/G;
        ll l=0,r=1000000000000000000/max(a[i],t[i]),m=(l+r)/2;
        while(r-l>1){
            if(t[i]*m>=T&&a[i]*m>=A){
                r=m;
                m=(l+r)/2;
            }else{
                l=m;
                m=(l+r)/2;
            }
        }
        T=t[i]*r;
        A=a[i]*r;
        //cout<<T<<" "<<A<<endl;
    }
    cout<<A+T<<endl;
    
    
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#define ll long long int
#define lim 100010
#define mod 1e9+7
#define INF 1e9
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define ABS(x) ((x)>0?(x):-(x))

typedef struct{
	int ind,num;
}data;
int comp(const void *a,const void *b){return ((data*)b)->num - ((data*)a)->num;}

int compare(const void *a,const void *b){return *(int*)a-*(int*)b;}

int main(void){
	int n;
	scanf("%d",&n);
	int p[n];
	for(int i=0;i<n;i++)scanf("%d",&p[i]);
	bool can=true;
	bool a=false;
	int x;
	for(int i=0;i<n;i++){
		if(p[i]==i+1)continue;
		if(a==false){
			a=true;
			can = false;
			x=p[i];
		}else{
			if(x==i+1)can=true;
			else{
				can = false;
				break;
			}
		}
		
	}
	if(can)printf("YES");
	else printf("NO");
	return 0;
}

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

int a[100001];
int main(){
    ll n,ai;
    cin>>n;
    cin>>ai;
    a[0]=ai;
    ll sum,sum1;
    ll ans=0,ans1=0;
    if(ai==0) ans=1,ans1=1,sum=1,sum1=-1;
    else if(ai>0) ans1=ai+1,sum=ai,sum1=-1;
    else ans=-ai+1,sum=1,sum1=ai;
    FOR(i,1,n){
        cin>>ai;a[i]=ai;
        if(sum>0){
            if(sum<-ai) sum+=ai;
            else{
                ans+=ai+sum+1;
                sum=-1;
            }
        }
        else{
            if(-sum<ai) sum+=ai;
            else{
                ans+=-sum+1-ai;
                sum=1;
            }
        }
    }
    FOR(i,1,n){
        ai=a[i];
        if(sum1>0){
            if(sum1<-ai) sum1+=ai;
            else{
                ans1+=ai+sum1+1;
                sum1=-1;
            }
        }
        else{
            if(-sum1<ai) sum1+=ai;
            else{
                ans1+=-sum1+1-ai;
                sum1=1;
            }
        }
    }
    cout<<min(ans,ans1)<<endl;
    return 0;
}

Measured memory_bytes: 640