akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main() {
	int H = 0;
	int W = 0;
	while (1) {
		scanf("%d %d", &H, &W);

		if (H == 0 && W == 0) { break; }
		for (int a = 0; a < H; a++) {
			for (int b = 0; b < W; b++) {
				if ((a % 2 == 1 && b % 2 == 1) || (a % 2 == 0 && b % 2 == 0)) {
					printf("#");
				}
				else {
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1740
#include<stdio.h>
int main()
{
	int i,t,n,s,f;
	while(1){
		scanf("%d",&t);
		if(t==0){
			break;
		}
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d%d\n",&s,&f);
			t-=(f-s);
		}
		if(t<=0){
			printf("OK\n");
		}else{
			printf("%d\n",t);
		}
	}
	return 0;
}

Measured memory_bytes: 2600
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();

        ArrayList<Number<Integer, Integer>> list = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            int work = sc.nextInt();
            list.add(new Number<Integer, Integer>(num, work));

        }

        sc.close();

        list.sort(Comparator.comparing(Number::getNum));

        for (int i = 0; i < n; i++) {
            int work = list.get(i).getWork();
            if (work >= k) {
                System.out.println(list.get(i).getNum());
                return;
            } else {
                k -= work;
            }
        }

    }

    static class Number<num, work> {
        public int num;
        public int work;

        public Number(int num, int work) {
            this.num = num;
            this.work = work;
        }

        public int getNum() {
            return num;
        }

        public int getWork() {
            return work;
        }
    }
}

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

struct StCity
{
  StCity() : m_nPref(0), m_nYear(0) { }

  int m_nPref;
  int m_nYear;
};

void input(int& rnPrefSiz, vector<StCity>& rvoCity)
{
  int nCitySiz;
  cin >> rnPrefSiz >> nCitySiz;
  rvoCity.resize(nCitySiz);

  for (StCity& roCity : rvoCity)
  {
    cin >> roCity.m_nPref >> roCity.m_nYear;
    --roCity.m_nPref;
  }
}

void calcIDNum(int nPrefSiz, const vector<StCity>& cnrvoCity)
{
  vector<vector<int>> vvnCity(nPrefSiz);
                                           // vvnCity[ nPref ] に nYear を保存 
  for (int i = 0; i < cnrvoCity.size(); ++i)
    vvnCity[ cnrvoCity[i].m_nPref ].push_back( cnrvoCity[i].m_nYear );

  for (int i = 0; i < vvnCity.size(); ++i)
  {                                        // vvnCity[ nPref ] 毎に nYear を昇順に sort
    sort( begin(vvnCity[i]), end(vvnCity[i]) );
                                           // vvnCity[ nPref ] 毎に nYear の重複を除く
    vvnCity[i].erase( unique( begin(vvnCity[i]), end(vvnCity[i]) ), end(vvnCity[i]) );
  }

  for (int i = 0; i < cnrvoCity.size(); ++i)
  {
    int nPref = cnrvoCity[i].m_nPref;
    cout << setfill('0') << setw(6) << nPref + 1;
                   // nYear で sort済の vvnCity[ nPref ] に対して、求める nYear を二分索引して
                   // イテレータを算出し、vvnCity[ nPref ]の begin イテレータを削除し、
                   // nYear が小さい方から何番目かを取得する
    int nIdNum = lower_bound( begin( vvnCity[ nPref ] ), end( vvnCity[ nPref ] ), 
                              cnrvoCity[i].m_nYear ) - begin( vvnCity[ nPref ] ); 
    cout << setfill('0') << setw(6) << nIdNum + 1 << endl;
  }
}
  
int main()
{
  int nPrefSiz;
  vector<StCity> voCity;
  
  input(nPrefSiz, voCity);
  calcIDNum(nPrefSiz, voCity);

  return 0;
}

Measured memory_bytes: 9596
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/operators.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	std::queue<std::int64_t> queue;
	for (auto i : boost::irange(1, 10))
	{
		queue.emplace(i);
	}
	std::int64_t last = 0;
	int N;
	std::cin >> N;
	for (auto i : boost::irange(0, N))
	{
		auto x = queue.front();
		queue.pop();
		last = x;
		auto next = 10 * x + (x % 10);
		if (x % 10 != 0)
		{
			queue.emplace(next - 1);
		}
		queue.emplace(next);
		if (x % 10 != 9)
		{
			queue.emplace(next + 1);
		}
	}
	std::cout << last << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

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

#define pb push_back
#define sz size()
#define clr clear()
#define rep(i,a) for(int i=0;i<(int)(a);i++)
using namespace std;
typedef long double D;
typedef vector<D> vec;
typedef vector<vec> mat;
const double EPS = 1e-3;

struct matrix{
  mat m;
  int r,c;

  matrix(void){r=c=0;m.clr;}

  matrix(mat a){
    r = a.sz;c = a[0].sz;
    m.resize(r);
    rep(i,r)m[i].resize(c);
    rep(i,r)rep(j,c)m[i][j] = a[i][j];
  }
};

vec gauss_jordan(const mat& A, const vec& b){
  int n = A.size();
  mat B(n,vec(n+1));
  rep(i,n)rep(j,n)B[i][j] = A[i][j];
  rep(i,n)B[i][n] = b[i];

  rep(i,n){
    int p = i;
    for(int j=i;j<n;j++){
      if(abs(B[j][i]) > abs(B[p][i]))p = j;
    }
    swap(B[i],B[p]);
    
    if(abs(B[i][i]) < EPS)return vec();
    
    for(int j=i+1;j<=n;j++)B[i][j] /= B[i][i];
    rep(j,n){
      if(i != j){
	for(int k=i+1;k<=n;k++)B[j][k] -= B[j][i] * B[i][k];
      }
    }
  }
  vec x(n);
  rep(i,n)x[i] = B[i][n];
  return x;
}

int main(){
  int d;
  while(cin >> d,d){
    vec v(d+3);
    rep(i,d+3)cin >> v[i];

    int ans = 0;
    rep(i,d+3){
      rep(j,d+3){
	if(i==j)continue;
	mat A; vec b;
	rep(k,d+3){
	  if(i==k || j==k)continue;
	  vec tmp(d+1); D pow = 1;
	  rep(l,d+1){
	    tmp[l] = pow;
	    pow *= k;
	  }
	  A.push_back(tmp);
	  b.push_back(v[k]);
	}
	vec x = gauss_jordan(A,b);

	D val1 = 0, val2 = 0;
	D pow1 = 1, pow2 = 1;
	rep(k,x.size()){
	  val1 += pow1 * x[k]; pow1 *= i;
	  val2 += pow2 * x[k]; pow2 *= j;
	}

	if(abs(val1-v[i])<EPS && abs(val2-v[j])+EPS>1.0){
	  ans = j;
	}else if(abs(val1-v[i])+EPS>1.0 && abs(val2-v[j])<EPS){
	  ans = i;
	}
      }
    }

    cout << ans << endl;
  }
}

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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  
  for (int i = 0; i<6; i++) {
    if (s[i] == '1') {
      ans++;
    }
  }
  
  cout << ans << endl;
  
  
  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, m, a, b int

	fmt.Scan(&n, &m)
	start := map[int]struct{}{}
	goal := map[int]struct{}{}

	for range make([]struct{}, m) {
		fmt.Scan(&a, &b)

		if a == 1 {
			start[b] = struct{}{}
		}
		if b == n {
			goal[a] = struct{}{}
		}
	}

	for s := range start {
		if _, in := goal[s]; in {
			fmt.Println("POSSIBLE")
			return
		}
	}
	fmt.Println("IMPOSSIBLE")
}


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

const int maxn = 1e5 + 10;

int n, c[maxn];
set<int> s;

int main(void) {
    ios_base::sync_with_stdio(0);   cin.tie(0);
    cin >> n;
    s.insert(0);    s.insert(n + 1);
    for(int i = 1; i <= n; ++i) {
        int p;  cin >> p;
        c[p] = i;
    }
    ll ans = 0;
    for(int i = n; i >= 1; --i) {
        auto it = s.lower_bound(c[i]);
        if(prev(it) != s.begin()) {
            ans += 1LL * i * (*prev(it) - *prev(prev(it))) * (*it - c[i]);
        }
        if(next(it) != s.end()) {
            ans += 1LL * i * (c[i] - *prev(it)) * (*next(it) - *it);
        }
        s.insert(c[i]);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 6528
// AOJ 2582: Step Aerobics
// 2017.10.6 bal4u@uu

#include <stdio.h>

int main()
{
	int n, ud, ans;
	char b[5];

	while (scanf("%d", &n) && n > 0) {
		ans = 0, ud = 0;
		while (n-- > 0) {
			scanf("%s", b);
			if (ud == 0) {
				if      (*b == 'l' && *(b+1) == 'u') ud = 1;
				else if (*b == 'r' && *(b+1) == 'u') ud = 2;
			} else if (ud == 1) {
				if      (*b == 'r' && *(b+1) == 'u') ud = 3, ans++;
				else if (*(b+1) == 'd') ud = 0;
			} else if (ud == 2) {
				if      (*b == 'l' && *(b+1) == 'u') ud = 3, ans++;
				else if (*(b+1) == 'd') ud = 0;
			} else if (ud == 3) {
				if      (*b == 'l' && *(b+1) == 'd') ud = 4;
				else if (*b == 'r' && *(b+1) == 'd') ud = 5;
			} else if (ud == 4) {
				if      (*b == 'r' && *(b+1) == 'd') ud = 0, ans++;
				else if (*(b+1) == 'u') ud = 3;
			} else if (ud == 5) {
				if      (*b == 'l' && *(b+1) == 'd') ud = 0, ans++;
				else if (*(b+1) == 'u') ud = 3;
			}
		}
		printf("%d\n", ans);
	}
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.rbegin(), a.rend());

    ll ans = 0;
    int t = n-1;
    rep(i,n){
        int lim = 2;
        if (i==0) lim = 1;
        rep(j,lim){
            if (t>0){
                ans += a[i];
                t--;
            }
        } 
    }
    cout << ans << endl;
}

Measured memory_bytes: 4008
#include <iostream>

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int train, bus;
    if (a <= b){
        train = a;
    }else{
        train = b;
    }
    if (c <= d){
        bus = c;
    }else{
        bus = d;
    }
    cout << train + bus << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream> 
#include <stdio.h>
#define MAX 20000005
typedef long long ll; 
using namespace std; 
int main () 
{
    
    int x,y ; 
    cin >> x >> y; 
    int cranes = 2 ; 
    int turtle = 4 ; 
    int cranelegs = x*cranes; 
    int turtlelegs = x*turtle; 
    if (y >= cranelegs && y <= turtlelegs && (y%2==0))
    {
        cout << "Yes" << endl; 

    }
    else 
    {
        cout << "No" << endl;
    }
    return 0; 
}



Measured memory_bytes: 3612
#include <iostream>
using namespace std;
typedef long long ll;

const ll MOD = 998244353;
const ll ma = 1000000;
ll c[1000002];
ll w[1000002];

ll modpow(ll x, ll n){
    ll res = 1;
    ll mul = x;
    while(n){
        if(n % 2) res = res * mul % MOD;
        mul = mul * mul % MOD;
        n /= 2;
    }
    return res;
}

int main()
{
    for(ll i = 1; i <= ma; i++) w[i] = modpow(i, MOD - 2);
    for(ll i = 1; i <= ma; i++){
        for(ll j = i * 2; j <= ma; j += i) w[j] = (w[j] - w[i] + MOD) % MOD;
    }
    ll n;
    cin >> n;
    ll a[200003];
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        c[a[i]]++;
    }
    ll ans = 0;
    for(ll d = 1; d <= ma; d++){
        ll sum = 0;
        for(ll i = d; i <= ma; i += d){
            sum = (sum + i * c[i]) % MOD;
        }
        ans = (ans + w[d] * ((sum * sum) % MOD)) % MOD;
    }
    for(ll i = 0; i < n; i++) ans = (ans + MOD - a[i]) % MOD;
    cout << (ans * modpow(2, MOD - 2)) % MOD << endl;
}

Measured memory_bytes: 17408
#include <stdio.h>
int main(void){
  int n,m=0;
	scanf("%d %d",&n,&m);
  int a[m];
    int sum=0;
  for(int i=0;i<m;i++){
    scanf("%d",&a[i]);
    sum+=a[i];
  }
if(n-sum>=0){
  printf("%d",n-sum);
}else{
  printf("%d",-1);
}
}

Measured memory_bytes: 1760
let [| A; B |] = stdin.ReadLine().Split() |> Array.map int

let mutable result = 0

let rec resolver k =
    if (k * 8 / 100) = A && (k * 10 / 100) = B then
        result <- k
        ()
    elif k = 1009 then ()
    else resolver (k + 1)

resolver 0
match result with
| 0 -> -1
| _ -> result
|> printfn "%d"


Measured memory_bytes: 14040
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define pb push_back
#define ff first
#define ss second
#define BS binary_search
#define mod 1000000007

const long long INF=1e18;

template <class A, class B> ostream& operator<<(ostream& os, const pair<A,B> p) {return os << "(" << p.first << "," << p.second << ")";} 

void dprint(string s) {cout << endl;}
template <class T, class... U> void dprint(string s, T t, U... u) 
{int w = s.find(','); cout << "[" << s.substr(0,w) << ": " << t << "] "; dprint(s.substr(w+1, (int)s.size()-w), u...);} 

#define DEBUG 
#ifdef DEBUG
#define dbg(X...) dprint(#X,X)
#else
#define dbg(X...) "KEEP CALM" 
#endif

const int N=100005; // Don't forget to CHANGE this value ACC. TO Q.

int32_t main()
{
    IOS;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int T=1; 
    //cin>>T;
    while(T--)
    {
        string s,t;cin>>s>>t;
        int n=s.size();
        int m=t.size();
        int ans=10000;
        for(int i=0;i<=n-m;i++){
            int cnt=0;
            for(int j=0;j<m;j++){
                if(s[i+j]!=t[j])
                    cnt++;
            }
            ans=min(cnt,ans);
        }
        cout<<ans<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli n, cnt=1;
	string s;
	cin >> n >> s;
	rep(i,n-1){
		if(s[i] != s[i+1]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

map<vector<int>,map<vector<int>,int>> G;

struct Edge {
  vector<int> v;
  int cost;
  Edge(vector<int> v, int cost):v(v),cost(cost){}
};
bool operator<(const Edge& a, const Edge& b){
  return a.cost > b.cost;
}

int dijkstra(const vector<int>& start, const vector<int>& goal){
  map<vector<int>,int> trace;
  priority_queue<Edge> que;
  que.push(Edge(start, 0));
  while(!que.empty()){
    Edge e = que.top(); que.pop();
    vector<int> dest = {e.v[0], e.v[1]};
    if(trace.count(dest) > 0) continue;
    trace[dest] = 1;
    if(dest == goal) return e.cost;

    //cout << e[0] << " " << e[1] << "\t" << e[2] << endl;
    FOR(it,G[dest]){
      vector<int> pos = it->first;
      int cst = it->second;
      if(trace.count(pos) == 0){
        que.push(Edge({pos[0], pos[1]}, e.cost + cst));
      }
    }
  }
  return -1;
}

int main(){
  int N, M;
  cin >> N >> M;

  vector<pair<int,int>> v[N];
  rep(i,M){
    int p, q, c;
    cin >> p >> q >> c;
    G[{c,p}][{c,q}] = 0; //駅を移動する
    G[{c,q}][{c,p}] = 0; //駅を移動する

    G[{c,p}][{-1,p}] = 0; //改札から出る
    G[{c,q}][{-1,q}] = 0; //改札から出る
    G[{-1,p}][{c,p}] = 1; //改札に入る
    G[{-1,q}][{c,q}] = 1; //改札に入る
  }

  cout << dijkstra({-1,1},{-1,N}) << endl;
  
  return 0;
}


Measured memory_bytes: 236140
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = tuple(map(int, input().split()))
    ans = [0] * n

    ans[0] = sum(a) - 2 * sum(a[1::2])
    for i in range(1, n):
        ans[i] = 2 * a[i-1] - ans[i-1]
    print(*ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14220
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int m, n;
            String give = sc.next();
            if (give.equals("-")) break;

            m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                n = sc.nextInt();
                String b = give.substring(n, give.length());
                String c = give.substring(0, n);
                give = b + c;
            }
            System.out.println(give);
        }

    }
}


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


using namespace std;

int main()
{
    int N,odd=0,even=0,number;
    cin>>N;
    for(int i=0;i<N;i++)
    {
        scanf("%d",&number);
        if(number%2 == 0)
            even++;
        else
            odd++;
    }
    if(odd%2 == 0)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size();
    bool flag = false;
    for (int i = 0; i < n; i++) {
        s = s[n - 1] + s.substr(0, n - 1);
        if (t == s) flag = true;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
  int N,sum=0;
  cin>>N;
  int j,k;
  
  for(int i=0;i<N;i++){
    cin>>j>>k;
    sum+=k-j+1;
       
  }
    
cout<<sum<<endl;

}

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

using namespace std;

int a[200100], c[200100];
long long ans;

struct node
{
    int l, r;
};


queue<node> q;

int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    sort(a+1, a+n+1, greater<int>());

    q.push({a[1], a[1]});
    for(int i = 2; i <= n; ++i)
    {
        auto x = q.front(); q.pop();
        ans += min(x.l, x.r);
        q.push({a[i], x.l});
        q.push({a[i], x.r});
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 6032
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	string S; cin >> S;

	do{
		int Slen = static_cast<int>(S.size());
		if(Slen%2){//even
			S.pop_back();
		}else{
			S.erase(S.end()-1, S.end());
		}  

		cerr << S.substr(0, Slen / 2) << ' ' << S.substr(Slen / 2, Slen / 2) << endl; 
		if(S.substr(0, Slen / 2) == S.substr(Slen / 2 , Slen / 2)){
			cout << S.size() << endl;
			return 0;
		}
	}while(S.size() > 2);
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
bool o[15][10] = {};
int main() {
	o[0][1] = true;
	o[0][2] = true;
	o[0][3] = true;
	o[0][4] = true;
	o[0][5] = true;
	o[0][6] = true;
	o[1][4] = true;
	o[1][5] = true;
	o[2][0] = true;
	o[2][2] = true;
	o[2][3] = true;
	o[2][5] = true;
	o[2][6] = true;
	o[3][0] = true;
	o[3][3] = true;
	o[3][4] = true;
	o[3][5] = true;
	o[3][6] = true;
	o[4][0] = true;
	o[4][1] = true;
	o[4][4] = true;
	o[4][5] = true;
	o[5][0] = true;
	o[5][1] = true;
	o[5][3] = true;
	o[5][4] = true;
	o[5][6] = true;
	o[6][0] = true;
	o[6][1] = true;
	o[6][2] = true;
	o[6][3] = true;
	o[6][4] = true;
	o[6][6] = true;
	o[7][1] = true;
	o[7][4] = true;
	o[7][5] = true;
	o[7][6] = true;
	o[8][0] = true;
	o[8][6] = true;
	o[8][1] = true;
	o[8][2] = true;
	o[8][3] = true;
	o[8][4] = true;
	o[8][5] = true;
	o[9][0] = true;
	o[9][1] = true;
	o[9][3] = true;
	o[9][4] = true;
	o[9][5] = true;
	o[9][6] = true;

	int n;
	while (cin >> n) {
		if (n == -1)return 0;
		int k = 10;
		for (int i = 0; i < n; i++) {
			int p; cin >> p;
			for (int i = 0; i < 7; i++)
				cout << (o[k][i] != o[p][i]);
			cout << endl;
			k = p;
		}
	}
}

Measured memory_bytes: 3028
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s[0] == '7' || s[1] == '7' || s[2] == '7') cout << "Yes" << endl;
    else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>


int main()
{
	int a, b, c, div = 0;
	
	scanf("%d %d %d", &a, &b, &c);
	for(int i = a; i <= b; i++)
	{
		if(c% i == 0)
		{
			div++;
		}
	}
	printf("%d\n", div);
	return 0;
}


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

int main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    long 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];
    }
    long ab[x * y];
    for (int i = 0; i < x; i++) {
        for (int j = 0; j < y; j++) {
            ab[i * y + j] = a[i] + b[j];
        }
    }
    sort(ab, ab + x * y, greater<long>());
    sort(c, c + z, greater<long>());
    int lim_i = min(k, x * y), lim_j = min(k, z);
    long abc[lim_i * lim_j];
    for (int i = 0; i < lim_i; i++) {
        for (int j = 0; j < lim_j; j++) {
            abc[i * lim_j + j] = ab[i] + c[j];
        }
    }
    sort(abc, abc + lim_i * lim_j, greater<long>());
    for (int i = 0; i < k; i++) {
        cout << abc[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 31488
#include<cstdio>
#include<string>
using namespace std;
main()
{
    int n;
    scanf("%d",&n);
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(to_string(i).size()%2==1)ans++;
    }
    printf( "%d\n",ans);
    return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

int main() {
  ll X, K, D; cin >> X >> K >> D;
  ll ans = 0;
  ll cnt = abs(X) / D; ll mod = abs(X) % D;
  if(K - cnt <= 0) {
    if(X >= 0) ans = X - (K * D);
    else ans = abs(X + (K * D));
  } else {
    if((K - cnt) % 2 == 0) ans = mod;
    else ans = abs(mod - D);
  }
  cout << ans << endl;
}

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

string s;
vector<int> n;
vector<int> c;

int main(){
  cin >> s;
  for(int i=0; i<s.size(); i++){
    c.push_back(0);
  }
  char cur='R';
  int count=1;
  for(int i=1; i<s.size(); i++){
    if(cur==s[i]) count++;
    else{
      n.push_back(count);
      cur=s[i];
      count=1;
    }
  }
  n.push_back(count);

  int idx=-1;
  for(int i=0; i<n.size(); i++){
    if(i%2==0){
      idx += n[i];
      if(n[i]%2==0){
        c[idx]+=n[i]/2;
        c[idx+1]+=n[i]/2;
      }else{
        c[idx]+=n[i]/2+1;
        c[idx+1]+=n[i]/2;
      }
    }else{
      if(n[i]%2==0){
        c[idx]+=n[i]/2;
        c[idx+1]+=n[i]/2;
      }else{
        c[idx]+=n[i]/2;
        c[idx+1]+=n[i]/2+1;
      }
      idx+=n[i];
    }
  }
  for(int i=0; i<s.size(); i++){
    cout << c[i] << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 1592
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int sn[101];

int main() {
  int n,m,a,b;
  cin >> n >> m;
  int h[n+1];
  bool good[n+1];
  rep(i,n+1) good[i]=true;
  for(int i=1;i<=n;i++) cin >> h[i];
  rep(i,m){
    cin >> a >> b;
    if(h[a] > h[b]) good[b]=false;
    else if(h[b] > h[a]) good[a]=false;
    else {good[a]=false; good[b]=false;}
  }
  int cnt=0;
  for(int i=1;i<=n;i++){
    if (good[i])  cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 4104
#include "iostream"
#include "vector"
#include "algorithm"
using namespace std;

int main(int argc, char const *argv[])
{
	int N,L;
	cin >> N >> L;
	vector<string> S;
	cin.ignore();
	string s;
	for (int i = 0; i < N; ++i)
	{
		cin >> s;
		S.push_back(s); 
	}

	sort(S.begin(), S.end());
	s = "";
	for (int i = 0; i < N; ++i)
	{
		s += S[i];
	}

	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,m = readInts()
AB = []
for i in range(n):
    a,b = readInts()
    AB.append((a,b))
AB = sorted(AB, key = lambda x:x[0])
#print(AB)
num = 0
cost = 0
for a,b in AB:
    if m >= num + b:
        num += b
        cost += a*b
    else:
        cost += a*(m - num)
        num = m
print(cost)


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


#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;


using namespace std;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<vector<int> > vvi;
typedef vector<vector<ii> > vvii;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define ff first
#define ss second
#define trav(a, x) for(auto& a : x) 
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define PI 3.1415926535897932384626433832795
const ll INF = 1e18;
const int mod = 1e9 + 7;
const int N = 1e5;
ll gcd(ll a,ll b){if (a==0) return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return a*(b/gcd(a,b));}
ll Abs(ll a){if(a>0)return a;return -a;}
ll Ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
double Abs(double a){if(a>0)return a;return -a;}

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> 

inline int pow_(ll x, ll y,ll p){
  int r = 1; while(y){if(y & 1) r = r * x % p; y >>= 1; x = x * x % p;} return r;
}
inline int inv_(int x){return pow_(x, mod - 2, mod);}
inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int mul(int a, int b){return a * 1LL * b % mod;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}

int main()
{
    #ifdef LOCAL_TEST
    freopen("in.txt","r",stdin);
    //freopen("out.txt", "w", stdout);
    #else
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    #endif
    int n,m;
    cin>>n>>m;
    vector<pair<ll,ll> > v;
    for(int i=1;i<=n;i++)
    {
        int a,b;
        cin>>a>>b;
        v.pb(mp(a,b));
    }

    sort(all(v));
    ll ans = 0;
    ll count = 0;
    for(int i=0;i<v.size();i++)
    {
        ll val = v[i].first;
        ll num = v[i].second;
        if(m - count > num)
        {
            count += num;
            ans += val*num;
        }
        else
        {
            ans += (m-count)*val;
            count = m;
            break;
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define PI                acos(-1)
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;

const int INF = int(1e9 + 7);
typedef long long       ll;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;

bool same(int n)
{
	set<int> s;
	while (n > 0)
	{
		s.insert( n%10 );
		n /= 10;
	}
	if (s.size() > 1) return false;
	return true;
}

int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0);
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    int n;
    cin >> n;
    while (!same(n)) n++;
    cout << n << '\n';
    return 0;
}
// PLUS ULTRA!

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            for (int i = 0; i <= 6; i++) {
                int fir = sc.nextInt();
                int sec = sc.nextInt();
            System.out.println(fir-sec);
            }
        }
    }
}

Measured memory_bytes: 17344
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

const int MAX = 100;


enum col
  {
   WHITE = 0,
   GRAY =  1,
   BLACK = 2,
  };

using namespace std;
const int INF = 0x7fffffff;

int M[MAX][MAX];
col color[MAX];
int d[MAX];
int p[MAX];
int n;

void daikusutora(int s){
  int ii,vv;

  //初期化
  for(ii=0;ii<n;ii++){
    color[ii] = WHITE;
    d[ii] = INF;
    p[ii] = -1;
  }
  
  d[s] = 0;
  p[s] = -1;
  
  int mincost,u;
  while(1){
    mincost = INF;
    u = -1;

    //次に選ぶ頂点の決定
    for(ii=0;ii<n;ii++){
      if(color[ii] != BLACK && d[ii] < mincost){

        mincost = d[ii];
        u = ii;
        //cout << "u:" << u << endl;
      }
    }

    //ループの終了条件
    if(mincost == INF){
      break;
    }

    color[u] = BLACK;
    //cout << "color:" << u << endl;

    //次のパスの選択候補
    for(vv=0;vv<n;vv++){
      //未探索の頂点かつ u -> vv へのパスがある場合
      if(color[vv] != BLACK && M[u][vv] != INF){
        //次に探索する候補
        if(d[u] + M[u][vv] < d[vv]){
          //cout << "vv:" << vv << endl;
          d[vv] = d[u] + M[u][vv];
          //color[vv] = GRAY;
        }
      }
    }
    
  }
  
}

int main(){

  long ii,jj,kk;
  int u,k,v,c;
  vector<int> a;

  cin >> n;

  //初期化
  for(ii=0;ii<n;ii++){
    for(jj=0;jj<n;jj++){
      M[ii][jj] = INF;
    }
  }
  
  for(ii=0;ii<n;ii++){

    cin >> u >> k;
    //cout << "u:" << u << "k:" << k << endl;
    for(jj=0;jj<k;jj++){
      cin >> v >> c;
      M[ii][v] = c;
    }
    
  }

  //for(ii=0;ii<n;ii++){
  //  for(jj=0;jj<n;jj++){
  //    cout << M[ii][jj] << " " ;
  //  }
  //  cout << endl;
  //}

  daikusutora(0);

  for(ii=0;ii<n;ii++){
    cout << ii << " " << d[ii] << endl;
  }
  return 0;
}



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

#define int long long
#define REP(i,n) for(int i=0;i<n;i++)

string s;

int solve(int state){
    int res=0;
    int temp=0;
    int n=s.size();
    REP(i,n){
        char c=s[i];
        if(i==0){
            temp=c-'0';
        }else{
            if((state>>(i-1))&1){
                res+=temp;
                temp=c-'0';
            }else{
                temp*=10;
                temp+=c-'0';
            }
        }
    }
    res+=temp;
    return res;
}

signed main(){
    cin>>s;
    int len=1<<(s.size()-1);
    int ans=0;
    REP(state,len){
        ans+=solve(state);
    }
    cout<<ans<<endl;
}


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

int main()
{
	int n, A[N], minj, temp, time;
	cin >> n;

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

	time = 0;
	for (int i = 0; i < n; i++)
	{
		minj = i;
		for (int j = i; j < n; j++)
		{
			if (A[j] < A[minj])
				minj = j;
		}

		if (i != minj)
		{
			temp = A[i];
			A[i] = A[minj];
			A[minj] = temp;

			time++;
		}
	}

	for (int i = 0; i < n - 1; i++)
		cout << A[i] << " ";
	cout << A[n - 1] << endl;
	cout << time <<endl;

	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define ull unsigned long long
using namespace std;

int main(){
  ull N;
  const ull mod=pow(10,9)+7;
  vector<ull> A;
  ull sum=0;
  cin >> N;

  for(int i=0;i<N;i++){
    ull input;
    cin >> input;
    A.push_back(input);
    }
  
  for(int bit=0;bit<=60;bit++){
    ull ones=0;
    vector<ull> v=A;
    for(int i=0;i<N;i++){
      ull a=v.back();
      v.pop_back();
      if(a&(1LL<<bit)) ones++;
    }
    sum = (sum + (1LL<<bit) % mod * ones % mod * (N-ones) % mod ) % mod;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 6636
h, w = map(int, input().split())

if h * w % 3 == 0:
    ans = 0
    
else:
    ans1 = 10 ** 5
    for i in range(1, h + 1):
        a = i * w
        b = (h - i) * (w // 2)
        c = (h - i ) * (w - w // 2)
        tmp = max(a, b, c) - min(a, b, c)
        ans1 = min(ans1, tmp)
        
    ans2 = 10 ** 5
    for i in range(1, w + 1):
        a = i * h
        b = (w- i) * (h // 2)
        c = (w - i) * (h - h // 2)
        tmp = max(a, b, c) - min(a, b, c)
        ans2 = min(ans2, tmp)
        
    ans3 = 10 ** 5
    for i in range(1, h + 1):
        a = i * w
        b = (h - i) // 2 * w
        c = (h - i - (h - i) // 2) * w
        tmp = max(a, b, c) - min(a, b, c)
        ans3 = min(ans3, tmp)
        
    ans4 = 10 ** 5
    for i in range(1, w + 1):
        a = i * h
        b = (w - i) // 2 * h
        c = (w - i - (w - i) // 2) * h
        tmp = max(a, b, c) - min(a, b, c)
        ans4 = min(ans4, tmp)
        
    ans = min(ans1, ans2, ans3, ans4)
    
print(ans)

Measured memory_bytes: 3188
import math

N = int(input())
X = list(map(int, input().split()))

ave = sum(X) / len(X)

m = math.floor(ave)
M = math.ceil(ave)

def f(x):
  ans = 0
  for i in X:
    ans += (x - i)**2
  return ans  

print(min(f(m), f(M)))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<long long> sum(N, Q);
    for(int i = 0; i < Q; i++){
        int a;
        cin >> a;
        a--;
        sum[a]--;
    }
    for(int i = 0; i < N; i++){
        if(K - sum[i] <= 0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}

Measured memory_bytes: 4024
N = int(input())
if N % 2 == 1 :
    print(0)
else:
    if N < 9 :
        print(0)
    else :
        ans = 0
        p = 1
        N = N // 2
        # 偶数の中から5で割れる数を数える
        while True :
            if (N // (5 ** p)) ==  0 :
                break
            else:
                q = N // (5 ** p)
                ans += q
                p += 1
        print(ans)

Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys
args = sys.argv
if len(args) == 2:
  from IPython import embed
  em = True
else:
  em = False
input = sys.stdin.readline
A, B = map(int, input().split())
if A <= 2*B:
  print(0)
else:
  print(A - 2*B)
if em: sys.stdin = open('/dev/tty')


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

template <typename T, typename F>
class SegTree{
  int n; T uni; F f;
  vector<T> dat;
public:
  SegTree(int _n, F f, T uni) : f(f), uni(uni) {
    n = 1;
    while(n < _n) n *= 2;
    dat = vector<T>(2*n,uni);
  }
  void set(int k, const T x) {
    dat[k+n] = x;
  }
  void build() {
    for(int i = n-1; i >= 0; i--) {
      dat[i] = f(dat[2*i],dat[2*i+1]);
    }
  }
  void update(int k, T x) {
    k += n;
    dat[k] += x;
    while(k >>= 1){
      dat[k] = f(dat[2*k],dat[2*k+1]);
    }
  }
  T query(int a, int b) {
    T l = uni, r = uni;
    for(a += n, b += n; a < b; a >>= 1, b >>= 1) {
      if(a & 1) l = f(l,dat[a++]);
      if(b & 1) r = f(dat[--b],r);
    }
    return f(l,r);
  }
};

int main() {
  int n, q;
  cin >> n >> q;
  auto f = [](int a, int b){return a + b;};
  SegTree<int,decltype(f)> st(n,f,0);
  rep(i,q) {
    int c, x, y;
    cin >> c >> x >> y;
    x--;
    if(c == 0) {
      st.update(x,y);
    } else {
      cout << st.query(x,y) << endl;
    }
  }
}


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

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int iSize = scanner.nextInt();
    int k = scanner.nextInt();
    int[] input = new int[iSize];
    for (int i = 0; i < iSize; i++) {
      input[i] = scanner.nextInt();
    }
    scanner.close();
    int[] arr = new int[iSize];
    Arrays.fill(arr, Integer.MAX_VALUE);
    arr[0] = 0;
    for (int i = 0; i < iSize; i++) {
      for (int j = i + 1; j <= i + k && j < iSize; j++) {
        arr[j] = Math.min(arr[j], arr[i] + Math.abs(input[i] - input[j]));
      }
    }
    System.out.println(arr[iSize - 1]);
  }
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

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

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// テーブルを作る前処理
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    vector<ll> a(N);

    REP(i,N) cin >> a[i];

    ll ans = 0;
    REP(i,N) {
        ans += a[i]/2;
        a[i] %= 2;

        if(i!=N-1) if(a[i] > 0 && a[i+1] > 0){
            ans  += 1;
            a[i] -= 1;
            a[i+1] -= 1;
        }
    }

    pl(ans)

    return 0;
}


Measured memory_bytes: 1024
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let nk: Vec<u32> = read_vec();
    let _: Vec<u32> = read_vec();
    println!("{}", 1 + (nk[0] - 2) / (nk[1] - 1));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	ll A;
	string s;
	cin >> A >> s;
	
	int B = (s[0] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0');
	ll ans = A * B / 100;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <stdio.h>

using namespace std;

int N,M,X,tol_book,cost,ans=1e9;
int score[15][15],money[15];//col列
int book_cho[15],sum_col[15];//choic_book = tar_row

void Dfs(int num_book)
{
    int i,j;
    if(num_book==tol_book+1)//选够书了
    {
        for(i=1;i<=M;++i)
            sum_col[i]=0;

        for(i=1;i<=tol_book;++i)//选多少书
            for(j=1;j<=M;++j)//计算所有列
                sum_col[j]+=score[ book_cho[i] ][j];

        for(i=1;i<=M;++i)
            if(sum_col[i]<X)
                return;//分不够

        cost=0;
        for(i=1;i<=num_book;++i)
            cost+=money[ book_cho[i] ];

        if(ans>cost)
            ans=cost;
    }
    else
    {
        for(i=book_cho[num_book-1]+1;i<=N;++i)//每次从下一本书开始
        {
            book_cho[num_book]=i;
            Dfs(num_book+1);
        }
    }
    return;
}

int main()
{
    int i,j;

    scanf("%d%d%d",&N,&M,&X);
    for(i=1;i<=N;++i)
    {
        scanf("%d",&money[i]);
        for(j=1;j<=M;++j)
            scanf("%d",&score[i][j]);
    }

    for(tol_book=1;tol_book<=N;++tol_book)//选择书的数量
    {
        book_cho[0]=0;//没有已选书，书号为0
        Dfs(1);
    }

    if(ans==1e9)
        printf("-1\n");
    else
        printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int a,b,c,d;
  cin >> a >>b>>c>>d;
  if (a+b>c+d){
    cout<< "Left"<<endl;
  }
    else if(a+b<c+d){
        cout<< "Right"<<endl;
  }
  else{
    cout<< "Balanced"<<endl;
}
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <random>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
#define fst	first
#define scn second
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll gcd(ll a, ll b) {
	return a%b == 0 ? b : gcd(b, a%b);
}
#define debug(x)	cout<<"case #" << x << ": " << endl
#define DEBUG 0
const int inf = 1e9;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };

int main() {
	int n;	cin >> n;
	vint a(n);
	rep(i, n)	cin >> a[i];
	int sum = 0;
	rep(i, n)	sum += a[i];
	bitset<4000001> dp(1);
	rep(i, n) {
		dp |= (dp << a[i]);
	}
	SREP(i, (sum + 1) / 2, sum) {
		if (dp[i]) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
 
ll dp[401][401];
vector<ll> a;
ll slime(ll leftBound,ll rightBound){
	ll &ans = dp[leftBound][rightBound];
	if(ans!=-1)
		return dp[leftBound][rightBound];
	if(rightBound==leftBound)
		return 0;
	ans = 1e15;
	ll right = 0,left = 0;
	for(int k=rightBound;k>=leftBound;--k)
		right+=a[k];
	for(int k=leftBound;k<rightBound;++k){
		left+=a[k];
		right-=a[k];
		ans = min(slime(leftBound,k)+slime(k+1,rightBound)+left+right,ans);
	}
	return ans;
}
 
int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);cout.tie(NULL);
	ll n;
	cin>>n;
	memset(dp,-1,sizeof(dp));
	a.resize(n);
	for (ll i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	cout<<slime(0,n-1) << '\n';
	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
using namespace std;
int main()
{
  int h,w,n,ma;
  cin>>h>>w>>n;
  ma=max(h,w);
  if(n%ma==0)
    cout<<n/ma<<endl;
  else
    cout<<(n/ma)+1<<endl;
  
  return 0;
}

Measured memory_bytes: 256
from decimal import Decimal
#decimal.Decimalってしなくて済むよ
a,b,c = map(int,input().split())
a = a ** Decimal(0.5)
b = b ** Decimal(0.5)
c = c ** Decimal(0.5)
a_b = a + b
if c > a_b:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 60012
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();

		int [] mountain = new int [a];

		for (int i = 0; i < a; i++) {
			mountain[i] = sc.nextInt();
		}

		int count = 0;

		for (int i = 1; i < mountain.length; i++) {
			for (int j = 0; j < i; j++) {
				if (mountain[i] < mountain[j]) {
					count++;
					break;
				}
			}

		}

		System.out.println(a - count);
	}
}

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

using ll = long long;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)

int main(){
    ll N;
    int X, M;
    cin >> N >> X >> M;
    V<bool> v(M, true);
    queue<int> q;
    ll XX = X;
    while(v.at(XX)){
        q.push(XX);
        v.at(XX) = false;
        XX *= XX;
        XX %= M;
    }
    ll sum = 0;
    while(q.front() != XX && N > 0){
        sum += q.front();
        N--;
        q.pop();
    }
    ll q_sum = XX;
    q.pop();
    q.push(XX);
    while(q.front() != XX){
        int a = q.front();
        q_sum += a;
        q.pop();
        q.push(a);
    }
    sum += q_sum * (N / q.size());
    int number = N - (N / q.size()) * q.size();
    rep(i, number){
        sum += q.front();
        q.pop();
    }
    
    cout << sum << endl;
}

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

bool isPrime(int x){
    for(int i=2;i<=sqrt(x);i++){
        if(x%i==0) return false;
    }
    return true;

}

void solve(){
    int x;
    cin>>x;
    for(int i = x;;i++){
        if(isPrime(i)){
            cout << i <<endl;
            break;
        }
    }

}


int main(){
   solve();

}

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

distance = [0] * N
for i in range(N - 1):
    distance[i] = A[i + 1] - A[i]
distance[N - 1] = K - sum(distance)
# print(distance)

sorted_distance = sorted(distance, reverse=True)
print(sum(distance) - sorted_distance[0])

Measured memory_bytes: 26444