akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   int gcd(int a,int b){return b?gcd(b,a%b):a;};

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

ll N;
int main(){
  cin >> N;
  ll ans = 0;
  while (N > 0){
    ans += (N % 10 == 2);
    N /= 10;
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int mod = 998244353;
const int inf = 1000000000000000000;
int a[100006];
signed main() {
	int n; cin >> n;
	double res = 0;
	int fz = 0;
	rep(i, n) {
		cin >> a[i];
		if (a[i])res += log10((double)a[i]);
		else fz++;
	}
	if (fz)cout << 0 << endl;
	else {
		if (res > 18.01)cout << -1 << endl;
		else {
			int r2 = 1;
			rep(i, n)r2 *= a[i];
			if (r2 > inf)r2 = -1;
			cout << r2 << endl;
		}
	}
}

Measured memory_bytes: 4752
#include<stdio.h>

int main(){
  int S, h, m, s;
  scanf("%d", &S);
  h=S/3600;
  m=(S-h*3600)/60;
  s=S-h*3600-m*60;
  printf("%d:%d:%d\n", h, m, s);
  return 0;
}



Measured memory_bytes: 2116
import java.util.*;

public class Main {

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

        int[] aArr = new int[n];

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

        Arrays.sort(aArr);

        int ans = 0;
        for (int i = 0; i < aArr.length; i++) {
            x -= aArr[i];
            if (x < 0) break;
            ans++;
        }

        if (x > 0) {
            System.out.println(ans - 1);
        } else {
            System.out.println(ans);
        }


    }
}


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

int main(){
    int A,B,K;
    cin>>A>>B>>K;
    int a=A;
    int b=B;
    for(int i=0;i<K;i++){
        if(i%2==0){
            if(a%2==1){a-=1;}
            //cout << a <<" "<< b <<endl;
            b+=a/2;
            a=a/2;
        }
        else{
            //cout << a <<" "<< b <<endl;
            if(b%2==1){b-=1;}
            a+=b/2;
            b=b/2;
        }


    }

     cout << a <<" "<< b <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;                                                            
#define pb push_back                                                            
#define mp make_pair                                                                                                                                      
#define sqr(a) ((a) * (a))                                                      
#define io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);   
#define co() cout.precision(10);                                                
#define F for(li i=0;i<n;i++)
#define fo(i,a,n) for(i=a;i<n;i++)
#define ne cout<<"\n"; 
#define test int t;cin>>t;while(t--)
//#define oj #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif

typedef long long li;
typedef long double ld;

int main()
{
        io();
        li n;
        cin>>n;
        li a[n][3],i;
        for(i=0;i<n;i++)
        cin>>a[i][0]>>a[i][1]>>a[i][2];
        li dp[n][3];
        dp[0][0] = a[0][0];
        dp[0][1] = a[0][1];
        dp[0][2] = a[0][2];
        for(i=1;i<n;i++)
        {
            dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a[i][0];
            dp[i][1] = max(dp[i-1][0],dp[i-1][2])+a[i][1];
            dp[i][2] = max(dp[i-1][1],dp[i-1][0])+a[i][2];
        }
        li ans = max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
        cout<<ans;
        ne;
}

Measured memory_bytes: 4992
// Code by Nguyen Huu Lam
#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
const LL MaxN = 1 + 1e5, INF = 1e9;

LL n, a[MaxN], d[26][MaxN], kq[MaxN];
string s;
vector<LL> q[26];

LL Check(LL k){
    memset(kq, 0, sizeof kq);
    for(int i = 0 ; i < n - k + 1 ; ++i){
        string s1 = s.substr(i, k);
        if(s.find(s1, i + k) != string::npos) return 1;
    }
    return 0;
}

void InOut(){
    #define TASK "ABC"
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
}

int main(){
    // InOut();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    cin >> s;
    for(int i = 0 ; i < 26 ; ++i) q[i].push_back(n);
    for(int i = n - 1 ; i >= 0 ; --i){
        for(int j = 0 ; j < 26 ; ++j) d[j][i] = *(q[j].end() - 1);
        q[s[i] - 'a'].push_back(i);
    }
    // for(int i = 0 ; i < n ; ++i) cout << d[0][i] << " ";
    // cout << endl; 
    LL l = 0, r = n / 2;
    while(l < r){
        LL tg = (l + r + 1) / 2;
        if(Check(tg)) l = tg;
        else r = tg - 1;
    }
    cout << l << endl;

    return 0;
}

Measured memory_bytes: 19712
#include <stdio.h>

int main(void)
{
	int S, h, m, s;
	S = 46979;
	scanf("%d", &S);
	h = S / 3600;
	m = (S - 3600*h) / 60;
	s = S - 3600*h - 60*m;
	
	printf("%d:", h);
	printf("%d:", m);
	printf("%d\n", s);
	return 0;
}

Measured memory_bytes: 592
# -*- coding: utf-8 -*-
# 整数の入力
a, b, c = map(int, input().split())

result = False
for i in range(1, b+1):
    sum_a = a * i

    if sum_a % b == c:
        result = True
        break

if result:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define double long double
#define Sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T> inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<int,int> P;
const long long MOD=1000000007;


void solve(long long A, long long B){
    int ans=0, ana=1;
    while (B>ana)
    {
        --ana;
        ana += A;
        ans++;
    }

    // if (B<=A)
    // {
    //     std::cout << 1 << std::endl;
    //     return;
    // }
    // ans = (B-A)/(A-1) + !!((B-A)%(A-1));
    // ans = ans +1;
    std::cout << ans << std::endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <cstdlib>
using namespace std;
using ll = long long int;
int INF = 1e9+7;

int main() {
    int N,A,B;
    cin >> N >> A >> B;
    cout << min(A,B) << ' ' << max(A+B-N,0) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int A,B,C,f=0;

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

    if((A==B) && (A!=C)){
        f=1;
    }
    if((C==B) && (A!=C)){
        f=1;
    }
    if((A==C) && (A!=B)){
        f=1;
    }

    if(f==0){
        printf("No\n");
    } else {
        printf("Yes\n");
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <math.h>
#include <stdlib.h>
using namespace std;
void getValue(string& l, int& d, int& a)
{
	string::size_type p = l.find(',');
	d = atoi(l.substr(0, p).c_str());
	a = atoi(l.substr(p + 1).c_str());
}
int main()
{
	string line;
	int d, a;
	double x = 0.0, y = 0.0, angle = 90.0, toR = 3.14159265358979323846 / 180.0;
	while (true){
		cin >> line;
		getValue(line, d, a);
		if (0 == d && 0 == a)
			break;
		x += cos(angle * toR) * d;
		y += sin(angle * toR) * d;
		angle -= a;
	}
	cout << (int)x << "\n" << (int)y << "\n";
	return 0;
}

Measured memory_bytes: 1196
import itertools


n, m = map(int, input().split())
edges = {tuple(sorted(map(int, input().split()))) for _ in range(m)}
ans = 0
for i in itertools.permutations(range(2, n+1), n-1):
    l = [1] + list(i)
    ans += sum([1 for edge in zip(l, l[1:]) if tuple(sorted(edge)) in edges]) == n-1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <utility> 
#include <unordered_set>
#include <vector>
#include <list> 
#include <string>
#include <iterator> 
#include <deque>
#include <array>
#include <forward_list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <bitset>
using namespace std;

#define N 100000
#define EPS 1e-9
#define PI 3.14159265358979323846264338327950

int h[N];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	
	while (true) {
		c -= b;
		if (c < 1) {
			cout << "Yes" << '\n';
			break;
		}
		a -= d;
		if (a < 1) {
			cout << "No" << '\n';
			break;
		}
	}
}


Measured memory_bytes: 3648
#include <stdio.h>
#define N 100

int main()
{
  int i,j,n,k,s,t;
  int hi[N][N];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++)
      hi[i][j]=0;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&s,&k);
    s--;

    for(j=0;j<k;j++){
      scanf("%d",&t);
      t--;

      hi[s][t]=1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j)
	printf(" ");
      printf("%d",hi[i][j]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2112
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();

        if (a.charAt(a.length() - 1) == b.charAt(0) && b.charAt(b.length() - 1) == c.charAt(0)) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 21716
A, B = map(int, input().split())

ones = [0] * 101
def calcones(end, pow):
	start = pow // 2
	if end < pow // 2:
		return 0
	
	n = (end - start + 1) // pow
	n *= pow // 2
	
	if 0 < (end - start + 1) % pow <= pow // 2:
		n += (end - start + 1) % pow
		
	return n

pow = 2
for i in range(1, 101):
	ones[i] = calcones(B, pow) - calcones(A-1, pow)
	pow *= 2
	
# print(ones)
		
ans = 0
pow = 1
for i in range(1, 101):
	ans += (ones[i] % 2) * pow
	pow *= 2
	
print(ans)

Measured memory_bytes: 61856
import sys
def resolve():
    input = sys.stdin.readline
    H,W=map(int,input().rstrip().split())
    S=[input().rstrip() for _ in range(H)]

    dx=[0,0,-1,1]#上下左右
    dy=[1,-1,0,0]

    for i in range(H):
        for j in range(W):
            if(S[i][j]=="#"):
                for dir in range(4):
                    nx=j+dx[dir]
                    ny=i+dy[dir]

                    if(nx<0 or nx>=W):
                        continue
                    if(ny<0 or ny>=H):
                        continue

                    if(S[i][j]==S[ny][nx]):
                        break
                else:
                    print("No")
                    return
    print("Yes")




from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """3 3
.#.
###
.#."""
        output = """Yes"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """5 5
#.#.#
.#.#.
#.#.#
.#.#.
#.#.#"""
        output = """No"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """11 11
...#####...
.##.....##.
#..##.##..#
#..##.##..#
#.........#
#...###...#
.#########.
.#.#.#.#.#.
##.#.#.#.##
..##.#.##..
.##..#..##."""
        output = """Yes"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Measured memory_bytes: 52204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
			// 文字列の入力
			string s = Console.ReadLine();

			int number = int.Parse(s.Replace(" ", ""));

			if((number % 4) == 0) {
				Console.WriteLine("YES");
			} else {
				Console.WriteLine("NO");
			}
		}
	}
}

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

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

typedef long long ll;

using namespace std;

void calcDist(vector<int> *g, int st, int *dist, int currentDist, bool *visited)
{
    dist[st] = currentDist;
    visited[st] = true;
    currentDist++;
    for (int i = 0; i < g[st].size(); ++i)
    {
        int node = g[st][i];
        if(!visited[node])
        {
            calcDist(g, node, dist, currentDist, visited);
        }
    }
}

int main()
{
    int N;
    cin >> N;
    vector<int> G[N];
    REP(i, N - 1)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // マス1, N からそれぞれのマスへの距離を計算
    int distF[N] = {0}, distS[N] = {0};
    bool visitedF[N] = {false}, visitedS[N] = {false};
    // マス1からの距離
    int st = 0;
    int dist = 0;
    calcDist(G, st, distF, dist, visitedF);

    // マスN からの距離
    st = N - 1;
    dist = 0;
    calcDist(G, st, distS, dist, visitedS);

    // マス1からの方が近いマスの数と、マスN からの方が近い点を数える
    int countF = 0, countS = 0;
    REP(i, N)
    {
        if(distF[i] <= distS[i])
        {
            countF++;
        }
        else
        {
            countS++;
        }
    }

    if (countF > countS)
    {
        cout << "Fennec" << endl;
    }
    else
    {
        cout << "Snuke" << endl;
    }

}


Measured memory_bytes: 12928
_ = raw_input()
tests = [int(test) for test in raw_input().split(" ")]
total_time = sum(tests)
drinks = int(raw_input())
for _ in range(drinks):
    i = [int(x) for x in raw_input().split(" ")]
    no, time = i[0], i[1]
    print total_time - (tests[no - 1] - time)


Measured memory_bytes: 2568
using System;

public class Program{
    public static void Main(){
        string[] s=Console.ReadLine().Split();
        int a=int.Parse(s[0]);
        int b=int.Parse(s[1]);
        int c=int.Parse(s[2]);
        if(a==b){
            Console.WriteLine(c);
        }else if(a==c){
            Console.WriteLine(b);
        }else{
            Console.WriteLine(a);
        }
    }
}


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

long long N;

int main() {
	cin>>N;
	for(long long h=1;h<=3500;h++){
		for(long long n=1;n<=3500;n++){
			long long x = h*n*N;
			long long y = 4*h*n - n*N - h*N;
			if(y>0 and x%y==0){
				cout<<h<<" "<<n<<" "<<x/y<<endl;
				return 0;
			}
		}
	}
	return 0;
}

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

void solve(long long X)
{
    long long cnt = 0;
    long long cnt2 = 0;
    while (X - 500 >= 0)
    {
        X -= 500;
        cnt++;
    }

    while (X - 5 >= 0)
    {
        X -= 5;
        cnt2++;
    }

    cout << (1000 * cnt + 5 * cnt2) << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long X;
    scanf("%lld", &X);
    solve(X);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;


int main() {
    int n;
    string s, p;   
    cin >> s >> p;
    n = s.size();
    s = s + s;
    for (int i = 0; i < n; i++){
        bool ok = true;
        for (int j = 0; j < p.size(); j++){
            if (s[i + j] != p[j]){
                ok = false;
            }
        }
        if (ok == true){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3228
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    pair<ll,int> drink[100000];
    REP(i,n){
        cin >> drink[i].first >> drink[i].second;
    }
    sort(drink,drink+n);
    ll ans = 0;
    REP(i,n){
        if(m<=0)break;
        ans += drink[i].first*min(m,drink[i].second);

        m -= drink[i].second;
    }
    cout << ans << endl;
}


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

anss = [0]*4

for i in range(N):
    S = input()
    if S == 'AC':
        anss[0]+=1
    if S == 'WA':
        anss[1]+=1
    if S == 'TLE':
        anss[2]+=1
    if S == 'RE':
        anss[3]+=1

print('AC x {}'.format(anss[0]))
print('WA x {}'.format(anss[1]))
print('TLE x {}'.format(anss[2]))
print('RE x {}'.format(anss[3]))


Measured memory_bytes: 9184
//部分木に含まれる頂点を全て求めてしまえばよい
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<utility>

using namespace std;

int main(){
  int n,q;cin >> n >> q;
  vector< vector<int> > u(n);
  for(int i=0;i<n-1;i++){
    int a,b;cin >> a >> b;
    u[a-1].push_back(b-1);
    u[b-1].push_back(a-1);
  }

  vector<int> c(n,0);
  for(int i=0;i<q;i++){
    int p,x;cin >> p >> x;c[p-1]+=x;
  }
  //cout << 0 << endl;
  /*
  for(int i=0;i<n;i++){
    for(int j=0;j<u[i].size();j++){
      cout << u[i][j];
      if(j==u[i].size()-1) cout << endl;
      else cout << " ";
    }
  }
  */

  queue< pair<int,int> > k;k.push(make_pair(-1,0));
  while(k.size()!=0){
  //for(int z=0;z<10;z++){
    int l1=k.size();
    for(int i=0;i<l1;i++){
      pair<int,int> a=k.front();
      int l2=u[a.second].size();
      for(int j=0;j<l2;j++){
        if(u[a.second][j]!=a.first){
          c[u[a.second][j]]+=c[a.second];
          k.push(make_pair(a.second,u[a.second][j]));
        }
      }
      k.pop();
    }

  }
  for(int i=0;i<n;i++){
    cout << c[i];
    if(i==n-1) cout << endl;
    else cout << " ";
  }
}


Measured memory_bytes: 16372
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
#from decimal import *

x = LIST()

print(x.index(0)+1)

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int k = sc.nextInt();
        char[][] c = new char[h][w];
        for (int i = 0; i < h; i++) {
            c[i] = sc.next().toCharArray();
        }
        int n = h + w;
        int ans = 0;
        for (int bit = 0; bit < (1 << n); bit++) {
            //StringBuilder sb = new StringBuilder();
            boolean[] choosedH = new boolean[h];
            boolean[] choosedW = new boolean[w];
            for (int i = 0; i < n; i++) {
                if ((1 & (bit >> i)) == 1) {
                    //sb.append(i);
                    if (i < h) {
                        choosedH[i] = true;
                    } else {
                        choosedW[i - h] = true;
                    }
                }
            }
            //System.out.println(sb);
            int cnt = 0;
            for (int i = 0; i < h; i++) {
                if (choosedH[i]) {
                    continue;
                }
                for (int j = 0; j < w; j++) {
                    if (choosedW[j]) {
                        continue;
                    }
                    if (c[i][j] == '#') {
                        cnt++;
                    }
                }
            }
            if (cnt == k) {
                ans++;
            }
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 37176
#include <stdio.h>

int main()
{
	int data[200000];
	int n;

//	int data[] = { 4,1,2,1 };
//	int n = 4;*
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &data[i]);
	}
	
	int max = -2000000000;
	int min = data[0];

	for (int i = 1; i < n; i++)
	{
		if (max < data[i] - min)
		{
			max = data[i] - min;
		}
		if (min > data[i])
		{
			min = data[i];
		}
	}

	printf("%d\n", max);
}

Measured memory_bytes: 2512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll f(ll a, ll b){
    if(a>b)swap(a,b);
    if(b%a==0)return b+b-a;
    ll trt = b/a;
    return 2*a*trt+f(b%a,a);
}
int main(){
    ll n,x;
    cin>>n>>x;
    cout<<n+f(n-x,x)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>

using namespace std;

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

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

    int pos[n][d];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < d; j++)
        {
            cin >> pos[i][j];
        }
    }
    
    int count = 0;
    for (int i = 0; i < n-1; i++)
    {
        for (int j = i+1; j < n; j++)
        {
            double sum = 0;
            for (int k = 0; k < d; k++)
            {
                int diff = abs((pos[i][k] - pos[j][k]));
                sum += (diff * diff);
            }

            double sqr = sqrt(sum);
            if (ceil(sqr) == floor(sqr))
            {
                count++;
            }
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem0514 : Quality Checking **/
int main()
{
	int A, B, C;
	
	while (cin>>A>>B>>C, A||B||C) {
		
		vector<int> P(A+B+C);
		rep(i, A+B+C) P[i] = 2;
		
		vector<vector<int> > list;
		
		int N; cin>>N;
		rep(i, N) {
			int x, y, z, b; cin>>x>>y>>z>>b;
			x--, y--, z--;
			
			if (b) {
				P[x] = 1;
				P[y] = 1;
				P[z] = 1;
			} else {
				list.push_back(vector<int>(3));
				list.back()[0] = x;
				list.back()[1] = y;
				list.back()[2] = z;
			}
		}
		
		rep(i, list.size()) {
			int x = list[i][0], y = list[i][1], z = list[i][2];
			if (P[x]==1 && P[y]==1 && P[z]==2)
				P[z] = 0;
			if (P[x]==1 && P[y]==2 && P[z]==1)
				P[y] = 0;
			if (P[x]==2 && P[y]==1 && P[z]==1)
				P[x] = 0;
		}
		
		rep(i, A+B+C) cout << P[i] << endl;
	}
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int X;
    cin >> X;
    int ans = X/200;
    ans = 10 - ans ;
    cout << ans << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int A, B;
    cin >> A >> B;

    cout << A * B - A - B + 1;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

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

int main(){
  int n;
  cin>>n;
  int vec[n+2];
  vec[0]=0,vec[n+1]=0;
  for(int i=1;i<=n;i++){
    cin>>vec[i];
  }
  int sum=0;
  for(int i=0;i<n+1;i++){
    sum+=abs(vec[i]-vec[i+1]);
  }
  for(int i=1;i<=n;i++){
    if(vec[i-1]<=vec[i]&&vec[i]<=vec[i+1]){
      cout<<sum<<endl;
      continue;
    }
    if(vec[i-1]>=vec[i]&&vec[i]>=vec[i+1]){
      cout<<sum<<endl;
      continue;
    }
    if(vec[i-1]==vec[i]||vec[i]==vec[i+1]){
      cout<<sum<<endl;
      continue;
    }
    cout<<sum-abs(vec[i-1]-vec[i])-abs(vec[i]-vec[i+1])+abs(vec[i-1]-vec[i+1])<<endl;
  }
}

Measured memory_bytes: 1664
#include<iostream>
using namespace std;
int main(){
	int S,h,m,s;
	cin >> S;

	h = S / 3600;
	m = (S - 3600 * h) / 60;
	s = (S - 3600 * h) % 60;


	cout << h << ":" << m << ":" << s << endl;



	return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>

using namespace std;

int main() {
	vector<int> hyou(32769, 0);
	hyou[0] = hyou[1] = 1;
	for (int i = 2; i*i < 32769; i++) {
		if (hyou[i] == 0) {
			for (int j = 2; j <= 32769/i; j++) {
				hyou[i*j] = 1;
			}
		}
	}
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		int counter = 0;
		for (int i = 2; i <= n/2; i++) {
			if (hyou[i] == 0) {
				if (hyou[n-i] == 0) {
					counter++;
				}
			}
		}
		cout << counter << endl;
	}
	return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define int               long long
#define fr                first
#define sc                second
#define vc                vector
#define endl              '\n'
#define pii               pair<int,int>
#define msi               map<string,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define LSB(i)            ((i)&-(i))

template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 1e5 + 5;
int dp[N];
int a[N];
int n;

void solve()
{
    cin >> n;
    for (int i = 1 ; i <= n; i++)
        cin >> a[i];
    // mem1(dp);
    dp[1] = 0;
    dp[2] = abs(a[2] - a[1]);
    for (int i = 3; i <= n; ++i)
        dp[i] = min(dp[i - 2] + abs(a[i] - a[i - 2]), dp[i - 1] + abs(a[i] - a[i - 1]));
    cout << dp[n];
}
signed main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin>>t;
    while (t--) solve();
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
using namespace std;
void read(int &res){
	res=0;char c;
	while((c=getchar())<48);
	do res=(res<<1)+(res<<3)+(c^48);
	while((c=getchar())>47);
}
int main(){
	char str[1001];
	scanf("%s",str+1);
	int i,j,len=strlen(str+1),t;
	for(i=len-1;i>=1;--i){
		if(i&1)continue;
		for(j=t=1;j<=i/2;++j)if(str[j]!=str[j+i/2]){
			t=0;
			break;
		}
		if(t){
			printf("%d",i);
			return 0;
		}
	}
	return 0;
}

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

int main() {
    int n,d,ans=1;
    cin >> n;
    vector<int> d_1;
    for(int i=0;i<n;i++){
        cin >> d;
        d_1.push_back(d);
    }
    sort(d_1.begin(),d_1.end(),greater<int>());
    for(int i=1;i<n;i++){
        ans++;
        if(d_1[i]==d_1[i-1]){
            ans--;
            continue;
        }
        else if(d_1[i]>d_1[i-1]){
            cout << ans-1 << endl;
            return 0;
        }
        else continue;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import static java.lang.System.*;
import java.util.*;
 
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		String s = sc.next();
		int price = 700;
		for (int i=0; i<3; i++) {
			if (s.charAt(i)=='o') price += 100;
		}
		out.println(price);
	}
}

Measured memory_bytes: 23252
#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 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 = I()
A = [I() for _ in range(n)]
dic = Counter(A)
cnt = 0
for k,v in dic.items():
    if v%2:
        cnt += 1
print(cnt)


Measured memory_bytes: 21836
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)

bool isSquare(int n) {
	int p = sqrt(n);
	if (p * p == n) return true;
	else return false;
}

int main() {
	int a, b;
	cin >> a >> b;
	int ans = -1;
	rep(i, 100000) {
		int x = i * 1.08 - i;
		int y = i * 1.1 - i;
		if (x == a && y == b) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;


int main(){
	int N;
	cin >> N;
	
	int D, X;
	cin >> D >> X;

	int count = 0;
	for(int i = 0; i < N; ++i){
		int A;
		cin >> A;
		for(int j = 1; j <= D; j += A){
			count++;
		}
		//cout << " * " <<  count << endl;
	}

	cout << (count + X) << endl;
}



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

using namespace std;
typedef long long ll;




int main()
{
    int N;
    cin >> N;
    vector<int> A(N+2);
    rep(i,N) cin >> A[i+1];
    A[0] = 0,A[N+1] = 0;
    
    vector<int> B(N+2);
    B[0] = 0;
    for (int i = 1; i <= N+1; i++) {
        B[i] = B[i-1]+abs(A[i]-A[i-1]);
    }
    //rep(i,N+2) cout << A[i] << " ";cout << endl;
    //rep(i,N+2) cout << B[i] << " ";cout << endl;
    
    for (int i = 1; i <= N; i++) {
        int ans = 0;
        ans += abs(A[i+1] - A[i-1]);
        ans += B[i-1];
        ans += B.back() - B[i+1];
        cout << ans << endl;
    }
    
    
    return 0;
}



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

using namespace std;

#define Fast  ios::sync_with_stdio(false); cin.tie(0)
#define pb push_back
#define pf push_front
#define pp pop
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define S second
#define F first
typedef long long ll;
const ll mod = 1e9 + 7;
const ll N = 1e6 + 5;
ll inf = 1e18;

int main(){

    Fast;

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

    ll ans = s.size();

    for(int i = 0 ; i <= s.size() - t.size() ; i ++){
        ll tmp = 0;
        for(int j = i; j < i + t.size(); j++){
            if(s[j] != t[j-i])tmp ++;
        }
        ans = min(ans , tmp);
    }
    cout << ans ;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
    #define sz(a) (int)(a).size()
     
    using namespace std;
     
    template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
    template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
    const int INF = 2e5+2;
    const long long hell = 998244353ll;
    
    void solve(){
          int n,m;
          cin>>n>>m;
          if(n%(2*m+1)==0) n-=1;
          cout<<(n/(2*m+1))+1<<endl;
    }

    int main(){
    	
    	ios_base::sync_with_stdio(0);cin.tie(0);
    	
    	int q=1;
    #ifdef LOCAL
      	cin>>q;
#endif
	while(q--){
	 solve();
	}

    #ifdef LOCAL
        cout << "Time elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms.\n";
    #endif	
    	return 0;
    }

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

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

int main(void){
    ll n;
    cin >> n;
    if (((n / 100) == 7) ||
    ((n / 10) % 10 == 7) ||
    (n % 10) == 7){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i=0; i<N; i++) {
    cin >> A.at(i);
  }
  vector<int> B(N);
  for (int i=0; i<N; i++) {
    cin >> B.at(i);
  }
  int sum = 0;
  for (int i=0; i<N; i++) {
    if (A.at(i) - B.at(i) > 0) {
      sum += A.at(i) - B.at(i);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  char c[5];
  scanf("%s", c);
  int ans = 0;
  for(int i=0; i<4; i++)
    if(c[i] == '+') ans++;
    else ans--;
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
import math
 
i = input().split()
n = int(i[0])
D = int(i[1])
num_list = []
count = 0
for i in range(n):
	num_list.append(list(map(int,input().split())))
 
for j in num_list:
    x = j[0]
    y = j[1]
    dist = math.sqrt(x ** 2 + y ** 2)
    if dist <= D:
        count += 1
 
print(count)

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

int main() {
    int q;
    cin >> q;
    for(int i=0; i<q; i++) {
        string A,B;
        cin >> A >> B;
        int aSize = A.size();
        int bSize = B.size();
        int c[aSize+1][bSize+1];
        for(int i=0; i<=aSize; i++) c[i][0] = 0;
        for(int j=0; j<=bSize; j++) c[0][j] = 0;
        for(int i=1; i<=aSize; i++) {
            for(int j=1; j<=bSize; j++) {
                if(A[i-1] == B[j-1]) c[i][j] = c[i-1][j-1] + 1;
                else c[i][j] = max(c[i-1][j], c[i][j-1]);
            }
        }
        cout << c[aSize][bSize] << endl;
    }
}


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

typedef long long ll;

#define PB push_back
#define MP make_pair

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ll a; cin >> a; ans += a - 1;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3596
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;



int main(){
    int n;
    cin >> n;
    map<string, int>mp;
    rep(i, n){
        string s;
        cin >> s;
        mp[s] = 1;
    }
    int res = 0;
    for(auto m : mp){
        res++;
    }
    cout << res << endl;
}



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


int main(){
  

  int n;
  cin>>n;
  
  vector<long long> data(n);
  
  for (int i=0;i<n;i++){
    long long tmp;
    cin>>tmp;
    
    data.at(i)=tmp-i;
  }
  
  sort(data.begin(),data.end());
  
  int b=data.at(n/2);
  
  long long answer=0;
  
  for (int i=0;i<n;i++){
    answer+=abs(data.at(i)-b);
  }
  
  cout<<answer<<endl;
  
  

  
  

  
  
}

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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    while (a % 2 == 0) {
      a /= 2;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// #include<iostream>
// #include<cmath>
// using namespace std;
// int n;
//
// int main(){
//   cin >> n;
//   double ans = pow(n,3) / 27;
//   cout << (double)ans << endl;
//   return 0;
// }
#include <stdio.h>
int main(){
int L;
scanf("%d",&L);
printf("%.12f\n",(double)L*L*L/27);
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	ll n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	ll co=0;
	rep(i,n-1){
		co+=in[i]/2;
		in[i]%=2;
		if(in[i]&&in[i+1]){
			co++;
			in[i]--;
			in[i+1]--;
		}
	}
	cout<<co+in[n-1]/2<<endl;
}
 
 







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

bool vis[5];
bool bo[233][233],flag=false;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline void dfs(int x,int y)
{
	if (x==4) { flag=true;return; }
	for (int i=1;i<=4;i++) if (!vis[i]&&bo[y][i])
	{
		vis[i]=true;dfs(x+1,i);vis[i]=false;
		if (flag) return;
	}
}

int main()
{
	for (int i=1;i<=3;i++) { int x=rd(),y=rd();bo[x][y]=bo[y][x]=true; }
	for (int i=1;i<=4;i++) if (!flag) vis[i]=true,dfs(1,i),vis[i]=false;
	if (flag) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N,A,B,C;
vector<int> L;
int ans=10000000;
void dfs(int cur,int a,int b,int c,int mp){
    if(cur==N){
        if(a>0&&b>0&&c>0){
            ans=min(ans,abs(a-A)+abs(b-B)+abs(c-C)+mp-30);
        }
        return;
    }
    dfs(cur+1,a+L[cur],b,c,mp+10);
    dfs(cur+1,a,b+L[cur],c,mp+10);
    dfs(cur+1,a,b,c+L[cur],mp+10);
    dfs(cur+1,a,b,c,mp);
}
int main(){
    cin>>N>>A>>B>>C;
    for(int i=0;i<N;i++){
        int k;cin>>k;
        L.push_back(k);
    }
    dfs(0,0,0,0,0);
    cout<<ans<<endl;
}

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
  ll n, m;
  ll a[110];
  ll sum = 0;
  cin >> n >> m;
  REP(i, n) {
    cin >> a[i];
    sum += a[i];
  }
  ll cnt = 0;
  REP(i, n) {
    if(a[i]*4*m >= sum ) {
      cnt ++;
    }
  }
  cout << ((cnt >= m) ? "Yes" : "No") << endl;
  
}


Measured memory_bytes: 256
import sys
n,y=map(int,input().split())
t=True
for i in range(n+1):
    for j in range(n+1):
        if ((10000*i+5000*j+1000*(n-i-j))==y) & (i+j<=n):
            t=False
            print(i, j, n-i-j)
            sys.exit(0) 
if t:
    print("-1 -1 -1")

Measured memory_bytes: 3060
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　| 　_　 _ l
　 　　　／` ミ＿xノ    見ちゃだめ！
　　 　 /　　　 　 |　
　　　 /　 ヽ　　 ﾉ　　
　 　 │　　|　|　|　　
　／￣|　　 |　|　|
　| (￣ヽ＿_ヽ_)__)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;

int main() {
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int ans = 0;
  for (int i = 0; i <= 3000; i++)
    for (int j = 0; j <= 3000; j++) {
      int v = i * r + j * g;
      if (n >= v && (n - v) % b == 0) ans++;
    }
  cout << ans << endl;
}

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

typedef long long ll;

#define PrintLn(X) cout << X << endl
#define Loop(n) for(int loop_ = n; loop_; --loop_)
#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define For(i, a, b) for(int i = a; i < (int)(b); ++i)

ll N, M;

ll f(ll n)
{
	ll s_needed = n - N;
	ll c_needed = 2 * n;
	if(s_needed < 0) s_needed = 0;
	return M >= s_needed * 2 + c_needed;
}

int main(void)
{
	cin >> N >> M;
	ll mn = 0;
	ll md;
	ll mx = 1000000000000;
	while(mn < mx - 1){
		md = (mn + mx) / 2;
		if(f(md)){
			mn = md;
		}else{
			mx = md;
		}
	}
	PrintLn(mn);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
double EPS = 1e-9;
constexpr ll MOD =  1e9+9;
using namespace std;
//vector<int> node[2][29];
//void test(){
//    freopen("in.txt", "r", stdin);
//    int n;
//    cin >> n;
//    ll s1, s2;
//    s1 = s2 = 0;
//    vector<int> a(n);
//    int mx = -1e9;
//    for(int i = 0;i < n;i++){
//        cin >> a[i];
//        mx = max(mx, a[i]);
//    }
//
//    for(int i = 0;i < n;i += 2){
//        if(a[i] > 0)s1 += a[i];
//    }
//    for(int i = 1;i < n;i += 2){
//        if(a[i] > 0)s2 += a[i];
//    }
//
//    freopen("out.txt", "r", stdin);
//    ll res;
//    cin >> res;
//    int x;
//    cin >> x;
//    int c;
//    for(int i = 0;i < x;i++){
//        cin >> c;
//        if(c == 1){
//            a.erase(a.begin());
//        }else if (c == a.size()){
//            a.erase(a.end()-1);
//        }else{
////            cout << c << ' ' << a.size() << endl;
//            a[c-1] = a[c] + a[c-2];
//            a.erase(a.begin() + c - 2);
//            a.erase(a.begin() + c - 1);
//        }
//    }
//    ll q = 0;
//    for(int i = 0;i < a.size();i++){
//        q += a[i];
//    }
////    assert(q == max(s1, s2));
//    cout << q << ' ' << s1 << ' ' << s2;
//}

int main()
{
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
//    srand(time(0));
//    test();
//    return 0;
//
//    cout << 100000 << endl;
//
//    for(int i = 0;i < 1000;i++)
//        cout << (rand() & 1 ? -1 : 1) * rand() << ' ';
//    return 0;
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    ll s1, s2;
    s1 = s2 = 0;
    vector<ll> a(n);
    ll mx = -1e9;
    for(int i = 0;i < n;i++){
        cin >> a[i];
        mx = max(mx, a[i]);
    }

    for(int i = 0;i < n;i += 2){
        if(a[i] > 0)s1 += a[i];
    }
    for(int i = 1;i < n;i += 2){
        if(a[i] > 0)s2 += a[i];
    }
    if(mx <= 0)
        cout << mx << endl;
    else
        cout << max(s1, s2) << endl;
    bool inv = s2 > s1;
    s1 = max(s1, s2);
    vector<int> sol;
    int x = 0;
    if(mx <= 0){
        bool found = 0;
        for(int i = 0;i < n;i++){
            if(a[i] == mx){
                for(int j = 0;j < n-i-1;j++){
                    sol.push_back(n-i-j);
                }
                break;
            }else{
                sol.push_back(1);
            }
        }

        cout << sol.size() << endl;
        for(auto el : sol)
            cout << el << endl;
        return 0;
    }
    if(inv){
        sol.push_back(1);
        a.erase(a.begin());
        n--;
    }
    int i = 0;
    while(a[i] <= 0){
        sol.push_back(1);
        sol.push_back(1);
        i += 2;
    }
//    int x = 0;
    for(;i + 2 < n;i += 2){
        if(a[i + 2] < 0){
            if(i+2 == n-1)
                x = 1;
            sol.push_back(3);
        }else{
            sol.push_back(2);
        }
    }
    if(x || !(n&1)){
        sol.push_back(2);
    }
    cout << sol.size() << endl;
    for(auto el : sol)
        cout << el << endl;
    return 0;
}


Measured memory_bytes: 256