akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

struct node{
    int parent;
    int left;
    int right;
    node(){
        parent = -1;
    }
};

int find_root(const vector<node>& T){
    for (int i = 0; i < T.size(); i++) {
        if (T[i].parent == -1) return i;
    }
}

void do_preorder(int id, const vector<node>& T, queue<int>& Q){
    if (id == -1) return;
    Q.push(id);
    do_preorder(T[id].left , T, Q);
    do_preorder(T[id].right, T, Q);
}

void do_inorder(int id, const vector<node>& T, queue<int>& Q){
    if (id == -1) return;
    do_inorder(T[id].left , T, Q);
    Q.push(id);
    do_inorder(T[id].right, T, Q);
}

void do_postorder(int id, const vector<node>& T, queue<int>& Q){
    if (id == -1) return;
    do_postorder(T[id].left , T, Q);
    do_postorder(T[id].right, T, Q);
    Q.push(id);
}

void print_Q(queue<int>& Q){
    while (!Q.empty()) {
        cout << " " << Q.front();
        Q.pop();
    }
    cout << endl;
}

int main(){
    int n;
    cin >> n;
    vector<node> T(n);
    for (int i = 0; i < n; i++) {
        int id, left, right;
        cin >> id >> left >> right;
        T[id].left  = left ;
        T[id].right = right;
        if (left  != -1) T[left].parent  = id;
        if (right != -1) T[right].parent = id;
    }

    int root = find_root(T);
    queue<int> Q;

    cout << "Preorder" << endl;
    do_preorder(root, T, Q);
    print_Q(Q);
    cout << "Inorder" << endl;
    do_inorder(root, T, Q);
    print_Q(Q);
    cout << "Postorder" << endl;
    do_postorder(root, T, Q);
    print_Q(Q);

    return 0;
}

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

int main(){
  string str;
  cin >> str;
  int count = 0;
  bool rain = false;
  
  for(int i = 0; i < 3; ++i){
  	if(str[i] == 'R' && rain == false){
		rain = true;
      	count = 1;
    }else if(str[i] == 'R' && rain == true){
    	 count++;
    }else{
     	rain = false;
    }
  }
  
  cout << count << endl;
  
  return 0;
}

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

int main()
{
int iLen;
int iA;
int iB;
char C;
string S;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> S;

	iLen = S.size();
	iB = iLen / 2;
	if( iLen % 2 == 0 )
		iA = iB - 1;
	else
		iA = iB;

	C = S[ iA ];
	while( iA >= 0 && iB < iLen )
	{
		if( C != S[ iA ] || C != S[ iB ] ) break;

		iA--;
		iB++;
	}

	cout << iB << endl;

	return 0;
}




Measured memory_bytes: 512
#include <iostream>

int main( void )
{
    int n, a;
    int max = -1000000, min = 1000000;
    long sum = 0;

    std::cin >> n;
    for( int i = 0; i < n; i++ )
    {
        std::cin >> a;
        sum += a;
        if ( max < a ) max = a;
        if ( min > a ) min = a;
    }

    std::cout << min << " " << max << " " << sum << std::endl;
    return 0;
}

Measured memory_bytes: 3072
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const long long MOD = 1000000007;

int main(){
  int a, p;
  cin>>a>>p;
  std::cout <<   (a*3+p)/2 << std::endl;

  return 0;
}


Measured memory_bytes: 256
using System;
//using System.Collections;
//using System.Collections.Generic;
//using System.Linq;

namespace solution
{
  class Class1
  {
    static void Main()
    {
      string s = Console.ReadLine();
      string p = Console.ReadLine();

      Console.WriteLine(((s + s).IndexOf(p) != -1) ? "Yes" : "No");
    }
  }
}


Measured memory_bytes: 9804
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] h = new int[n];
		for (int i = 0; i < h.length; i++) {
			h[i] = Integer.parseInt(sc.next());
		}
		int ans = 1;
		for (int i = h.length - 1; i > 0; i--) {
			for (int j = i - 1; j >= 0; j--) {
				if (h[i] < h[j]) {
					break;
				} else if (j == 0) {
					ans++;
				}
			}
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 23508
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>*/
#include <bits/stdc++.h>

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;
double PI = 4*atan(1);

int N,M, ans = MOD, a[300][300], num[300], cur = 0;
bool ok[300];

void get() {
    F0R(i,M) num[i] = 0; 
    cur = 0;
    F0R(i,N) F0R(j,M) if (ok[a[i][j]]) {
        num[a[i][j]] ++;    
        break;
    }
    F0R(i,M) cur = max(cur,num[i]);
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> N >> M;
	F0R(i,N) F0R(j,M) {
	    cin >> a[i][j];
	    a[i][j] --;
	}
	F0R(i,M) ok[i] = 1;
	
	while (1) {
	    get();
	    if (cur != 0) ans = min(ans,cur);
	    else break;
	    F0R(j,M) if (num[j] == cur) ok[j] = 0;
	}
	cout << ans;
}

Measured memory_bytes: 640
//In the name of God
//SMani24
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const int N = 1e5 + 10;

ll n, m, a[N];
ll lcm, ans;
bool f;

int gcd(int a, int b) {
	if (a == 0)
		return b;
	return gcd(b % a, a);
}
void read_input() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i] /= 2;
	}
}
void solve() {
	lcm = a[0];
	for (int i = 1; i < n; i++)
		lcm = (lcm * a[i]) / gcd(lcm, a[i]);
	for (int i = 0; i < n; i++)
		f = f | !((lcm / a[i]) & 1);
	if (f)
		ans = 0;
	else
		ans = (m / lcm) - (m / (lcm * 2));
}
void write_output() {
	cout << ans << endl;
}
int main() {
	read_input(), solve(), write_output();
	return 0;
}


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

int a, b, c, d, e;

int main()
{
    cin >> a >> b >> c >> d >> e;
    cout << (a < 0 ? (-a) * c : 0) + (a <= 0 ? d : 0) + (a > 0 ? (b - a) * e : b * e) << endl;
}


Measured memory_bytes: 3092
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
  #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
bool check(int a,int b){
	bool ok=false;
  for(int i=1;i<=3;i++){
	   if((a*b*i)&1){
		    ok=true;
		    break; 
		  }
	 }
  return ok;	
}
void solve(){
   int a,b;
   cin>>a>>b;
   cout<<(check(a,b)?"Yes":"No")<<endl;	
}
int32_t main(){
   IOS;
   solve();
   //debug();
  #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
  #endif	
}

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

int main() {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    int res1 = 0, res2 = 0;
    double temp = 0.0;
    for (int i = 0; i * A <= F; i++) {
        for (int j = 0; j * B <= F; j++) {
            if (i == 0 && j == 0) continue;
            int water = 100 * A * i + 100 * B * j;
            int limit = min(water / 100 * E, F - water);
            for (int k = 0; k * C <= limit; k++) {
                int l = (limit - k * C) / D;
                int sugar = k * C + l * D;
                if ((double)sugar / water > temp) {
                    temp = (double)sugar / water;
                    res1 = water + sugar;
                    res2 = sugar;
                }
            }
        }
    }
    if (temp == 0) {
        cout << A * 100 << " " << 0 << endl;
    } else{
        cout << res1 << " " << res2 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>
#include <tuple>




typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define FOR(i,a,b) for(int i=(int)(a) ; i < (int) (b) ; ++i )
#define rep(i,n) FOR(i,0,n)
#define sz(x) int(x.size())


template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;

int gcd(int x,int y){
    if (y==0) return x;
    else return gcd(y,x%y);
}

int main(){
    int n;
    string s;
    cin>>n>>s;
    int ans=-1;
    for (int k=1;k<n;k++){
        int cnt=0;
        for (char c='a';c<='z';c++){
            bool left=false;bool right=false;
            for (int i=0;i<k;i++){
                if (s[i]==c) left=true;
            }
            for (int j=k;j<n;j++){
                if (s[j]==c) right=true;
            }
            if (left && right) cnt++;
        }
        ans=max(ans,cnt);
        
    }
    
    cout<<ans;
    
    return 0;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }

        Arrays.sort(a);
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int now = a[i];
            int count = 1;
            for (int j = i + 1; j < n; j++) {
                if (a[j] == now) {
                    count++;
                    i++;
                } else {
                    break;
                }
            }
            if (count % 2 == 1) {
                ans++;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 58432
#include <iostream>
using namespace std;
int a[100];
int N,c,i,ans,tmp;
int main() {
  cin >> N;
  for(i=0;i<N;i++) {
    cin >> a[i];
  }
  i = 0;
  c = 1;
  for(i=0;i<N;i++) {
    if(a[i]==a[i+1]) {
      c = c+1;
    }
    else {
      tmp = c/2;
      ans = ans+tmp;
      c = 1;
    }
  }
  cout << ans << '\n';
  return(0);
}

Measured memory_bytes: 256
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;



public class Main {
	public static class FastReader {
			BufferedReader br;
			StringTokenizer root;
			
	 
			public FastReader() {
				br = new BufferedReader(new InputStreamReader(System.in));
			}
	 
			String next() {
				while (root == null || !root.hasMoreTokens()) {
					try {
						root = new StringTokenizer(br.readLine());
					} catch (Exception addd) {
						addd.printStackTrace();
					}
				}
				return root.nextToken();
			}
	 
			int nextInt() {
				return Integer.parseInt(next());
			}
	 
			double nextDouble() {
				return Double.parseDouble(next());
			}
	 
			long nextLong() {
				return Long.parseLong(next());
			}
	 
			String nextLine() {
				String str = "";
				try {
					str = br.readLine();
				} catch (Exception addd) {
					addd.printStackTrace();
				}
				return str;
			}
		}
	 
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	public static FastReader sc = new FastReader();
 
	static int mod = (int)(1e9+7),MAX=(int)(1e5+10);
	static List<int[]>[] edges;
	
	public static void main(String[] args) throws IOException{
	
		long num = sc.nextLong();
		out.print(getAlpha(num));
	  out.close();
	}
	 public static String getAlpha(long num) {

		    String result = "";
		    while (num > 0) {
		      num--; // 1 => a, not 0 => a
		      int remainder = (int) (num % 26);
		      char digit = (char) (remainder + 97);
		      result = digit + result;
		      num = (num - remainder) / 26;
		    }

		    return result;
		  }
	
	
}

Measured memory_bytes: 37268
#include<stdio.h>
int main(){
int a;
scanf("%d",&a);
int b[a],c[a];
int d=0;
for(int i=0; i<a; i++){
scanf("%d",&b[i]);
}
for(int i=0; i<a; i++){
scanf("%d",&c[i]);
}
for(int i=0; i<a; i++){
if(b[i]>c[i]){d+=b[i]-c[i];}
}
printf("%d",d);
return 0;}

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

int64_t MOD = 1000000007;
double PI = 3.141592653589793;

int main()
{
    int N, AC = 0, WA = 0, TLE = 0, RE = 0;
    string tmp;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        if (tmp == "AC")
            AC++;
        if (tmp == "WA")
            WA++;
        if (tmp == "TLE")
            TLE++;
        if (tmp == "RE")
            RE++;
    }
    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
const ll INF = 114514810;
const ll MOD = 1000000007;
const double EPS = 1e-8;
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
int index(int x, int y, int w) { return w*x + y; }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int main()
{
	int w, h;
	while (cin >> w >> h, w)
	{
		vs fld(h);
		REP(i, h) cin >> fld[i];
		int src;
		vi v;
		REP(i, h)REP(j, w)
		{
			if (fld[i][j] == 'o') src = index(i, j, w);
			if (fld[i][j] == '*') v.push_back(index(i, j, w));
		}
		if (v.size() == 0)
		{
			puts("0");
			continue;
		}
		int dis[400][400];
		int V = h*w;
		REP(i, V)REP(j, V) dis[i][j] = (i == j ? 0 : INF);
		REP(i, h)REP(j, w)
		{
			if (fld[i][j] == 'x') continue;
			REP(k, 4)
			{
				int nx = i + dx[k], ny = j + dy[k];
				if (valid(nx, ny, h, w) && fld[nx][ny] != 'x') dis[index(i, j, w)][index(nx, ny, w)] = 1;
			}
		}
		REP(k, V)REP(i, V)REP(j, V) chmin(dis[i][j], dis[i][k] + dis[k][j]);
		sort(ALL(v));
		int ans = INF;
		do
		{
			int cnt = 0;
			int tmp = src;
			int next = v[0];
			REP(i, v.size()-1)
			{
				cnt += dis[tmp][next];
				tmp = v[i];
				next = v[i + 1];
			}
			cnt += dis[tmp][next];
			chmin(ans, cnt);
		} while (next_permutation(ALL(v)));
		cout << (ans == INF ? -1 : ans) << endl;
	}
	return 0;
}

Measured memory_bytes: 1828
#include<stdio.h>
long long fiboDP(int n) {
    long long fibo_dp[200] = {0};
    fibo_dp[0] = 1;
    fibo_dp[1] = 1;
    for(int i=2; i<=n; i++) {
        fibo_dp[i] = fibo_dp[i-1] + fibo_dp[i-2];
    }
    return fibo_dp[n];
}

int main(void){
    int n;
    scanf("%d\n", &n);
    printf("%lld\n", fiboDP(n));
    return 0;
}



Measured memory_bytes: 2104
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

bool f[100010];
ll c[100010];

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

	ll Q;
	
	cin >> Q;

	for (int i = 2; i * i <= 100000; i++)
	{
		if (!f[i])
		{
			for(int j = i+i; j <= 100000; j+=i)
			{
				f[j] = true;
			}
		}
		
	}

	for (int i = 3; i <= 100000; i+=2)
	{
		if (!f[i] && !f[(i+1) / 2])
		{
			c[i]++;
		}
	}

	for (int i = 3; i <= 100000; i++)
	{
		c[i] += c[i-1];
	}

	rep(i, Q)
	{
		ll l , r;
		cin >> l >> r;
		cout << c[r] - c[l-1] << endl;
	}


	
	return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<queue>
#include<cstdio>
#include<stdlib.h>
#include<string>
using namespace std;
typedef struct{
	string name;
	int time;
}Q;
int sum;
queue<Q> qu;
int main(){
	int n ,q;
	Q tmp;
	cin>>n>>q;
	for(int i=0;i<n;i++){
		cin>>tmp.name>>tmp.time;
		qu.push(tmp);
	}
	while(!qu.empty()){
		tmp=qu.front();
		qu.pop();
		if(tmp.time<=q){
			sum+=tmp.time;
			cout<<tmp.name<<" "<<sum<<endl;
		}
		else{
			tmp.time-=q;
			sum+=q;
			qu.push(tmp);
		}
	}
	return 0;
}


Measured memory_bytes: 6224
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;
inline int toInt(string s){int v;istringstream i(s);i>>v;return v;}
template<class T> inline string toString(T x){ostringstream o;o<<x;return o.str();}
template<class T> void pv(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}
const int INF = 1000000000;
const double PI = acos(-1.0), EPS = 1e-10;

int main() {
	int N; cin >> N;
	vector<int> ans(6, 0);
	while(N--) {
		double t; cin >> t;
		if(t < 165) ans[0]++;
		else if(t < 170) ans[1]++;
		else if(t < 175) ans[2]++;
		else if(t < 180) ans[3]++;
		else if(t < 185) ans[4]++;
		else ans[5]++;
	}
	for(int i = 1; i <= 6; i++) {
		cout << i << ":";
		for(int j = 0; j < ans[i - 1]; j++)
			cout << "*";
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long k = sc.nextInt();
		int a[] = new int[n];
		for(int i = 0; i < n; i++){
			a[i] = sc.nextInt();
		}
		long cnt1 = 0;
		long cnt2 = 0;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(a[i] > a[j]){
					if(i<j){
						cnt2++;
						cnt1++;
					}
					else{
						cnt1++;
					}
				}
			}
		}
		long ans = cnt2 * (k);;
		ans %= 1000000007;

		cnt1 %= 1000000007;
		long b = (k-1) * k /2;

		b %= 1000000007;

		ans += cnt1 * b;
		ans %= 1000000007;



//		for(;k > 0; k--){
//			ans += (cnt1) * (k-1);
//			ans %= 1000000007;
//		}

		System.out.println(ans);

	}
}

Measured memory_bytes: 25832
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;

#define bil ((ll)1e9)
#define mod ((ll)1e9+7)

int main(int argc,char* argv[]){
    int a,b,c;
    cin >> a >> b >> c;

    if(a==b && a==c)
        cout << "1" << endl;    
    else if(a!=b && a!=c && b!=c)
        cout << "3" << endl;
    else
        cout << "2" << endl;
    
    return 0;
}


Measured memory_bytes: 256
from heapq import heappush,heappop
N,K,Q=map(int,input().split())
A=list(map(int,input().split()))
ans=float("inf")
for x in A:
    data=[]
    h=[]
    for i in range(N):
        if A[i]>=x:
            heappush(h,A[i])
        else:
            if h:
                data.append(h)
                h=[]
    if h:
        data.append(h)
    lsls=[]
    for h in data:
        for j in range(max(0,len(h)-K+1)):
            lsls.append(heappop(h))
    lsls.sort()
    if len(lsls)>=Q:
        ans=min(ans,lsls[Q-1]-lsls[0])
print(ans)

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



int main() {
int N;
cin >> N;
bool check = 0;
for(int i = N; i > 0; i--){
for(int j = 1; j < 35; j++)
if((i == j*j || i == j*j*j || i == j*j*j*j || i == j*j*j*j*j)&& check == 0){
    cout << i << endl;
    check = 1;
    break;
}

}


}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace::std;
int msb(int x) {
	union { double a; int b[2]; };
	a = x;
	return (b[1] >> 20) - 1023;
}

int RepeatedDivision(int N){
	if (N <= 1) return 1;
	return 1 << msb(N);
}


int main(){
    int N;
    cin >> N;
    cout << RepeatedDivision(N) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'

//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

using namespace std;
template<class T, class T2> inline int chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline int chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const int MAXN = (1 << 16);
const int mod = 998244353;

int pw(int x, int p)
{
	int r = 1;
	while(p)
	{
		if(p & 1) r = r * 1ll * x % mod;
		x = x * 1ll * x % mod;
		p >>= 1;
	}

	return r;
}

int fact[MAXN], ifact[MAXN];
int pw2[MAXN];

void init()
{
	fact[0] = 1; for(int i = 1; i < MAXN; i++) fact[i] = fact[i - 1] * 1ll * i % mod;
	ifact[MAXN - 1] = pw(fact[MAXN - 1], mod - 2); for(int i = MAXN - 2; i >= 0; i--) ifact[i] = ifact[i + 1] * 1ll * (i + 1) % mod;
	pw2[0] = 1; for(int i = 1; i < MAXN; i++) pw2[i] = 2ll * pw2[i - 1] % mod;
}

inline int C(int n, int k) { if(n < 0 || k > n) return 0; return (fact[n] * 1ll * ifact[k] % mod) * 1ll * ifact[n - k] % mod; }

int n, k;

void read()
{
	cin >> k >> n;
}

int solve(int g, int n, int bonus)
{
	int ret = 0;
	for(int i = 0; i <= g; i++)
	{
		int curr = C(g, i) * 1ll * pw2[i] % mod;
		
		int cnt = n - i, places = bonus + i;
		if(cnt < 0) continue;

		curr = curr * 1ll * C(places + cnt - 1, cnt) % mod;

		ret = (ret + curr) % mod;
	}

	return ret;
}

int answer[MAXN];

void solve()
{
	init();

	for(int c = 2; c <= k + 1; c++)
	{
		int bonus = max(0, k - c + 1), ans = 0;

		if(c % 2 == 1) ans = solve(c / 2, n, bonus);
		else ans = (solve((c - 1) / 2, n, bonus) + solve((c - 1) / 2, n - 1, bonus)) % mod;

		answer[c] = ans;
		answer[2 * k - c + 2] = ans;
	}

	for(int i = 2; i <= 2 * k; i++)
		cout << answer[i] << endl;
}

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

	read();
	solve();
	return 0;
}



Measured memory_bytes: 1152
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <numeric>
#define ll long long
#define MAXM 101
#define MODD 1000000007
using namespace std;

bool already_sorted[222222];
int P[222222];
int PP[222222];

int main() {
    int N,K;
    cin>>N>>K;
    for(int i=1;i<=N;i++)
        cin>>P[i];

    P[0]=N+1;
    P[N+1]=-1;
    
    set<int> X;
    for(int i=1;i<=K;i++) {
        X.insert(P[i]);
    }

    
    for(int i=1;i<=N;i++)
        already_sorted[i]=false;
    
    for(int i=1;i<=N;) {
        
        int j=i;
        while(j+1<=N && P[j+1]>P[j])
            j++;
        // i to j.
        
        for(int k=i;k+K-1<=j;k++) {
            already_sorted[k]=true;
        }
        
        
        i=j+1;
    }
    
    
    // 0,2,1,4
    // 0,1,2,4
    // 0,1,2,4
    
    // A[i-1..j-1]
    // A[i...j]
    // if A[i-1] < min(A[i..j]) and A[j]=max(A[i..j])
    
    // every consecutive elements, check if the
    

    int ans=0;
    for(int st=1;st+K-1<=N;st++) {
        int en=st+K-1;
        if ((P[st-1]>*X.begin() || P[en]!=*X.rbegin()) && !already_sorted[st])
            ans++;
        X.erase(P[st]);
        X.insert(P[st+K]);
    }
    
    
    for(int i=1;i<=N;i++) {
        if (already_sorted[i]) {
            ans++;
            break;
        }
    }
    
    cout << ans << endl;
    
    
    
    
    
}


Measured memory_bytes: 12672
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll k,a,b;
  cin>> k >> a >> b;
  ll ans=a;
  if(b-a<=2){
    cout << k+1;
    return 0;
  }
  k=k-(a-1);
  if(k%2==0){
    ans+=(k/2)*(b-a);
  }else{
    ans+=(k/2)*(b-a)+1;
  }
  cout << ans;
}

Measured memory_bytes: 3632
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
  double x, h;
  double y, T, S;

  while(1) {
    S = 0;
    cin >> x >> h;
    if(x+h == 0)break;

    y = sqrt((x/2)*(x/2) + h*h);
    T = x * y / 2;
    S = T*4 + x*x;

    printf("%.6lf\n", S);
  }
}

Measured memory_bytes: 1236
a=[*?a..?z]
s=gets.chomp
n=gets.to_i
l=s.length
l.times do |i|
  g=26-a.index(s[i])
  if g<=n && g!=26
    n-=g
    s[i]=?a
  end
end
g=a.index(s[-1])
s[-1]=a[(g+n)%26]
puts s

Measured memory_bytes: 2044
///   ***   ---   |||		 In the name of ALLAH		|||   ---   ***   ///



#include<bits/stdc++.h>
using namespace std;


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {			cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }


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





int main()
{
	optimize();

	#ifndef ONLINE_JUDGE
		file()
	#endif

	int n, q;
	cin >> n;

	ll sum = 0;
	map<int, int> cnt;

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

	cin >> q;
	while ( q-- ) {
		ll b, c;
		cin >> b >> c;

		sum -= ( b * cnt[b] );
		sum += ( c * cnt[b] );
		
		cnt[c] += cnt[b];
		cnt[b] = 0;
		cout << sum << endl;
	}



	

	return 0;
}



















Measured memory_bytes: 8080
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = "";
            while ((s = Console.ReadLine()) != null)
            {
                var n = int.Parse(s);
                int i = 1;
                while(n != 0)
                {
                    if((n & 1) != 0)
                    {
                        Console.Write(i + (n == 1 ? "\n" : " "));
                    }
                    i <<= 1;
                    n >>= 1;
                }
            }
        }
    }
}

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

int main(){
  long long N, A, B;
  cin >> N >> A >> B;
  long long ans=0;
  long long cnt;
  ans+=N/(A+B)*A;
  cnt = min(A, N%(A+B));
  ans+=cnt;
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();	//トッピングの種類
		int baseprice = sc.nextInt();	//生地の値段
		int	topprice  = sc.nextInt();	//トッピングの値段
		int basecal = sc.nextInt();	//生地のカロリー
		int topcal [] = new int[N];
		for(int i = 0; i < N; i++){
			topcal [i] = sc.nextInt();	//トッピングのカロリー
		}
		for(int i = 0; i < N; i++){
			for(int k = 0; k < N; k++){
				if( topcal[i]>topcal[k]){
					int work = topcal[i];
					topcal[i] = topcal[k];
					topcal[k] = work;
				}
			}
		}
		//Arrays.sort(topcal);
		for(int i = 0;i < N;i++){
			if((basecal+topcal[i])/(baseprice+topprice)>=(basecal/baseprice)){
				basecal += topcal[i];
				baseprice += topprice;
				}
			}
		System.out.println(basecal/baseprice);
	}

}

Measured memory_bytes: 18212
import sys
import math

n = input()

s = [set(), set(), set(), set()]
ch = {0:"S", 1:"H", 2:"C", 3:"D"}

for i in xrange(n) :
    kind, num = raw_input().split()
    num = int(num)

    for j in xrange(4) :
        if (kind == ch[j]) :
            s[j].add(num)
            break

for i in xrange(4) :
    for j in xrange(1, 14) :
        if not(j in s[i]) :
            print ch[i], j

Measured memory_bytes: 6396
#include <iostream>

using namespace std;

class dice{
public:
	int me[6];
	int set();
	int roll(char c);
	int show();
};

int dice::set(){
	int i;

	for (i = 0; i < 6; i++)
		cin >> me[i];

	return 0;
}

int dice::roll(char c){
	int temp;
	if (c == 'S'){
		temp = me[0];
		me[0] = me[4];
		me[4] = me[5];
		me[5] = me[1];
		me[1] = temp;
	}
	else if (c == 'N'){
		temp = me[0];
		me[0] = me[1];
		me[1] = me[5];
		me[5] = me[4];
		me[4] = temp;
	}
	else if (c == 'W'){
		temp = me[0];
		me[0] = me[2];
		me[2] = me[5];
		me[5] = me[3];
		me[3] = temp;
	}
	else if (c == 'E'){
		temp = me[0];
		me[0] = me[3];
		me[3] = me[5];
		me[5] = me[2];
		me[2] = temp;
	}
	else{
		temp = me[1];
		me[1] = me[2];
		me[2] = me[4];
		me[4] = me[3];
		me[3] = temp;
	}

	return 0;
}

int dice::show(){

	cout << me[0] << endl;
	return 0;
}

int main(){
	dice d[2];
	string s = "SSSSWSSSSWSSSS", spin = "ssss";
	int i,j;
	int n;
	int f = 1;

	cin >> n;

	d[0].set();

	for (i = 1; i < n; i++){
		d[1].set();
		for (j = 0; j < s.length(); j++){
			if (d[0].me[0] == d[1].me[0] && d[0].me[5] == d[1].me[5])
				break;
			else{
				d[1].roll(s[j]);
			}
		}
		for (j = 0; j < spin.length(); j++){
			if (d[0].me[1] == d[1].me[1] && d[0].me[2] == d[1].me[2] && d[0].me[3] == d[1].me[3] && d[0].me[4] == d[1].me[4])
				break;
			else{
				d[1].roll(spin[j]);
			}
		}

		if (d[0].me[0] == d[1].me[0] && d[0].me[1] == d[1].me[1] && d[0].me[2] == d[1].me[2] && d[0].me[3] == d[1].me[3] && d[0].me[4] == d[1].me[4] && d[0].me[5] == d[1].me[5])
		{
			f = 0;
		}
	}
	

	if (f==1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

using namespace std;

int
main(void){
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int tmp = min(x, y);
	int ans = min(x*a + y*b, min(tmp*2*c + (x - tmp)*a + (y - tmp)*b, max(x, y)* 2 * c));
	cout << ans; 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    constexpr double pi = 3.1415926535897932;
    
    double A, B, H, N;
    cin >> A >> B >> H >> N;
    
    double kakudo = abs(pi / 6 * H - 11 * pi * N / 360);
    kakudo = min(kakudo, pi * 2 - kakudo);
    cout << fixed << setprecision(15) << sqrt(A * A + B * B - 2 * A * B * cos(kakudo)) << endl;
    return 0;
}



Measured memory_bytes: 4228
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <random>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
ll rand26() {
  random_device rnd;
  mt19937 mt(rnd());
  uniform_real_distribution<> rand(0, 25);
  return (ll)rand(mt);
}
ll rand365() {
  random_device rnd;
  mt19937 mt(rnd());
  uniform_real_distribution<> rand(0, 364);
  return (ll)rand(mt);
}
int main()
{
  ll D; cin >> D;
  vector<ll> c(26);
  rep(i,26) cin >> c[i];
  vector<vector<ll>> s(D, vector<ll>(26));
  rep(i,D) {
    rep(j,26) {
      cin >> s[i][j];
    }
  }

  vector<ll> t(D);  
  vector<ll> last(26, -1);
  rep(i,D) {
    ll score = -1000000000;
    rep(j,26) {
      ll tmp = 0;
      rep(k,26) {
	if(j == k) {
	  tmp += s[i][j];
	}
	else {
	  tmp -= c[k] * (i - last[k]);
	}
      }
      if( chmax(score, tmp) ) {
	t[i] = j;
      }
    }
  }
  
  ll m = 26*365*140;
  vector<ll> d(m), q(m);
  rep(k,140) {
    rep(i,26) {
      rep(j,365) {
	d[k*26*365 + i*365 + j] = (j + k) % 365;
	q[k*26*365 + i*365 + j] = (i + k) % 26;
      }
    }
  }
  
  vector<set<ll>> st(26);
  rep(i,26) {
    st[i].insert(-1);
    st[i].insert(D);    
  }
  rep(i,D) {
    st[t[i]].insert(i);
  }

  ll res = 0;
  // ペナルティ
  vector<ll> pen(26, 0);
  rep(i,26) {
    auto it = st[i].begin();
    it++;
    while(it != st[i].end()) {
      auto it2 = it;
      it2--;
      ll x = *it - *it2 - 1;
      res -= x * (x + 1) / 2 * c[i];
      pen[i] += x * (x + 1) / 2 * c[i];
      it++;
    }
  }
  rep(i,D) {
    res += s[i][t[i]];
  }

  rep(i,0){
    ll oldres = res;
    ll old = t[d[i]];
    ll neww = q[i];
    if(old == neww) continue;
    set<ll> oldst1 = st[old];
    set<ll> oldst2 = st[neww];    
    ll oldpen1 = pen[old];
    ll oldpen2 = pen[neww];
    
    res += s[d[i]][neww] - s[d[i]][old];
    st[old].erase(d[i]);
    st[neww].insert(d[i]);    
    // old
    res += pen[old];
    pen[old] = 0;
    auto it = st[old].begin();
    it++;
    while(it != st[old].end()) {
      auto it2 = it;
      it2--;
      ll x = *it - *it2 - 1;
      res -= x * (x + 1) / 2 * c[old];
      pen[old] += x * (x + 1) / 2 * c[old];
      it++;
    }
    // new
    res += pen[neww];
    pen[neww] = 0;
    it = st[neww].begin();
    it++;
    while(it != st[neww].end()) {
      auto it2 = it;
      it2--;
      ll x = *it - *it2 - 1;
      res -= x * (x + 1) / 2 * c[neww];
      pen[neww] += x * (x + 1) / 2 * c[neww];
      it++;
    }

    if(oldres < res) {
      t[d[i]] = neww;
    }
    else {
      t[d[i]] = old;
      st[old] = oldst1;
      st[neww] = oldst2;
      pen[old] = oldpen1;
      pen[neww] = oldpen2;      
    }
  }

  rep(i,D) cout << t[i]+1 << "\n";
  
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int k;
  cin>>k;
  int m = max(max(a,b),c);
  int ans = a + b + c - m + (m<<k);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;

struct Idx { int ia, ib, ic; };
bool used[1003][1003][1003];
deque<Idx> que;
vector<ll> ans;

int main() {
	int X, Y, Z, K; cin >> X >> Y >> Z >> K;
	vector<ll> a(X), b(Y), c(Z);
	for (int i = 0; i < X; i++) cin >> a[i];
	for (int i = 0; i < Y; i++) cin >> b[i];
	for (int i = 0; i < Z; i++) cin >> c[i];
	sort(a.rbegin(), a.rend());
	sort(b.rbegin(), b.rend());
	sort(c.rbegin(), c.rend());
	vector<ll> abc;
	for (int i = 0; i < X; i++) {
		for (int j = 0; j < Y; j++) {
			for (int k = 0; k < Z; k++) {
				if ((i + 1)*(j + 1)*(k + 1) > K) continue;
				abc.push_back(a[i] + b[j] + c[k]);
			}
		}
	}
	sort(abc.rbegin(), abc.rend());
	for (int i = 0; i < K; i++) cout << abc[i] << endl;
	return 0;
}


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

using namespace std;

#define ll  long long
#define ld long double
#define f first
#define s second
#define matrix vector<vector<char>>
#define zero(n,m) matrix(n , vector<char>(m,'0'))
#define one(n,m) matrix(n , vector<ll>(m,1))
#define pii pair<int,int>
#define point complex<ld>
#define angle(a) (atan2((a).imag() , (a).real() ))
#define pi acos(-1)
#define X real()
#define Y imag()

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

    string s;
    cin >> s;
    if (s.back() == 's') s += "es";
    else s += 's';
    cout << s << '\n';

    return 0;
}

Measured memory_bytes: 3648
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	N := getInt()
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt()
	}
	// out(a)
	ans := 0
	for i := 0; i < N-1; i++ {
		pair := a[i]
		if a[i+1] < a[i] {
			pair = a[i+1]
		}
		// out("pair", a[i], pair)
		if pair != 0 && (a[i]-pair)%2 == 1 {
			pair--
		}
		a[i] -= pair
		a[i+1] -= pair
		ans += pair
		x := a[i] / 2
		ans += x
		a[i] -= x * 2
		// out(pair)
	}
	ans += a[N-1] / 2
	//out(a)
	out(ans)
}


Measured memory_bytes: 3072
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		long e = sc.nextLong();


		long min = Math.min(a, b);
		min = Math.min(min, c);
		min = Math.min(min, d);
		min = Math.min(min, e);

		long sum = n / min;
		if (n % min != 0) {
			sum = sum + 1;
		}

		System.out.println(sum + 4);
	}

}

Measured memory_bytes: 23380
#include <iostream>

using namespace std;

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[10001];
int main(){
  scanf("%s",s+1);
  int n=strlen(s+1);
  for (int i=1;i<=n;i++)if (s[i]!='1'&&s[i]!='9')printf("%c",s[i]);else printf("%c",'9'-s[i]+'1');
}

Measured memory_bytes: 256
n = int(input())
act = [list(map(int, input().split())) for i in range(n)]

a = [0]*n
b = [0]*n
c = [0]*n

#a[n]は、n日目にaをした場合のn日間の幸福度の最大値

a[0] = act[0][0]
b[0] = act[0][1]
c[0] = act[0][2]


for i in range(1,n):
    a[i] = max(b[i-1], c[i-1]) + act[i][0]
    b[i] = max(c[i-1], a[i-1]) + act[i][1]
    c[i] = max(b[i-1], a[i-1]) + act[i][2]

print(max(a[n-1], b[n-1], c[n-1]))

Measured memory_bytes: 42484
#include <bits/stdc++.h>
#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(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var <<  " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  const int N = 3;
  int c[N][N];
  REP(i,N)REP(j,N){
      int cx;
      cin >> cx;
      c[i][j] = cx;
  }

  vector<int> a(N);
  vector<int> b(N);
  a[0] = 0;
  REP(i,N) b[i] = c[0][i] - a[0];
  a[1] = c[1][0] - b[0];
  a[2] = c[2][0] - b[0];
  bool ok = true;
  REP(i,N)REP(j,N){
    if(c[i][j] != a[i]+b[j]){
      ok = false;
      break;
    }
  }
  debug(a);
  debug(b);
  debug(c);

  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;  
  return 0;
}

Measured memory_bytes: 3584
# coding: utf-8
# Your code here!

l = [0] * 110

while True:
   try:
      n = int(input())
      l[n] += 1
   except EOFError:
      break

m = max(l)
for i in range(1, 101):
   if l[i] == m:
      print(i)
 


Measured memory_bytes: 5596
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
struct UnionFind {
    VI d;
    UnionFind(int n = 0): d(n,-1) {}
    int find(int x) {
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x,int y) {
        x = find(x); y = find(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x,int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};
int deg[100005];
VI to[100005];

struct mint {
  LL x; // typedef long long ll;
  mint(LL x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
    if(n == 0) return 1;
    mint x = f(n/2);
    x *= x;
    if(n%2 == 1) x *= 2;
    return x;
}

mint choose(int n,int a) {
    mint x = 1, y = 1;
    rep(i,a) {
        x *= n-i;
        y *= i+1;
    }
    return x/y;
}

int main() {
    int n;
    cin >> n;
    if(n%10 == 3) {
      cout << "bon" << endl;
    } else if(n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8) {
      cout << "pon" << endl;
    } else {
      cout << "hon" << endl;
    }
}


Measured memory_bytes: 5972
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
    int n,m;
    scanf("%d",&n);
    char a[n][12];
    for(int i=0;i<n;i++)
        scanf("%s",a[i]);
    scanf("%d",&m);
    char b[m][12];
    for(int i=0;i<m;i++)
        scanf("%s",b[i]);
    int c[101]={0};
    for(int i=0;i<n;i++)
        c[i]=1;
    for(int i=0;i<n;i++)
        for(int k=0;k<m;k++)
    {
        if(strcmp(a[i],b[k])==0)
            c[i]--;
    }
    for(int i=0;i<n;i++)
        for(int k=i+1;k<n;k++)
    {
        if(strcmp(a[i],a[k])==0)
            c[i]++;
    }
    int max=c[0];
    for(int i=1;i<=n;i++)
    {
        if(c[i]>max)
            max=c[i];
    }
    printf("%d\n",max);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define MAX 26
#define NIL -1

typedef struct{
  int p;
  int l;
  int r;
} Tree;

Tree T[MAX];

void preParse(int u){
  if(u==NIL) return;

  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u==NIL) return;

  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u==NIL) return;

  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

int main(){
  int n,i,id,left,right;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].p=-1;
    T[i].l=-1;
    T[i].r=-1;
  }

  for(i=0;i<n;i++){
    scanf("%d%d%d",&id,&left,&right);
    T[id].l=left;
    T[id].r=right;
    if(left!=NIL) T[left].p=id;
    if(right!=NIL) T[right].p=id;
  }

  for(i=0;i<n;i++){
    if(T[i].p==NIL){
      printf("Preorder\n");
      preParse(i);
      printf("\nInorder\n");
      inParse(i);
      printf("\nPostorder\n");
      postParse(i);
    }
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 616