akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

int[] dist, prev;

void main() {
    int N, K;
    scan(N, K);
    auto a = readln.split.to!(int[]);
    a[] -= 1;
    a[] %= K;
    auto as = new int[](N + 1);
    foreach (i ; 1 .. N + 1) {
        as[i] = (as[i - 1] + a[i - 1]) % K;
    }

    debug {
        writeln(as);
    }

    long ans;
    int[int] c;
    foreach (i ; 0 .. N + 1) {
        if (i >= K) c[as[i - K]]--;
        if (as[i] in c) ans += c[as[i]];
        c[as[i]]++;
        debug {
            writeln(c);
        }
    }
    writeln(ans);
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 25652
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))

# 素因数分解、リストで返す
#############################################################


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    a.sort()
    return a
#############################################################


primes = defaultdict(int)

for i in range(N):
    p = prime_factorize(A[i])
    p_set = set(p)
    for pi in p_set:
        primes[pi] += 1

# print(primes)

if len(primes) == 0:
    print("pairwise coprime")
    exit()

max_cnt = max(primes.values())
min_cnt = min(primes.values())

if max_cnt == 1:
    print("pairwise coprime")
elif max_cnt != N:
    print("setwise coprime")
else:
    print("not coprime")


Measured memory_bytes: 184016
from bisect import bisect_left

INF = 10**12


def main():
    A, B, Q = map(int, input().split())
    S = [-INF] + [int(input()) for _ in range(A)] + [INF]
    T = [-INF] + [int(input()) for _ in range(B)] + [INF]
    for _ in range(Q):
        x = int(input())
        l1 = bisect_left(S, x)
        l2 = bisect_left(T, x)
        tmp = INF
        for s in (S[l1-1], S[l1]):
            for t in (T[l2-1], T[l2]):
                tmp = min(tmp, abs(s-t) + abs(x-s))
                tmp = min(tmp, abs(s-t) + abs(x-t))
        print(tmp)


if __name__ == "__main__":
    main()


Measured memory_bytes: 80728
#include<stdio.h>
int check[50],n,m,cnt;
int main()
{
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++)
    {
        int k;
        scanf("%d",&k);
        for(int i=0;i<k;i++)
        {
            int a;
            scanf("%d",&a);
            check[a]++;
        }
    }
    for(int i=1;i<=m;i++)
    {
        if(check[i]==n)
        {
            cnt++;
        }
    }
    printf("%d",cnt);
}

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

template< typename DATA >
class FenwickTree {
private:
	int size__;
	vector< DATA > data;
	
public:
	FenwickTree(int n) : size__(n), data(n + 1, DATA()) {}
	
	DATA sum(int i) {
		DATA res = DATA();
		
		while (i > 0) {
			res += data[i];
			i -= i & -i;
		}
		
		return res;
	}
	
	void add(int i, DATA x) {
		while (i <= size__) {
			data[i] += x;
			i += i & -i;
		}
	}

    DATA sum(int L, int R) { return sum(R) - sum(L-1); }
};

int main() {
    int N;
    cin >> N;
    vector<FenwickTree<int>> bit(26, FenwickTree<int>(N));

    string S;
    cin >> S;
    for (int i=0; i<N; ++i) bit[S[i] - 'a'].add(i+1, 1);

    int Q;
    cin >> Q;
    for (int q=0; q<Q; ++q) {
        int t;
        cin >> t;
        if (t == 1) {
            int i; char c;
            cin >> i >> c;
            if (S[i-1] == c) continue;
            bit[S[i-1] - 'a'].add(i, -1);
            bit[c - 'a'].add(i, 1);
            S[i-1] = c;
        }
        else {
            int L, R;
            cin >> L >> R;
            
            int ans = 0;
            for (int i=0; i<26; ++i) if (bit[i].sum(L, R) > 0) ++ans;
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 52992
(let* ((n (read))
       (lst (loop :repeat n :collect (read)))
       (lst-a (mapcar #'< lst (cdr lst)))
       (mem 0)
       (ans '()))
  (loop :for k :in lst-a :do (push (if k (prog1 mem (setf mem 0)) (progn (incf mem) 0)) ans) :finally (push mem ans))
  (princ (apply #'max ans)))

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

int main() {
  int X, N;
  cin >> X >> N;
  
  if(X < 10){
    cout << N + 100 * (10 - X) << endl;
  }
  
  else{
    cout << N << endl;
  }

  
    
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int i;
		Integer[] num = new Integer[5];
		for(i = 0; i < 5; i++) {
			num[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(num, Collections.reverseOrder());
		System.out.printf("%d %d %d %d %d\n",num[0], num[1], num[2], num[3], num[4]);
		sc.close();
	}


}



Measured memory_bytes: 26168
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int a,b,c;
	string str;
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<' '<<b<<' '<<c;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
/*
void call(int n){
	int i=1;
	int x;
	CHECK_NUM:
		x=i;
		if(x%3==0){
			printf(" %d",i);
			goto END_CHECK_NUM;
		}
	INCLUDE3:
		if(x%10==3){
			printf(" %d",i);
			goto END_CHECK_NUM;
		}
		x/=10;
		if(x!=0) goto INCLUDE3;
	END_CHECK_NUM:
		if(++i<=n) goto CHECK_NUM;
	printf("\n");
}
*/
int main(){
	int n;
	int i;
	int x;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		x=i;
		if(x%3==0){
			printf(" %d",i);
		}
		else{
			while(x!=0){
				if(x%10==3){
					printf(" %d",i);
					x=0;
				}
				x/=10;
			}
		}
	}
	printf("\n");
	return 0;
}



Measured memory_bytes: 2052
import java.util.*;

public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        
        Dijkstra g = new Dijkstra(n);
        
        for(int i=0; i<n-1; i++){
            int u = Integer.parseInt(sc.next())-1;
            int v = Integer.parseInt(sc.next())-1;
            int w = Integer.parseInt(sc.next());
            g.addEdge(u,v,w);
        }
        
        long[] color = g.build(0);
        
        for(int i=0; i<n; i++){
            System.out.println(color[i]%2);
        }
    }
}



class Dijkstra{
    
    public final long INF = (long)1e18;
    private int n;
    private List<Edge>[] edge;
    
    public Dijkstra(int n){
        this.n = n;
        edge = new List[n];
        for(int i=0; i<n; i++){
            edge[i] = new ArrayList<>();
        }
    }
    
    public void addEdge(int from, int to, int cost){
        edge[from].add(new Edge(from, to, cost));
        edge[to].add(new Edge(to, from, cost));
    }
    
    public long[] build(int from){
        long[] dist = new long[n];
        Arrays.fill(dist, INF);
        dist[from] = 0;
        
        PriorityQueue<Vertex> q = new PriorityQueue<>();
        q.add(new Vertex(from, 0));
        while(q.size() != 0){
            int u = q.poll().ver;
            
            for(Edge ne : edge[u]){
                int v = ne.to;
                long weight = ne.cost;
                if(dist[v] > dist[u]+weight){
                    dist[v] = dist[u]+weight;
                    q.add(new Vertex(v, dist[v]));
                }
            }
        }
        
        return dist;
    }
}

class Edge implements Comparable<Edge>{
    public int from = 0;
    public int to = 0;
    public int cost = 0;
    
    public Edge(int from, int to, int cost) {
        this.from = from;
        this.to = to;
        this.cost = cost;
    }
    
    @Override
    public int compareTo(Edge o) {
        return this.cost - o.cost;
    }
}

class Vertex implements Comparable<Vertex>{
    public int ver = 0;
    public long cost = 0;
    
    public Vertex(int ver, long cost) {
        this.ver = ver;
        this.cost = cost;
    }
    
    @Override
    public int compareTo(Vertex o) {
        long tmp = this.cost - o.cost;
        if(tmp == 0) return 0;
        return (int)(tmp/Math.abs(tmp));
    }
}

Measured memory_bytes: 75360
#include <stdio.h>

int main(){
  int a,b,ch;
  scanf("%d %d",&a,&b);
  if(a<b){
    ch=a;
    a=b;
    b=ch;
  }
  while(1){
    ch=a%b;
    if(ch==0)break;
    else {
      a=b;
      b=ch;
    }
  }
  printf("%d\n",b);
  return 0;
}

Measured memory_bytes: 2692
def find(target, list):
  l = 0
  r = len(list)-1
  while l < r:
    m = (l + r) / 2
    if list[m] == target:
      return 1
    if target < list[m]:
      r = m
    else:
      l = m + 1
  if list[l] == target:
    return 1
  else:
    return 0

n = int(raw_input())
S = map(int, raw_input().split())
q = int(raw_input())
T = map(int, raw_input().split())
count = 0
for i in xrange(q):
  count += find(T[i], S)
print count

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
const ll INF = 0x3f3f3f3f;
const ll LINF = 1ll << 55;
const ll MOD = 1e9 + 7;
const ll MAXN = 400 + 5;
const ll MAXK = 1e5 + 10;

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

template<typename T>
ostream& operator<< (ostream& out, vector<T>& vec) {
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        out << *it << " ";
    }
    return out;
}

template<typename T>
istream& operator>> (istream& in, vector<T>& vec) {
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        in >> *it;
    }
    return in;
}

int main() {
    vll nums(3);
    cin >> nums;
    if (nums[0] == nums[1] && nums[1] == nums[2]) {
        cout << 0 << endl;
    } else {
        ll ans = 0;
        ll sum = nums[0] + nums[1] + nums[2];
        auto itmax = max_element(nums.begin(), nums.end());
        auto itmin = min_element(nums.begin(), nums.end());
        ll remain = sum - *itmax - *itmin;
        if (nums[0] != nums[1] && nums[1] != nums[2] && nums[0] != nums[2]) {
            if ((remain - *itmin) % 2 == 0) {
                ans = (remain - *itmin) / 2 + *itmax - remain;
            } else {
                ans = (remain + 1 - *itmin) / 2 + *itmax - remain + 1;
            }
        } else {
            if (remain == *itmax) {
                if ((remain - *itmin) % 2 == 0) {
                    ans = (remain - *itmin) / 2;
                } else {
                    ans = (remain + 1 - *itmin) / 2 + 1;
                }
            } else {
                ans = *itmax - remain;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;
int dp[5001];

void solve()
{
	int n;
	while(cin >> n, n)
	{
		for(int i = 0; i < 5001; ++i)
		{
			dp[i] = -999999999;
		}
		vector<int> Vec(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> Vec[i];
		}
		int Max = -999999999;
		dp[0] = Vec[0];
		int sum = Vec[0];
		for(int i = 1; i < n; ++i)
		{
			if(sum + Vec[i] < Vec[i])
			{
				dp[i] = Vec[i];
				sum = Vec[i];
			}
			else
			{
				dp[i] = sum + Vec[i];
				sum += Vec[i];
			}
			if(dp[i] < dp[i - 1])
			{
				dp[i] = dp[i - 1];
			}
		}
		cout << dp[n - 1] << endl;
	}
}

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

Measured memory_bytes: 0
#include<stdio.h>

int maxi(int a,int b){
  if(a>b) return a;
  return b;
}

int main(void){
  int x=0,n,i,max=0;
  scanf("%d",&n);
  char s[n];
  scanf("%s",s);
  for(i=0;i<n;i++){
    if(s[i]=='I'){
      x++;
      max=maxi(x,max);
    }else x--;
  }
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 128
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int a = 1;
		int b = 1;
		int c = 1;
		int x = 0;

		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		
		for(; a <= b; a++){
			if(c % a == 0){
				x++;
			}
		}
		System.out.println(x);
	}	
}

Measured memory_bytes: 26244
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int tmp = 3 * max({a,b,c});
  tmp -= a,tmp -= b,tmp -= c;
  if(tmp % 2 == 0)cout << tmp / 2 << endl;
  else cout << (tmp + 3) / 2 << endl;
  return 0;
}

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

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

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

using namespace std;


signed main() {
  string s;
  cin >> s;

  int K;
  cin >> K;

  int N = s.size();

  int dp[1100][5][5];
  dp[0][0][0] = 1;

  REP(i, N) REP(j, K+1) REP(k, 2){
    int lim = k ? 9 : (s[i]-'0');
    REP(d, lim+1){
      dp[i+1][j+(d != 0)][k || (d != lim)] += dp[i][j][k];
    }
  }

  int ans = 0;
  REP(k, 2) ans += dp[N][K][k];
  cout << ans << endl;

  return 0;
}

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

using namespace std;

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

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	string s;
	cin >> s;
	int stat0=0, stat1=0;
	for(char c:s){
		if(c == '0') ++stat0;
		else if(c=='1') ++stat1;
	}
	cout << min(stat0, stat1)*2;

}


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

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> a(n+1);
  rep(i, m) {
    int at;
    cin >> at;
    a[at] = 1;
  }
  int left = 0;
  int right = 0;
  for(int i = 0; i < x; i++) {
    left += a[i];
  }
  for(int i = x; i < n+1; i++) {
    right += a[i];
  }
  int ans = min(left, right);
  cout << ans << endl;
  return 0;
} 

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

int main() {
  string s; cin >> s;
  string mae = s.substr(0,(s.size()-1)/2);
  string maer = s.substr(0,(s.size()-1)/2);
  reverse(maer.begin(),maer.end());
  string ato = s.substr((s.size()+1)/2,(s.size()-1)/2);
  string ator = s.substr((s.size()+1)/2,(s.size()-1)/2);
  reverse(ator.begin(),ator.end());

  if(mae != maer || mae != ato || mae != ator) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
A = np.array([list(map(int,input().split())) for _ in range(N)],dtype=np.int64)

INF = 10**9+10
E = np.zeros(((N*(N-1))//2,3),dtype=np.int64)
k = 0
for i in range(N):
    for j in range(i+1,N):
        E[k,0] = A[i][j]
        E[k,1] = i
        E[k,2] = j
        k += 1
E = E[E.argsort(0)[:,0]]
B = np.ones((N,N),dtype=np.int64)*INF
ans = 0
for l,i,j in E:
    l_min = np.min(B[i]+B[j])
    if l > l_min:
        ans = -1
        break
    elif l < l_min:
        ans += l
    B[i][j] = l
    B[j][i] = l
print(ans)

Measured memory_bytes: 26524
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    while(1){
        int sum = 0;
        string n;
        cin >> n;
        if(n == "0"){
            break;
        }
        for(int i=0;i<n.length();i++){
            sum += int(n[i]-'0');
        }
        cout << sum << endl;   
    }
}



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

using namespace std;
int main(){
  while(1){
  int n;
  cin>>n;
    int m;
    cin>>m;
    if(n==0&&m==0){break;}
  vector<vector<int>> v(n+1);//??¨?????????
  vector<int> s(n+1,0);//??????
s[1]=1;
  for(int i=0;i<m;i++){
    int a;
    cin>>a;
    int b;
    cin>>b;
    v[a].push_back(b);
    v[b].push_back(a);
  }

  vector<vector<int>> r(n+1);//?????°???????????¨
  r[0].push_back(1);
  int num=0;
  while(1){
  int change=0;
  if(r[num].empty()==false){
    for(unsigned int j=0;j<r[num].size();j++){
      for(unsigned int i=0;i<v[r[num][j]].size();i++){
        if(s[v[r[num][j]][i]]==0){
          s[v[r[num][j]][i]]=1;
          r[num+1].push_back(v[r[num][j]][i]);
          change=1;
        }
      }
    }
  }
    if(change==0){break;}
    if(num==1){break;}
    num++;
  }
  int kazu=0;
  for(unsigned int i=0;i<s.size();i++){
    if(s[i]==1){kazu++;}
  }
  cout<<kazu-1<<endl;

}
}

Measured memory_bytes: 3160
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>

using namespace std;

int main() {

	int A[5];

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

	for (int i = 0; i < 5; i++)
	{
		if (A[i] == 0)
		{
			cout << i + 1;
		}
	}

	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
int divr[maxn];
/*ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
















int ct[100005][2];
int main()
{
     int n;
     cin>>n;
     ll ans=1LL;
    int res[1005]={0};
     for(int i=2;i<=n;i++)
     {
          int t=i;
          for(int j=2;j<=sqrt(t);j++)
          {
               if(t%j==0)
               {
                    int ct=0;
                    while(t%j==0)ct++,t/=j;
                    res[j]+=ct%mod;
                    res[j]%=mod;
               }
          }
          if(t>1){
               res[t]=(res[t]+1)%mod;
          }
     }
     for(int i=2;i<=1000;i++)
     {
          if(res[i]>0)
          {
               ans=(ans*(res[i]+1LL))%mod;
          }
     }
     cout<<ans;
}




















 

Measured memory_bytes: 256
/*
  AtCoder Beginner Contest 100
  B - Ringo's Favorite Numbers
*/

#include<iostream>
using namespace std;

int D, N;

int main() {
   scanf("%d%d", &D, &N);

  if (N == 100) N = 101;
  for (int i = 0; i < D; ++i) {
    N *= 100;
  }

  printf("%d\n", N);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int is[10000];
int main(int argc, char *argv[])
{
    for(;;) {
        int n, m;
        scanf("%d %d", &n, &m);
        if(n == 0 && m == 0) break;
        for(int i = 0; i < n; i++) {
            int c;
            scanf("%d", &c);
            is[i] = c;
        }
        int best = -1;
        for(int i = 0; i < n; i++) {
            for(int j = i+1; j < n; j++) {
                int k = is[i] + is[j];
                if( k <= m && k > best) best = k;
            }
        }
        if(best < 0) printf("NONE\n");
        else printf("%d\n", best);
    }
    return 0;
}


Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
int main()
{
  double  L;
  cin >> L;
  double a = L/3;
  double ans = pow(a, 3);
  cout <<fixed <<setprecision(6)<< ans<< endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int a , b , c , d , e;
  b=N/100 ;
     a=N/1000 ;
       b-=a*10 ;
  d=N%10 ;
    c=1000*a+100*b+d ;
  e=N-c ;
    e/=10 ;
   
  /*cout << a << ":" << b << ":" << e <<  ":" << d;*/
    
/*if ((b==e==a)||(b==e==d)){
  cout << "Yes" << endl;}*/
  
  if (( b==e )&&(b==a) ){
  cout << "Yes" << endl;}
    
    else if ((e==d)&&(b==e)){
      cout << "Yes" << endl ;}
  
  else {
    cout << "No" << endl;} ;  
 
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int a, b, c, d;
    std::cin>>a>>b>>c>>d;

    std::string ans;
    if(abs(c - a) <= d){
        ans = "Yes";
    }else if(abs(b - a) <=d && abs(c - b) <= d){
        ans = "Yes";
    }else{
        ans = "No";
    }
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <utility>
#define INF 1000000009
#define LINF 1000000000000000009
#define int long long
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef pair<ll, double> PD;
//ll mod = 1000000007;
//ll mod = 998244353;

vector<int> parent(100010);
vector<int> ran(100010);

void init(int n) {
	for (int i = 0; i < n; i++) {
		parent[i] = i;
		ran[i] = 0;
	}
}

int find(int x) {
	if (parent[x] == x) return x;
	else return parent[x] = find(parent[x]);
}

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) return;
	if (ran[x] < ran[y]) parent[x] = y;
	else {
		parent[y] = x;
		if (ran[x] == ran[y]) ran[x]++;
	}
}

signed main() {
	int n, m, q;
	cin >> n >> m >> q;
	init(n);
	vector<int> a(q), b(q), c(q);
	for (int i = 0; i < q; i++) {
		cin >> a[i] >> b[i] >> c[i];
		if (c[i] == 0) {
			unite(a[i], b[i]);
		}
	}
	vector<int> root(n);
	set<int> st;
	for (int i = 0; i < n; i++) {
		root[i] = find(i);
		st.insert(root[i]);
	}
	int sz = st.size();
	m -= n - sz;
	if (sz*(sz - 1) < 2 * m) {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < q; i++) {
		if (c[i] == 1) {
			if (root[a[i]] == root[b[i]] || sz <= 2) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	for (int i = 0; i < q; i++) {
		if (c[i] == 1) {
			if (find(a[i]) != find(b[i])) {
				m--;
				unite(a[i], b[i]);
			}
		}
	}
	init(n);
	for (int i = 0; i < q; i++) {
		if (c[i] == 1) {
			if (find(a[i]) != find(b[i])) {
				unite(a[i], b[i]);
			}
		}
	}
	map<int, int> mp;
	for (int i = 0; i < n; i++) {
		mp.insert(P(find(i), 0));
		mp[find(i)]++;
	}
	int dis = 0;
	int diss = 0;
	for (auto p : mp) {
		if (p.second >= 2) {
			dis++;
		}
		if (p.second == 2) {
			diss++;
		}
	}
	if (dis == 1 && diss == 1) dis++;
	if (m >= dis) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
}

Measured memory_bytes: 11904
from itertools import product

N = int(input())

sqrt = int(N ** 0.5)

factorize_result = {}
n = N
for i in range(2, sqrt + 1):
    if n % i == 0:
        factorize_result[i] = 1
        n = n // i
        while n % i == 0:
            factorize_result[i] += 1
            n = n // i
if n > 1:
    factorize_result[n] = 1

ans = 0
vs = [list(range(v+1)) for v in factorize_result.values()]
for indices in product(*vs, repeat=1):

    tmp = 1
    for i, (k, v) in enumerate(factorize_result.items()):
       tmp *= k ** indices[i]

    tmp -= 1
    if tmp == 0:
        continue

    if N % tmp == N // tmp:
        ans += tmp

print(ans)







Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    bool prime[20000];
    fill(prime,prime+20000,true);
    prime[0]=prime[1]=false;
    for(int i=2;i*i<=20000;i++){
        if(prime[i])for(int j=i*2;j<=20000;j+=i)prime[j]=false;
    }
    int n;
    while(cin>>n,n){
        do{
            if(prime[n]&&prime[n-2]){
                cout<<n-2<<" "<<n<<endl;
                break;
            }

        }while(n--,n>=5);
    }
}

Measured memory_bytes: 1180
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>

#define lpsbd(i, s, b, d) for(size_t i = (s); i < (b); i+=(d))
#define lpsb(i, s, b) for(size_t i = (s); i < (b); i++)
#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)
#define all(x) (x).begin(), (x).end()

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

const ll MOD = 1000000007;

int dp[110][110][400]; //dp[i][j][k] i-1番目までの中からj個選び、追加で発生した重さがk円のときの価格の最大値

int main(void)
{
    int N, M;
    cin >> N >> M;
    auto tasks = vc(p, N);
    fa(i, tasks) cin >> i.first >> i.second;
    sort(all(tasks));
    int i = 1, j = 0;
    int ans = 0;
    priority_queue<int> pq;
    for(; i <= M; i++)
    {
        for (; j < N; j++)
        {
            if (tasks[j].first > i) break;
            pq.push(tasks[j].second);
        }
        if (!pq.empty())
        {
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1660
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
 
#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 10000;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
 
void solve()
{
    ll ans = 0;
    ll n;
    cin >> n;
    map<ll,ll> y;
    for(ll i=2;i*i<=n;i++)
    {
        ll cnt = 0;
        while(n%i==0)  
        {
            cnt++;
            n/=i;
        }
        if(cnt)   y[i] = cnt;
    }   
    if(n>1)   y[n] = 1; 
    for(auto X:y)
    {
        ll temp = X.ss;
        ll cnt = 1,sum = 0;
        while(sum+cnt<=temp)
        {
            sum += cnt;
            cnt++;
        }
        ans += cnt-1;
    }
    cout<<ans;
}

int main()
{
     FAST;
     ll t = 1;
   //  cin >> t;
     while(t--)
     {
          solve();
     }
}

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

long long dp[105][100005];

long long max_value(int w[],long long v[],int n,int id, long long W){

    if(id==n)return 0;// the value of nothing is zero.
    if(dp[id][W]!=-1)return dp[id][W];

    long long p1=0;
    if(W>=w[id])
        p1=v[id]+max_value(w,v,n,id+1,W-w[id]);

    long long p2=max_value(w,v,n,id+1,W);

    long long ans=max(p1,p2);
    dp[id][W]=ans;
    return ans;
}

int main(){
    int t=1;
    while(t--){
        int n;
        long long W;
        cin>>n>>W;
        int w[n];
        long long v[n];
        for(auto i=0;i<n;++i){
            cin>>w[i]>>v[i];
        }
        memset(dp,-1,sizeof(dp));

        long long maxm=max_value(w,v,n,0,W);
        cout<<maxm<<endl;
    }
    return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 998244353;
const ll INF = (ll) 1e15;

struct Combination {
    Combination(ll n) {
        mNumTbl.resize(n + 1);
        mInverseNumTbl.resize(n + 1);
        mNumTbl[0] = 1;
        mInverseNumTbl[0] = 1;
        FOR(i, n + 1, 1) {
            mNumTbl[i] = (mNumTbl[i - 1] * i) % MOD;
        }
        FOR(i, n + 1, 1) {
            mInverseNumTbl[i] = modpow(mNumTbl[i]);
        }
    }

    ll get(ll n, ll r) {
        if (n < r || n < 0)
            return 0;
        return (((mNumTbl[n] * mInverseNumTbl[r]) % MOD) * mInverseNumTbl[n - r]) % MOD;
    }

    ll modpow(ll n) {
        ll s = 1, p = n;
        for (ll i = 0; (1LL << i) <= MOD - 2; ++i, p = (p * p) % MOD) {
            if (((MOD - 2) & (1 << i)) == 0)
                continue;
            s *= p;
            s %= MOD;
        }
        return s;
    }

    vector<ll> mInverseNumTbl;
    vector<ll> mNumTbl;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, A, B, K;
    cin >> N >> A >> B >> K;
    Combination cmb(N);
    ll ans = 0;
    REP(i, N + 1) {
        ll a = A * i;
        ll m = K - a;
        if (m < 0)
            break;
        if (m % B != 0)
            continue;
        ll j = m / B;
        if (j > N)
            continue;

        ans += cmb.get(N, i) * cmb.get(N, j);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
#ifdef ONLINE_JUDGE
#define getchar gc
inline char gc(){
	static char buf[1<<16],*p1=buf,*p2=buf;
	if(p1==p2){
		p2=(p1=buf)+fread(buf,1,1<<16,stdin);
		if(p2==p1) return EOF;
	}
	return *p1++;
}
#endif
template<class t> inline t read(t &x){
    char c=getchar();bool f=0;x=0;
    while(!isdigit(c)) f|=c=='-',c=getchar();
    while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
    if(f) x=-x;return x;
}
template<class t> inline void write(t x){
    if(x<0) putchar('-'),write(-x);
    else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=105; 
int n,m,ans;
bool v[N];


signed main(){
	read(n);read(m);
	while(m--){
		int n;
		read(n);
		while(n--){
			int x;
			read(x);
			v[x]=1;
		}
	}
	for(int i=1;i<=n;i++) ans+=!v[i];
	write(ans);
}

Measured memory_bytes: 3644
N = int(input())
A = list(map(int, input().split()))
A.sort()
from math import gcd
for i in range(N-1):
    a = A[i]
    b = A[i+1]
    a, b = 0, gcd(a,b)
    A[i] = a
    A[i+1] = b
print(A[N-1])

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

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

	ll n, m, x;
	cin >> n >> m >> x;
	vector<vector<ll>> books(n, vector<ll>(m+1));

	for (int i = 0 ; i < n ; i++) {
		cin >> books[i][0];
		for (int j = 0 ; j < m ; j++) {
			cin >> books[i][j+1];
		}
	}

	ll best_price = -1;
	for (int i = 1 ; i < (1 << n) ; i++) {
		vector<ll> conn(m);
		ll price = 0;

		for (int j = 0 ; j < n ; j++) {
			if (i & (1 << j)) {
				for (int k = 0 ; k < m ; k++) {
					conn[k] += books[j][k+1];
				}
				price += books[j][0];
			}
		}
		if (all_of(conn.begin(), conn.end(), [&x](int n) { return n >= x; })) {
			if (best_price == -1 || best_price > price)
				best_price = price;
		}
	}
	cout << best_price << "\n";

	return 0;
}


Measured memory_bytes: 3664
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(){
  long long int mi = 100000000000,ma = -100000000000,a,n;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a;
    ma = max(ma,a-mi);
    mi = min(mi,a);
  }
  cout<<ma<<endl;
}

Measured memory_bytes: 3120
W,H,x,y,r = map(int,input().split())

if x > 0 and y > 0:
    if (x - r) >= 0 and (x + r) <= W:
        if (y - r) >= 0 and (y + r) <= H:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')


Measured memory_bytes: 5596
A=[]
fp =0
bp =0

n=int(raw_input())
while n:
    s = raw_input()

    if s[0] == 'i':
        A.append(int(s[7:]))
        fp += 1
    elif s[6] == ' ':
        try:
            i = A[::-1].index(int(s[7:]))
            if i!=-1:
                del A[-i-1]
                fp -=1
        except:
            pass
    elif s[6] == 'F':
        A.pop()
        fp -=1
    elif s[6] == 'L':
        bp +=1
    n -=1

for e in A[bp:fp+1][::-1]:
    print int(e),

Measured memory_bytes: 42372
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
#define LATTE 1000000000

int main(){
	int N;
	while(cin>>N,N){
		int dp[10][10]={},A,B,C;
		bool latte[10]={};
		for(int i=0;i<10;i++)for(int j=0;j<10;j++) if(i!=j) dp[i][j]=LATTE;
		for(int i=0;i<N;i++){
			cin>>A>>B>>C;
			dp[A][B]=dp[B][A]=C;
			latte[A]=latte[B]=true;
		}
		for(int k=0;k<10;k++){
			for(int i=0;i<10;i++){
				for(int j=0;j<10;j++){
					dp[i][j] = min(dp[i][j],dp[i][k]+dp[k][j]);
				}
			}
		}
		int _min=LATTE,ans;
		for(int i=0;i<10;i++){
			if(!latte[i]) continue;
			int sum=0;
			for(int j=0;j<10;j++){
				if(!latte[j]) continue;
				if(dp[i][j]==LATTE){
					sum=LATTE;
					break;
				}
				sum += dp[i][j];
			}
			if(_min>sum){
				_min = sum; ans = i;
			}
		}
		printf("%d %d\n",ans,_min);
	}
}

Measured memory_bytes: 1144
import sys
H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]

for i in range(H):
    for j in range(W):
        if s[i][j] == '.':
            continue
        if i != 0:
            if s[i - 1][j] == '#':
                continue
        if i != H - 1:
            if s[i + 1][j] == '#':
                continue
        if j != 0:
            if s[i][j - 1] == '#':
                continue
        if j != W - 1:
            if s[i][j + 1] == "#":
                continue

        print('No')
        sys.exit()

print('Yes')

Measured memory_bytes: 3064
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

struct UnionFind
{
  int n;
  std::vector<int> par,size;
  UnionFind(int sz) : n(sz), par(sz,0), size(sz,1) {
    std::iota(par.begin(),par.end(),0);
  }
  int find(int x) {
    if(par[x]==x) return x;
    return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x=find(x);y=find(y);
    if(x==y) return;
    if(size[x]<size[y]) std::swap(x,y);
    size[x]+=size[y];
    par[y]=x;
  }
};


signed main() {
	int clar[4][4] = {
		6,3,1,4,
		2,-1,2,-1,
		1,3,6,4,
		5,-1,5,-1
	};
	int h,w;
	std::cin >> h >> w;
	std::vector<std::string> g(h);
	rep(i,h) std::cin >> g[i];
	auto enc = [&w](int x, int y) -> int {
		return x*w+y;
	};
	UnionFind uf(h*w);
	rep(i,h) {
		rep(j,w) {
			if(g[i][j]-'0'!=clar[i%4][j%4]) continue;
			rep(dx,2) rep(dy,2) {
				debug(dx,dy);
				if(dx==0 && dy==0) continue;
				if(dx*dy!=0) continue;
				if(i+dx>=h || j+dy>=w) continue;
				if(g[i+dx][j+dy]-'0'!=clar[(i+dx)%4][(j+dy)%4]) continue;
				debug(enc(i,j),enc(j+dx,j+dy));
				uf.unite(enc(i,j),enc(i+dx,j+dy));
			}
		}
	}
	debug(uf.par);
	if(uf.find(0)==uf.find(h*w-1)) print("YES");
	else print("NO");

	return 0;
}



Measured memory_bytes: 3340
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int len;
    cin >> len;
    vector<int> arr(len);
    int s = 0;
    bool ok = false;
    for(int i = 0; i < len; i++) {
        cin >> arr[i];
        s += arr[i];
        if(arr[i] % 10 != 0)
            ok = true;
    }
    if(!ok) {
        cout << 0;
        return 0;
    }
    if(s % 10 == 0) {
        sort(arr.begin(), arr.end());
        int i = 0;
        while(arr[i] % 10 == 0)
            i++;
        s -= arr[i];
    }
    cout << s;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define maxn 200005
int n,a[maxn];
int cnt1[maxn],cnt2[maxn];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i+=2)
		cnt1[a[i]]++;
	for(int i=2;i<=n;i+=2)
		cnt2[a[i]]++;
	//找到cnt1里出现次数最多的和次多的数
	int Mx1=0,id1,MMx1=0; 
	for(int i=1;i<=200000;i++)
		if(cnt1[i]>Mx1)
			MMx1=Mx1,Mx1=cnt1[i],id1=i;
		else if(cnt1[i]>=MMx1)
			MMx1=cnt1[i];
	
	int Mx2=0,id2,MMx2=0; 
	for(int i=1;i<=200000;i++)
		if(cnt2[i]>Mx2)
			MMx2=Mx2,Mx2=cnt2[i],id2=i;
		else if(cnt2[i]>=MMx2)
			MMx2=cnt2[i];
	if(id1!=id2)
		cout<<n-Mx1-Mx2<<'\n';
	if(id1==id2)
		cout<<min(n-Mx1-MMx2,n-MMx1-Mx2)<<'\n';
}

Measured memory_bytes: 1408
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanln(&n)

	for i := 1; i <= n; i++ { // CHECK_NUM
		x := i
		for {
			if x%3 == 0 {
				fmt.Printf(" %d", i)
				break // goto END_CHECK_NUM
			}
			for { // INCLUDE3
				if x%10 == 3 {
					fmt.Printf(" %d", i)
					break // goto END_CHECK_NUM
				}
				x /= 10
				if x != 0 {
					continue // goto INCLUDE3
				}
				break
			}
			break
		} // END_CHEC_KNUM
		// goto CHECK_NUM
	}
	fmt.Printf("\n")
	return
}



Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
int n,m,len;
int sx,sy;
char a[maxn];
char b[maxn];
int main(){
	scanf("%d%d%d%d%d",&n,&m,&len,&sx,&sy);
	scanf("%s",a+1);
	scanf("%s",b+1);
	int posx; int posy;
	posx=sx;
	for(int i=1;i<=len;i++){
		if(a[i]=='U') posx--;
		if(!posx){
			printf("NO\n");
			return 0;
		}else if(b[i]=='D'&&posx+1<=n) posx++;
	}
	posx=sx;
	for(int i=1;i<=len;i++){
		if(a[i]=='D') posx++;
		if(posx>n){
			printf("NO\n");
			return 0;
		}else if(b[i]=='U'&&posx-1>=1) posx--;
	}
	posy=sy;
	for(int i=1;i<=len;i++){
		if(a[i]=='L') posy--;
		if(!posy){
			printf("NO\n");
			return 0;
		}else if(b[i]=='R'&&posy+1<=m) posy++;
	}
	posy=sy;
	for(int i=1;i<=len;i++){
		if(a[i]=='R') posy++;
		if(posy>m){
			printf("NO\n");
			return 0;
		}else if(b[i]=='L'&&posy-1>=1) posy--;
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 640
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e6+7;
const int N = 1e5+7;


void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

    
int main()
{
    
        int a,b,c,k;
        scf(a),scf(b),scf(c),scf(k);
        
        while(b<=a)
        {
            b=b*2;
            k--;
        }
        
        while(c<=b)
        c=c*2,k--;
        
        if(c>b&&b>a&&k>=0)
        printf("Yes\n");
        
        else
        printf("No\n");
        
        
}
    

Measured memory_bytes: 3744
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890

using namespace std;

char s[17];

int main()
{
    int i,j;
    int N;

    scanf("%d",&N);
    map<vector<int>,int>mp;
    LLI cnt = 0;
    for( i=0; i<N; i++)
    {
        scanf("%s",s);
        vector<int>key(26,0);
        for(j=0;j<10;j++)
        {
            key[s[j]-'a']++;
        }
        cnt+=mp[key];
        mp[key]++;
    }
    printf("%lld\n",cnt);

    return 0;
}


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

using namespace std;
typedef long long LL;
const int N=1e5+5;

int head[N],nxt[N<<1],to[N<<1],siz[N],z[N],k[N];
int n,m,num,X,Y,odd,sum,tot,mid;
LL ans;

int read()
{
    int x=0,p=1; char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') p=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
    return x*p;
}

void add(int x,int y)
{
	nxt[++num]=head[x],to[num]=y,head[x]=num;
}

void dfs1(int x,int fa)
{
	for(int i=head[x]; i ;i=nxt[i])
	{
		int y=to[i];
		if(y==fa) continue ;	
		if(siz[y])
		{
			if(siz[y]==siz[x]) odd=1;
			X=x,Y=y;
		}
		else
		{
			siz[y]=-siz[x];
			dfs1(y,x);
		}
	}
}

void dfs2(int x,int fa)
{
	for(int i=head[x]; i ;i=nxt[i])
	{
		int y=to[i];
		if(y==fa || (x==X&&y==Y) || (x==Y&&y==X))
			continue ;
		dfs2(y,x);
		siz[x]+=siz[y];
		k[x]+=k[y];
	}
}

int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);

	n=read(),m=read();
	for(int i=1;i<=m;i++)
	{
		int x=read(),y=read();
		add(x,y),add(y,x);
	}

	siz[1]=1;
	dfs1(1,0);
	for(int i=1;i<=n;i++) sum+=siz[i];

	if(n-1==m)
	{ if(sum) return printf("-1\n"),0; }
	else
		if(odd)
		{
			if(sum&1) return printf("-1\n"),0;
			ans+=abs(sum>>1); 
			siz[X]-=sum>>1,siz[Y]-=sum>>1;
		}
		else
		{
			if(sum) return printf("-1\n"),0;
			k[X]=1,k[Y]=-1;
		}

	dfs2(1,0);
	for(int i=1;i<=n;i++)
		if(k[i]) z[++tot]=k[i]*siz[i];
		else ans+=abs(siz[i]);
	z[++tot]=0;
	sort(z+1,z+tot+1);
	mid=z[tot+1>>1];
	for(int i=1;i<=tot;i++) ans+=abs(z[i]-mid);

	printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 8064
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}

uint32_t nextpint(void){ char c=getchar(); while(c<'0'||'9'<c) c=getchar(); uint_fast32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return x; }

int main(int argc, char *argv[], char *envp[]){
	int n=nextpint();
	int k=nextpint();
	long ans=0;
	for(int b=k+1; b<=n; b++){
		ans+=n/b*(b-k);
		if(k==0) ans--;
		int c=n%b-k+1;
		if(c>0) ans+=c;
	}
	printf("%ld\n", ans);
}


Measured memory_bytes: 128
from string import ascii_lowercase
import sys


def input():
    return sys.stdin.readline().strip()


class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (n + 1)
        self.k_init = 2 ** (self.n - 1).bit_length()

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.n:
            self.data[i] += x
            i += i & -i


n = int(input())
s = input()
q = int(input())

bits = {c: BIT(n) for c in ascii_lowercase}
[bits[c].add(i, 1) for i, c in enumerate(s, 1)]
queries = (input().split() for _ in range(q))

for q_type, *q in queries:
    if q_type == '1':
        iq = int(q[0])
        cq = q[1]
        for b in bits.values():
            if b.sum(iq) - b.sum(iq - 1) == 1:
                b.add(iq, -1)
                break
        bits[cq].add(iq, 1)
    else:
        l, r = map(int, q)
        print(sum([bool(v.sum(r) - v.sum(l - 1) > 0) for v in bits.values()]))


Measured memory_bytes: 175476