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


int main () {

    int N,D,X,sum=0;
    cin >> N >> D >> X;
    int A[N],ans=X;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        for(int j = 1; j <= D; j += A[i]) {
            sum ++;
        }
        ans += sum;
        sum = 0;
    }

    cout << ans << endl;


    return 0;
}

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

//RMQ
struct SegmentTree{
private:
	int N;
	vector<long long> node, lazy;
	vector<bool> lazyFlg;
	const long long DEFAULT = 9223372036854775807LL;
public:
	void init(int n){ //初期化 O(N)
		node.clear();
		lazy.clear();
		lazyFlg.clear();
		N = 1;
		while(N < n) N = (N<<1);
		for(int i=0; i<2*N-1; i++){
			node.push_back(DEFAULT);
			lazy.push_back(0LL);
			lazyFlg.push_back(false);
		}
	}
	void eval(int k, int l, int r){ //遅延評価 O(1)
		if(lazyFlg[k]){ //RUQ：下に更新クエリが溜まっていても加算クエリが溜まっていても上書き
			node[k] = lazy[k];
			if(r-l > 1){
				lazy[2*k+1] = lazy[k];
				lazyFlg[2*k+1] = true;
				lazy[2*k+2] = lazy[k];
				lazyFlg[2*k+2] = true;
			}
			lazy[k] = 0LL;
			lazyFlg[k] = false;
		}
		else{ //RAQ：下に更新クエリが溜まっていても加算クエリが溜まっていても加算
			node[k] += lazy[k];
			if(r-l > 1){
				lazy[2*k+1] += lazy[k];
				lazy[2*k+2] += lazy[k];
			}
			lazy[k] = 0LL;
		}
	}
	void update(int a, long long x){ //[a,a+1)の値を変更 O(log N)
		update(a, a+1, x);
	}
	void update(int a, int b, long long x, int k=0, int l=0, int r=-1){ //[a,b)の値を変更 O(log N)
		if(r == -1) r = N;
		eval(k, l, r);
		if(b <= l || r <= a) return; //交差する場合
		if(a <= l && r <= b){ //完全に含む場合
			lazy[k] = x;
			lazyFlg[k] = true;
			eval(k, l, r);
		}
		else{
			update(a, b, x, 2*k+1, l, (l+r)/2);
			update(a, b, x, 2*k+2, (l+r)/2, r);
			node[k] = std::min(node[2*k+1], node[2*k+2]);
		}
	}
	void add(int a, long long x){ //[a,a+1)の値に加算 O(log N)
		add(a, a+1, x);
	}
	void add(int a, int b, long long x, int k=0, int l=0, int r=-1){ //[a,b)の値に加算 O(log N)
		if(r == -1) r = N;
		eval(k, l, r);
		if(b <= l || r <= a) return; //交差する場合
		if(a <= l && r <= b){ //完全に含む場合
			lazy[k] += x;
			eval(k, l, r);
		}
		else{
			add(a, b, x, 2*k+1, l, (l+r)/2);
			add(a, b, x, 2*k+2, (l+r)/2, r);
			node[k] = std::min(node[2*k+1], node[2*k+2]);
		}
	}
	long long min(int a, int b, int k=0, int l=0, int r=-1){ //[a,b)の最小値 O(log N)
		if(r == -1) r = N;
		if(b <= l || r <= a) return DEFAULT; //交差する場合
		eval(k, l, r);
		if(a <= l && r <= b) return node[k]; //完全に含む場合
		return std::min(min(a, b, k*2+1, l, (l+r)/2), min(a, b, k*2+2, (l+r)/2, r));
	}
	void print(){
		for(int i=0; i<node.size(); i++) cout << node[i] << endl;
		for(int i=0; i<node.size(); i++) cout << lazy[i] << endl;
		for(int i=0; i<node.size(); i++) cout << lazyFlg[i] << endl;
	}
};

int main(){
	int N, Q;
	cin >> N >> Q;
	SegmentTree st;
	st.init(N+1);
	st.update(0, N, 0LL);
	for(int q=0; q<Q; q++){
		int c, s, t;
		cin >> c >> s >> t;
		if(c == 0){
			long long x; cin >> x;
			st.add(s, t+1, x);
		}
		else cout << st.min(s, t+1) << endl;
	}
}


Measured memory_bytes: 7144
#include <bits/stdc++.h>
using namespace std;
int main() {
  string n;
  cin >> n;
int l = n.size();
int warukazu;
int wararerukazu = stoi(n);
for(int i  =0;i < l;i++){
int b = n[i] - '0';
warukazu += b;
}
if(wararerukazu%warukazu == 0){
  cout << "Yes" <<endl;
}
else{
  cout << "No" <<endl;
}
}




Measured memory_bytes: 256
package main

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

type Node struct {
	left  *Node
	val   int
	right *Node
}

func main() {
	var nOps int
	fmt.Scan(&nOps)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	var node *Node
	for i := 0; i < nOps; i++ {
		sc.Scan()
		switch sc.Text() {
		case "insert":
			sc.Scan()
			val, _ := strconv.Atoi(sc.Text())
			node = insert(node, val)
		case "find":
			sc.Scan()
			val, _ := strconv.Atoi(sc.Text())
			if contains(node, val) {
				fmt.Println("yes")
			} else {
				fmt.Println("no")
			}
		case "print":
			printValues(listByInOrder(node, []int{}))
			printValues(listByPreOrder(node, []int{}))
		}
	}
}

func printValues(vs []int) {
	buf := bufio.NewWriter(os.Stdout)
	for _, v := range vs {
		buf.Write([]byte(fmt.Sprintf(" %d", v)))
	}
	buf.Write([]byte("\n"))
	buf.Flush()
}

func listByInOrder(node *Node, vs []int) []int {
	if node != nil {
		vs = listByInOrder(node.left, vs)
		vs = append(vs, node.val)
		vs = listByInOrder(node.right, vs)
	}
	return vs
}

func listByPreOrder(node *Node, vs []int) []int {
	if node != nil {
		vs = append(vs, node.val)
		vs = listByPreOrder(node.left, vs)
		vs = listByPreOrder(node.right, vs)
	}
	return vs
}

func insert(node *Node, val int) *Node {
	if node == nil {
		return &Node{nil, val, nil}
	}

	var parent *Node
	nd := node
	for nd != nil {
		parent = nd
		if nd.val > val {
			nd = nd.left
		} else {
			nd = nd.right
		}
	}

	if parent.val > val {
		parent.left = &Node{nil, val, nil}
	} else {
		parent.right = &Node{nil, val, nil}
	}

	return node
}

func contains(node *Node, val int) bool {
	switch {
	case node == nil:
		return false
	case node.val == val:
		return true
	case node.val > val:
		return contains(node.left, val)
	default:
		return contains(node.right, val)
	}
}


Measured memory_bytes: 36348
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	ans := "Yes"
	for i := 0; i < len(s); {
		if i+1 < len(s) {
			if s[i:i+2] != "hi" {
				ans = "No"
				break
			} else {
				i += 2
			}
		} else {
			ans = "No"
			break
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#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 srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

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

  int N;
  cin >> N;
  vector<ull> A(N);
  rep(i, N) cin >> A[i];

  std::sort(A.begin(), A.end());

  cout << A[N-1] - A[0] << '\n';
}


Measured memory_bytes: 632
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int sum = 0;
		int min = Integer.MAX_VALUE;
		List<Integer> intList = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			intList.add(sc.nextInt());
		}

		for (int index = 1; index <= 100; index++) {
			for (int j = 0; j < intList.size(); j++) {
				int hp = (intList.get(j) - index) * (intList.get(j) - index);
				sum = sum + hp;
			}
			if (sum < min) {
				min = sum;
			}
			sum = 0;
		}

		System.out.println(min);
	}

}

Measured memory_bytes: 21588
#include<stdio.h>
int main() {
	int a, b, kai;
	char op;
	while(1){
		scanf("%d %c %d", &a, &op, &b);
		if(op=='?'){
			break;
		}else if(op=='+'){
			kai = a + b;
			printf("%d\n", kai);
		}else if(op=='-'){
			kai = a - b;
			printf("%d\n", kai);
		}else if(op=='*'){
			kai = a * b;
			printf("%d\n", kai);
		}else if(op=='/'){
			kai = a / b;
			printf("%d\n", kai);
		}
	}
}


Measured memory_bytes: 2104
h, w = map(int, input().split())
s = [list(map(str, input().rstrip())) for _ in range(h)]

dp = [[10001] * w for _ in range(h)]

if s[0][0] == "#":
    dp[0][0] = 1
else:
    dp[0][0] = 0

moves = [[1, 0], [0, 1]]

for y in range(h):
    for x in range(w):
        for m in moves:
            ny, nx = y + m[0], x + m[1]
            if ny >= h or nx >= w:
                continue
            add = 0
            # .から#に突入する時だけカウントが増える
            if s[y][x] == "." and s[ny][nx] == "#":
                add = 1
            dp[ny][nx] = min(dp[ny][nx], dp[y][x] + add)

print(dp[-1][-1])

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

using namespace std;

int n;
int h[100010],f[100010];

int main(){
	scanf("%d",&n);
	h[0]=1e9;
	for(int i=1;i<=n;i++){
		scanf("%d",h+i);
		if(i>1)f[i]=min(f[i-1]+abs(h[i]-h[i-1]),f[i-2]+abs(h[i]-h[i-2]));
	}

	printf("%d\n",f[n]);

	return 0;
}

Measured memory_bytes: 1024
N, A, B = gets.split.map(&:to_i)
v = gets.split.map(&:to_i).sort.reverse

p v[0, A].inject(:+) / A.to_f
m = v[0, A].min
a = v[0, A].count(m)
b = v[A..-1].count(m)

def f(n)
  return 1 if n <= 1
  (1..n).inject(:*)
end

if v[0, A].size == a
  t = f(a+b)
  p((A..B).map do |n|
    if n <= a + b
      t / (f(n) * f(a+b-n))
    else
      0
    end
  end.inject(:+))
else
  p f(a+b)/(f(a) * f(b))
end



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

using namespace std;

int main() {
    int n;
    cin >> n;
    int hold = n, sum = 0;
    while (hold) {
        sum += hold % 10;
        hold /= 10;
    }
    if (n % sum == 0) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 3528
#include <stdio.h>
 
int main()
{
    unsigned long long int x;
    scanf("%llu", &x);
    int ans;
    long long int money=100;
for(int i = 0;x>money;i++){
    money+=money/100;
    ans=i;
}

    printf("%d",ans+1);
    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

const ll mod = 1000000007;
const ll contest = 26;

int main(){
    ll d, csum = 0; cin >> d;
    vector<ll> c(contest);
    vector<vector<ll>> s(d, vector<ll>(contest));
    rep(i, contest){
        cin >> c[i];
        csum += c[i];
    }
    rep(i, d) rep(j, contest) cin >> s[i][j];
    vector<ll> last(contest, 0);
    vector<ll> result(d, 0);
    ll sum = 0;
    rep(i, d){
        ll maxx = 0, tt = 1, score = 0;
        rep(t, contest){
            score = sum + s[i][t];
            rep(j, contest){
                if(t == j) continue;
                score -= c[j]*((i+1)-last[j]);
            }
            if(score > maxx){
                tt = t;
                maxx = score;
            }
        }
        last[tt] = i+1;
        result[i] = tt;
        sum += maxx % mod;
        //cout << tt+1 << endl;
    }
    
    rep(a, d){
        random_device rd;
        mt19937 mt(rd());
        ll tt = mt()%d, cc = a == 0 ? result[tt] : mt()%contest;
        ll bak = result[tt];
        result[tt] = cc;

        fill(last.begin(), last.end(), 0);
        ll old = a == 0 ? -1000000000 : sum;
        sum = 0;
        rep(i, d){
            sum += s[i][result[i]];
            last[result[i]] = i+1;
            rep(j, contest){
                if(result[i] == j) continue;
                sum -= c[j]*((i+1)-last[j]);
            }
        }
        if(sum < old){
            result[tt] = bak;
            sum = old;
        }
    }
    for(auto i : result){
        cout << i+1 << endl;
    }
    return 0;
}

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

int main() {
    int N;
    int G[101][101];
    cin >> N;
    for (int j = 0; j <= N; ++j) for (int k = 0; k <= N; ++k) G[j][k] = 0;
    for (int _ = 0; _ < N; ++_) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; ++j) {
            int v; cin >> v;
            G[u][v] = 1;
        }
    }

    for (int j = 1; j <= N; ++j) {
        for (int k = 1; k <= N; ++k) {
            if (k > 1) cout << " ";
            cout << G[j][k];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while(a>0 && c>0){
		c -= b;
		if(c <= 0){
			cout << "Yes" << endl;
			break;
		}
		a -= d;
		if(a <= 0) cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
a = list(map(int,input().split()))
N=a[0]
T=a[1]
tmp=[]
ct = [list(map(int,input().split())) for l in range(N)]
for i in range(N):
    if ct[i][1]<=T:
        tmp.append(ct[i][0])

tmp.sort()

if len(tmp)==0:
    print('TLE')
else:
    print(tmp[0])
        


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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int r = 0;
    int b = 0;
    for(int i = 0; i<n; i++){
        if(s[i] == 'R'){
            r += 1;
        }else{
            b += 1;
        }
    }
    if(r > b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100000][3];
int dp[100000][3];
 
int main()
{
int n;
  cin>>n;
  for(int i=0;i<n;i++)
  {
     for(int j=0;j<3;j++)
     {
     cin>>a[i][j];
     }
  }
  
  dp[0][0]=a[0][0];
   dp[0][1]=a[0][1];
   dp[0][2]=a[0][2];
  for(int day=1;day<n;day++)
  {
    dp[day][0]=a[day][0]+max(dp[day-1][1],dp[day-1][2]);
    dp[day][1]=a[day][1]+max(dp[day-1][0],dp[day-1][2]);
    dp[day][2]=a[day][2]+max(dp[day-1][0],dp[day-1][1]);
  }
  int answer=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
  cout<<answer;
  return 0;
}

Measured memory_bytes: 5964
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

int main(){
    int n,r=0,b=0;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='R') r++;
        else b++;
    }
    if(r>b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


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

int main (){
	int i,n,l,sum=0;
	cin >> n >> l;
	for(i=1;i<=n;i++) sum+=(l+i-1);
	if(l>=0) cout << sum-l << endl;
	else if(l+n-1>=0) cout << sum << endl;
	else cout << sum-(l+n-1) << endl;
    return 0;
}

Measured memory_bytes: 256
main(l,m,n,a,i){for(;a=12,scanf("%d",&l),l;printf((a>11)?"NA\n":"%d\n",a+1))for(i=0;i<12;++i)if(scanf("%d%d",&m,&n),(l-=m-n)<1)a=(a<i)?a:i;}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

bool prevSubset(bitset<15>& bs, const bitset<15>& mask)
{
    if(bs.none())
        return false;
    bs = bs.to_ulong() - 1ull;
    bs &= mask;
    return true;
}

int solve(vector<int>& w, int limit)
{
    int n = w.size();
    vector<int> dp(1<<n, INT_MAX/2);
    dp[(1<<n)-1] = 0;
    for(int i=(1<<n)-1; i>0; --i){
        bitset<15> mask(i);
        bitset<15> bs(i);
        do{
            int sum = 0;
            for(int j=0; j<n; ++j){
                if(bs[j])
                    sum += w[j];
            }
            if(sum <= limit)
                dp[(mask^bs).to_ulong()] = min(dp[(mask^bs).to_ulong()], dp[i] + 1);
        }while(prevSubset(bs, mask));
    }

    return dp[0];
}

int main()
{
    int n, m, limit;
    cin >> n >> m >> limit;

    vector<vector<int> > w(n);
    for(int i=0; i<n; ++i){
        int k;
        cin >> k;
        w[i].resize(k);
        for(int j=0; j<k; ++j)
            cin >> w[i][j];
    }

    vector<int> a;
    int prev = 0;
    int ret = 1 - m;
    for(int i=n-1; i>=0; --i){
        ret += prev * 2;
        if(w[i].size() > 0){
            for(unsigned j=0; j<w[i].size(); ++j)
                a.push_back(w[i][j]);
            prev = solve(a, limit);
        }
    }

    cout << max(0, ret) << endl;
    return 0;
}

Measured memory_bytes: 1352
import java.util.*;

public class Main {
  public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int a = sc.nextInt();
    	int b = sc.nextInt();
    	if(a + b >= 10){
          System.out.println("error");
        } else {
          System.out.println(a + b);
        }
  }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 20;

int a[N], res;
int x[N][N], y[N][N];
bool ok[N], okk[N];

int main()
{
	int n; cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		for (int j = 0; j < a[i]; j++){
			cin >> x[i][j] >> y[i][j];
		}
	}
	for (int i = 0; i < 1 << n; i++){
		int sum = 0;
		bool tag = true;
		for (int j = 0; j < n; j++){
			ok[j] = (i >> j) & 1;
			if (ok[j])	sum++;
		}
		for (int j = 0; j < n && tag; j++){
			if (ok[j]){
				for (int k = 0; k < a[j] && tag; k++){
					if (y[j][k]){
						if (!ok[x[j][k]-1]) tag = false;
					}
					else{
						if (ok[x[j][k]-1]) tag = false;
					}
				}
			}
		}
		if (tag) res = max(res, sum);
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1, 0, 1, 1, -1, -1}, dx = {1,-1,0,0, 0, 1, -1, 1, -1};
//vector<int> dy = {0, 0, 1, -1}, dx = {1, -1, 0, 0};
vector<ll> A(100010);

int main(void){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    for(int i = 0; i < N; i++) cin >> A[i];
    vector<pair<ll,ll>> bc(M);
    for(int i = 0; i < M; i++){
        cin >> bc[i].second >> bc[i].first;
    }
    sort(bc.begin(), bc.end());
    reverse(bc.begin(), bc.end());
    vector<ll> xs;
    for(int i = 0; i < M; i++){
        for(int j = 0; j < bc[i].second; j++){
            xs.push_back(bc[i].first);
            if(xs.size() > N) break;
        }
        if(xs.size() > N) break;
    }
    
    for(int i = 0; i < N; i++){
        xs.push_back(A[i]);
    }
    sort(xs.begin(), xs.end());
    reverse(xs.begin(), xs.end());
    ll ans = 0;
    for(int i = 0; i < N; i++){
        ans += xs[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4852
package main

import (
	"fmt"
	"strings"
	"strconv"
)

func main() {
	var S string
	var a,b int
	fmt.Scan(&S)
	list := strings.Split(S,"/")
	a, _ = strconv.Atoi(list[0])
	b, _ = strconv.Atoi(list[1])

	if  a<2019{
		fmt.Println("Heisei")
		return
	} else {
		if b<4 {
			fmt.Println("Heisei")
			return
		} else if b==4 {
			fmt.Println("Heisei")
			return
		} else {
			fmt.Println("TBD")
			return
		}
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> P;
typedef pair<int64_t, int64_t> Pll;
  
int main() {
    int N, M, X, sum1 = 0, sum2 = 0;
    cin >> N >> M >> X;
    for (int i = 0; i < M; i++) {
        int a;
        cin >> a;
        if (a < X) {
            sum1++;
        }
        else if(a > X) {
            sum2++;
        }
    }
    cout << min(sum1, sum2) << endl;
}

Measured memory_bytes: 256
s = input()
flg = 0
n = len(s)
for i in range(n-1):
    if s[i] == "A" and s[i+1] == "C":
        flg = 1
        break
    else:
        flg = 0
if flg == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
	int h,w;cin>>h>>w;
  	vector<vector <char> >maze(h,vector<char >(w,'.'));
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      cin>>maze[i][j];
  for(int i=0;i<h;i++){
  	for(int j=0;j<w;j++){
    	if(maze[i][j]=='#')cout<<'#';
      else{
          int bombs=0;
      	for(int k=-1;k<=1;k++)
          for(int l=-1;l<=1;l++)
         	if(i+k>=0 && i+k<h && j+l>=0 && j+l<w && maze[i+k][j+l]=='#')bombs+=1;
      	cout<<bombs;
      }
    }
    cout<<'\n';
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
int n,u,v,m;
bool U[500][500],N[500][500];
map<int,pair<int,int> >usa,ne;
main()
{
	cin>>n>>u>>v>>m;
	if(n==1)
	{
		u*=4;
		v*=4;
	}
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)
	{
		int a;cin>>a;
		usa[a]=make_pair(i,j);
	}
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)
	{
		int a;cin>>a;
		ne[a]=make_pair(i,j);
	}
	for(;m--;)
	{
		int a;cin>>a;
		int x,y;
		bool f1,f2;
		if(usa.find(a)!=usa.end())
		{
			x=usa[a].first,y=usa[a].second;
			U[x][y]=1;
			f1=1,f2=1;
			for(int i=0;i<n;i++)f1&=U[x][i],f2&=U[i][y];
			if(f1)u--;
			if(f2)u--;
			if(x==y)
			{
				f1=1;
				for(int i=0;i<n;i++)f1&=U[i][i];
				if(f1)u--;
			}
			if(x==n-y-1)
			{
				f1=1;
				for(int i=0;i<n;i++)f1&=U[i][n-i-1];
				if(f1)u--;
			}
		}
		if(ne.find(a)!=ne.end())
		{
			x=ne[a].first,y=ne[a].second;
			N[x][y]=1;
			f1=1,f2=1;
			for(int i=0;i<n;i++)f1&=N[x][i],f2&=N[i][y];
			if(f1)v--;
			if(f2)v--;
			if(x==y)
			{
				f1=1;
				for(int i=0;i<n;i++)f1&=N[i][i];
				if(f1)v--;
			}
			if(x==n-y-1)
			{
				f1=1;
				for(int i=0;i<n;i++)f1&=N[i][n-i-1];
				if(f1)v--;
			}
		}
		if(u<=0&&v<=0)
		{
			cout<<"DRAW"<<endl;
			return 0;
		}
		else if(u<=0)
		{
			cout<<"USAGI"<<endl;
			return 0;
		}
		else if(v<=0)
		{
			cout<<"NEKO"<<endl;
			return 0;
		}
	}
	cout<<"DRAW"<<endl;
}


Measured memory_bytes: 21412
#include <cstdio>

int c[3], f[26];

bool solve() {
  for(int i = 0; i < 26; i++) {
    if(f[i] % 2 != 0) {
      if(c[0] == 0) return false;
      f[i]--;
      c[0]--;
    }
    f[i] /= 2;
  }
  if(c[0] % 2 != 0) return false;
  c[1] += c[0] / 2;
  c[0] = 0;
  for(int i = 0; i < 26; i++) {
    if(f[i] % 2 != 0) {
      if(c[1] == 0) return false;
      f[i]--;
      c[1]--;
    }
    f[i] /= 2;
  }
  if(c[1] % 2 != 0) return false;
  c[2] += c[1] / 2;
  c[1] = 0;
  return true;
}

int main() {
  int H, W;
  scanf("%d%d", &H, &W);
  for(int i = 1; i <= (H + 1) / 2; i++) {
    for(int j = 1; j <= (W + 1) / 2; j++) {
      int p = 4;
      if(H + 1 - i == i) p >>= 1;
      if(W + 1 - j == j) p >>= 1;
      if(p == 1) {
        c[0]++;
      } else if(p == 2) {
        c[1]++;
      } else {
        c[2]++;
      }
    }
  }
  for(int i = 0; i < H; i++) {
    scanf(" ");
    for(int j = 0; j < W; j++) {
      f[getchar() - 'a']++;
    }
  }
  puts(solve() ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 888
/*  /$$                                     /$$
      | $$                                    | $$
  /$$$$$$$  /$$$$$$   /$$$$$$$  /$$$$$$   /$$$$$$$  /$$$$$$   /$$$$$$
 /$$__  $$ /$$__  $$ /$$_____/ /$$__  $$ /$$__  $$ /$$__  $$ /$$__  $$
| $$  | $$| $$$$$$$$| $$      | $$  \ $$| $$  | $$| $$$$$$$$| $$  \__/
| $$  | $$| $$_____/| $$      | $$  | $$| $$  | $$| $$_____/| $$
|  $$$$$$$|  $$$$$$$|  $$$$$$$|  $$$$$$/|  $$$$$$$|  $$$$$$$| $$
 \_______/ \_______/ \_______/ \______/  \_______/ \_______/|__//$$$$$$ /$$$$$$
                                                               |______/|______/

*/
#include <bits/stdc++.h>
#define fastio        ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ln            cout<<endl;
#define vi            vector<int>
#define vll           vector<long long>
#define sortl(vec)    sort(vec.begin(), vec.end());
#define sortr(vec)    sort(vec.rbegin(), vec.rend());
#define forn(i, x, n) for(long long i = x; i < n; i++)
#define revn(i, n, x) for(long long i = n; i >= x ; i--)
#define in(vec)       for(auto &it : vec) cin >> it;
#define loop(vec)     for(auto &it : vec)
#define	out(vec)      for(auto &it : vec) cout << it << " "; ln
#define ll            long long
#define mod           1000000007
#define debug(x)      cout << x << endl;
#define pb            emplace_back
#define mp            make_pair
#define um            unordered_map
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define f             first
#define s             second
#define pi            3.14159265359
#define CLOCK         cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
using namespace std;

ll power(ll x, ll y, ll p) {
	ll res = 1;
	x = x % p;

	while (y > 0) {
		if (y & 1)
			res = (res * x) % p;

		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}

ll modulo(ll a, ll b) {
	ll c = a % b;
	return (c < 0) ? c + b : c;
}

int main() {
// in(vec) works for size-defined type vectors

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input1.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output1.txt", "w", stdout);
#endif

	fastio
	ll t = 1;
	while (t--) {
		ll n, k;
		cin >> n >> k;
		vll vec(n);
		in(vec)

		sortl(vec);
		ll  sum = 0;
		forn(i, 0, k) {
			sum += vec[i];
		}


		cout << sum << endl;
	}
	CLOCK
	return 0;
}



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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  ll n;
  cin >> n;
  vector<ll> a(n);
  scan(a);
  vector<ll> ans(n);
  ans[0] = 0;

  rep(i, 1, n) { ans[i] = (a[i - 1] - ans[i - 1] / 2) * 2; }
  ans[0] += (a[n - 1] - ans[n - 1] / 2);
  rep(i, 1, n) { ans[i] = (a[i - 1] - ans[i - 1] / 2) * 2; }

  string s_ans = "";
  rep(i, 0, n) s_ans += to_string(ans[i]) + " ";
  s_ans.pop_back();

  cout << s_ans << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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;
}

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 4096
#include<iostream>
#include<stack>

using namespace std;

int main(){
	stack <int> depot;

	int train;

	while (cin >> train){
		if (train != 0) depot.push(train);
		else {
			cout << depot.top() << endl;
			depot.pop();
		}
	}

	return 0;

}

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

ll gcd(ll a, ll b){
	if (a == 0) return b;
	return gcd(b  %a, a);
}

ll lcm(ll a, ll b){
	return (a*b) / gcd(a, b);
}

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

	ll t,i,sum=0;
	cin >> t;

	for(i=1;i<t+1;i++)
	{
		ll x = t/i;
		sum += i*((x*(x+1))/2);
	}

	cout << sum << endl;


}

Measured memory_bytes: 3644
#include<stdio.h>
#include<cmath>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int N;
	int sum = 0;
	scanf("%d", &N);
	int B[110];
	for (int i = 0; i < N - 1; i++) {
		scanf("%d", &B[i]);
		if (i == N - 2) {
			sum += B[i];
		}
	}

	for (int i = 0; i < N-1; i++) {
		if (i == 0) {
			sum += B[i];
		}
		else {
			if (B[i] >= B[i - 1]) {
				sum += B[i - 1];
			}
			if (B[i] < B[i - 1]) {
				sum += B[i];

			}
		}
	}
	if (N == 2) {
		printf("%d", 2 * B[0]);
		return 0;
	}
	printf("%d", sum);

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-5;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    int n;cin>>n;
    vector<int> h(n);
    for(int i=0;i<n;i++)cin>>h[i];
    int ans=0;
    for(int i=1;i<=100;i++){
        int co=0;
        bool f=false;
        for(int j=0;j<n;j++){
            if(f){
                if(h[j]<i){
                    f=false;
                }
            }else{
                if(h[j]>=i){
                    f=true;
                    co++;
                }
            }
        }
        ans+=co;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=(ll)(1e9+21);
ll run();
int main() {
#ifdef home
    freopen("i", "r", stdin);
    freopen("d", "w", stderr);
#endif
    cout.precision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    run();
    return 0;
}


ll run() {
    int n;
    cin>>n;
    int a[n][3];
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>a[i][j];
        }
    }

    int dp[n][3]={0};
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];


    for(int i=1;i<=n;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(k!=j){
                    dp[i][j] = max(dp[i][j], dp[i-1][k] + a[i][j]);
                }
            }
        }
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}


Measured memory_bytes: 2560
N = int(input())
chin = []
sum = 0

for i in range(N):

    x = int(input())
    sum += x

    if x % 10 != 0:
        chin.append(x)

chin.sort()
i = 0

while chin != [] and i < len(chin) and sum % 10 == 0:
    sum -= chin[i]
    i += 1

if sum % 10 == 0:
    print(0)
else:
    print(sum)


Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int mod =1e9+7;
const int N = (int)2e5 + 5;

void solve(){
	int n,k;
	cin>>n>>k;
	int d[k];
	set<int>s;
	rep(i,k){
		cin>>d[i];
		int a[d[i]];
		rep(j,d[i]){
			cin>>a[j];
			s.insert(a[j]);
		}
	}
	cout<<n-sz(s);
    
}

int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 3668
n = int(input())
a = list(map(int, input().split(' ')))
b = [a[i] + i for i in range(n)]
c = [j - a[j] for j in range(n)]
d = dict()
ans = 0
for i in range(n):
  if d.get(b[i]) is None:
    d.setdefault(b[i],1)
  else:
    d[b[i]] += 1
  if d.get(c[i]) is not None:
    ans += d[c[i]]
print(ans)

Measured memory_bytes: 50136
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  ll a[N];
  ll sum[N + 1];
  sum[0] = 0;
  for(int i = 0; i < N; i++){
    cin >> a[i];
    sum[i + 1] = sum[i] + a[i];
  }

  sort(sum, sum + N + 1);
  /*for(int i = 0; i <= N; i++){
    cout << sum[i] << " ";
  }
  cout << endl;*/
  ll cnt = 0;
  ll ans = 0;
  for(int i = 1; i <= N; i++){
    if(sum[i] == sum[i - 1]){
      cnt++;
    }
    else{
      ans += (cnt + 1) * cnt / 2;
      cnt = 0;
    }
  }
  ans += (cnt + 1) * cnt / 2;

  cout << ans << endl;
  return 0;


}

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

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

	vector<int> p(n);
	rep(i, n) cin >> p.at(i);
	vector<int> inc(n);
	rep(i, n) inc.at(i) = i+1;

	int ans = 0;
	rep(i, n) if(p.at(i) != inc.at(i)) ans++;
	if(ans == 2 || ans == 0) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}


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

const int N = 2e6 + 10;
const int mod = 998244353;

inline int fpow (int a, int b) {
	int ret = 1;
	while (b) {
		if (b & 1) ret = 1ll * ret * a % mod;
		a = 1ll * a * a % mod;
		b >>= 1;
	}
	return ret;
}

int f[N], invf[N];

void predeal (int n) {
	f[0] = invf[0] = 1;
	for (int i = 1; i <= n; i++) {
		f[i] = 1ll * f[i - 1] * i % mod;
	}
	invf[n] = fpow(f[n], mod - 2);
	for (int i = n - 1; i >= 1; i--) {
		invf[i] = 1ll * invf[i + 1] * (i + 1) % mod; 
	}
}

inline int C (int n, int m) {
	return n >= m ? 1ll * f[n] * invf[m] % mod * invf[n - m] % mod : 0;
}

int main (void) {
	predeal(2e6);

	int n, m, ans = 0;
	scanf("%d%d", &n, &m);
	for (int i = 0; i <= m; i++) {
		if ((m - i) & 1) continue;
		ans += 1ll * C(n, i) * C((3 * m - i) / 2 + n - 1, n - 1) % mod;
		if (ans >= mod) ans -= mod;
	}
	for (int i = 0; i < m; i++) {
		if ((m - 1 - i) & 1) continue;
		ans -= 1ll * C(n, 1) * C(n, i) % mod * C((m - 1 - i) / 2 + n - 1, n - 1) % mod;
		if (ans < 0) ans += mod;
	}

	cout << ans << endl;

}

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

int main() {
  int N,M;cin >> N >> M;
  vector<int> a(60);
  vector<int> b(60);
  for(int i=0;i<M;i++){
		cin >> 	a.at(i) >> b.at(i);
      }
  for(int i=1;i<=N;i++){
    int count=0;
     for(int j=0;j<M;j++){
      if(a.at(j)==i){
      count++;
      }
      if(b.at(j)==i){
      count++;
      }
     }
    cout << count <<endl; 
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (int i = a; i < b; i++)
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
int n;
int arr[200004];
int cat[200004];
int tot = 0;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	REP(i, 0, n){
		cin >> arr[i];
		tot = tot^arr[i];
	}
	REP(i, 0, n){
		cat[i] = tot^arr[i];
	}
	REP(i, 0, n){
		if (i != 0) cout << " ";
		cout << cat[i];
	}
	
}

Measured memory_bytes: 5132
#include <bits/stdc++.h>
using namespace std;
 
#define debug(x) cerr << #x << " = " << x << '\n';
#define BP() cerr << "OK!\n";
#define PR(A, n) cerr << #A << " = "; for (int i=1; i<=n; ++i) cerr << A[i] << ' '; cerr << '\n';
#define PR0(A, n) cerr << #A << " = "; for (int i=0; i<n; ++i) cerr << A[i] << ' '; cerr << '\n';

const int inf = 1e9;
const int maxn = 2002;

int n, f[maxn][maxn], pos[maxn][2], g1[maxn][2], g2[maxn][2][maxn];
pair<int, int> a[maxn];

int dp(int x, int y) {
	if (x==n && y==n)
		return 0;
	if (f[x][y]>-1)
		return f[x][y];
	int res = inf;
	if (x<n) {
		res = min(res, dp(x+1, y) + g1[x+1][0]+g2[x+1][0][y+1]);
	}
	if (y<n) {
		res = min(res, dp(x, y+1) + g1[y+1][1]+g2[y+1][1][x+1]);
	}
	return f[x][y] = res;
}

int main() {
	//freopen("data.inp", "r", stdin);
	//freopen("data.out", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for (int i=1; i<=2*n; ++i) {
		char c;
		cin >> c >> a[i].first;
		a[i].second = (c=='W' ? 0 : 1);
		pos[a[i].first][a[i].second] = i;
	}
	for (int i=1; i<=n; ++i) {
		for (int j=0; j<2; ++j) {
			for (int t=i+1; t<=n; ++t) {
				g1[i][j] += (pos[t][j]<pos[i][j]);
			}
			for (int t=n; t>=1; --t) {
				g2[i][j][t] = g2[i][j][t+1] + (pos[t][j^1]<pos[i][j]);
			}
		}
	}
	//debug(pos[3][1]);
	//debug(g2[1][0][3]);
	memset(f, -1, sizeof(f));
	//debug(dp(0, 3));
	cout << dp(0, 0);
}

Measured memory_bytes: 47488
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	
	
    public static void main(String[] args) {
    	FastScanner sc = new FastScanner();
    	
    	int N = sc.nextInt();
    	int[] Y = new int[N];
    	int[] C = new int[N];
    	
    	for(int i=0;i<N;i++){
    		Y[i] = sc.nextInt();
    	}
    	
    	for(int i=0;i<N;i++){
    		C[i] = sc.nextInt();
    	}
    	
    	int s = 0;
    	
    	for(int i=0;i<N;i++){
    		if(Y[i]>C[i]){
    			s += Y[i]-C[i];
    		}
    	}
    	
    	System.out.println(s);
    }
    
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    int c = 0;
    for (int i = 1; i <= n; i++) {
        if (a[i] == i) {
            c++;
            i++;
        }
    }

    cout << c << endl;
}


Measured memory_bytes: 640
N, K = list(map(int, input().split()))
a = list(map(int, input().split()))

MOD = 10 ** 9 + 7
DP = [[0] * (K + 1) for _ in range(N)]

for i in range(a[0] + 1):
  DP[0][i] = 1

L = [0] * (K + 1)
for i in range(1, N):
  L[0] = 1
  for j in range(1, K + 1):
    L[j] = (DP[i - 1][j] + L[j - 1]) % MOD
  x = a[i]
  for j in range(K + 1):
    if j <= x:
      DP[i][j] = L[j]
    else:
      DP[i][j] = L[j] - L[j - x - 1]
      while DP[i][j] < MOD:
        DP[i][j] += MOD

print(DP[N - 1][K] % MOD)

Measured memory_bytes: 118640
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

# code here
# a, b = map(int, input().strip().split())
n = int(input())
N = map(int, input().strip().split())

s = 0
for n in N:
    c = 0
    d, r = divmod(n, 2)

    while r == 0:
        d, r = divmod(d, 2)
        c += 1
    s += c

print(s)


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long h,sum=0;
	cin>>h;
	long long power=0;
	while(h>1)
	{
		power++;
		h/=2;
	}
	sum=pow(2,power+1)-1;
	cout<<sum;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>

#define rep(i, b) for(int i = 0; i < b; i++)
#define repi(i, a, b) for(int i = a; i < b; i++)
#define all(c) c.begin(),c.end()
#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 MAX_V 1001
#define MAX_E 401
#define INF INT_MAX
#define MOD 998244353
#define EPS 1e-7

typedef long long ll;
inline int toInt(std::string s) { int v; std::istringstream sin(s); sin >> v; return v; }
template<class T> inline std::string toString(T x) { std::ostringstream sout; sout << x; return sout.str(); }
using namespace std;

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
#define X real()
#define Y imag()
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template< typename T >
struct edge {
	int src, to;
	T cost;

	edge(int to, T cost) : src(-1), to(to), cost(cost) {}

	edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

	edge &operator=(const int &x) {
		to = x;
		return *this;
	}

	operator int() const { return to; }
};
template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

int main()
{
	int a, b;
	cin >> a >> b;
	if (a + b == 15)
	{
		cout << "+" << endl;
	}
	else if (a*b == 15)
	{
		cout << "*" << endl;
	}
	else {
		cout << "x" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<int,bool> used;
int a[222222];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(!used[a[i]])
			used[a[i]]=true;
		else{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 10368
N, M = gets.split.map(&:to_i)
red = {}
red[1] = 1
balls = Array.new(N+1, 1)
M.times do |i|
    x, y = gets.split.map(&:to_i)
    red[y] = true if red[x]
    balls[x] -= 1
    balls[y] += 1
    red[x] = false if balls[x] == 0
end
puts red.keys.count{|k|red[k]}

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

using namespace std;

#define forn(a, e) for (i64 a = 0; a < (i64)(e); a++)
#define forr(a, s, e) for (int a = s; a < (int)(e); a++)
#define fore(e, a) for (auto& e : a)

#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; fore(e, a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; fore(r, a) { fore(e, r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; fore(e, a) { cerr << e.field << " ";} cerr << "\n"; }
#define logvff(a, f1, f2) {cerr << #a".{"#f1 << ", "#f2 << "} = \n"; fore(e, a) { cerr << "(" << e.f1 <<", " << e.f2 << ") ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logvff(a, f1, f2)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif

using i64 = long long;
using iip = pair<i64, i64>;
using ivec = vector<int>;
using llvec = vector<i64>;
using svec = vector<string>;
template<typename T> using vec = vector<T>;

template<typename T, typename Dim>
auto make_vec(T value, Dim dim) { return vector<T>(dim, value); }
template<typename T, typename Dim1, typename... Dim>
auto make_vec(T value, Dim1 dim1, Dim... dims) { return make_vec(make_vec(value, dims...), dim1); }

template<typename T>
bool uax(T& v, const T& newv) { if (v < newv) { v = newv; return true; } else return false; }
template<typename T>
bool uin(T& v, const T& newv) { if (v > newv) { v = newv; return true; } else return false; }

// template<typename T>
// istream& operator>>(istream& is, vector<T>& c) { for (auto& e : c) is >> e; return is; }

// template<typename ...T>
// istream& read(T&... args) { return (cin >> ... >> args); }

static mt19937 rande(123123);
template<typename T>
T rand_int(T from, T to) { uniform_int_distribution<T> distr(from, to); return distr(rande); }

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

  i64 n, a, b;
  while (cin >> n >>  a >> b) {
    if (abs(a - b) % 2 == 0) {
      cout << abs(a - b) / 2 << endl;
    } else {
      if (a > b) {
        swap(a, b);

      }
      i64 ra = a - 1;
      i64 rb = n - b;
      i64 ans = min(ra, rb) + 1 + (b - a - 1) / 2;
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 256
N=int(input())
W=[int(i) for i in input().split()]
a=sum(W)
ans=10**9
for i in range(N):
    s=0
    for j in range(i+1):
        s+=W[j]
    t=a-s
    #print(i,t,s)
    ans=min(ans,abs(s-t))
print(ans)

Measured memory_bytes: 40468
N, K = map(int,input().split())
S = input()

if S[K-1] == 'A':
    tmp = 'a'
elif S[K-1] == 'B':
    tmp = 'b'
else:
    tmp = 'c'
if K == 1:
    ans = tmp + S[K:]
elif K < N:
    ans = S[:K-1] + tmp + S[K:] 
elif K == N:
    ans = S[:K-1] + tmp
print(ans)

Measured memory_bytes: 3064
// AOJ 1172 "チェビシェフの定理" (ICPC国内予選 2011 Problem A)
import java.util.Scanner;
import java.util.BitSet;

public class Main {
    static BitSet isNotPrime; // 素数でないならtrue
    static final int MAX_N = 123456;
    
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        
        isNotPrime = new BitSet(MAX_N * 2 + 1);
        sieve();
        while (true) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }
            
            int ans = 0;
            for (int i = n + 1; i <= 2 * n; i++) {
                if (!isNotPrime.get(i)) {
                    ans++;
                }
            }
            System.out.println(ans);
        }
    }
    
    public static void sieve() {
        isNotPrime.set(0);
        isNotPrime.set(1);
        for (int i = 2; i < MAX_N; i++) {
            if (!isNotPrime.get(i)) {
                for (int j = i * 2; j <= MAX_N * 2; j += i) {
                    isNotPrime.set(j);
                }
            }
        }
    }
}

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

int main(void) {
  int N;
  cin >> N;
  vector<int> c(N),s(N),f(N);
  for (int i = 0; i < N-1; i++) {
    cin >> c[i] >> s[i] >> f[i];
  }

  for (int i = 0; i < N-1; i++) {
    int t = 0;
    for (int j = i; j < N-1; j++) {
      if (t < s[j]) {
        t = s[j] + c[j];
      } else {
        if (t % f[j] == 0) {
          t += c[j];
        } else {
          t = ((t / f[j]) + 1) * f[j] + c[j];
        }
      }
    }
    cout << t << endl;
  }cout << 0 << endl;
  
  return 0;
}

Measured memory_bytes: 256