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

// Segment Tree for Arbitrary Semigroup

/*
struct Element{
    // Value
    bool isIdentity;
};

Element Identity = {// , true};

Element Operation(const Element &A, const Element &B){
    if(A.isIdentity) return B;
    if(B.isIdentity) return A;
    // Operation
}
 */

// Range Minimum Query
struct Element{
    int value;
    bool isIdentity;
};

Element Identity = {0, true};

Element Operation(const Element &A, const Element &B){
    if(A.isIdentity) return B;
    if(B.isIdentity) return A;
    return {min(A.value, B.value)};
}


struct SegmentTree{
    int size; // number of leaves: power of two
    vector<Element> cbt; // complete binary tree

    // Initialize with Identity Element
    SegmentTree(int N){
        size = 1;
        while (size < N) size *= 2;
        cbt.resize(size * 2 - 1, Identity);
    }

    // Initial Input
    void initial_set(int i, const Element &A) {
        i += size - 1;
        cbt[i] = A;
    }

    void initial_build() {
        for (int i = size - 2; i >= 0; --i) {
            cbt[i] = Operation(cbt[i*2+1], cbt[i*2+2]);
        }
    }


    // 葉のi番目(0-indexed)をxに更新
    void update(int i, const Element &A){
        i += size - 1;
        cbt[i] = A;
        while (i > 0){
            i = (i - 1) / 2;
            cbt[i] = Operation(cbt[i*2+1], cbt[i*2+2]);
        }
    }

    // 区間[a, b) (0-indexed)の最小値を返す関数
    // 外から呼ぶときは query(a, b, 0, 0, tree.size)
    Element query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return Identity;
        if(a <= l && r <= b) return cbt[k];
        Element vl = query(a, b, k*2+1, l, (l+r)/2);
        Element vr = query(a, b, k*2+2, (l+r)/2, r);
        return Operation(vl, vr);
    }
};

#define MAX_M 100005

int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> jobs(N);
    for (int i = 0; i < N; ++i) {
        int A, B;
        cin >> A >> B;
        jobs[i] = make_pair(B, A); // 順番に注意
    }
    sort(jobs.begin(), jobs.end(), greater<pair<int, int>>());

    // セグ木でスケジュール管理しながら報酬で貪欲
    // 貪欲で棄却される仕事は完全下位互換(または同等)でそれを入れても報酬が上がらないことが保証される
    SegmentTree tree(MAX_M);
    // 何日後までに報酬を受け取ればいいか
    for (int i = 0; i < M; ++i) {
        tree.initial_set(i, {i+1, false});
    }
    tree.initial_build();
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int A = jobs[i].second;
        int B = jobs[i].first;
        auto day = tree.query(A-1, tree.size, 0, 0, tree.size);
        if(day.isIdentity) continue;
        ans += B;
        tree.update(day.value-1, Identity);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3072
my ($n, $m) = split / /, <>;
chomp $m;

my (@na, @ma);
for (my $i = 0; $i < $n; $i++) {
  my @lines = split //, <>;
  chomp $lines[$#lines];
  push @na, \@lines;
}
for (my $i = 0; $i < $m; $i++) {
  my @lines = split //, <>;
  chomp $lines[$#lines];
  push @ma, \@lines;
}

for (my $i = 0; $i < $n - $m + 1; $i++) {
  NEXT: for (my $j = 0; $j < $n - $m + 1; $j++) {
    for (my $k = 0; $k < $m; $k++) {
      for (my $l = 0; $l < $m; $l++) {
        if ($na[$i + $k][$j + $l] ne $ma[$k][$l]) {
          next NEXT;
        }
      }
    }
    print "Yes\n";
    exit;
  }
}
print "No\n";


Measured memory_bytes: 896
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

long long H,W;
char A[1010][1010];
char str[1010];
int X[1010][1010];
queue <int> qH;
queue <int> qW;

int main(){
  cin >> H >> W;

  for (int i=0;i<H;i++){
    cin >> str;
    for (int j=0;j<W;j++){
      A[i][j]=str[j];
      if (A[i][j]=='.'){
        X[i][j]=-1;
      }else{
        X[i][j]=0;
        qH.push(i);
        qW.push(j);
      }
    }
  }
  int step=0;
  while (!qH.empty()) {
    int h=qH.front();
    int w=qW.front();
    qH.pop();
    qW.pop();
    if (h>0 && X[h-1][w]==-1){
      qH.push(h-1);
      qW.push(w);
      X[h-1][w]=X[h][w]+1;
    }
    if (h<H-1 && X[h+1][w]==-1){
      qH.push(h+1);
      qW.push(w);
      X[h+1][w]=X[h][w]+1;
    }
    if (w>0 && X[h][w-1]==-1){
      qH.push(h);
      qW.push(w-1);
      X[h][w-1]=X[h][w]+1;
    }
    if (w<W-1 && X[h][w+1]==-1){
      qH.push(h);
      qW.push(w+1);
      X[h][w+1]=X[h][w]+1;
    }
    step=X[h][w];
  }
  cout <<step << endl;
  return 0;
}


Measured memory_bytes: 13056
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 8080
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD=1e9+7;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
double calc(int x){
	int sum=0;
	int y=x;
	while(x!=0){
		sum+=x%10;
		x/=10;
	}
	double ret=(double)y/(double)sum;
	return ret;
}
int main(){
	int N,K;
	cin>>N>>K;
	int memo;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		if(a==1)memo=i;
	}
	int ans=(N-1+K-2)/(K-1);
	cout<<ans<<endl;
}

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

int main() {
int H,W;
cin>>H>>W;
char T[H][W];
for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
        cin>>T[i][j];
    }
    }
for(int i=0;i<H;i++){
    for(int x=0;x<2;x++){
    for(int j=0;j<W;j++){
        cout<<T[i][j];
    }
    cout<<endl;
    }
    }

	return 0;
}


Measured memory_bytes: 256
from collections import Counter

def get_k(i, j):
    return 2*j - i

if __name__ == '__main__':
    N = int(input())
    S = input()
    C = Counter(S) 
    eq_cnt = 0
    cnt = C['R'] * C['G'] * C['B']
    for i in range(N):
        for j in range(i+1, N):
            k = get_k(i, j)
            if k >= N: continue
            if (S[i] != S[j] and S[i] != S[k] and S[j] != S[k]):
                eq_cnt += 1
    print(cnt - eq_cnt)

Measured memory_bytes: 74216
n,a,b = map(int, input().split())
if (b-a)%2==0:
    ans = (b-a)//2
else:
    ans = min(n-a, b-1)
    ans = min(ans, min(a-1, n-b) + (b-a-1)//2 + 1)
    # ans = ((b-a)+2-1)//2 + 1
print(ans)


Measured memory_bytes: 2940
def bubbleSort(A, N):
    cnt = 0
    for _ in range(N):
        for j in range(N - 1, 0, -1):
            if A[j] < A[j - 1]:
                cnt += 1
                A[j], A[j - 1] = A[j - 1], A[j]
    print(*A)
    print(cnt)
N = int(input())
A = list(map(int, input().split()))
bubbleSort(A, N)


Measured memory_bytes: 5604
#!/usr/bin/env python
import sys
sys.setrecursionlimit(10**9)
from collections import deque
import heapq
from itertools import combinations
import bisect

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

ans=10**10
for i in range(1<<n):
    t=[0]*m
    kai=0
    for j in range(n):
        if i&(1<<j)!=0:
            for k in range(m):
                t[k]+=ca[j][k+1]
            kai+=ca[j][0]
    if min(t)>=x:
        ans=min(ans,kai)
if ans==10**10:
    print(-1)
else:
    print(ans)




Measured memory_bytes: 74580
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
   ll n;cin>>n;
   ll a[n];f(i,0,n)cin>>a[i];
   sort(a,a+n);
   ll mini=INT_MAX;
   f(j,a[0],a[n-1]+1){ll st=0;
   f(i,0,n){
    st+=(a[i]-j)*(a[i]-j);
   }
   mini=min(mini,st);
   }
   cout<<mini;
    return 0;  
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

ll pow_mod(ll a, ll n, ll MOD){
  ll m[60]; m[0]=a; // m[i] : a^(2^i)をMODで割った余り
  rep(i,59) m[i+1] = (m[i]*m[i])%MOD;

  ll retval = 1;
  bitset<60> s(n);
  rep(i,60) if (s.test(i)) (retval *= m[i]) %= MOD;

  return retval; 
}

int main(){
  int N; cin >> N;
  string s; cin >> s;
  int c[N]; rep(i,N) c[i] = s[i]-'0';
 
  int cnt = 0;
  rep(i,10) rep(j,10) rep(k,10){
    int idx_i = find(c,c+N,i) - c;
    int idx_j = find(c+idx_i+1,c+N,j) - c;
    int idx_k = find(c+idx_j+1,c+N,k) - c;
    if (idx_i<N && idx_j<N && idx_k<N) cnt++;
  }
  cout << cnt << endl;


  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 3780
package main

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

type Num struct {
	Num          int
	DiffDistance int
}

func main() {
	s := IOInitialize()
	N := Int(s)
	nums, sum := scanNums(s, N)
	for i := 0; i < N; i++ {
		fmt.Println(sum - nums[i+1].DiffDistance)
	}
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}

func scanNums(s *bufio.Scanner, len int) (nums []Num, sum int) {
	before1 := 0
	before2 := 0
	sum = 0
	for i := 0; i < len; i++ {
		num := Int(s)
		distance := abs(num - before1)
		sum += distance
		diffDistance := abs(num-before1) + abs(before1-before2) - abs(num-before2)
		nums = append(nums, Num{Num: num, DiffDistance: diffDistance})
		before2 = before1
		before1 = num
	}
	distance := abs(0 - before1)
	sum += distance
	diffDistance := abs(0-before1) + abs(before1-before2) - abs(0-before2)
	nums = append(nums, Num{Num: 0, DiffDistance: diffDistance})

	return
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

Measured memory_bytes: 8960
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;

const int MAX_N = 100005, MOD = 1000000007;
typedef long long i64;

int N, A[MAX_N], in[MAX_N], fa[MAX_N], in_temp[MAX_N];

int find(int x) {
  return fa[x] == x ? x : fa[x] = find(fa[x]);
}

vector<int> cop[MAX_N];
i64 ifac[MAX_N], fac[MAX_N], inv[MAX_N], bin[MAX_N];

i64 binom(int n, int m) {
  if (n < m) return 0;
  return fac[n] * ifac[m] % MOD * ifac[n - m] % MOD;
}

int check(vector<int> &vec) {
  bool flag = 0;
  for (int x : vec) {
    if (in[x] == 0) flag = 1;
    if (in[x] >= 3) return 0;
  }
  if (flag) return 1;
  return 2;
}

i64 work(vector<int> &vec) {
  static int que[MAX_N], cir[MAX_N], len[MAX_N];
  int l = 1, r = 0;
  
  for (int x : vec) 
    if (in_temp[x] == 0) que[++r] = x;
  while (l <= r) {
    int u = que[l++];
    in_temp[A[u]]--, len[A[u]] = len[u] + 1;
    if (in_temp[A[u]] == 0) que[++r] = A[u];
  }

  static int rt[MAX_N];
  
  for (int x : vec) {
    if (in_temp[x]) cir[x] = 1;
    if (in[x] == 2) rt[x] = 1;
    if (!cir[x] && in[x] == 2) return 0;
  }

  static int st[MAX_N];
  int top = 0;
  
  for (int x : vec) 
    if (cir[x]) {
      int u = x;
      do {
	st[top++] = u;
	u = A[u];
      } while (u != x);
      break;
    }

  i64 res = 1;
  for (int i = 0; i < top; ++i)
    if (rt[st[i]]) {
      int j = (i - 1 + top) % top, d = 0;
      while (!rt[st[j]]) {
	d++;
	j = (j - 1 + top) % top;
      }
      d++;
      if (d < len[st[i]]) res = 0;
      else if (d > len[st[i]]) res = res * 2 % MOD;
    }
  
  return res;
}

i64 fpm(i64 x, i64 y) {
  i64 res = 1;
  while (y) {
    if (y & 1) res = res * x % MOD;
    x = x * x % MOD;
    y >>= 1;
  }
  return res;
}

int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) fa[i] = i;
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &A[i]);
    in[A[i]]++;
    if (find(A[i]) != find(i)) fa[find(A[i])] = find(i);
  }

  memcpy(in_temp, in, sizeof in);
  
  static int id[MAX_N], tot, cnt[MAX_N];
  
  for (int i = 1; i <= N; ++i) {
    int x = find(i);
    if (!id[x]) id[x] = ++tot;
    cop[id[x]].push_back(i);
  }

  i64 res = 1;

  for (int i = 1; i <= tot; ++i) {
    int kind = check(cop[i]);
    if (kind == 0) res = 0;
    else if (kind == 1) res = res * work(cop[i]) % MOD;
    else cnt[cop[i].size()]++;
  }

  fac[0] = ifac[0] = inv[1] = bin[0] = 1;
  for (int i = 1; i <= N; ++i) fac[i] = fac[i - 1] * i % MOD;
  for (int i = 2; i <= N; ++i) inv[i] = -(MOD / i) * inv[MOD % i] % MOD;
  for (int i = 1; i <= N; ++i) ifac[i] = ifac[i - 1] * inv[i] % MOD;
  for (int i = 1; i <= N; ++i) bin[i] = bin[i - 1] * 2 % MOD;
  
  for (int i = 1; i <= N; ++i) {
    i64 now = 0;
    for (int j = 0; j <= cnt[i]; ++j) {
      int rest = cnt[i] - j;
      if (rest & 1) continue;
      i64 coef = binom(cnt[i], j) * ((i & 1) && i != 1 ? bin[j] : 1) % MOD;
      if (rest == 0) now = (now + coef) % MOD;
      else now = (now + coef * fac[rest] % MOD * fpm(inv[2], rest / 2) % MOD * ifac[rest / 2] % MOD * fpm(i, rest / 2) % MOD) % MOD;
    }
    res = res * now % MOD;
  }

  printf("%lld\n", (res + MOD) % MOD);
  
  return 0;
}


Measured memory_bytes: 11520
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    if((b-a)%2 == 0) cout << (b-a)/2 << "\n";
    else {
        cout << min({
           a + (b-a)/2,
           n-b+1 + (b-a)/2
        });
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

	while (true) {
		int h, w;
		cin >> h >> w;
		if (h == 0 && w == 0) break;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if ((i + j) % 2 == 0) cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <sstream>
#include <regex>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
//const int INF = 100100100;
const int INF = (1LL<<32);
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;

string divide[4] = { "dream","dreamer","erase","eraser" };

string s;
bool can = false;
bool dp[1000010];

signed main() {
	ios::sync_with_stdio(false);
	cin >> s;
	dp[0] = true;
	rep(i, s.size()) {
		if (!dp[i]) continue;
		rep(j, 4) {
			string d = divide[j];
			if (s.substr(i,d.size()) == d) {
				dp[i + d.size()] = true;
			}
		}
	}
	if (dp[s.size()]) cout << "YES\n";
	else cout << "NO\n";
	return 0;
}



Measured memory_bytes: 592
#include <stdio.h>
int n, a, p[7];
int main() {
	while (true) {
		scanf("%d", &n);
		if (!n) break;
		for (int i = 0; i < 7; i++) p[i] = 0;
		for (int i = 0; i < n; i++) scanf("%d", &a), p[a < 60 ? a / 10: 6]++;
		for (int i = 0; i < 7; i++) printf("%d\n", p[i]);
	}
	return 0;
}

Measured memory_bytes: 2572
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin>> n;
    long long count=0;
    for(long long i=1; i<(n+1);i++){
        long long x=n/i;
        count +=i*x*(x+1)/2;
    }
    cout << count << endl;
    
}


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

using namespace std;

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

	int n, x;
	cin >> n >> x;

	vector<long long> b(n);
	vector<long long> l(n);
	vector<long long> u(n);
	long long sum = 0;
	for(int i = 0; i < n; ++i) {
		cin >> b[i] >> l[i] >> u[i];
		sum += b[i] * l[i];
	}

	auto calc = [&] (int i) {
		return b[i] * l[i] + (x - b[i]) * u[i];
	};

	vector<int> id(n);
	iota(id.begin(), id.end(), 0);
	sort(id.begin(), id.end(), [&] (int i, int j) {
		return calc(i) > calc(j);
	});

	vector<long long> pre(n);
	pre[0] = calc(id[0]);
	for(int i = 0; i + 1 < n; ++i) {
		pre[i + 1] = pre[i] + calc(id[i + 1]);
	}

	long long ans = 1LL * n * x;

	for(int i = 0; i < n; ++i) {
		int j = id[i];
		int left = -1;
		int right = n;
		int cur = n;
		while(right - left > 1) {
			int mid = left + right >> 1;
			int p = mid - 1 + (mid >= i + 1);
			if((p >= 0 ? pre[p] : 0) + (mid - 1 < i ? calc(j) : 0) >= sum) {
				right = cur = mid;
			} else {
				left = mid;
			}
		}

		left = -1;
		right = x + 1;
		int pos = x;
		while(right - left > 1) {
			int mid = left + right >> 1;
			long long add = l[j] * min(1LL * mid, b[j]) + u[j] * max(0LL, mid - b[j]);
			int p = cur >= i + 1 ? cur : cur - 1;
			if(add + (p >= 0 ? pre[p] : 0) - (cur >= i + 1 ? calc(j) : 0) >= sum) {
				right = pos = mid;
			} else {
				left = mid;
			}
		}
		ans = min(ans, 1LL * cur * x + pos);
	}	

	cout << ans << '\n';

	return 0;
}


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

using namespace std;
int main(int argc, const char * argv[]) {
    long long int n, x, i, ans, num, sum;
    ans = 0;
    sum = 0;
    cin >> n >> x;
    long long int a[n];
    for(i = 0;i < n;i++){
        cin >> a[i];
        sum += a[i];
    }
    sort(a, a+n);
    num = x;
    if(sum < num)ans--;
    for(i = 0;i < n;i++){
        if(num - a[i] >= 0){
            num -= a[i];
            ans++;
        }else{
            break;
        }
    }
    printf("%lld\n", ans);
    
    return 0;
}

Measured memory_bytes: 256
H,W = map(int, input().split())
abc = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

for h in range(H):
    S = list(map(str, input().split()))
    if 'snuke' in S:
        ind = S.index('snuke')
        ans = abc[ind:ind + 1] + str(h+1)
        print(ans)
        break


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    ll n;cin>>n;
    ll a[n];
    ll sum=0;
    rep(i,0,n-1){
        cin>>a[i];
        sum^=a[i];
    }
    rep(i,0,n-1){
        cout<<(sum^a[i]);
        if(i==n-1){
            cout<<endl;
        }else{
            cout<<' ';
        }
    }
    
    return 0;
}



Measured memory_bytes: 5220
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

int dp[1 << 18][51];
int main() {
    int N; cin >> N;
    vector<int> A(N), B(N);
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<N; i++) cin >> B[i];

    fill(dp[0], dp[1 << N], INF);
    dp[0][0] = 0;
    for(int bit=0; bit<(1<<N); bit++) {
        for(int v=0; v<=50; v++) {
            if(dp[bit][v] == INF) continue;
            // fprintf(stderr, "dp[%d][%d] = %d\n", bit, v, dp[bit][v]);
            for(int i=0; i<N; i++) {
                if(bit >> i & 1) continue;
                // 前に行ったやつ + 元々前にいるやつ
                int c = __builtin_popcount(bit), b = c;

                // bit の補集合であって i 以前のもの
                // i bit 目を含めないようにする
                int rem = (((1 << N) - 1 - bit) & ((1 << i) - 1));
                c += __builtin_popcount(rem);
                // cerr << "rem = " << rem << endl;
                // cerr << "c = " << c << endl;
                
                // 現在の値 (元インデックスと偶奇違うなら反転)
                int val = (c - i) % 2 ? B[i] : A[i];
                
                // 現在のインデックスが c
                // 目標インデックスが b -> dist = c - b
                // 目標との偶奇が違うなら反転
                int dist = c - b;
                if(dist % 2) val ^= (A[i] ^ B[i]);
                
                if(v <= val) {
                    int nbit = bit | (1 << i);
                    chmin(dp[nbit][val], dp[bit][v] + dist);
                }
            }
        }
    }

    int ans = *min_element(dp[(1<<N)-1], dp[(1<<N)-1] + 51);
    cout << (ans == INF ? -1 : ans) << endl;
    return 0;
}


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

def main():
    n = int(input())
    p = list(map(int, input().split()))
    
    a = [(int(x)+1)*20000 for x in range(n)]
    b = [int(x)*20000 for x in range(n, 0, -1)]
    
    for i in range(n):
        v = p[i]-1
        a[v] += i+1
        b[v] += i+1
        
    print(*a)
    print(*b)
    
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 11508
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

bool judge(std::vector<std::pair<int, int>>& ps) {
    std::sort(ps.begin(), ps.end(),
              [](auto p, auto q) { return p.second > q.second; });
    int h = 0;
    for (auto p : ps) {
        if (h + p.second < 0) return false;
        h += p.first;
    }
    return true;
}

void solve() {
    int n;
    std::cin >> n;

    std::vector<std::pair<int, int>> pos, neg;
    int hsum = 0;
    while (n--) {
        std::string s;
        std::cin >> s;

        int h = 0, d = 0;
        for (char c : s) {
            h += (c == '(' ? 1 : -1);
            d = std::min(d, h);
        }
        hsum += h;

        if (h >= 0) {
            pos.emplace_back(h, d);
        } else {
            neg.emplace_back(-h, d - h);
        }
    }

    std::cout << (hsum == 0 && judge(pos) && judge(neg) ? "Yes" : "No") << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 11228
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) std::cerr<< #x <<": "<<x<<"\n"
#define debug2(x,y) std::cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<"\n"
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  vi a(n);
  rep (i, n) {
    scanf("%d", &a[i]);
  }
  vll accum(n+1, 0);
  rep (i, n) {
    accum[i+1] = accum[i] + a[i];
  }
  map<int, int> mp;
  rep (i, n+1) {
    int r = accum[i] % m;
    mp[r] += 1;
  }
  ll ans = 0;
  for (auto p : mp) {
    ll cnt = p.second;
    ans += cnt * (cnt - 1) / 2;
  }
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main(){
  string rm,str[2];
  cin>>str[0]>>str[1];
  int num[2];
  cin>>num[0]>>num[1];
  cin>>rm;
  if(rm==str[0]) num[0]--;
  else num[1]--;
  cout<<num[0]<<" "<<num[1]<<endl;
  return 0;
}

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

int main(){
  string s;
  cin>>s;
  int n = s.size();
  int p0 = 0;
  int p1 = 0;
  rep(i,n){
    if (i%2==0){
      if(s[i] == '1') p0++;
      else p1++;
    }
    if (i%2==1){
      if(s[i] == '0') p0++;
      else p1++;
    }
  }
  cout<<min(p0,p1)<<endl;
}


Measured memory_bytes: 512
#![allow(non_snake_case)]
use proconio::{input, fastout};
use proconio::marker::{Chars, Bytes, Usize1};

#[fastout]
fn main() {
    input!{
        s: String
    };
    let c = if s.contains("RRR") {3} else if s.contains("RR") {2}
            else if s.contains("R") {1} else {0};
    println!("{}", c)

}


Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
#define N 100005
int a[N];
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	int n,m;
	cin>>n>>m;
	int a1=0,a2=0;
	for(int i=1;i<=m;i++)
	{
		string x;
		int y;
		cin>>y>>x;
		if(x=="WA"&&a[y]<=0) a[y]--;
		else if(x=="AC"&&a[y]<=0) a1++,a2-=a[y],a[y]=1;
	}
	cout<<a1<<" "<<a2<<endl;
#ifdef __LOCAL__
	printf("Time Used : %d\n",clock());
#endif
	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
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; }

int main()
{
    int n;
    cin >> n;
    ll m = 100000;
    rep(i, n){
        m *= 1.05;
        if(m%1000 > 0){
            m /= 1000;
            m *= 1000;
            m += 1000;
        }
    }
    pr(m);
    return 0;}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	a = a * 100;
	b = b * 100;
	for(int i = 0; i <= 100000; ++i) {
		if(i * 8 - (i * 8) % 100 == a && i * 10 - (i * 10) % 100 == b) {
			cout << i << '\n';
			return 0;
		}
	}
	cout << -1 << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double
#define M 100000008

int main()
{
	FAST;
	ll k,a,b;
	cin >> k >> a >> b;
	if(b <= (a+2))
	{
		cout << 1+k;
		return 0;
	}
	else if(k <= (a-1))
	{
		cout << k+1;
		return 0;
	}
	else
	{
		ll c = a;
		ll l = k-(a-1);
		if(l%2 == 0)
		{
			c += (l/2)*(b-a);
		}
		else
		{
			c += (l/2)*(b-a);
			c++;
		}
		cout << c;
	}
}


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

/*
int isPrime(int x){
    int i;
    if(x < 2) return 0;
    else if(x == 2) return 1;
    if (x % 2 == 0) return 0;
    for(i = 3; i*i<=x; i+=2){
        if(x % i == 0) return 0;
    }
}*/

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

int main(){
    int x;
    cin >> x;
    int p = x;
    while (!is_prime(p)){
        p++;
    }
    cout << p << "\n";

    return 0;
}


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

using namespace std;

int data[8] = {0, 1, 2, 3, 5, 7, 8, 9};

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<int> buf;
		while(n)
		{
			buf.push_back(n % 8);
			n /= 8;
		}
		reverse(buf.begin(), buf.end());
		for(int i = 0; i < buf.size(); ++i)
		{
			cout << data[buf[i]];
		}
		cout << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

class WAR_FLY {
public:
    vvi d; //辺の数
    int V; //頂点の数
    
    WAR_FLY(int n) {
        V = n;
        d = vector<vector<int> > (n,vector<int>(n));
        for(int i = 0; i < V; i++) {
            for(int j = 0; j < V; j++) {
                if(i == j) {
                    d[i][j] = 0;
                }
                else {
                    d[i][j] = INF;
                }
            }
        }
    }

    void warshall_floyd() {
        for(int k = 0; k < V; k++) {
            for(int i = 0; i < V; i++) {
                for(int j = 0; j < V; j++) {
                    d[i][j] = min((ll)d[i][j], (ll)d[i][k] + (ll)d[k][j]);
                }
            }
        }
    }

    void add(int from, int to, int cost) {
        d[from][to] = cost;
    }

    bool is_negative_loop() {
        for(int i = 0; i < V; i++) {
            if(d[i][i] < 0) return true;
        }
        return false;
    }

    void show() {
        for(int i = 0; i < V; i++) {
            for(int j = 0; j < V; j++) {
                cout << d[i][j] << " ";
            }
            cout << endl;
        }
    }
};

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

    int h,w;
    cin>>h>>w;

    vvi c(10,vi (10));
    rep(i,10)rep(j,10)cin>>c[i][j];

    WAR_FLY wa(10);
    rep(i,10)rep(j,10)wa.add(i,j,c[i][j]);
    wa.warshall_floyd();

    ll ans=0;
    int d;
    rep(i,h)rep(j,w){
        cin>>d;
        if(d==1||d==-1)continue;
        ans+=wa.d[d][1];
    }
    fin(ans);

//////////////////////////////////////////////////////
return 0;}

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

using namespace std;

const int MAXN = 1e5 + 5;
int mem[MAXN] , a[MAXN];
int n;
int solve(int i)
{
if(i == n - 1) return 0;
if(i >= n) return 1e9;

int &ret = mem[i];
if(ret != -1) return ret;
int c1 = 1e9 ,c2 = 1e9;
if(i + 1 < n) c1 =  solve(i + 1) + abs(a[i] - a[i + 1]);
if(i + 2 < n) c2 =  solve(i + 2) + abs(a[i] - a[i + 2]);
  ret = min(c1,c2);
return ret;

}

int main()
{
cin >> n;
for(int i = 0 ; i < n ; i++) cin >> a[i];
memset(mem,-1,sizeof(mem));
cout << solve(0) ;


}

Measured memory_bytes: 5760
package main

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

const size = 1000000

var reader = bufio.NewReaderSize(os.Stdin, size)

func nextLine() string {
	var line, buffer []byte
	isPrefix := true
	var err error
	for isPrefix {
		line, isPrefix, err = reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
	}
	return string(buffer)
}
func nextStringArray() []string {
	return strings.Split(nextLine(), " ")
}
func nextInt() int {
	n, _ := strconv.Atoi(nextLine())
	return n
}
func nextIntArray() []int {
	s := strings.Split(nextLine(), " ")
	n := len(s)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}

func min(i, j int) int {
	if i > j {
		return j
	}
	return i
}

func main() {
	s := nextLine()
	odds := ""
	for i := 0; i < len(s); i++ {
		if i%2 == 0 {
			odds += string(s[i])
		}
	}
	fmt.Println(odds)
}


Measured memory_bytes: 15360
#include <bits/stdc++.h>
using namespace std;
#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define f first
#define s second
#define ld long double
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int a,b; cin >> a >> b;
    cout<<a*b<<endl;
}

Measured memory_bytes: 3636
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n, k = map(int, input().split())
p = [int(x) - 1 for x in input().split()]
c = [int(x) for x in input().split()]

ans = -float('inf')
for i in range(n):
    now = i
    c_sum = [0]
    s = set()
    cnt = 0
    while True:
        s.add(now)
        c_sum.append(c_sum[-1] + c[now])
        cnt += 1
        now = p[now]
        if now in s:
            break
    c_sum = c_sum[1:]
    if k < cnt:
        ans = max(ans, max(c_sum[: k]))
    else:
        score = c_sum[-1]
        count = k // cnt
        k_ = k - count*cnt
        score *= count
        score_2 = score - c_sum[-1]
        score_2 += max(c_sum)
        if k_ > 0:
            score += max(0, max(c_sum[:k_]))
        ans = max(ans, score, max(c_sum), score_2)
print(ans)




    

Measured memory_bytes: 168828
#include <cstdio>
#include <cstring>
#include <cmath>
#include <climits>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;

#define COUT cout <<
#define SPACE_COUT << " "  <<
#define COMMA_COUT << ", " <<
#define ENDL << endl;

int
main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    
    int total = 0;
    int len = s.size();
    int i = 1;
    char prev = s[0];
    while(i < len) {
        if (prev != s[i]) {
            total++;
            prev = s[i];
        }
        i++;
    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1e09+7;



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

int main(){


  ll n;
  cin>>n;
  set<ll> data;
  
  string answer="YES";
  
  rep(i,n){
    ll tmp;
    cin>>tmp;
    if (data.find(tmp)!=data.end()){
      answer="NO";
      break;
    }
    data.insert(tmp);
  }
  
  cout<<answer<<endl;
  
  
  
}



Measured memory_bytes: 9600
#ABC081-B
n = int(input())
a = list(map(int,input().split()))
flg = True
cnt = 0

while flg:
    for i in range(n):
        if a[i] % 2 == 0: 
            a[i] = a[i]/2
        else:
            flg = False
            break
    if flg:
        cnt += 1
    

            
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){
  int a,b,c,d,e;
  cin >> a >> b;
  if (4*a<b) {
    cout << "No";
  }else if (2*a>b) {
    cout << "No";
  }else if (b%2!=0){
    cout << "No";
  }else{
    cout << "Yes";
  }
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }
    int ans = 1e9;
    for(int i = 1; i <= 100; i++){
        int sum = 0;
        for(int j = 0; j < n; j++){
            sum += (i - x[j])*(i - x[j]);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3556
IDENTIFICATION DIVISION.
      PROGRAM-ID. 108A.
      DATA DIVISION.
      WORKING-STORAGE SECTION.
      01 INP PIC X(100).
      01 BH  PIC 9(2).
      01 BW  PIC 9(2).
      01 SH  PIC 9(2).
      01 SW  PIC 9(2).
      
      01 ANS PIC 9(5).
      01 ANSS PIC ZZZZ9.
      
      PROCEDURE DIVISION.
      ACCEPT INP.
      UNSTRING INP DELIMITED BY " "
      INTO BH BW.
      
      ACCEPT INP
      UNSTRING INP DELIMITED BY " "
      INTO SH SW.
      
      COMPUTE ANS = ( BH - SH ) * ( BW - SW )
      
      MOVE ANS TO ANSS.
      
      DISPLAY FUNCTION TRIM(ANSS).
      
      STOP RUN.

Measured memory_bytes: 512
//  Created by conan1024hao in 2020.
//  Copyright © 2020 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????统一类型        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int a,b,c;cin>>a>>b>>c;
    if(a==b&&a!=c)
    {
        cout<<"Yes"<<Endl;
    }
    else if(a==c&&a!=b){
        cout<<"Yes"<<endl;
    }else if(b==c&&a!=b){
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------








Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<stdio.h>

int main() {

		int n,i,x[100],y[100];
		double l1=0,l2=0,l3=0,l_inf=0;
		
		std::cin >> n;

		for (i = 0; i < n; i++)std::cin >> x[i];
		for (i = 0; i < n; i++)std::cin >> y[i];

		for (i = 0; i < n; i++) {
			l1 += std::abs(x[i] - y[i]);
		}
		for (i = 0; i < n; i++) {
			l2 += (pow(x[i] - y[i], 2));
		}
		l2 = sqrt(l2);
		for (i = 0; i < n; i++) {
			l3 += (pow(std::abs(x[i] - y[i]), 3));
		}
		l3 = pow(l3, 0.3333333333333);

		for (i = 0; i < n; i++) {
			if (std::abs(x[i] - y[i]) > l_inf)l_inf = std::abs(x[i] - y[i]);
		}

		printf("%8f\n%8f\n%8f\n%8f\n", l1, l2, l3, l_inf);

		


		
		
}


Measured memory_bytes: 3344
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = sum(b)

for i in range(n-1):
  if a[i] + 1 == a[i+1]:
    ans += c[a[i] - 1]

print(ans)


Measured memory_bytes: 3060
public class Main {


  private static void solve() {
    String s = next();
    if (s.compareTo("2019/04/30") <= 0) {
      System.out.println("Heisei");
    } else {
      System.out.println("TBD");
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 23252
n = int(input())
lst = [int(i) for i in input().split()]
if(lst.count(0) > 0):
    print(0)
    exit()

ans = 1
for i in lst:
    ans *=  i#input().split()
    if(ans > 1.0e+18):
        print(-1)
        exit()

print(ans)


Measured memory_bytes: 21640