akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1000010;
int n,a[N],w[N],fa[N];
struct data{
    ll w;int s,x;
    bool operator <(const data &p)const{
        if(w*p.s!=p.w*s)return w*p.s<p.w*s;
        return x<p.x;
    }
}p[N];
set<data>Q;
int cnt=0,b[N];
inline int find(int x){return b[x]==x?x:b[x]=find(b[x]);}
int main(){
    scanf("%d",&n);
    for(int i=2;i<=n;i++)
        scanf("%d",&fa[i]);
    for(int i=1;i<=n;i++)scanf("%d",&w[i]);
    for(int i=1;i<=n;i++){
        p[i]=(data){w[i],1,i};
        Q.insert(p[i]);b[i]=i;
    }
    cnt=n;
    ll ans=0;
    data t;
    while(!Q.empty()){
      t=*Q.begin();Q.erase(t);
      int y=find(fa[t.x]);
        if(!y)continue;
      ans+=(t.s-t.w)*p[y].w;
        Q.erase(p[y]);
        data e=t;
        e.w+=p[y].w;e.s+=p[y].s;e.x=++cnt;
        b[cnt]=cnt;b[y]=cnt;b[find(t.x)]=cnt;
        fa[cnt]=fa[y];fa[t.x]=cnt;
        p[cnt]=e;
        Q.insert(e);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 28672
#include <iostream>

using namespace std;

int main(void)
{
    int A, B, C, x;

    cin >> A >> B >> C;

    x = C-(A-B);

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

    else{
	cout << "0" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  int sum = 0; 
  for(int i = 0; i < n; ++i){
    cin >> v[i];
    sum += v[i];
  }
  int temp = 0;
  int ans = INF;
  for(int i = 0; i < n; ++i){
    temp += v[i];
    ans = min(ans, abs(temp - (sum - temp)));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func rScan() []rune {
	return []rune(Scan())
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}
func bOut(f bool, x string, y string) {
	if f {
		fmt.Println(x)
	} else {
		fmt.Println(y)
	}
}
func mod(x, d int) int {
	x %= d
	if x < 0 {
		x += d
	}
	return d
}
func iSSPrint(x []int) {
	fmt.Println(strings.Trim(fmt.Sprint(x), "[]"))
}

var lp int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, lp)
	sc.Split(bufio.ScanWords)
	n, m := iScan(), iScan()
	a := make([][]int, 8)
	for i := 0; i < n; i++ {
		x, y, z := iScan(), iScan(), iScan()
		a[0] = append(a[0], x+y+z)
		a[1] = append(a[1], x+y-z)
		a[2] = append(a[2], x-y+z)
		a[3] = append(a[3], x-y-z)
		a[4] = append(a[4], -x+y+z)
		a[5] = append(a[5], -x+y-z)
		a[6] = append(a[6], -x-y+z)
		a[7] = append(a[7], -x-y-z)
	}
	ans := 0
	for i := 0; i < 8; i++ {
		sort.Sort(sort.Reverse(sort.IntSlice(a[i])))
		ans = larger(ans, sum(a[i][:m]))
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1960
#include<bits/stdc++.h>
#define m 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn=2e5+7;
int n,a[maxn];
int p1=m;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int cnt=0,num=1,flag=0;
    for(int i=0;i<n;i++){
        if(a[i]==1) flag=1;
        if(a[i]!=num) cnt++;
        else num++;
    }
    if(flag) cout<<cnt;
    else cout<<-1;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int N;
    cin >> N;
    string s, t;
    map<string, lli> x;
    lli cnt = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> s;
        sort(s.begin(), s.end());
        if (x[s] != 0)
        {
            cnt += x[s];
        }
        x[s]++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 11388
#include <iostream>

int main()
{
    int a = 0,b = 0;
    bool flag1,flag2;
    flag2 = false;
    while (true){
        flag1 = false;
        std::cin >> a >> b;
        if (a == 0 && b == 0){
            break;
}       if (flag2 == true){
            std::cout << std::endl;
}       flag2 = true;
        for (int i = a;i <= b;i++){
            if (i % 4 == 0 && i % 100 != 0){
                std::cout << i << std::endl;
                flag1 = true;
}           else if (i % 400 == 0){
                std::cout << i << std::endl;
                flag1 = true;
}
}
        if (flag1 == false){
            std::cout << "NA" << std::endl;
}
}
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

int main(void)
{
    int K, S;
    cin >> K >> S;

    int ans = 0;
    for(int x = 0; x <= K; ++x)
    {
        for(int y = 0; y <= K; ++y)
        {
            int z = S - x - y;
            if((0 <= z) && (z <= K))
                ans++;
        }
    }
    cout << ans << 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;
typedef long long ll;


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

  vector<int> people(n,k-q);
  
  for (int i = 0; i < q; i++){
    int a;
    cin >> a;
    a--;
    people[a] ++;
  }

   
for(int i = 0 ; i < n; i++){
if(people[i] > 0){
  puts("Yes");
}else {
  puts("No");
}
}
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	string s;
	int k,u,p,c;
	k=u=p=c=0;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='K') k++;
		else if(s[i]=='U') u++;
		else if(s[i]=='P') p++;
		else if(s[i]=='C') c++; 
	}
	cout<<min(k,min(u,min(p,c)))<<endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
signed main(){
	string s;
	cin>>s;
	if(s.size()%2){
		int a=0;
		f(i,s.size()-1){
			a*=10;
			if(i%2)a+=9;
		}
		a+=stoi(s)+1-pow(10,s.size()-1);
		cout<<a<<endl;
	}
	else{
		f(i,s.size()-1){
			if(i%2==0)cout<<9;
			else cout<<0;
		}
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <map>
#include <utility>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; ++i)
#define repr(i, j) FOR(i, j, 0)
#define INF (1 << 30)
#define MOD 1e9 + 7
#define pb push_back

typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

vector<int> x, y, nx, ny;

int main() {
	int N, M;
	scanf("%d %d", &N, &M);
	rep(i, N) {
		int a, b;
		scanf("%d %d", &a, &b);
		x.pb(a); y.pb(b);
	}
	rep(i, M) {
		int c, d;
		scanf("%d %d", &c, &d);
		nx.pb(c); ny.pb(d);
	}
	rep(i, N) {
		int mini = INF;
		int ans;
		rep(j, M) {
			int tmp = abs(x[i] - nx[j]) + abs(y[i] - ny[j]);
			if (mini > tmp) {
				mini = min(mini, tmp);
				ans = j + 1;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


int main(){
  int n;
  cin>>n;
  int a[n+1];
  int b[n];
  ll sum=0;
  REP(i,n+1){
    cin>>a[i];
  }
  REP(i,n){
    int b;
    cin>>b;
    if(b>a[i]){
      b=b-a[i];
      sum+=a[i];
      a[i]=0;
      if(b>a[i+1]){
        b=b-a[i+1];
        sum+=a[i+1];
        a[i+1]=0;
      }else{
        sum+=b;
        a[i+1]-=b;
      }
    }else{
      sum+=b;
    }

  }
  cout<<sum<<endl;
}

Measured memory_bytes: 640
import math

def ten_sum(n):
    s = 0
    while n > 0:
        s += n % 10
        n = math.floor(n / 10)
    return s

lst = []
N = int(input())
for A in range(1, N):
    lst.append(ten_sum(A) + ten_sum(N - A))


print(min(lst))

Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(long long i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(long long i=int(n);i>0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+5  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
//ll const mod=998244353;
ll const mod=1e9+7;
const ll MAX=1000005;
using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvl =vector<vector<ll>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}


int main(){
    int n;
    cin>>n;
    vi a(n);
    rep(i,n)cin>>a[i];
    sort(rall(a));
    ll v=0,h=0;
    rep(i,n-1){
        if(a[i]==a[i+1]){
            if(v==0)v=a[i];
            else if(h==0)h=a[i];
            i++;
        }
    }
    cout<<h*v<<endl;
    return 0;
}

Measured memory_bytes: 3728
main=do
 aa<-getLine
 ab<-getLine
 ac<-getLine
 let a=words$aa++" "++ab++" "++ac
 getLine
 b<-lines<$>getContents
 putStrLn$if length(filter(\ls->f b(map(\id->a!!id)ls))[[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]])==0 then"No"else"Yes"
f b[]=True
f b(a:as)=if a`elem`b then f b as else False


Measured memory_bytes: 380
# coding: utf-8
# Your code here!

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

m = 0
t = 1
for i in range(61):
    count = 0
    for j in range(N):
        count += A[j] % 2
        A[j] //= 2
    m += ((t * (N - count)) % int(1e9+7)) * count % int(1e9+7)
    m %= int(1e9+7)
    t *= 2
    t %= int(1e9+7)
    
print(m)

Measured memory_bytes: 122936
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
#include<queue>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
const int mod = 1000000007;
const int INF = 1000000001;
const long long LINF = 1e18;
const int MAX = 510000;

int main() {
	long long int n,sum=0;
	cin >> n;
	vector<long long int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
		sum += a.at(i);
	}
	long long int m = 0;
	int i = 0;
	int mean = 0;
	while (m +a.at(i)<= sum / 2) {

		m += a.at(i);
		i++;
	
	}
	mean = i;
	long long int nokori = 0;
	while (i < n) {
		nokori += a.at(i);
		i++;
	}
	cout << min(abs(m+a.at(mean)-(nokori-a.at(mean))),abs(m - nokori))<< endl;
	
		return 0;
	}


Measured memory_bytes: 4848
#include <bits/stdc++.h>
#define sc scanf
#define pf printf
#define pb push_back
using namespace std;

void solve(){
	
	int a,b;
	sc("%d%d",&a,&b);
	int sum =0;
	int cnt =0;
	for(int i=0;i<a;i++){
		if(sum<=b)cnt++;
		int x ;
		sc("%d",&x);
		sum+=x;
	}
	
	if(sum<=b)cnt++;
	
	cout<<cnt<<endl;
		
}

int main() {
	solve();
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	static final int INF = Integer.MAX_VALUE/2;
	
	static class Edge{
		int from;
		int to;
		int cost;
		Edge(int from,int to,int cost){
			this.from = from;
			this.to = to;
			this.cost = cost;
		}
	}
	
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int V = stdIn.nextInt();
		int E = stdIn.nextInt();
		int r = stdIn.nextInt();
		
		int[] d = new int[V];
		Arrays.fill(d,INF);
		d[r] = 0;
		
		ArrayList<Edge> list = new ArrayList<Edge>();
		for(int i=0;i<E;i++){
			int s = stdIn.nextInt();
			int t = stdIn.nextInt();
			int l = stdIn.nextInt();
			Edge edge = new Edge(s,t,l);
			list.add(edge);
		}
		
		for(int i=0;i<V;i++){
			for(int j=0;j<E;j++){
				Edge edge = list.get(j);
				if(d[edge.from]!=INF && d[edge.to]>d[edge.from]+edge.cost){
					d[edge.to] = d[edge.from]+edge.cost;
					if(i==V-1){
						System.out.println("NEGATIVE CYCLE");
						return;
					}
				}
			}
		}
		
		for(int i=0;i<V;i++){
			if(d[i]>INF/2){
				System.out.println("INF");
			}
			else{
				System.out.println(d[i]);
			}
		}
	}
}

Measured memory_bytes: 29656
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int n;
    cin >> n;
    int a[n],mn=1000000000,mx=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        mn = min(mn,a[i]);
        mx = max(mx,a[i]);
    }

    cout << mx-mn << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
    char s[100000],a;
    int i,j;
    scanf("%s",s);
    for(a='a';a<='z';a++){
        i=0; j=0;
        while(s[i]!='\0'){
            if(a!=s[i])
                j++;
            i++;
        }
        if(j==strlen(s)){
            printf("%c\n",a);
            return 0;
        }
    }
    printf("None\n");
    return 0;
}


Measured memory_bytes: 1764
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		ou.println(Math.abs(Integer.parseInt(sc.next()) * 60 + Integer.parseInt(sc.next()) - Integer.parseInt(sc.next()) * 60 - Integer.parseInt(sc.next())) - Integer.parseInt(sc.next()));
		ou.flush();
	}
}

Measured memory_bytes: 35880
import java.util.*;
import java.io.*;
import java.math.*;
import java.util.Collections;

class Main {

    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

    public static final long gcd(final long... param) {
        final long len = param.length;
        long g = gcd(param[0], param[1]);
        for (int i = 1; i < len - 1; i++) {
            g = gcd(g, param[i + 1]);
        }
        return g;
    }


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long K = sc.nextLong();

        long sum = 0;
            for (int i = 1; i <= K; i++)         {
                for (int j = 1; j <= K; j++)     {
                    for (int k = 1; k <= K; k++)         {
                    sum += gcd(i, j, k);
                }
            }

        }

        System.out.println(sum);
    }

}


Measured memory_bytes: 54684
N = gets.to_i

min = 999999
def digsum(n);n.to_s.split(//).map(&:to_i).inject(:+);end

for a in 1..(N-1)
    b = N - a
    sum = digsum(a) + digsum(b)
    if sum < min
        min = sum
    end
end
puts min

Measured memory_bytes: 1916
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
        int a, b, c;
        int cnt = 0, coins = 0;
        cin >> a >> b >> c;
        while (true) {
                cnt++;
                if(coins >= c) {
                        cnt--;
                        break;
                }
                coins += a;
                if(cnt % 7 == 0) {
                        coins += b;
                }

        }
        cout << cnt << endl;
        return 0;
}



Measured memory_bytes: 3100
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
    int n,a,c1=0,c2=0,b;
    while(cin>>n)
    {


    for(int i=0;i<n;i++)
    {
        scanf("%d",&a);
        if(a%4==0) c1++;
        else if(a%2==0) c2++;
    }
    c1+=c2/2;
    if(c1>=n/2) printf("Yes");
    else printf("No");
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    int n,x,y,a;
    cin>>n>>x>>y;
    x--;
    y--;
    int d[2005]={};
    REP(i,n){
        FOR(j,i+1,n){
            a=min(j-i,min(abs(x-i),abs(y-i))+min(abs(x-j),abs(y-j))+1);
            d[a]++;
        }
    }
    FOR(i,1,n) cout<<d[i]<<endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

typedef long long ll;
typedef pair<ll, int> P;

int main(){
	int n,k;
	string s;
	vector<int> v;
	v.push_back(0);

	cin >> n >> k;
	cin >> s;

	if(s[0]=='0'){
		v.push_back(0);
	}
	for(int i=1;i<n;i++){
		if(s[i-1]!=s[i]){
			v.push_back(i);
		}
	}
	if(s[n-1]=='0'){
		v.push_back(n);
	}
	v.push_back(n);
	int m = v.size();
	int ans = 0;
	for(int i=0;i<m;i+=2){
		ans = max(ans,v[min(i+2*k+1,m-1)]-v[i]);
	}
	//for(int i=0;i<m;i++) cout << v[i] << endl;
	

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1020
/*
 Shahadat Hossain
 I.C.T Department
 Comilla University
 Session: 2013-2014
 */

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define UNIQUE(x)       x.erase(unique(all(x)), x.end())

#define fs              first
#define sc              second
#define pb              push_back

#define sz(x)           (int)x.size()
#define all(v)          v.begin(),v.end()
#define D(x)            cerr << #x " = " << x << '\n'
#define ms(a,b)         memset(a, b, sizeof(a))
#define valid(x,y)      x>=0 && y>=0 && x<n && y<m

#define input           freopen("/Users/shahadat/Desktop/input.txt", "r", stdin)
#define output          freopen("/Users/shahadat/Desktop/output.txt", "w", stdout)

#define endl            '\n'
#define eps             1e-5
#define yes             printf("YES\n")
#define no              printf("NO\n")

#define int             long long

int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
inline int Set(int n,int pos) { return n = n | (1 << pos); }
inline int Reset(int n,int pos) { return n = n & ~(1 << pos); }
inline bool Check(int n,int pos) { return (bool)(n & (1 << pos)); }
inline int Count(ll n) { return __builtin_popcountll(n); }

int const N = 1e5 + 5;
int const MOD = 1e9 + 7;
vector<int> store;
int dp[N][20];

int fun(int pos, int rem){
    if(pos == store.size()){
        if(rem == 5) return 1;
        return 0;
    }
    
    if(dp[pos][rem] != -1)
        return dp[pos][rem];
    
    int left = store[pos] == -1 ? 0 : store[pos];
    int right = store[pos] == -1 ? 9 : store[pos];
    
    int res = 0;
    for(int i = left; i <= right; i++){
        res += fun(pos + 1, (rem * 10 + i) % 13);
        res %= MOD;
    }
    return dp[pos][rem] = res;
}


int32_t main(){
    
    string str;
    cin >> str;
    
    ms(dp, -1);
    for(auto c: str){
        if(c == '?') store.pb(-1);
        else store.pb(c - '0');
    }
    

    cout << fun(0, 0);
}


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

long long ncr[250][250] = {};

long long f(long long N){
	return (1ll<<N) - 1;
}
long long g(long long N){
	return (1ll<<N);
}

void output(vector<int> a){
	for(int i = 0 ; i < a.size() ; i++){
		cout << a[i];
		if( i + 1 == a.size() ) cout << endl;
		else cout << " ";
	}
	return;
}

int check(vector<int> a){
	int ans = 0;
	for(int i = 1 ; i < (1<<a.size()) ; i++){
		vector<int> b;
		for(int j = 0 ; j < a.size() ; j++){
			if( i >> j & 1 ){
				b.push_back(a[j]);
			}
		}
		if( b.size() % 2 == 0 ){
			int f = 1;
			for(int j = 0 ; j < b.size() / 2 ; j++)
				if( b[j] != b[j+b.size()/2]) f = 0;
			if(f) ans++;
		}
	}
	return ans;
}

void solve(long long N){
	
	ncr[0][0] = 1;
	for(int i = 0 ; i < 220 ; i++){
		for(int j = 0 ; j < 220 ; j++){
			ncr[i+1][j] += ncr[i][j];
			ncr[i+1][j+1] += ncr[i][j];
		}
	}
	vector<int> v;
	for(int i = 1 ; i <= 40 ; i++){
		if( f(i+1) > N ){
			for(int j = 1 ; j <= i ; j++){
				v.push_back(j);
			}
			N -= f(i);
			break;
		}
	}
	//cout << " rN" << N << endl;
	vector<int> need;
	while(N > 1 ){
		for(int i = 1 ; i <= v.size() ; i++){
			if( g(i+1) > N ){
				//cout << i << " " << g(i) << endl;
				need.push_back(i);
				N -= g(i);
				break;
			}
		}
	}

	vector<int> b = v;
	int x = 50;
	for(int i = 0 ; i < need.size() ; i++){
		v.push_back(x);
		b.insert(b.begin()+need[i],x++);
	}
	vector<int> X;
	for( auto w : v ){ X.push_back(w); } 
	for( auto w : b ){ X.push_back(w); }
	if(N == 1 ){
		X.push_back(100);	
		X.push_back(100);	
		
	}	
	cout << X.size() << endl;
	output(X);
	//cout << check(X) << endl;
	//cout <<  "< ans " << endl;
	

	
}

int main(){	
	long long N;
	scanf("%lld",&N);
	solve(N);
	return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#define MAX 3000
#define MOD 1000000007
using namespace std;
vector<int> v,a;
bool check()
{
	sort(a.begin(),a.end());
	sort(v.begin(),v.end());
	for(int i=0;i<a.size();++i)
		if(a[i]^v[i])
			return false;
	return true;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	for(int i=0,x;i<n;++i)
	{
		cin>>x;
		a.push_back(x);
		v.push_back(abs(n-i-1-i));
	}
	if(!check())
		cout<<"0"<<endl;
	else
	{
		n >>= 1;
		long long ans = 1;
		for(int i=1;i<=n;++i)
			ans *= 2LL, ans %= MOD;
		cout<<ans<<endl;
	}
	return 0;
}

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

void printv(vector<ll> v) {
  for (ll i : v)
    cout << i << endl;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> st(n + 1, 1);
  rep(i, m) {
    int c, d;
    cin >> c >> d;
    for (int j = c; j < d; j++)
      st[j] = 3;
  }
  cout << accumulate(st.begin(), st.end(), 0) << endl;
}



Measured memory_bytes: 3108
// finish date: 2018/07/07
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector <vector<int>> vvi;
typedef vector <vector<vector < int>>>
vvvi;
typedef vector <ll> vl;
typedef vector <vector<ll>> vvl;
typedef vector<double> vd;
typedef vector <vector<double>> vvd;
typedef vector <vector<vector < double>>>
vvvd;
typedef vector<bool> vb;
typedef vector <vector<bool>> vvb;
typedef vector <string> vs;
typedef vector<char> vc;
typedef vector <vector<char>> vvc;
typedef pair<int, int> pii;
const int bigmod = 1000000007;
const int INF = 1050000000;


int main() {
    int N;
    cin >> N;
    int num = 1 << N;
    vi A(num);
    rep(i, num) cin >> A[i];
    vector <pii> max1(num), max2(num);
    max1[0] = pii(A[0], 0);
    max2[0] = pii(0, -1);
    FOR(i, 1, num) {
        max1[i] = pii(A[i], i);
        max2[i] = pii(0, -1);
        rep(j, N) {
            if (i & (1 << j)) {
                int idx = i - (1 << j);
                if (max1[i] <= max1[idx]) {
                    if (max1[i] != max1[idx]) {
                        swap(max1[i], max2[i]);
                        max1[i] = max1[idx];
                    }
                    if (max2[i] < max2[idx]) {
                        max2[i] = max2[idx];
                    }
                } else if (max2[i] < max1[idx]) {
                    max2[i] = max1[idx];
                }
            }
        }
//        if (A[i] > max2[i]) {
//            max2[i] = A[i];
//            if (max2[i] > max1[i]) swap(max2[i], max1[i]);
//        }
//        cout << max1[i] + max2[i] << endl;
    }
    int ma = -1;
    FOR(i, 1, num) {
        ma = max(ma, max1[i].first + max2[i].first);
        cout << ma << endl;
    }


    return 0;
}



Measured memory_bytes: 8192
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>

using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
constexpr int mod = 1e9+7;
constexpr int INF32 = numeric_limits<int>::max();
constexpr Int INF64 = numeric_limits<Int>::max();
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rer(i,l,r) for(int(i)=(l); (i)<(r); ++(i))
#define rep(i,n) rer(i,0,n)
#define gnr(i,l,r) for(int (i)=(r)-1; (i)>=(l); --(i))
#define pri(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(i,n-1)cout<<a[i]<<' '; if(n)cout<<a[n-1]<<'\n';}
#define prip(p) cout<<(p).fi<<' '<<(p).se<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

Int n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;

int main(){
  cin.tie(nullptr); ios::sync_with_stdio(0);
  //cout<<fixed<<setprecision(20);

  cin>>x>>y>>q;
  rep(i,q){
    if(i&1){
      x+=y/2;y/=2;
    }else{
      y+=x/2;x/=2;
    }
  }
  cout<<x<<' '<<y<<'\n';
}


Measured memory_bytes: 3628
import java.util.*;
import java.io.*;
public class Main{
/// functions
static long gcd(long a,long b){if(b==0){return a;}return gcd(b,a%b);}
static long Modpow(long a,long p,long m){if(p==1){return a;}long x=Modpow(a,p/2,m);x=(x*x)%m;return (p&1l)!=0? (x*a)%m:x;}
static long Modmul(long a,long b,long m){return ((a%m)*(b%m))%m;}
static long ModInv(long a,long m){return Modpow(a,m-2,m);}
static long nck(int n,int r,long m){if(r>n){return 0l;}return Modmul(f[n],ModInv(Modmul(f[n-r],f[r],m),m),m);}
// end
static long[] f;

public static void main(String[] args) throws FileNotFoundException, IOException{
       Scanner s=new Scanner(System.in);
       StringBuilder sb=new StringBuilder();
       BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.out));
       int n=s.nextInt(),m=s.nextInt();
       if(m>=n){out.write("Yes");}
       else{out.write("No");}
       out.flush();

      /* long res=0;
       String m=Integer.toString(n);
       int k=m.length();
       for(int i=11;i<=n;i++){
       	if(i%10==0){continue;}
       	String ss=Integer.toString(i);
       	int l=ss.length();
       	long tmp=0;
       	if((ss.charAt(l-1)-'0'<=m.charAt(0)-'0')&&(ss.charAt(0)-'0'<=m.charAt(k-1)-'0')){
       		 tmp++;
       		 long tmp1=0;
       		 if((ss.charAt(l-1)==ss.charAt(0))&&l>1){tmp1++;}
       		for(int j=1;j<k-1;j++){
       			int xx=m.charAt(j)-'0';
       			tmp=(long)tmp*xx;
       		}
       		 tmp+=tmp1;
       		res+=tmp;
       	}
       	//out.write(i+" "+tmp+"\n");
       }
       res+=Math.min(9,n);
       for(int i=1;i<=Math.min(9,n);i++){
       		String ss=Integer.toString(i);
       	int l=ss.length();
       	long tmp=0;
       	if((ss.charAt(l-1)-'0'<=m.charAt(0)-'0')&&(ss.charAt(0)-'0'<=m.charAt(k-1)-'0')){
       		tmp++;
              for(int j=1;j<k-1;j++){
       			int xx=m.charAt(j)-'0';
       			tmp=(long)tmp*xx;
       		}
       	}
       	   res+=tmp;
       }
       out.write(res+"");
        out.flush();*/
  }
}


Measured memory_bytes: 21844
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N = II()
    S = set()
    for i in range(N):
        s = input()
        S.add(s)
    print(len(S))
    

if __name__ == '__main__':
    solve()


Measured memory_bytes: 31104
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n;
		String name[];
		int d[][];
		int score[];

		while (true) {
			n = sc.nextInt();
			if (n == 0) {
				break;
			}

			name = new String[n];
			d = new int[n][30];
			score = new int[n];

			for (int i = 0; i < n; i++) {
				name[i] = sc.next();
				int k = sc.nextInt();
				for (int j = 0; j < k; j++) {
					d[i][sc.nextInt()] = 1;
				}
			}

			for (int i = 0; i < 30; i++) {
				int p = n + 1;
				for (int j = 0; j < n; j++) {
					p -= d[j][i];
				}
				for (int j = 0; j < n; j++) {
					if (d[j][i] == 1) {
						score[j] += p;
					}
				}
			}

			int minId = 0;
			for (int i = 0; i < n; i++) {
				if (score[i] < score[minId] || (score[i] == score[minId] && name[i].compareTo(name[minId]) < 0)) {
					minId = i;
				}
			}

			System.out.println(score[minId] + " " + name[minId]);
		}
	}
}

Measured memory_bytes: 31856
#include <stdio.h>

int main(int argc, char **argv)
{
	int s,h,m;
	scanf("%d",&s);
	h = s / 3600;
	s = s % 3600;
	m = s / 60;
	s = s % 60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int llint;
int main() {
	llint n, k;
	cin >> n >> k;
	vector<pair<llint, llint>>a(n);
	for (int i = 0;i < n;i++) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a.begin(), a.end());
	llint cnt = 0;
	llint ans;
	for (int i = 0;i < n;i++) {
		cnt += a[i].second;
		if (k <= cnt) {
			ans = a[i].first;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;

int main() {
	double r;
	cin >> r;
	r = r * 3.1415926535 * 2;
	cout << r << endl;
	return 0;
}

Measured memory_bytes: 3784
#include <iostream>

 

using namespace std;

 

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


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(void)
{
	int n;
	cin >> n;
	vector< string > bubble(n),select(n);
	for(int i=0;i<n;i++){
		cin >> bubble[i];
		select[i]=bubble[i];
	}

	string a;
	for(int i=0;i<n;i++){
		for(int j=n-1;i<j;j--){
			if(bubble[j][1]<bubble[j-1][1]){
				a=bubble[j];
				bubble[j]=bubble[j-1];
				bubble[j-1]=a;
			}
		}
	}
    cout << bubble[0];
	for(int i=1;i<n;i++) cout << " " << bubble[i];
	cout << endl << "Stable" << endl;

    int b;
	for(int i=0;i<n;i++){
		b=i;
		for(int j=i;j<n;j++){
			if(select[j][1]<select[b][1]){
				b=j;
			}
		}
		a=select[i];
		select[i]=select[b];
		select[b]=a;
	}
	cout << select[0];
	for(int i=1;i<n;i++) cout << " " << select[i];
	if(bubble==select) cout << endl << "Stable" << endl;
    else cout << endl << "Not stable" << endl;
	return 0;
}

Measured memory_bytes: 1216
import itertools
import math

n, m = map(int, input().split())
k = []
a = []
for i in range(n):
    l = list(map(int, input().split()))
    k.append(l[0])
    a.append(l[1:])

dic = {}
for i in range(len(a)):
    for j in range(len(a[i])):
        if a[i][j] not in dic:
            dic[a[i][j]] = 1
        else:
            dic[a[i][j]] += 1

count = 0
for i in range(len(dic.keys())):
    if list(dic.values())[i] == n:
        count += 1

print(count)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define ll long long
#define V vector<long long>
#define VV vector<vector<long long>>
#define VVV vector<vector<vector<long long>>>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
using namespace std;

int main() {
    string a,b;
    cin>>a>>b;
    VV dp(a.size()+1,V(b.size()+1,0));
    rep(i,a.size()+1)dp[i][0]=i;
    rep(i,b.size()+1)dp[0][i]=i;
    rep(i,a.size()){
        rep(j,b.size()){
            if(a[i]==b[j]){
                dp[i+1][j+1]=min(dp[i+1][j]+1,min(dp[i][j+1]+1,dp[i][j]));
            }else{
                dp[i+1][j+1]=min(dp[i+1][j]+1,min(dp[i][j+1]+1,dp[i][j]+1));
            }
        }
    }
    cout<<dp[a.size()][b.size()]<<endl;
}



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

using namespace std;
#define int1(a) scanf("%d",&a)
#define int2(a,b) scanf("%d %d",&a,&b)
#define int3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define int4(a,b,c,d) scanf("%d %d %d %d",&a,&b,&c,&d)
#define lint1(a) scanf("%lld",&a)
#define lint2(a,b) scanf("%lld %lld",&a,&b)
#define lint3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define lint4(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define lli long long int
#define pint(x) printf("%d",x)
#define ps printf(" "); 
#define plint(x) printf("%lld",x)
//#define sort(a,n) qsort(a,n,sizeof(int),cmpfunc)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define bg begin()
#define ed end()
#define itn int
#define Set(a, s) memset(a, s, sizeof (a))
#define mod 1000000007
#define tmod(k) if ((k) >= mod) k %= mod;
#define EPS 1e-9
#define endl '\n'
#define nl printf("\n");
#define fors(i,n) for(int i=0; i<n; i++)
#define fore(i,n) for(int i=n-1; i>=0; i--)
#define forv(i,a,n) for(int i=a; i<n; i++)
#define fora(i,ele) for(auto i: ele)
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
typedef pair<int,int> pii;
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
void ASCII_Chart(){int i,j,k;printf("ASCII Chart:(30-129)\n");forv(i,30,50){fors(j,5){k=i+j*20;printf("%3d---> '%c'   ",k,k);}printf("\n");}}
const int INF = 0x3f3f3f3f;
#define pi 3.14159265
#define PI 2*acos(0.0)
float roundoff(float val, float p){ return floor(val*pow(10.0,p)+0.5)/pow(10.0,p);}

//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};
//int dx[]={1,-1,0,0}; int dy[]={0,0,1,-1};
class node{
public:
	int id;
	int prio;
	int prd;
};

class compare{
public:
	bool operator()(node &n1, node &n2){
		if(n1.prio>n2.prio)//ascending
			return true;
		else if(n1.prio==n2.prio){
			return n1.id>n2.id;
		}
		return false;
	}
};
//priority_queue<node, vector<node>, compare> pq;

int main(void) {
    ios_base::sync_with_stdio(true);
    cin.tie(NULL);
    cout.tie(NULL);
    /*#ifdef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #else
    // online submission
    #endif*/
    st str;
    cin>>str;
    st st2 = "FESTIVAL";
    fors(i,str.length()-8){
        cout<<str[i];
    }
    //reverse(s
    
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	string s,t;
	cin>>s>>t;
	int n=s.size();
	map<char,char> mp1,mp2;
	rep(i,n){
		if(mp1.find(s[i])!=mp1.end()){
			if(mp1[s[i]]!=t[i]){
				cout<<"No"<<endl;
				return 0;
			}
		}
		if(mp2.find(t[i])!=mp2.end()){
			if(mp2[t[i]]!=s[i]){
				cout<<"No"<<endl;
				return 0;
			}
		}
		mp1[s[i]]=t[i];
		mp2[t[i]]=s[i];
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 916
N, K = map(int, input().split())
l = [int(i) for i in input().split()]
if (len(l) - K) % (K - 1) == 0:
    print(int((len(l) - K) / (K - 1)) + 1)
else:
    print(int((len(l) - K) / (K - 1)) + 2)


Measured memory_bytes: 13880
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin>>a>>b;
    int e,f;
    int mi=100001,ma=0;
   for(int i=0;i<b;i++){
       cin>>e>>f;
       ma=max(ma,e);
       mi=min(mi,f);
   }
   if(mi-ma+1>0)cout<<mi-ma+1<<endl;
   else cout<<0<<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  M = 1000005;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i,N) cin >> A.at(i);
  vector<int> cnt(M);
  sort(A.begin(), A.end());
  for (int x: A) {
    if (cnt.at(x) != 0) {
      cnt.at(x) = 2;
      continue;
    }
    for (int i = x; i < M ; i+=x){
      cnt.at(i)++;
    }
  }
  int ans = 0;
  for (int x: A) {
    if (cnt.at(x) == 1) ans++;
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 7964
n = input()
n = int(n)
# strs= input().split()
hashs = {}

for i in range(n):
    s = input()
    if s not in hashs.keys():
        hashs[s] = 1
    else:
        hashs[s] += 1
# sorted(hashs.items(), key=lambda item:item[1])
maxs = 0
for key, value in hashs.items():
    maxs = max(maxs, value)

res = []
for key, value in hashs.items():
    if value == maxs:
        res.append(key)
res.sort()
for m in range(len(res)):
    print(res[m])

Measured memory_bytes: 32096
#include<iostream>
#include<vector>

using namespace std;

int main(){
    int N, M; cin >> N >> M;
    vector<int> elevation(N + 1);
    vector<int> adjency[N + 1];
    for(int i = 1;i <= N;++i){
        int H; cin >> H;
        elevation[i] = H;
    }
    for(int i = 0;i < M;++i){
        int A, B; cin >> A >> B;
        if(elevation[A] <= elevation[B]){
            adjency[A].push_back(B);
        }
        if(elevation[B] <= elevation[A]){
            adjency[B].push_back(A);
        }
    }
    int result = 0;
    for(int i = 1;i <= N;i++){
        if(adjency[i].empty()){
            ++result;
        }
    }
    cout << result;
}

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

#define ff                  first
#define sf                  scanf
#define pf                  printf
#define ss                  second
#define ppb                 pop_back
#define pb                  push_back
#define MP                  make_pair
#define MAXN                10000
#define MOD                 100000007
#define inf                 0x3f3f3f3f
#define PI                  (2.0*acos(0.0))
#define INF                 0x3f3f3f3f3f3f3f3f
#define rev(v)              reverse(all(v))
#define all(v)              v.begin(), v.end()
#define __lcm(x, y)         (x * y) / __gcd(x, y)
#define FOR(i, x, y)        for(int i = x; i < y; i++)
#define RFOR(i, x, y)       for(int i = x; i >= y; i--)
#define MEM(arr, val)       memset(arr, val, sizeof(arr));
#define unq(v)              (v).resize(unique(all(v)) - v.begin())
#define READ()              freopen("input.txt", "r", stdin)
#define WRITE()             freopen("output.txt", "w", stdout)
#define si(n)               scanf("%d", &n)
#define sl(n)               scanf("%lld", &n)
#define sii(a, b)           scanf("%d %d", &a, &b)
#define sll(a, b)           scanf("%lld %lld", &a, &b)
#define siii(a, b, c)       scanf("%d %d %d", &a, &b, &c)
#define slll(a, b, c)       scanf("%lld %lld %lld", &a, &b, &c)
#define siiii(a, b, c, d)   scanf("%d %d %d %d", &a, &b, &c, &d)
#define sllll(a, b, c, d)   scanf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define vout(v)             for(int i = 0; i < v.size(); i++) {cout << v[i]; if(i < v.size() - 1) cout << ' '; else cout << endl;}

int main(){
        int n, k; cin >> n >> k;
        map<int, int> mp;

        FOR(i, 0, n){
            int x; cin >> x;
            mp[x]++;
        }
        int ans = n;

        while(true){
            int tmp = ans, flg = 0;
            while(tmp > 0){
                if(mp[tmp % 10]) flg = 1;
                tmp /= 10;
            }
            if(flg == 0) break;
            else ++ans;
        }
        cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
use std::io;
use std::collections::VecDeque;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin
        .read_line(&mut buf)
        .expect("ERROR Can't read array size");
    let n:usize = buf.trim().parse().unwrap();
    let mut buf = String::new();
    stdin
        .read_line(&mut buf)
        .expect("ERROR Can't read array size");
    let mut a: Vec<i64> = buf.split_whitespace()
        .map(|n| n.parse().unwrap())
        .collect();

    let mut ans = 0i64;
    let mut flag = true;

    while flag {
        flag = false;
        for i in 0..n {
            let x  = a[i] / (n as i64);
            if x > 0 {
                for j in 0..n {
                    if j!=i {
                        a[j] += x;
                    }
                }
                ans += x;
                a[i] = a[i] % (n as i64);
                flag = true;
            }
        }
    }
    println!("{}", ans);

}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
   int r,g,b;
   int num;
   
   cin >> r >> g >> b;
   
   num = (10*g)+b;

   
   if(num%4==0)
        cout << "YES";
    else
        cout << "NO";
   
   
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int n,m=42;
bool vis[100010];
int main()
{
	scanf("%d",&n);
	if (n==3){printf("2 5 63");return 0;}
	for (int i=2;i<=30000;i+=2) vis[i]+=1;
	for (int i=3;i<=30000;i+=3) vis[i]+=2;
	int tim=n/8;
	n=n%8;
	for (int i=1;i<=12*tim;i++)
		if (vis[i]) printf("%d ",i);
	int nw=6*tim*2;
	if (n==1) printf("%d",nw+6);
	if (n==2) printf("%d %d",nw+6,nw+12);
	if (n==3) printf("%d %d %d",nw+6,nw+3,nw+9);
	if (n==4) printf("%d %d %d %d",nw+2,nw+4,nw+3,nw+9);
	if (n==5) printf("%d %d %d %d %d",nw+2,nw+4,nw+3,nw+6,nw+9);
	if (n==6) printf("%d %d %d %d %d %d",nw+2,nw+4,nw+3,nw+6,nw+9,nw+12);
	if (n==7) printf("%d %d %d %d %d %d %d",nw+2,nw+4,nw+3,nw+6,nw+9,nw+8,nw+10);
//	if (n==8) printf("%d %d %d %d %d %d %d %d",nw+2,nw+4,nw+3,nw+6,nw+9,nw+8,nw+10,nw+12);
}

Measured memory_bytes: 384
import numpy as np
n,k=[int(j) for j in input().split()]
a=np.array([int(j) for j in input().split()])
aa=a.cumsum()
l=aa[:,None]-aa[None,:]+a[None,:]
l=l.flatten()
l=l[l>0]

def f(x):
    return np.sum(l&x==x)>=k

left=0
right=1<<40
while right-left>1:
    mid=(left+right)//2
    if f(mid):
        left=mid
    else:
        right=mid
print(left)

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

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

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

    // start
    int a, b, c;
    cin >> a >> b >> c;
    if (b - a == c - b)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main() {
  int n;
  std::cin >> n;
  while(n--) {
    int t;
    std::cin >> t;
    if(t % 2 == 0) {
      if(t % 3 == 0 || t % 5 == 0) {
        // std::cout << "APPROVED" << std::endl;
      } else {
        std::cout << "DENIED" << std::endl;
        return 0;
      }
    }
  }
  std::cout << "APPROVED" << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

 int main()
 {
 char s[10];
 scanf("%s", s);
 if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3])printf("Yes\n");
 else if(s[0] == s[2] && s[2] != s[1] && s[1] == s[3])printf("Yes\n");
 else if(s[0] == s[3] && s[3] != s[1] && s[1] == s[2])printf("Yes\n");
 else printf("No\n");
   return 0;
 }

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

const ll mod = 1'000'000'007;

ll pow_mod(ll n, ll k) {
  if (k == 0)
    return 1;
  ll tmp = pow_mod(n, k / 2);
  ll res = tmp * tmp % mod;
  if (k % 2 != 0)
    res = n * res % mod;
  return res;
}

ll choose_mod(ll n, ll r) {
  ll a = 1, b = 1;
  for (int i = 0; i < r; ++i)
    a *= n - i, a %= mod;
  for (int i = 0; i < r; ++i)
    b *= i + 1, b %= mod;
  return a * pow_mod(b, mod - 2) % mod;
}

int main() {
  ll n, a, b;
  cin >> n >> a >> b;

  ll all = (pow_mod(2, n) - 1) % mod;
  ll sub = (choose_mod(n, a) + choose_mod(n, b)) % mod;
  ll ans = all - sub % mod;
  if (ans < 0)
    ans += mod;
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define first f
#define second s
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  string s,b="2016";
  cin>>s;
  for(int i=0;i<4;i++)cout<<s[i];
  cout<<" ";
  for(int i=4;i<s.size();i++)cout<<s[i];
  cout<<endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define RI register int
const int mod=1e9+7;
int n,ans,f[102][102][102],a[102];
int qm(int x) {return x>=mod?x-mod:x;}
int main()
{
	scanf("%d",&n);
	for(RI i=1;i<=n+n-1;++i) scanf("%d",&a[i]);
	sort(a+1,a+n+n);
	f[n][1][0]=1;
	for(RI i=n-1;i>=1;--i) {
		int pl=(a[i]!=a[i+1]),pr=(a[n+n-i]!=a[n+n-i-1]);
		for(RI j=0;j<=n+n-1;++j)
			for(RI k=0;j+k<=n+n-1;++k) {
				if(!f[i+1][j][k]) continue;
				for(RI L=1;L<=j+pl;++L)
					f[i][j+pl-L+1][k+pr+(L>1)]=qm(f[i][j+pl-L+1][k+pr+(L>1)]+f[i+1][j][k]);
				for(RI R=1;R<=k+pr;++R)
					f[i][j+pl+1][k+pr-R]=qm(f[i][j+pl+1][k+pr-R]+f[i+1][j][k]);
			}
	}
	for(RI i=0;i<=n+n-1;++i)
		for(RI j=0;j<=n+n-1;++j) ans=qm(ans+f[1][i][j]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1408