akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var A = sc.ReadDouble();
        var B = sc.ReadDouble();
        var X = sc.ReadDouble();

        var h = X / (A * A);
        var m = B - h;

        if (h == m)
        {
            Console.WriteLine(45);
        }
        else if (h > m)
        {
            // 半分より多いとき
            var p = B - (h - m);
            var ans = ToAngle(Math.Atan(p / A));
            Console.WriteLine(ans);
        }
        else
        {
            // 半分以下のとき
            var s = A * h;
            var q = s / B * 2;
            var ans = 90 - ToAngle(Math.Atan(q / B));
            Console.WriteLine(ans);
        }
    }

    static double ToAngle(double radian)
    {
        return (double)(radian * 180 / Math.PI);
    }

    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath> 
#include <queue>
#include <functional>

using namespace std;
typedef long long ll;
//typedef pair<int, int> P;
static const int dx[4] = {1, -1, 0, 0};
static const int dy[4] = {0, 0, 1, -1};


int main() {

    int n;
    cin >> n;

    vector<ll> x(n), y(n);

    for (int i = 0; i < n; i++) scanf("%lld", &x[i]);
    for (int i = 0; i < n; i++) scanf("%lld", &y[i]);

    ll x_sum = accumulate(x.begin(), x.end(), 0LL);
    ll y_sum = accumulate(y.begin(), y.end(), 0LL);

    ll cnt = y_sum - x_sum;

    bool can = true;
    
    ll cnt_y = cnt, cnt_x = cnt * 2;
    ll temp;
    for (int i = 0; i < n; i++) {
        if (x[i] == y[i]) continue;
        else if (x[i] < y[i]) {
            temp = y[i] - x[i];
            if (temp % 2 != 0) {
                cnt_y--;
                temp++;
            }
            cnt_x -= temp;
        }
        else {
            temp = x[i] - y[i];
            cnt_y -= temp;
        }
    }

    if (cnt_x != cnt_y or cnt_x < 0 or cnt_y < 0) {
        can = false;
    }

    if (can) cout << "Yes\n";
    else cout << "No\n";
}


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

int main(){
	int m,f,b;
	cin >> m >> f >> b;

		if( m >= b )
		{
		cout << "0" << endl;
		}else{
			if( m + f >= b )
			{
			cout << b - m << endl;
			}else{
			cout << "NA" << endl;
			}
		}

}


Measured memory_bytes: 3124
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#include <set> 

using namespace std;

#define int long long
#define val(x) cout << #x << " equals to " << x << endl
#define F first
#define S second
#define pb push_back

const int N = 2e6 + 7;
const int INF = 1e18;

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  #ifndef ONLINE_JUDGE
    // freopen("/home/emrey/Coding/IO/in.txt", "r", stdin);
    // freopen("/home/emrey/Coding/IO/out.txt", "w", stdout);
  #endif
  
  int n, m;
  cin >> n >> m;
  cout << ((n * (n - 1) / 2) + (m * (m - 1) / 2)) << endl;
}


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

int main()
{
	string s,S;
	cin >> s;
	S = s;
	string ans;
	int t,i;
	int slong = s.size();
	int count = 0;
	vector<int> check(s.size(), 0);
	for (t = 0; t < slong; t++) {
		count = 1;
		for (i = 0; i < t; i++) {
			if (s[i] == s[t]) {
				check[i] = 0;
				count++;
			}
		}
		if (count % 2 == 1)
			check[t] = 1;
		else
			check[t] = 0;
	}
	int tes = 0;
	for (t = 0; t < slong; t++) {
		if (check[t] == 1)
			tes = 1;
	}

	if (tes == 1) {
		cout << "No";
	}
	else {
		cout << "Yes";
	}
	return 0;
	
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

int W,H,x,y,r;

scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);   

if((W-x>=r&&x>=r)&&(H-y>=r&&y>=r)){  

printf("Yes\n");

}  

else{   

printf("No\n");  

}

return 0;

}
 

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

#define INF 0x3f3f3f3f
#define ii pair<int,int >
#define MAXN 100005

int memo[MAXN], a[MAXN];
int n, k;

int f(int idx){

	if(idx == n) return 0;
	if(memo[idx] != -1) return memo[idx];
	int ans = INF;
	for(int i=1; i<=k; i++){
		if(idx+i <= n) ans = min(f(idx+i) + abs(a[idx] - a[idx+i]), ans);
	}
	return memo[idx] = ans;
}

int main(){

	while(cin >> n >> k){
		//cout << n << endl;
		memset(memo, -1, sizeof(memo));
		for(int i=1; i<=n; i++) cin >> a[i];
		cout << f(1) << endl;
	}	

	return 0;
}

Measured memory_bytes: 5760
import java.util.Scanner;
//import java.io.*;
//import java.util.Arrays;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		//InputStreamReader is = new InputStreamReader(System.in);
		//BufferedReader br = new BufferedReader(is);
		//String text = scan.next();
		while(scan.hasNext()){
			int a[] = new int[4];
			int b[] = new int[4];
			int hit = 0;
			int bur = 0;
			for(int i = 0 ; i < 4 ; i++){
				a[i] = scan.nextInt();
			}
			for(int i = 0 ; i < 4 ; i++){
				b[i] = scan.nextInt();
			}
			for(int i = 0 ; i < 4 ; i++){
				for(int j = 0 ; j < 4 ; j++){
					if(a[i] == b[j]){
						if(i == j){
							++hit;
						}else{
							++bur;
						}
					}
				}
			}
			System.out.println(hit + " " + bur);
		}
	}
}

Measured memory_bytes: 25916
#include <iostream>
using namespace std;
int main(){
  int x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2;
  int vecx = x2-x1;
  int vecy = y2-y1;
  int x3,y3,x4,y4;
  x3 = x2-vecy;
  y3 = y2+vecx;
  x4 = x3-vecx;
  y4 = y3-vecy;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
il = lambda: list(map(int, input().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]

n, x = il()
a = il()
ans = 0
if a[0] > x:
    ans += a[0] - x
    a[0] = x
for i in range(n-1):
    wa = a[i] + a[i+1]
    if wa > x:
        a[i+1] -= wa - x
        ans += wa - x
print(ans)

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

int main(){
    int n, i, s = 0;
    cin >> n;
    int l[2*n];
    for(i=0; i<2*n; i++){
        cin >> l[i];
    }
    sort(l, l+2*n);
    for(i=0; i<n; i++){
        s += l[i*2];
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split(' '))
A = list(map(int,input().split(' ')))
l = [list(map(int,input().split())) for i in range(M)]

A.sort()
l = sorted(l,key = lambda x:x[1])

ind =0
for b,c in l[::-1]:
    mx = min(N,ind+b)
    for i in range(ind,mx):
        if c>A[i]:
            A[i] = c
    if mx==N:
        break
    ind += b
print(sum(A))

Measured memory_bytes: 33732
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# s = input()


N = int(input())
A = list(map(int, input().split()))

ans = 1
ind = 0
flag = 0
bef = 0

while ind < N:
	now = A[ind]
	if bef == 0:
		bef = now
	elif flag == 0:
		if now == bef:
			()
		elif now < bef:
			bef = now
			flag = -1
		else:
			bef = now
			flag = 1
	elif now != bef:
		if flag == 1:
			if now < bef:
				ans += 1
				flag = 0
		elif flag == -1:
			if now > bef:
				ans += 1
				flag = 0
	bef = now
	ind += 1
print(ans)


Measured memory_bytes: 14228
#pragma GCC optimize("Ofast")
#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()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<pll> P(N);
    rep(i,N) {
        cin >> P[i].first;
        P[i].second = i;
    }

    set<int> dic;
    dic.emplace(-1);
    dic.emplace(N);
    sort(all(P));
    vector<pll> A(N),B(N,make_pair(-1,N));
    for (int i = N-1; i >= 0; i--) {
        A[i].first = *prev(dic.lower_bound(P[i].second));
        if (A[i].first != -1) B[i].first = *prev(prev(dic.lower_bound(P[i].second)));
        A[i].second = *dic.upper_bound(P[i].second);
        if (A[i].second != N) B[i].second = *next(dic.upper_bound(P[i].second));
        dic.emplace(P[i].second);
    }
    
    ll ans = 0;
    for (ll i = N-2; i >= 0; i--) {
        ans += (i+1LL)*((A[i].first-B[i].first)*(A[i].second-P[i].second) + (P[i].second-A[i].first)*(B[i].second-A[i].second));
    }

    cout << ans << endl;
}

Measured memory_bytes: 9600
package main

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

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	aStr := stdin.Text()
	stdin.Scan()
	s := stdin.Text()

	a, _ := strconv.Atoi(aStr)
	if a >= 3200 {
		fmt.Println(s)
	} else {
		fmt.Println("red")
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

int table[30] = {0};

int main(void)
{
  int n, m;
  int result = 0;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int a;
      cin >> a;
      table[a]++;
    }
  }
  for (int i = 0; i <= m; i++) {
    if (table[i] == n) {
      result++;
    }
  }

  cout << result << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>

using namespace std;

template<typename T, typename S>
istream& operator >> (istream& is, pair<T, S>& p) {
    is >> p.first >> p.second;
    return is;
}

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

template<typename T>
ostream& operator << (ostream& os, const vector<T>& v) {
    for (auto& x : v) {
        os << x << " ";
    }
    os << "\n";
    return os;
}

using ld = long double;

struct Point {
    ld x, y;

    Point () {}

    Point(ld x, ld y): x(x), y(y) {}

    Point operator + (const Point& other) const {
        return {x + other.x, y + other.y};
    }

    Point operator - () const {
        return {-x, -y};
    }

    Point operator - (const Point& other) const {
        return *this + (- other);
    }

    ld operator * (const Point& other) const {
        return x * other.x + y * other.y;
    }

    ld len () const {
        return sqrt(*this * *this);
    }
};

struct Edge {
    int s, t;
    ld c;
};

const ld INF = 1e12;
using pldi = pair<ld, int>;

vector<ld> dijkstra(int v, const vector<vector<Edge>>& e) {
    vector<ld> dist(e.size(), INF);
    dist[v] = 0;

    set<pldi> grey;
    grey.insert({0.0, v});
    while (!grey.empty()) {
        auto [du, u] = *grey.begin();
        grey.erase(grey.begin());
        for (auto edge : e[u]) {
            int t = edge.t;
            ld c = edge.c;
            if (dist[t] > du + c) {
                grey.erase({dist[t], t});
                dist[t] = du + c;
                grey.insert({dist[t], t});
            }
        }
    }
    return dist;
}

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

#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    Point S, T;
    cin >> S.x >> S.y >> T.x >> T.y;
    int n;
    cin >> n;
    vector<Point> ps(n);
    vector<ld> rs(n);
    for (int i = 0; i < n; ++i) {
        cin >> ps[i].x >> ps[i].y >> rs[i];
    }
    vector<vector<Edge>> e(n + 2);
    {
            int u = n + 1;
            int v = n;
            ld d = max((ld)0.0, (T - S).len());
            e[u].push_back({u, v, d});
            e[v].push_back({v, u, d});
    }
    for (int i = 0; i < n; ++i) {
        {
            int u = i;
            int v = n;
            ld d = max((ld)0.0, (ps[i] - S).len() - rs[i]);
            e[u].push_back({u, v, d});
            e[v].push_back({v, u, d});
        }
        {
            int u = i;
            int v = n + 1;
            ld d = max((ld)0.0, (ps[i] - T).len() - rs[i]);
            e[u].push_back({u, v, d});
            e[v].push_back({v, u, d});
        }
        for (int j = i + 1; j < n; ++j) {
            ld d = max((ld)0.0, (ps[i] - ps[j]).len() - rs[i] - rs[j]);
            e[i].push_back({i, j, d});
            e[j].push_back({j, i, d});
        }
    }
    auto dist = dijkstra(n, e);
    cout << setprecision(10) << fixed << dist[n + 1];

}


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

using namespace std;

int main () {	
	long long n, x;
	cin >> n >> x;
	long long ans = 0;
	while (x != 0) {
		ans += ((n - x) / x) * 3 * x;
		n = (n % x + x);
		x = n - x;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>  
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <bitset>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
const double PI=acos(-1.0);

typedef long long Int;
typedef long long LL;
typedef unsigned long long UINT;
typedef vector <int> VI;
typedef pair <int, int> PII;
typedef pair <double, double> PDD;

const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 1007;
const int MAX1 = 2007;
const int MAX2 = 24000000;
const int LEN = 21;
const int BASE = 1000000000;

int get(int n, int m)
{
  return !(m & (n-m));
}


int main()
{
  // FOR (i,0,10)
  // {
  //   FOR (j,0,i+1)
  //     cout << get(i, j);
  //   cout << endl;
  // }

  int n;
  cin >> n;

  string s;
  cin >> s;

  int res1 = 0, res2 = 0;
  int any = 0;
  FOR (i,0,SZ(s))
    if (s[i] == '2')
    {
      any = 1;
      res1 ^= get(n-1, i);
    }
    else
    if (s[i] == '3')
    {
      res2 ^= get(n-1, i);
    }

  if (res1)
  {
    cout << 1 << endl;
    return 0;
  }

  if (any)
  {
    cout << 0 << endl;
    return 0;
  }

  if (res2)
  {
    cout << 2 << endl;
    return 0;
  }

  cout << 0 << endl;


  
  
  return 0;
}


Measured memory_bytes: 1412
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,D,ans=0;
  cin>>N>>D;
  vector<vector<int>> x(N,vector<int>(D));
  for(int i=0;i<N;i++){
    for(int j=0;j<D;j++){
      cin>>x[i][j];
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<i;j++){
      int d2=0;
      for(int k=0;k<D;k++){
        d2+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      }
      for(int k=0;k<5000;k++){
        if(k*k==d2)ans++;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
def update(tree, index, value):
    while index < len(tree):
        tree[index] = max(tree[index], value)
        index += index & -index


def read(tree, index):
    value = 0
    while index > 0:
        value = max(value, tree[index])
        index -= index & -index
    return value


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    h = read_ints()
    a = read_ints()
    tree = [0]*(N+1)
    max_beauty = 0
    for i in range(N):
        beauty = read(tree, h[i])+a[i]
        update(tree, h[i], beauty)
        max_beauty = max(max_beauty, beauty)
    return max_beauty


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 118876
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a,int b){return a*b/gcd(a,b);}

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,m;
    cin >> n >> m;
    if(n>=m)
    {
        cout << 0 << endl;
        return;
    }
    vi x(m);
    rep(i,m)cin >> x[i];
    RSORT(x);
    int ans=x[0]-x[m-1];
    vi sa(m-1);
    rep(i,m-1)
    {
        sa[i]=x[i]-x[i+1];
    }
    RSORT(sa);
    int sum_sa=0;
    rep(i,n-1)
    {
        sum_sa+=sa[i];
    }
    cout << ans - sum_sa << endl;
}

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

typedef pair<int, int> pii ;

struct edge
{
  int to, cost;
};

int main()
{
  int n, k;
  while (cin >> n >> k, n){
    int d[100];
    vector<edge> G[100];
    priority_queue<pii, vector<pii>, greater<pii> > q;

    for (int i = 0; i < k; i++){
      int a, b, c;
      cin >> a >> b >> c;
      b--; c--;

      if (a) {
        int e;
        cin >> e;

        edge E;
        E.to = c; E.cost = e;
        G[b].push_back(E);
        E.to = b;
        G[c].push_back(E);

      } else {
        fill(d, d + n, 1e9);
        d[b] = 0;
        q.push(make_pair(0, b));

        while (!q.empty()) {
          pii p = q.top(); q.pop();
          int v = p.second;
          if (d[v] < p.first) continue;
          for (int i = 0; i < G[v].size(); i++){
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
              d[e.to] = d[v] + e.cost;
              q.push(make_pair(d[e.to], e.to));
            }
          }
        }
        
        cout << (d[c] == 1e9 ? -1 : d[c]) << endl;
      }
    }
  }
}

Measured memory_bytes: 3160
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VLL a(n);
    REP(i,0,n) cin >> a[i];   
    int cnt = 0;
    REP(i,0,n) cnt += (i % 2 == 0 && a[i] % 2 == 1);
    cout << cnt << endl; 
}

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

Measured memory_bytes: 3628
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(Ofast)
#pragma GCC optimize("inline")
#include<bits/stdc++.h>
#define getchar gc
using namespace std;
const int L=1000000;
char LZH[L],*SSS,*TTT;
inline char gc(){if (SSS==TTT) TTT=(SSS=LZH)+fread(LZH,1,L,stdin);return *SSS++;}
inline int read(){
	int res=0,pd=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')pd=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){res=res*10+ch-'0';ch=getchar();}
	return res*pd;
}
int a[100003];
inline bool cmp(int x,int y){return x>y;}
inline void Yes(){puts("First");}
inline void No(){puts("Second");}
signed main(){
	int n=read();
	for (int i=1;i<=n;++i) a[i]=read();
	sort(a+1,a+n+1,cmp);
	for (int i=1;i<=n;++i) if (i+1>a[i+1]){
		if ((a[i]-i)%2) Yes();
		else{
			int now=i+1,flag=0;
			while(a[now]==i) flag^=1,now++;
			if (flag) Yes();else No();
		}
		return 0;
	}
	return 0;
} 

Measured memory_bytes: 1664
#include <stdio.h>
#define MAX 5000000
void maxHeapify(int );
void buildMaxHeap(void); 
int par(int);
int le(int );
int ri(int );

int T[MAX],howm;

int main(){
  int i,j,p,l,r;
  scanf("%d",&howm);
  for(i=1;i<=howm;i++){
    scanf("%d",&T[i]);
  }
  buildMaxHeap();
  
  for(i=1;i<=howm;i++){
    printf(" %d",T[i]);
    /*if(i!=howm){
      printf(" ");
    }
    */
  }
    printf("\n");  
  return 0;
}


int par(int i){
  return i/2;
}

int le(int i){
  return i*2;
}

int ri(int i){
  return i*2+1;
}

void buildMaxHeap(void){
  for(int i=howm/2;i>=1;i--){
    maxHeapify(i);
  }
}

void maxHeapify(int i){
  int l,r,largest,tr;
  l=le(i);
  r=ri(i);
  if(l<=howm && T[l]>T[i]){
    largest=l;
  }
  else{
    largest=i;
  }
  if(r<=howm && T[r]>T[largest]){
    largest=r;
  }
  if(largest!=i){
    tr=T[i];
    T[i]=T[largest];
    T[largest]=tr;
    maxHeapify(largest);
  }
}



Measured memory_bytes: 3816
#include<stdio.h>
int CO[100010];
int R=1,C=1,H[1000010]={0};
int N[1000010]={-1000};
//ヒープに入れる
void hin(int a){
  int i=C++;
  for(N[R]=a;a<N[H[i/2]];i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//ヒープから最小値を取り出す
int hout(){
  int rt=H[1],nt=1,i=0,k=H[--C];
  while(nt-i){
    H[i=nt]=k;
    if(i*2  <C&&N[  k  ]>N[H[i*2  ]])H[i]=H[nt=i*2  ];
    if(i*2+1<C&&N[H[nt]]>N[H[i*2+1]])H[i]=H[nt=i*2+1];
  }
  return rt;
}
void dijk(int v,int e,int *a,int *to,int *co,int mi){
  int i,j,id[100010],ta[100010],nt[100010],f[100010]={0};
  for(i=0;i<v;i++)ta[i]=-1;
  for(i=0;i<v;i++)CO[i]=1000000000;
  for(i=0;i<e;i++){
    nt[i]=ta[a[i]];
    ta[a[i]]=i;
  }
  CO[mi]=0;
  for(i=1;i<v;i++){//printf("%d\n",mi);
    f[mi]=1;
    for(j=ta[mi];j+1;j=nt[j]){
      if(CO[to[j]]>CO[mi]+co[j])hin(CO[id[R]=to[j]]=CO[mi]+co[j]);
    }
    while(f[mi])mi=id[hout()];
  }
}
int main(){
  int n,m,fr[10000],to[10000],co[10000],a,b,c,d,i;
  scanf("%d %d",&n,&m);
  for(i=0;i<m*2;i+=2){
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);
    fr[i]=to[i+1]=a-1;
    to[i]=fr[i+1]=b-1;
    co[i]=c;
    co[i+1]=d;
  }
  scanf("%d,%d,%d,%d",&a,&b,&c,&d);
  dijk(n,m*2,fr,to,co,a-1);
  c-=d+CO[b-1];
  //for(i=0;i<n;i++)printf("%d ",CO[i]);printf("\n");
  dijk(n,m*2,fr,to,co,b-1);
  printf("%d\n",c-CO[a-1]);
  return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int l, r, d;
  cin>>l>>r>>d;
  int ans = 0;
  for(int i = l; i <= r; i++) if(i % d == 0) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

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];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int K;
  cin >> K;

  int ans = 0;
  repp(a, 1, K) {
    repp(b, 1, K) {
      repp(c, 1, K) {
        ans += gcd(a, gcd(b, c));
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h> 
 
using namespace std;
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const double EPS=1e-10;


int main(){
    int N;
    cin>>N;
    int res=INT_MAX;
    for(int A=1;A<=N-1;A++){
        int B=N-A;
        int tmp=0;
        string str=to_string(A);
        REP(i,SZ(str))tmp+=str[i]-'0';
        str=to_string(B);
        REP(i,SZ(str))tmp+=str[i]-'0';
        res=min(res,tmp);
    }
    cout<<res<<endl;
    return 0;
}


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

int main(){
    string S , T;
    cin >> S >> T;
    int A , B;
    cin >> A >> B;
    string U;
    cin >> U;

    if(U == S){
        cout << A - 1 << ' ' << B << endl;
    }

    else {
        cout << A << ' ' << B - 1 << endl;
    }

}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
src = list(map(int,input().split()))
ctr = Counter(src)

if len(ctr) > 2:
    print('No')
    exit()

if len(ctr) == 1:
    k = src[0]
    print('Yes' if 2*k <= N or k == N-1 else 'No')
    exit()

min_k, max_k = min(ctr.keys()) ,max(ctr.keys())
min_v, max_v = ctr[min_k], ctr[max_k]
if min_v > min_k:
    print('No')
else:
    print('Yes' if (max_k - min_v)*2 <= max_v else 'No')

Measured memory_bytes: 18656
func main() {
    let K = Int(readLine()!)!
    
    var sev = 7
    
    if K % 5 == 0 || K % 2 == 0 {
        print(-1)
        return
    }

    for i in 1...1000000 {
        if sev % K == 0 {
            print( i )
            return
        } else {
            sev = sev % K * 10 + 7
        }
    }
    print(-1)
}
 
main()
 


Measured memory_bytes: 7700
import java.util.Scanner;
public class Main{
	static int[][] map=new int[14][14];
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			String[] str=sc.next().split(",");
			int x=Integer.parseInt(str[0])+2;
			int y=Integer.parseInt(str[1])+2;
			int s=Integer.parseInt(str[2]);
			if(s==1){
				map[y-1][x]++;
				map[y][x-1]++;
				map[y][x]++;
				map[y][x+1]++;
				map[y+1][x]++;
			}
			if(s==2){
				for(int i=y-1;i<=y+1;i++){
					for(int j=x-1;j<=x+1;j++){
						map[i][j]++;
					}
				}
			}
			if(s==3){
				for(int i=y-1;i<=y+1;i++){
					for(int j=x-1;j<=x+1;j++){
						map[i][j]++;
					}
				}
				map[y-2][x]++;
				map[y][x-2]++;
				map[y][x+2]++;
				map[y+2][x]++;
			}
		}
		int count=0;
		int max=0;
		for(int i=2;i<12;i++){
			for(int j=2;j<12;j++){
				if(map[j][i]==0){
					count++;
				}
				if(map[j][i]>max){
					max=map[j][i];
				}
			}
		}
		System.out.println(count);
		System.out.println(max);
	}
}

Measured memory_bytes: 17156
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

S = input()

if S == "ABC":
    print("ARC")
else:
    print("ABC")


Measured memory_bytes: 67080
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    int ans = 0;
    rep(i, A, B + 1) {
        string s = to_string(i);
        string r = s;
        reverse(all(r));
        if (s == r) { ans++; }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
inline bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;cin >> n >> k;
	int ans = 0;
	while(n > 0){
		n /= k;
		ans++;
	}
	cout << ans << endl;
}

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

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, M; 
  cin >> N >> M;

  vector<vector<int>> graph(N);
  REP(i, M){
    int u, v;
    cin >> u >> v;
    u--; v--;
    graph[u].emplace_back(v);
    graph[v].emplace_back(u);
  }
  
  REP(i, N) cout << graph[i].size() << "\n";

  return 0;
}

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

using namespace std;

int main() {
	long long n, m; cin >> n >> m;
	vector<pair<long long, long long> > ab(n);
	for (int i = 0; i < n; ++i) cin >> ab[i].first >> ab[i].second;
	sort(ab.begin(), ab.end());
	long long ans = 0;
	for (int i = 0; i < n; ++i) {
		if (ab[i].second < m) ans += ab[i].first * ab[i].second, m -= ab[i].second;
		else {
			ans += ab[i].first * m;
			break;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(x => x.to!int-1).array;

    auto ans = new int[](N);
    auto used = new bool[](N);

    auto hated = new SegmentTree!(Tuple!(int, int), (a,b)=>a[0]>=b[0]?a:b, tuple(0, 0))(N);
    foreach (i; 0..N) hated.assign(i, tuple(0, i));
    foreach (i; 0..N) hated.add(A[i], 1);

    auto pq = new BinaryHeap!(Array!int, "a > b");
    foreach (i; 0..N) pq.insert(i);

    DList!int tmp;

    foreach (i; 0..N-3) {
        bool ok = false;
        auto q = hated.query(0, N-1);
        if (q[0] == N - i - 1) {
            ans[i] = q[1];
            hated.assign(q[1], tuple(0, 0));
            hated.add(A[q[1]], -1);
            used[q[1]] = true;
            continue;
        }
        while (!pq.empty) {
            auto n = pq.front;
            pq.removeFront;
            if (used[n]) continue;
            tmp.insertBack(n);
            if (i != 0 && A[ans[i-1]] == n) continue;
            ans[i] = n;
            hated.assign(n, tuple(0, 0));
            hated.add(A[n], -1);
            used[n] = true;
            while (!tmp.empty) {
                auto m = tmp.front;
                tmp.removeFront;
                if (m != n) pq.insert(m);
            }
            ok = true;
            break;
        }
        if (!ok) {
            writeln(-1);
            return;
        }
    }

    bool ok() {
        foreach (i; 0..N-1) if (ans[i+1] == A[ans[i]]) return false;
        return true;
    }

    int[] rest;
    while (!pq.empty) {
        if (!used[pq.front]) rest ~= pq.front;
        pq.removeFront;
    }
    auto len = rest.length.to!int;

    do {
        foreach (i; 0..len) ans[N-len+i] = rest[i];
        if (ok()) {
            ans.map!(a => (a+1).to!string).join(" ").writeln;
            return;
        }
    } while(nextPermutation(rest));

    writeln(-1);
}

class SegmentTree(T, alias op, T e) {
    T[] table;
    int size;
    int offset;

    this(int n) {
        size = 1;
        while (size <= n) size <<= 1;
        size <<= 1;
        table = new T[](size);
        fill(table, e);
        offset = size / 2;
    }

    void assign(int pos, T val) {
        pos += offset;
        table[pos] = val;
        while (pos > 1) {
            pos /= 2;
            table[pos] = op(table[pos*2], table[pos*2+1]);
        }
    }

    void add(int pos, int val) {
        pos += offset;
        table[pos][0] += val;
        while (pos > 1) {
            pos /= 2;
            table[pos] = op(table[pos*2], table[pos*2+1]);
        }
    }

    T query(int l, int r) {
        return query(l, r, 1, 0, offset-1);
    }

    T query(int l, int r, int i, int a, int b) {
        if (b < l || r < a) {
            return e;
        } else if (l <= a && b <= r) {
            return table[i];
        } else {
            return op(query(l, r, i*2, a, (a+b)/2), query(l, r, i*2+1, (a+b)/2+1, b));
        }
    }
}

Measured memory_bytes: 10556
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
typedef     unsigned long long  ull;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll> >      vpll;
typedef		vector<ll>      vll;
typedef		map<string,ll>      msl;
typedef		map<ll,ll>      mll;
#define yes cout << "YES\n"
#define no cout<<"NO\n"
//#define sort(x) sort(x.begin(), x.end())
//sort(a,a+n,greater<ll>())
//for (auto it = mp.begin(); it != mp.end(); ++it){}
#define MAX 1000005
#define mod 1000000007


ll ar[MAX]={0};
int main()
{
 //O_O ;
   ll n,k;cin>>n>>k;
   for(ll i=0;i<k;i++)
    {
        ll temp;cin>>temp;
        for(ll i=0;i<temp;i++)
        {
            ll temp2;cin>>temp2;
            ar[temp2]=1;
        }
    }
  ll c=0;
    for(ll i=1;i<=n;i++)
    {
        if(ar[i]==0)
            c++;
    }
    cout<<c<<nn;


    return 0;
}


Measured memory_bytes: 3636
import sys
from collections import *

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

n = int(input())
pp = LI()
xx = LI()
to = defaultdict(list)
ww = [[-1, -1] for _ in range(n)]

def dfs(u=0):
    if not len(to[u]):
        ww[u] = [xx[u], 0]
        return True
    ret_ww = set([0])
    uw = xx[u]
    sum_ret_w = 0
    for cu in to[u]:
        if not dfs(cu): return False
        new_ret_ww = set()
        for cuw in ww[cu]:
            sum_ret_w += cuw
            for ret_w in ret_ww:
                new_ret_w = ret_w + cuw
                if new_ret_w <= uw: new_ret_ww.add(new_ret_w)
        ret_ww = new_ret_ww
    if not ret_ww: return False
    ww[u] = [uw, sum_ret_w - max(ret_ww)]
    return True

def main():
    for u, p in enumerate(pp, 1):
        to[p - 1].append(u)
    # print(to)
    if dfs():
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    # print(ww)

main()


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

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	for (int x=0; x<=50000; x++) {
		int t=1.08*x;
		if(t==n) {
			cout<<x<<"\n";
			return 0;
		}
	}
	cout<<":(\n";
	return 0;
}

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


int main(){
 
  int n;
  cin >> n;
  
  int tmp;
  tmp = n % 10;
  
  if(tmp == 2 || tmp == 4 || tmp == 5 || tmp == 7 || tmp == 9){
      cout << "hon" << endl;
  }
  else if(tmp == 0 || tmp == 1 || tmp == 6 || tmp == 8){
      cout << "pon" << endl;
  }
  else{
      cout << "bon" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>

using namespace std;

#define INF 999999999

int main(){
	int N, M, t[100], h[100], st, sh, j,k, ans[2],flag;
	while(1){
		cin >> N >> M;
		if(!N)break;
		
		st=0;
		sh=0;
		for(j=0;j<N;j++){
			cin >> t[j];
			st += t[j];
		}
		for(j=0;j<M;j++){
			cin >> h[j];
			sh += h[j];
		}
		
		flag = 0;
		ans[0] = 103;
		ans[1] = 103;
		//cout << st << " " << sh << endl;
		for(j=0;j<N;j++){
			for(k=0;k<M;k++){
				if(st-t[j]+h[k] == sh+t[j]-h[k]){
					flag++;
					//cout << t[j] << " " << h[k] << endl;
					if(t[j] < ans[0]) ans[0] = t[j];
					if(h[k] < ans[1]) ans[1] = h[k];
				}
			}
		}
		if(flag>0) cout << ans[0] << " " << ans[1] << endl;
		else cout << "-1" << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
int main(){
	int n,ans;
	while(cin>>n){
		ans=0;
		rep(a,10)rep(b,10)rep(c,10)rep(d,10)
			if(a+b+c+d==n)ans++;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    cin >> N;
    vector<int> L(2 * N);
    rep(i, 0, 2 * N) cin >> L[i];
    sort(all(L));
    int ans = 0;
    for (int i = 0; i < 2 * N; i += 2)
    {
        ans += L[i];
    }
    cout << ans << endl;
}


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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  int n;
  cin >> n;
  vector<vector<int> > G;
  G.resize(n);
  for(int i = 0; i < n; i++){
    int u, k;
    cin >> u >> k;
    for(int j = 0; j < k; j++){
      int tmp;
      cin >> tmp;
      G[i].push_back(tmp);
    }
  }
  for(int i = 0; i < n; i++){
    int k = 0;
    for(int j = 0; j < n; j++){
      if(G[i].size() != 0){
        if(G[i][k] == j + 1){
          cout << 1;
          k++;
        }else cout << 0;
      }else cout << 0;
      if(j != n - 1)cout << " ";
    }

      cout << endl;
      k = 0;
  }
}

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

s=1
if min(A) == 0:
    s = 0
    print(s)
elif max(A) > 10**18:
    s = -1
    print(s)
else:
    for i in range(N):
        s = s*A[i]
        if s > 10**18:
            s = -1
            print('-1')
            break
    if s != -1:
        print(s)

Measured memory_bytes: 21712
fun main() = Thread(null, ::abc168a, "", 128 * 1024 * 1024).start()

@OptIn(ExperimentalStdlibApi::class)
fun abc168a() {
    val n = readLine()!!.toInt()

    val answer = when (n.toString().last().toString().toInt()) {
        2, 4, 5, 7, 9 -> "hon"
        0, 1, 6, 8 -> "pon"
        else -> "bon"
    }

    println(answer)
}


Measured memory_bytes: 36040