akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define N 1000
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
#define fastio ios::sync_with_stdio(false); cin.tie(0)

int main(){
    fastio;

    int n, tab = 0, ta = 0, tb = 0, len, sta, fin, ans = 0;
    bool isA, isB;
    string s;
    cin >> n;
    for(int i = 0 ; i < n ; i++){
        cin >> s;
        isA = false; isB = false;
        len = s.size();
        sta = 1;
        fin = len;
        if(s[0] == 'B') { sta = 2; isB = true;}
        if(s[len-1] == 'A') { fin = len-1; isA = true;}
        for(int j = sta ; j < fin ; j++) 
            if(s[j-1] == 'A' && s[j] == 'B') ans++;
        if(isA && isB) tab++;
        else if(isA) ta++;
        else if(isB) tb++;
    }

    if(ta == 0 && tab){
        ta++;
        tab--;
    }

    while(tab && ta){
        ans++;
        tab--;
    }

    while(tb && ta){
        ans++;
        tb--; ta--;
    } 

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

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

int main() {
  int n;
  cin >> n;
  vector<string> blue(n);
  for (int i = 0; i < n; i++) {
    cin >> blue.at(i);
  }
  int m;
  cin >> m;
  vector<string> red(m);
  for (int i = 0; i < m; i++) {
    cin >> red.at(i);
  }

  int ans = 0;
  for (int i = 0; i < n; i ++) {
    int tmp = 0;
    for (int j = 0; j < n; j ++) {
      if (blue.at(i) == blue.at(j)) {
        tmp ++;
      }
    }
    for (int j = 0; j < m; j ++) {
      if (blue.at(i) == red.at(j)) {
        tmp --;
      }
    }
    ans = max(ans, tmp);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
fun main() {
    readInt()

    fun howMany(j: Int, left: List<Int>, right: List<Int>): Long {
        var num = 0L
        for (i in left) {
            if (i > j) break
            val forbidden = j + j - i
            val findForbidden = right.binarySearch(forbidden)
            val startIndex = -(right.binarySearch(j) + 1)
            num += (right.size - startIndex)
            if (findForbidden >= 0) num--
        }
        return num
    }
    val s = readLn()

    val r = mutableListOf<Int>()
    val g = mutableListOf<Int>()
    val b = mutableListOf<Int>()

    s.forEachIndexed { index, c ->
        when(c) {
            'R' -> r.add(index)
            'G' -> g.add(index)
            'B' -> b.add(index)
        }
    }

    var ans = 0L
    for (j in 1 until s.length - 1) {
        when(s[j]) {
            'R' -> {
                ans += howMany(j, g, b)
                ans += howMany(j, b, g)
            }
            'G' -> {
                ans += howMany(j, r, b)
                ans += howMany(j, b, r)
            }
            'B' -> {
                ans += howMany(j, r, g)
                ans += howMany(j, g, r)
            }
        }
    }

    println(ans)
}

// Input Reader
private fun readLn() = readLine()!!
// Read from file
//private val inputReader = InputStreamReader(FileInputStream(File("input.txt")))
//private val lines = inputReader.readLines()
//private var currLine = -1
//private fun readLn(): String {
//    currLine++
//    return lines[currLine]
//}

private fun readInt() = readLn().toInt()


Measured memory_bytes: 53628
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstdlib>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

int main(){
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    if (s < t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    

}

Measured memory_bytes: 256
import unittest


class TestB(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think([5, 4, 2, 1], 1), 'Yes')

    def test_2(self):
        self.assertEqual(think([380, 19, 1], 2), 'No')

    def test_3(self):
        self.assertEqual(think([4, 56, 78, 901, 2, 345, 67, 890, 123, 45, 6, 789], 3), 'Yes')


def solve():
    a, m = read()
    result = think(a, m)
    write(result)


def read():
    n, m = read_int(2)
    return read_int(n), m


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a, m):
    total = sum(a)
    threshold = total // (4 * m) if total % (4 * m) == 0 else total // (4 * m) + 1
    return 'Yes' if len(list(filter(lambda x: x >= threshold, a))) >= m else 'No'


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 49388
#include <iostream>
using namespace std;
 
int main() {
	int H, W;
	while(1){
		cin >> H >> W;
		if(H==0 && W==0)break;
		for(int i=0; i < H; i++){
			if(i==0 || i==(H-1)){
				for(int pole = 0; pole < W; pole++) cout << "#";
				cout << "\n";
			}
			else{
				cout << "#";
				for(int vd = 0; vd < W-2; vd++) cout << ".";
				cout << "#" << "\n";
			}
	}
	cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 3008
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef double ld;
ld PI=acos(-1),EPS=1e-15,a[100],b[100];
ld n,ans,A,B,L;
int main(void){
    cin>>n;
    //cout<<PI<<endl;
    for(int i=0;i<n;i++)cin>>a[i]>>b[i];
    for(int i=0;i<360;i++){
        A=0,B=0;
        L=(ld)((ld)i/180);
        //cout<<L<<endl;
        for(int j=0;j<n;j++){
            if(a[j]*cos(PI*L)+b[j]*sin(PI*L)>0){
                A+=a[j],B+=b[j];
            }
        }
        ans=max(ans,A*A+B*B);
    }
    cout<<setprecision(20)<<pow(ans,0.5)<<endl;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int n,arr[105],a,b;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }
    sort(arr+1,arr+n+1);
    int kode=1;
    for(int i=n;i>=1;i--){
        if(kode==1) a+=arr[i];
        else b+=arr[i];
        kode=1-kode;
    }
    cout<<a-b<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define _Pi 3.1415926535
#define _MOD = 1e9+7;
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];

    sort(a.begin(),a.end());
    sort(c.begin(),c.end());

    ll ans = 0;

    rep(i,n){
        ll A = lower_bound(a.begin(),a.end(),b[i]) - a.begin();
        ll C = c.end() - upper_bound(c.begin(),c.end(),b[i]);
        ans += A*C;
    }

    cout << ans << endl;

    return 0;
}


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

int n, a, b, c, score[10010], now=0;
vector<int> cs, t[10010];
vector<pair<int, int>> es;

void dfs(int v, int previous=-1) {
    score[v] = cs[now];
    now += 1;
    for (auto u: t[v]) {
        if (u != previous) {
            dfs(u, v);
        }
    }
}

void print_vec(vector<int> v) {
    for (auto a: v) {
        cout << a << " ";
    }
    cout << endl;
}

int main() {
    cin >> n;
    for (int i = 0; i < n-1; ++i) {
        cin >> a >> b;
        t[a-1].push_back(b-1);
        t[b-1].push_back(a-1);
        es.push_back(make_pair(a-1, b-1));
    }
    for (int i = 0; i < n; ++i) {
        cin >> c;
        cs.push_back(c);
    }
    sort(cs.rbegin(), cs.rend());

    dfs(0);

    int final_score = 0;
    for (auto it: es) {
        final_score += min(score[it.first], score[it.second]);
    }
    cout << final_score << endl;
    for (int i = 0; i < n; ++i) {
        cout << score[i] << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <functional>
#include <set>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
	ll N, nx, e, ecnt, a, con = 0;

	cin >> N;
	nx = N;

	for (ll i = 2; i*i <= nx;i++){
		e = 0;
		ecnt = 1;
		while (N%i == 0){
			N = N / i;
			e++;
			if (e==ecnt){
				e = 0;
				ecnt++;
				con++;
				//cout << "i="<<i << endl;
			}
		}
	}
	if (N != 1)	con++;

	cout << con << endl;
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int N,A;
  cin >> N >> A;
  
  if (N % 500 -A <= 0){
    cout << "Yes" << endl;
  }
  else if (N % 500 <= 0){
    cout << "Yes" << endl;
  }
  else if (N % 500 -A >= 0){
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3556
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var a=sc.Ia;
		var h=sc.Arr(n,i=>new Tuple<int,int>(i+1,a[i]-1));
		Array.Sort(h,(u,v)=>u.Item2-v.Item2);
		var g=new int[n*n];
		var bo=true;
		for(int i = 0;i<n;i++) {
			if(g[h[i].Item2]!=0){bo=false;break;}
			g[h[i].Item2]=h[i].Item1;
		}
		for(int i = 0,j=0;i<n;i++) {
			int p=h[i].Item1-1;
			while(p>0&&j<h[i].Item2){
				if(g[j]!=0){j++;}
				else{g[j]=h[i].Item1;p--;}
			}
			if(p!=0){bo=false;break;}
		}
		for(int i = n-1,j=n*n-1;i>=0;i--) {
			int p=n-h[i].Item1;
			while(p>0&&j>h[i].Item2){
				if(g[j]!=0){j--;}
				else{g[j]=h[i].Item1;p--;}
			}
			if(p!=0){bo=false;break;}
		}
		if(bo){
			Console.WriteLine("Yes");
			Console.WriteLine("{0}",String.Join(" ",g));
		}
		else{
			Console.WriteLine("No");
		}
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 28508
#!/usr/bin/env perl

use strict;
use warnings;

my ($n, $m) = split / /, <>;
chomp $m;

my $ans = 0;
for (my $i = 0; $i < 1000000; $i++) {
  $ans += ($i + 1) * (($n - $m) * 100 + 1900 * $m) * ((1 - 1.0 / (2 ** $m)) ** $i) / (2 ** $m);
}

print int($ans + 0.5), "\n";


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

int main(){
    int  C, N, M ,K;
    int sum = 0;
    int t = 0;
    string s, s1;
    cin >> N >> M >> C;
    sum = C;
    vector<int> B(M);
    for(int i = 0; i < M; i++){
        cin >> B.at(i);
    }

    vector<int> A(M);
    for(int j = 0; j < N; j++){
        for(int i = 0; i < M; i++){
            cin >> A.at(i);
            sum += A.at(i)*B.at(i);
        }
        if(sum > 0) t++;
        sum = C;
    }
    cout << t << endl;

//    vector<int> X();

//    for(int i = 0; i < ; i++){}
//    for(int j = 0; j < ; j++){}

//    cout <<  << endl;
}

Measured memory_bytes: 256
'use strict'

function Main(input) {
  const X = Number(input.split(" ")[0])
  const A = Number(input.split(" ")[1])
  
  if(X < A) {
    console.log(0)
  } else {
    console.log(10)
  }
  
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim())

Measured memory_bytes: 21064
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner();
			int n = cin.Int();
			int m = cin.Int();
			var to = new List<Tuple<int, int>>[n];
			for (int i = 0; i < n; i++) {
				to[i] = new List<Tuple<int, int>>();
			}

			for (int i = 0; i < m; i++) {
				int l = cin.Int() - 1;
				int r = cin.Int() - 1;
				int d = cin.Int();
				to[l].Add(new Tuple<int, int>(r, d));
				to[r].Add(new Tuple<int, int>(l, -1 * d));
			}

			bool[] done = new bool[n];
			long[] pos = new long[n];
			for (int i = 0; i < n; i++) {
				pos[i] = -1;
			}

			var q = new Queue<int>();
			for (int i = 0; i < n; i++) {
				if (done[i]) {
					continue;
				}

				q.Enqueue(i);
				done[i] = true;
				pos[i] = 0;
				while (q.Count > 0) {
					int next = q.Dequeue();
					foreach (var nn in to[next]) {
						int target = nn.Item1;
						long nextPos = pos[next] + nn.Item2;
						if (pos[target] == -1) {
							pos[target] = nextPos;
							if (done[target] == false) {
								done[target] = true;
								q.Enqueue(target);
							}
						} else {
							if (pos[target] != nextPos) {
								Console.WriteLine("No");
								return;
							} else {
								if (done[target] == false) {
									done[target] = true;
									q.Enqueue(target);
								}
							}
						}
					}
				}
			}

			Console.WriteLine("Yes");
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 42816
//@author yash2040
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define int long long
#define pb push_back
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
const int maxn=10000000+10;
int divi[maxn]={0};
void f(int n) 
{ 
  
    // Array to store the count 
    // of divisors 
    //int div[n + 1]; 
    //memset(div, 0, sizeof div); 
  
    // For every number from 1 to n 
    for (int i = 1; i <= n; i++) { 
  
        // Increase divisors count for 
        // every number divisible by i 
        for (int j = 1; j * i <= n; j++) 
            divi[i * j]++; 
    } 
  
    // Print the divisors 
    //for (int i = 1; i <= n; i++) 
       // cout << div[i] << " "; 
}
main()
{
	fast();
	int t=1;
//	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		f(n);
		int sum=0;
		for(int i=1;i<=n;i++)
		sum+=i*divi[i];
		cout<<sum<<endl;
	}
	
}




Measured memory_bytes: 81744
n,k=map(int,input().split())
box=list(map(int,input().split()))

count=0
for i in range(n):
    for j in box[i:]:
        if box[i]>j:
            count +=1

count_2=0
for i in range(n):
    for j in box:
        if box[i]>j:
            count_2 +=1

ans=(count*k)%(10**9+7) + ((count_2*k*(k-1))//2)%(10**9+7)
print(ans%(10**9+7))

Measured memory_bytes: 41564
n, m = map(int, input().split())
apple = list(map(int, input().split()))
count = 0
a = sum(apple)
for i in apple:
    if float(i) >= a/(4*m):
        count += 1
    else:
        pass
if count >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61988
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

const int N = 3;
int a[N][N];

const int M = 105;
bool have[M];

void good() {
  cout << "Yes\n";
  exit(0);
}

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  // Emily <3
  for (int i = 0; i < 3; ++i)
    for (int j = 0; j < 3; ++j) {
      cin >> a[i][j];
    }
  int n; cin >> n;
  while (n--) {
    int t; cin >> t;
    have[t] = true;
  }
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      a[i][j] = have[a[i][j]];
    }
  }
  for (int i = 0; i < 3; ++i) {
    bool bad = false;
    for (int j = 0; j < 3; ++j) {
      if (!a[i][j]) {
        bad = true;
        break;
      }
    }
    if (!bad) good();
  }
  for (int j = 0; j < 3; ++j) {
    bool bad = false;
    for (int i = 0; i < 3; ++i) {
      if (!a[i][j]) {
        bad = true;
        break;
      }
    }
    if (!bad) good();
  }
  if (a[0][0] & a[1][1] & a[2][2]) good();
  if (a[0][2] & a[1][1] & a[2][0]) good();
  cout << "No\n";
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
const unsigned long long int M= 1000000007;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()	
#define fr(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define int   long long 
#define endl "\n"
using namespace std;
int power(int x,int y){int res=1;while(y>0){if(y&1)res=x*res; y=y>>1;x=x*x;}return res;}
int power(int x,int y,int mod){int res=1;while(y>0){if(y&1)res=x*res%mod; y=y>>1;x=x*x%mod;}return res;}

void nik()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);

	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
}
     

 	#define F first 
	#define S second 


int vis[50]={0};
std::vector<int> v[50],ans[50];

void dfs(int i,int p)
{
	if(v[i].size()==0)return ;
	if(!vis[i])
	{
		vis[i]=1;
		ans[p].pb(i);
		for(int it:v[i])
		{
			if(!vis[it])dfs(it,p);
		}

	}
}

signed main()
{	//nik();

int test=1;
//cin>>test;
while(test--)
{

string s;
cin>>s;
int n=s.length();
if(s[n-1]=='s')s+="es";
else s+="s";

cout<<s<<endl;
	

}
return 0;
}



Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int mod=1e9+7;
const int N = 2e5+5;


vector<ll>ans,veca,vecb;
vector<int>adj[N];
vector<double>aka;
vector<pair<int,double>>dp[N];
vector<bool>vis;


void init(int n){
    ans.clear();veca.clear();aka.clear();vis.clear();ans.resize(n);
    vecb.clear(),vecb.resize(n);veca.resize(n);vis.resize(n);
    for (int i = 0; i <n; i++) {
        vis[i]=0;
    }
    for (int i = 0; i<=n; i++) {
        adj[i].clear();
    }
    for (int i = 0; i <=n; i++) {
        dp[i].clear();
    }
    for (int i = 0; i < n; i++) {
        ans[i]=0;
    }
}

int check(int a,int b,int c){
    int res=0;
    if(a+b>c) res=1;
    return res;
    
}
bool valid(int a,int b,int c){
    if((a<b)&&(b<c)) return 0;
    return 1;
}
void solve(){
    int n,flag=0;
    cin>>n;
    init(n);
    for (int i = 0; i <n; i++) {
        cin>>veca[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                if(!valid(i,j,k)){
                    set<int>st;vector<int>vec;
                    st.insert(veca[i]);st.insert(veca[j]);st.insert(veca[k]);
                    vec.push_back(veca[i]);vec.push_back(veca[j]);vec.push_back(veca[k]);
                    if(st.size()==3){
                        sort(vec.begin(),vec.end());
                        flag+=check(vec[0],vec[1],vec[2]);
                    }
                }
            }
        }
    }
    cout<<flag<<"\n";
    
}

int main(){
   
   
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int T=1;
    //cin>>T;
    while(T--){
        solve();
    }
        
        
    return 0;
}

Measured memory_bytes: 13020
import java.util.*;

class Main{
public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();
    String c = sc.next();
    char x = 'a';
    for(int i = 0; i < 300; i++) {
    	if(x == 'a') {
    		if(a.length() == 0) {
    			System.out.println("A");
    			break;
    		} else {
    			x = a.charAt(0);
    			a = a.substring(1);
    		}
    	}
    	if(x == 'b') {
    		if(b.length() == 0) {
    			System.out.println("B");
    			break;
    		} else {
    			x = b.charAt(0);
    			b = b.substring(1);
    		}
    	}
    	if(x == 'c') {
    		if(c.length() == 0) {
    			System.out.println("C");
    			break;
    		} else {
    			x = c.charAt(0);
    			c = c.substring(1);
    		}		
    	}        					
    }
}
}


Measured memory_bytes: 23764
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("0"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

vvi to, co;
vi used;
vi s;
bool ok;
int ms;

int dfs(int v, int c=0) {
  if (used[v] != -1) {
    ok &= used[v]==c;
    return 0;
  }
  used[v] = c;
  s[c]++;
  int res = 1;
  rep(i,sz(to[v])) {
    ms++;
    res += dfs(to[v][i], (c+co[v][i])%3);
  }
  return res;
}

int main() {
  int n, m;
  scanf("%d%d",&n,&m);
  to = co = vvi(n);
  rep(i,m) {
    df(a); df(b);
    --a; --b;
    to[a].pb(b); co[a].pb(1);
    to[b].pb(a); co[b].pb(2);
  }
  used = vi(n,-1);
  ll ans = 0;
  rep(i,n) if (used[i] == -1) {
    s = vi(3); ok = true; ms = 0;
    int x = dfs(i);
    if (ok) {
      rep(j,3) ok &= !!s[j];
      if (ok) {
        rep(j,3) ans += (ll)s[j]*s[(j+1)%3];
      } else {
        ans += ms/2;
      }
    } else {
      ans += (ll)x*x;
    }
  }
  cout << ans << endl;
  return 0;
}







Measured memory_bytes: 16256
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        h1: u64,
        m1: u64,
        h2: u64,
        m2: u64,
        k: u64,
    }

    let a = h1 * 60 + m1;
    let b = h2 * 60 + m2;
    let c = if a < b { b - a } else { b + 24 * 60 - a };
    let ans = c - k;
    println!("{}", ans);
}


Measured memory_bytes: 2112
/* When Talent doesn't work, Hard work beats Talent*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(13);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define scanstr(s) cin>>ws; getline(cin,s);

const double PI = 3.141592653589793;

void solve()
{
	int n;
	cin >> n;
	cout << n * n *n << nl;
}

int32_t main()
{
	FastIO;
	int T;
	T=1;
	while(T--) solve();
	return 0;
}



Measured memory_bytes: 3624
# snuke 君は自転車を買いに来ました。 snuke 君はすでに買う自転車を決めたのですが、その自転車にはベルが付いていないため、
# 自転車とは別にベルも買う必要があります。 snuke 君は安全意識が高いので、ベルをどちらの手でも鳴らせるよう、両方のハンドルに 1 つずつ 付けることにしました。
# お店にあるベルは 3 種類で、それぞれ a 円、 b 円、 c 円です。 この 3 つのうち、異なる 2 つのベルを選んで買うときの、値段の合計の最小値を求めて下さい。

a,b,c = map(int,input().split())

if a >= b and a >= c :
    print(b + c)
elif b >= a and b >= c:
    print(a + c)
elif c >= a and c >= b:
    print(a + b)

Measured memory_bytes: 9036
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;cin>>n>>k;
    vector<ll>a(n);
    rep(i,n){
        cin>>a[i];
    }
    //boolでいける
    vector<vector<bool> >dp(n+1,vector<bool>(k+1));
    vector<vector<bool> >dp2(n+2,vector<bool>(k+1));
    dp[0][0]=1;
    rep(i,n){
        rep(j,k+1){
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
            if(j+a[i]<=k)dp[i+1][j+a[i]]=max(dp[i][j],dp[i+1][j+a[i]]);
            else{
                dp[i+1][k]=max(dp[i+1][k],dp[i][j]);
            }
        }
    }
    ll ans=n;
    dp2[n+1][0]=1;
    for(int i=n+1;i>1;i--){
        rep(j,k+1){
            dp2[i-1][j]=max(dp2[i-1][j],dp2[i][j]);
            if(j+a[i-2]<=k)dp2[i-1][j+a[i-2]]=max(dp2[i][j],dp2[i-1][j+a[i-2]]);
            else{
                dp2[i-1][k]=max(dp2[i-1][k],dp2[i][j]);
            }
        }
    }
    REP(i,1,n+1){
        ll ai=a[i-1];
        ll ma1=0,ma2=0;
        rep(j,k+1){
            if(dp[i-1][j])ma1=j;
        }
        rep(j,k+1){
            if(dp2[i+1][j])ma2=j;
        }
        if(ma1+ma2<k-ai){
            continue;
        }
        //cout<<ma1<<' '<<ma2<<endl;
        vector<ll>rui(k+1);
        rui[k]=dp2[i+1][k];
        for(int j=k-1;j>=0;j--){
            rui[j]=rui[j+1]+dp2[i+1][j];
        }
        bool f=0;
        rep(j,k){
            if(!dp[i-1][j])continue;
            ll l=max(0LL,k-ai-j);
            ll r=k-j;
            if(i==4){
            }
            if(rui[l]-rui[r]>0)f=1;
        }
        if(f)ans--;
        //cout<<i<<' '<<ans<<endl;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 9088
#include <iostream>
#include <math.h>
using namespace std;

int main(){
  long long N;
  cin >> N;
 
  long long sqN = (long long)(sqrt(N));
  long long a, b;
 
  for(long long i = sqN; i >= 0; --i){
    if(N % i == 0){
      a = i;
      b = N / i;
      break;
    }
  }
 
  cout << (a + b - 2) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>


#define ll long long


//gcdやり直す

void swap (int *x, int *y) {
  int temp;    

  temp = *x;
  *x = *y;
  *y = temp;
}




/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}






/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int h,w,k;
  scanf("%d%d%d",&h,&w,&k);
  char s[h+10][w+10];
  for(int i=0;i<h;i++){
    scanf("%s",s[i]);
  }


  int ans=0;
  for(int bit1=0;bit1<(1<<h);bit1++){
    for(int bit2=0;bit2<(1<<w);bit2++){
      int count=0;
      for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
          if((1<<i) & bit1){
            continue;
          }
          if((1<<j) & bit2){
            continue;
          }

          if(s[i][j]=='#'){
            count++;
          }
        }
      }

      if(count==k){
        ans++;
      }
    }
  }
  printf("%d\n",ans);
}
/*

//bit全探索
//0->塗る　1->塗らない
01001 & (1<<3)
01001 & 01000->true;
->false;


  0 0 1 0 0 1 
0             
1             
0             
0             
1              
1             

*/

Measured memory_bytes: 1732
package main

import "fmt"

func main() {
	var R int
	fmt.Scan(&R)
	var s string
	if R < 1200 {
		s = "ABC"
	} else if R < 2800 {
		s = "ARC"
	} else {
		s = "AGC"
	}
	fmt.Println(s)
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;

long long int tonum(string str){
  int s=0,e=0;
  for(; e<(int)str.length(); e++){
    if(str[e]=='(') s=e+1;
    if(str[e]==')') break;
  }
  return stoll(str.substr(s,e-s));
}

long long int binop(long long int a, long long int b, char op){
  if(op=='+') return a+b;
  if(op=='-') return a-b;
  if(op=='*') return a*b;
  return -1;
}

long long int calc(string str, int i, int j, int k){
  vector<long long int> nums;
  int s=0;
  int depth=0;
  bool onlynum=true;
  for(int d=0; d<(int)str.length(); d++){
    if(str[d]=='+' || str[d]=='-' || str[d]=='*'){
      onlynum=false;
      if(depth==0){
        if(str[s]=='('){
          nums.push_back( calc(str.substr(s+1, d-s-2), i,j,k));
        }else{
          nums.push_back( calc(str.substr(s,d-s), i,j,k) );
        }
        nums.push_back( str[d] );
        s = d+1;
      }
    }
    if(str[d]=='(') depth++;
    if(str[d]==')') depth--;
  }

  if(onlynum) return tonum(str);
  if(str[s]=='('){
    nums.push_back( calc(str.substr(s+1,(int)str.length()-s-2), i,j,k));
  }else{
    nums.push_back( calc(str.substr(s,(int)str.length()-s), i,j,k) );
  }

  map<char,int> oppr;
  oppr['+']=i;
  oppr['-']=j;
  oppr['*']=k;
  for(int i=0; i<3; i++){
    int nowop=1;
    while(nowop<(int)nums.size()){
      if(oppr[nums[nowop]] == i){
        nums[nowop-1] = binop(nums[nowop-1], nums[nowop+1], (char)nums[nowop]);
        nums.erase(nums.begin()+nowop);
        nums.erase(nums.begin()+nowop);
      }else{
        nowop+=2;
      }
    }
  }

  return nums[0];
}

int main(){
  string str;
  cin >> str;

  long long int ans = -9223372036854775807;
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      for(int k=0; k<3; k++){
        ans = max(ans, calc(str,i,j,k));
      }
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll; //long longをllとして簡略

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i,n){
    cin >> p[i];
  }
  int min=INT_MAX;
  int ans=0;
  rep(i,n){
    if(p[i]<min){
      min = p[i];
      ans++;
    }
  }

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

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

using std::cin;
using std::vector;

constexpr int MAX_PACKET = 100000;

int weight_num;
int tracks_num;
vector<int> weight;

bool canAlloc(long capacity);

int main()
{
    cin >> weight_num >> tracks_num;
    weight.reserve(weight_num);

    int max_weight = 0;
    long sum_weight = 0;
    for (auto i = 0; i < weight_num; i++) {
        int in;
        cin >> in;
        weight.push_back(in);
        if (weight.at(i) > max_weight) {
            max_weight = weight.at(i);
        }
        sum_weight += weight.at(i);
    }

    long low = max_weight;
    long upp = sum_weight;
    while (low < upp) {
        long mid = (low + upp) / 2;
        if (canAlloc(mid)) {
            upp = mid;
        } else {
            low = mid + 1;
        }
    }

    std::cout << low << std::endl;

    return 0;
}

bool canAlloc(long capacity)
{
    long alloced_in_one = 0;
    int track_id = 0;

    int i = 0;
    while (i < weight_num) {
        if (alloced_in_one + weight.at(i) <= capacity) {
            alloced_in_one += weight.at(i++);
        } else {
            alloced_in_one = 0;
            if (++track_id == tracks_num) {
                return false;
            }
        }
    }
    return true;
}

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

int main() {
	int a[55], n, maxi = 0, cur = 0; cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (abs(a[i]) > maxi) {
			maxi = abs(a[i]);
			cur = i;
		}
	}
	cout << n * 2 - 1 << endl;
	for (int i = 0; i < n; i++)cout << cur + 1 << ' ' << i + 1 << endl;
	if (a[cur] >= 0)for (int i = 0; i < n - 1; i++)cout << i + 1 << ' ' << i + 2 << endl;
	else for (int i = n - 1; i; i--)cout << i + 1 << ' ' << i << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;


// f(0) = 1
// f(1) = 1
// f(2) = 2*f(0)
// f(3) = 3*f(1)
// f(4) = 4*f(2) = 4*2*f(0)
// f(5) = 5*f(3) = 5*3*f(1)
// f(6) = 6*f(4) = 6*4*2*f(0);
// f(7) = 7*f(5) = 7*5*3*f(1)
// f(8) = 8*f(6) = 8*6*4*2*f(0)
//...
// f(10) = 10*

// if n is odd, ans = 0;
// else
// f(2n) is multiple of n numbers;
// if n = 5, it contain one "5".
// if n = 10, it contains 5, 10
// if n = 15, it containt 5, 10, 15
// if n = 5m it contains m "5"
// devide n by 5 until n'%5 != 0;

//f(2n) contains n odd numbers.
//f(100) = 100*98*96*......90*......80......
//f(100) = 100*90*80*70*60*50*40*30*20*10*C
//       =f(10)*10
//f(1000) = f(100)*10

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

   if(n%2 == 1) {
     cout << 0 << endl;
     return 0;
   }
   ll ans = 0;
   ll cnt = 10;
   while(cnt <= n){
     ans += n/cnt;
     cnt *= 5;
   }
   cout << ans << endl;
 }


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

int main(int argc, char *argv[])
{
  int n;
  int p, rt, i, j, ct = 0;
  int prime;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%d", &p);

    rt = (int)floor(sqrt(p));

    prime = 1;
    for (j = 2; j <= rt; j++) {
      if (p % j == 0) {
        prime--;
        break;
      }
    }

    if (prime == 1) ct++;
  }

  printf("%d\n", ct);

  return 0;
}

Measured memory_bytes: 596
a,b,k = [int(i) for i in input().split()]

ct=1
for i in range(k):
  if ct==1:
    if a%2==0:
      b=b+a/2
      a=a/2
    else:
      b=b+(a-1)/2
      a=(a-1)/2
    ct=ct*-1
  else:
    if b%2==0:
      a=a+b/2
      b=b/2
    else:
      a=a+(b-1)/2
      b=(b-1)/2
    ct=ct*-1
print(int(a),int(b))

Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;

int main(void){
 double n,m,d,ans;
 int k=1;
 cin>>n>>m>>d;

 if(d==0)ans=(m-1)*(n-d)/(n*n);
 else ans=(m-1)*2.0*(n-d)/(n*n);
 std::cout<<std::fixed;
 std::cout<<ans<<std::endl;
 

}

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

using namespace std;

int main() {
  long long t,n,k,i,w=0,l=0;
string s;
cin>>s;
n=s.size();
for(i=0;i<n;i++)
{
    if(i%2==0)
    {
        if(s[i]=='p')l++;
    }
    else
    {
        if(s[i]=='g')w++;
    }
}
  cout<<w-l;
  
}

Measured memory_bytes: 512
from collections import deque
N, M = map(int, input().split())
graph = [[] * N for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

# BFS
reach = [False] * N
prev_v = [-1] * N
que = deque()

reach[0] = True
que.append(0)
while que:
    v = que[0]
    que.popleft()
    for new_v in graph[v]:
        if reach[new_v]:
            continue
        que.append(new_v)
        reach[new_v] = True
        prev_v[new_v] = v

for i in range(N):
    if not reach[i]:
        print("No")
        exit()
print("Yes")
for i in range(1, N, 1):
    print(prev_v[i]+1)


Measured memory_bytes: 34928
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	char s[10];
	scanf("%s", s);
	if(s[0]==s[1] && s[1]!=s[2] && s[2]==s[3]) printf("Yes\n");
	else if(s[0]==s[2] && s[2]!=s[1] && s[1]==s[3]) printf("Yes\n");
	else if(s[0]==s[3] && s[3]!=s[1] && s[1]==s[2]) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
#include <stdio.h>

int main() {
	int cross[101];
	
	while(!feof(stdin)) {
		for(int i=0; i<101; i++){
			cross[i] = 0;
		}
		
		while(true) {
			int a,b;
			//if(scanf("%d %d", &a, &b)<=0){return 0;}
			scanf("%d %d", &a, &b);
			if ( a==0 ) {
				if(feof(stdin)){return 0;}
				bool ng = false;
				if ( cross[1]%2 == 1 && cross[2]%2 == 1 ) {
					for(int i=3; i<101; i++) {
						if ( cross[i]%2 == 1 ) {
							ng = true;
							break;
						}
					}
				} else {
					ng = true;
				}
				puts(ng?"NG":"OK");
				break;
			}
			cross[a]++;
			cross[b]++;
		}
	}
}

Measured memory_bytes: 1016
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int M = Integer.parseInt(sc.next());
    int[] val = new int[N];
    int ans = N;
    int min = 1000000;
    for(int i = 0; i < N; i++){
      int n = Integer.parseInt(sc.next());
      M -= n;
      min = n < min ? n : min;
    }
    
    ans += M == 0 ? 0 : M/min;
    System.out.println(ans);
  }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int> > a(n, vector<int>(m));

  for (int i = 0; i < n; i++) {
    cin >> c[i];
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  ll ans = 999999999;
  vector<int> sum(m, 0);
  ll money = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    // cout << bit << endl;
    money = 0;
    fill(sum.begin(), sum.end(), 0);
    int count = 0;
    for (int i = 0; i < n; i++) {
      if (bit & (1 << i)) {
        money += c[i];  // book-cを選ぶ
        for (int j = 0; j < m; j++) {
          sum[j] += a[count][j];
        }
      }
      count++;
    }

    for (int i = 0; i < m; i++) {
      if (sum[i] < x) {
        break;
      }
      if (i == m - 1) {
        // cout << "a" << endl;
        ans = min(ans, money);
      }
    }
  }
  if (ans == 999999999) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>

using namespace std;

int search_xyz(int e);

int main()
{
    int num;
    int n, m;
    while (cin >> n >> m && n > 0)
    {
        pair<int, int> road[n];
        int res = 0;
        for (int i = 0; i < n; i++)
        {
            cin >> road[i].second >> road[i].first;
            res += road[i].second * road[i].first;
        }
        sort(road, road + n);
        reverse(road, road + n);
        int point = 0;
        while (m > 0 && point < n)
        {
            if (m >= road[point].second)
            {
                res -= road[point].first * road[point].second;
                m -= road[point].second;
            }
            else
            {
                res -= road[point].first * m;
                m = 0;
            }
            point++;
        }
        cout << res << endl;
    }

    return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,a,b;
    cin>>n>>m;
    ll dp[m+1];
    memset(dp,0,sizeof(dp));
    for(int i=0;i<n;i++){
    	cin>>a>>b;
    	for(int j=m-b;j>=0;j--){
    		dp[j+b]=max(dp[j+b],dp[j]+a);
    	}
    }
    cout << dp[m] <<endl;
    return 0;
}




Measured memory_bytes: 3292
#include <string>
#include <iostream>

int main() {
  // そこまでのsの数より多いtはすべて残る
  // 逆に、それ以降のtの数より多いsは全て残る
  std::string x;
  std::cin >> x;
  int s = 0, ans = 0;
  for (int i = 0;i < x.size();i++) {
    if (x[i] == 'T') {
      if (s == 0) {
        ans++;
      } else {
        s--;
      }
    } else {
      s++;
    }
  }
  std::cout << ans + s << '\n';
  return 0;
}

Measured memory_bytes: 640
N, M = map(int, input().split())
E = []
for i in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    E.append([a, b])

E.sort()
l, r = 0, float('inf')
ans = 0
for a, b in E:
    if b <= l or a >= r:
        ans += 1
        l, r = a, b
    else:
        l = max(a, l)
        r = min(b, r)

print(ans + 1)


Measured memory_bytes: 20072
require 'complex'

# Complex * Complex -> Double                                                          

def dot(c1, c2)
  (c1.conj * c2).real
end

# Complex * Complex -> Double                                                          
def cross(c1, c2)
  (c1.conj * c2).imag
end

# Complex * Complex * Complex -> Complex                                               
# return the proj of vector p0p to vector p0p1                                         
def proj(p0, p1, p)
  (p1 - p0) * dot(p1 - p0, p - p0) / ((p1 - p0).abs ** 2) + p0
end


def sign d
  eps = 1e-8
  d < -eps ? -1 : (d > eps ? 1 : 0)
end

# Complex * Complex * Complex -> Bool                                                  
# Return true if Point q is on segment p1p2                                            
# otherwise return false                                                               
def on_seg(p1, p2, q)
  sign(cross(p1 - q, p2 - q)) == 0 &&
    sign(dot(p1 - q, p2 - q)) < 0
end

def direct(p0, p1, p2)
  d = cross(p1 - p0, p2 - p0)
  if sign(d) == 1
    :COUNTER_CLOCKWISE
  elsif sign(d) == -1
    :CLOCKWISE
  else
    if on_seg(p2, p1, p0)
      :ONLINE_BACK
    elsif on_seg(p0, p2, p1)
      :ONLINE_FRONT
    else
      :ON_SEGMENT
    end
  end  
end

def main
  xp0, yp0, xp1, yp1 = gets.chomp.split(/\s/).collect { |x| x.to_f}
  q = gets.chomp.to_i
  (1..q).each do |ca|
    p0 = Complex(xp0, yp0)
    p1 = Complex(xp1, yp1)
    x, y = gets.chomp.split(/\s/).collect { |x| x.to_f}
    p = Complex(x, y)
    puts direct(p0, p1, p).to_s
  end
end

main

Measured memory_bytes: 6220
//============================================================================
// Name        : d.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<vector>
using namespace std;
typedef long long ll;
ll pow(ll a,ll p,ll def){
	ll ans=1;
	ll mul=a;
	while(p){
		if(p%2){
			ans*=mul;
			ans%=def;
		}
		p/=2;
		mul*=mul;
		mul%=def;
	}
	return ans;
}


int main() {
	int n,k;cin>>n>>k;
	vector<ll> bc(k+1),rc(k+2);
	bc[0]=0;
	bc[1]=1;
	rc[0]=0;
	rc[1]=1;
	ll def=1;
	for(int i=0;i<9;i++)def*=10;
	def+=7;
	for(int i=2;i<=k;i++){
		bc[i]=bc[i-1]*(k-1-(i-1)+1);
		bc[i]%=def;
		bc[i]*=pow(i-1,def-2,def);
		rc[i]=rc[i-1]*(n-k-1-(i-1)+1);
		rc[i]%=def;
		rc[i]*=pow(i-1,def-2,def);
		bc[i]%=def;
		rc[i]%=def;
	}
	rc[k+1]=rc[k+1-1]*(n-k-1-(k+1-1)+1);
	rc[k+1]%=def;
	rc[k+1]*=pow(k+1-1,def-2,def);
	rc[k+1]%=def;
//	for(int i=0;i<=k;i++){
//		cout<<bc[i]<<' ';
//	}cout<<endl;
//	for(int i=0;i<=k+1;i++){
//		cout<<rc[i]<<' ';
//	}cout<<endl;
	for(int i=1;i<=k;i++){
//		cout<<i<<endl;
		ll ans=0;
		ans+=rc[i-1];
		ans+=2*rc[i];
		ans+=rc[i+1];
		ans*=bc[i];
		ans%=def;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;

void solve(){
	int h,w,m;
	cin >> h >> w >> m;
	vector <int> r(h),c(w);
	set <pair <int,int>> ss;
	for(int i = 0;i < m;++i){
		int n1,n2;
		cin >> n1 >> n2;
		--n1,--n2;
		ss.insert({n1,n2});
		++r[n1];
		++c[n2];
	}
	int maxxr = -1,maxxc = -1,ir = 0,ic = 0;
	for(int i = 0;i < h;++i){
		maxxr = max(maxxr,r[i]);
	}
	for(int i = 0;i < w;++i){
		maxxc = max(maxxc,c[i]);
	}
	vector <int> mr,mc;
	for(int i = 0;i < h;++i){
		if(r[i] == maxxr) mr.push_back(i);
	}
	for(int i = 0;i < w;++i){
		if(c[i] == maxxc) mc.push_back(i);
	}
	for(int i = 0;i < mr.size();++i){
		for(int j = 0;j < mc.size();++j){
			if(ss.find({mr[i],mc[j]}) == ss.end()){
				cout << maxxr + maxxc << newl;
				return;
			}
		}
	}
	cout << maxxr + maxxc - 1 << newl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


Measured memory_bytes: 23764
import math
"nの約数列挙"
def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return ass

"nの素因数分解"
def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


import collections
N = int(input())
A = prime_factor(N)
A.sort()
c = collections.Counter(A)
ans = 0
for x in c.values():
  count = 1
  while x > 0:
    x -= count
    if x >= 0:
      count +=1
      ans += 1

print(ans)



Measured memory_bytes: 9740