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

namespace Program
{
    public class ABC117D
    {
        static public void Main(string[] args)
        {
            var N = NextInt;
            var K = (ulong)NextLong;
            var count = new ulong[64];
            var Aary = new ulong[N];
            for (int i = 0; i < N; ++i)
            {
                var A = (ulong)NextLong;
                Aary[i] = A;
                for (int j = 0; j < 64; ++j)
                {
                    count[j] += A & 1;
                    A >>= 1;
                }
            }
            var mask = (ulong)0x8000000000000000;
            var X = (ulong)0;
            var ok = false;
            for (int i = 0; i < 64; ++i)
            {
                X <<= 1;
                if (ok)
                {
                    if (count[63 - i] <= (ulong)N / 2) X += 1;
                }
                else
                {
                    if ((mask & K) != 0)
                    {
                        if (count[63 - i] <= (ulong)N / 2) X += 1;
                        else ok = true;
                    }
                }
                mask >>= 1;
            }

            var ans = (ulong)0;
            foreach (var item in Aary)
            {
                ans += item ^ X;
            }

            Console.WriteLine(ans);
        }

        static class Console_
        {
            private static Queue<string> param = new Queue<string>();
            public static string NextString()
            {
                if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);
                return param.Dequeue();
            }
        }
        static int NextInt => int.Parse(Console_.NextString());
        static long NextLong => long.Parse(Console_.NextString());
        static string NextString => Console_.NextString();

        static IEnumerable<long> Prime(long x)
        {
            if (x < 2) yield break;
            yield return 2;
            var halfx = x / 2;
            var table = new bool[halfx + 1];
            var max = (long)(Math.Sqrt(x) / 2);
            for (long i = 1; i <= max; ++i)
            {
                if (table[i]) continue;
                var add = 2 * i + 1;
                yield return add;
                for (long j = 2 * i * (i + 1); j <= halfx; j += add) table[j] = true;
            }
            for (long i = max + 1; i <= halfx; ++i) if (!table[i]) yield return 2 * i + 1;
        }
        static IEnumerable<long> Divisor(long x)
        {
            if (x < 1) yield break;
            var max = (long)Math.Sqrt(x);
            for (long i = 1; i < max; ++i)
            {
                if (x % i != 0) continue;
                yield return i;
                if (i != x / i) yield return x / i;
            }
        }
        static long GCD(long a, long b)
        {
            long tmpa = a, tmpb = b;
            while (tmpb > 0) { var tmp = tmpb; tmpb = tmpa % tmpb; tmpa = tmp; }
            return tmpa;
        }
    }
}


Measured memory_bytes: 31196
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] s = (sc.next() + "*").toCharArray();
		s[n] = s[0];
		sc.close();

		char[] ans = new char[n + 2];
		ans[0] = 'S';
		ans[1] = 'S';
		if (judge(n, s, ans)) return;

		ans[0] = 'S';
		ans[1] = 'W';
		if (judge(n, s, ans)) return;

		ans[0] = 'W';
		ans[1] = 'W';
		if (judge(n, s, ans)) return;

		ans[0] = 'W';
		ans[1] = 'S';
		if (!judge(n, s, ans)) System.out.println(-1);
	}

	static boolean judge(int n, char[] s, char[] ans) {
		for (int i = 2; i < n + 2; i++) {
			if (ans[i - 1] == 'S') {
				if (s[i - 1] == 'o') {
					ans[i] = ans[i - 2];
				} else {
					ans[i] = not(ans[i - 2]);
				}
			} else {
				if (s[i - 1] == 'o') {
					ans[i] = not(ans[i - 2]);
				} else {
					ans[i] = ans[i - 2];
				}
			}
		}
		if (ans[n] == ans[0] && ans[n + 1] == ans[1]) {
			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < n; i++) {
				sb.append(ans[i]);
			}
			System.out.println(sb.toString());
			return true;
		}
		return false;
	}

	static char not(char c) {
		if (c == 'S') {
			return 'W';
		} else {
			return 'S';
		}
	}
}


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

using namespace std;

#define rep(i,a,b) for(int i=a;i<b;i++)


int main(){
	int i,j,n,m,K;
	scanf("%d%d%d",&n,&m,&K);
	rep(i,0,n+1){
		j=K-m*i;
		if(n==2*i){
			if(m*i==K){
				puts("Yes");return 0;
			}
		}
		else{
			int k=n-2*i;
			if(j%k==0){
				j/=k;
				if(j>=0&&j<=m){
					puts("Yes");return 0;
				}
			}
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
/*
 * atcoder/abc089/b.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
void solve();
int main() { solve(); return 0; }

#define ull unsigned long long
void solve() {
  string s; cin >> s;
  int n = s.size();
  for (int count=2; count<n; count += 2) {
    string s2 = s.substr(0, n-count);
    int m = s2.size()/2;
    if (s2.substr(0, m) == s2.substr(m)) {
      cout << m*2 << endl;
      return;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 3632
import java.util.*;
import java.io.*;
import java.util.function.*;

class Main {
    static Scanner scanner = new Scanner();
    static int mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        int n = scanner.nextInt();
        long[] count = new long[62];
        for (int i = 0; i < n; i++) {
            long a = scanner.nextLong();
            for (int j = 0; j < 62; j++) {
                if (((a >> j) & 1) > 0) {
                    count[j]++;
                }
            }
        }
        long ans = 0;
        for (int i = 0; i < 62; i++) {
            long not = n - count[i];
            ans = (ans + count[i] * not % mod * ((1L << i) % mod) % mod) % mod;
        }
        System.out.println(ans);
    }

    public static void main(String[]$) {
        try {
            new Main().solve();
            System.out.flush();
        } catch (Throwable t) {
            System.out.flush();
            t.printStackTrace();
        }
    }
}

class System {
    static PrintWriter out = new PrintWriter(java.lang.System.out);

    static void exit() {
        java.lang.System.exit(0);
    }
}

class Scanner {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(java.lang.System.in), 0x10000);
    private StringTokenizer tokenizer;

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

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

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

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}


Measured memory_bytes: 78564
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n;
    cin >> n;
    cout << n * n * n;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <iomanip>
#include <sstream>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;

int main() {
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	int med0 = (n - 1) / 2;
	int med1 = n / 2;
	cout << a[med1] - a[med0] << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

struct UnionFind
{
    vector<int> par, rank;

    UnionFind(int N) : par(N), rank(N)
    {
        rep(i, N) par[i] = i, rank[i] = 0;
    }

    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 (rank[rx] < rank[ry])
        {
            par[rx] = ry;
        }
        else
        {
            par[ry] = rx;
            if (rank[rx] == rank[ry])
                rank[rx]++;
        }
    }

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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> p(N);
    rep(i, N) {
        cin >> p[i];
        p[i]--;
    }

    UnionFind tree(N);
    rep(i, M) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        tree.unite(x, y);
    }

    int ans = 0;
    rep(i, N) {
        if (tree.same(i, p[i])) ans++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4576
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

int N;

void dfs(string s, int n, vector<bool> first) {
    if (n == 0) {
        cout<<s<<endl;
        return;
    }

    rep(i, N) {
        string t = "a";
        if (first[i]) {
            t[0] += i;
            first[i] = false;
            dfs(s + t, n - 1, first);
            return;
        }
        else {
            t[0] += i;
            dfs(s + t, n - 1, first);
        }
    }
}

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

    cin>>N;

    string s = "";
    vector<bool> first(N, true);
    dfs(s, N, first);
}


Measured memory_bytes: 1536
import bisect
n = int(input())
a = [int(input()) for i in range(n)]
answer = []

for i in range(n):
    if i == 0:
        answer.append(-a[i])
    elif -answer[-1] >= a[i]:
        answer.append(-a[i])
    else:
        a_index = bisect.bisect_right(answer, -a[i])
        answer[a_index] = -a[i]

print(len(answer))


Measured memory_bytes: 55896
n,q = gets.split(' ').map &:to_i
s = gets.chop.split('')
pre = ''
arr = []
point = 0
s.each_with_index do |t, i|
  point += 1 if pre == 'A' && t == 'C'
  arr[i] = point
  pre = t
end
q.times {
  l,r = gets.split(' ').map &:to_i
  p arr[r-1] - arr[l-1]
}


Measured memory_bytes: 12284
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
template<typename T>
void swap(T &a, T &b) {
    T tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}

int main() {
  ll A,B,C;
  cin>>A>>B>>C;
  ll sum=A+B+C;
  if(sum>=22){
    cout<<"bust"<<endl;
  }else{
    cout<<"win"<<endl;
  }
  return 0;
}


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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    while (1) {
        if (C <= 0) {
            cout << "Yes" << endl;
            return 0;

        }
        if (A <= 0) {
            cout << "No" << endl;
            return 0;
        }
        C -= B;
        A -= D;
    }
    return 0;
}


Measured memory_bytes: 3572
import sys
from collections import defaultdict
from queue import deque
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def prime_factors(n):
    ret = dict()

    i = 2
    tmp = n
    while i * i <= n:
        e = 0
        while tmp % i == 0:
            tmp //= i
            e += 1
        if e > 0:
            ret[i] = e

        i += 1

    if tmp > 1:
        ret[tmp] = 1

    return ret


def main():
    n = gete(int)
    d = prime_factors(n)

    ans = 0
    for p in d:
        e = d[p]
        tmp = e
        for i in range(1, e + 1):
            tmp -= i
            if tmp < 0: break
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

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


void solve(std::vector<long long> H, std::vector<long long> M, long long K){
    int t = (H[1] * 60 + M[1]) - (H[0] * 60 + M[0]) - K;
    cout << t << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::vector<long long> H(2);
    std::vector<long long> M(2);
    for(int i = 0 ; i < 2 ; i++){
        scanf("%lld",&H[i]);
        scanf("%lld",&M[i]);
    }
    long long K;
    scanf("%lld",&K);
    solve(std::move(H), std::move(M), K);
    return 0;
}


Measured memory_bytes: 3704
S = input()
K = int(input())
N = len(S)

prev = S[0]
count_list = []
count=1
for i in range(1,N):
    if prev==S[i]:
        count+=1
    else:
        count_list.append(count)
        prev=S[i]
        count=1
count_list.append(count)

if len(count_list)==1:
    print((count_list[0]*K)//2)
else:
    if S[0]==S[N-1]:
        ans = 0
        for count in count_list[1:-1]:
            ans+=count//2
        ans *= K
        ans += count_list[0]//2
        ans += count_list[-1]//2
        ans += (K-1) * ((count_list[0]+count_list[-1])//2)
        print(ans)
    else:
        ans = 0
        for count in count_list:
            ans+=count//2
        ans *= K
        print(ans)


Measured memory_bytes: 38408
<?php
	$output = array();
	while( true ) {
		fscanf( STDIN, "%d%d", $x, $y );
		if( 0 == $x and 0 == $y ) { break; }
		if( $y < $x ) {
			$t = $x;
			$x = $y;
			$y = $t;
		}
		array_push( $output, $x." ".$y );
	}
	print implode( "\n", $output );
?>

Measured memory_bytes: 6940
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define  clr(v,val)      memset(v,val,sizeof(v))
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
typedef  long long     ll ;
typedef  unsigned long long     ull ;
const double eps= (1e-9);
using namespace std;
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
ll setBit1(ll num, ll idx) {return num | (1ll<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=400000+9;
string s,t;
int main(){
    GO();
    cin>>s>>t;
    int cnt=0;
    for(int i=0;i<sz(s);i++){
        if(s[i]!=t[i]) cnt++;
    }
    cout<<cnt<<"\n";
}































































Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int MAX_N = 1e5+2;
int N, M;
int x[MAX_N], y[MAX_N];
vector<int> G[MAX_N];
int dp[MAX_N];

void add_edge(int from, int to)
{
	G[from].push_back(to);
}

int dfs(int x)
{
	int& res = dp[x];
	if(res != -1) return res;
	res = 0;
	for(int i=0;i<(int)G[x].size();++i){
		int y = G[x][i];
		res = max(res, 1+dfs(y));
	}
	return res;
}

void solve()
{
	for(int i=0;i<M;++i) add_edge(x[i],y[i]);
	memset(dp,-1,sizeof(dp));
	for(int i=1;i<=N;++i){
		dfs(i);
	}
	int ans = 0;
	for(int i=1;i<=N;++i) ans=max(ans,dp[i]);
	cout << ans << '\n';
}

int main()
{
	cin >> N >> M;
	for(int i=0;i<M;++i){
		cin >> x[i] >> y[i];
	}
	solve();
	return 0;
}

Measured memory_bytes: 8960
#include<stdio.h>
#include<stdlib.h>

int cmp1(const void *p,const void *q)
{
    return *(int *)p - *(int *)q;
}

int main()
{
    int n,m,ans=0;
    int piv=0,pick=0;
    int i,j,k;
    char a[1000010]={0};
    scanf("%d",&n);

    for(i=0;i<n;i++)
    {
        scanf("%d",&m);
        a[m]++;
    }

    //furui
    for(j=1;j<=1000000;j++)
    {
        if(a[j]==0)continue;
        else
        {
            if(a[j]==1)ans++;
            else a[j]=0;

            for(k=j*2;k<=1000000;k+=j)a[k]=0;
        }
    }
    //ans=0;
    //for(i=0;i<n;i++)if(b[i]==0)ans++;
    printf("%d",ans);
}


Measured memory_bytes: 2712
#include<cstdio>
using namespace std;

int main(){
    int n;
    long long sum = 0;
    long long a;
    long long min = 1000000;
    long long max = -1000000;
    
    scanf(" %d", &n);
    
    for (int i = 0; i < n; i++) {
        scanf(" %ld", &a);
        if (a > max) max = a;
        if (a < min) min = a;
        sum = sum + a;
    }
    printf("%ld %ld %ld\n", min, max, sum);
    
    return 0;
}


Measured memory_bytes: 2744
import scala.io.{StdIn => in}

object Main extends App {
  val n = in.readInt
  val s = in.readLine.toArray

  val table = (0 until n).scanLeft(0)((acc, i) => {
    if(s(i) == '#') acc + 1 else acc
  })

  val ans = (0 to n)./:(Int.MaxValue)( (res, i) => {
    val w = table(i) - table(0)
    val b = (n-i) - (table(n) - table(i))
    res min (w + b)
  })
  println(ans)
}

Measured memory_bytes: 41872
#include<stdio.h>

int main(){
  char S[10];
  int i=0;
  int flag=0;
  
  scanf("%s",S);
  
  while(S[i]){
    if(S[i] != 'h' || S[i+1] != 'i'){
      flag = 1;
      break;
  }
    i+=2;
  }
  
  if(flag) printf("No\n");
  else printf("Yes\n");
  
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main()
{
	int n,m=100000;
	scanf("%d",&n);
	while(--n >=0)
	{
		m+=m*0.05;
		if(m%1000!=0)
			m=m-(m%1000)+1000;
	}
	printf("%d\n",m);
	return 0;
}

Measured memory_bytes: 592
import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N = int(input())
s = []
d = dd(int)
for _ in range(N): s.append(input()[: -1])
for x in s: d[x] += 1
ks = d.keys()
mx = max(d.values())
res = []
for k in ks:
  if d[k] == mx: res += [k]
res.sort()
for r in res: print(r)

Measured memory_bytes: 88876
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

char s[200010];
int main(){
	scanf("%s",s);
	int n=strlen(s);
	
	rep(i,0,n)if(s[i]=='?'){
		if(i>0&&s[i-1]=='P')s[i]='D';
		else if(i<n-1&&s[i+1]=='D')s[i]='P';
		else if(i<n-1&&s[i+1]=='?')s[i]='P';
		else s[i]='D';
	}
	puts(s);
}

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

using namespace std;

int D[10] ;
  
    int n =0, k=0;
    
    
int find(int a){
    for(int i=0;i<k; i++)
    {
        if(D[i]==a){return true;}
    }
    return false;
    
}


bool check(int no){
    while(no!=0){
        int r = no %10;
        if (find(r)){
            return false;
        }
        no/=10;
        
    }
    
    return true;
}

void solve(){
    cin>>n >>k;

    
    for (int i = 0; i < k; i++) {
        /* code */
        cin>>D[i];
    }
    
    while(true){
       // cout<<n<<endl;
        
        if(check(n)){
            cout<<n;
            return;
        }
        else{
            n++;
        }
    }
    
    

}

int main() {

    solve();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#define intt long long

int main(){
	intt N, M; intt ans{}; std::cin >> N >> M;
	std::priority_queue<intt> que;
	for (intt i = 0; i < N; ++i) { intt a; std::cin >> a; que.push(a); }
	for (intt i = 0; i < M; ++i) { intt b = que.top(); que.pop(); que.push(b / 2); }
	while (!que.empty()) { ans += que.top(); que.pop(); }
	std::cout << ans << std::endl;

	return 0;
}

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

char w[10][8];

int dd[4][2] = {{0,1},{1,0},{0,-1},{-1,0}}, k;
char dr[8] = "RDLU";
int pos[2] = {0,1};

bool existWall(int i){
    int rem = (k+i+4)%4;
    if( pos[0] == 0 && rem == 3 ) return false;
    if( pos[1] == 0 && rem == 2 ) return false;
    if( rem%2 ){
        return w[2*pos[0]+2-rem][pos[1]] == '1';
    }else{
        return w[2*pos[0]][pos[1]-rem/2] == '1';
    }
}

int main(){
    for(int i = 0; i < 9; i++){
        cin >> w[i];
    }
    cout << 'R';
    k = 0;
    while( pos[0] != 0 || pos[1] != 0 ){
        for(int i = -1; i < 3; i++){
            if( existWall(i) ){
                k = (k+i+4)%4;
                break;
            }
        }
        pos[0] += dd[k][0];
        pos[1] += dd[k][1];
        cout << dr[k];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1132
import math
N, M = [int(i) for i in input().split()]
r = pow(10, 9) + 7
L = abs(N - M)

if L >= 2:
    print(0)
elif L == 0:
    E = 2*math.factorial(N)*math.factorial(M)
    print(E % r)
else:
    E = math.factorial(N)*math.factorial(M)
    print(E % r)

Measured memory_bytes: 5180
#include<iostream>
#include<cstdio>
#include<stack>
#include<string>
#include<sstream>
using namespace std;

stack<double> v;
string str;
int main(void){
	while(getline(cin,str)){
		stringstream ss(str);
		string num;
		while(ss >> num){
			if(num=="*"){
				double a=v.top();
				v.pop();
				double b=v.top();
				v.pop();
				v.push(a*b);
			}
			else if(num=="/"){
				double a=v.top();
				v.pop();
				double b=v.top();
				v.pop();
				v.push(b/a);
			}
			else if(num=="+"){
				double a=v.top();
				v.pop();
				double b=v.top();
				v.pop();
				v.push(a+b);
			}
			else if(num=="-"){
				double a=v.top();
				v.pop();
				double b=v.top();
				v.pop();
				v.push(b-a);
			}else{
				double c;
				stringstream numc;
				numc << num;
				numc >> c;
				v.push(c);
			}
		}
		double a=v.top();
		printf("%0.7f\n",a);
		v.pop();
	}
    return 0;
}

Measured memory_bytes: 1304
S = input()
month = ['01','02','03','04','05','06','07','08','09','10','11','12']
a = S[0:2]
b = S[2:4]
if a in month and b in month:
  print('AMBIGUOUS')
elif a in month:
  print('MMYY')
elif b in month:
  print('YYMM')
else:
  print('NA')

Measured memory_bytes: 3060
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    m,d=map(int,input().split())
    ans=0
    for i in range(1,m+1):
        for j in range(d+1):
            d_10=j//10
            d_1=j%10
            if d_10>=2 and d_1 >=2 and i == d_10*d_1:
                ans+=1
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 3060
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin >> n;
	vector<double> nums(n); fore(e, nums) cin >> e;
	sort(nums.begin(), nums.end());
	double cur = nums[0];
	forl(i, 1, n) {
		cur = (cur+nums[i])/2.0;
	}
	println(cur);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
string a;  
cin >> a;

  
  if(a=="SAT"){
cout << '1' << endl;}
  if(a=="FRI"){
cout << '2' << endl;}
if(a=="THU"){
cout << '3' << endl;}
if(a=="WED"){
cout << '4' << endl;}
if(a=="TUE"){
cout << '5' << endl;}
  if(a=="MON"){
cout << '6' << endl;}
  if(a=="SUN"){
cout << '7' << endl;}
  
  
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <algorithm>
#include <initializer_list>
#include <vector>
#include <algorithm>
#include <cstdlib>

std::int_fast64_t calc_diff(const std::initializer_list<std::int_fast64_t> source) {
  std::vector<std::int_fast64_t> buffer(source.begin(), source.end());
  std::sort(buffer.begin(), buffer.end());
  return *buffer.rbegin() - *buffer.begin();
}

std::int_fast64_t strategy1(const std::int_fast64_t x, const std::int_fast64_t y) {
  return calc_diff({x * (y / 3), x * (y / 3 + (y % 3 == 2 ? 1 : 0)), x * (y / 3 + (y % 3 >= 1 ? 1 : 0))});
}

std::int_fast64_t strategy2(const std::int_fast64_t x, const std::int_fast64_t y) {
  switch (y % 3) {
  case 0:
    return calc_diff({x * (y / 3), (x / 2) * (y / 3 * 2), (x / 2 + x % 2) * (y / 3 * 2)});
  case 1:
    return std::min(
      calc_diff({x * (y / 3 + 1), (x / 2) * (y / 3 * 2), (x / 2 + x % 2) * (y / 3 * 2)}),
      calc_diff({x * (y / 3), (x / 2) * (y / 3 * 2 + 1), (x / 2 + x % 2) * (y / 3 * 2 + 1)})
    );
  case 2:
    return std::min({
      calc_diff({x * (y / 3 + 2), (x / 2) * (y / 3 * 2), (x / 2 + x % 2) * (y / 3 * 2)}),
      calc_diff({x * (y / 3 + 1), (x / 2) * (y / 3 * 2 + 1), (x / 2 + x % 2) * (y / 3 * 2 + 1)}),
      calc_diff({x * (y / 3), (x / 2) * (y / 3 * 2 + 2), (x / 2 + x % 2) * (y / 3 * 2 + 2)})
    });
  default:
    std::exit(EXIT_FAILURE);
  }
}

int main() {
  std::int_fast64_t h, w;
  std::cin >> h >> w;
  std::cout << std::min({strategy1(h, w), strategy1(w, h), strategy2(h, w), strategy2(w, h)}) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " <<
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);

  int a,b,c;
  cin >> a >> b >> c;

  cout << max(0ll, c - (a - b)) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N,K;
    cin>>N>>K;
    vector<int>P(N);
    for(int i=0;i<N;i++){
        cin>>P[i];
    }
    sort(P.begin(),P.end());
    int ans=0;
    for(int i=0;i<K;i++){
        ans+=P[i];
    }
    cout<<ans<<endl;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

pair<int, int> get(string &s){
	pair<int, int> ret = {0, 0};
	for(auto ch : s){
		if(ch == '(')ret.first++;
		else if(ret.first)ret.first--;
		else ret.second++;
	}
	return ret;
}

bool cmp(pair<int, int> a, pair<int, int> b){
	return a.second < b.second;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int st = 0, en = 0;
	int n; cin>>n;
	vector<pair<int, int> > vp, vn;
	for(int i = 0; i < n; i++){
		string s; cin>>s;
		pair<int, int> a = get(s);
		if(!a.first)en += a.second;
		else if(!a.second)st += a.first;
		else if(a.first > a.second)vp.push_back(a);
		else vn.push_back(a);
	}
	sort(vp.begin(), vp.end(), cmp);
	for(auto x : vp){
		if(st < x.second){
			cout<<"No"<<endl;
			exit(0);
		}
		st += x.first - x.second;
	}
	sort(vn.begin(), vn.end());
	for(auto x : vn){
		if(en < x.first){
			cout<<"No"<<endl;
			exit(0);
		}
		en += x.second - x.first;
	}
	if(st == en)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 5244
package main

import (
	"fmt"
)

func sqrt(n int) int {
	lb := 1
	ub := n + 1
	m := 0
	for ub-lb > 1 {
		m = (lb + ub) / 2
		if m*m <= n {
			lb = m
		} else {
			ub = m
		}
	}
	return lb
}

func main() {
	var n int
	fmt.Scanf("%d", &n)
	fmt.Printf("%d:", n)
	for n > 1 {
		var i int
		for i = 2; i <= sqrt(n); i++ {
			if n%i == 0 {
				fmt.Printf(" %d", i)
				break
			}
		}
		if i > sqrt(n) {
			break
		}
		n /= i
	}
	if n > 1 {
		fmt.Printf(" %d", n)
	}
	fmt.Printf("\n")
}



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

using namespace std;

#define reps(i, n, m) for (int i = (int) (n); i < (int) (m); i++)
#define rep(i, n) reps(i, 0, (n))
#define all(v) (v).begin(), (v).end()

int main() {
    int n; cin >> n;
    vector<tuple<long long, long long, char, long long, string>> v;
    rep(i, n) {
        long long a, b, d;
        char c;
        string e;
        cin >> a >> b >> c >> d >> e;
        v.emplace_back(a, b, c, d, e);
    }
    sort(all(v));
    rep(i, n) {
        cout << get<0>(v[i]) << " ";
        cout << get<1>(v[i]) << " ";
        cout << get<2>(v[i]) << " ";
        cout << get<3>(v[i]) << " ";
        cout << get<4>(v[i]) << endl;
    }
}



Measured memory_bytes: 13024
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Feb  8 05:12:38 2019

@author: shinjisu
"""


def db(x):
    global debug
    if debug:
        print(x)


# スタックオーバーフロー
def gen(tstr):
    if len(tstr) <= len(S):
        for w in words:
            yield tstr + w
            for w2 in gen(tstr + w):
                yield w2


# RE
def solve():
    ans = False
    for genstr in gen(''):
        db(genstr)
        if genstr == S:
            ans = True
            break
    return ans


# TLE
def solve2():
    stack = list(words)
    while stack != []:
        str = stack.pop()
        db(('pop', str))
        if len(str) < len(S):
            for w in words:
                stack.append(str+w)
        elif len(str) == len(S) and str == S:
            return True
    return False


# 逆方向から探す
def solve3():
    string = S + ' '
    n = len(string)
    while n > 1:
        for w in words:
            db((string.rfind(w, 0, n),len(w),n))
            if string.rfind(w, 0, n) + len(w) + 1 == n:
                break
        else:
            return False
        db((n,w))
        n -= len(w)
    return True


debug = False
words = ('dream', 'dreamer', 'erase', 'eraser')
S = input()
db(S)
if solve3():
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3316
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

int main()
{
  ll n, k;
  cin >> n >> k;
  ll i = -1 + (n + (k - 1)) / k;
  ll c1 = (n - i * k);
  ll c2 = abs(n - (i + 1) * k);
  cout << (c1 < c2 ? c1 : c2) << endl;
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    string s, t;
    cin >> s >> t;
    reverse(t.begin(), t.end());
    cout << (s == t ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int a, b, c, d, n;

int main()
{
    string s;
    cin >> s;
    map<char, int> mp;
    for (int i = 0; i < s.size(); i++)
    {
        mp[s[i]]++;
    }
    bool flag = 0;
    for (auto &a : mp)
    {
        if (a.second != 2)
            flag = 1;
    }
    cout << (flag ? "No" : "Yes") << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  int a,b,c,d,x,y;
  cin>>a>>b>>c>>d;
  if(a>b){
    x=b;
  }else{
    x=a;
  }
  if(c>d){
    y=d;
  }else{
    y=c;
  }
  cout<<x+y<<endl;
  return 0;
}
  

Measured memory_bytes: 256
def is_valid_row?(row)
  (row.size-1).times do |j|
    return false if row[j]=='1' and row[j+1]=='1'
  end
  true
end

def valid_rows(w)
  (2**(w-1)).times.map do |i|
    sprintf("%0#{w-1}b0", i)  # last bit is always zero
  end.select do |row|
    is_valid_row?(row)
  end
end

$dp_count_valid_rows = {}

def count_valid_rows(w, ini, dx)
  key = "#{ini},#{dx}"
  if $dp_count_valid_rows[key]
    return $dp_count_valid_rows[key]
  end

  if dx == 0
    ans = valid_rows(w).count do |row|
      row[ini] == '0' and row[ini-1] == '0'
    end
  elsif dx == 1
    ans = valid_rows(w).count do |row|
      row[ini] == '1'
    end
  elsif dx == -1
    ans = valid_rows(w).count do |row|
      row[ini-1] == '1'
    end
  else
    ans = 0
  end
  $dp_count_valid_rows[key] = ans
  return $dp_count_valid_rows[key]
end

$dp_count_correct_amida = {}

D = 1000000007
  

def count_correct_amida(h, w, ini, dest)
  key = "#{h},#{ini},#{dest}"
  if $dp_count_correct_amida[key]
    return $dp_count_correct_amida[key]
  end

  if ini >= w or ini < 0
    ans = 0
  elsif h == 0
    ans = (dest == ini ? 1 : 0)
  else
    n0 = count_valid_rows(w, ini, 0) * count_correct_amida(h-1, w, ini, dest)
    n1 = count_valid_rows(w, ini, 1) * count_correct_amida(h-1, w, ini+1, dest)
    n2 = count_valid_rows(w, ini, -1) * count_correct_amida(h-1, w, ini-1, dest)
    ans = (n0 + n1 + n2) % D
  end
  $dp_count_correct_amida[key] = ans
  $dp_count_correct_amida[key]
end

H,W,K = readline.chomp.split.map(&:to_i)
puts count_correct_amida(H, W, 0, K-1)


Measured memory_bytes: 2300
#include<bits/stdc++.h>
  
using namespace std;
  
int main()
{
  int R, C;
  string S[128];
  int hash[1 << 16];
  for(int i = 0; i < 1 << 16; i++) hash[i] = __builtin_popcount(i);
  
  cin >> R >> C;
  for(int i = 0; i < R; i++) cin >> S[i];
  
  vector< int > latte(1 << C, -1);
  latte[0] = 0;
  const int mask = (1 << C) - 1;
  for(int y = 0; y < R; y++) {
    for(int x = 0; x < C; x++) {
      vector< int > malta(1 << C, -1);
      for(int j = 0; j < 1 << C; j++) {
        if(latte[j] == -1) continue;
  
        auto ch = [&](int &a, int b)
        {
          a = max(a, b);
        };
  
        const int beet = hash[j & ((1 << x) - 1)];
        if(beet + C - x > S[y].size()) ch(malta[j & ~(1 << x)], latte[j]);
        if(beet < S[y].size()) {
          int point = 0;
          if(x && (j >> (x - 1)) & 1) {
            if(beet && S[y][beet] == S[y][beet - 1]) ++point;
          }
          if(y && (j >> x) & 1) {
            int pos = (int) S[y - 1].size() - hash[j >> x];
            if(pos >= 0 && S[y - 1][pos] == S[y][beet]) ++point;
          }
          ch(malta[j | (1 << x)], latte[j] + point);
        }
      }
      latte = move(malta);
    }
  }
  cout << *max_element(begin(latte), end(latte)) * 2 << endl;
}

Measured memory_bytes: 3708
import math

n = int(input())
x = list(map(int, input().split()))
mod = 10 ** 9 + 7

fac = math.factorial(n - 1) % mod


def pow(n, p):
    res = 1
    while p > 0:
        if p % 2 == 0:
            n = n ** 2 % mod
            p //= 2
        else:
            res = res * n % mod
            p -= 1
    return res % mod


res = 0
for i in range(n - 1):
    d = x[n - 1] - x[i]
    res += (d * fac * pow(i + 1, mod - 2)) % mod

print(res % mod)


Measured memory_bytes: 62576
#include<iostream>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
long long int a[5],fir=-1000000,sec=-1000000,thi=-1000000,fou=-1000000,fif=-1000000;
int main(){
    for(int i=0;i<5;i++){
    cin>>a[i];
    if(a[i]>=fir){
	fif=fou;
	fou=thi;
    thi=sec;
    sec=fir;
    fir=a[i];}else
    if(a[i]>=sec){
	fif=fou;
	fou=thi;
    thi=sec;
    sec=a[i];}else
    if(a[i]>=thi){
	fif=fou;
	fou=thi;
    thi=a[i];}else
    if(a[i]>=fou){
	fif=fou;
    fou=a[i];}else
	{fif=a[i];}
	}
    cout<<fir<<" "<<sec<<" "<<thi<<" "<<fou<<" "<<fif<<endl;

	return 0;}


Measured memory_bytes: 1164
import itertools as it
D, G = map(int, input().split())
P, C = [], []
for _ in range(D):
    p, c = map(int, input().split())
    P.append(p)
    C.append(c)
A = it.permutations([i for i in range(D)])
ans = 10**9
for a in A:
    S, i, sub_ans = 0, 0, 0
    while 1:
        if S + (a[i] + 1) * 100 * P[a[i]] < G:
            S += (a[i] + 1) * 100 * P[a[i]]
            sub_ans += P[a[i]]
        else:
            x = (G - S) // ((a[i] + 1) * 100)
            if S + (a[i] + 1) * 100 * x < G:
                x += 1
            sub_ans += x
            S += (a[i] + 1) * 100 * x
        S += C[a[i]]
        if S >= G:
            if sub_ans < ans:
                ans = sub_ans
            break
        i += 1
print(ans)

Measured memory_bytes: 43588
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

int a[3005];
long long memo[3005][3005];
long long dp(int l,int r);
signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    int n;
    long long sum = 0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum += a[i];
    }
    memset(memo,-1,sizeof(memo));
    cout << dp(0,n-1) << "\n";
    return 0;
}
long long dp(int l,int r){
    if(memo[l][r] != -1){
        return memo[l][r];
    }
    if(l == r){
        return a[l];
    }else{
        return memo[l][r] = max(a[l]-dp(l+1,r),a[r]-dp(l,r-1));
    }
}


Measured memory_bytes: 71040
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 210000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
// long long C(int a,int b){
// 	if(a<b||b<0)return 0;
// 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
// }
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
char in[5];
int main(){
	scanf("%s",in);
	if(in[0]==in[1]||in[1]==in[2]||in[2]==in[3])printf("Bad\n");
	else printf("Good\n");
}

Measured memory_bytes: 128
// https://atcoder.jp/contests/dp/tasks/dp_h

#include <bits/stdc++.h>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <utility>

#define MOD 1000000007
#define INF 1e9 + 7

#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define F first
#define S second
#define pb push_back
#define all(p) p.begin(), p.end()
#define isOdd(n) n % 2
#define isEven(n) (n % 2 == 0)
#define sz(x) x.size()
#define deb(x) cout << #x << " : " << x << endl;

using namespace std;

typedef long long int lli;

typedef pair<lli, lli> pii;
typedef vector<lli> vi;
typedef set<lli> si;
typedef unordered_map<lli, lli> umii;
typedef unordered_set<lli> usi;

void dispvec(vi);
struct CustomCompare;

//-------------------------------------SOLVE HERE-------------------------------------

void solve()
{
    int rows, cols;
    cin >> rows >> cols;
    vector<string> maze(rows);
    for (int i = 0; i < rows; i++)
    {
        cin >> maze[i];
    }
    vector<vi> dp(rows, vi(cols, 0));
    dp[0][0] = 1;
    for (int i = 1; i < cols; i++)
    {
        if (maze[0][i] == '.')
            dp[0][i] = dp[0][i - 1];
    }
    for (int i = 1; i < rows; i++)
    {
        if (maze[i][0] == '.')
            dp[i][0] = dp[i - 1][0];
    }

    for (int r = 1; r < rows; r++)
    {
        for (int c = 1; c < cols; c++)
        {
            if (maze[r][c] == '.')
            {
                dp[r][c] = (dp[r - 1][c] + dp[r][c - 1]) % MOD;
            }
        }
    }
    cout << dp[rows - 1][cols - 1] << endl;
}

//-------------------------------------MAIN HERE--------------------------------------

int main()
{
#ifndef ONLINE_JUDGE
    freopen("/home/mufaddal/Mufaddal/Programs/Competitive/input", "r", stdin);
    freopen("/home/mufaddal/Mufaddal/Programs/Competitive/output", "w", stdout);
#endif
    int t = 1;
    // cin >> t;
    int i = 1;
    while (i <= t)
    {
        // cout << "Case #" << i << ": ";
        solve();
        i++;
    }

    return 0;
}

void dispvec(vi arr)
{
    vi::iterator itr = arr.begin();
    while (itr != arr.end())
    {
        cout << *itr << " ";
        itr++;
    }
    cout << endl;
}

struct CustomCompare
{
    //stable sort by first then second both in increasing
    bool operator()(const pii &i, const pii &j)
    {
        if (i.first == j.first)
            return i.second < j.second;
        return i.first < j.first;
    }
};

Measured memory_bytes: 12960
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  ll maxi=0,ans=0;
  for(int i=0;i<n;i++){
    if(maxi<=a.at(i)){
      maxi=a.at(i);
    }
    ans+=maxi-a.at(i);
  }
  cout << ans;
}
    

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

using namespace std;

typedef long long ll;

int n, a[107];

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

  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int sol = (int) 1e9;
  for (int i = 1; i <= 100; i++) {
    int co = 0;
    for (int j = 1; j <= n; j++) co += (a[j] - i) * (a[j] - i);
    sol = min(sol, co);
  }
  cout << sol << "\n";
}


Measured memory_bytes: 256
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
for _ in range(N):
    a = int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k] == a:
                A[j][k] = 0
result = "No"
for i in range(3):
    if sum(A[i]) == 0:
        result = "Yes"
    elif A[0][i] + A[1][i] + A[2][i] == 0:
        result = "Yes"
    elif A[0][0] + A[1][1] + A[2][2] == 0 or A[0][2] + A[1][1] + A[2][0] == 0:
        result = "Yes"
    else:
        None
print(result)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().solve(new Scanner(System.in));
	}
	
	public void solve(Scanner sc) {
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		
		for(int i=0; i<n; i++) {
			int ai = Integer.parseInt(sc.next());
			a[i] = ai;
		}
		quickSortAsc(a, 0, a.length-1);
		
		int min = a[0];
		int minMod = min;
		while(true) {
			for(int i=0; i<n; i++) {
				int mod = a[i] % min;
				
				if( mod == 1 ) {
					System.out.println(1);
					return;
				}
				
				if(mod != 0 && mod < minMod) {
					minMod = mod;
				}
			}
			
			if(minMod == min) {
				System.out.println(min);
				return;
			}
			min = minMod;
		}
	}
	
	private void quickSortAsc(int[] target, int left, int right) {
		if(left >= right) return;
		
		int pivot = target[(left+right)/2];
		
		int l = left;
		int r = right;
		while(l <= r) {
			while(target[l] < pivot) {l++;}
			while(target[r] > pivot) {r--;}
			if(l<=r) {
				int tmp = target[l];
				target[l] = target[r];
				target[r] = tmp;
				l++;
				r--;
			}
		}
		quickSortAsc(target, left, r);
		quickSortAsc(target, l, right);
	}
}


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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P   = pair<int, int>;

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

template <class T>
void dump_vector(const vector<T> &v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == len - 1 ? "\n" : " ");
    }
}

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

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

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

signed main() {
    int N;
    cin >> N;
    int cnt = 0;
    rep(i, 0, N) {
        int a;
        cin >> a;
        if (is_prime(a)) cnt++;
    }
    cout << cnt << "\n";
}



Measured memory_bytes: 3136