akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] ans = new int[n+1];
        for (int i=1;i<=n;i++)ans[sc.nextInt()]=i;
        for (int i=1;i<=n;i++)System.out.print(ans[i]+" ");
        System.out.println();
    }
}


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

template <long long Modulus = 1000000007>
struct MInt
{
    long long x;
    static const long long mod = Modulus;
    
    MInt(long long a = 0) : x((a % mod + mod) % mod) {}

    // operator
    MInt& operator = (const MInt& a)
    {
        x = a.x;
        return *this;
    }
    MInt& operator = (const long long& a)
    {
        *this = MInt(a);
        return *this;
    }

    MInt operator -() const
    { 
        return MInt(-x);
    };

    MInt& operator +=(const MInt& a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }

    MInt& operator -=(const MInt& a)
    {
        if ((x += mod - a.x) > mod)
            x -= mod;
        return *this;
    }

    MInt& operator *=(const MInt& a)
    {
        x *= a.x;
        x = x % mod;
        return *this;
    }

    MInt operator+(const MInt& a) const
    {
        MInt res(*this);
        return res += a;
    }

    MInt operator-(const MInt& a) const
    {
        MInt res(*this);
        return res -= a;
    }

    MInt operator*(const MInt& a) const
    {
        MInt res(*this);
        return res *= a;
    }

    MInt pow(long long t) const
    {
        if (t == 0)
            return 1;
        MInt a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    // only for prime mod
    MInt Inv() const
    {
        return pow(mod - 2);
    }
    // only for prime mod
    MInt& operator/=(const MInt& a)
    {
        return (*this) *= a.Inv();
    }
    MInt operator/(const MInt& a) const
    {
        MInt res(*this);
        return res /= a;
    }
};

template <class TMInt = MInt<>>
struct Comb
{
    std::vector<TMInt> fact, invfact, inv;
    long long mod;
    Comb(int n) : fact(n+1), invfact(n+1), inv(n+1)
    {
        fact[0] = fact[1] = 1;
        mod = fact[0].mod;
        invfact[0] = invfact[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < n; ++i)
        {
            fact[i] = fact[i - 1] * TMInt(i);
            long long invx = inv[mod % i].x * (mod - mod / i) % mod;
            inv[i] = TMInt(invx);
            invfact[i] = invfact[i - 1] * inv[i];
        }
    }

    TMInt operator()(int n, int k)
    {
        if (k < 0 || n < k)
            return 0;
        return fact[n] * invfact[k] * invfact[n - k];
    }
};

using modint = MInt<>;
using combination = Comb<modint>;


int main()
{
    long long n, k;
    std::cin >> n >> k;
    combination comb(1000000);
    modint ans(0);
    if (k >= n - 1)
    {
        ans += comb(2 * n - 1, n);
        std::cout << ans.x << std::endl;
        return 0;
    }
    ans = modint(1);
    for (long long i = 1; i <= k; ++i)
    {
        modint cnt = comb(n, i);
        cnt *= comb(n - 1, i);
        ans += cnt;
    }
    std::cout << ans.x << std::endl;
    return 0;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
int main()
{
  int a,b,c,d;
  sd(a);sd(b);sd(c);sd(d);
  if(ceil(c*1.0/b)<=ceil(a*1.0/d))
    cout<<"Yes";
else
{
        cout<<"No";
}

  nline;
  return 0;
}


Measured memory_bytes: 3760
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 * A Reward for a Carpenter
 */
public class Main {

	static Main main = new Main();

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int n = Integer.parseInt(line);
			int m = Integer.parseInt(br.readLine());
			Graph graph = main.new Graph(n);

			for (int i = 0; i < m; ++i) {
				graph.addEdges(br.readLine());
			}

			StringTokenizer st = new StringTokenizer(br.readLine(), ",");
			int s = Integer.parseInt(st.nextToken());// start
			int g = Integer.parseInt(st.nextToken());// goal
			int b = Integer.parseInt(st.nextToken());// budget
			int p = Integer.parseInt(st.nextToken());// pillar

			//
			int way, back;
			way = graph.dijkstra(s, g);
			back = graph.dijkstra(g, s);

			System.out.println(b - p - way - back);

		}
	}

	class Graph {

		int length;
		int[][] adjacency;

		Graph(int n) {
			length = n + 1;
			adjacency = new int[length][length];
			for (int i = 1; i < length; ++i) {
				for (int j = 1; j < length; ++j) {
					adjacency[i][j] = -1;
				}
			}
		}

		void addEdges(String info) {
			StringTokenizer st = new StringTokenizer(info, ",");
			int a, b, c, d;
			a = Integer.parseInt(st.nextToken());
			b = Integer.parseInt(st.nextToken());
			c = Integer.parseInt(st.nextToken());
			d = Integer.parseInt(st.nextToken());

			adjacency[a][b] = c;
			adjacency[b][a] = d;

		}

		int dijkstra(int start, int goal) {

			boolean[] checked = new boolean[length];
			int[] total = new int[length];
			int next;

			for (int i = 1; i < length; ++i) {
				total[i] = Integer.MAX_VALUE;
			}

			total[start] = 0;
			next = start;
			while (next != -1) {

				int s = next;
				checked[s] = true;

				for (int g = 1; g < length; ++g) {
					if (adjacency[s][g] != -1) {
						if (total[g] > total[s] + adjacency[s][g]) {
							total[g] = total[s] + adjacency[s][g];
						}
					}
				}

				int min = Integer.MAX_VALUE, idx = -1;
				for (int g = 1; g < length; ++g) {
					if (!checked[g] && min > total[g]) {
						min = total[g];
						idx = g;
					}
				}

				next = idx;
			}

			return total[goal];
		}
	}
}

Measured memory_bytes: 16872
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
 
using namespace std;

int p[9],q[9];
bool vis[9];
int f[9];


void solve(){
	int n; cin>>n;
	for(int i=0; i<n; i++) cin>>p[i];
	for(int i=0; i<n; i++) cin>>q[i];
	f[0] =1;
	for(int i=1; i<9; i++){
		f[i] = i*f[i-1];
	}
		
	ll rp=0,rq=0;
	for(int i=0; i<n; i++){
		int x=0;
		for(int j=1; j<p[i]; j++){
			if(vis[j]) x++;
		}
		rp += f[n-i-1]*(p[i]-1-x);
		vis[p[i]] = 1;
	}
	memset(vis,0,sizeof(vis));
	for(int i=0; i<n; i++){
		int x =0;
		for(int j=1; j<q[i]; j++){
			if(vis[j]) x++;
		}
		rq += f[n-i-1]*(q[i]-1-x);
		vis[q[i]] = 1;
	}
	cout<<abs(rp-rq);

}


int main()
{ 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//cout<<fixed<<setprecision(12);
	
	int t =1; 
	//cin>>t;

	for(int i=1; i<=t; i++){
		solve();
		cout<<"\n";
	}
	return 0;

}




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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007 //998244353
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll binpow(ll a,ll b){	if(a==0) return 0; if(b==0) return 1;ll ans=1;while(b>0){if(b&1) ans=ans*a; a=a*a; b=b>>1;}	return ans;}
template <typename T> 
T Min(T a,T b){ return a<b?a:b; }
template <typename T>
T Max(T a,T b){ return a>b?a:b; }

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;
	
	//ll n;cin>>n; vl a(n); repi(i,n) cin>>a[i];
	int a,b;
	cin>>a>>b;
	if(((b&1)==0 )&& (b>=2*a)&&(b<=4*a)) cout<<"Yes\n"; else cout<<"No\n";
	
	/*
	int test1;cin>>test1;while(test1--){ 
		
	 }
	 //*/
return 0;
}



Measured memory_bytes: 3608
using System;


    public static class Program
    {
    static void Main()
    {

        var data1 = Console.ReadLine().Split(' ');
        var a = int.Parse(data1[0]);
        var b = int.Parse(data1[1]);
        var c = int.Parse(data1[2]);
        
        var sum = 0;
        var d = 0;

        while (sum < c)
        {
            sum += a;
            d++;
            if (d % 7 == 0)
            {
                sum += b;
            }
           
        }

        Console.WriteLine(d);
        


    }
    }


Measured memory_bytes: 17916
#include<bits/stdc++.h>
#define int long long

using namespace std;

int n, arr[199998] = {}, sum[199998] = {}, ss = 0;

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

    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> arr[i], ss += arr[i];
    for (int i = n; i < 2 * n; i++)
        arr[i] = arr[i - n];
    for (int i = 0; i < 2 * n; i++)
    {
        if (i < 2)
            sum[i] = arr[i];
        else if (i < n - 1)
            sum[i] = sum[i - 2] + arr[i];
        else
            sum[i] = sum[i - 2] - arr[i - n + 1] + arr[i];
        //cerr << sum[i] << ' ';
    }
    //cerr << '\n';

    for (int i = 0; i < n; i++)
        cout << ss - sum[i + n - 2] * 2 << " \n"[i == n - 1];

    return 0;
}


Measured memory_bytes: 4480
n = int( input() );
a = input().split(" ");
flag = [0]*8;
count_pro = 0;
for i in range(n) :
	if int(a[i]) < 3200 :
		flag[int(int(a[i])/400)] = 1;
	else :
		count_pro = count_pro + 1;
mi = 0;
mx = 0;
if sum(flag) == 0 :
	mi = 1;
else :
	mi = sum(flag);

#if count_pro > 8 - sum(flag) :
#	mx = 8;
#else :
mx = sum(flag)+count_pro;

print(mi,mx)

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

// types
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<pll> vpl;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll n;
  cin >> n;
  string s;
  cin >> s;

  vll b(n+1),w(n+1);
  REP(i, n){
    if(s[i]=='.')
      w[i+1] = w[i]+1;
    else
      w[i+1] = w[i];

    if(s[i]=='#')
      b[i+1] = b[i]+1;
    else
      b[i+1] = b[i];
  }

  ll ans = INF;
  REP(i, n+1)
    ans = min(ans, b[i]-b[0]+w[n]-w[i]);
  cout << ans << endl;
}



Measured memory_bytes: 3732
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
ll d,ans;
ll power_ten[28];
int a[28];

ll read()
{
    ll x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x*f;
}

void calc(int L)
{
    //for (int i=1;i<=L/2;i++) printf("%d ",a[i]);puts("");
    ll tmp=L&1?10:1;
    if (a[1]>=0) tmp=tmp*(9-a[1]);
    else tmp=tmp*(10+a[1]);
    for (int i=2;i<=L/2;i++) tmp=tmp*(10-abs(a[i]));
    ans+=tmp;
}

void dfs(int x,ll rest,int L)
{
    if (x>L/2)
	{
	    if (!rest) calc(L);
	    return;
	}
    int i;
    for (i=-9;i<9&&(power_ten[L-x]-power_ten[x-1])*i<=rest;i++);
    a[x]=i;
    dfs(x+1,rest-(power_ten[L-x]-power_ten[x-1])*i,L);
    for (;i>-9&&(power_ten[L-x]-power_ten[x-1])*i>=rest;i--)
	{
	    a[x]=i-1;
	    dfs(x+1,rest-(power_ten[L-x]-power_ten[x-1])*(i-1),L);
	}
}
		    
int main()
{
    d=read();
    power_ten[0]=1;
    for (int i=1;i<=18;i++) power_ten[i]=power_ten[i-1]*10;
    for (int i=1;i<=18;i++) dfs(1,d,i);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque, Counter
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
from decimal import *
INF = 10 ** 20

def main():
    a,b,c = getList()
    k = max([a,b,c])
    getcontext().prec = 20  # デフォルト28桁のところを20桁にする
    a = Decimal(a).sqrt()
    b = Decimal(b).sqrt()
    c = Decimal(c).sqrt()
    # if math.sqrt(a/k) + math.sqrt(b/k)  < math.sqrt(c/k):
    if a + b < c:
        print("Yes")
    else:
        print("No")

    # print(math.sqrt(2000000000))
if __name__ == "__main__":
    main()

Measured memory_bytes: 59504
# gcdは最大公約数
from fractions import gcd
# lcmは最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

def main():
    from sys import stdin, setrecursionlimit
    setrecursionlimit(10**6)
    r = stdin.readline()[:-1]
    #n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]

    a = int(r)
    print(lcm(2,a))
if __name__ == '__main__':
    main()



Measured memory_bytes: 68588
#include <bits/stdc++.h>
using namespace std;
char fnc(char ch){
  if(ch == 'A') return 'T';
  else if(ch == 'T') return 'A';
  if(ch == 'C') return 'G';
  return 'C';
}
int main(){
  char ch;
  cin >> ch;
  cout << fnc(ch) << endl;
  return 0;
}


Measured memory_bytes: 256
s = int(input())
anslist = {s}
m = 1
for i in range(100000):
    m += 1
    if s % 2 == 0:
        s = s // 2
    else:
        s = 3 * s + 1
    if s in anslist:
        print(m)
        break
    else:
        anslist.add(s)

Measured memory_bytes: 3060
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define int long long

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int h,w; cin >> h >> w;
    vector<vector<int> > c(10,vector<int>(10));
    vector<vector<int> > a(h,vector<int>(w));

    for(int i = 0;i < 10;i ++){
        for(int j = 0;j < 10;j ++){
            cin >> c.at(i).at(j);
        }
    }
    for(int i = 0;i < h;i ++){
        for(int j = 0;j < w;j ++){
            cin >> a.at(i).at(j);
        }
    }

    int i,j,k;
    for(;;){
        bool hantei = true;
        for(i = 0;i < 10;i ++){
            for(j = 0;j < 10;j ++){
                for(k = 0;k < 10;k ++){
                    if(c.at(i).at(j) > c.at(i).at(k) + c.at(k).at(j)){
                        c.at(i).at(j) = c.at(i).at(k) + c.at(k).at(j);
                        hantei = false;
                    }
                }
            }
        }

        if(hantei == true){
            break;
        }
    }

    vector<int> mrk(10);
    for(int i = 0;i < 10;i ++){
        mrk.at(i) = c.at(i).at(1);
    }

    int ans = 0;
    for(i = 0;i < h;i ++){
        for(j = 0;j < w;j ++){
            if(a.at(i).at(j) != -1){
                ans += mrk.at(a.at(i).at(j));
            }
        }
    }

    cout << ans << endl;

}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int n, a, b, c;
vector<int> l;
int ret = 1e9;
int rec(int i, int A, int B, int C, int res){
	if(i == n){
		if(A != 0 && B != 0 && C != 0){
			return abs(a-A) + abs(b-B) + abs(c-C) + (res-3)*10;
		} else {
			return 1e9;
		}
	}

	// 4 通り
	chmin(ret, rec(i+1, A, B, C, res));
	chmin(ret, rec(i+1, A+l[i], B, C, res+1));
	chmin(ret, rec(i+1, A, B+l[i], C, res+1));
	chmin(ret, rec(i+1, A, B, C+l[i], res+1));

	return ret;
}
int main()
{
	cin >> n >> a >> b >> c;
	l.resize(n);
	rep(i,n) cin >> l[i];

	cout << rec(0,0,0,0,0) << endl;
}


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

int a[20];
bool b[40001];
int main() {
	int n; scanf("%d", &n);
	rep(i, n)scanf("%d", &a[i]);
	rep(i, 1 << n) {
		int sum = 0;
		rep(j, n) {
			if (i >> j & 1)sum += a[j];
		}
		b[sum] = true;
	}
	int q; scanf("%d", &q);
	rep(i, q) {
		int m; scanf("%d", &m);
		puts(b[m] ? "yes" : "no");
	}
}

Measured memory_bytes: 3164
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 262144
int main() {
	int n;
	cin >> n;
	map<int, int> geko;
	REP(i, n) {
		int tmp;
		cin >> tmp;
		geko[tmp]++;
	}
	int ans = 0;
	for (int i = 1;i <= 100000;++i) {
		ans = max(ans, geko[i - 1] + geko[i] + geko[i + 1]);
	}
	cout << ans << endl;
	return 0;
}

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

#define all(s) s.begin(), s.end()
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second
#define bit(x, y) ((x >> y) & 1)

unordered_map<long long, long long> mp[5];
int cnt = 0;
int a, b, c, d;

long long solve(long long u, int pre) {
    cnt++;
    if (mp[pre][u]) return mp[pre][u];
    long long foo = 2e18;
    if (log(2e18) > log(u) + log(d)) foo = u * d;
    if (pre == 0 || pre == 1) {
        foo = min(foo, solve(u + 1, pre + 1) + d);
        foo = min(foo, solve(u - 1, pre + 1) + d);
        if (u % 2 == 0) foo = min(foo, solve(u / 2, 0) + a);
        if (u % 3 == 0) foo = min(foo, solve(u / 3, 0) + b);
        if (u % 5 == 0) foo = min(foo, solve(u / 5, 0) + c);
    } else if (pre == 2) {
        foo = min(foo, solve(u + 1, pre + 1) + d);
        foo = min(foo, solve(u - 1, pre + 1) + d);
        if (u % 3 == 0) foo = min(foo, solve(u / 3, 0) + b);
        if (u % 5 == 0) foo = min(foo, solve(u / 5, 0) + c);
    } else if (pre == 3) {
        foo = min(foo, solve(u + 1, pre + 1) + d);
        foo = min(foo, solve(u - 1, pre + 1) + d);
        if (u % 5 == 0) foo = min(foo, solve(u / 5, 0) + c);
    } else if (pre == 4) {
        if (u % 5 == 0) foo = min(foo, solve(u / 5, 0) + c);
    }
    return mp[pre][u] = foo;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0); 
    cout.tie(0);
    int ntest;
    cin >> ntest;
    while (ntest--) {
        long long u;
        cin >> u;
        cin >> a >> b >> c >> d;
        for (int i = 0; i < 5; i++) {
            mp[i].clear();
            mp[i][1] = d;
        }
        cout << solve(u, 0) << endl;
    } 
    return 0;
}

Measured memory_bytes: 11144
#include <bits/stdc++.h>
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int DX[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int DY[] = {-1, 0, 1, -1, 1, -1, 0, 1};
const int N = 55;
string grid[N], ans[N];
int n, m;

int main() {
    ios::sync_with_stdio(false);
    cout.precision(10);
    cin >> n >> m;
    grid[0] = string(m + 2, ' ');
    grid[n + 1] = grid[0];
    for(int i = 1; i <= n; i++) {
        string s;
        cin >> s;
        grid[i] = ' ' + s + ' ';
    }
    for(int i = 1; i <= n; i++) {
        string s;
        for(int j = 1; j <= m; j++) {
            if(grid[i][j] == '#') {
                s += '#';
            } else {
                char cnt = '0';
                for(int d = 0; d < 8; d++) {
                    int ii = i + DX[d];
                    int jj = j + DY[d];
                    if(grid[ii][jj] == '#') {
                        cnt++;
                    }
                }
                s += cnt;
            }
        }
        cout << s << endl;
    }
    return 0;
}

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

void solve(long long N, long long M, std::vector<long long> X){
    ll ans = 0;
    std::vector<ll> dX;
    std::sort(X.begin(), X.end());
    //for(auto i: X) cout << i << " ";
    //cout << endl;
    if(N >= M) ans = 0;
    else{
        for(ll i = 1; i < M; ++i) dX.push_back(abs(X[i] - X[i-1]));
        //for(auto i : dX) cout << i << " ";
        //cout << endl;
        std::sort(dX.begin(), dX.end());
        ans = accumulate(dX.begin(), dX.begin() + M - N, 0);
        //for(auto i : dX) cout << i << " ";
        //cout << endl;
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> X(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&X[i]);
    }
    solve(N, M, std::move(X));
    return 0;
}


Measured memory_bytes: 2168
n,m = map(int,input().split())
import heapq
from collections import defaultdict
dic = defaultdict(list)
l = []
heapq.heapify(l)
for i in range(n):
    a,b=map(int,input().split())
    b = -b
    dic[a].append(b)
s = 0
t = [0]
for i in range(m):
    for i in dic[i+1]:
        heapq.heappush(l,i)
    if len(l) ==0 : M = 0
    else:
        # print(l)
        M = heapq.heappop(l)
        s += -M
print(s)

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

#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)


int main(){
  int n;
  cin >> n;
  vector<int> x(n),y(n);
  rep(i,n){
    cin >> x[i];
    y[i] = x[i];
  }
  sort(all(y));

  rep(i,n){
    if(x[i]<=y[(n-1)/2]){
      cout << y[(n+1)/2] << endl;
    }else{
      cout << y[(n-1)/2] << endl;
    }
  }
}

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

long long N, K, A[100009], B[100009], L[100009], R[100009], maxn;

int main() {
	cin >> N >> K;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		B[i] = B[i - 1] + A[i];
	}
	for (int i = 1; i <= N; i++) { L[i] = L[i - 1]; if (A[i] >= 0) L[i] += A[i]; }
	for (int i = N; i >= 1; i--) { R[i] = R[i + 1]; if (A[i] >= 0) R[i] += A[i]; }
	for (int i = 1; i <= N - K + 1; i++) {
		int cl = i, cr = i + K - 1;
		long long v1 = L[cl - 1];
		long long v2 = R[cr + 1];
		long long v3 = B[cr] - B[cl - 1]; v3 = max(v3, 0LL);
		maxn = max(maxn, v1 + v2 + v3);
	}
	cout << maxn << endl;
	return 0;
}

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

#define LL long long
#define Dl double
#define Pb push_back
#define Po pop_back
#define Mp make_pair
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

typedef vector<LL> Vl;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef vector<Pll> Vpl;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
#define X first
#define Y second
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

int main()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

    LL n, k;
    cin >> n >> k;

    LL a[60];
    for(LL i = 0; i < n; i++)
        cin >> a[i];

    sort(a, a + n);

    LL ans = 0;
    for(LL i = n - 1; i >= 0; i--)
        if(k)
            ans += a[i], k--;

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



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{   
    int x, n;
    cin >> x >> n;
    set<int> s;
    rep(i, n) {
        int a;
        cin >> a;
        s.insert(a);
    }
    int mi = 114514;
    int ans = 114514;
    rep(i, 102) {
        if(s.find(i) != s.end()) continue;
        if(mi > abs(x-i)) {
            mi = abs(x-i);
            ans = i;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3556
#include<stdio.h>
#include<string.h>
char str1[100],str2[100],temp[100];
int main()
{
    int i,j=0,t;
    scanf("%s[^\n]",str1);
    scanf("%s[^\n]",str2);
    i=strlen(str1);
    t=i-1;
    if(strlen(str1)!=strlen(str2))
    {
        printf("NO\n");
    }
    else
    {
        while(str1[j]!='\0')
        {
            temp[j]=str1[t];
            j++;
            t--;
        }
        t=0;
        i=0;
        while(temp[i]!='\0')
        {
            if(temp[i]==str2[i])
            {
                t++;
            }
            i++;
        }
        if(strlen(str2)==t)
        {
            printf("YES\n");
        }
        else if(strlen(str2)!=t)
        {
            printf("NO\n");
        }
    }
    return 0;
}

Measured memory_bytes: 128
import itertools

def main():
    n, m = map(int, input().split())
    num_list = []
    for i in range(m):
        num_list.append(list(map(int,input().split())))

    p_list = list(map(int, input().split()))

    ans = 0

    for i in itertools.product([0,1], repeat=n):
        check = [0] * m
        for j in range(m):
            tmp = 0
            check[j] = True
            for n in range(1, num_list[j][0] + 1):
                if i[num_list[j][n] - 1] == 1:
                    tmp += 1
            if tmp % 2 != p_list[j] % 2:
                check[j] = False
        if all(check):
            ans += 1

    print(ans)

if __name__ == '__main__':
    main()

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

using namespace std;

char A[101];
int main()
{
    int cnt = 0;
    scanf("%s",&A);
    int len=  strlen(A);
    for(int i=0;i<len;i++)
    {
        if(A[i]=='+')cnt++;
        else cnt--;
    }

    printf("%d",cnt);
    return 0;
}


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

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);ios::sync_with_stdio(false);
  int n, q;

  cin >> n >> q;

  vector<vector<int>> to(n);
  vector<ll> ans(n);

  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    --a;--b;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  rep(i, q) {
    int p, x;
    cin >> p >> x;
    --p;
    ans[p] += x;
  }

  auto dfs = [&](auto dfs, int v, int p) -> void {
    for(int u : to[v]) if(u != p) {
      ans[u] += ans[v];
      dfs(dfs, u, v);
    }
  };

  dfs(dfs, 0, -1);

  rep(i, n) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 21888
#!/usr/bin/env python3
import sys

MOD = 2  # type: int


def solve(N: int, P: int, A: "List[int]"):
    if not sum([e%2 for e in A]):
        if P:
            print(0)
        else:
            print(2**N)
    else:
      print(2**(N-1))
    return


# 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)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, P, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9104
#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

fn main() {
    input! {
        n: usize,
        a: [usize;n],
    }

    let mut sum = 0usize;
    let mut mx = 0;
    for e in a {
        if mx > e {
            sum += mx - e;
        } else {
            mx = e;
        }
    }
    println!("{}", sum);
}


Measured memory_bytes: 5596
from collections import deque
N, M = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
def is_bipartite(G):
    n = len(G)
    color = [-1]*n
    que = deque([0])
    color[0] = 0
    while que:
        v = que.pop()
        c = color[v]
        for nv in G[v]:
            if color[nv]<0:
                color[nv] = 1-c
                que.append(nv)
            elif color[nv] == c:
                return False
    return color
color = is_bipartite(G)
if color:
    a = color.count(0)
    b = N-a
    print(a*b-M)
else:
    print(N*(N-1)//2-M)
            
            

Measured memory_bytes: 22424
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,0,n){
        cin>>a[i];
        a[i]--;
    }
    
    int ans=0;
    rep(i,0,n){
        if(i==a[a[i]]) ans++;
    }
    cout<<ans/2<<endl;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#define hhh cerr<<"hhh"<<endl
#define see(x) cerr<<(#x)<<'='<<(x)<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
inline int read() {int x=0,f=1;char c=getchar();while(c!='-'&&(c<'0'||c>'9'))c=getchar();if(c=='-')f=-1,c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return f*x;}

const int maxn = 3e5+7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;



int main() {
    int N=read(), R=read();
    cout<<R+100*max(0,10-N)<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char** argv){
    int N;
    cin >> N;
    int a[N];
    for (int i=0; i<N; i++){
        int tmp;
        cin >> tmp;
        a[i] = tmp - 1;
    }
    int ans = -1;
    int on = 0;
    for (int i=0; i<N; i++){
        on = a[on];
        if (on == 1){
            ans = i + 1;
            break;
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define P pair<int, int>
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
const int MAX_HW = 35;


int H, W, S, v[MAX_HW][MAX_HW], E[MAX_HW][MAX_HW];
P dp[MAX_HW][MAX_HW][MAX_HW][MAX_HW];

int calc(int Y1, int X1, int Y2, int X2){
  int ret = E[Y2][X2];
  if(X1 - 1 >= 0) ret -= E[Y2][X1 - 1];
  if(Y1 - 1 >= 0) ret -= E[Y1 - 1][X2];
  if(X1 - 1 >= 0 && Y1 - 1 >= 0) ret += E[Y1 - 1][X1 - 1];
  return ret;
}

P dfs(int Y1, int X1, int Y2, int X2){
  if(dp[Y1][X1][Y2][X2] != P(-1, -1)) return dp[Y1][X1][Y2][X2];
  P ret = P(1, calc(Y1, X1, Y2, X2));
  FOR(y, Y1, Y2 + 1){
    int a = calc(Y1, X1, y, X2), b = calc(y + 1, X1, Y2, X2);
    if(E[H - 1][W - 1] - a > S || E[H - 1][W - 1] - b > S) continue;
    P aa = dfs(Y1, X1, y, X2), bb = dfs(y + 1, X1, Y2, X2);
    ret = max(ret, P(aa.first + bb.first, min(aa.second, bb.second)));
  }
  FOR(x, X1, X2 + 1){
    int a = calc(Y1, X1, Y2, x), b = calc(Y1, x + 1, Y2, X2);
    if(E[H - 1][W - 1] - a > S || E[H - 1][W - 1] - b > S) continue;
    P aa = dfs(Y1, X1, Y2, x), bb = dfs(Y1, x + 1, Y2, X2);
    ret = max(ret, P(aa.first + bb.first, min(aa.second, bb.second)));
  }
  return dp[Y1][X1][Y2][X2] = ret;
}

int main() {
  while(cin >>H >>W >>S && H){
    REP(i, H) REP(j, W) cin >>v[i][j];
    memset(E, 0, sizeof(E));
    E[0][0] = v[0][0];
    FOR(i, 1, H) E[i][0] = E[i - 1][0] + v[i][0];
    FOR(i, 1, W) E[0][i] = E[0][i - 1] + v[0][i];
    FOR(y, 1, H)
      FOR(x, 1, W)
      E[y][x] = v[y][x] + E[y - 1][x] + E[y][x - 1] - E[y - 1][x - 1];
    REP(i, MAX_HW) REP(j, MAX_HW) REP(k, MAX_HW) REP(l, MAX_HW) dp[i][j][k][l] = P(-1, -1);
    P ans = dfs(0, 0, H - 1, W - 1);
    cout <<ans.first <<" " <<(S - E[H - 1][W - 1] + ans.second) <<endl;
  }
  return 0;
}

Measured memory_bytes: 12904
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
typedef long long ll;


using namespace std;

bool isInnocent(int pattern, int ind){
    if((pattern >> ind) & 0x01 > 0){
        return true;
    }else{
        return false;
    }
}

int main(){
    int N;
    cin >> N;
    vector<vector<pair<int, int>> > vals(N, vector<pair<int,int>> ());
    for(int i=0;i<N;i++){
        int A;
        cin >> A;
        for(int k=0;k<A;k++){
            int x,y;
            cin >> x >> y;
            vals[i].push_back(make_pair(x, y));
        }
    }
    int cntMax = 0;
    for(int pattern=0;pattern<pow(2,N) ;pattern++){
        int cnt=0;
        bool consistent = true;
        for(int i=0;i<N;i++){
            if(!isInnocent(pattern, i)){continue;}
            auto ps = vals[i];
            for(auto p:ps){
                if(
                    (isInnocent(pattern, p.first-1) && (p.second == 0)) || 
                    (!isInnocent(pattern, p.first-1) && (p.second == 1))){
                    consistent = false;
                    break;
                }
            }
            cnt++;
            if(!consistent){
                break;
            }
        }
        if(consistent){
            cntMax = max(cntMax, cnt);
        }
    }
    cout << cntMax << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
 
using namespace std;
 
int main(){
    long long a, b, x;
    cin >> a >> b >> x;
    if(a%x==0){
        a/=x;
    }
    else{
        a = a/x+1;
    }
    b/=x;
    // if(b<a || b==0){
    //     return 0;
    // }
    b = b-a+1;
    cout << b << endl;
}

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

int main(){
    string S;
    cin >> S;
    int N = S.size();
    vector<int> R(N+2,0),L(N+2,0);
    vector<int> ans(N+1,0);
    for(int i=1;i<=N;i++){
        if(S[i-1]=='R') L[i] = L[i-1]+1;
    }
    for(int i=N;i>=1;i--){
        if(S[i-1]=='L') R[i] = R[i+1]+1;
    }
    for(int i=1;i<N;i++){
        if(S[i-1]=='R' && S[i]=='L'){
            ans[i] = (L[i]+1)/2+R[i+1]/2;
            ans[i+1] = (R[i+1]+1)/2+L[i]/2;
        }
    }
    for(int i=1;i<=N;i++) cout << ans[i] << (i!=N? " ":"\n");
}

Measured memory_bytes: 1920
// WARNING: Add compile option "-std=c++11" for C++11 compile.

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

// Macro
#define REP(i, N) for(int i=0; i<(int)N; i++)
#define REPR(i, N) for(int i=(int)N-1; i>=0; i--)

// Type
using ll = long long;
template <typename T = int> using P = pair<T, T>;

// Constants
const ll MOD = 1000000007;

/**
  型に合わせたINFを返す
  int: 214,748,364 (2.14 * 1e8)
  ll : 922,337,203,685,477,580 (9.22 * 1e17)
*/
template <typename T = int>
T getINF() {
  // NOTE: INF同士を足してもオーバーフロー起こさないように、10で割っている
  return numeric_limits<T>::max() / 10;
}

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

int main() {
  int r, D, x;
  cin >> r >> D >> x;

  for(int i = 0; i < 10; i++) {
    x = (r * x) - D;
    cout << x << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int n;
	ll a[100010];
	scanf("%d",&n);
	rep(i,n){
		scanf("%lld",&a[i]);
	}
	
	ll cnt = 0;
	vector<ll> vec;
	rep(i,n){
		if(a[i] == 0)continue;
		if(a[i]%2 == 0){
			vec.pb(i);
			vec.pb(i);
			a[i] -= 2;
		}
		else{
			vec.pb(i);
			a[i] --;
		}
		cnt += a[i]/2;
	}
	
	for(int i = 0 ; i+1 < vec.size() ;){
		if(vec[i+1] <= vec[i]+1){
			cnt ++;
			i += 2;
		}
		else i ++;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3188
import           Control.Monad
import           Data.List

main :: IO ()
main = do
  [n, m] <- map read . words <$> getLine
  as <- replicateM n $ tail . map read . words <$> getLine :: IO [[Int]]
  print
    $ length . filter (== True) . map and . transpose
    $ map (\a -> [x `elem` a | x <- [1 .. m]]) as

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

//
int main(){
    int n; cin >> n;
    vector<int> a(n); rep(i,n) cin >> a[i];
    int asum = 0; rep(i,n) asum += a[i];
    
    //dp[i][r];
    //最初からi番目まで塗り分けてRの値がrである塗り分け方の総数
    vector<vector<ll>> dp(n,vector<ll>(asum+1,0));
    vector<vector<ll>> dp2(n,vector<ll>(asum+1,0));
    dp[0][0] = 2;
    dp[0][a[0]] = 1;
    dp2[0][0] = 1;
    dp2[0][a[0]] = 1;
    //ここも合ってるっぽい
    rep(i,n-1){
        rep(j,asum+1){
            if(j >= a[i+1]){
                dp[i+1][j] = (2*dp[i][j] + dp[i][j-a[i+1]]) % mod;
                dp2[i+1][j] = (dp2[i][j] + dp2[i][j-a[i+1]]) % mod;
            }else{
                dp[i+1][j] = 2*dp[i][j] % mod;
                dp2[i+1][j] = dp2[i][j] % mod;
            }
        }
    }
    
    ll dp1 = 0;
    for(int i = (asum + 1)/2; i <= asum; i++){
        dp1 += dp[n-1][i];
        dp1 = dp1 % mod;
    }
    dp1 = (3*dp1)%mod; //ここは合ってるらしい

    ll sanno_n_jou = 1; rep(i,n){
        sanno_n_jou *= 3;
        sanno_n_jou = sanno_n_jou % mod;
    }if(asum % 2 == 0){
        cout << (sanno_n_jou - dp1 + 3*dp2[n-1][asum/2] + mod) % mod << endl;
    }else{
        cout << (sanno_n_jou - dp1 + mod) % mod << endl;
    }
}

Measured memory_bytes: 422336
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>

using namespace std;
typedef long long llong;
const int MOD=1000000007;

int main(int argc, char**argv){
    string s;
    cin >> s;

    s[3] = '8';
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
t = []
x = []
y = []
t_b = 0
x_b = 0
y_b = 0
flag = 0
for i in range(n):
    t_a,x_a,y_a = map(int,input().split())
    t_d = t_a - t_b
    if x_a - x_b + y_a - y_b == t_a - t_b:
        t_b = t_a
        x_b = x_a
        y_b = y_a
    elif (t_a - t_b) - (x_a - x_b + y_a - y_b) > 0 and ((t_a - t_b) - (x_a - x_b + y_a - y_b))%2 == 0:
        t_b = t_a
        x_b = x_a
        y_b = y_a
    else:
        flag = 1
        break
if flag == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define MAX 100000000000

int main() {
    ll A,B,Q; scanf("%lld%lld%lld",&A,&B,&Q);
    ll s[A+2];
    ll t[B+2];
    ll x[Q];
    rep(i,A) scanf("%lld",&s[i]);
    rep(i,B) scanf("%lld",&t[i]);
    rep(i,Q) scanf("%lld",&x[i]);
    s[A] = -MAX; s[A+1] = MAX;
    t[B] = -MAX; t[B+1] = MAX;
    sort(s,s+A+2);
    sort(t,t+B+2);
    rep(i,Q){
        ll ans = MAX;
        ll rights; ll lefts;
        ll rightt; ll leftt;
        ll right = A+2;
        ll left = 0;
        while(left + 1 < right){
            ll mid = (left+right)/2;
            if (x[i] >= s[mid]) left = mid;
            else right = mid;
        }
        rights = right;
        lefts = left;
        right = B+2;
        left = 0;
        while(left + 1 < right){
            ll mid = (left+right)/2;
            if (x[i] >= t[mid]) left = mid;
            else right = mid;
        }
        rightt = right;
        leftt = left;
        ans = min(ans,abs(s[rights]-x[i])+abs(t[rightt]-s[rights]));
        ans = min(ans,abs(s[rights]-x[i])+abs(t[leftt]-s[rights]));
        ans = min(ans,abs(s[lefts]-x[i])+abs(t[rightt]-s[lefts]));
        ans = min(ans,abs(s[lefts]-x[i])+abs(t[leftt]-s[lefts]));
        ans = min(ans,abs(t[rightt]-x[i])+abs(s[rights]-t[rightt]));
        ans = min(ans,abs(t[rightt]-x[i])+abs(s[lefts]-t[rightt]));
        ans = min(ans,abs(t[leftt]-x[i])+abs(s[rights]-t[leftt]));
        ans = min(ans,abs(t[leftt]-x[i])+abs(s[lefts]-t[leftt]));
        cout << ans << endl;
    }
    return 0;
}


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

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

    // 105 * n  <   < 100 * (n+1) is NG range.
    int nMax = x / 100;
    

    bool isPossible = true;
    for (int n = 0; n < nMax+1; n++)
    {
        if ((105 * n < x) && (100 * (n+1) > x))
        {
            isPossible = false;
            break;
        }
    }

    if (isPossible)
    {
        cout << "1" << endl;
    }
    else
    {
        cout << "0" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
	int d;
	for(cin>>d;d>0;d--){
		double x1,x2,x3;
		double y1,y2,y3;
		cin>>x1>>y1>>x2>>y2>>x3>>y3;

		double A1=2*(x2-x1);
		double B1=2*(y2-y1);
		double C1=(x1*x1)-(x2*x2)+(y1*y1)-(y2*y2);
		double A2=2*(x3-x1);
		double B2=2*(y3-y1);
		double C2=(x1*x1)-(x3*x3)+(y1*y1)-(y3*y3);
		double a=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
		double b=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
		double c=sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
		double t1=(A1*B2-A2*B1);
		double t2=(B1*C2-B2*C1);
		double t3=(C1*A2-C2*A1);
		printf("%.3lf %.3lf %.3lf",
				t2/t1,t3/t1,(a*b*c)/sqrt((a+b+c)*(-a+b+c)*(a-b+c)*(a+b-c)));
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
def main():
  k, x = map(int, input().split())
  out1 = x - (k - 1)
  out2 = x + k
  out = []
  for i in range(out1, out2):
    out.append(str(i))
  print(" ".join(out))

if __name__ == '__main__':
  main()

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

int main(void){
    long long int x, a, r, i, j, min;
    scanf("%lld %lld", &x, &a);
    if(x<a) printf("0");
    else printf("10");
    
}

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

#define INF (1<<30)

int main(){
	int n;	cin>>n;
	vector<int> a(n);	for(int i=0;i<n;i++)cin>>a[i];
	sort(a.begin(), a.end());

	int mid=(1+a[n-1])/2;

	int b=INF;
	for(int i=0;i<n;i++){
		if(abs(mid-b)>abs(mid-a[i])){
			b=a[i];
		}
	}

	printf("%d %d\n",a[n-1],b);

	return 0;
}


Measured memory_bytes: 640
#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 H,W;
int A[500][500];
vector<vector<int>> R;

void add(int y1,int x1,int y2,int x2) {
	A[y1][x1]--;
	A[y2][x2]++;
	R.push_back({y1+1,x1+1,y2+1,x2+1});
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W;
	FOR(y,H) FOR(x,W) cin>>A[y][x];
	FOR(y,H) FOR(x,W) if(A[y][x]%2) {
		if(x<W-1) add(y,x,y,x+1);
		else if(y<H-1) add(y,x,y+1,x);
	}
	cout<<R.size()<<endl;
	FORR(v,R) cout<<v[0]<<" "<<v[1]<<" "<<v[2]<<" "<<v[3]<<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);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 9904
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<iostream>
#include<map>
#include<string>
#define INF 10009310000
using namespace std;
map<char,int> ele;
string x,y;
int n;
long long lucas[88];
int main(){
    scanf("%d",&n);
    lucas[0]=2;
    lucas[1]=1;
    for(int i=2;i<=n;i++)
        lucas[i]=lucas[i-1]+lucas[i-2];
    printf("%lld",lucas[n]);
}

Measured memory_bytes: 3792