akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("trapv")
#pragma GCC target("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define deb(x) cout << #x << " is " << x << "\n"
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;

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

void solve()
{
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char>> arr(h, vector<char>(w));
    for (auto &row : arr)
    {
        for (auto &ele : row)
            cin >> ele;
    }
    int ans = 0;
    for (int maskH = 0; maskH < (1LL << h); maskH++)
    {
        for (int maskW = 0; maskW < (1LL << w); maskW++)
        {
            int curr = 0;
            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    if (((maskH & (1LL << i)) == 0) && ((maskW & (1LL << j)) == 0) && arr[i][j] == '#')
                    {
                        curr++;
                    }
                }
            }
            if (curr == k)
            {
                ans++;
            }
        }
    }
    cout << ans;
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

const int MAXN = 100001;
int a[ MAXN ];
int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    int cnt = 0;
    for (int i = 1; i <= n; ++i)
        if (a[ a[i] ] == i) ++cnt;
    cout << cnt / 2 << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N, M;
  cin >> N >> M;
  VEC<pair<int, string>> P(M);
  REP(i, 0, M) {
    cin >> P[i].first >> P[i].second;
    P[i].first--;
  }
  map<int, int> cnt;
  // DUMP(cnt);
  VEC<bool> accepted(N, 0);
  REP(i, 0, M) {
    int prob = P[i].first;
    string res = P[i].second;
    accepted[prob] = accepted[prob] || (res == "AC");
    if (!accepted[prob]) {
      cnt[prob]++;
    }
  }
  int solved = 0;
  int penalty = 0;
  REP(i, 0, N) {
    // DUMP(i, cnt[i], accepted[i]);

    if (accepted[i]) {
      penalty += cnt[i];
      solved++;
    }
  }
  cout << solved << " " << penalty << endl;

  return 0;
}


Measured memory_bytes: 11136
def firstdigit(i):
    r = i%10
    return 10 if r==0 else r
food = []
for s in range(5):
    food.append(int(input()))
food=sorted(food,key=firstdigit)
sum=food.pop(0)
for s in food:
    sum+=s-s%10+10 if s%10!=0 else s
print(sum)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main
{
	public static int Search(String S)
	{
		int result = 0;
		for(int i = 0; i < S.length() - 1; i++)
			if(S.charAt(i) == S.charAt(i+1))
				result++;
		return result;				

	}

	
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int K = in.nextInt();
		in.nextLine();
		String S = in.nextLine();
		
		System.out.println((Search(S) + 2 * K) > (N - 1) ? (N - 1): (Search(S) + 2 * K));

	}

}

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

int main(){
    int n,k;
    cin>>n>>k;
    int arr[n];
    int cnt = 0;
    for(int i=0; i<n; i++){
        cin>>arr[i];
        if(arr[i] >= k){
            cnt++;
        }
    }
    cout<<cnt<<endl;

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn=1e3+50;

struct point {
    double x,y;
    point(double x=0,double y=0):x(x),y(y){}
    bool operator < (const point &rhs)const{
        return atan2(y,x) < atan2(rhs.y, rhs.x);
    }
}p[maxn];

int main(){
    int n;cin>>n;
    FOR(i,1,n){
        scanf("%lf%lf",&p[i].x,&p[i].y);
    }
    sort(p+1,p+1+n);
    double ans=0;
    FOR(i,1,n){

        double allx=0,ally=0;
        int pos=i;
        do{
            allx+=p[pos].x;
            ally+=p[pos].y;
            ans=max(allx*allx+ally*ally,ans);
            if(pos+1<=n)pos=pos+1;
            else pos=1;
        }while(pos!=i);
    }
    printf("%.12f\n",sqrt(ans));
}

Measured memory_bytes: 384
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]
broken = [True] * n
for i in a:
    broken[i] = False
dp = [0] * (n + 1)
dp[0] = 1
for i in range(n):
    for j in range(i + 1, min(n + 1, i + 3)):
        if broken[i]:
            dp[j] += dp[i]
            dp[j] %= (10 ** 9 + 7)
print(dp[n])

Measured memory_bytes: 9620
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define int long long
typedef long long ll;
void amin(int &a, const int &b){
    a = min(a, b);
}
signed main(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    vector<int> R(K);
    vector<int> B(K);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    for(int i=0;i<K;i++){
        cin >> R[i];
    }
    for(int i=0;i<K;i++){
        cin >> B[i];
    }

    sort(A.rbegin(), A.rend());
    sort(R.rbegin(), R.rend());
    sort(B.rbegin(), B.rend());
    int INF = (int)1 << 50;
    vector<vector<vector<int> > > dp(R.size() + 1, 
    vector<vector<int> >(B.size() + 1, vector<int>(6005, INF)));
    int offset = 3002;
    dp[0][0][offset] = 0;

    vector<int> SA(N + 1, 0);
    vector<int> SR(N + K, 0);
    vector<int> SB(N + K, 0);

    for(int i=0;i<N;i++){
        SA[i + 1] = SA[i] + A[i];
    }

    for(int i=0;i<K;i++){
        SR[i + 1] = SR[i] + R[i];
        SB[i + 1] = SB[i] + B[i];
    }
    for(int i=0;i<= R.size(); i++){
        for(int j=0;j<= B.size(); j++){
            if(i + j < N){
                for(int k = -3000; k<=3000;k++){
                   

                    if(i + 1 <= R.size()){
                        //if(k + R[i] - A[i + j] >= 0){
                            amin(dp[i + 1][j][k + R[i] - A[i + j] + offset], dp[i][j][k + offset] + max((int)0, A[i + j] - R[i]));
                        //}
                    }
                    if(j + 1 <= B.size()){
                        //if(b + B[i] - A[i + j] >= 0){
                            amin(dp[i][j + 1][k + offset], dp[i][j][k + offset] + max((int)0, A[i + j] - B[j]));
                        //}
                    }
                }
            }
        }
    }
    int res = INF;
    for(int i=0;i<=N;i++){
        int j = N - i;
        if(i <= R.size() && j <= B.size()){
            
            for(int k = -(SR[R.size()] - SR[i]) ; k <= 3000; k++){
                int b = SR[i] + SB[j] - SA[i + j] - k;
                if(b >= -(SB[B.size()] - SB[j])){
                    if(dp[i][j][k + offset] < INF){
                        //cerr << SA[i + j]<<endl;
                        //cerr << i <<" " << j << " " << k << " " << b << endl;
                    }
                    amin(res, dp[i][j][k + offset]);
                }
            }   
        }
    }
    if(res == INF)res = -1;
    cout << res << endl;

    return 0;
}


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

def main():
    s = sorted(list(input().strip()), reverse=False)
    t = sorted(list(input().strip()), reverse=True)

    ok = False
    same_all = True
    for i in range(min(len(s), len(t))):
        if s[i] < t[i]:
            same_all = False
            ok = True
            break
        elif s[i] > t[i]:
            same_all = False
            break
    
    if same_all:
        if len(s) < len(t):
            ok = True
    
    if ok:
        print("Yes")
    else:
        print("No")



if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
n, k = map(int, input().split())
h = [int(i) for i in input().split()]

def chmin(a, b):
    if a > b:
        return b
    else:
        return a
f_inf = pow(10,9)+99

dp = [f_inf] * (n+1)
dp[0] = 0
for i in range(1, n):
    for j in range(1, k+1):
        if i - j >= 0:
            dp[i] = chmin(dp[i], dp[i-j]+ abs(h[i] - h[i - j]))
print(dp[n-1])


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string S,T;

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

	cin >> S >> T;

	for (int i = S.size()-T.size();i >= 0;i--){
		bool flag = true;
		for (int j = 0;j < T.size();j++){
			if(S[i+j] != T[j] && S[i+j] != '?'){ flag = false; break;}
		}
		if(flag){
			for (int j = 0;j < i;j++){
				if(S[j] == '?') cout << 'a';
				else cout << S[j];
			}
			for (int j = 0;j < T.size();j++){
				cout << T[j];
			}
			for (int j = i+T.size();j < S.size();j++){
				if(S[j] == '?') cout << 'a';
				else cout << S[j];
			}
			cout << endl;
			return 0;
		}
	}

	cout << "UNRESTORABLE" << endl;

	return 0;

}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EWhoSaysAPun solver = new EWhoSaysAPun();
        solver.solve(1, in, out);
        out.close();
    }

    static class EWhoSaysAPun {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            char[] s = in.next().toCharArray();

            int answer = 0;
            for (int i = 0; i < n; i++) {
                int[] z = Strings.zAlgorithm(s, i);
                for (int j = 0; j < z.length; j++) {
                    answer = Math.max(answer, Math.min(j, z[j]));
                }
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }

    static class Strings {
        private Strings() {
        }

        public static int[] zAlgorithm(char[] s, int offset) {
            int n = s.length - offset;
            int[] z = new int[n];
            z[0] = n;

            for (int i = 1, l = -1, r = -1; i < n; i++) {
                z[i] = r > i ? Math.min(r - i, z[i - l]) : 0;
                while (i + z[i] < n && s[offset + i + z[i]] == s[offset + z[i]])
                    z[i]++;
                if (i + z[i] > r) {
                    l = i;
                    r = i + z[i];
                }
            }
            return z;
        }

    }
}



Measured memory_bytes: 44596
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

using P = pair<int, int>;
int main(){
	int H, W;
	cin >> H >> W;
	int sh, sw, gh, gw;
	cin >> sh >> sw >> gh >> gw;
	sh--; sw--; gh--; gw--;

	vector<string> maze(H);
	for(int i=0; i<H; i++) cin >> maze[i];

	int dh[] = {-1, 0, 1, 0};
	int dw[] = {0, -1, 0, 1};
	const int INF = 1e6 + 1;
	vector<vector<int>> cost(H, vector<int>(W, INF));
	cost[sh][sw] = 0;
	deque<P> deq;
	deq.push_front(P(sh, sw));
	while(!deq.empty()){
		int h = deq.front().first;
		int w = deq.front().second;
		deq.pop_front();
		
		for(int i=0; i<4; i++){
			int nh = h + dh[i];
			int nw = w + dw[i];
			if(nh < 0  ||  H <= nh) continue;
			if(nw < 0  ||  W <= nw) continue;
			if(maze[nh][nw] == '#') continue;
			if(cost[nh][nw] <= cost[h][w]) continue;
			cost[nh][nw] = cost[h][w];
			deq.push_front(P(nh, nw));
		} 

		for(int _h=-2; _h<=2; _h++){
			for(int _w=-2; _w<=2; _w++){
				int nh = h + _h;
				int nw = w + _w;
				if(nh < 0  ||  H <= nh) continue;
				if(nw < 0  ||  W <= nw) continue;
				if(maze[nh][nw] == '#') continue;
				if(cost[nh][nw] <= cost[h][w] + 1) continue;
				cost[nh][nw] = cost[h][w] + 1;
				deq.push_back(P(nh, nw));
			}
		}
	

	}

	int ans = cost[gh][gw];
	if(ans == INF) ans = -1;
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 9456
N, K = map(int,input().split())
List = []
for i in range(1,N+1):
  List.append(i)

List_All = []
  
for i in range(K):
  d = int(input())
  A = list(map(int,input().split()))
  for j in range(d):
    List_All.append(A[j])

count = 0
for i in range(N):
  if List_All.count(List[i]) == 0:
    count += 1

print(count)

Measured memory_bytes: 9208
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		for (int i = 0; i < 5; i++) {
			if (sc.nextInt() == 0) {
				System.out.print(i + 1);
				break;
			}
		}
		sc.close();
	}

}


Measured memory_bytes: 35724
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int main(){
    int X,Y;
    cin >> X >> Y;
    cout << X + Y/2 << endl;
    return 0;
}


Measured memory_bytes: 256
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();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();
        int f = sc.nextInt();
      
      	int neta = a * 100;
      	int netb = b * 100;
      
      	List<Integer> wlist = new ArrayList<>();
      	List<Integer> slist = new ArrayList<>();
      
      	for(int i = 0; i <= f / neta; i++){
          for(int j = 0; j <= f / netb; j++){
            int total = neta * i + netb * j;
            if(total <= f) wlist.add(total);
          }
        }
      
      	for(int i = 0; i <= f / c; i++){
          for(int j = 0; j <= f / d; j++){
            int total = c * i + d * j;
            if(total <= f) slist.add(total);
          }
        }
      
      	float rate = 0;
      	int total = 0;
      	int s = 0;

        for(int i = 0; i < wlist.size(); i++){          
          for(int j = 0; j < slist.size(); j++){
            if(wlist.get(i) == 0) continue;
            if(wlist.get(i) + slist.get(j) > f) continue;
            if(100 * slist.get(j) > wlist.get(i) * e) continue;
            
            if(slist.get(j) == 0 && rate == 0){
              total = wlist.get(i);
            }
            
            if(100 * slist.get(j) > rate * wlist.get(i)){
              rate = 100 * slist.get(j) / (float)wlist.get(i);
              total = slist.get(j) + wlist.get(i);
              s = slist.get(j);
            }
          }
        }

        System.out.println(total + " " + s);
	}
}

Measured memory_bytes: 27596
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

lst = inputs[1]

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
  p lst
end

def proc(arr)
  return arr[0] if arr.size == 1
  
  min = arr.min
  for i in 0..arr.size-1
    arr[i] -= min
  end

  subarr = []
  head = 0
  tail = 0
  while head < arr.size
    while arr[head] != 0 and head < arr.size
      head += 1
    end
    if arr[tail] != 0
      subarr << arr[tail..head-1].clone
    end
    head += 1    
    tail = head
  end

  pd subarr

  ret = min
  subarr.each do |arr_i|
    ret += proc(arr_i)
  end

  return ret
end

puts proc(lst)


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N;
  cin >>  N;
  
  vector<int> d(N);
  for (int i = 0; i < N; ++i) cin  >> d.at(i);
  
  int ans = 0;
  
  sort(d.begin(), d.end());
  
  int a = (N + 1) / 2;
  ans =  max(0, d.at(a) - d.at(a - 1));
    
  cout << ans ;
}

Measured memory_bytes: 640
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
3
'''

def solve(L):
	l = L/3
	w = (L - l)/2
	h = L - w - l
	return l*w*h
	

L = int(stdin.readline())
ans = solve(L)
print("%.10f"%ans)


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

int main(){
  int max = 0;
  int N,M,T;
  int a[1000];

  cin >> N >> M >> T;

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

  max = a[0] - M;
  
  for(int i=1; i<N; ++i){
    if(a[i] - a[i-1] > 2 * M){
      max += a[i] -  a[i -1] - 2*M;

      continue;
    }
  }

  if(T - a[N - 1] > M){
    max += T - a[N-1] - M;
  }
  

  
  cout << max << endl;
  
  return 0;
}



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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  long N, K;
  cin >> N >> K;
  vector<long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  long ok = -2e18, ng = 2e18;
  while (ng - ok > 1) {
    long mid = (ok + ng) / 2, sum = 0;
    for (int i = 0; i < N; i++) {
      long double tmp = (long double) mid / A.at(i);
      if (A.at(i) > 0) sum += lower_bound(A.begin(), A.end(), tmp) - A.begin();
      if (A.at(i) < 0) sum += N - (upper_bound(A.begin(), A.end(), tmp) - A.begin());
      if (A.at(i) == 0) sum += (mid > 0) ? N : 0;
      if (A.at(i) * A.at(i) < mid) sum--;
    }
    (sum / 2 < K) ? ok = mid : ng = mid;
  }
  cout << ok << "\n";
}


Measured memory_bytes: 4760
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;


const int mod=1000000007;
//const int mod=998244353;


ll pow(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}


int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,l,r,p;
    cin >> n;
    vi v(1e6+1);
    for(int i=0; i<n; i++){
        cin >> a;
        v[a]++;
    }
    for(int i=1; i<=1e6; i++){
        if(v[i]==1){
            for(int j=2*i; j<=1e6; j+=i){
                v[j]=0;
            }
        }
        else if(v[i]!=0){
            for(int j=i; j<=1e6; j+=i){
                v[j]=0;
            }
        }
    }
    cout << accumulate(all(v),0ll) << el;
    return 0;
}
    


Measured memory_bytes: 7156
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007ll
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define db(x) cout << #x << " = " << x << '\n'
#define sep cout << "********************************************\n"
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL)
int main(int argc, char const *argv[])
{
	ll n, k, a[200005];
	cin >> k >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	vll v;
	for (int i = 1; i < n; ++i)
	{
		v.pb(a[i] - a[i - 1]);
	}
	v.pb(a[0] + k - a[n - 1]);
	sort(v.begin(), v.end());
	ll ans = 0;
	for (int i = 0; i < n - 1; ++i)
	{
		ans += v[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3956
#include<stdio.h>
#define N 2000
int function(int, int);
int n, array[N];
int main()
{
  int a, arr[N], i;
  scanf("%d", &n);
  for(i=0; i<n; i++)
    {
      scanf("%d", &array[i]);
    }

   scanf("%d", &a);
   for(i=0; i<a; i++)
    {
      scanf("%d", &arr[i]);
    if(function(0, arr[i]))
           printf("yes\n");
      else
           printf("no\n");
      }
  return 0;
}

int function(int k, int m)
{
  if(array[k] == m)
     return 1;
  if(k+1 == n)
    return 0;
  if(function(k+1, m-array[k]) || function(k+1, m))return 1;
  return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <vector> 
#include <algorithm>
using namespace std;
 
int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  string S,T; cin>>S>>T;
  // int型のvectorを要素数26, 値0で初期化
  vector<int> c1(26,0), c2(26,0);
  for(int i = 0; i<S.length(); i++ ) c1[S[i]-'a']++;
  for(int i = 0; i<T.length(); i++ ) c2[T[i]-'a']++;
  sort(c1.begin(), c1.end());
  sort(c2.begin(), c2.end());
  if( c1 == c2 ) cout<<"Yes\n";
  else cout<<"No\n";
  return 0;
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B < C + D) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  for(ll i = 0; i < n; ++i) cin >> a[i];
  vector<ll> sum(a);
  for(ll i = 1; i < n; ++i) sum[i] += sum[i - 1];
 
  map<ll, ll> mp;
  for(const auto& v : sum) mp[v % m]++;

  ll ans = mp[0];
  for(const auto& m : mp)
  {
    ll v = m.second;
    ans += v * (v - 1) / 2;
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 8536
#include "bits/stdc++.h"

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];

    // 3 ^ n - odd
    int X = 1, Y = 1;
    for (int i = 0; i < N; ++i) {
        X *= 3;
        if ((A[i] & 1) == 0) Y *= 2;
    }
    cout << X - Y << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N	5000
#define M	5000
#define N_	(1 << 13)	/* N_ = pow2(ceil(log2(N))) */

long long max(long long a, long long b) { return a > b ? a : b; }

long long st[N_ * 2], lz[N_]; int h_, n_;

void put(int i, long long x) {
	st[i] += x;
	if (i < n_)
		lz[i] += x;
}

void pus(int i) {
	if (lz[i]) {
		put(i << 1, lz[i]), put(i << 1 | 1, lz[i]);
		lz[i] = 0;
	}
}

void pul(int i) {
	if (!lz[i])
		st[i] = max(st[i << 1], st[i << 1 | 1]);
}

void push(int i) {
	int h;

	for (h = h_; h > 0; h--)
		pus(i >> h);
}

void pull(int i) {
	while (i > 1)
		pul(i >>= 1);
}

void update(int l, int r, int x) {
	int l_ = l += n_, r_ = r += n_;

	push(l_), push(r_);
	for ( ; l <= r; l >>= 1, r >>= 1) {
		if ((l & 1) == 1)
			put(l++, x);
		if ((r & 1) == 0)
			put(r--, x);
	}
	pull(l_), pull(r_);
}

int main() {
	static int aa[N], bb[N][M], qu[M][N], cnt[M];
	int n, m, i, j;
	long long ans;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n - 1; i++)
		scanf("%d", &aa[i]);
	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++)
			scanf("%d", &bb[i][j]);
	h_ = 0;
	while (1 << h_ < n)
		h_++;
	n_ = 1 << h_;
	ans = 0;
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			int b, b_;

			b = bb[i][j];
			update(i, i, b);
			while (cnt[j] && (b_ = bb[qu[j][cnt[j] - 1]][j]) <= b) {
				update(cnt[j] == 1 ? 0 : qu[j][cnt[j] - 2] + 1, qu[j][cnt[j] - 1], b - b_);
				cnt[j]--;
			}
			qu[j][cnt[j]++] = i;
		}
		ans = max(ans, st[1]);
		if (i < n - 1)
			update(0, i, -aa[i]);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 26476
n, m = map(int, input().split())
mod = 10**9+7
ans = 1
if abs(n-m)== 1:
    for i in range(1, n+1):
        ans = (ans * i) % mod
    for j in range(1, m+1):
        ans = (ans * j) % mod
    print(ans)
elif n == m:
    for i in range(1, n+1):
        ans = (ans * i) % mod
    print(ans**2 * 2 % mod)
else:
    print(0)

Measured memory_bytes: 3064
using System;

namespace ITP1_1_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string inputLine = "";
            

            inputLine =Console.ReadLine();
            string[] inputNum = inputLine.Split(' ');

            int area = 0;
            int perimeter = 0;

            area = int.Parse(inputNum[0]) * int.Parse(inputNum[1]);
            perimeter = 2 * int.Parse(inputNum[0]) + 2 * int.Parse(inputNum[1]);
            Console.WriteLine(area + " " + perimeter);
           
        }
    }
}



Measured memory_bytes: 15848
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int a,b,c,i;
	while(scanf("%d %d",&a,&b) != EOF){
		c = a + b;
		for(i = 0; c != 0; i++){
			c /= 10;
		}
		cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
int main() {
  ll n, l, r, mid, x, y;
  cin >> n;
  for (ll i = 0LL; i <= 4000LL; i++) {
    x = i * i * i * i * i;
    l = -100;
    r = i;
    while (l <= r) {
      mid = (l + r) / 2LL;
      if (x - mid * mid * mid * mid * mid == n) {
        cout << i << " " << mid << endl;
        return 0;
      } else if (x - mid * mid * mid * mid * mid < n) {
        r = mid - 1LL;
      } else {
        l = mid + 1LL;
      }
    }
    if (x == l * l * l * l * l) {
      cout << i << " " << l << endl;
      return 0;
    }
    if (x == r * r * r * r * r) {
      cout << i << " " << r << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long long ll;

template <typename T> void max_self(T& a, T b){
  a = max(a,b);
}

template <typename T> void min_self(T& a, T b){
  a = min(a,b);
}

void solve(){	
  int n;cin>>n;
  if(n>=30)
    cout<<"Yes\n";
  else
    cout<<"No\n";
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //int t; cin >> t;
  //while(t--) solve();
  //
  solve();
  return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
                    
                    
int main(){
    int H, N;
    cin >> H >> N;
    vector<int> A;
    string ans = "No";
    for(int i = 0;i < N;i++){
        int a;
        cin >> a;
        A.push_back(a);
    }
    
    int A_sum = accumulate(A.begin(), A.end(), 0);

    if(A_sum >= H){
        ans = "Yes";
    }

    cout << ans << endl;
}

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

int main() {
	int N;
	double T, A;
	cin >> N >> T >> A;
	double min_value = 1LL << 60;
	int min_index = -1;
	for (int i = 0; i < N; ++i) {
		double H;
		cin >> H;
		double diff = abs((T - H * 0.006) - A);
		if (diff < min_value) {
			min_value = diff;
			min_index = i;
		}
	}
	cout << min_index + 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

int fp(int a, ll x, int m) {
    if (x == 0) {
        return 1;
    }
    if (x % 2 == 1) {
        return 1ll * a * fp(a, x - 1, m) % m;
    }
    int t = fp(a, x / 2, m);
    return 1ll * t * t % m;
}

int dc1(int a, ll x, int m) {
    if (x == 0) {
        return 0;
    }
    if (x % 2 == 1) {
        return (dc1(a, x - 1, m) + fp(a, x - 1, m)) % m;
    }
    int t = dc1(a, x / 2, m);
    return (t + 1ll * fp(a, x / 2, m) * t) % m;
}

int dc2(int a, ll x, int m) {
    if (x == 0) {
        return 0;
    }
    if (x % 2 == 1) {
        return (dc2(a, x - 1, m) + (x - 1) % m * fp(a, x - 1, m)) % m;
    }
    int t = dc2(a, x / 2, m);
    int t2 = (t + x / 2 % m * dc1(a, x / 2, m)) % m;
    t2 = 1ll * t2 * fp(a, x / 2, m) % m;
    return (t + t2) % m;
}

int main() {
    ll l, a, b;
    int m;
    cin >> l >> a >> b >> m;
    ll last = a + (l - 1) * b;

    int pow10 = 1;
    ll p = (ll)1e9 * (ll)1e9;
    int ans = 0;
    for (int i = 18; i >= 0; i--) {
        if (last >= p) {
            ll first = p / b * b + a % b;
            if (first < p) {
                first += b;
            }
            if (first < a) {
                first = a;
            }

            int tens = fp(10, i + 1, m);
            ll cnt = (last - first) / b + 1;

            int cur = last % m * dc1(tens, cnt, m) % m;
            cur = ((cur - b % m * dc2(tens, cnt, m)) % m + m) % m;
            cur = 1ll * cur * pow10 % m;
            ans = (ans + cur) % m;

            pow10 = 1ll * pow10 * fp(tens, cnt, m) % m;
            last = first - b;
            if (last < a) {
                break;
            }
        }
        p /= 10;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
//#define int long long
using LL = long long;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

int ct[2019];

signed main(){
    fastcin();

    string s;
    cin >> s;
    int n = s.size();
    reverse(all(s));
    int now = 0, pow = 1;
    ct[0] = 1;
    rep(i, n){
        now += (s[i]-'0')*pow;
        now %= 2019;
        ct[now]++;
        pow *= 10;
        pow %= 2019;
    }
    LL ans = 0;
    rep(i, 2019){
        ans += ct[i]*(ct[i]-1)/2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3756
n,m=map(int,input().split())
a=list(map(int,input().split()))

cnt=0
dic={}
dic[0]=1
aaa=0
for aa in a:
    aaa+=aa

    if aaa%m in dic:
        cnt+=dic[aaa%m]
        dic[aaa%m]+=1
    else:
        dic[aaa%m]=1
            #print(aaa,aa,aaa%m,dic)
    #print(dic)
print(cnt)



Measured memory_bytes: 62576
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
#define rep(i, m, n) for (int i = m; i < n; ++i)
const int64 INF = 1e18;

struct BellmanFord {
    struct Edge {
        int from, to;
        long long cost;
    };
private :
    int n;
    const long long INF;
    vector<Edge> edges;
public :
    vector<long long> dist;
    vector<bool> nega;
    BellmanFord(int _n, int _m, long long _INF) :
    edges(_m), dist(_n, _INF), nega(_n), n(_n), INF(_INF) {}
    void input(int i, int a, int b, long long c) {
        edges[i] = {a, b, c};
    }
    void exe(int s) {
        dist[s] = 0;
        for(int loop = 0; loop < n - 1; ++loop) {
            for(auto &e : edges) {
                if(dist[e.from] == INF) continue;
                if(dist[e.to] > dist[e.from] + e.cost) {
                    dist[e.to] = dist[e.from] + e.cost;
                }
            }
        }
    }
    void negative() {
        for(int loop = 0; loop < n; ++loop) {
            for(auto &e : edges) {
                if(dist[e.from] == INF) continue;
                if(dist[e.to] > dist[e.from] + e.cost) {
                    dist[e.to] = dist[e.from] + e.cost;
                    nega[e.to] = true;
                }
                if(nega[e.from]) nega[e.to] = true;
            }
        }
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    BellmanFord bf(N, M, INF);
    rep(i, 0, M){
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        bf.input(i, a, b, -c);
    }
    bf.exe(0);
    bf.negative();
    if(bf.nega[N - 1]) cout << "inf" << endl;
    else cout << -bf.dist[N - 1] << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  bool x =false;

  for (int i =0; i<N; i++){
    string op;
    cin >> op;
    if (op=="Y"){
      x = 1;
      break;
    }

  }
  if (x==true)
  cout<<"Four"<<endl;
  else
    cout<<"Three"<<endl;
  
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define FOR(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
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; }
using ll = long long;

int main() {
  ll h, w; cin >> h >> w;
  ll ans = INF, a, b, c;
  FOR(i,1,h) {
    a = i*w;
    b = (h-i)*(w/2);
    c = (h-i)*(w-w/2);
    chmin(ans, max({a,b,c})-min({a,b,c}));
    b = ((h-i)/2)*w;
    c = (h-i-(h-i)/2)*w;
    chmin(ans, max({a,b,c})-min({a,b,c}));
  }
  FOR(i,1,w) {
    a = i*h;
    b = (w-i)*(h/2);
    c = (w-i)*(h-h/2);
    chmin(ans, max({a,b,c})-min({a,b,c}));
    b = ((w-i)/2)*h;
    c = (w-i-(w-i)/2)*h;
    chmin(ans, max({a,b,c})-min({a,b,c}));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main{
	int N;
	int M;
	Node[] nodes;

	class Node{
		int idx;
		int c;
		ArrayList<Node> nodes;
		public Node(int idx){
			this.idx = idx;
			nodes = new ArrayList<>();
			c = -1;
		}
		
		public boolean equals(Object o){
			return idx == ((Node)o).idx;
		}
		
		public int hashCode(){
			return idx;
		}
	}
	
	public void solve(){
		N = nextInt();
		M = nextInt();
		nodes = new Node[N];
		for(int i = 0; i < N; i++){
			nodes[i] = new Node(i);
		}
		
		for(int i = 0; i < M; i++){
			int a = nextInt() - 1;
			int b = nextInt() - 1;
			nodes[a].nodes.add(nodes[b]);
			nodes[b].nodes.add(nodes[a]);
		}
		
		if(dfs(nodes[0], 0)){
			long black = 0;
			for(int i = 0; i < N; i++){
				black += nodes[i].c;
			}
			long white = N - black;
			out.println(black * white - M);
		}else{
			
			out.println((long)N * (N - 1) / 2 - M);
		}
	}
	
	public boolean dfs(Node cur, int c){
		if(cur.c != -1){
			return cur.c == c;
		}
		cur.c = c;
		boolean flg = true;
		for(Node n : cur.nodes){
			flg &= dfs(n, (c + 1) % 2);
		}
		return flg;
	}
	
	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

Measured memory_bytes: 57048
def smaller(x, y):
	if x < y:
		return x
	return y

N, M = map(int, input().split())
drinks = []
for i in range(0, N):
	drinks.append(list(map(int, input().split())))
drinks.sort(key = lambda v: v[0])
sum = 0
left = M
for i in range(0, N):
	sum += drinks[i][0]*smaller(drinks[i][1], left)
	left -= smaller(drinks[i][1], left)
	if left == 0:
		break
print(sum)

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

int count_divide_num(int, int*);

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

    int number[N];
    for(int i=0; i<N; i++){
        cin >> number[i];
    }

    cout << count_divide_num(N, number) << endl;
    return 0;
}

int count_divide_num(int N, int number[]){
    int divide_num = 0;
    bool odd_flag = false;

    while(1){
        for(int i=0; i<N; i++){
            //偶数でない数があったときはその時点のdivide_numを返して関数を抜ける
            if(number[i] % 2 != 0){
                odd_flag = true;
            }
        }
        if(odd_flag){
            return divide_num;
        }
        else {
            for(int i=0; i<N; i++){
                number[i] /= 2;
            }
            divide_num++;
        }
    }
}


Measured memory_bytes: 256
from math import *



n,m,c=map(int,input().split(" "))
b=list(map(int,input().split(" ")))

ct=0

for i in range(n):
	a=list(map(int,input().split(" ")))
	sm=0

	for i in range(len(a)):
		sm+=(b[i]*a[i])
	if(sm+c>0):
		ct+=1
print(ct)



Measured memory_bytes: 3060
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		int ans = 1;
		int max = 0;
		for(int i = 0; i < n; i++){
			h[i] = sc.nextInt();
			if(i != 0){
				if(h[i] >= max){
					ans++;
				}
			}
			max = Math.max(max,h[i]);
		}
		System.out.print(ans);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
namespace TYC
{
    #define int ll

    typedef long long ll;
    const int N = 1e5 + 10;
 
    int n, m, x[N], a[N], ans[N];
    ll K;
 
    inline int read()
    {
        int x = 0, f = 0, ch = getchar();
        while (!isdigit(ch))
            f |= (ch == '-'), ch = getchar();
        while (isdigit(ch))
            x = x * 10 + ch - '0', ch = getchar();
        return f ? -x : x;
    }
 
    inline void calc(int *r, int *x, int *y)
    {
        static int tmp[N], fir[N], to[N];
        memcpy(fir, x, sizeof(int[n]));
        memcpy(to, y, sizeof(int[n]));
        for (int i = 1; i <= n; i++)
            tmp[i] = to[fir[i]];
        memcpy(r, tmp, sizeof(int[n]));
    }
 
    void work()
    {
        n = read();
        for (int i = 0; i < n; i++)
            x[i] = read();
        for (int i = 0; i < n; i++)
            a[i] = ans[i] = i;
        m = read();
        scanf("%lld", &K);
        for (int i = 0; i < m; i++)
        {
            int t = read();
            swap(a[t - 1], a[t]);
        }
        for (; K; K >>= 1, calc(a, a, a))
            if (K & 1)
                calc(ans, a, ans);
        for (int i = 0; i < n; i++)
            a[i] = x[ans[i]] - x[ans[i] - 1];
        for (int i = 0; i < n; ++i, a[i] += a[i - 1])
            printf("%lld.0\n", a[i]);
    }

    #undef int
}
 
int main()
{
    TYC::work();
    return 0;
}

Measured memory_bytes: 6144
#include <stdio.h>
int main (void)
{
  int N;
  int A[N];
  int i,j;
  int cnt;
  int flag =1;
  
  scanf("%d",&N);
  for (i=0;i<N;i++)
  {
    scanf("%d",&A[i]);
  }
 
  for(j=0;j<100;j++){
    if (flag == 1)
    {
  		for (i=0;i<N;i++)
 	 	{
   			 if (A[i] % 2 == 0)
    			A[i]=A[i]/2;
   		 	else
         		{flag = 0;
     		 		break;}
        }
    cnt++;
  	}
  }
              printf("%d",cnt-1); 


  return 0;
}


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

using namespace std;
typedef long long ll;

string S;

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> S;

    ll ans = 0;
    int ck = 0;
    for (int i = S.length() - 1; i >= 0; i--)
    {
        char nc = S[i];
        if (nc + (ck % 2) == 'C')
            ck++;
        else
        {
            if (nc == 'A')
            {
                if (ck % 2 == 0)
                {
                    ans += ck / 2;
                }
                else
                    ck = 0;
            }
            else
            {
                ck = 0;
                if (nc == 'C') ck = 1;
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 720
//
// Created by GGG1235 on 2019/11/24.
//

#include <bits/stdc++.h>

#pragma GCC optimize(3)

using namespace std;

typedef long long LL;

int main(int argc,const char **argv,const char **envp) 
{
    ios::sync_with_stdio(false);
    cin.tie();
    
    string szInput;
    
    int nLength = 0;
    int nTmp   = 0;
    
    cin >> szInput;
    nLength = static_cast<int>(szInput.length());
    for (int i = 0; i < nLength; ++i)
    {
        if (szInput[i] == 'g')
        {
            nTmp++;
        }
    }
    cout << min(nLength / 2, nTmp) - min(nLength - nLength / 2, nLength - nTmp) << endl;
    return 0;
}

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

s = input()
S = set(s)

ans = INF
for x in S:
	cnt = 0
	t = s
	while 1 < len(set(t)):
		l = ""
		for i in range(1, len(t)):
			if t[i] == x or t[i-1] == x:
				l += x
			else:
				l += t[i]
		t = l
		cnt += 1
	ans = min(ans, cnt)

print(ans)


Measured memory_bytes: 10520
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <math.h>
void P(int *n);
void PF(int *n, int p[], int j);
int main() {
	int n;
	scanf("%d", &n);
	printf("%d:", n);
	P(&n);
	printf(" %d\n", n);
	return 0;
}

void P(int *n){
	int p[7000];
	int i,j=4,k;
	p[0] = 2; p[1] = 3; p[2] = 5; p[3] = 7;
	for (k = 7; k <= (int)sqrt((double)*n);k++) {
		for (i = 3; i <= (int)sqrt((double)k); i += 2) {
			if (k%i == 0||k%2==0)break;
			if (i >= (int)sqrt((double)k) - 1) p[j++] = k;
		}
	}
	PF(n, p, j);
}

void PF(int *n, int p[], int j){
	int i;
	for (i = 0; i < j; i++) {
		if (*n / p[i] == 1) break;
		if (*n%p[i] == 0) {
			printf(" %d", p[i]);
			*n /= p[i];
			PF(n, p, j);
		}
	}
}

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

long gcd(long a, long b) {

  if (b == 0) {
    return a;
  }

  return gcd(b, a % b);

}

int main() {

  int N, X;
  cin >> N >> X;
  
  vector<int> x(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }

  int g = abs(x[0] - X);

  for (int i = 1; i < N; i++) {
    g = gcd(g, abs(x[i] - X));
  }

  cout << g << endl;
  
}

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

L = [0 for i in range(N+1)]

for i in range(K):
  d = int(input())
  LL = list(map(int, input().split()))
  for j in range( len(LL) ):
    L[ LL[j] ] += 1

ans = 0
for i in range(1,N+1):
  if L[i] == 0:
    ans += 1
print(ans)

Measured memory_bytes: 9200