akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
#include<vector>
#include<queue>
#include<functional>
using namespace std;
typedef pair<int,int> P;

int N,M,K;		//町数、道の数、店舗数
struct NODE{
	vector<int> cost,list;
	int minest;	//頂点から店への最短距離
}MISE[3000];

void Ini(int *a,int index,int num){
	for(int i = 0;i < index;i++){
		a[i] = num;
	}
}
void Dijkstra(int left){
	priority_queue<P,vector<P>,greater<P> > que;
	int done[3000],DEFINEED = 0;
	int nowcost[3000];
	P edge;
	Ini(done,N,-1);
	Ini(nowcost,N,500000000);
	que.push(P(0,left));
	while(DEFINEED < N && !que.empty()){
		edge = que.top();
		que.pop();
		if(done[edge.second] >= 0)
			continue;
		DEFINEED++;
		done[edge.second] = edge.first;
		//確定した頂点から枝を出す
		int lsize;
		lsize = MISE[edge.second].list.size();
		for(int i = 0;i < lsize;i++){
			if(done[MISE[edge.second].list[i]] == -1 && nowcost[MISE[edge.second].list[i]] > edge.first+MISE[edge.second].cost[i]){
				nowcost[MISE[edge.second].list[i]] = edge.first+MISE[edge.second].cost[i];
				que.push(P(nowcost[MISE[edge.second].list[i]],MISE[edge.second].list[i]));
			}
		}
	}
	for(int  i = 0;i < N;i++){
		if(MISE[i].minest > done[i] && done[i] != -1)
			MISE[i].minest = done[i];
	}
}
int main(){
	int i,a,b,c;
	int Mplace;
	cin >> N >> M >> K;
	for(i = 0;i < N;i++){
		MISE[i].minest = 500000000;
	}
	for(i = 0;i < M;i++){
		cin >> a >> b >> c;
		a--;b--;
		//隣接リスト作成。道の生成による影響は2ノード間にのみ作用する。
		MISE[a].list.push_back(b);
		MISE[a].cost.push_back(c);
		MISE[b].list.push_back(a);
		MISE[b].cost.push_back(c);
	}
	for(i = 0;i < K;i++){
		cin >> Mplace;
		Mplace--;
		Dijkstra(Mplace);
	}
	double D_length;
	int I_length,I_Mlength = 0;
	for(i = 0;i < N;i++){
		//枝の間が一番距離が長くなりそう
		int lsize;
		lsize = MISE[i].list.size();
		for(int j = 0;j < lsize;j++){
			D_length = (double)MISE[i].cost[j]/2.0;
			D_length += (MISE[i].minest+MISE[MISE[i].list[j]].minest)/2.0;
			if(D_length - (int)D_length == 0)
				I_length = (int)D_length;
			else
				I_length = (int)D_length+1;
			if(I_Mlength < I_length)
				I_Mlength = I_length;
		}
	}
	cout << I_Mlength << endl;
	return 0;
}

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

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

typedef struct
{
	int y;
	int x;
	char type;
} STATE;

char grid[256][256];

void init()
{
	memset(grid, 0, sizeof(grid));
}

void search(int ny, int nx)
{
	queue<STATE> que;
	que.push({ny, nx, grid[ny][nx]});
	while (!que.empty()){
		STATE st = que.front(); que.pop();
		if (grid[st.y][st.x] == 0) continue;
		grid[st.y][st.x] = 0;
		
		for (int k = 0; k < 4; k++){
			int ty = st.y + dy[k];
			int tx = st.x + dx[k];
			
			if (grid[ty][tx] == st.type){
				que.push({ty, tx, st.type});
			}
		}
	}
}

int main()
{
	int h, w;
	while (scanf("%d %d", &h, &w), h + w){
		init();
		
		for (int i = 1; i <= h; i++){
			for (int j = 1; j <= w; j++){
				scanf(" %c", &grid[i][j]);
			}
		}
		
		int cnt = 0;
		for (int i = 1; i <= h; i++){
			for (int j = 1; j <= w; j++){
				if (grid[i][j] != 0){
					search(i, j);
					cnt++;
				}
			}
		}
		
		printf("%d\n", cnt);
	}
	
	return 0;
}

Measured memory_bytes: 1276
Q = int(input())
xdn = [[int(i) for i in input().split()] for _ in range(Q)]

MOD = 10 ** 6 + 3

fact = [0] * MOD
inv = [0] * MOD
fact[0] = 1
inv[0] = pow(fact[0], MOD - 2, MOD)

for i in range(1, MOD) :
    fact[i] = (i * fact[i - 1]) % MOD
    inv[i] = pow(fact[i], MOD - 2, MOD)

for x, d, n in xdn :
    if x == 0 :
        print(0)
        continue
        
    if d == 0 :
        print(pow(x, n, MOD))
        continue
    
    xd = (x * pow(d, MOD - 2, MOD)) % MOD
    if xd + n - 1 >= MOD :
        print(0)
        continue
        
    print((fact[xd + n - 1] * inv[xd - 1] * pow(d, n, MOD)) % MOD)

Measured memory_bytes: 84184
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int 
#define ar array
#define pb push_back
#define fi(a,b) for(int i=a;i<(b);i++)
#define fj(a,b) for(int j=a;j<(b);j++)
#define fk(a,b) for(int k=a;k<(b);k++)
#define lb lower_bound
#define ub upper_bound
//hash base 177013



int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	//ll testcase;
	//cin>>testcase;
	//while(testcase--)
	{
		ll ans=0;
		int n;
		cin>>n;
		int a[n];
		fi(0,n) cin>>a[i];
		fi(0,n-1)
		{
			if(a[i+1]<a[i])
			{
				ans+=abs(a[i+1]-a[i]);
				a[i+1]+=abs(a[i+1]-a[i]);
			}
		}
		cout<<ans<<'\n';
		
	}
}


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

#define MAX 100005
#define NIL -1

struct Node { 
    int parent, left, right; };
struct Node T[MAX];
int d[MAX];

Node gNode[MAX];
int gDepth[MAX];

int getDepth(int u) {
    int d = 0;
    while (T[u].parent != -1) {
        u = T[u].parent;
        d++;
    }
    return d;
}

void print(int node){
    cout << "node " << node << ": ";
    cout << "parent = " << gNode[node].parent << ", ";
    cout << "depth = " << gDepth[node] << ", ";
    
    if(gNode[node].parent == NIL) cout << "root, ";
    else if(gNode[node].left == NIL)cout << "leaf, ";
    else cout << "internal node, ";
    
    cout << "[";
    
    for(int i = 0,left = gNode[node].left;left != NIL;++i,left = gNode[left].right){
        if(i) cout << ", ";
        cout << left;
    }
    cout << "]" << endl;
}

// 再帰的に深さを求める
void rec(int node ,int parent){
    gDepth[node] = parent;
    if(gNode[node].right != NIL){
        // 右の兄弟に同じ深さを設定
        rec(gNode[node].right,parent);
    }
    if(gNode[node].left != NIL){
        // 最も左の子に自分の深さ+1を設定
        rec(gNode[node].left,parent + 1);
    }
}


int main(){
    int nodeNum,nodeIndex,node,left,root,n;
    cin >> n;
    // 1.初期化
    for(int i = 0;i < n;++i){
        gNode[i].parent = gNode[i].left = gNode[i].right = NIL;
    }
    // 2.nodeに代入していく
    for(int i = 0;i < n;++i){
        cin >> nodeIndex >> nodeNum;
        for(int j = 0;j < nodeNum;++j){
            cin >> node;
            // 初期値はleft
            if(j == 0){
                gNode[nodeIndex].left = node;
            }
            else{
                gNode[left].right = node;
            }
            left = node;
            gNode[node].parent = nodeIndex;
        }
    }
    
    // 3.rootを探す
    for(int i = 0;i < n;++i){
        if(gNode[i].parent == NIL){
            root = i;
        }
    }
    
    // 根からはじめて深さを代入する
    rec(root,0);
    
    // 4.nodeのindexごとに出力する
    for(int i = 0;i < n;++i){
        print(i);
    }
    return 0;
}



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

using namespace std;

int main() {

  int Tc; cin >> Tc;
  while(Tc--) {
    bool f = 0;
    string S; cin >> S;
    while(S.size() > 1) {
      S = to_string(S[0] + S[1] - 2 * '0') + S.substr(2);
      f ^= 1;
    }
    cout << vector<string>{"Audrey", "Fabre"}[f] << " wins.\n";
  }
  
  return 0;
}

Measured memory_bytes: 3068
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
	char a[7],b[4];
	scanf("%s %s",a,b);
	strcat(a,b);
	int c;
	sscanf(a,"%d",&c);
	int c1=sqrt(c);
	float c2=sqrt(c);
	if(c1==c2)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
	ll N, A, B;
	cin >> N >> A >> B;

	ll ans = 0;
	if (N == 1)
	{
		if (A == B)
		{
			ans = 1;
		}
	}
	else
	{
		ans = (N - 2)*(B - A) + 1;
	}
	cout << std::max(ans, (ll)0) << endl;
	return 0;
}

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

signed main() {
    int n, bef = 10;
    string ans = "Good";
    
    cin >> n;
    for ( int i = 0; i < 4; i++ ) {
        if ( n % 10 == bef ) {
            ans = "Bad";
        }
        bef = n % 10;
        n = n / 10;
    }
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
 
#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// typedef
typedef std::vector<int> VI;
typedef std::vector<VI> VII;
typedef std::vector<std::string> VS;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

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

int MaxNotFilled(std::vector<bool> &fill) {
  int max = -1;
  REP(i, SIZE(fill)) {
    if (!fill.at(i) && i > max) {
      max = i;
    }
  }
  return max;
}

void search(int d, int g, VI p, VI c,
            std::vector<bool> &fill, int points, int num,
            int &min) {
  int max_notfilled = MaxNotFilled(fill);
  if (points >= g) {
    if (num < min) {
      min = num;
    }
    return;
  }
  // if all the problems are filled
  if (max_notfilled != -1) {
    /*
    check(points);
    check(g);
    check(max_notfilled);
    check(points + 100 * (max_notfilled+1) * (p.at(max_notfilled)-1));
    */
    if (points + 100 * (max_notfilled+1) * (p.at(max_notfilled)-1) >= g) {
      if (points < g) {
        if (num + (int)std::ceil(1.*(g - points) / (100 * (max_notfilled+1))) < min) {
          min = num + (int)std::ceil(1.*(g - points) / (100 * (max_notfilled+1)));
        }
      } else {
        if (num < min) {
          min = num;
        }
      }
    }
  }
  
  REP(i, d) {
    if (!fill.at(i)) {
      // check(i);
      fill.at(i) = true;
      search(d, g, p, c, fill, points + 100*(i+1) * p.at(i) + c.at(i), num + p.at(i), min);
      fill.at(i) = false;
    }
  }
}

void solve() {
  int d, g;
  std::cin >> d >> g;
  VI p(d), c(d);
  std::vector<bool> fill(d, false);
  
  int sum = 0;
  REP(i, d) {
    std::cin >> p.at(i) >> c.at(i);
    sum += p.at(i);
  }
  
  int min = sum;
  search(d, g, p, c, fill, 0, 0, min);
  
  cout(min);
}

Measured memory_bytes: 256
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

n = int(input())
a = [int(i) for i in input().split(" ")]

for i in reversed(range(1, n)):
    a[i - 1] = gcd(a[i], a[i - 1])

print(a[0])

Measured memory_bytes: 14252
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << '\n'; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << ' ' << val;
            return *this;
        }
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val;
        return {};
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
                first = false;
            }
            cout << x;
        }
    }
};

int main()
{
    input in;
    output out;

    int A, B, C;
    in >> A, B, C;
    if (A + B + C < 22)
        out << "win";
    else
        out << "bust";

    return 0;
}


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

bool able_check(long L, long* A, long N, long K);

int main(void){
  long N,K;
  cin>>N>>K;
  long* A = (long*)malloc(sizeof(long)*N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  long min=1;
  long max=1000000010;
  while(max-min>5){
    long mid=(min+max)/2;
    if(able_check(mid,A,N,K)){
      max=mid;
    }
    else{
      min=mid;
    }
  }
  for(long i=min;i<=max;i++){
    if(able_check(i,A,N,K)){
      cout<<i<<endl;
      break;
    }
  }
  return 0;
}

bool able_check(long L, long* A, long N, long K){
  long retval=0;
  for(int i=0;i<N;i++){
    if(A[i]%L==0){
      retval+=A[i]/L-1;
    }
    else{
      retval+=A[i]/L;
    }
  }
  return retval<=K;
}


Measured memory_bytes: 4680
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		n = scanner.nextInt();
		int q = scanner.nextInt();
		int[] st = new int[n];
		for (int i = 0; i < n; i++)
			st[i] = scanner.nextInt();
		int[] s = Arrays.copyOf(st, n);
		Arrays.sort(s);
		List<Integer> list = new LinkedList<Integer>();
		while (q-- > 0) {
			char query = scanner.next().charAt(0);
			int x = scanner.nextInt();
			if (query == 'A') {
				list.add(st[x - 1]);
				Collections.sort(list);
			} else if (query == 'R') {
				list.remove(Integer.valueOf(st[x - 1]));
			} else {
				int r = INF;
				int l = 0;
				while (r != l) {
					int mid = (r + l) / 2;
					int pre = 0;
					int BAN = 0;
					for (int i : list) {
						int p = lower(s, i - mid);
						BAN += Math.max(p - pre, 0);
						pre = upper(s, i);
					}
					BAN += n - pre;
					if (BAN <= x)
						r = mid;
					else
						l = mid + 1;
				}
				System.out.println(l != INF ? l : "NA");
			}
		}
	}

	private int lower(int[] s, int i) {
		int p = Arrays.binarySearch(s, i);
		if (p < 0) {
			p = p * -1 - 1;
		} else {
			for (int j = p - 1; j >= 0; j--) {
				if (s[j] != i)
					break;
				p--;
			}
		}
		return p;
	}

	private int upper(int[] s, int i) {
		int pre = Arrays.binarySearch(s, i);
		for (int j = pre + 1; j < n; j++) {
			if (s[j] != i)
				break;
			pre++;
		}

		return pre + 1;
	}

	int INF = 1000000001;
	int n;
}

Measured memory_bytes: 303476
#include<bits/stdc++.h>
const int M=1e9+7;// M=1e9+7;//M=300000;//
const int N=1e5+5;
typedef long long int ll;
using namespace std;
 
ll cnt(0),n,m,x,y,i,j,temp,t,k,ans(0),sum(0),mn(M),mx(-9e9);

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin>>s;
	cout<<(s=="ABC"?"ARC":"ABC");
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
typedef pair<int, int> pint;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    int  ans=1;
    if(s=="SSS") ans=0;
    else if (s=="SSR") ans=1;
    else if (s=="SRR") ans=2;
    else if(s=="RRR") ans=3;
    else if (s=="RRS") ans=2;
    else if(s=="RSS") ans=1;
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

int N;
vector< vector<ll> > graph;
vector<ll> C;

vector<ll> node;
ll c_ind;

ll dfs(int i) {
    for(auto& n : graph[i]) {
        if(node[n] == -1) {
            node[n] = C[c_ind];
            c_ind++;
            dfs(n);
        }
    }
    return 0;
}

signed main()
{
    cin >> N;
    graph.assign(N, vector<ll>());
    REP(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    C.resize(N);
    ll sum = 0;
    REP(i, N) {
        cin >> C[i];
        sum += C[i];
    }
    sort(C.begin(), C.end(), greater<ll>());
    sum -= C[0];

    node.assign(N, -1);
    c_ind = 0;
    dfs(0);

    printf("%lld\n", sum);
    REP(i, node.size()) {
        printf("%lld%c", node[i], (i == node.size()-1) ? '\n' : ' ');
    }

    return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
  int n,m,x,y;
  cin >> n >> m >> x >> y;
  int maxX = x;
  int minY = y;
  for(int i=0;i<n;i++){
    int xi;
    cin >> xi;
    maxX = max(maxX,xi);
  }
  for(int i=0;i<m;i++){
    int yi;
    cin >> yi;
    minY = min(minY,yi);
  }
  if(maxX < minY) cout << "No War" << endl;
  else cout << "War" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
int dx[4] = {1, 0, 0, -1};
int dy[4] = {0, 1, -1, 0};

int main(void){
	int n; cin >> n;
	int dp[100];
	dp[0] = dp[1] = 1;
	reps(i, 2, n + 1){
		dp[i] = dp[i - 1] + dp[i - 2];
	}

	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 3092
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;

//約数を求める
vector<ll> divisor(ll num){
    vector<ll> vec;
    for(ll i=1;i*i<=num;i++){
        if(num%i == 0){
            vec.push_back(i);
            if(i*i != num) vec.push_back(num/i);
        }
    }
    sort(begin(vec), end(vec));
    return vec;
}

int main() {
    cin >> N;
    vector<ll> vec = divisor(N); 
    int ans = 10000;
    rep(i, vec.size()){
        ans = min(ans, (int)max(to_string(vec[i]).size(), to_string(N/vec[i]).size()));
    }
    cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int datas[105];
int memo[100005][2];
int solve(int sisa, bool con)
{
	bool win=0;
	if(memo[sisa][con]!=-1) return memo[sisa][con];
	for(int z=0;z<n;z++)
	{
		if(sisa-datas[z]>=0)
		{
			int tmp=solve(sisa-datas[z], con^1);
			if(tmp==con)
			{
				win=1;
				break;
			}
		}
	}
	if(win)
	{
		return memo[sisa][con]=con;
	}
	else
	{
		return memo[sisa][con]=con^1;
	}
}

int main()
{
	int k;
	scanf("%d%d", &n, &k);
	for(int a=0;a<n;a++) scanf("%d", &datas[a]);
	memset(memo, -1, sizeof(memo));
	int hasil=solve(k, 0);
	if(hasil==0)
	{
		printf("First");
	}
	else
	{
		printf("Second");
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 8832
#include<stdio.h>
#include<math.h>
int main() {
	long long N, M;
	long long ans = 0;
	long long tmpn = 1, tmpm = 1;
	scanf("%lld%lld", &N, &M);
	if (abs(N - M) > 1)
	{
		printf("%lld\n", ans);
	}
	else
	{
		for (long long i = 1; i <= N; i++)
		{
			tmpn = (tmpn * i) % 1000000007;

		}
		for (long long i = 1; i <= M; i++)
		{
			tmpm = (tmpm * i) % 1000000007;

		}
		ans = tmpn * tmpm;
		if (N == M)
		{
			ans *= 2;
		}
		ans = ans % 1000000007;
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 128
H, W, K = tuple(int(i) for i in input().split())

row = [0, 1]
row_b = [0, 0]
for _ in range(W-1):
    temp = [i + j for i, j in zip(row, row_b)]
    row_b = row
    row = temp
    row.append(row[1])
    row_b.append(0)
row.append(0)
row_b.append(0)
# print(row, row_b)

a = {(0, i): 0 for i in range(W+2)}
a[(0, 1)] = 1
for h in range(1, H+1):
    for w in range(0, W+2):
        if w == 0 or w == W+1:
            a[(h, w)] = 0
        else:
            a[(h, w)] = row_b[w-1]*a[(h-1, w-1)] + row[w]*a[(h-1, w)] + row_b[w]*a[(h-1, w+1)]
        # print(f"({h}, {w}) {a[(h, w)]}")
print(a[(H, K)] % 1000000007)


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

int main() {
    int N, M, a;
    scanf("%d%d", &N, &M);
    priority_queue<int> pq;
    while (N--) {
        scanf("%d", &a);
        pq.push(a);
    }
    while (M--) {
        a = pq.top(); pq.pop();
        pq.push(a/2);
    }
    long long sum = 0;
    while (!pq.empty()) {
        sum += pq.top(); pq.pop();
    }
    printf("%lld", sum);
}

Measured memory_bytes: 892
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

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

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	string S;
	cin >> S;
	int count = 0;
	for (int i = 0; i < S.size()-1; ++i) {
		if (S[i] == S[i + 1]) {
			if (S[i] == '0') {
				S[i + 1] = '1';
			}
			else {
				S[i + 1] = '0';
			}
			count++;
		}
	}
	cout << count << endl;
	return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int minCount=32767;
  for(int i=0; i<N; i++){
    int count=0;
    int A;
    cin >> A;
    while(A%2==0){
      if(minCount<=count) break;
      count++;
      A/=2;
    }
    if(i==0 || minCount>count) minCount=count;
  }
  cout << minCount << endl;
}
    
    

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

int main(void) {
    double n,x[100],y[100],ans1=0.0,ans2=0.0,ans3=0.0,ans4=0.0;
    cin>>n;
    vector<double> ans4_a(n,0);
    for(int i=0;i<n;i++) cin>>x[i];
    for(int i=0;i<n;i++) cin>>y[i];
    for(int i=0;i<n;i++) {
        ans1+=abs(x[i]-y[i]);
        ans2+=abs(x[i]-y[i])*abs(x[i]-y[i]);
        ans3+=abs(x[i]-y[i])*abs(x[i]-y[i])*abs(x[i]-y[i]);
        ans4_a[i]=abs(x[i]-y[i]);
    }
    ans4=*max_element(ans4_a.begin(),ans4_a.end());
    printf("%f\n",ans1);
    printf("%f\n",sqrt(ans2));
    printf("%f\n",pow(ans3,1.0/3.0));
    printf("%f\n",ans4);
    return 0;
}

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

using namespace std;

int n, y[55], ans;
char x[55][105];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%s%d", x[i], y + i);
	scanf("%s", x[n]);
	for (int i = 0, j = 0; i < n; i++) {
		ans += y[i] * j;
		if (string(x[i]) == string(x[n]))
			j = 1;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(2**N):
    val = 0
    for j in range(N):
        if (i >> j) & 1:
            val+=V[j]
            val-=C[j]
    ans = max(ans, val)
print(ans)


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

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

void solve(long long N){
    int s = N%10;
    if(s == 3 ){
        cout << "bon" << endl;
        return;
    }
    if(s==0 || s==1 || s==6 ||s ==8){
        cout << "pon" << endl;
        return;
    }
    cout << "hon"<< endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3652
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using CompLib.Util;

public class Program
{
    string A;
    string B;
    string C;

    bool Eq(char l, char r)
    {
        return l == '?' || r == '?' || l == r;
    }

    public void Solve()
    {
        var sc = new Scanner();
        A = sc.Next();
        B = sc.Next();
        C = sc.Next();

        // Bの相対位置はiにいるのはだめ
        var AB = new BitArray(20000);
        var BC = new BitArray(20000);
        var AC = new BitArray(20000);

        // Aに対するB,Cの位置
        for (int i = 0; i < A.Length; i++)
        {
            for (int j = 0; j < B.Length; j++)
            {
                if (!Eq(A[i], B[j])) AB[i - j + 10000] = true;
            }

            for (int j = 0; j < C.Length; j++)
            {
                if (!Eq(A[i], C[j])) AC[i - j + 10000] = true;
            }
        }

        for (int i = 0; i < B.Length; i++)
        {
            for (int j = 0; j < C.Length; j++)
            {
                if (!Eq(B[i], C[j])) BC[i - j + 10000] = true;
            }
        }

        int ans = int.MaxValue;

        // Aに対するbの位置
        for (int i = -4000; i <= 4000; i++)
        {
            // cの位置
            for (int j = -4000; j <= 4000; j++)
            {
                if (AB[i + 10000] || AC[j + 10000] || BC[j - i + 10000]) continue;

                int l = Math.Min(0, Math.Min(i, j));
                int r = Math.Max(A.Length, Math.Max(i + B.Length, j + C.Length));
                ans = Math.Min(ans, r - l);
            }
        }

        Console.WriteLine(ans);
    }


    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13244
using System;
using System.Linq;

namespace ABC138B
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToArray();

            double d = a.Select(e => (double)1 / e).Sum();
            Console.WriteLine((double)1 / d);
        }
    }
}


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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

const int MAXN = 2e5 + 5;
const int MOD = 1e9 + 7;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define FAIL0 {cout << "0\n"; return 0;}
#define FAIL1 {cout << "-1\n"; return 0;}
#define FAILNO {cout << "No\n"; return 0;}

int N;
char S[MAXN];

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> S;
    N = strlen(S);

    int bc = 0;
    LL ans = 0;
    int i = N-1;
    while(i >= 0) {
        if (S[i-1] == 'B' && S[i] == 'C') {
            bc++;
            i--;
        }
        else if (S[i] == 'A') ans += bc;
        else bc = 0;
        i--;
    }

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


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int n,i,j,mx=0,ans=0,a;
    cin >> n;
    for(i=0; i<n; i++)
    {
        cin>> a;
        ans+=a;
        mx=max(mx,a);
    }
    ans-=mx;
    ans+=(mx/2);
    cout << ans << "\n";


    return 0;
}


Measured memory_bytes: 256
#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")
using namespace std;

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gcd __gcd
#define lcm(a, b) ((a) * (b) / gcd((a), b))
#define all(x) x.begin(), x.end()
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define fastio() ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)
#define endl '\n'

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;

template <class T> inline T RD(T &a) {T x; cin >> x; return a = x;}

const int maxn = 2020;

vector<vector<ll> > dp;

signed main()
{
//	freopen("TEXT.inp", "r", stdin); freopen("TEXT.out", "w", stdout);
	fastio();

	dp.assign(maxn, vector<ll>(maxn, 0));
    ll n, t; cin >> n;
    vector<pair<ll, int> > a;

    for(int i = 0; i < n; ++i){
        cin >> t;
        a.push_back(mp(t, i));
    }

    sort(all(a), greater<pair<ll, int> >());

    ll ans = 0;

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            if(i + j >= n){
                ans = max(ans, dp[i][j]);
                break;
            }
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + a[i + j].fi * abs(a[i + j].se - i));
            dp[i][j + 1] = max(dp[i][j + 1], dp[i][j] + a[i + j].fi * abs(a[i + j].se - (n - j - 1ll)));
        }
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 35088
// 有點不耐煩會破壞偉大的計劃

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug(){
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

int main(){
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    long long d, t, s; cin >> d >> t >> s;

    if(t * s >= d) cout << "Yes";
    else cout << "No";

    return 0;
}


Measured memory_bytes: 3632
N,W = map(int, input().split())

w = [0 for i in range(N)]
v = [0 for i in range(N)]
Wsum = [0 for i in range(N+1)]
Vsum = [0 for i in range(N+1)]

for i in range(N):
    w[i],v[i] = map(int, input().split())
Wmin = min(w)

w.insert(0,"0")
v.insert(0,"0")


for i in range(N):
    Wsum[i+1] = Wsum[i] + w[i+1]
    Vsum[i+1] = Vsum[i] + v[i+1]


nap_memo = {}

#i番目の品物まで含み制約W2のナップサック問題の最適解
def nap(i,W2):
    #重複計算を避けるためnap(i,W2)を保持
    key = str(i) + ':' + str(W2)
    if key in nap_memo:
        return nap_memo[key]
    #品物0個のときは価値は0
    elif i == 0:
        r = 0
    #制約0のときも価値は0
    elif W2 < Wmin:
        r = 0
    #w[i]がW2を超えるときはi番目の品物は不必要
    elif W2 < w[i]:
        r = nap(i-1,W2)
    #品物の重さ全部足して制約以下なら全部足したものが価値で良い
    elif Wsum[i] <= W2:
        r = Vsum[i]
    #i番目の品物をナップサックに入れるか入れないか
    else:
        r = max( nap(i-1,W2-w[i])+v[i] , nap(i-1,W2) )
    
    nap_memo[key] = r
    return r
    
            
print(nap(N,W))


Measured memory_bytes: 10760
import sys
input=sys.stdin.readline


def main():
	#N,M=map(int,input().split())
	#S=input().rstrip()
	N=int(input())
	#vA=list(map(int,input().split()))
	#vAB=[tuple(map(int,input().split()))
	#	 for _ in [0,]*M]
	
	print(-(-N//2))
	
main()


Measured memory_bytes: 38384
import java.util.*;
public class Main{
  public static void main(String[] args) {
    int a,b;
    Scanner sc=new Scanner(System.in);
    a=sc.nextInt();
    b=sc.nextInt();

    if(a>2*b){
      System.out.println(a-2*b);
    }else{
      System.out.println(0);
    }
  }
}


Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
 
void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;
 
  cout << endl;
}
 
int main(){
  int n;
  cin >> n;
  call(n);
}


Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int dp[5001][5001];

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

	int n; cin >> n;
	string s; cin >> s;

	FOR_DW(i, s.size() - 1, 0) {
		FOR_DW(j, s.size() - 1, 0) {
			int prev = 0;
			if (i + 1 < s.size() && j + 1 < s.size()) {
				prev = dp[i + 1][j + 1];
			}
			if (s[i] == s[j]) {
				dp[i][j] = prev + 1;
			}
			else {
				dp[i][j] = 0;
			}
		}
	}

	int ans = 0;
	FOR_LT(i, 0, s.size()) {
		FOR_LT(j, 0, s.size()) {
			ans = max(min(dp[i][j], abs(i - j)), ans);
		}
	}


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 97920
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;

#define MOD (int)(1e9 + 7)

long long dp[2'001];

long long Dfs(int s)
{
    if (s == 0)
        return 1ll;
    
    long long &ret = dp[s];
    if (ret != -1ll)
        return ret;

    ret = 0ll;
    for (int i = 3; i <= s; ++i)
        ret = (ret + Dfs(s - i)) % MOD;

    return ret;
}

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

    int S;
    cin >> S;

    memset(dp, -1, sizeof(dp));

    cout << Dfs(S);

    return 0;
}

Measured memory_bytes: 3540
#include<stdio.h>
#include<math.h>

int main(){
   int n,ka;
   scanf("%d ", &n);
   ka = (n + n-2);
   char in[20];
   double aa[n][2], pp, sum=0;
   for(int i=0;i<n;i++){
   	fgets(in,sizeof(in),stdin);
    sscanf(in,"%lf %lf", &aa[i][0],&aa[i][1]);
    // printf("%lf %lf\n",aa[i][0],aa[i][1] );
   }
    int m=n-1;
    double ave=1, tyu;
    for(int i=1;i<=n;i++){
    	ave = i*ave;
        if(i==n-2){
          tyu = ave;
        }
    }
	while(m>0){
      for(int i=0;i<m;i++){
       // printf("%d %d\n",i,m);
        pp = (aa[m][0]-aa[i][0])*(aa[m][0]-aa[i][0]) 
          + (aa[m][1]-aa[i][1])*(aa[m][1]-aa[i][1]);
        pp=sqrt(pp);
        //printf("%lf\n", pp);
        if(n<3){ sum = sum + pp*(double)ka;}
        else {
          sum = sum + pp*tyu*(double)ka;
        }
        //printf("%lf\n", sum);
      }
      m--;
    }
  
    printf("%lf", sum/ave);
   return 0;
 
}

Measured memory_bytes: 128
def pN(n, x, y, N):
	result = list()
	for i in range(n):
		result.append(abs(x[i] - y[i]) ** N)
	return (sum(result) ** (1 / N))

def pMax(n, x, y):
	result = list()
	for i in range(n):
		result.append(abs(x[i] - y[i]))
	return max(result)

n = int(input())
x = [int(x) for x in input().split()]
y = [int(y) for y in input().split()]
print('%.8f' % pN(n, x, y, 1))
print('%.8f' % pN(n, x, y, 2))
print('%.8f' % pN(n, x, y, 3))
print('%.8f' % pMax(n, x, y))


Measured memory_bytes: 5652
#include <iostream>
#include <cstdio>
#define MAX_N 100
using namespace std;

void swap(int &a, int &b);
void display(int ary[], int size);
int bubbleSort(int ary[], int size);

int main(void) {
	int N;
	int ary[MAX_N];

	cin >> N;
	for(int i = 0; i < N; i++) {
		cin >> ary[i];
	}

	int cnt = bubbleSort(ary, N);
	printf("%d\n", cnt);

	return 0;
}

void display(int ary[], int size) {
	for(int i = 0; i < size; i++) {
		printf("%d", ary[i]);
		if(i == size-1) putchar('\n');
		else            putchar(' ');
	}
}

int bubbleSort(int ary[], int size) {
	bool flag = true;
	int cnt = 0;
	while(flag) { 
		flag = false;
		for(int j = size-1; j > 0; j--) {
			if(ary[j] < ary[j-1]) {
				swap(ary[j], ary[j-1]);
				cnt++;
				flag = true;
			}
		}
	}
	display(ary, size);
	return cnt;
}

void swap(int &a, int &b) {
	int c = a;
	a = b;
	b = c;
}

Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a;
  double b[100000],d,c=0;
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>b[i];
  }
  sort(b,b+a);
  for(int i=0;i<a;i++){
    if(i==0) c=c+b[i];
    else{ 
      c=(c+b[i])/2;
    }
  }
  cout<<c<<"\n";
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.*;
import java.lang.Math;
 class Main{
     public static void main(String[] args) {
      Scanner sc=new Scanner(System.in);

      String s1=sc.next();
      String d="";
      for(int i=0;i<s1.length();i++)
            d+='x';
            
      System.out.print(d);
      


      }
}  

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

using namespace std;

int N, M, X;

int main(){
	cin >> N >> M >> X;
	int A[M];
	for(int i = 0; i < M; ++i) cin >> A[i];
	int road[N+1] = {};
	for(int i = 0; i < M; ++i) road[A[i]] = 1;
	int ans = min(accumulate(road, road + X, 0), accumulate(road + X + 1, road + N, 0));
	cout << ans << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
PY = [list(map(int, input().split())) + [i] for i in range(m)]
PY = sorted(PY, key=lambda x: x[1])
PC = [1] * (n+1)

anss = []
for p, y, i in PY:
    anss.append((i, p, PC[p]))
    PC[p] += 1
anss = sorted(anss, key=lambda x: x[0])
for i, p, c in anss:
    print('{:06}{:06}'.format(p, c))


Measured memory_bytes: 113712
#include <cstdio>
#include <algorithm>

using namespace std;

struct team {
	team() {
		for (int i = 0; i < 10; ++i) {
			ac[i] = -1;
			fa[i] = 0;
		}
	}
	int no;
	int ac[10];
	int fa[10];
	
	int na() const {
		int ans = 0;
		for (int i = 0; i < 10; ++i)
			if (ac[i] != -1)
				++ans;
		return ans;
	}
	
	int st() const {
		int ans = 0;
		for (int i = 0; i < 10; ++i)
			if (ac[i] != -1)
				ans += ac[i] + fa[i] * 20;
		return ans;
	}
	
	bool operator==(const team &rh) const {
		return this->na() == rh.na() && this->st() == rh.st();
	}
	
	bool operator<(const team &rh) const {
		if (this->na() > rh.na())
			return true;
		else if (this->na() < rh.na())
			return false;
		
		if (this->st() < rh.st())
			return true;
		else if (this->st() > rh.st())
			return false;
		
		return this->no > rh.no;
	}
};

int main()
{
	for (;;) {
		int m, t, p, r;
		scanf("%d %d %d %d", &m, &t, &p, &r);
		if (m == 0 && t == 0 && p == 0 && r == 0)
			break;
			
		team teams[50];
		for (int i = 0; i < t; ++i)
			teams[i].no = i + 1;
		
		for (int i = 0; i < r; ++i) {
			int m, t, p, j;
			scanf("%d %d %d %d", &m, &t, &p, &j);
			
			if (j == 0)
				teams[t - 1].ac[p - 1] = m;
			else
				teams[t - 1].fa[p - 1] += 1;
		}
		
		sort(teams, teams + t);
		
		for (int i = 0; i < t; ++i) {
			printf("%d", teams[i].no);
			if (i == t - 1)
				printf("\n");
			else if (teams[i] == teams[i + 1])
				printf("=");
			else
				printf(",");
		}
	}
	
	return 0;
}

Measured memory_bytes: 1028
n = int(input())
a = list(map(int,input().split()))
q = int(input())
l = [0]*10**6
ans = sum(a)
for i in a:
    l[i]+=1
for i in range(q):
    b,c = map(int,input().split())
    l[c] += l[b]
    ans -= b*l[b]
    ans += c*l[b]
    l[b] = 0
    print(ans)

Measured memory_bytes: 23864
#include <iostream>
#include <algorithm>
using namespace std;
#define MAX 1400

int dp[MAX][MAX], G[MAX][MAX];
int getLargestSqure(int H, int W)
{
    int maxWidth = 0;
    for(int i=0; i<H; i++)
    {
        for(int j=0; j<W; j++)
        {
            dp[i][j] = (G[i][j]+1)%2;
            maxWidth |= dp[i][j];
        }
    }
    for(int i=1; i<H; i++)
    {
        for(int j=1; j<W; j++)
        {
            if(G[i][j])
                dp[i][j] = 0;
            else
            {
                dp[i][j] = min(dp[i-1][j-1],min(dp[i-1][j],dp[i][j-1]))+1;
                maxWidth = max(maxWidth,dp[i][j]);
            }
        }
    }
    return maxWidth*maxWidth;
}
int main()
{
    int H, W;
    cin >> H >> W;
    for(int i=0; i<H; i++)
    {
        for(int j=0; j<W; j++)
            cin >> G[i][j];
    }
    cout << getLargestSqure(H,W) << endl;
    return 0;
}

Measured memory_bytes: 18396
#include <stdio.h>
#include <math.h>
int main(){
	int L,A,B,C,D,result;
	double home;
	scanf("%d %d %d %d %d",&L,&A,&B,&C,&D);
	home = fmax((double)A/C,(double)B/D);
	result = L -(int)ceil(home);
	printf("%d\n",result);
	return 0;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    string s;
    cin >> s;
    int cnt = 0;
    for(auto i : s){
        if(i == 'o') cnt++;
    }
    if(15 - size(s) + cnt >= 8){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    double ans = (A[0] + A[1]) / 2.0;

    for(int i=2; i<N; i++) {
        ans = ans / 2.0 + A[i] / 2.0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3712
N = gets.to_i
X = gets.split.map(&:to_i)

min = 10 ** 9

X.min.upto(X.max) do |i|
  c = X.inject(0) do |acc, x|
    acc + (x - i) ** 2
  end
  min = c if c < min
end

puts min

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

template<class T> constexpr bool in_range(T y, T x, T H, T W) { return 0<=y&&y<H&&0<=x&&x<W; }

typedef long long ll;
int const inf = 1<<29;

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

template<class T> using PQ_G = priority_queue<T, vector<T>, greater<T>>;

bool solve() {

  int R; cin >> R;
  if(R == 0) return 1;

  int W[2], H[2], X[2], Y[2];
  vector<vector<vector<int>>> G(2);

  rep(i, 2) {
    cin >> W[i] >> H[i] >> X[i] >> Y[i]; Y[i]--, X[i]--;
    G[i].resize(H[i]); rep(k, H[i]) G[i][k].resize(W[i]);
    rep(y, H[i]) rep(x, W[i]) cin >> G[i][y][x];
  }

  map<int, int> counts[2];

  rep(t, 2) {
    vector<vector<int>> dist(H[t], vector<int>(W[t], inf));
    PQ_G<tuple<int, int, int>> pq;
    pq.emplace(0, Y[t], X[t]);
    dist[Y[t]][X[t]] = 0;

    counts[t][0] = 0;
    counts[t][1] = 1;

    while(!pq.empty()) {
      int c, y, x; tie(c, y, x) = pq.top(); pq.pop();

      if(dist[y][x] < c) continue;

      rep(k, 4) {
        int ny = y + dy[k], nx = x + dx[k];
        if(!in_range(ny, nx, H[t], W[t])) continue;
        int nc = max(c, G[t][ny][nx]);
        if(dist[ny][nx] <= nc) continue;
        dist[ny][nx] = nc;
        counts[t][nc]++;
        pq.emplace(nc, ny, nx);
      }
    }
  }

  set<pair<int, int>> st[2];

  rep(t, 2) {
    st[t].emplace(inf, inf);
    for(auto iter=counts[t].begin(); iter!=counts[t].end(); iter++) {
      if(iter == counts[t].begin()) continue;
      auto prev = iter; prev--;
      iter->second += prev->second;
    }
  }

  rep(t, 2) for(auto e: counts[t]) {
    st[t].emplace(e.second, e.first);
  }

  int ans = inf;

  rep(i, R + 1) {
    auto a = st[0].lower_bound({i, -inf});
    auto b = st[1].lower_bound({R-i, -inf});
    if(a->first == inf) continue;
    if(b->first == inf) continue;
    ans = min(ans, a->second + b->second);
  }

  cout << ans << endl;

  return 0;
}

int main() {

  while(!solve());

  return 0;
}

Measured memory_bytes: 25688