akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;
typedef unsigned long long ull;

inline int scan() {
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
inline void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
using namespace std;
int a[200005];
int b[200005];
int w1[200005];
int w2[200005];
int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
    cin >> a[i];
    for(int i = 1; i <= n; i++)
    cin >> b[i];
    int ans = 0;
    for(int i = 0; i <= 28; i++)
    {
        for(int j = 1; j <= n; j++)w1[j] = a[j]&(1<<i+1)-1;
        for(int j = 1; j <= n; j++)w2[j] = b[j]&(1<<i+1)-1;
        sort(w2+1, w2+1+n);
        int now = 0;
        int t1 = 1<<i, t2 = t1*2, t3 = t1*3, t4 = t1*4;
        for(int j = 1; j <= n; j++)
        {
            now ^= (lower_bound(w2+1, w2+1+n, t2-w1[j])-lower_bound(w2+1, w2+1+n, t1-w1[j]))&1;
            now ^= (lower_bound(w2+1, w2+1+n, t4-w1[j])-lower_bound(w2+1, w2+1+n, t3-w1[j]))&1;
        }
        ans |= (now<<i);
    }

    cout << ans << endl;
    return 0;
}
/*
                 ___====-_  _-====___
           _--^^^#####//      \\#####^^^--_
        _-^##########// (    ) \\##########^-_
       -############//  |\^^/|  \\############-
     _/############//   (@::@)   \\############\_
    /#############((     \\//     ))#############\
   -###############\\    (oo)    //###############-
  -#################\\  / VV \  //#################-
 -###################\\/      \//###################-
_#/|##########/\######(   /\   )######/\##########|\#_
|/ |#/\#/\#/\/  \#/\##\  |  |  /##/\#/  \/\#/\#/\#| \|
`  |/  V  V  `   V  \#\| |  | |/#/  V   '  V  V  \|  '
   `   `  `      `   / | |  | | \   '      '  '   '
                    (  | |  | |  )
                   __\ | |  | | /__
                  (vvv(VVV)(VVV)vvv)
                  ÁúÉñ±£ÓÓ ÓÀÎÞbug
*/


Measured memory_bytes: 3328
s = gets.chomp
t = gets.chomp
f = {}
inv = {}

s.size.times do |i|
  f[s[i]] ||= t[i]
  inv[t[i]] ||= s[i]

  next if f[s[i]] == t[i] && inv[t[i]] == s[i]

  puts :No
  exit
end

puts :Yes

Measured memory_bytes: 14928
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int main()
{
	set<int> st;

	int n;
	cin >> n;

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

		if (st.find(a) == st.end()) {
			st.insert(a);
		}
		else {
			st.erase(a);
		}
	}

	cout << st.size() << endl;

	return 0;
}


Measured memory_bytes: 4864
#include <stdio.h>

int main(void) {

	int H, W;
	int i, j;

	while (1) {

		scanf("%d %d", &H, &W);

		if (H == 0 && W == 0)
			break;

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

				if (i == 0) {
					printf("#");
				}
				else if (i == H - 1) {
					printf("#");
				}
				else if (j == 0) {
					printf("#");
				}
				else if (j == W - 1) {
					printf("#");
				}
				else {
					printf(".");
				}
			}
			printf("\n");
		}

		printf("\n");
	}

	return(0);

}


Measured memory_bytes: 2032
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int X, A, B;

    scanf("%d%d%d", &X, &A, &B);

    printf("%d\n", (X-A) % B);

    return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>  
using namespace std;  
char a1[8] = {'1','2','3','4','5','6','7','8'},b1[8],c1[8];
bool check(char a[],char b[],int n){
	for(int i = 0; i < n; i++){
		if(a[i] != b[i])
			return 0;
	}
	return 1;
}
int main()  
{  
	int n,x1,x2,flag = 0,t = 0;
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> b1[i];
	for(int i = 0; i < n; i++)
		cin >> c1[i];
	if(check(b1,c1,n)){
		cout << 0 << endl;
	}
	else{
		while(next_permutation(a1,a1+n)){
			t++;
			if((check(a1,b1,n) || check(a1,c1,n)) && flag == 0){
				x1 = t;
				flag++;
			}
			else if((check(a1,b1,n) || check(a1,c1,n)) && flag == 1){
				x2 = t;
				flag++;
				break;
			}
		}
		cout << abs(x1-x2) << endl;	
	}
    return 0;  
}  

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

typedef unsigned long long int lli;
vector<lli> p;
int main(void){
	bool ps[200000];
	for(int i=0;i<200000;i++)ps[i]=true;
	ps[0]=ps[1]=false;
	p.push_back(0);
	for(int i=2;i<200000;i++){
		if(ps[i]){
			for(int j=2*i;j<200000;j+=i) ps[j]=false;
			p.push_back(i+p[p.size()-1]);
			if(p.size()==10001)break;
		}
	}
	int n;
	while(cin>>n,n){
		cout<<p[n]<<endl;
	}
}

Measured memory_bytes: 3340
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
CD = [list(map(int, input().split())) for _ in range(N)]

cnt = 0
sCD = sorted(CD, key=lambda x: x[1])
for c, d in sCD:
  AB = sorted(AB, key=lambda x: - x[0])
#  print(AB)
  for itr in range(len(AB)):
    a, b = AB[itr]
    if a < c and b < d:
      cnt += 1
      AB.pop(itr)
      break
print(cnt)

Measured memory_bytes: 39408
using System;
using System.Collections.Generic;
class MathClass
{
    static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var set = new SortedSet<int>();
        for(int i = 0; i < N; i++)
        {
            var d = int.Parse(Console.ReadLine());
            set.Add(d);
        }
        Console.WriteLine(set.Count);
    }
}

Measured memory_bytes: 13268
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int a, b, k; cin >> a >> b >> k;

	int ans = 0, cnt_k=0;
	rrep(i, 100){
		int div = i + 1;
		if(a % div == 0 && b % div == 0){
			cnt_k++;
			if(cnt_k == k) {
				ans = div;
				break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3548
#include <cstdio>
#include <cstring>
#define FOR(i, l, r) for(int i = l; i <= r; ++i)

using namespace std;

const int N = 200010;
const int mod = 998244353;

char s[N];
int n, fl, ans, tmp;
int vis[N], f[N][3], h[N][3][3];

void brute_force()
{
    int tmp = 0;
    FOR(i, 1, n) tmp = tmp * 10 + s[i] - 'a' + 1;
    if (vis[tmp]) return; else ++ans, vis[tmp] = 1;

    FOR(i, 1, n - 1) if (s[i] != s[i + 1])
    {
        char t1 = s[i], t2 = s[i + 1], t3 = 'a' + 'b' + 'c' - t1 - t2;
        s[i] = s[i + 1] = t3; brute_force();
        s[i] = t1, s[i + 1] = t2;
    }
}

int main()
{
    scanf("%s", s + 1), n = strlen(s + 1);

    FOR(i, 2, n) if (s[i] != s[1]) fl = 1;
    if (!fl) {puts("1"); return 0;}

    if (n <= 3) {brute_force(); printf("%d\n", ans); return 0;}

    FOR(i, 2, n) if (s[i] == s[i - 1]) fl = 0;
    if (fl) ans = 1;

    FOR(i, 1, n) tmp += s[i] - 'a'; tmp %= 3;

    f[0][0] = 1;
    FOR(i, 0, n - 1) FOR(j, 0, 2) FOR(k, 0, 2)
        (f[i + 1][(j + k) % 3] += f[i][j]) %= mod;
    (ans += f[n][tmp]) %= mod;

    FOR(i, 0, 2) h[1][i][i] = 1;
    FOR(i, 1, n - 1) FOR(j, 0, 2) FOR(k, 0, 2) FOR(l, 0, 2)
        if (l != k) (h[i + 1][(j + l) % 3][l] += h[i][j][k]) %= mod;
    FOR(i, 0, 2) (ans += mod - h[n][tmp][i]) %= mod;

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
const int INF = 1e9;

template <typename T>
class MedianQueue{
  public:
    priority_queue<T,vector<T>> leftQ;
    priority_queue<T,vector<T>,greater<T>> rightQ;
    MedianQueue() {}
    ~MedianQueue() {}
    void push(T x) {
        if (leftQ.empty() || x <= leftQ.top()) {
            leftQ.push(x);
        } else {
            rightQ.push(x);
        }
    }
    pair<T,T> get_median() {
        while (abs((int)leftQ.size() - (int)rightQ.size()) > 1) {
            if (leftQ.size() < rightQ.size()) {
                leftQ.push(rightQ.top());
                rightQ.pop();
            } else {
                rightQ.push(leftQ.top());
                leftQ.pop();
            }
        }
        if (leftQ.size() + 1 == rightQ.size()) {
            return {rightQ.top(), rightQ.top()};
        } else if (leftQ.size() == rightQ.size() + 1){
            return {leftQ.top(), leftQ.top()};
        } else {
            return {leftQ.top(), rightQ.top()};
        }
    }
    int size() {
        return leftQ.size() + rightQ.size();
    }
};

int main(void){
    int Q;
    cin >> Q;
    MedianQueue<ll> qu;
    qu.push(-INF);
    qu.push(+INF);
    pair<ll,ll> med = qu.get_median();
    ll height = 0;
    rep(i,Q){
        int q;
        cin >> q;
        if (q == 1) {
            ll a,b;
            cin >> a >> b;
            height += b;
            qu.push(a);
            if (a < med.first || med.second < a) {
                height += min(abs(a - med.first), abs(a - med.second));
            }
            med = qu.get_median();
        } else {
            cout << med.first << " " << height << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3828
#include<iostream>
#include<vector>
#include<set>
#include<unordered_set>
#include<cmath>
#include<cstring>
#include<map>
#include<unordered_map>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;
int main(){
	FAST
	ll n;
	cin >> n;
	ll x = 1, y = n;
	for(ll i=2; i*i <= n; i++){
		if (n%i == 0) x = i, y = n/i;
	}
	cout << y+x-2;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
using namespace std;
const int MOD = 1000000007; 
typedef long long ll;
typedef string str;
 
int main(){
  int W,H,N;
  cin >> W >> H >> N;
  int square[H][W] = {};
  rep(i,N){
    int x,y,a;
    cin >> x >> y >> a;
    switch(a){
      case 1:
        rep(j,H)
          fill(square[j], square[j] + x, 1);
        break;
      case 2:
        rep(i,H)
          REP(j,x,W)
            square[i][j] = 1;
        break;
      case 3:
        rep(j,W)
          rep(i,y)
            square[i][j] = 1;
        break;
      case 4:
        REP(i,y,H)
          rep(j,W)
            square[i][j] = 1;
        break;
    }
  }

  int ans = 0;
  rep(i,H)
    ans += count(square[i],square[i] + W,0);

  cout << ans;

  return 0;
}

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

public class Test
{
	public static void Main()
	{
		// my code goes here
		var a = Console.ReadLine().Split().Select(b => int.Parse(b)).ToArray();
		if(a[0]<=a[1]){
			Console.WriteLine("unsafe");
		}else{
			Console.WriteLine("safe");
		}
	}
}

Measured memory_bytes: 28220
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    k=int(input())
    n=50
    q=k//n
    r=k%n
    A=[q+n-r+1+i for i in range(r)]+[q+i for i in range(n-r)]
    print(n)
    print(*A)
resolve()

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

int main()
{
  int n;
  cin >> n;
  
  vector<string> s(n);
  for(int i = 0; i < n; i++){
    cin >> s[i];
  }
  
  sort(s.begin(),s.end());
  int ans = 1;
  for(int i = 1; i < n; i++){
    if(s[i] != s[i-1]){
      ans++;
    }
  }//for
  
  cout << ans << endl;
}

Measured memory_bytes: 9580
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using VPII = vector<PII>;
template<typename T, typename C> using PQ = priority_queue<T, vector<T>, C>;
using Complex = complex<double>;


int A, B;


int F(int x){
    int ret = ((x+1)/2)%2;
    if(x%2 == 0) ret ^= x;
    return ret;
}


signed main(){
    cin >> A >> B;

    cout << (F(A-1)^F(B)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    char a, b; cin >> a >> b;

    if(a=='H'){
        if(b=='H'){
            cout << 'H' << endl;
        }
        else{
            cout << 'D' << endl;
        }
    }
    else{
        if(b=='H'){
            cout << 'D' << endl;
        }
        else{
            cout << 'H' << endl;
        }
        
    }
    return 0;
}


Measured memory_bytes: 256
H,W=map(int,input().split())
ans=10**10
for h in range(1,H):
    w=(W+1)//2
    S=[h*W,(H-h)*w,(H-h)*(W-w)]
    ans=min(ans,max(S)-min(S))
    h2=(H-h+1)//2
    S=[h*W,h2*W,(H-h-h2)*W]
    ans=min(ans,max(S)-min(S))    
for w in range(1,W):
    h=(H+1)//2
    S=[w*H,(W-w)*h,(W-w)*(H-h)]
    ans=min(ans,max(S)-min(S))
    w2=(W-w+1)//2
    S=[H*w,H*w2,H*(W-w-w2)]
    ans=min(ans,max(S)-min(S))
print(ans)

Measured memory_bytes: 42844
n, a, b, c = gets.chomp.split.map(&:to_i)
arr = Array.new(n)
n.times do |i|
	arr[i] = gets.chomp.to_i
end

min = 1145141919
mpm = 1145141919
[0, 1, 2, 3].repeated_permutation(n) do |bits|
	uniq = bits.uniq
	next if uniq.index(0) == nil || uniq.index(1) == nil || uniq.index(2) == nil

	abc = Array.new(4,0)
	bits.each_with_index do |bit, i|
		abc[bit] += arr[i]
	end
	sa = (abc[0]-a).abs + (abc[1]-b).abs + (abc[2]-c).abs
	mp = 0
	0.upto(2) do |j|
		mp += [(bits.count{|bit| bit == j} - 1), 0].max * 10
	end
	mp += sa
	if mp < mpm
		mpm = mp
		#puts "mpm:#{mpm}"
		#p bits
	end
end
puts mpm

Measured memory_bytes: 14668
import java.io.*;
import java.util.*;

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
}

class Solver {
  private static int[] DI = new int[]{1, 0, -1, 0};
  private static int[] DJ = new int[]{0, 1, 0, -1};
  
  private int pack(int numOp, int i, int j) {
    return (numOp << 20) | (i << 10) | j;
  }
  
  private int getI(int position) {
    return (position >> 10) & 0x3FF;
  }
  
  private int getJ(int position) {
    return position & 0x3FF;
  }
  
  private int getNumOp(int position) {
    return position >> 20;
  }
   
  public int solve(int h, int w, char[][] map) {
    /*
    HashSet<Integer> currentBlack = new HashSet<Integer>();
    HashSet<Integer> totalBlack = new HashSet<Integer>();
    */
    boolean[] visited = new boolean[1 << 20];
    ArrayDeque<Integer> queue = new ArrayDeque<>();
    
    for (int i = 0; i < map.length; i++) {
      for (int j = 0; j < map[i].length; j++) {
        if (map[i][j] == '#') {
          int position = pack(0, i, j);
          queue.add(position);
          visited[position & 0xFFFFF] = true;
        }
      }
    }
    
    int operation = 0;
    int numOp = 0;
    
    while (!queue.isEmpty()) {
      int position = queue.poll();
      numOp = getNumOp(position);
      int i = getI(position);
      int j = getJ(position);
      int nextNumOp = numOp + 1;
      for (int k = 0; k < DI.length; k++) {
        int nextI = i + DI[k];
        int nextJ = j + DJ[k];
        if (nextI < 0 || nextJ < 0 || nextI >= h || nextJ >= w) {
          continue;
        }
        int nextPosition = pack(nextNumOp, nextI, nextJ);
        if (visited[nextPosition & 0xFFFFF]) {
          continue;
        }
        visited[nextPosition & 0xFFFFF] = true;
        queue.addLast(nextPosition);
      }
    }
    return numOp;
  }
}

public class Main {
  private static void execute(ContestReader reader, PrintWriter out) {
    int h = reader.nextInt();
    int w = reader.nextInt();
    char[][] map = new char[h][];
    for (int i = 0; i < h; i++) {
      map[i] = reader.next().toCharArray();
    }
    
    out.println(new Solver().solve(h, w, map));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}



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

#define mp make_pair
#define pb push_back

#define ll long long

const int MOD = 1e9+7;

int n,m;
const int N=1e5+5;
vector<int> adj[N];
int dp[N];
int maxans=0;
vector<int> vis(N,0);

void dfs(int x)
{
    if(vis[x])
        return;
    vis[x]=1;
    if(adj[x].size()==0)
    {
        dp[x]=1;
        return;
    }
    dp[x]=0;
    for(auto it : adj[x])
    {
        dfs(it);
    }

    for(auto it : adj[x])
    {
        dp[x]=max(dp[x],1+dp[it]);
    }
    maxans=max(maxans, dp[x]);
}

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

    cin>>n>>m;
    for(int i=0;i<=n;i++)
        dp[i]=0;
    int a,b;
    for(int i=0;i<m;i++)
    {
        cin>>a>>b;
        adj[a].pb(b);
    }

    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            dfs(i);
        }
    }

    cout<<maxans-1;

    return 0;
}

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

char tbl[128][2] = {0};
int N;

////////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////////
char convert(char c)
{
	int i;
	for ( i = 0 ; i < N ; i++ ) {
		if(tbl[i][0] == c) {
			c = tbl[i][1];
			break;
		}
	}
	return c;
}

////////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////////
int main(void){
	int i;
	int M;
	char c;

	while(1) {
		scanf("%d", &N);

		if ( N == 0) break;

		for ( i = 0 ; i < N ; i++ ) {
			scanf(" %c %c", &tbl[i][0], &tbl[i][1]);
		}

		scanf("%d", &M);

		for ( i = 0 ; i < M ; i++ ) {
			scanf(" %c", &c);
			printf("%c", convert(c));
		}

		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 572
#include<iostream>
using namespace std;
int main(){
    int h, w, a, b;
    cin >>h>> w >> a >>b;
    for(int i=0; i<b; i++){
        for(int j=0; j<a; j++) cout << "0";
        for(int j=a; j<w; j++) cout << "1";
        cout << endl;
    }
    
    for(int i=b; i<h; i++){
        for(int j=0; j<a; j++) cout << "1";
        for(int j=a; j<w; j++) cout << "0";
        cout << endl;
    }
	return 0;
}

Measured memory_bytes: 1280
# coding:utf-8

import sys
from collections import deque, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


# UnionFind
class UnionFind:
    # 負: ルートで値は木のサイズを表す
    # 正: 子で値は次のノードを表す
    def __init__(self, size: int) -> None:
        self.nodes = [-1] * size  # 初期状態では全てのノードがルート

    def find(self, x: int) -> int:
        if self.nodes[x] < 0:
            return x
        else:
            self.nodes[x] = self.find(self.nodes[x])
            return self.nodes[x]

    def unite(self, x: int, y: int) -> bool:
        rx, ry = self.find(x), self.find(y)
        if rx == ry:
            return False

        if self.size(x) < self.size(y):
            rx, ry = ry, rx

        self.nodes[rx] += self.nodes[ry]
        self.nodes[ry] = rx

        return True

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return - self.nodes[self.find(x)]


def main():
    n, m = LI()

    uf = UnionFind(n)
    res = deque()
    res.append(n * (n - 1) // 2)
    AB = [LI_() for _ in range(m)]
    AB.reverse()
    for a, b in AB:
        if uf.same(a, b):
            res.append(res[-1])
            continue

        tmp = res[-1] - uf.size(a) * uf.size(b)
        if tmp < 0:
            tmp = 0
        res.append(tmp)
        uf.unite(a, b)

    res.reverse()
    res.popleft()
    print(*res, sep='\n')


main()


Measured memory_bytes: 29076
#include<iostream>
using namespace std;
static const int MAX =100;
static const int INFTY=(1<<21);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n,M[MAX][MAX];

void dijkstra(){
  int minv;
  int d[MAX],color[MAX];

  for(int i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }

  d[0]=0;
  color[0]=GRAY;
 
  while(1){
    minv=INFTY;
    int u=-1;
    for(int i=0;i<n;i++){
      if(minv>d[i]&&color[i]!=BLACK){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
    for(int v=0;v<n;v++){
      if(color[v]!=BLACK&&M[u][v]!=INFTY){
	if(d[v]>d[u]+M[u][v]){
	  d[v]=d[u]+M[u][v];
	  color[v]=GRAY;
	}
      }
    }
  }
 
  for(int i=0;i<n;i++){
    cout<<i<<" "<<(d[i]==INFTY?-1:d[i])<<endl;
  }
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      M[i][j]=INFTY;
    }
  }
  int k,c,u,v;
  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>v>>c;
      M[u][v]=c;
    }
  }
  dijkstra();
  return 0;
}




Measured memory_bytes: 3120
n,k=map(int,input().split())
s=input()

happy=0
unhappy=0
for i in range(1,n):
  if s[i]==s[i-1]:
    happy+=1
  else:
    unhappy+=1

for i in range(k):
  if unhappy==1:
    unhappy-=1
    happy+=1
    break
  unhappy-=2
  happy+=2

print(min(happy,n-1))

Measured memory_bytes: 9236
s = input()

def ispalindrome(str): return 1 if str == str[::-1] else 0

nagasa = (int(len(s)) - 1) // 2
nagasa2 = (int(len(s)) +3 ) // 2
nagasa3 = int(len(s))

result = ispalindrome(s) #回文なら1

tmp = s[0:nagasa]
result = result + ispalindrome(tmp)

tmp2 = s[nagasa2-1:nagasa3]
result = result + ispalindrome(tmp2)

if result == 3:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
n = int(input())

f = 1
for i in range(1,n+1):
    f *= i

ps = [0 for i in range(101)]
for i in range(2,100):
    while f % i == 0:
        f //= i
        ps[i] += 1

ans = 0
for i1 in range(0,100):
    for i2 in range(0,100):
        for i3 in range(i2+1,100):
            if i1 == i2 or i1 == i3: continue
            if (ps[i1]+1) >= 3 and (ps[i2]+1) >= 5 and (ps[i3]+1) >= 5:
                ans += 1
for i1 in range(0,100):
    for i2 in range(0,100):
        if i1 == i2: continue
        if (ps[i1]+1) >= 3 and (ps[i2]+1) >= 25:
            ans += 1
        if (ps[i1]+1) >= 15 and (ps[i2]+1) >= 5:
            ans += 1
            
for i1 in range(0,100):
    if (ps[i1]+1) >= 75:
        ans += 1

print(ans)


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

int main() {
    int ans=0, N, minNum=2e9, X;   
    cin >> N >>X;
    vector<int> m(N);
    
    for(int i=0; i<N ; i++){
	cin >> m[i];
	minNum = min(minNum, m[i]);
	X-=m[i];	
	ans++;
    }

    ans += X/minNum;

    

    
    cout << ans<< endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int d = Integer.parseInt(in.next());
            int n = Integer.parseInt(in.next());
            int ans = 0;

            if (n != 100) ans = (int) (n * Math.pow(100, d));
            else ans = (int) (101 * Math.pow(100, d));

            // 出力
            out.println(ans);

        }

    }
}



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

int main(){
	int n;
	int i;
	int max, min;
	long sum=0;
	
	cin >> n;
	int a[n];
	
	for(i=0;i<n;i++){
		cin >> a[i];
		sum+=a[i];
	}
	
	max=a[0];
	min=a[0];
	for(i=1;i<n;i++){
		if(max<a[i])
			max=a[i];
		if(min>a[i])
			min=a[i];
	}
	
	cout << min << ' ' << max << ' ' << sum << endl;
	
	return 0;
}

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

int main() {
    int n;
    int a[100];
    cin >> n;
    for (int i=0;i<n;i++) cin >> a[i];
    for (int i=n-1;0<=i;i--) {
        cout << a[i];
        if (i != 0) cout << " ";
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 1164
n = int(input())

def g1(n, p):
    if n == 0:
        return 0
    return n//p + g1(n//p, p)

def g2(n, p):
    if n%2 == 1:
        return g1(n,p) - g2(n-1, p)
    res = g1(n//2, p)
    if p == 2:
        res += n//2
    return res
        
ans = min(g2(n,2), g2(n,5))
print(ans)

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

using namespace std;

long long n,q,cnt,mx,m,temp,k;
long long a[100101];
long long b[100101];
long long c[100101];
long long table[100101][3];
string str;
long long N,K;

long long solve(int i , int j ){
    
    if(i>=N)return 0;

    if(table[i][j]!=-1) return table[i][j];
    
    if(j == 0)table[i][j]= a[i]+max(solve(i+1 , 2) , solve(i+1 , 1)   );
    if(j == 1)table[i][j]= b[i]+max(solve(i+1 , 2) , solve(i+1 , 0)   );
    if(j == 2)table[i][j]= c[i]+max(solve(i+1 , 0) , solve(i+1 , 1)   );

    
    return table[i][j];
}

int main()
{
    cin>>n;
    N=n;
    K=k;
    for(int i=0;i<n;i++){
        table[i][0]=-1;
        table[i][1]=-1;
        table[i][2]=-1;
    }
    
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    solve(0,0);
    solve(0,1);
    solve(0,2);
    cout<<max(table[0][0],max(table[0][1],table[0][2]));
    
    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef pair<int, int> P;

int h, w, s;
int u[100][100];
int sum[110][100];
P dp[35][35][35][35];

int getSum(int lx, int ly, int rx, int ry) {
	return sum[ry + 1][rx + 1] - sum[ry + 1][lx] - sum[ly][rx + 1] + sum[ly][lx];
}
P f(int lx, int ly, int rx, int ry) {
	//cout << lx << " " << ly << " " << rx << " " << ry << endl;
	if(dp[lx][ly][rx][ry].first != 0) return dp[lx][ly][rx][ry];
	int d = sum[h][w] - getSum(lx, ly, rx, ry);
	P ret = P(1, s - d);
	for(int i = ly; i < ry; i++) {
		int d1 = sum[h][w] - getSum(lx, ly, rx, i);
		int d2 = sum[h][w] - getSum(lx, i + 1, rx, ry);
		if(d1 > s || d2 > s) continue;
		P a = f(lx, ly, rx, i);
		P b = f(lx, i + 1, rx, ry);
		P p = P(a.first + b.first, min(a.second, b.second));
		ret = max(ret, p);
	}
	for(int j = lx; j < rx; j++) {
		int d1 = sum[h][w] - getSum(lx, ly, j, ry);
		int d2 = sum[h][w] - getSum(j + 1, ly, rx, ry);
		if(d1 > s || d2 > s) continue;
		P a = f(lx, ly, j, ry);
		P b = f(j + 1, ly, rx, ry);
		P p = P(a.first + b.first, min(a.second, b.second));
		ret = max(ret, p);
	}
	return dp[lx][ly][rx][ry] = ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	;
	while(cin >> h >> w >> s, h) {
		for(int i = 0; i < 35; i++) {
			for(int j = 0; j < 35; j++) {
				for(int k = 0; k < 35; k++) {
					for(int l = 0; l < 35; l++) {
						dp[i][j][k][l] = P(-1, -1);
					}
				}
			}
		}
		memset(dp, 0, sizeof dp);
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				cin >> u[i][j];
			}
		}

		for(int i = 1; i <= h; i++) {
			for(int j = 1; j <= w; j++) {
				sum[i][j] = u[i - 1][j - 1] + sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
			}
		}

		P ans = f(0, 0, w - 1, h - 1);
		cout << ans.first << " " << ans.second << endl;
	}
}

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

int A,B,R;

vector<int> P[11000];

bool check( int x, int y, int x1, int y1 ){
  if( (x1-x)*(x1-x) + (y1-y)*(y1-y) > 16*R*R ) return false;
  return true;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  while( cin >> A >> B >> R && (A||B||R) ){
    for(int i=0;i<=10000;i++) P[i].clear();
    for(int i=0;i<A;i++){
      int x,y;
      cin >> x >> y;
      P[x].push_back( y );
    }

    for(int i=0;i<=10000;i++) sort( P[i].begin(), P[i].end() );    

    int res = 0;
    for(int i=0;i<B;i++){
      int x,y; cin >> x >> y;
      //cout << x << " " << y << " : " << endl;
      for(int nx = max(0,x-4*R);nx<=x+4*R;nx++ ){
        int id = lower_bound( P[nx].begin(), P[nx].end(), y-4*R ) - P[nx].begin();
        for(int j=id;j<P[nx].size();j++){
          //cout << nx << " "<< P[nx][j] << endl;
          if( P[nx][j] > y + 4*R ) break;
          if( check( nx, P[nx][j], x, y ) ) res++;
        }
      }     
    }
    cout << res << endl;
    
  }
}

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


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

  long double l;
  cin >> l;
  long double ans = l/3 * l/3 * l/3;
  cout << fixed << setprecision(17) << ans << endl;


  return 0;
    

}


Measured memory_bytes: 256
N, M = map(int, input().split())
req = []
for i in range(M):
    a, b = map(int, input().split())
    req.append([a, b])

req = sorted(req, key=lambda x: x[1])

ans = 1
current = req[0][1]
for i in range(1, len(req)):
    if req[i][0] < current:
        continue
    current = req[i][1]
    ans += 1
print(ans)

Measured memory_bytes: 26312
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

const ll MOD = 1e9+7;
signed main(){
    int n; cin >> n;
    n=n%10;
    if(n==2||n==4||n==5||n==7||n==9)cout<<"hon"<<endl;
    else if(n==0||n==1||n==6||n==8)cout<<"pon"<<endl;
    else if(n==3)cout<<"bon"<<endl;
}



Measured memory_bytes: 3640
/**
 * Transformation.cpp
 * Create:20180430
 * Description:文字列strに対して、
 * 与えられた命令の列を実行するプログラム
 * print a b strのa文字目からb文字目までを出力する
 * reverse a b strのa文字目からb文字目までを逆順にする
 * replace a b p strのa文字目からb文字目までをpに置き換える
 */
#include <iostream>

const std::string COMMAND_PRINT = "print";
const std::string COMMAND_REVERSE = "reverse";
const std::string COMMAND_REPLACE = "replace";

void print(const std::string &str, int a, int b);
std::string reverse(const std::string &str, int a, int b);
std::string replace(const std::string &str, int a, int b, const std::string &p);

int main(int argc, char* argv[]){
  std::string word;
  int count;

  std::cin >> word;
  std::cin >> count;
  for (int i = 0; i < count; i++){
    std::string command;
    std::string p;
    int start, end;
    std::cin >> command >> start >> end;

    if (command == COMMAND_PRINT){
      print(word, start, end);
    }
    if (command == COMMAND_REVERSE){
      word = reverse(word, start, end);
    }
    if (command == COMMAND_REPLACE){
      std::cin >> p;
      word = replace(word, start, end, p);
    }
  }

  return 0;
}

/**
 * 表示関数
 * @param str 元の文字列
 * @param a   スタート位置
 * @param b   終了位置
 */
void print(const std::string &str, int a, int b){
  std::string result = str.substr(a, (b + 1 - a));
  std::cout << result << std::endl;
}

/**
 * 逆転関数
 * @param  str 元の文字列
 * @param  a   スタート位置
 * @param  b   終了位置
 * @return     処理結果文字列
 */
std::string reverse(const std::string &str, int a, int b){
  std::string result = str.substr(0, a);
  std::string tmp = "";
  for (char c:str.substr(a, (b + 1 - a))){
    tmp = c + tmp;
  }
  result += tmp;
  result += str.substr(b + 1, (str.size() - (b + 1)));
  return result;
}

/**
 * 置換関数
 * @param  str 元の文字列
 * @param  a   スタート位置
 * @param  b   終了位置
 * @param  p   置換文字列
 * @return     処理結果文字列
 */
std::string replace(const std::string &str, int a, int b, const std::string &p){
  std::string result = str.substr(0, a);
  result += p;
  result += str.substr(b + 1, (str.size() - b));
  return result;
}


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

vector<int> getFail(const string& s) {
	vector<int> fail = {-1};
	for (int i = 0; i < int(s.size()); i++) {
		int cur = fail.back();
		while (cur != -1 && s[i] != s[cur]) {
			cur = fail[cur];
		}
		fail.push_back(cur + 1);
	}
	return fail;
}

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

	string s; cin >> s;
	int N = int(s.size());

	vector<int> fail = getFail(s);
	vector<int> rfail = getFail(string(s.rbegin(), s.rend()));

//	for (int v : fail) { cerr << v << ' '; } cerr << endl;
//	for (int v : rfail) { cerr << v << ' '; } cerr << endl;

	if (fail.back() == N-1) {
		cout << N << '\n';
		cout << 1 << '\n';
		exit(0);
	}

	// whether s[0...i) is cyclic
	auto isCyclic = [](const vector<int>& f, int i) -> bool {
		return i > 1 && f[i] != 0 && i % (i - f[i]) == 0;
	};

	if (!isCyclic(fail, N)) {
		cout << 1 << '\n';
		cout << 1 << '\n';
		exit(0);
	}

	int ways = 0;
	for (int i = 1; i < N; i++) {
		if (!isCyclic(fail, i) && !isCyclic(rfail, N - i)) {
			ways++;
		}
	}

	cout << 2 << '\n';
	cout << ways << '\n';

	return 0;
}

Measured memory_bytes: 6292
#include <iostream>
#include <string>
#include <set>

using namespace std;

template<typename T> inline void chmax(T& t, T f){if(t < f)t = f;}

int main(){
    int Q;
    cin >> Q;
    while(Q--){
        int N, R = 0;
        cin >> N;
        set<int> u{N};
        for(; 10 <= N; ++R){
            string s = to_string(N);
            N = 0;
            for(int i=1; i<(int)s.size(); ++i){
                chmax(N, stoi(s.substr(0, i)) * stoi(s.substr(i)));
            }
            if(!u.insert(N).second)N = -1;
        }
        cout << (N < 0? N: R) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1240
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>

using namespace std;

int main(){
  set<int> s;
  int a,b,c;
  cin >> a >> b >> c;
  s.insert(a);
  s.insert(b);
  s.insert(c);
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
ans = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0} 
for _ in range(N):
    s = input()
    ans[s] += 1
print('AC x ' + str(ans['AC']))
print('WA x ' + str(ans['WA']))
print('TLE x ' + str(ans['TLE']))
print('RE x ' + str(ans['RE']))



Measured memory_bytes: 9192
#include <stdio.h>
int main(void){
	int H,W,i,j;
	scanf("%d %d",&H,&W);
	char a[101][101];
	for(i=0;i<H;i++){scanf("%s",&a[i]);}
	for(i=-1;i<=H;i++){
		if(i==-1||i==H){for(j=0;j<W+2;j++){printf("#");}}
		else{printf("#%s#",a[i]);}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c;
	cin>>a>>b>>c;
	int r1 = abs(a - b);
	int r2 = abs(a - c);
	int r3 = abs(b - c);
	vector<int> vec;
	vec.push_back(r1);
	vec.push_back(r2);
	vec.push_back(r3);
	sort(vec.begin(), vec.end());
	cout<<vec[0] + vec[1]<<endl;
	return 0;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
import sys
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
    
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])


def main():
    n=inp()
    a=inplm(n)
    ans = 0
    x = 0
    for i in range(n):
        if a[i] != 0:
            x += a[i]
        else:
            ans += x//2
            x = 0
    ans += x//2
    print(ans)

if __name__ == "__main__":
    main()

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

using namespace std;
const int MAX=3000+3;
typedef long long ll;
int N;
ll a[MAX], dp[MAX][MAX][2];

//ll solve(int p, int q, int t=0) {
//  if(p>q) return 0;
//
//  if(dp[p][q] != -1) {
//    return dp[p][q];
//  }
//  if(t) {
//    return dp[p][q] = min(solve(p+1, q, 0) - a[p], solve(p, q-1, 0) - a[q]);
//  } else {
//    return dp[p][q] = max(solve(p+1, q, 1) + a[p], solve(p, q-1, 1) + a[q]);
//  }
//}

ll solve(int l, int r, int t){

    if(l > r) return 0;
    ll &ret=dp[l][r][t];
    if(ret!=-1) return ret;

    if(t){
        ret=min(solve(l+1, r, 0)-a[l], solve(l, r-1, 0)-a[r]);
    } else {
        ret=max(solve(l+1, r, 1)+a[l], solve(l, r-1, 1)+a[r]);
    }

    return ret;

}


int main(){
    scanf("%d",&N);
    memset(dp, -1, sizeof(dp));
    for(int i=0;i<N;i++) scanf("%lld",&a[i]);
    printf("%lld\n",solve(0, N-1, 0));
    return 0;
}


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

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

    vector<pair<long long, long long>> a(n);
    vector<vector<long long>> dp(n, vector<long long>(w+1));

    for(pair<long long, long long> &el : a) {
        cin >> el.first >> el.second;
    }
    sort(a.begin(), a.end());

    for(int j = 0; j < a[0].first; j++)
        dp[0][j] = 0;
    for(int j = a[0].first; j <= w; j++)
        dp[0][j] = a[0].second;

    for(int i = 1; i < n; i++)
        for(int j = 0; j <= w; j++) {
            dp[i][j] = dp[i-1][j];
            if(j >= a[i].first)
                dp[i][j] = max(dp[i][j], dp[i-1][j-a[i].first] + a[i].second);
        }

    cout << dp[n-1][w] << endl;
}

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

using namespace std;

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

    int n, m, x;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> x;
        n -= x;
    }
    if (n > 0) cout << "No\n";
    else cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
function Main(input){
  input = input.split(' ');
  var a = Number(input[0]);
  var b = Number(input[1]);
  var c = Number(input[2]);

  if( b - a === c - b ) {
    console.log('YES');
  } else {
    console.log('NO');
  }

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

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

int main (){
    int a;
    int fn=0,sn=0;
    for(int i=0;i<3;i++){
        cin >>a;
        if(a==5)fn++;
        if(a==7)sn++;
    }
    if(fn==2&&sn==1) cout <<"YES"<<endl;
    else cout <<"NO"<<endl;
    return 0;
}


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

int main(){
  int d, g, ret=1000000;
  cin >> d >> g;
  g/=100;
  vector<int>p(d), cp(d);
  for(int i=0; i<d; i++){
    int c;
    cin >> p[i] >> c;
    cp[i] = (i+1)*p[i]+c/100;
  }
  for(int i=0; i<(1<<d); i++){
    int cnt=0, ps=0, mi=0;
    for(int j=0; j<d; j++){
      if(i&(1<<j)){
        cnt+=p[j];
        ps+=cp[j];
      }
      else mi=j;
    }
    if(ps>=g)ret=min(ret, cnt);
    else {
      int inc = (g-ps)%(mi+1)==0 ? (g-ps)/(mi+1): (g-ps)/(mi+1)+1;
      if(inc<p[mi])ret=min(ret, cnt+inc);
    }
  }
  cout << ret;
  return 0;
}

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

typedef pair<int, int> P;

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; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n, mi, ma;
    while( cin >> n >> mi >> ma, n | mi | ma ){
        vector<int> p( n );
        REP( i, n ) cin >> p[i];

        int ans = 0, sa = -1;
        FOR( i, mi, ma + 1 ){
            if( chmax( sa, p[i - 1] - p[i] ) || sa == p[i - 1] - p[i] ){
                ans = i;
            }
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3092
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int A,B,K;

signed main(){
	cin>>A>>B>>K;
	if(A>=K){
		cout<<A-K<<" "<<B<<endl;
	}
	else if(A+B>=K){
		cout<<0<<" "<<B-(K-A)<<endl;
	}
	else{
		cout<<0<<" "<<0<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
n = int(input())
k = n
L = []
for i in range(2,100000):
    while n%i == 0:
        L.append(i)
        n = n//i
if n != 1:
    L.append(n)
s = str(k)+':'
for i in range(len(L)):
  s += ' '+str(L[i])
print(s)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> A(5);//入力
  for(int i=0; i<5; i++)
    cin >> A.at(i);
  
  vector<int> B(5);//1の位を切り上げた値
  int max = 0;//B - A の最大の値
  int sum = 0;//Bの合計値

  //切り上げの計算
  for(int i=0;i<5;i++){
    B.at(i) = (A.at(i) + 9) / 10;
    B.at(i) *= 10;
    //cout << B.at(i) << endl;
    sum += B.at(i);
    if(max < B.at(i) - A.at(i))
      max = B.at(i) - A.at(i);
  }

  cout << std::setprecision(20);
  //cout << "sum : " << sum << endl << "max : " << max << endl;
  cout << sum - max << endl;
}


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

N, W = map(int, input().split())
wv = [tuple(map(int, input().split())) for _ in range(N)]
w1 = wv[0][0]
dp = [[0] * 301 for _ in range(N+1)]
for w, v in wv:
    w -= w1
    for i in range(1, N+1)[::-1]:
        for j in range(w, 301):
            dp[i][j] = max(dp[i][j], dp[i-1][j-w] + v)
ans = 0
for i in range(N+1):
    w = W - w1*i
    if w < 0:
        break
    ans = max(ans, dp[i][min(300, W-w1*i)])
print(ans)

Measured memory_bytes: 42860