akhauriyash/Code-Regression huggingface dataset:
n = int(input())
as_ = list(map(int, input().strip().split()))

total_length = sum(as_)
current = 0
for a in as_:
    if current + a == total_length // 2:
        print(0)
        exit(0)
    if current + a > total_length / 2:
        candidate1 = current
        candidate2 = current + a
        break

    current += a

left1 = candidate1
right1 = total_length - left1
left2 = candidate2
right2 = total_length - left2


ans = min(
    right1 - left1, # 左が短いので左を伸ばすまたは右を縮める
    left2 - right2 # 左が長いので左を縮めるまたは右を伸ばす
)
print(ans)


Measured memory_bytes: 26220
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef long double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define cerr if(true)cerr
void print(){cout<<endl;}
template<typename T,typename... Args>
void print(T a, Args... args) {cout<<a<<" ";print(args...);}
lli llipowerp(lli x, lli y, lli p=LLONG_MAX)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
template <typename T>
inline void printvec(vector<T> inp){
    for(auto it:inp) cout<<it<<" ";
    cout << endl;
}
//---------------------------------------------------------------------------------
lli n;
vector<lli> a,pref;

lli dp[405][405],s[405][405];
lli get2(int l, int r)
{
    return pref[r] - pref[l - 1];
}
lli get(int l,int r){
    if(l>r) return 0;
    if(dp[l][r]!=-1) return dp[l][r];

    if(l==r){
        dp[l][r]=0;
    }
    else if(r==l+1){
        dp[l][r]=a[l]+a[r];

    }
    else{
        dp[l][r]=LLONG_MAX;
        for(int i=l;i<r;i++){
            dp[l][r]=min(dp[l][r],get(l,i)+get(i+1,r)+get2(l,r));
        }
    }
    return dp[l][r];


}

int main(){
    int n;
    cin>>n;
    a.resize(n+1);
    pref.resize(n+1,0);
    fori(n){
        cin>>a[i+1];

    }
    
    memset(dp,-1,sizeof(dp));
    memset(s, -1, sizeof(s));
    
    pref[1]=a[1];
    for(int i=2;i<=n;i++){
        pref[i]=pref[i-1]+a[i];
    }
    // fori(n+1){
    //     forj(n+1) cout<<get(i,j)<<" ";
    //     cout<<endl;
    // }
   // cout<<get2(4,6);
    cout<<get(1,n)<<endl;

}

Measured memory_bytes: 2816
#include <stdio.h>

int main(){
  int n,m;
  scanf("%d%d",&n,&m);
  int k,a[m],i,j,buf,ans=0;
  for(i=0;i<m;i++) a[i]=0;
  
  for(i=0;i<n;i++){
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&buf);
      a[buf-1]++;
    }
  }
  for(i=0;i<m;i++){
    if(a[i]==n) ans++;
  }
  printf("%d",ans);
}

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

using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) ((a)*(b)/GCD(a,b))
#define PI (3.141592653589793238462643383279502884197169399375105820974944)
#define MP make_pair
#define n1 first
#define n2 second
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDB pair<db,db>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define VS vector<string>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const int INF = 1000000007;
const ll LINF = 1000000000000000555;
const int N = 550555;
const int L = 21;
const int M = 2155;

int cnt[N];
void solve() {
    int n;
    cin >> n;

    for (int i = 1; i < n; i++){
        int x;
        cin >> x;
        cnt[x]++;
    }

    for (int i = 1; i <= n; i++){
        cout << cnt[i] << endl;
    }

}

int main() {
    ios_base::sync_with_stdio(false);
#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 4396
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<vector<int>> vvi;
#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define frpn(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define all(a) a.begin(), a.end()
#define mkp make_pair
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define fornd(i, n) for(int i=(int)(n-1); i>=0; --i)

//const int NAX = (int)3e5+5;
const int MOD = (int)1e9+7;

template <class T>
inline void rem(T &n){
   n = (-MOD <= n && n <= MOD) ? n : n%MOD ;
  if(n < 0) n += MOD; 
}
//modular inverse
//inv(a,m) - inverse of a mod m
template <class T>
inline T inv(T a, T m){
 return 1<a ? m - inv(m%a, a)*m/a : 1;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    vi a(n), b(n);
    forn(i, n-1) cin >> b[i];
    a[0] = b[0], a[n-1] = b[n-2];
    forab(i, 1, n-2) {
      a[i] = min(b[i], b[i-1]);
    }
    ll sm = 0ll;
    forn(i, n) sm += a[i]; 
    cout << sm << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second
#define endl "\n"

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<int, int> P;


int main(){
    ll a, b, n; cin >> a >> b >> n;
    ll c;
    if(b - 1 > n){
        c = n;
    }
    else{
        c = b-1;
    }

    cout << a * c / b << endl;


    return 0;
}


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

public class Main {
   
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		int x = in.readInt();
		boolean bool[] = new boolean[x+1]; 
		bool[1] = true;
		for(int i= 2; i<x; i++) {
			int v = i*i; 
			while(v <= x) {
				bool[v] = true; 
				v *= i;
			}
		}
		for(int i = x; i>= 1; i--) {
			if(bool[i]) {
				System.out.println(i);
				return; 
			}
		}
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 23380
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#define ll long long
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pi(n) prllf("%d",n)
#define pl(n) prllf("%d",n)
using namespace std;

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  if(a*n<b){
    cout<<a*n;
  }else{
    cout<<b;
  }

}


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

int main() {
  
	int a;
	string s;
	
	cin >>a >>s;
	
	if(a<3200){
		
		cout <<"red" <<endl;
		
	}
	else{
		
		cout <<s <<endl;
		
	}
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<malloc.h>
using namespace std;
//#define int long long
typedef pair<int, int> pii;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

string s;
stack<int> sta;
int sum[20200];
int to[20200];

signed main(){
    cin >> s;
    s = '_' + s;
    int N = (int)s.size();
    memset(to, -1, sizeof(to));
    for(int i = 1; i <= N; i++){
        if(s[i] == '\\'){
            sta.push(i);
        }
        else if(s[i] == '/'){
            if(sta.empty())continue;
            int l = sta.top();
            sum[i] = i - l;
            to[l] = i;
            sta.pop();
        }
    }
    for(int i = 1; i <= N; i++){
        sum[i] += sum[i - 1];
    }
    cout << sum[N] << endl;

    vector<int> v;
    for(int i = 1; i <= N; i++){
        if(~to[i]){
            v.push_back(sum[to[i]] - sum[i - 1]);
            i = to[i] - 1;
        }
    }
    int n = (int)v.size();
    printf("%d", n);
    for(int i = 0; i < n; i++){
        printf(" %d", v[i]);
    }
    printf("\n");

    return 0;
}

/*

*/


Measured memory_bytes: 3492
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
//        repeat(readInteger()) { solve() }
        solve()
        out.flush()
    } }
}

fun solve() {
    val k = readInteger()
    out.println("ACL".repeat(k))
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
int A[51];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N) cin>>A[i];
	sort(A,A+N);
	reverse(A,A+N);
	cout<<accumulate(A,A+K,0)<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

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

	string s, t;
	cin >> s >> t;

	int ok = 1;
	for (int i = 0; i < s.size(); ++i)
	{
		ok &= s[i] == t[i];
	}
	cout << (ok ? "Yes" : "No");
}

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

bool isInclude(const vector<int>& v, int x) {
    for (int i : v) if (i == x) return true;
    return false;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> edge(n, vector<int>(0));
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    vector<int> base(n);
    for (int j = 0; j < n; ++j) {
        base[j] = j;
    }
    int ans = 0;
    do {
        if (base[0] != 0) break;
        vector<bool> seen(n, false);
        seen[0] = true;
        for (int i = 0; i < n - 1; ++i) {
            if (isInclude(edge[base[i]], base[i + 1])) {
                seen[i + 1] = true;
            } else {
                break;
            }
        }
        bool test = true;
        for (bool b : seen) {
            if (!b) {
                test = false;
                break;
            }
        }
        if (test) ans++;
    } while (next_permutation(base.begin(), base.end()));
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        var S = Console.ReadLine();
        var T = Console.ReadLine();

        var ans = T.Length;

        for (int start = 0; start <= S.Length - T.Length; start++)
        {
            int diff = 0;
            for (int i = 0; i < T.Length; i++)
            {
                if (S[start + i] != T[i]) diff++;
            }
            ans = Math.Min(ans, diff);
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 17580
def solve():
    INF = float('inf')

    def Dijkstra(adjList, vSt):
        numV = len(adjList)
        useds = [False] * numV
        fuels = [-1] * numV
        fuels[vSt] = L
        nums = [INF] * numV
        num = 0
        vs = set([vSt])
        while vs:
            vNexts = set()
            fuelNexts = [-1] * numV
            while vs:
                fNow, vNow = -1, -1
                for v in vs:
                    if fuels[v] > fNow:
                        fNow, vNow = fuels[v], v
                nums[vNow] = num
                useds[vNow] = True
                vs.remove(vNow)

                fuel = fuels[vNow]
                for v2, wt in adjList[vNow]:
                    if useds[v2]: continue
                    if fuel >= wt:
                        if fuel-wt > fuels[v2]:
                            fuels[v2] = fuel-wt
                        vs.add(v2)
                    elif L >= wt:
                        if L-wt > fuelNexts[v2]:
                            fuelNexts[v2] = L-wt
                        vNexts.add(v2)

            vs = set([v for v in vNexts if not useds[v]])
            fuels = fuelNexts
            num += 1
        return nums


    N, M, L = map(int, input().split())
    adjL = [[] for _ in range(N)]
    for _ in range(M):
        A, B, C = map(int, input().split())
        A, B = A-1, B-1
        adjL[A].append((B, C))
        adjL[B].append((A, C))

    numss = []
    for v in range(N):
        nums = Dijkstra(adjL, v)
        numss.append(nums)

    Q = int(input())
    anss = []
    for _ in range(Q):
        s, t = map(int, input().split())
        s, t = s-1, t-1
        if numss[s][t] == INF:
            anss.append(-1)
        else:
            anss.append(numss[s][t])

    print('\n'.join(map(str, anss)))


solve()


Measured memory_bytes: 76632
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <deque>
#include <queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <iomanip>
#include <utility>
#include <functional>
using namespace std;
//orz jzm
#define ll long long
#define ull unsigned ll
const double EPS=1e-8;
const ll PR=19260817;
const ll inv2=500000004;
const ll inv3=333333336;
int h, w, n;
int ans[105][105];
int main() {
	scanf("%d%d%d", &h, &w, &n);
	int x=1, y=1;
	for (int i=1; i<=n; i++) {
		int c;scanf("%d", &c);
		while (c--) {
			ans[x][y]=i;
			if (y&1) {
				if (x==h) y++;
				else x++;
			} else {
				if (x==1) y++;
				else x--;
			}
		}
	}
	for (int i=1; i<=h; i++) {
		for (int j=1; j<=w; j++)
			printf("%d ", ans[i][j]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<vector<int>> vec(N, vector<int>(3));
  for(int i=0; i<N; i++){
    cin >> vec[i][0] >> vec[i][1] >> vec[i][2];
  }
  int currentX = 0, currentY = 0, currentTime = 0;
  for(int i=0; i<N; i++){
    int distanceX, distanceY;
    if(currentX > vec[i][1]){
      distanceX = currentX - vec[i][1];
    }else{
      distanceX = vec[i][1] - currentX;
    }
    if(currentY > vec[i][2]){
      distanceY = currentY - vec[i][2];
    }else{
      distanceY = vec[i][2] - currentY;
    }
    if(vec[i][0] - currentTime < distanceX + distanceY){
      cout << "No";
      return 0;
    }else{
      if(((vec[i][0] - currentTime) - (distanceX + distanceY)) % 2 == 1){
        cout << "No";
        return 0;
      }
    }
    currentTime = vec[i][0];
    currentX = vec[i][1];
    currentY = vec[i][2];
  }
  cout << "Yes";
  return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 

int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    
    ll n;
    cin>>n;

    ll ans = 0;
    ll cur = 0;

    ll arr[n];
    for(ll i=0;i<n;i++)
    {
        cin>>arr[i];
    }
     
    for(ll i=n-2;i>=0;i--)
    {
        if(arr[i]>=arr[i+1])
        {
            cur++;
        }
        else{
            ans = max(ans,cur);
            cur = 0;
        }
    }

    ans = max(ans,cur);

    cout<<ans<<endl;

}

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

int main(){
  int K,X;
  cin >> K >> X;

  if(K == 1)
  cout << X << endl;
  else{
    for(int i = K - 1; i > 0; i--)
    cout << X - i << " ";
    cout << X << " ";
    for(int i = 1; i < K; i++)
    cout << X + i << " ";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double ans;
    int N;
    cin>>N;
    getchar();
    while(N--)
    {
        double x;
        string u;
        cin>>x>>u;getchar();
        if(u=="JPY")
            ans+=x;
        else
            ans+=x*(double)380000;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
def c_traveling():
    N = int(input())
    P = [[int(i) for i in input().split()] for j in range(N)]
    t = x = y = 0  # 初期時刻には原点にいる
    for t_next, x_next, y_next in P:
        dt = t_next - t
        dd = abs(x_next - x) + abs(y_next - y)
        if not (dt >= dd and (dt - dd) % 2 == 0):
            # 次の座標へのマンハッタン距離以上に制限時間がないと到達できない
            # 制限時間と距離の偶奇が一致していないと次の座標で止まるれない
            return 'No'
        t, x, y = t_next, x_next, y_next
    return 'Yes'

print(c_traveling())

Measured memory_bytes: 21052
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define FOR(i, a, b) for(i=a; i<b; ++i)
#define EFOR(i, a, b) for(i=a; i>b; --i)

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

int _MAX(int a, int b) {return a>b?a:b;}
int _MIN(int a, int b) {return a<b?a:b;}

#define MAXN

int main() {
	int i,n,m;

	scanf("%d %d", &n, &m);

	if (((m*n)&0x01) == 0)
		printf("No\n");
	else
		printf("Yes\n");

	return 0;
}



Measured memory_bytes: 128
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val m = sc.nextInt()

  val mod = 1_000_000_000 + 7L

  if (Math.abs(n - m) > 1) {
    println(0)
    return
  }

  var nc = 1L
  for (i in 1..n) {
    nc = nc * i.toLong() % mod
  }
  var mc = 1L
  for (i in 1..m) {
    mc = mc * i.toLong() % mod
  }

  var ans = nc * mc % mod

  if (n == m) {
    ans = ans * 2 % mod
  }

  println(ans)

}


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

def how_many_times_divisible(n):
    times = 0
    while n % 2 == 0:
        times += 1
        n /= 2
    return times

ans = min(list(map(how_many_times_divisible, A)))
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
const int N=100005;
queue<int> q;
vector<int> g[N];
int d[N], f[N];
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i=1, x, y; i<=m; i++) {
		scanf("%d%d", &x, &y);
		g[x].push_back(y);
		d[y]++;
	}
	for (int i=1; i<=n; i++) if (d[i]==0) q.push(i);
	
	int ans = 0;
	while (!q.empty()) {
		int x=q.front(); q.pop();
	//	printf("x:  %d\n", x);
		for (int i=0; i<g[x].size(); i++) {
			int y=g[x][i];
			d[y]--;
			f[y]=max(f[y], f[x]+1);
			if (d[y]==0) q.push(y);
		}
		ans=max(f[x], ans);
	}
//	for (int i=1; i<=n; i++) printf("%d ", f[i]);
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

int main(){
  int sh;
  int sm;
  int s;
  int eh;
  int em;
  int e;
  int k;
  cin >> sh >> sm >> eh >> em >> k;
  s = sh*60+sm;
  e = eh*60+em;
  cout << e-k-s << endl;

  return 0;
}


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

#define oo(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
  cout << name << ": " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
  const char *comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
#define frii(i , j , n) for (lli i = j; i < n; ++i)
#define ra(a) for(int &x : (a)) cin >> (x);
typedef long long int lli;
typedef unsigned long long int ulli;
const lli MOD = 1e9 + 7;
#define pb emplace_back
#define mp make_pair
#define vi vector<int>
#define vlli vector<lli>

inline void mx(lli &a , lli b){
  a = max(a , b);
}

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  lli n , w;
  cin >>  n >> w;
  vlli dp(w+1);
  frii(i , 0 ,n){
    lli we , val;
    cin >> we >> val;
    for(lli wa = w-we ; wa >= 0  ; --wa )
    {
      mx(dp[wa + we] , dp[wa] + val);
    }
  }
  lli ans = 0;
  for(lli i = 0 ;i <= w; ++i){
    mx(ans , dp[i]);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 1024
/*in the name of Allah the most beneficent the most merciful.*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 1000000007
//#define mod2 20071027
//#define MOD 998244353
#define base 139
// #define MOD 1000074259
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case #%lld: ", ++c)
#define out(x) cout << #x << " -> " << x << endl;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FILE   freopen("input.txt", "r", stdin);  freopen("out.txt", "w", stdout);
using namespace std;
const ll B = 20, N = 300010, M = 2000000;
deque<char>s;
string x;
ll q, t, f;
char ch;
int solve()
{
    cin >> x;
    for (auto u : x) s.pb(u);
    ll a = 1, b = 2;
    cin >> q;
    while (q--)
    {
        in1(t);
        if (t == 1)
            swap(a, b);
        else
        {
            cin >> f >> ch;
            if (f == a) s.push_front(ch);
            else s.push_back(ch);
        }
    }
    if (a != 1)
    {
        ll sz = s.size();
        for (int i = sz - 1; i >= 0; i--)
            printf("%c", s[i]);
        printf("\n");

    }
    else
    {
        for (auto u : s)
            printf("%c", u);
        printf("\n");

    }
    return 0;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    return solve();
}

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

int main()
{
    int n, m, k;
    cin >> n >> m;
    vector<vector<bool>> a(n, vector<bool>(m, false));
    for (int i = 0; i < n; i++) {
        cin >> k;
        for (int j = 0; j < k; j++) {
            int x;
            cin >> x;
            a.at(i).at(x-1) = true;
        }
    }
    int count = 0;
    for (int i = 0; i < m; i++) {
        int j = 0;
        while (a.at(j).at(i)) {
            j++;
            if (j == n)
                break;
        }
        if (j == n)
            count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,x,w;
    scanf("%d",&n);
    int k[1][n],p[1][n];
    for(x=0;x<n;x++){
        scanf("%d %d",&k[0][x],&p[0][x]);
    }
    for(x=0;x<n;x++){
        w=k[0][x]%p[0][x];
        if(w==0){
            printf("%d\n",p[0][x]);
        }
        else{
            printf("%d\n",w);
        }
    }
    return 0;
}

Measured memory_bytes: 596
s =  input()
num = int(input())
out = 0

cha = s[0]
countf = 1
countl = 0
for i in range((len(s)-1)//2):
  if s[i+1] == cha:
    countf += 1
  else:
    break
for i in range((len(s)+1)//2):
  if s[-i-1] == cha:
    countl += 1
  else:
    break

fs = s[:-countl]
ms = s[countf:-countl]
ls = s[countf:]

if countf == 1 and countl == 0:
  fs = s
  ms = s
  ls = s

if countf != 1 and countl == 0:
  fs = s
  ms = s[countf:]
  ls = s[countf:]
  
count = 1
for i in range(len(fs)-1):
  if fs[i] == fs[i+1]:
    count += 1
  else:
    out += count//2
    count = 1
out += count//2
  
count = 1
for i in range(len(ls)-1):
  if ls[i] == ls[i+1]:
    count += 1
  else:
    out += count//2
    count = 1
out += count//2    

count = 1
tout = 0
for i in range(len(ms)-1):
  if ms[i] == ms[i+1]:
    count += 1
  else:
    tout += count//2
    count = 1
tout += count//2
out += tout*(num-2)

out += ((countf+countl)//2) * (num-1)

if s.count(s[0]) == len(s):
  out = (len(s)*num)//2

print(out)

Measured memory_bytes: 3064
#include <stdio.h>

int d[10][10];

int w[10][10];

int xw[30];
int yw[30];
int tw[30];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i = 0; i < 10; i++)
	{
		for(int ii = 0; ii < 10; ii++)
		{
			scanf("%d",d[i] + ii);
		}
	}
	int q = 1;
	for(int j = 0; j < n; j++)
	{
		q *= 3;
	}
	for(int j = 0; j < q; j++)
	{
		for(int k1 = 0; k1 < 10; k1++)
		{
			for(int k2 = 0; k2 < 10; k2++)
			{
				w[k1][k2] = d[k1][k2];
			}
		}
		int now = j;
		int nk = 0;
		for(int k1 = 0; k1 < 10; k1++)
		{
			for(int k2 = 0; k2 < 10; k2++)
			{
aa:
				if(w[k1][k2] != 0)
				{
					if(nk < n)
					{
						int p = now % 3;
						now /= 3;
						tw[nk] = p + 1;
						if(p == 0)
						{
							xw[nk] = k2;
							yw[nk] = k1 + 1;
							if(k1 < 8 && k2 != 0 && k2 != 9)
							{
								if(w[k1 + 1][k2 - 1] != 0 && w[k1 + 1][k2] != 0 && w[k1 + 1][k2 + 1] != 0 && w[k1 + 2][k2] != 0)
								{
									w[k1][k2]--;
									w[k1 + 1][k2 - 1]--;
									w[k1 + 1][k2]--;
									w[k1 + 1][k2 + 1]--;
									w[k1 + 2][k2]--;
								}
								else
								{
									goto bb;
								}
							}
							else
							{
								goto bb;
							}
						}
						if(p == 1)
						{
							xw[nk] = k2 + 1;
							yw[nk] = k1 + 1;
							if(k1 < 8 && k2 < 8)
							{
								if(w[k1][k2 + 1] != 0 && w[k1][k2 + 2] != 0 && w[k1 + 1][k2] != 0 && w[k1 + 1][k2 + 1] != 0 && w[k1 + 1][k2 + 2] != 0 && w[k1 + 2][k2] != 0 && w[k1 + 2][k2 + 1] != 0 && w[k1 + 2][k2 + 2] != 0)
								{
									w[k1][k2]--;
									w[k1][k2 + 1]--;
									w[k1][k2 + 2]--;
									w[k1 + 1][k2]--;
									w[k1 + 1][k2 + 1]--;
									w[k1 + 1][k2 + 2]--;
									w[k1 + 2][k2]--;
									w[k1 + 2][k2 + 1]--;
									w[k1 + 2][k2 + 2]--;
								}
								else
								{
									goto bb;
								}
							}
							else
							{
								goto bb;
							}
						}
						if(p == 2)
						{
							xw[nk] = k2;
							yw[nk] = k1 + 2;
							if(k1 < 6 && k2 > 1 && k2 < 8)
							{
								if(w[k1 + 1][k2 - 1] != 0 && w[k1 + 1][k2] != 0 && w[k1 + 1][k2 + 1] != 0 && w[k1 + 2][k2 - 2] != 0 && w[k1 + 2][k2 - 1] != 0 && w[k1 + 2][k2] != 0 && w[k1 + 2][k2 + 1] != 0 && w[k1 + 2][k2 + 2] != 0 && w[k1 + 3][k2 - 1] != 0 && w[k1 + 3][k2] != 0 && w[k1 + 3][k2 + 1] != 0 && w[k1 + 4][k2] != 0)
								{
									w[k1][k2]--;
									w[k1 + 1][k2 - 1]--;
									w[k1 + 1][k2]--;
									w[k1 + 1][k2 + 1]--;
									w[k1 + 2][k2 - 2]--;
									w[k1 + 2][k2 - 1]--;
									w[k1 + 2][k2]--;
									w[k1 + 2][k2 + 1]--;
									w[k1 + 2][k2 + 2]--;
									w[k1 + 3][k2 - 1]--;
									w[k1 + 3][k2]--;
									w[k1 + 3][k2 + 1]--;
									w[k1 + 4][k2]--;
								}
								else
								{
									goto bb;
								}
							}
							else
							{
								goto bb;
							}
						}
						nk++;
						goto aa;
					}
					else
					{
						goto bb;
					}
				}
			}
		}
		for(int k = 0; k < n; k++)
		{
			printf("%d %d %d\n",xw[k],yw[k],tw[k]);
		}
		return 0;
bb:
		int as = 0;
	}
}

Measured memory_bytes: 1032
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np

def main():
	s=input().rstrip().decode('utf-8')
	
	cnt=0
	ans=0
	
	for i in range(len(s)):
		if s[-i-1]=="W":
			cnt+=1
		else:
			ans+=cnt
	
	print(ans)
	
	
	
	
	
	
	
if __name__ == "__main__":
	main()


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

int main() {
  int A, B;
  string op;
  cin >> A >> op >> B;

  if (op == "+") {
    cout << A + B << endl;
  }
  if(op == "-"){
    cout << A - B << endl;
  }
  if(op == "*"){
    cout << A * B << endl;
  }
  if(op == "/"){
    if(B != 0){
      cout << A / B << endl;
    }
    else{
      cout << "error" << endl;
     }
  }
  if(op == "?"|| op == "=" || op == "!"){
    cout <<"error" << endl;
  }
}


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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    from math import gcd
    
    # 篩の応用でnまでの数全部を素因数分解する
    
    # nまでの素数を列挙(n loglogn)
    n = 10**6 + 5
    
    D=[1]*(n+1) # 篩をしたときに初めて割った数

    #is_prime[i]にはi+1が素数か否かを示すboolが入る，[0]に1の素数判定がある(1-index)．
    is_prime = [True]*(n+1)
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            D[i-1]=i
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                if D[j-1]==1: # D[j-1]にはその数を初めて割れる数を入れとく
                    D[j-1]=i
                j += i

    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    P=[[]for _ in range(n)]
    
    # print(D)
    for i in range(2,n):
        if is_prime[i-1]:
            P[i-1].append(i)
        else:
            now=i
            while now >= 2:
                # print(i,D[now-1])
                P[i-1].append(D[now-1])
                now=now//D[now-1]

    # for i in range(100):
    #     print(i+1,P[i])
    
    N=I()
    A=LI()
    from collections import defaultdict
    dd = defaultdict(int)
    flag=1
    for i in range(N):
        a=A[i]
        S=set(P[a-1])
        # print(a,S)
        for p in S:
            if dd[p]:
                flag=0
                break
            dd[p]+=1
    

            
    if flag:
        print("pairwise coprime")
    else:
        g=A[0]
        for i in range(1,N):
            g=gcd(g,A[i])
        if g==1:
            print("setwise coprime")
        else:
            print("not coprime")
                
            
    

main()


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

int main()
{
    string B;
    ll A;
    cin >> A >> B;

    B.replace(1, 1, "");
    ll b = (stoi(B));

    cout << (A*b)/100 << endl;

    return 0;
}


Measured memory_bytes: 3616
import sys
input = sys.stdin.readline
from heapq import heappop, heappush

"""
f(x) = （一番上の長方形の左端がxに来るときのコストの最小値） を関数ごと更新していきたい
更新後をg(x)とする
g(x) = |x-L| + min_{-width_1 \leq t\leq width_2} f(x+t), 前回の幅、今回の幅
常に、区間上で最小値を持ち傾きが1ずつ変わる凸な関数であることが維持される。（区間は1点かも）
傾きが変わる点の集合S_f = S_f_lower + S_f_upperを持っていく。
S_f_lower, S_upperは一斉に定数を足す：変化量のみ持つ
"""

N = int(input())
LR = [[int(x) for x in input().split()] for _ in range(N)]

# initialize
L,R = LR[0]
S_lower = [-L]
S_upper = [L]
min_f = 0
add_lower = 0
add_upper = 0
prev_w = R - L

push_L = lambda x: heappush(S_lower, -x)
push_R = lambda x: heappush(S_upper, x)
pop_L = lambda: -heappop(S_lower)
pop_R = lambda: heappop(S_upper)

for L,R in LR[1:]:
    w = R - L
    # 平行移動とのminをとるステップ
    add_lower -= w
    add_upper += prev_w
    # abs(x-L) を加えるステップ
    # abs は瞬間に2傾きが変わるので
    x = pop_L() + add_lower
    y = pop_R() + add_upper
    a,b,c,d = sorted([x,y,L,L])
    push_L(a - add_lower)
    push_L(b - add_lower)
    push_R(c - add_upper)
    push_R(d - add_upper)
    min_f += c-b
    prev_w = w

print(min_f)



Measured memory_bytes: 30264
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

const int MOD = 1e9 + 7;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  vector<int> num(3);
  for(int i = 0; i < 3; i++)
  {
    cin >> num[i];
  }
  sort(num.begin(), num.end());
  cout << num[2] * 10 + num[1] + num[0];

  return 0;
}


Measured memory_bytes: 256
from collections import Counter

n=int(input())
nl=sorted(list(map(int,input().split())))
m=int(input())
ml=sorted(list(map(int,input().split())))

cnl=Counter(nl)
cml=Counter(ml)

ans="YES"

for i in cml.keys():
  if i  not in cnl.keys():
    ans="NO"
  else:
    if cml[i] > cnl[i]:
      ans="NO"
      break
      
print(ans)

Measured memory_bytes: 56760
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   

int main(){
    std::ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    int i=0;
    int val=0,sumi=0;
    while(n>0){
    	//dig[i++]=n%10;
    	i++;
    	sumi+=n%10;
    	val=n%10;
    	n/=10;
    }
    cout<<max(sumi,9*(i-1)+val-1);


    return 0;  
    
}



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

using namespace std;

typedef long long int ll;

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

  ll n;
  cin >> n;
  set < string > s;
  for(int i = 0; i < n; i++){
    string res;
    cin >> res;
    s.insert(res);
  }
  cout << s.size() << endl;
}


Measured memory_bytes: 19288
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;
int main()
{
    int n, k, q;
    cin >> n >> k >> q;

    vector<int> a;
    for (int i=0; i < q; i++)
    {
        int val;
        cin >> val;
        a.push_back(val);
    }
    
    vector<ll> pt (n);
    fill(pt.begin(), pt.end(), k - q);

    for (auto &e: a)
    {
        pt.at(e - 1)++;
    }

    for (const auto &e: pt)
    {
        cout << (e > 0 ? "Yes" : "No") << endl;
    }

    return 0;
}


Measured memory_bytes: 1912
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	scanner.Split(bufio.ScanWords)

	n, k := nextInt(), nextInt()

	array := make([]int, 100001)
	for i := 0; i < n; i++ {
		a, b := nextInt(), nextInt()
		array[a] += b
	}

	counter := 0
	for i, v := range array {
		counter += v
		if counter >= k {
			fmt.Println(i)
			break
		}
	}
}

func next() string {
	scanner.Scan()
	return scanner.Text()
}
func nextInt() int {
	i, err := strconv.Atoi(next())
	if err != nil {
		fmt.Println(err)
	}
	return i
}


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

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

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  string s, t;
  cin >> s >> t;

  vector<set<char> > v(26);
  vector<set<char> > v2(26);
  for (int i = 0; i < t.size(); i++) {
    v[t[i]-'a'].insert(s[i]);
    v2[s[i]-'a'].insert(t[i]);
  }

  for (int i = 0; i < 26; i++) {
    if (v[i].size() > 1 || v2[i].size() > 1) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 776
# AtCoder
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

ans = 0
commands = [''] * N

for i, t in enumerate(T):
    if t == 's':
        command = 'r'
        score = R
    elif t == 'r':
        command = 'p'
        score = P
    elif t == 'p':
        command = 's'
        score = S

    if (i-K >= 0) and (commands[i-K] == command):
        command = ''
        score = 0

    ans += score
    commands[i] = command

print(ans)


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

typedef long long ll;
typedef pair<ll, ll> P;

const int mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11

ll modpow(ll a,ll b){    // aのb乗
    ll ans=1;
    while(b>0){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return ans;
}

int main()
{
    ll n; cin >> n;
    if(n == 1) cout << 0 << endl;
    else{
        ll ans = modpow(10,n);
        ll sub = 2 * modpow(9,n) - modpow(8,n);
        sub %= mod;
        ans -= sub;
        ans = (ans%mod+mod) % mod;
        cout << ans << endl;
    }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define il inline
#define ri register int
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define mid ((l+r)>>1)
#define MAXN
#define MAXM
#define mod
#define inf (1<<30)
#define eps (1e-6)
#define alpha 0.75
#define rep(i, x, y) for(ri i = x; i <= y; ++i)
#define repd(i, x, y) for(ri i = x; i >= y; --i)
#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, int> pli;
typedef pair <int, ll> pil;
typedef pair <ll, ll> pll;
template <typename T> il bool chkmin(T &x, T y) {return x > y ? x = y, 1 : 0;}
template <typename T> il bool chkmax(T &x, T y) {return x < y ? x = y, 1 : 0;}
template <typename T> il void read(T &x) {
	char ch = getchar(); int f = 1; x = 0;
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = x*10+ch-'0', ch = getchar();
	x *= f;
}
template <typename T, typename... Args> il void read(T &x, Args &...args) {
	read(x), read(args...);
}
int n;
ll ans;
int main() {
	int pre = 0, now;
	read(n);
	rep(i, 1, n) {
		read(now);
		if(pre && now) --now, --pre, ++ans;
		ans += now / 2, pre = now & 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
//2014
#include<iostream>
using namespace std;
int main(void){
	int a,b,c,d,p,X,Y;
	cin>>a;
	cin>>b;
	cin>>c;
	cin>>d;
	cin>>p;
	if(p<c){
		Y=b;
	}
	else if(p>c){
		Y=b+((p-c)*d);	
	}
	X=p*a;
	if(X<Y){
		cout<<X<<endl;
	}
	else{
		cout<<Y<<endl;
	}
	return 0;
}


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

typedef struct {
    double y, x;
} p_t;

string to_str(Int x) {
    string s = "";
    while (x > 0) {
        char a = '0' + (x % 10);
        s = a + s;
        x /= 10;
    }
    return s;
}

int main() {
    Int n;
    cin >> n;
    Int x = 1;
    while (n > 0) {
        n /= 2;
        x <<= 1;
    }
    dump(x - 1);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int sum=0,n,x,k,ans=0;
int a[1000001];
map<int,int> m; 
int main(){
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        m[x]++;
    }
    int q=m.size();
    map<int,int>::iterator it=m.begin();
    for(it;it!=m.end();it++)a[++sum]=(*it).second;
    sort(a+1,a+sum+1);
    for(int i=1;i<=q-k;i++)ans+=a[i];
    cout<<ans<<endl;
    return 0;
 } 

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

using namespace std;

const int N=100000+10;

int n;
int a[N],b[N],c[N],d[N],r[N];
long long answer;

void msort(int s,int t)
{
    if(s==t) 
    { 
        return;
    }              
    int mid=(s+t)/2;
    msort(s,mid);             
    msort(mid+1,t);      
    int i=s, j=mid+1, k=s;   
    while(i<=mid && j<=t)
    {
    	if(d[i]<=d[j])  
        {
            r[k]=d[i];
            k++; 
            i++;
        }
        else
        {
        	answer+=mid-i+1;
            r[k]=d[j]; k++; j++;
        }
    }  
    while(i<=mid)
    {
        r[k]=d[i]; k++; i++;
    }
    while(j<=t)  
    {
        r[k]=d[j]; k++; j++;
    }
    for(int i=s; i<=t; i++) d[i]=r[i];  
    return;
} 

long long check(int x)
{
	answer=0;
	for(int i=1;i<=n;++i)
	{
		if(a[i]<x)c[i]=-1;
		if(a[i]>=x) c[i]=1;
	}
	d[0]=0;
	for(int i=1;i<=n;++i)
	{
		d[i]=d[i-1]+c[i];
	}
	msort(0,n);
	//cout<<answer<<endl;
	return answer;
}

int main()
{
	long long k;
	cin>>n;
	k=(long long)n*(n+1)/2;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i];
		b[i]=a[i];
	}
	int left,right,mid;
	left=1;
	right=unique(b+1,b+1+n)-1-b;
	sort(b+1,b+1+right);
	while(left<right)
	{
		mid=(left+right+1)/2;
		long long ret=check(b[mid]);
		//cout<<answer<<endl;
		if(ret<=k/2)
		{
			left=mid;
		}
		if(ret>k/2)
		{
			right=mid-1;
		}
	}
	cout<<b[left]<<endl;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define N 200005
ll inf = 1e14;
ll mod = 1e9 + 7;
char en = '\n';

ll abs1(ll x) {
  if (x < 0)
    return -x;
  return x;
}
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

ll dp[N];
ll arr[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n, k;
  cin >> n >> k;
  for (ll i = 1; i <= n; i++)
    cin >> arr[i];

  memset(dp, 0, sizeof(dp));

  for (ll i = 1; i <= k; i++) {
    dp[i] = 0;
    ll arr2[105];
    memset(arr2, 0, sizeof(arr2));
    for (ll j = 1; j <= n; j++) {
      if (arr[j] <= i) {
        arr2[dp[i - arr[j]]]++;
      }
    }
    ll j = 0;
    for (j = 0;; j++) {
      if (arr2[j] == 0)
        break;
    }
    dp[i] = j;
  }

  if (dp[k])
    cout << "First" << en;
  else
    cout << "Second" << en;

  return 0;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  vector<int> va(n);
  for (int i = 0; i < n; ++i) {
    cin >> va[i];
  }

  int ans = -1;
  for (int i = -100; i <= 100; ++i) {
    int cost = 0;
    for (int j = 0; j < va.size(); ++j) {
      cost += pow(va[j] - i, 2);
    }

    if (ans < 0 || ans > cost) {
      ans = cost;
    }
  }

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

Measured memory_bytes: 3600
#include"bits/stdc++.h"
using namespace std;

#define ll long long int
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define eb(x) emplace_back(x)
#define mp(a,b) make_pair(a,b)
#define sz(a) int((a).size())
#define mod 1000000007
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define inf LLONG_MAX
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }


void seethis(vector<ll>vect)
{
    for(ll x:vect)
        cout<<x<<" ";
    cout<<"\n";
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
//LCM
int lcm(int a, int b) {  return a * (b / __gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

//Tree
/* const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];*/

//ModPower
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

int main()
{
	FASTIO;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ll a;
	 cin>>a;

	 cout<<(a+ a*a +a*a*a)<<"\n";

	
	return 0;
}

Measured memory_bytes: 3556
N = int(input())

A = list(map(int,input().split()))
#print(A)
result = 1
for i in A:
    result = result * i
    if result > 1000000000000000000:
        break

for j in A:
    if j == 0:
        result = 0
    



if result <= 1000000000000000000:
    print(result)
else:
    print(-1)

Measured memory_bytes: 21712
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}
/********************************************************/
//	d.erase(unique(all(d)), d.end());



int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>n;
		// n=s.length();
		ll a[n];
		c=1;
		rep(i,n)
		{
			cin>>a[i];
			if(a[i]==0)
				c=0;
		}
		if(c==0)
		{
			cout<<"0\n";
			return 0;
		}
		rep(i,n)
		{
			k=a[i];
			m=c;
			if(c>(1000000000000000000ll/k))
			{
				c=-1;
				break;
			}
			c*=k;
			if(c>1000000000000000000ll || (c/k) != m)
			{
				c=-1;
				break;
			}
		}
		// c=n*m;
		cout<<c;

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

Measured memory_bytes: 4440