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

class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int height = 0;
		int max = 0;
		int seen = 0;
		
		for(int i = 1; i <= N; i++) {
			height = sc.nextInt();
			if(max <= height) {
				seen ++;
				max = height;
			}
		}
			System.out.println(seen);
	}
}

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)

const ll INF = 1e14;

void dijkstra(int s, vector<ll> & d, vector<int> & p, vector<vector<pair<ll, int>>>& adj) {
    int n = adj.size();
    d.assign(n, INF);
    p.assign(n, -1);

    d[s] = 0;
    set<pair<ll, int>> q;
    q.insert({0, s});
    while (!q.empty()) {
        int v = q.begin()->second;
        q.erase(q.begin());

        for (auto edge : adj[v]) {
            int to = edge.second;
            ll len = edge.first;

            if (d[v] + len < d[to]) {
                q.erase({d[to], to});
                d[to] = d[v] + len;
                p[to] = v;
                q.insert({d[to], to});
            }
        }
    }
}

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

    int N, M;
    cin >> N >> M;
    
    vector<vector<pair<ll, int>>> adj(N);
    for (int i=0;i<M;i++) {
        int L, R;
        ll C;
        cin >> L >> R >> C;
        L--;
        R--;
        adj[L].push_back(make_pair(C, R));
    }

    for(int i=1;i<N;i++) {
        adj[i].push_back(make_pair(0, i-1));
    }


    vll d(N);
    vi p(N);

    dijkstra(0, d, p, adj);

    if (d[N-1] >= INF) {
        cout << "-1" << endl;
    }
    else {
        cout << d[N-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 10496
#include<bits/stdc++.h>
using ll= long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()

#define INF (ll)1e9 //10^9:∞
#define LLINF (ll)1e12
#define MOD (ll)(1e9+7) //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)
#define endl "\n"

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/


/*.....................DEFINE FUNCTIONS ......................*/

long long powmod(long long x, long long n) {
	long long ret = 1;
	while (n > 0) {
		if (n & 1) ret = ret * x % MOD;  // n の最下位bitが1ならば(nが奇数ならば) x^(2^i) をかける
		x = x * x % MOD;
		n >>= 1;  // n を1bit 左にずらす
	}
	return ret;
}


long long nCr_mod(long long n, long long r) {
	long long x = 1, y = 1;

	for (int
	        i = 0; i < r; i++) {
		x = x * (n - i) % MOD ;
		y = y * (i + 1) % MOD;
	}

	return x * powmod(y, MOD - 2) % MOD;
}


/*.........................kemkemG0...........................*/
signed main() {
	__MAGIC__


	ll X,Y;
	cin>>X>>Y;
	ll ans=0;
	if(2*X-Y<0 || 2*Y-X <0 || (2*X-Y)%3!=0 || (2*Y-X)%3!=0)ans=0;
	else {
		ll a=(2*X-Y)/3;
		ll b=(2*Y-X)/3;

		ans=nCr_mod(a+b,a);

	}

	cout<<ans<<endl;
	


		return 0;
}


Measured memory_bytes: 3624
#!/usr/bin/env ruby

require 'pp'
attrs = Array.new
while line = $stdin.gets
  attrs << line.chomp.split
end

N = attrs[0][0].to_i
S = attrs[1]

array = {}
max = 1

N.times do |i|
  a_i = attrs[i + 1][0]
  if array[a_i] == nil then
    array[a_i] = 1
  else
    array[a_i] += 1
    max = array[a_i] if max < array[a_i]
  end
end

array.delete_if { |_, num| max != num }

array.keys.sort.each{|v| puts v}

Measured memory_bytes: 48232
N = int(input())
S = input()

sub = 0
for j in range(1, (N - 1) // 2 + 1):
    for i in range(0, N - 2 * j):
        if S[i] != S[i + j] and S[i + j] != S[i + 2 * j] and S[i + 2 * j] != S[i]:
            sub += 1

r = S.count('R')
g = S.count('G')
b = N - r - g

ans = r * g * b - sub
print(ans)

Measured memory_bytes: 9208
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC112D
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt;
            var M = ReadInt;

            //約数の列挙
            var yakusuu = GetDivisors(M).ToArray();
            yakusuu = yakusuu.OrderByDescending(x => x).ToArray();

            long ans = 0;
            for (int i = 0; i < yakusuu.Length; i++)
            {
                if (M / yakusuu[i] >= N)
                {
                    ans = yakusuu[i];
                    break;
                }
            }
            Console.WriteLine(ans);
        }

        public static IEnumerable<long> GetDivisors(long num)
        {
            if (num < 1) yield break;

            for (long i = 1; i * i <= num; i++)
            {
                if (num % i == 0)
                {
                    yield return i;
                    if (i * i != num) yield return (num / i);
                }
            }
        }
    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] ReadLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}



Measured memory_bytes: 13396
n=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))
A=[]
B=[]
C=[1]
for i in range(1,n+1):
  A.append(i)
  B.append(i)
  if i!=1:
    C.append(C[-1]*i)
a=0
b=0
for i in range(n-1):
  a=a+C[-2-i]*(A.index(P[i]))
  A.remove(P[i])
  b=b+C[-2-i]*(B.index(Q[i]))
  B.remove(Q[i])
print(abs(a-b))

Measured memory_bytes: 3064
import sys
import numpy as np
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N,M,X = map(int, readline().split())
data = np.array(read().split(), np.int64)
data = data.reshape(N,-1)
C = data[:,0]
A = data[:,1:]
 
cost = np.zeros(1<<N, np.int64)
ability = np.zeros((1<<N, M), np.int64)
 
for i in range(N):
  cost[1<<i:1<<(i+1)] = cost[:1<<i] + C[i]
  ability[1<<i:1<<(i+1)] = ability[:1<<i] + A[i]
  
ok = np.all(ability >= X, axis=1)
 
x = cost[ok]
answer = -1 if len(x) == 0 else x.min()
print(answer)

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

bool is_prime(long long n){
    if(n<=1) return false;
    for(long long p=2;p*p<=n;++p){
        if(n%p ==0)return false;
    }
    return true;
}

int main(){
    int n;
    cin>>n;
    long long ans = n;
    while(!is_prime(ans)) ++ans;
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    vector<int> v(10);
    rep(i,10)cin>>v[i];
    
    sort(all(v),greater<int>());
    
    rep(i,3)cout<<v[i]<<endl;
}



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

int main() {
string A,B,C;
  cin >> A >> B >> C;
A.at(0)+='A'-'a'; B.at(0)+='A'-'a'; C.at(0)+='A'-'a';
  cout << A.at(0)<< B.at(0)<< C.at(0)<<endl;
}


Measured memory_bytes: 256
//package cf;
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
public class Main {
    static int mod=1000000007;
    public static void main(String[] args) throws Exception{
        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(java.io.FileDescriptor.out), "ASCII"), 512);
        FastReader sc=new FastReader();

        int h=sc.nextInt();
        int w=sc.nextInt();
        int dp[][]=new int[h+1][w+1];
        char ar[][]=new char[h][w];
        for(int i=0;i<=h;i++) {
            Arrays.fill(dp[i],-1);
        }
            for(int i=0;i<h;i++)
        {
            String s=sc.nextLine();
            ar[i]=s.toCharArray();
        }
        System.out.println(grid(ar,0,0,h,w,dp));

        // StringBuilder sb=new StringBuilder();
        //   out.write(sb.toString());
        out.flush();
    }

    private static int grid(char[][] ar, int i, int j, int h, int w, int[][] dp) {
        if(i==h-1&&j==w-1)
            return 1;
        if(i>=h||j>=w)
            return 0;
        if(dp[i][j]!=-1)
            return dp[i][j];
        int right=(i+1<h&&ar[i+1][j]!='#'?grid(ar,i+1,j,h,w,dp):0)%mod;
        int down=(j+1<w&&ar[i][j+1]!='#'?grid(ar,i,j+1,h,w,dp):0)%mod;
        dp[i][j]=(right+down)%mod;
        return dp[i][j];
    }


    ///////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
    static class FastReader {

        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }


}


Measured memory_bytes: 45360
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;



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

	cin >> N;
	string s;
	cin >> s;
	for (auto i : s) {
		if (i != '.') {
			M *= 10;
			M += i - '0';
		}
	}
	cout << N * M / 100 << endl;
}

Measured memory_bytes: 3652
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
ll power (ll base,ll exponent)
{
    ll ans=1;
    //base%=MOD;
    //exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base);
      base=(1LL*base*base);
      exponent>>=1;
    }
    return ans;
}

int32_t main()
{   
     IOS;
     
     ll n,m,i,j,k;
     cin>>k>>n;
     ll ans=INF;
     ll a[n];
     for(i=0;i<n;i++) cin>>a[i];
     for(i=0;i<n;i++)
     {
      // cout<<a[i]<<endl;
       if(i!=n-1)
       {
         ans=min(ans,k-(a[i+1]-a[i]));
       }
       else
       {
        ans=min(ans,k-abs(a[n-1]-(a[0]+k)));
       }
     }
     cout<<ans;
     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

struct UnionFind{
  vector<int> par; //par[i]:iの親番号
  vector<int> siz;

  UnionFind(int N) : par(N),siz(N,1){
    for(int i=0;i<N;i++)par[i]=i;
  }

  int root(int x){
    if(par[x]==x)return x;
    return par[x]=root(par[x]);
  }

  void unite(int x,int y){
    int rx=root(x);
    int ry=root(y);
    if(rx==ry)return;
    if(siz[rx]<siz[ry])swap(rx,ry);
    siz[ry]+=siz[rx];
    par[rx]=ry;
  }

  bool same(int x,int y){
    int rx=root(x);
    int ry=root(y);
    return rx==ry;
  }

  int size(int x){
    return siz[root(x)];
  }
};

int main(){
  int N,M,K;cin>>N>>M>>K;
  UnionFind uf(N);
  vector<int> fr(N,0);
  REP(i,M){
    int a,b;cin>>a>>b;
    a--;b--;
    uf.unite(a,b);
    fr[a]++,fr[b]++;
  }
  REP(i,K){
    int c,d;cin>>c>>d;
    c--;d--;
    if(uf.same(c,d)){
      fr[c]++,fr[d]++;
    }
  }
  REP(i,N){
    cout<<uf.size(i)-fr[i]-1<<endl;
  }
}


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

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> h(n);
    for (int i = 0; i < n; i++) { std::cin >> h[i]; }

    for (int i = n-1; i > 0; i--) {
        if (h[i] == h[i - 1] - 1)
            h[i - 1]--;
        else if (h[i] < h[i - 1]) {
            std::cout << "No" << std::endl;
            return 0;
        }
    }

    std::cout << "Yes" << std::endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
using namespace std;

int N, M;
vector<vector<bool>> v;
// n今どこみてるか
int dfs(int n, vector<bool> visited) {
  // 全部訪れてたら1を返す
  for (int i=0; i<N; i++) {
    if (!visited[i]) break;
    if (i==N-1) return 1;
  }

  int res = 0;
  for (int i=0; i<N; i++) {
    if (!v[n][i]) continue;
    if (visited[i]) continue;
    visited[i] = true;
    res += dfs(i, visited);
    visited[i] = false;
  }
  return res;
}

int main(){
  cin >> N >> M;
  v = vector<vector<bool>>(N, vector<bool>(N, false));
  int tmpa, tmpb;
  for (int i=0; i<M; i++) {
    cin >> tmpa >> tmpb;
    tmpa--;
    tmpb--;
    v[tmpa][tmpb] = true;
    v[tmpb][tmpa] = true;
  }

  vector<bool> visited(N, false);
  visited[0] = true;
  int res = dfs(0,visited);
  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
using namespace std;

int n;
ll k,a[202020];
ll st=-2e18,en=2e18;

int main() {
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	while(st+1!=en) {
        ll mid = (st + en)/2;
        ll cnt = 0;
        for(int i = 0;i < n;i++){
            if(a[i] < 0){
                int l = i,r = n;
                while(l+1 != r){
                    int m = (l+r)/2;
                    if(a[i]*a[m] <= mid)r = m;
                    else l = m;
                }
                cnt += n - r;
            }else{
                int l = i,r = n;
                while(l+1 != r){
                    int m = (l + r)/2;
                    if(a[i]*a[m] <= mid)l = m;
                    else r = m;
                }
                cnt += l - i;
            }
            
        }
        if(cnt < k)st = mid;
        else en = mid;
	}
    cout << en << '\n';
	return 0;
}


Measured memory_bytes: 1792
import time
import math
def sieve(n):
    prime = []
    limit = math.sqrt(n)
    data = [i for i in range(2, n+1)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


n = int(input())
if n == 1:
    print(1)
    exit()
prime = sieve(n)
ans = 1
for sosu in prime:
    cnt = 0
    for i in range(2, n+1):
        num = i
        while num % sosu == 0:
            num //= sosu 
            cnt += 1
    ans *= (cnt + 1)
print(ans % (10**9 + 7))


Measured memory_bytes: 40044
n=int(input());a=eval('list(input()),'*n);f=sum(n==t.count('#')for t in zip(*a));print(-all(t.count('#')<1for t in a)or min(n*2-f-a[i].count('#')+all(a[j][i]>'#'for j in range(n))for i in range(n)))

Measured memory_bytes: 5676
#include <cstdio>
#include <vector>

int as[100005];
std::vector<int> edges[100005];

int lose[100005];

void dfs(int node){
  lose[node]=0;
  for(int child:edges[node]){
    //printf("%d => %d\n",node,child);
    if(lose[child]==-1) dfs(child);
    lose[node]|=lose[child];
  }
  lose[node]^=1;
}

int main(){
  int N;
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    scanf("%d",&as[i]);
  }
  for(int i=0;i<N-1;i++){
    int U,V;
    scanf("%d %d",&U,&V);
    U--,V--;
    if(as[U]>as[V]) edges[U].push_back(V);
    if(as[V]>as[U]) edges[V].push_back(U);
  }
  std::fill(lose,lose+N,-1);
  for(int i=0;i<N;i++){
    if(lose[i]==-1){
      dfs(i);
    }
  }
  std::vector<int> vs;
  for(int i=0;i<N;i++){
    if(!lose[i]) vs.push_back(i+1);
  }
  for(int i=0;i<vs.size();i++){
    if(i) printf(" ");
    printf("%d",vs[i]);
  }
  printf("\n");
  return 0;
}


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

int bubbleSort(int A[],int N)
{
	int sw=0;//?????????????????°
	bool flag=1;
	for(int i=0;flag;i++){
		flag = 0;
		for(int j= N-1;j>=i+1 ;j--){
			if(A[j] < A[j-1]){
				flag=1;
			   	swap(A[j],A[j-1]);
				sw++;

			}
		}
	}
	return sw;
}

int main()
{
	int N,A[100];
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> A[i];		
	}
	int sw = bubbleSort(A,N);

	for(int i=0;i<N;i++){
		if(i>0) cout << ' ';
		cout << A[i];
	}
	cout << endl;
	cout << sw << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int dp[100100];

int main()
{
    int n; cin >> n;
    int six[6] = {6,36,216,1296,7776,46656};
    int nine[5] = {9,81,729,6561,59049};
    for(int i = 0; i < 100100; i++){
        dp[i] = inf;
    }
    dp[0] = 0;
    for(int i = 1; i <= n; i++){
        for(int six = 1; six <= i; six *= 6){
            dp[i] = min(dp[i],dp[i-six]+1);
        }
        for(int nine = 1; nine <= i; nine *= 9){
            dp[i] = min(dp[i],dp[i-nine]+1);
        }
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=5e5+5;
const int inf=0x3f3f3f3f;
int n,t=9,x,flag,a[5][5],cnt[5][5],sum;
int main(){
    for(int i=1;i<=3;i++){
        for(int j=1;j<=3;j++){
            scanf("%d",&a[i][j]);
        }
    }
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        for(int j=1;j<=3;j++){
            for(int k=1;k<=3;k++){
                if(a[j][k]==x){
                    cnt[j][k]=1;
                }
            }
        }
    }
    for(int i=1;i<=3;i++){
        sum=0;
        for(int j=1;j<=3;j++){
            sum=sum+cnt[i][j];
        }
        if(sum==3){
            flag=1;
        }
    }
    for(int j=1;j<=3;j++){
        sum=0;
        for(int i=1;i<=3;i++){
            sum+=cnt[i][j];
        }
        if(sum==3){
            flag=1;
        }
    }
    sum=cnt[1][1]+cnt[2][2]+cnt[3][3];
    if(sum==3){
        flag=1;
    }
    sum=cnt[1][3]+cnt[2][2]+cnt[3][1];
    if(sum==3){
        flag=1;
    }
    if(flag){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<iomanip>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<numeric>

#define int long long

using namespace std;

int INF = 1e16 + 7;

void solve() {
    int n;
    cin >> n;
    string str;
    cin >> str;
    int w = 0, ans = 0;
    for (auto ch : str) w += ch == 'W';
    for (int i = n - 1; i > n - 1 - w; --i) ans += str[i] == 'R';
    cout << ans;
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3488
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;

ll gcd(ll x,ll y){
    if(y==0) return 0;
    return gcd(y,x%y);
}

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}

int main(){
    string s;cin>>s;
    if(s=="KIHBR"||s=="AKIHBR"||s=="KIHABR"||s=="KIHBAR"||s=="KIHBRA"
    ||s=="AKIHABR"||s=="AKIHBAR"||s=="AKIHBRA"||s=="KIHABAR"||s=="KIHABRA"
    ||s=="KIHBARA"||s=="AKIHABAR"||s=="AKIHABRA"||s=="AKIHBARA"
    ||s=="KIHABARA"||s=="AKIHABARA"){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}

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

#define int long long
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
int N, A, B;

signed main()
{
    cin >> N >> A >> B;

    int ans = min(A*N, B);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 100005;


int a, b, m, i, c, d, e, res, tab[N], bat[N];

int main() {
scanf("%d %d %d", &a, &b, &m);
for (i=0;i<a;i++) scanf("%d", &tab[i]);
for (i=0;i<b;i++) scanf("%d", &bat[i]);
res = INF;
for (i=0;i<m;i++) {
	scanf("%d %d %d", &c, &d, &e);
	res = min(res, tab[c - 1] + bat[d - 1] - e);
}
sort(tab, tab + a);
sort(bat, bat + b);
res = min(res, tab[0] + bat[0]);
printf("%d\n", res);
return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>

typedef struct{
  double x,y;
}Point;

void print(Point p){
  printf("%.8f %.8f\n",p.x,p.y);
}

void plot(int n,Point p1,Point p2){
  Point s,t,u;
  double th = 60.0*(acos(-1) / 180.0);

  if(n == 0) return;

  s.x = (2.0 * p1.x + 1.0 * p2.x) / 3.0;
  s.y = (2.0 * p1.y + 1.0 * p2.y) / 3.0;
  t.x = (1.0 * p1.x + 2.0 * p2.x) / 3.0;
  t.y = (1.0 * p1.y + 2.0 * p2.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  plot(n - 1,p1,s);
  print(s);
  plot(n - 1,s,u);
  print(u);
  plot(n - 1,u,t);
  print(t);
  plot(n - 1,t,p2);
}

int main(){
  Point p1,p2;
  int n;

  scanf("%d",&n);

  p1.x = 0;
  p1.y = 0;
  p2.x = 100;
  p2.y = 0;
  print(p1);
  plot(n,p1,p2);
  print(p2);

  return 0;
}



Measured memory_bytes: 2108
#include <cstdio>
#include <cstring>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int dir[] = { 0, 1, 0, -1 };
int W, H, N, xs, ys, xa[1009], xb[1009], ya[1009], yb[1009], xc[2009], yc[2009], d[1009][1009];
void rec(int x, int y) {
	d[x][y] = 1;
	for (int i = 0; i < 4; i++) {
		int tx = x + dir[i], ty = y + dir[i ^ 1];
		if (0 <= tx && tx < xs - 1 && 0 <= ty && ty < ys - 1 && d[tx][ty] == 0) rec(tx, ty);
	}
}
int main() {
	while (scanf("%d%d", &W, &H), W) {
		scanf("%d", &N);
		for (int i = 0; i < N; i++) {
			scanf("%d%d%d%d", &xa[i], &ya[i], &xb[i], &yb[i]);
			xc[i] = xa[i], yc[i] = ya[i];
			xc[i + N] = xb[i], yc[i + N] = yb[i];
		}
		xc[2 * N] = 0, xc[2 * N + 1] = W; sort(xc, xc + 2 * N + 2);
		xs = unique(xc, xc + 2 * N + 2) - xc;
		yc[2 * N] = 0, yc[2 * N + 1] = H; sort(yc, yc + 2 * N + 2);
		ys = unique(yc, yc + 2 * N + 2) - yc;
		memset(d, 0, sizeof(d));
		for (int i = 0; i < N; i++) {
			xa[i] = lower_bound(xc, xc + xs, xa[i]) - xc;
			ya[i] = lower_bound(yc, yc + ys, ya[i]) - yc;
			xb[i] = lower_bound(xc, xc + xs, xb[i]) - xc;
			yb[i] = lower_bound(yc, yc + ys, yb[i]) - yc;
			d[xa[i]][ya[i]]++; d[xb[i]][yb[i]]++;
			d[xa[i]][yb[i]]--; d[xb[i]][ya[i]]--;
		}
		for (int i = 0; i < xs; i++) {
			for (int j = 0; j < ys; j++) {
				d[i][j + 1] += d[i][j];
			}
		}
		for (int i = 0; i < xs; i++) {
			for (int j = 0; j < ys; j++) {
				d[i + 1][j] += d[i][j];
			}
		}
		int ret = 0;
		for (int i = 0; i < xs - 1; i++) {
			for (int j = 0; j < ys - 1; j++) {
				if (d[i][j] == 0) rec(i, j), ret++;
			}
		}
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 9592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int k, a, b; cin >> k >> a >> b;
  if (b / k - (a - 1) / k > 0) cout << "OK\n";
  else cout << "NG\n";

  return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=1e5+10;
const int mod=0;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int n,c,k,t[N],ans=0;
priority_queue<int,vector<int>,greater<int>> q;
int main() {
    cin>>n>>c>>k;
    for(int i=1;i<=n;i++) t[i]=gi();
    sort(t+1,t+n+1);
    for(int i=1;i<=n;i++) {
        while(!q.empty()&&t[i]-q.top()>k) {
            ans++;int cnt=c;
            while(cnt--&&!q.empty()) q.pop();
        }
        q.push(t[i]);
    }
    ans+=(int(q.size())-1)/c+1;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;

lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

  string s;
  string t = "2019/04/30";
  
  cin >> s;
  
  if(s <= t) COUT("Heisei");
  else COUT("TBD");
	return 0;
}


Measured memory_bytes: 256
import numpy as np

S = np.array([ord(i) for i in input()], dtype=np.int8)
T = np.array([ord(i) for i in input()], dtype=np.int8)
LS = len(S)
LT = len(T)
equal = np.equal.outer(S, T).astype(int)

dp = [np.zeros(LT + 1, dtype=int)]
for i in range(LS):
    ndp = dp[-1].copy()
    np.maximum(ndp[:-1] + equal[i], ndp[1:], out=ndp[1:])
    np.maximum.accumulate(ndp, out=ndp)
    dp.append(ndp)


ans = []
i, j = LS, LT
while i > 0 and j > 0:
    if S[i - 1] == T[j - 1]:
        ans.append(chr(S[i - 1]))
        i -= 1
        j -= 1
        continue
    if dp[i][j] == dp[i - 1][j]:
        i -= 1
    else:
        j -= 1
ans.reverse()
print("".join(ans))


Measured memory_bytes: 155568
N, M, X = map(int, input().split())

costs = []
arrays = []
for _ in range(N):
    arr = tuple(map(int, input().split()))
    costs.append(arr[0])
    arrays.append(arr[1:])

total_costs = []
for i in range(1, 2**N):
    total_cost = 0
    selected_arrays = [] 
    for j in range(0, N):
        if (i >> j)&1:
            total_cost += costs[j]
            selected_arrays.append(arrays[j])
            
    rikais = [0] * M
    for arr in selected_arrays:
        for i, a in enumerate(arr):
            rikais[i] += a

    if all(map(lambda r: r>=X, rikais)):
        total_costs.append(total_cost)

if len(total_costs) == 0:
    print('-1')
else:
    print(min(total_costs))

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int counter(int x){
    if(!x)return 0;
    return counter(x>>1)+(x&1);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    int C=in();
    int K=in();
    vector<int> t;
    REP(i,N){
        int temp;
        cin>>temp;
        t.pb(temp);
    }
    int ans;ans=0;
    sort(all(t));
    int cnt;cnt=0;
    int nowtime;nowtime=-1;
    REP(i,N){
        if(cnt+1<=C&&t[i]<=nowtime){
            cnt++;
        }else{
            cnt=1;
            nowtime=t[i]+K;
            ans++;
        }

    }
    print(ans);
    return 0;
}


Measured memory_bytes: 4220
n, a, b = [int(x) for x in input().split()]

p = 10 ** 9 + 7

# x^nを求める
def exp_by_sq(x, n):
    if n == 0:
        exp = 1
    elif n == 1:
        exp = x % p
    elif  n % 2 == 0:
        exp = exp_by_sq(x * x % p, n // 2)
    else:
        exp = x * exp_by_sq(x * x % p, (n - 1) // 2) % p
    return exp % p

def binomial_p(n, k, p):
    '''
    Input: integers n, k such that n >= k >= 0, prime number p
    Output: n choose k mod p
    '''
    k = min(k, n-k)

    if k == 0:
        retval = 1
    elif k == 1:
        retval = n
    else:
        numer = n  # n * (n - 1) * ... * (n - k + 1)
        inv = [0, 1]    # inv[i] : inverse of i mod p
        inv_denom = 1 # factorial of inverse of k mod p = 1^(-1) * 2^(-1) * ... * k^(-1) mod p
        for i in range(2, k + 1):
            numer = numer * (n - i + 1) % p
            inv.append(( inv[p % i] * (p - p//i) ) % p ) # inverse of i
            inv_denom = inv_denom * inv[-1] % p
        retval = numer * inv_denom % p

    return retval

ans = (exp_by_sq(2, n) - 1 - binomial_p(n, a, p) - binomial_p(n, b, p)) % p

print(ans)


Measured memory_bytes: 66672
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<typeinfo>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  string s; cin>>s;
  ll ans = 1;
  string prev;
  ll x = s.size();

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

  if(s[0] == s[1]){
    prev.pb(s[0]);
  }
  else prev = s[0];

  ll i = prev.size();

  while(i < x){
    // cout<<i<<" "<<ans<<" "<<prev<<endl;
    if(i==x-2 and s[i] == s[i+1]){
      i+=2;
      ans++;
    }
    else if(prev.size() == 2){
      prev = s[i];
      i++;
      ans++;
    }
    else{
      if(s[i] == prev[0]){
        prev.clear();
        prev.pb(s[i]); prev.pb(s[i+1]);
        i+=2;
        ans++;
      }
      else{
        prev = s[i];
        i++;
        ans++;
      }
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  int N,K; cin>>N>>K;
  int R,S,P; cin>>R>>S>>P;
  string T; cin>>T;

  map<char, char> win;
  win['r'] = 'p';
  win['s'] = 'r';
  win['p'] = 's';
  map<char, char> ex; // 以外
  ex['r'] = 'R';
  ex['s'] = 'S';
  ex['p'] = 'P';

  map<char,int> pt;
  pt['p'] = P;
  pt['r'] = R;
  pt['s'] = S;
  ll ans = 0;

  string hd = "";
  REP(i,N) {
    if (i>=K) {
      if (hd[i-K]!=win[T[i]]) {
        hd += win[T[i]];
        ans += pt[hd[i]];
      } else {
        hd += ex[win[T[i]]]; // 勝ち手以外: あいこ or 負け
      }
    } else {
      hd += win[T[i]]; 
      ans += pt[hd[i]];
    }
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 640
// I look at my watch
// it say nine twenty-five
// And I think oh God
// I'm still alive
 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) int((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(int i = int(a); i < int(b); ++i)
#define roF(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
typedef long double ld;




int main(){	
	vector<int>v;
	For(i,0,3){
		int val;cin>>val;
		v.pb(val);
	}
	sort(all(v));
	cout<<v[0]+v[1]<<endl;

	return 0;
}


Measured memory_bytes: 3512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pll pair<long long int, long long int>
#define great (long long int)(1e9+7)
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fst first
#define scd second

void solve()
{
   ll a;
   cin>>a;
   cout<<a+a*a+a*a*a<<endl;
}
int main()
{
    //fastio;
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 3588
import java.io.*;
import java.util.Scanner;



public class Main {
    public static void main(String[] args)throws Exception{
        Scanner scan = new Scanner(System.in);
        int H = 0;
        int W = 0;
        String w = "";
        int judge = 0;
        while(judge == 0){
            H = scan.nextInt();
            W = scan.nextInt();
            //wは繰り返し使うので、その都度初期化する
            if(judge == 0){
                w = "";
            }
            if(H == 0 && W == 0){
                judge = 1;
            }else{
                for(int i = 0;i <= W - 1;i++){    
                   w = w + "#";
                }
                for(int I = 0;I <= H - 1;I++){
                   if(I != H - 1){
                    System.out.println(w);
                   }else if(I == H - 1){
                    System.out.println(w + "\r\n");
                   }
                }
            }
        }
        
    }
}


Measured memory_bytes: 27588
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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=1001001001;
const int mod=1e9+7;

int main() {
  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  sort(A.begin(),A.end());
  vector<bool>div(1000000,true);
  for(int i=0;i<N;i++){
    if(i>=1&&A[i]==A[i-1]){div[A[i]]=false;continue;}
    for(int j=2;j<=1000000/A[i];j++){
      div[A[i]*j]=false;
    }
  }
  int cnt=0;
  for(int i=0;i<N;i++){
    if(div[A[i]]){cnt++;}
  }
  cout<<cnt<<endl;
  return 0;
}


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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SORT(v, n) sort(v, v+n);
#define SSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	int a,b;
	cin >> a >> b;
	cout << a+(b/2) << endl;
}

Measured memory_bytes: 764
#include<iostream>
using namespace std;
int main(){
    int N,A;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>A;
        if(A%2==0){
            if(A%3!=0&&A%5!=0){cout<<"DENIED"<<endl;return 0;}
        }
    }
    cout<<"APPROVED"<<endl;
    return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
import Data.Array.IArray
--import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
dictCompare :: [a -> a -> Ordering] -> a -> a -> Ordering
dictCompare [] _ _ = EQ
dictCompare (f:fs) x y = let c = f x y in if c==EQ then dictCompare fs x y else c
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
-- end of templete

gen n = [(x,y,n-x-y) | x <- [1..n-2], y <- [1..n-x-1]]
count s = count' (0,0,0) s
  where
    count' (x,y,z) [] = (x,y,z)
    count' (x,y,z) ('W':xs) = count' (x+1,y,z) xs
    count' (x,y,z) ('B':xs) = count' (x,y+1,z) xs
    count' (x,y,z) ('R':xs) = count' (x,y,z+1) xs

f (x,y,z) xs = wc + bc + rc
  where
    (ws, (bs, rs)) = splitAt y <$> splitAt x xs
    wc = sum $ map (\(w,b,r) -> b + r) ws
    bc = sum $ map (\(w,b,r) -> r + w) bs
    rc = sum $ map (\(w,b,r) -> w + b) rs

main = do
    [n, m] <- getInts
    fs <- map count <$> replicateM n getLine
    print $ minimum $ map (flip f fs) $ gen n


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define ins insert

#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define debug(a) cerr<<(a)<<endl
#define dbrep(a,n) rep(_i,n) cerr<<(a[_i])<<" "; cerr<<endl
#define dbrep2(a,n,m) rep(_i,n){rep(_j,m) cerr<<(a[_i][_j])<<" "; cerr<<endl;}
#else
#define debug(a) ;
#define dbrep(a,n) ;
#define dbrep2(a,n,m) ;
#endif

using namespace std;

template<class A, class B>
ostream &operator<<(ostream &os, const pair<A,B> &p){return os<<"("<<p.fi<<", "<<p.se<<")";}
template<class A, class B>
istream &operator>>(istream &is, pair<A,B> &p){return is>>p.fi>>p.se;}

/* Some Libraries */

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

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    ll D,T,S; cin>>D>>T>>S;
    debug(D);
    debug(T*S);
    cout<<(D<=T*S?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 3596
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
std::random_device rd;
std::mt19937 mt(rd());
constexpr int MOD = 1e9+7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;



void solve() {
	string S; cin >> S;
	int N = S.size();
	if (N & 1) {
		print("No"); return;
	}
	for (int i = 0; i < N; i += 2) {
		if (S.substr(i, 2) != "hi") {
			print("No"); return;
		}
	}
	print("Yes");
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



Measured memory_bytes: 764
def combination(n, x):
    ans = []
    for i in range(1, n + 1):
        for j in range(1, n + 1):
            k = x - i - j
            if i != j and j != k and i != k and 0 < k <= n:
                ans.append(sorted([i, j, k]))
    ans.sort()
    ans = list(map(list, set(map(tuple, ans))))
    print(len(ans))

while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    else:
        combination(n, x)



Measured memory_bytes: 6564
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5+5;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    2019;
ll n;ll lo=1;ll hi=2e5;
ll arr[N];
bool fn(ll x)
{
	ll t;
	map<ll,ll> mp;
	if(x==1)
	{
		for(int i=2;i<=n;i++)
		if(arr[i]<=arr[i-1]) return 0;
		return 1;
	}
	for(int i=2;i<=n;i++)
	if(arr[i]<=arr[i-1])
	{
		t=arr[i];
		mp.erase(mp.upper_bound(t),mp.end());

  while(t>0&&mp[t]==x-1)
		{
			mp.erase(t);
			t--;
		}
		if(!t)
		return 0;
		else
		mp[t]++;
	}
	return 1;
}
int main()
{  fast
cin>>n;
//int ans=1;
for(int i=1;i<=n;i++)cin>>arr[i];
while(lo<=hi)
{
	ll mid=(lo+hi)/2;
//	cout<<mid<<endl;
	if(fn(mid))
	hi=mid-1;
	else
	lo=mid+1;
}
cout<<hi+1<<endl;
}


Measured memory_bytes: 1792