akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  bool exist = true;
  vector<char> vec(0);
  for(int i=0; i<S.size(); i++){
    if(S.at(i) != 'x'){
      vec.push_back(S.at(i));
    }
  }
  int a = vec.size();
   for(int i=0; i<a/2; i++){
    if(vec.at(i) != vec.at(a-i-1)){
      exist = false;
      break;
    }
   }
  
  int ans = 0;
  if(exist){
    int x = 0;
    int y = S.size()-1;
    while(x < y){
      if(S.at(x) == S.at(y)){
        x++;
        y--;
        continue;
      }
      else if(S.at(x) == 'x'){
        ans++;
        x++;
      }
      else if(S.at(y) == 'x'){
        ans++;
        y--;
      }
    }
  }
  else{
    ans = -1;
  }
  cout << ans << endl;    
}

Measured memory_bytes: 640
#include<iostream>

using namespace std;

int way(int now_x, int now_y, int next_x, int next_y) {
	int dis_x = 0, dis_y = 0;

	dis_x = abs(next_x - now_x);
	dis_y = abs(next_y - now_y);

	return dis_x + dis_y;
}

int check(int dis, int time) {
	if (dis > time)
		return 0;
	else if (dis == time)
		return 1;
	else if ((time - dis) % 2 == 0)
		return 1;
	else
		return 0;
}

int main() {
	int n, *xi, *yi, *time, x, y, t, i;

	cin >> n;

	xi = new int[n];
	yi = new int[n];
	time = new int[n];

	for (i = 0; i < n; i++) {
		cin >> t >> x >> y;
		xi[i] = x;
		yi[i] = y;
		time[i] = t;
	}

	if (check(way(0, 0, xi[0], yi[0]), time[0]) == 0) {
		cout << "No";
		return 0;
	}

	for (i = 1; i < n; i++) {
		if (check(way(xi[i - 1], yi[i - 1], xi[i], yi[i]), (time[i]-time[i-1])) == 0) {
			cout << "No";
			return 0;
		}
	}

	cout << "Yes";

	return 0;
}

Measured memory_bytes: 1408
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true){
            final int times = Integer.parseInt(br.readLine());
            if (times == 0) { break; }
            
            Map<String, Long> data = new LinkedHashMap<>();
            Map<String, Long> out = new HashMap<>();
            for (int i=1; i <= times; i++) {
                String[] e = br.readLine().split(" ");
                Long total = data.merge(e[0], Long.parseLong(e[1]) * Long.parseLong(e[2]), Long::sum);
                if (total >= 1_000_000L) {
                    if (out.putIfAbsent(e[0], total) == null) {
                        System.out.println(e[0]);
                    }
                }
            }
            if (out.size() == 0) {
                System.out.println("NA");
            }
        }
    }
}

Measured memory_bytes: 31636
H,N = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
A.insert(0,[0,0])
INFTY = 10**9
dp = [[INFTY for _ in range(H+1)] for _ in range(N+1)]
for i in range(N+1):
    dp[i][0] = 0
for i in range(1,N+1):
    for j in range(1,H+1):
        dp[i][j] = dp[i-1][j]
        dp[i][j] = min(dp[i][j],dp[i][max(0,j-A[i][0])]+A[i][1])
print(dp[N][H])

Measured memory_bytes: 125404
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	
	int a,b,c;
	cin >> a >> b >> c;
	if(a+b+c>21) cout << "bust" << endl;
	else cout << "win" << endl;
	
	return 0;
}

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

typedef long long ll;

int N, A, B, C, D;

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

    for(int i = 0; i <= N - 1; i++) {
        ll le = (ll)A + (ll)i*C - (ll)(N - 1 - i)*D;
        ll ri = (ll)A + (ll)i*D - (ll)(N - 1 - i)*C;

        if(le <= B && B <= ri) {
            printf("YES");
            return 0;
        }
    }
    printf("NO");
}


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

int n, a, c[100009], cnt;
int main() {
    cin >> n;
    rep(i, 0, n) {
        cin >> a;
        c[a]++;
    }
    rep(i, 0, 100001) {
        cnt = max(cnt, c[i] + c[i + 1] + c[i + 2]);
    }
    cout << cnt << endl;
}

Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Globalization;
using System.IO;

namespace AOJ2
{
    class Program
    {
        private static StreamScanner sc = new StreamScanner(Console.OpenStandardInput());
        static void Main()
        {
            var wPoint = new List<int>();
            var kPoint = new List<int>();
            for (int i = 0; i < 10; i++)
            {
                wPoint.Add(int.Parse(sc.Scan()));
            }
            for (int i = 0; i < 10; i++)
            {
                kPoint.Add(int.Parse(sc.Scan()));
            }
            Console.WriteLine(wPoint.OrderByDescending(x => x).Take(3).Sum()
                +" "+ kPoint.OrderByDescending(x => x).Take(3).Sum());


        }

    }
    public class StreamScanner
    {
        public StreamScanner(Stream stream) { str = stream; }
        private readonly Stream str;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        private byte read()
        {
            if (ptr >= len)
            {
                ptr = 0;
                if ((len = str.Read(buf, 0, 1024)) <= 0)
                {
                    return 0;
                }
            }
            return buf[ptr++];
        }
        public char Char()
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
        public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
    }
}

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

using namespace std;

vector<vector<int>> v(8, vector<int>(8));
vector<int> r(8, 1);
vector<int> c(8, 1);
vector<int> rpc(15, 1);
vector<int> rmc(15, 1);

bool put(int R, int C) {
    if (r[R] && c[C] && rpc[R+C] && rmc[R-C+7]) {
        r[R] = c[C] = rpc[R+C] = rmc[R-C+7] = 0;
        v[R][C] = 1;
        return true;
    }
	return false;
}

void dfs(int R = 0, int C = 0) {
    if (C == 8) {
        if (R == 7 && r[R] == 0) {
            for (int i = 0; i < 8; i++) {
                for (int j = 0; j < 8; j++) {
                    if (v[i][j]) cout << 'Q';
                    else cout << '.';
                }
                cout << endl;
            }
			exit(0);
        } else if (R == 7) {
            return;
        } else {
        	C = 0; R++;
		}
    }
    if (R && r[R-1]) return;
    dfs(R, C+1);
    int a, b, d, e;
    a = r[R];
    b = c[C];
    d = rpc[R+C];
    e = rmc[R-C+7];
    if (put(R, C)) {
		dfs(R, C+1);
		r[R] = a;
		c[C] = b;
		rpc[R+C] = d;
		rmc[R-C+7] = e;
 		v[R][C] = 0;
	}
}

int main() {
    int k; cin >> k;
    while (k--) {
        int a, b; cin >> a >> b;
        v[a][b] = 1;
        r[a] = 0;
        c[b] = 0;
        rpc[a+b] = 0;
        rmc[a-b+7] = 0;
    }
    dfs();
}


Measured memory_bytes: 3144
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI 3.141592653589793238462643383279
#define EPS 10e-8

using namespace std;

int main()
{
	int m, n;
	int sum;
	vector <double> sa, sb;

	for (;; ){
		cin >> m;
		if (!m )
			break; 
		vector <int> a (m, 0 );
		sum = 0;
		rep (i, m - 1 ){
			cin >> a[i];
			sum += a[i];
		} // end rep
		a[m-1] = 360 - sum;
		cin >> n;
		vector <int> b (n, 0 );
		sum = 0;
		rep (j, n-1 ){
			cin >> b[j];
			sum += b[j];
		} // end rep
		b[n-1] = 360 - sum;
		double s = 0.0, t = 0.0;
		rep (i, m )
			s += sin ((double)a[i]*PI/180. );
		sa.push_back (s );
		rep (j, n )
			t += sin ((double)b[j]*PI/180. );
		sb.push_back (t );
	} // end for

	int size = sa.size();
	rep (i, size ){
//		sa[i] = fabs (sa[i] ); sb[i] = fabs (sb[i] );
		if (sa[i] > sb[i]+EPS ){
			cout << '1' << endl;
		}else if (sa[i]+EPS < sb[i] ){
			cout << '2' << endl;
		}else{
			cout << '0' << endl;
		} // end if 
	} // end for

	return 0;
}

Measured memory_bytes: 0
# N  個の整数 a1,a2,..,aN が与えられます。えび君はこれらを書き換えて全て同じ整数にしようとしています。
# 各ai(1≦i≦N)は高々一回しか書き換えられません(書き換えなくても良い)。
# 整数xを整数yに書き換えるとき、コストが(x−y)2かかります。
# 仮にai=aj(i≠j)だとしても、ひとつ分のコストで同時に書き換えることは出来ません(入出力例2 を参照)。
# えび君が目的を達成するのに必要なコストの総和の最小値を求めてください。

n = gets.to_i
a = gets.chomp.split
n.times do |i|
    a[i] = a[i].to_i
end

a_each_kinds = []
a.each do |num|
    if !a_each_kinds.include?(num)
        a_each_kinds << num
    end
end

if a_each_kinds.length == 1
    puts 0
else
    costs = []
    (-100..100).each do |num|
        cost = 0
        n.times do |i|
            cost += (a[i] - num) ** 2
        end
        costs << cost
    end
    puts costs.min
end

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

int main() {
    int R, G, B, n;
    cin >> R >> G >> B >> n;

    int cnt = 0;
    for (int r = 0; R * r <= n; r++)
    {
        for (int g = 0; G * g<= n - R * r; g++)
        {
            if ((n - R * r - G * g) % B == 0) cnt++;  
        }  
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner read = new Scanner(System.in);
        int n = read.nextInt();
        int m = read.nextInt();
      	if (n == m)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


Measured memory_bytes: 23892
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main(){
	int n,k;
	while(cin>>n>>k){
		if(n%k == 0){
			cout<<0<<endl;
			continue; 
		}else{
			cout<<1<<endl;
			continue;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

int main(){
    int N, A, B;
    cin >> N >> A >> B;

    cout << min(A, B) << " " << max(A + B - N, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os;
}
template<class T> istream& operator>>(istream& is, vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) is >> *i; return is;
}

char colors[4096];
int arr[4096];
int dp[2048][2048];

int main()
{
#if defined(_DEBUG) 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	cout.tie(NULL);

	int n;
	cin >> n;

	map<char, map<int,int>> inv;
	for (int i = 0; i < 2*n; i++)
	{
		string cc;
		cin >> cc >> arr[i];

		colors[i] = cc[0];
		inv[colors[i]][arr[i]] = i;
	}

	vector<int> less_cnt(2*n);
	vector<vector<int>> others_before(2*n);
	for (int i = 0; i < 2*n; i++)
	{
		for (int j = 0; j < i; j++)
		{
			if (colors[j] == colors[i] && arr[j] < arr[i])
				less_cnt[i]++;
			if (colors[j] != colors[i])
			{
				others_before[i].push_back(arr[j]);
			}
		}
		sort(others_before[i].begin(), others_before[i].end());
	}

	for (int b_c = 0; b_c <= n; b_c++)
	{
		for (int w_c = 0; w_c <= n; w_c++)
		{
			if (b_c == 0 && w_c == 0)
				continue;
			int val = 100000000;
			if (b_c > 0)
			{
				int tmp = dp[b_c - 1][w_c];
				int pos = inv['B'][b_c];
				int move_cnt = pos - less_cnt[pos] - (upper_bound(others_before[pos].begin(), others_before[pos].end(), w_c) - others_before[pos].begin());
				if (move_cnt < 0)
					throw 1;
				val = min(val, tmp + move_cnt);
			}
			if (w_c > 0)
			{
				int cand = dp[b_c][w_c - 1];
				int pos = inv['W'][w_c];
				int move_cnt = pos - less_cnt[pos] - (upper_bound(others_before[pos].begin(), others_before[pos].end(), b_c) - others_before[pos].begin());
				if (move_cnt < 0)
					throw 1;
				cand += move_cnt;
				val = min(val, cand);
			}
			if (val < 0 || val == 100000000)
				throw 1;
			dp[b_c][w_c] = val;
		}
	}

	cout << dp[n][n];

	return 0;
}

Measured memory_bytes: 38272
#include<string>
#include<cstring>
#include<iostream>
using namespace std;

int main()
{
	string s;
	cin>>s;
	int len,i,k=0,t=0;
	len=s.size();
	if(len<4 || len>10)
		cout<<"WA"<<endl;
	else if (s[0]!='A')
		cout<<"WA"<<endl;
	else
	{
		for(i=1;i<len;i++)
		{
			if(s[i]=='C'&&i>=2&&i<=len-2)
				t++;
			if(s[i]>='a'&&s[i]<='z')
				k++;
		}
		if(t==1&&k==len-2)
			cout<<"AC"<<endl;
		else
			cout<<"WA"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, i, m, j, k, a;
char s[105];
int main(){
	scanf("%d%s", &n, s);
	m=strlen(s);
	if(m>n){
		for(i=0; i<n; i++){
			printf("%c", s[i]);
		}
		printf("...");
	}
	else{
		printf("%s", s);
	}
	return 0;
}

Measured memory_bytes: 3744
#include <iostream>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)

int main(){
  set<ll> st;
  ll a,b,k;cin>>a>>b>>k;
  FOR(i,a,min(a+k,b+1)){
    st.insert(i);
  }
  FOR(i,max(a,b-k+1),b+1){
    st.insert(i);
  }

  foreach(itr,st){
    cout<<*itr<<endl;
  }
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())
graph = [[] for _ in range(N + 1)]
for _ in range(M):
    x, y = map(int, input().split())
    graph[x].append(y)

dp = [-1] * (10 ** 5 + 1)


def dfs(v):
    if dp[v] != -1:
        return dp[v]

    res = 0
    for child in graph[v]:
        res = max(res, dfs(child) + 1)
    dp[v] = res
    return res


def solve():
    ans = 0
    for v in range(1, N + 1):
        ans = max(ans, dfs(v))
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 59056
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1e9+7;
using namespace std;
typedef pair<int,int> pii;
int main(){
    int h,w,n;
    cin >> h >> w >> n;
    cout << (n+max(h,w)-1)/(max(h,w)) << endl;
}


Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#define MOD 1000000007
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vector <int> p(N);
    for(int i = 0; i < N; i++){
        cin >> p[i];
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(p[i]==i+1){
            if(i==N-1){
                swap(p[i], p[i-1]);
            }else{
                swap(p[i], p[i+1]);
            }
            ans++;
        }
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 640
#include <chrono>
#include <map>
#include <iostream>

using namespace std;
using namespace std::chrono;

int main() {
  auto start = high_resolution_clock::now();

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  map<int, int> mp;
  for (int i = 0; i < n; ++i) {
    int val;
    cin >> val;
    ++mp[val];
  }

  int ans = 0;
  for (const pair<const int, int>& it : mp) {
    int cur = it.second;

    map<int, int>::iterator iter = mp.find(it.first - 1);
    if (iter != mp.end())
      cur += iter->second;
    iter = mp.find(it.first + 1);
    if (iter != mp.end())
      cur += iter->second;

    ans = max(ans, cur);
  }

  cout << ans << endl;

  cerr << "Total execution time : " << duration_cast<milliseconds>(high_resolution_clock::now() - start).count() << " ms" << endl;

  return 0;
}


Measured memory_bytes: 3200
#include <iostream>
using namespace std;
int a,b,c;
int main(void){
    cin>>a>>b>>c;
    if(a==b&&b==c){
        cout<<"No"<<endl;
        return 0;
    }
    if(a==b||b==c||a==c){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 1001001001;
//stoi(s) : string→int stoll(s) :string→longlong  int→string to_string(i)
const double PI = acos(-1.0);
//小数点の表し方 cout << fixed << setprecision(5);
int n;

void dfs(string s,char mx){
    if(s.size() == n){
        cout << s << endl;
        return;
    }else if(s.size() == 0){
        s = "a";
        dfs(s,'a');
    }
    else
    {
        char nx = char(int(mx) + 1);
        for(char c = 'a';c<=nx;c++){
            if(c == nx){
                dfs(s+c,nx);
            }else{
                dfs(s+c,mx);
            }
        }
    }
}


int main(){
    cin >> n;
    dfs("",'a');
    return 0;

}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

vi divide(10000100,1);

int main() {

	int n;
	cin >> n;
	rep_lr(i, 2, n + 1) {
		int ii = i;
		while (ii <= n) {
			divide[ii]++;
			ii += i;
		}
	}
	
	ll ans = 0;
	rep_lr(i, 1, n + 1) {
		ans += (ll)i * divide[i];
	}

	cout << ans << endl;

}

Measured memory_bytes: 42184
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;
ll n,k;
ll rank[200010];
ll tmp[200010];

bool compare_sa(ll i,ll j){
	if(rank[i]!=rank[j]) return rank[i] < rank[j];
	else{
		ll ri=(((i+k)<=n)?rank[i+k]:-1);
		ll rj=(((j+k)<=n)?rank[j+k]:-1);
		return ri<rj;
	}
}

void construct_sa(string S,ll *sa){
	n=S.length();
	for(ll i=0;i<=n;i++){
		sa[i]=i;
		rank[i]=i<n?S[i]:-1;
	}
	
	for(k=1;k<=n;k*=2){
		sort(sa,sa+n+1,compare_sa);
		
		tmp[sa[0]]=0;
		for(ll i=1;i<=n;i++){
			tmp[sa[i]]=tmp[sa[i-1]]+(compare_sa(sa[i-1],sa[i])?1:0);
		}
		for(ll i=0;i<=n;i++){
			rank[i]=tmp[i];
		}
	}
}

void construct_lcp(string S,ll *sa,ll *lcp){
	ll h=0;
	lcp[0]=0;
	//for(ll i=0;i<=n;i++) rank[sa[i]]=i;
	for(ll i=0;i<n;i++){
		ll j=sa[rank[i]-1];
		if(h>0) h--;
		for(;j+h<n&&i+h<n;h++){
			if(S[j+h]!=S[i+h]) break;
		}
		lcp[rank[i]-1]=h;
	}
}

ll sa[100000];
ll lcp[100000];
int main()
{
	string S,T;
	ll sl;
	ll ans;
	while(cin>>S>>T){
	ans=0;
	sl=S.length();
	S+="$"+T;
	construct_sa(S,sa);
	construct_lcp(S,sa,lcp);
	for(ll i=0;i<S.length();i++){
		if((sa[i]<sl)!=(sa[i+1]<sl)){
			ans=max(ans,lcp[i]);
		}
	}
	cout<<ans<<endl;
}}

Measured memory_bytes: 3460
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

int main() {

	int s, w;
	cin >> s >> w;
	if (w >= s) {
		cout << "unsafe" << endl;
	}
	else {
		cout << "safe" << endl;
	}
}

Measured memory_bytes: 3668
#include<iostream>
#include<cmath>

using namespace std;

int cnt(long m){
  int dig=0;
  while(m>0){
    m/=10;
    dig++;
  }
  return dig;
}

int main(){
 long n;
  cin >> n;

  int res;
  res=cnt(n);
  
  for(long i=1;i*i<=n;i++){
   if(n%i!=0) continue;

    res=min(res,max(cnt(i),cnt(n/i)));  
  } 
  
 cout << res << endl;
}

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

using namespace std;

int n;
map<string, int> mp;
long long ans;

int main()
{
  cin >> n;
  
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    ans += mp[s];
    mp[s]++;
  }
  
  cout << ans << endl;
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> uniqued;
    for (unsigned int i = 0; i < a.size(); i++) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    unique_copy(a.begin(), a.end(), back_inserter(uniqued));
    cout << (a.size() == uniqued.size() ? "YES" : "NO") << endl;
}

Measured memory_bytes: 5096
using System;
using System.Collections.Generic;
class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int q = int.Parse(input[1]);

            string s = Console.ReadLine();

            int[] ac = new int[n];
            ac[0] = 0;
            for (int i=1; i<n; i++)
            {
                if (s[i-1] == 'A' && s[i] == 'C')
                {
                    ac[i] = ac[i-1] + 1;
                }
                else ac[i] = ac[i-1];
            }
            for (int i=0; i<q; i++)
            {
                string[] read = Console.ReadLine().Split(' ');
                int l = int.Parse(read[0]);
                int r = int.Parse(read[1]);
                int ans;
                if (l > 1) 
                {
                    ans = ac[r-1] - ac[l-2];
                    if (ac[l-2] != ac[l-1]) ans--;
                }
                else ans = ac[r-1];
                Console.WriteLine(ans);
            }


            
            

            
            
        }
    }
    //mcs Main.cs
    //mono Main.exe

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int k;
    cin >> k;
    int a, b;
    a = k / 2;
    b = a + k % 2;
    cout << a * b << endl;
    return 0;
}



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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin >> s >> t;
    int n=s.size();
    int cnt=0;
    for(int i = 0; i < n; i++) {
        if(s[i]!=t[i]) cnt++;
    }
    cout << cnt << "\n";

    return 0;
}

Measured memory_bytes: 3828
#include <algorithm>
#include <bits/stdc++.h>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); //cinの高速化
  
  string S;
  IN(S);
  if(S[0] == 'S') OUT("Cloudy");
  else if(S[0] == 'C') OUT("Rainy");
  else if(S[0] == 'R') OUT("Sunny");  
}

Measured memory_bytes: 256
import itertools

n = int(input())
# p = list(map(int, input().split()))
# q = list(map(int, input().split()))
p = input()
q = input()

l = list(range(1, n+1))

# print(l)
prm = list(itertools.permutations(l))
# print(prm)

a = None
b = None
for i in range(len(prm)):
    s = ' '.join(str(c) for c in prm[i])
    if s == p:
        a = i+1
    if s == q:
        b = i + 1

# print(s)
print(abs(a-b))

Measured memory_bytes: 48748
import sys
import sys
input = sys.stdin.readline
a,b = input().split()
a = int(a)
b = int(b)
coin = 0
if a > b:
    coin += a
    a -= 1
else:
    coin += b
    b -= 1
if a > b:
    coin += a
    a -= 1
else:
    coin += b
    b -= 1
print(coin)

Measured memory_bytes: 3064
#include <stdio.h>

int gcd(int, int);

int main() 
{

    int num;
    int sum = 0;

    scanf("%d", &num);

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

    printf("%d", sum);
    
    return 0;

}

int gcd(int a, int b){
    if (b == 0){
        return a;
    }

    return gcd(b, a%b);
}



Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int A, B;
int main(){
    cin >> A >> B;
    if(A <= 5) cout << 0 << endl;
    else if(A <= 12) cout << B / 2 << endl;
    else cout << B << endl;
    return 0;
}

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

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  cout << (x-z)/(y+z) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int X[5], i;
  int Y[5];

  for(i = 0; i < 5; i++){
    scanf("%d", &X[i]);
    Y[i] = X[i] % 10;
  }

  int min = 10;
  int index = 0;

  for(i = 0; i < 5; i++){
    if(Y[i] < min && Y[i] != 0){
      min = Y[i];
      index = i;
    }
  }
  int time = 0;

  for(i = 0; i < 5; i++){
    if(i != index) time += X[i];
    while(time % 10 != 0) time++;
  }

  printf("%d\n", time + X[index]);

  return 0;
}


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

int main(){
    int N;
    int A[2][100];

    cin >> N;
    for(int j=0;j<N;j++){
        cin >> A[0][j];
    }
    for(int j=0;j<N;j++){
        cin >> A[1][j];
    }

    int max=0;
    for(int i=0;i<N;i++){
        int count=0;
        for(int j=0;j<=i;j++){
            count+=A[0][j];
        }
        for(int j=i;j<N;j++){
            count+=A[1][j];
        }
        if(count>max) max=count;
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		int p[] = new int [N];
		for (int i = 0; i < N; i++) {
			p[i] = sc.nextInt() - 1;
		}
		
		int r[] = new int[N];
		for (int i = 0; i < N; i++) {
			r[p[i]] = i + 1;
		}
		
		long a[] = new long[N];
		long b[] = new long[N];
		// 初期値の設定
		for (int i = 0; i < N; i++) {
			a[i] = (N + 1) * (i + 1);
			b[i] = (N + 1) * (N - i - 1) + r[i]; 
		}
		
		// 出力
		for (long n : a) {
			System.out.print(n + " ");
		}
		System.out.println("");
		for (long n : b) {
			System.out.print(n + " ");
		}
		
		sc.close();
	}
}

Measured memory_bytes: 30664
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL INF=100000000000;
string u="abcdefghijklmnopqrstuvwxyz";

int main(){
    LL x;
    cin >> x;
    if(x%11>6) cout << x/11*2+2 << endl;
    else if(x%11==0) cout << x/11*2 << endl;
    else cout << x/11*2+1 << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np


def parse():
    _, k = map(int, input().split())
    p = list(map(int, input().split()))
    c = list(map(int, input().split()))
    pc = {i: (pi - 1, ci) for i, (pi, ci) in enumerate(zip(p, c))}
    return k, pc


def read_split():
    k, pc = parse()
    lst = [[]]
    lst[0].append(pc.pop(0))
    while True:
        if not pc:
            break
        p, _ = lst[-1][-1]
        if p in pc:
            pcj = pc.pop(p)
            lst[-1].append(pcj)
        else:
            j = next(iter(pc.keys()))
            pcj = pc.pop(j)
            lst.append([pcj])
    return k, [np.array([ls[1] for ls in lst_], dtype=np.long) for lst_ in lst]


def inner(n, k, s, sim):
    if sim.shape[1] == 1:
        return sim.max()
    if k < n or s <= 0:
        return sim.max()
    div = k // n
    mod = k % n
    if mod == 0:
        return s * (div - 1) + sim.max()
    else:
        return s * div + sim[:, :mod].max()


def main():
    k, data_set = read_split()
    result = min([d.min() for d in data_set])
    for data in data_set:
        n = data.size
        rep = np.repeat(data[None], 2, axis=0).flatten()
        sim = np.array([np.cumsum(rep[i:i+min(k, n)]) for i in range(n)])
        cand = inner(n, k, data.sum(), sim)
        result = max(result, cand)
    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 418852
from collections import Counter

N = int(input())

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)
    return a

a = prime_factorize(N)
num = list(Counter(a).values())

ans = 0
for i in num:
    j = 1
    while i - j >= 0:
        ans += 1
        i -= j
        j += 1

print(ans)
        

Measured memory_bytes: 9492
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{
	int n,a;
	set<int>S;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		S.insert(a);
	}
	cout<<S.size()<<endl;
	return 0;
}

Measured memory_bytes: 256
S = input()
flag = True
if S[0] != 'A' or S[2:-1].count('C') != 1 or S[1].lower() != S[1] or S[-1].lower() != S[-1]:
  flag = False
for i in range(2,len(S)-1):
  if S[i] != 'C' and S[i].lower() != S[i]:
    flag = False
print('AC' if flag else 'WA')

Measured memory_bytes: 3060
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
ans = ["YES","NO"]

distance = abs(b-a)
speed = v-w

result = distance - speed * t
if result <= 0:
    print(ans[0])
elif result > 0:
    print(ans[1])
    


Measured memory_bytes: 9184
#include<iostream>
using namespace std;
typedef long long LL;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	LL x;
	cin>>x;
	LL t=100;
	int cnt=0; 
	while(t<x){
		t+=0.01*t;
		cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
ll n,a[1000010],ans;
int main(){
	scanf("%lld",&n);
	for(ll i=1;i<=n;i++)scanf("%lld",&a[i]);
	sort(a+1,a+1+n);
	if(n&1){
		ll x=n/2;
		for(ll i=1;i<=x;i++)
		ans+=a[n-i+1];
		ans*=2;
		for(ll i=1;i<=n-x;i++)ans-=a[i];
		for(ll i=1;i<=n-x-2;i++)ans-=a[i];
		ll ans2=0;
		for(ll i=1;i<=x+1;i++)ans2+=a[n-i+1];
		for(ll i=1;i<=x-1;i++)ans2+=a[n-i+1];
		for(ll i=1;i<=n-x-1;i++)ans2-=a[i]*2;
		cout<<max(ans,ans2)<<endl;
	 	return 0;
	}
	else{
		ll x=n/2;
		for(ll i=1;i<=x;i++)
		ans+=a[n-i+1];
		ans*=2;
		ans-=a[n-x+1];
		for(ll i=1;i<=x;i++)
		ans-=a[i]*2;
		ans+=a[x];
		cout<<ans<<endl; 
	}
	return 0;
}
/*
*/ 

Measured memory_bytes: 1024
#!/usr/bin/ruby
require 'mathn'
while(l=gets.split)!=["0","0"]	
	n=l[0].to_i;m=l[1].to_i(n)
	if n==0 then break end
	p n.prime_division.map{|a,b|
		z=m;r=0
		while z>0 do r+=(z=z.div a) end
		r.div b
	}.min
end

Measured memory_bytes: 4204
N, M = map(int, input().split())
S = []
C = []
for i in range(N):
  S.append(list(map(int, input().split())))
  
for i in range(M):
  C.append(list(map(int, input().split())))

def manh_dist(S, C):
  return abs(S[0] - C[0]) + abs(S[1] - C[1])
  
for i in range(N):
  index = M+1
  dist = 1e9
  for j in range(M):
    #print(manh_dist(S[i], C[j]), dist)
    if dist > manh_dist(S[i], C[j]):
      dist = manh_dist(S[i], C[j])
      index = j
  print(index+1)
  


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N,M,X,Y;
	cin >> N >> M >> X >> Y;
	vector<ll> x(N),y(M);
	FOR(i,0,N)cin>>x[i];
	FOR(i,0,M)cin>>y[i];
	SORT(x);
	SORT(y);
	ll maxx = x[N-1];
	ll miny = y[0];
	bool ans = false;
	FOR(Z,X+1,Y+1){
		if(maxx<Z && miny>=Z )ans = true;
	}
	if(ans){
		cout << "No War" << endl;
	}else{
		cout << "War" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef long double ld;
const ld pi = 4*atan((ld)1);
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll nax = 0;

string s;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll ans = 0;
	ll cnt = 0;
	cin >> s;
	for(ll i = 0; i < s.size(); i++){
		if(s[i] == 'R'){
			cnt++;
		}
		else{
			cnt = 0;
		}
		ans = max(ans, cnt);
	}
	cout << ans << '\n';
}



Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//freopen("test.txt","r",stdin);
	ll n;
	cin>>n;
	vector<ll> v;
	for(ll i=0;i<n;i++)
	{
		ll x;
		cin>>x;
		v.push_back(x);
	}
	bool flag=true;
	for(ll i=1;i<n;i++)
	{
		if(v[i]<v[i-1])
			flag=false;
	}
	for(ll i=0;i<n;i++)
	{
		for(ll j=i+1;j<n;j++)
		{
			swap(v[i],v[j]);
			bool check=true;	
			for(ll l=1;l<n;l++)
			{
				if(v[l]<v[l-1])
				{
					check=false;
				}
			}
			if(check==true)
				flag=true;
			swap(v[i],v[j]);
		}
	}
	if(flag)
		cout<<"YES"<<"\n";
	else
		cout<<"NO"<<"\n";

}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	FastScanner in;
	PrintWriter out;

	void solve() {
		int n = in.nextInt();
		int[] l = new int[n];

		for (int i = 0; i < n; i++) {
			l[i] = in.nextInt();

		}
		Arrays.sort(l);

		int answer = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				for (int k = j + 1; k < n; k++) {
					if (l[j] >= l[k] + l[i]) {
						break;
					}
					if (l[k] >= l[i] + l[j]) {
						break;
					}
					answer++;
				}
			}

		}

		out.println(answer);

	}

	void run() {
		try {
			in = new FastScanner(new File("Main.in"));
			out = new PrintWriter(new File("Main.out"));

			solve();

			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	void runIO() {

		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

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

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

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

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

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

	public static void main(String[] args) {
		new Main().runIO();
	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
Graph G;
vector<ll>dist;
bool negative[2510];
#define INF 1e18
bool flag;
bool bellman_ford(ll n,ll s){//nは頂点数 sは始点
    dist=vector<ll>(n,INF);
    dist[s]=0;
    for (int i = 0; i < n; i++)
    {   flag=false;
        for (int v = 0; v < n; v++)
        {
            for (int k = 0; k < G[v].size(); k++)
            {
                Edge e=G[v][k];
                if(dist[v]!=INF && dist[e.first]>dist[v]+e.second){
                    dist[e.first]=dist[v]+e.second;
                    flag = true;
            }
            
        }
        }
        if(!flag) break;
}
for (int i = 0; i < n; i++)
    {
        for (int v = 0; v < n; v++)
        {
            for (int k = 0; k < G[v].size(); k++)
            {
                Edge e=G[v][k];
                if(dist[v]!=INF && dist[e.first]>dist[v]+e.second){
                    
                    dist[e.first]=-INF;
                    negative[e.first]=true;

                }
                }
        }
    }
}
        
   

int main(){
    ll n,m,p;
    cin>>n>>m>>p;
    G.assign(n,vector<Edge>());
    for (int i = 0; i < m; i++)
    {
        int a,b,c;
        cin>>a>>b>>c;
        a--;
        b--;
        G[a].push_back(Edge(b,(-1)*(c-p)));
    }

    bellman_ford(n, 0);
    if(!negative[n-1]){
        cout<<max(-dist[n-1],0LL)<<endl;
    }
    else{
        cout<<-1<<endl;
    }

    
    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int d;
  vector<int> A(N);
  vector<int> T(N, 1);
  for (int i=0; i<K; i++){
    cin >> d;
    for (int j=0; j<d; j++){
      cin >> A.at(j);
      T.at(A.at(j)-1) = 0;
    }
  }
  
  int ans=0;
  for (int i=0; i<N; i++){
    ans += T.at(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int A  = keyboard.nextInt();
		int B  = keyboard.nextInt();
		int C  = keyboard.nextInt();
		
		int ans = 0;
		int k = B/A;
		ans = k >C ? C : k;
				
		System.out.println(ans);
		keyboard.close();	
	}
}

Measured memory_bytes: 21844
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

int K, dist[(int)1e5 + 5];
deque<int> BFS;

int main(){
  FAST_IO
  cin >> K;

  for(int rep = 0; rep < K; ++rep) dist[rep] = INF;
  dist[1] = 1;
  BFS.push_back(1);

  while(!BFS.empty()){
    int cur = BFS.front();
    BFS.pop_front();

    int nxt = (cur + 1) % K;
    if(dist[nxt] > dist[cur] + 1){
      dist[nxt] = dist[cur] + 1;
      BFS.push_back(nxt);
    }

    nxt = (cur * 10) % K;
    if(dist[nxt] > dist[cur]){
      dist[nxt] = dist[cur];
      BFS.push_front(nxt);
    }
  }

  cout << dist[0] << '\n';
  return 0;
}


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

bool ispn(int x){
	if(x == 2 || x == 3)return true;
	if(x%2 == 0 || x%3 == 0 || x <= 4) return false;
	for(int i = 6; (i-1)*(i-1) <= x; i++)
		if(x%(i-1) == 0 || x%(i+1) == 0)return false;
	return true;
}

int main(){
	int n, count = 0, a;
	
	cin>>n;
	
	for(int i = 0; i < n; i++){
		cin>>a;
		if(ispn(a))count++;
	}
	cout<<count<<endl;
	return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define FLASH ios_base::sync_with_stdio(0);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";


using namespace std;

ll a,b,c,d;
ll maxx=-LLONG_MAX;
int main(){
FLASH;
cin>>a>>b>>c>>d;
maxx=max(a*c,maxx);
maxx=max(b*d,maxx);
maxx=max(a*d,maxx);
maxx=max(c*b,maxx);
cout<<maxx<<endl;







return 0;
} 


Measured memory_bytes: 3652
n=input()
for i in range(n):
	x,y,b,p=map(int,raw_input().split())
	if b>4 and p>1:print (x*b+y*p)*8/10
	elif b>4:print min(x*b+y*p,(x*b+y*2)*8/10)
	elif p>1:print min(x*b+y*p,(x*5+y*p)*8/10)
	else:print min(x*b+y*p,(x*5+y*2)*8/10)

Measured memory_bytes: 4228
#include<stdio.h>
#include<string.h>
int main(void){
int A,B,C,D,E,N,M,x,y,cou=0,cou2,v[1000000],w[1000000],min_i,en=0;
    char S[10],W[10],s[10],X,Y;
   scanf("%d %d",&A,&B);
   if(A==B){
       printf("Draw");
   }else if(A==1){
       if(B!=1){
           printf("Alice");
       }
   }else if(B==1){
       if(A!=1){
           printf("Bob");
       }
   }else if(A>B){
       printf("Alice");
   }else{
       printf("Bob");
   }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef     long long               ll;
typedef     vector<ll>              vll;
#define     meme(s)                 memset(s,0,sizeof(s))
#define     rall(s)                 s.rbegin(),s.rend()
#define     i(x)                    scanf("%lld",&(x))
typedef     unordered_map<ll,ll>    mll;
#define     pb                      push_back
#define     in2(x,y)                i(x),i(y)
#define     EL                      cout<<'\n'
#define     fio                     ios_base::sync_with_stdio(false),cin.tie(NULL)
#define     all(s)                  s.begin(),s.end()
typedef     unordered_map<ll,vll>   circuit;
typedef     unordered_map<ll,bool>  is;
const ll    MOD=                    1e9+7;
#define     no                      cout<<"NO\n"
#define     yes                     cout<<"YES\n"
#define     fr(n,x)                 for(int n=0;n<x;n++)
#define     pf(x)                   printf("%lld\n",(x))
const ll    mx=                     2e7;
#define     segtree                 ll L=2*node,R=L+1,mid=(l+r)/2
#define     cs(n)                   printf("Case %lld: ",(n))
typedef     pair<ll,ll>             pll;
typedef     set<ll>                 sll;
#define     X                       first
#define     Y                       second
vector<bool>                        pr(mx,1);
void sv()                           {pr[1]=0;for(ll n=2;n*n<=mx;n++){if(pr[n]){for(ll k=2*n;k<mx;k+=n)pr[k]=0;}}}
ll bit[mx];
void up( ll ind,ll vl)              {while (ind<mx){bit[ind]+=vl;ind+=ind&(-ind);}} //BIT update
ll qr( ll ind)                      {ll res=0;while(ind){res+=bit[ind];ind-=ind&(-ind);}return res;} //BIT query
#define T(j) ll t;cin>>(t);for(ll j=1;j<=t;j++)



void solve()
{
    ll x;
    i(x);
    mll vis;
    vll s(x);
    fr(n,x)
    {
        i(s[n]);
        vis[s[n]]++;
    }
    ll res=0;
    fr(n,x)
    {
        bool p=1;
        ll d=s[n];
        vis[d]--;
        for(ll j=1;j*j<=d;j++)
        {
            if(d%j==0)
            {
                if(vis[j])
                {
                    p=0;
                    break;
                }
                if(j*j!=d)
                {
                    ll v=d/j;
                    if(vis[v])
                    {
                        p=0;
                        break;
                    }
                }
            }
        }
        vis[s[n]]++;
        if(p)res++;
    }
    pf(res);
}
int main() {
    //T(n)
        //cs(n),
        solve();

}

Measured memory_bytes: 35860
n, l = map(int, input().split())
aaa = list(map(int, input().split()))

max_i = 0
max_two_ropes = 0
for i in range(n - 1):
    two_ropes = aaa[i] + aaa[i + 1]
    if max_two_ropes < two_ropes:
        max_i = i
        max_two_ropes = two_ropes

if max_two_ropes < l:
    print('Impossible')
else:
    print('Possible')
    ans = list(range(1, max_i + 1))
    ans.extend(range(n - 1, max_i + 1, -1))
    ans.append(max_i + 1)
    print('\n'.join(map(str, ans)))


Measured memory_bytes: 17764
#include<bits/stdc++.h>
const int N=2e5+5;
#define mst(a) memset(a,0,sizeof a) 
typedef long long ll;
using namespace std;
ll a[N],b[N];
int main(){
	 ll n,mx=0,ans=0;
	 cin>>n;
	 for(int i=1;i<=n;i++) cin>>a[i],b[a[i]]++,mx=max(mx,a[i]);
	 for(int i=1;i<=mx;i++)
	 {
	 		if(b[i])
	 		{
	 			ans+=b[i]*(b[i]-1)/2;
			}
	 }
	 //printf("ans=%lld\n",ans);
	 for(int i=1;i<=n;i++)
	 {
	 	ll tmp=(b[a[i]]-1);
	  	 printf("%lld\n",ans-tmp);
	  }
	  return 0;
}

Measured memory_bytes: 4736
#include<stdio.h>
int n;
int A[500001];
void maxHeapify(int);
int main(){
  int parent(int);
  int left(int);
  int right(int);
  void buildMaxHeap();
  int i;
  
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }

  buildMaxHeap();
  
  for(i=1;i<=n;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}

int parent(int i){
  return i/2;
}

int left(int i){
  return 2 * i;
}

int right(int i){
  return 2 * i + 1;
}

void buildMaxHeap(void){
  int i;
  for(i = n/2;i>=1;i--){
    maxHeapify(i);
  }
}

void maxHeapify(int i){
  int l = left(i);
  int r = right(i);
  int largest;
  int tmp;
  if(l <= n && A[l] > A[i]) largest = l;
  else largest = i;
  if(r <= n && A[r]  > A[largest]) largest = r;
  if(largest != i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(largest);
  }
}



Measured memory_bytes: 3640