akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //a
  int a, b;
  cin >> a >> b;
  cout << max(0, a - 2 * b) << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

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

	int N, K; cin >> N >> K;
	vector<int> x(N, 0);
	rep (i, N) cin >> x[i];

	int res = 0;
	rep (i, N){
		res += 2 * (int)min(x[i], K - x[i]);
	} // end rep
	
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    map<ll, ll> m;
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        m[A[i]]++;
    }

    vector<ll> C;
    for (auto p : m) {
        if (p.second >= 4) {
            C.push_back(p.first);
            C.push_back(p.first);
        } else if (p.second >= 2) {
            C.push_back(p.first);
        }
    }
    sort(C.begin(), C.end(), greater<ll>());
    if ((int)C.size() < 2) {
        cout << 0 << endl;
    } else {
        cout << C[0] * C[1] << endl;
    }
}


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

using namespace std;
void solve4() {
//	int N_MAX = 100000;
	int N, M, A;
	cin >> N >> M;
	int sum = 0;
	map<long long, int> mp;
	mp[0] = 1;
	for (int i = 0; i < N; ++i) {
		cin >> A;
		sum += A;
		sum %= M;
		mp[sum]++;
	}
//	for (const auto& x : mp) {
//		std::cout << x.first << " => " << x.second << "\n";
//	}

//calculate
	long long ans = 0;
	for (const auto& p : mp) {
		int count = p.second;
		if (count != 1) {
			ans += (long long)count * (count - 1) / 2;
		}
	}

//print
	cout << ans << '\n';
}

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


Measured memory_bytes: 4224
#pragma warning disable IDE1006
#pragma warning disable IDE0011
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Convert;
using static System.Math;
using static Extentions;

class IO
{
    int idx;
    string[] line;

    public void R(params char[] sep) { line = Console.ReadLine().Split(sep); idx = 0; }
    public string S => line[idx++];
    public string[] Ss => line.Skip(idx++).ToArray();
    public char C => char.Parse(line[idx++]);
    public char[] Cs => line.Skip(idx++).Select(char.Parse).ToArray();
    public int I => int.Parse(line[idx++]);
    public int[] Is => line.Skip(idx++).Select(int.Parse).ToArray();
    public long L => long.Parse(line[idx++]);
    public long[] Ls => line.Skip(idx++).Select(long.Parse).ToArray();
    public double F => double.Parse(line[idx++]);
    public double[] Fs => line.Skip(idx++).Select(double.Parse).ToArray();
    public decimal D => decimal.Parse(line[idx++]);
    public decimal[] Ds => line.Skip(idx++).Select(decimal.Parse).ToArray();
    public BigInteger B => BigInteger.Parse(line[idx++]);
    public BigInteger[] Bs => line.Skip(idx++).Select(BigInteger.Parse).ToArray();

    public void Write<T>(params T[] xs)
    {
        Console.Write(xs.First());
        foreach (var x in xs.Skip(1)) Console.Write(" " + x);
        Console.WriteLine();
    }
    public void Write(params object[] xs)
    {
        Console.Write(xs.First());
        foreach (var x in xs.Skip(1)) Console.Write(" " + x);
        Console.WriteLine();
    }
}

static class Extentions
{
    public static BigInteger Fact(long x)
    {
        BigInteger a = 1;
        for (var i = 2L; i <= x; i++) a *= i;
        return a;
    }

    public static long C(long n, long r)
    {
        return (long)(Fact(n) / Fact(n - r) / Fact(r));
    }
}

static class Program
{
    public static void Main()
    {
#if !DEBUG
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
#endif
        Solve(new IO());
        Console.Out.Flush();
    }

    public static void Solve(IO io)
    {
        io.R();
        var n = io.L;
        var p = io.L;
        io.R();
        var a = io.Ls;

        var even = a.LongCount(x => x % 2 == 0);
        var odd = a.LongCount(x => x % 2 == 1);

        var tmp1 = 0L;
        for (var i = p; i <= odd; i += 2) tmp1 += C(odd, i);
        var tmp2 = 0L;
        for (var i = 0L; i <= even; i++) tmp2 += C(even, i);
        var ans = tmp1 * tmp2;

        io.Write(ans);
    }
}

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

const int ALPHABET_SIZE = 26;

// trie node
struct TrieNode {
    struct TrieNode* children[ALPHABET_SIZE];

    // isEndOfWord is true if the node represents
    // end of a word
    bool isEndOfWord;
};

// Returns new trie node (initialized to NULLs)
struct TrieNode* getNode(void)
{
    struct TrieNode* pNode = new TrieNode;

    pNode->isEndOfWord = false;

    for (int i = 0; i < ALPHABET_SIZE; i++)
        pNode->children[i] = NULL;

    return pNode;
}

// If not present, inserts key into trie
// If the key is prefix of trie node, just
// marks leaf node
void insert(struct TrieNode* root, string key)
{
    struct TrieNode* pCrawl = root;

    for (int i = 0; i < key.length(); i++) {
        int index = key[i] - 'a';
        if (!pCrawl->children[index])
            pCrawl->children[index] = getNode();

        pCrawl = pCrawl->children[index];
    }

    // mark last node as leaf
    pCrawl->isEndOfWord = true;
}

// Returns true if key presents in trie, else
// false
bool search(struct TrieNode* root, string key)
{
    struct TrieNode* pCrawl = root;

    for (int i = 0; i < key.length(); i++) {
        int index = key[i] - 'a';
        if (!pCrawl->children[index])
            return false;

        pCrawl = pCrawl->children[index];
    }

    return (pCrawl != NULL && pCrawl->isEndOfWord);
}

// Returns true if root has no children, else false
bool isEmpty(TrieNode* root)
{
    for (int i = 0; i < ALPHABET_SIZE; i++)
        if (root->children[i])
            return false;
    return true;
}

// Recursive function to delete a key from given Trie
TrieNode* remove(TrieNode* root, string key, int depth = 0)
{
    // If tree is empty
    if (!root)
        return NULL;

    // If last character of key is being processed
    if (depth == key.size()) {

        // This node is no more end of word after
        // removal of given key
        if (root->isEndOfWord)
            root->isEndOfWord = false;

        // If given is not prefix of any other word
        if (isEmpty(root)) {
            delete (root);
            root = NULL;
        }

        return root;
    }

    // If not last character, recur for the child
    // obtained using ASCII value
    int index = key[depth] - 'a';
    root->children[index] =
          remove(root->children[index], key, depth + 1);

    // If root does not have any child (its only child got
    // deleted), and it is not end of another word.
    if (isEmpty(root) && root->isEndOfWord == false) {
        delete (root);
        root = NULL;
    }

    return root;
}



int main()
{
    
    int  n ; 
    cin>> n ; 
        TrieNode* arr = new TrieNode() ; 
        
        int count =0 ; 
        for(int  i = 0 ;i < n ;i++)
        {
            string s ;
            
            cin>>s ; 
            if(search (arr , s))
            continue ; 
            else
            {
                count++ ;
                insert( arr, s) ; 
                
            }
        }
        cout<<count <<endl ;

    
}


Measured memory_bytes: 303392
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
void NO(){cout<<"NO"<<endl;exit(0);}
int main(){
ll n;cin>>n;ll x[100001];ll s=0;for(int i=0;i<n;++i)cin>>x[i],s+=x[i];
ll n2=n*(n+1)/2;ll k=s/n2;if(n2*k!=s)NO();
ll j=0;for(int i=0;i<n;++i){ll d=x[(i+1)%n]-x[i];if((k-d)%n!=0||k-d<0)NO();j+=(k-d)/n;}
if(j!=k)NO();cout<<"YES"<<endl;
return 0;}

Measured memory_bytes: 1024
#include <cstdio>

const int MaxN = 3000 + 5;
const int Mod = 1000000007;

int N;
char S[MaxN];
int F[MaxN], G[MaxN];

inline int add(int x, int y) { return (x += y) >= Mod ? x - Mod : x; }
inline int sub(int x, int y) { return (x -= y) < 0 ? x + Mod : x; }

void init() {
  scanf("%d", &N);
  scanf("%s", S + 1);
}

inline void makePre() {
  G[0] = 0;
  for (int i = 1; i <= N; ++i)
    G[i] = add(G[i - 1], F[i]);
}

void solve() {
  F[1] = 1;
  makePre();
  for (int i = 2; i <= N; ++i) {
    for (int j = 1; j <= i; ++j) {
      if (S[i - 1] == '<') F[j] = G[j - 1];
      else F[j] = sub(G[N], G[j - 1]);
    }
    makePre();
  }
  printf("%d\n", G[N]);
}

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

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef pair<int,int> P;
typedef long long ll;
const int INF = 1001001001;
const ll INFL = 1e17;
const int MOD = 1e9+7;


int main(){
    int n,k;
    cin >> n >> k;
    int r,s,p;
    cin >> r >> s >> p;
    string str;
    cin >> str;
    ll ans = 0;
    for(int i=1; i<=k; i++){
        char before = 'n';
        char now;
        for(int j=i; j<=n; j+=k){
            now = str[j-1];
            if(now == before){
                before = 'n';
            }else{
                if(now == 'r') ans += p;
                else if(now == 's') ans += r;
                else if(now == 'p') ans += s;
                before = now;
            }
        }
    }   
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int k;

   int a[5];


   for(int i=0;i<5;i++)
   {
       cin>>a[i];
   }
   //sort(a,a+n);
  // reverse(a,a+n);
    for(int i=0;i<5;i++)
   {
      if(a[i]==0){
            k=i+1;
        break;
      }
   }
   cout<<k<<endl;
   return 0;


}


Measured memory_bytes: 3596
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;

int main()
{
    fast_io
    ll i,j,a,b,c;
    cin>>a>>b>>c;
    if(a==b&&b==c)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;



    return 0;
}





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

int main(){
	
	string str;
	int a = 0, i = 0;
	
	while(1){
	
		cin >> str;
		
		if(str == "0")break;
		
		for(i = 0; i < str.size(); ++i){
		
			a += str[i] - '0';
		}
		
		cout << a << endl;
		a = 0;
	}
	
	return 0;
}

Measured memory_bytes: 1188
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
using namespace std;
int main(void)
{
	long long n,x;
	int i,a,b[100];
	char c;
	scanf("%lld",&n);
	n--;
	x=26;
	a=1;
	while(1)	{
		if(n<x)	{
			for(i=0;i<a;i++)	{
				b[i]=n%26;
				n=n/26;
			}
			for(i=a-1;i>=0;i--)	{
				c='a'+b[i];
				printf("%c",c);
			}
			printf("\n");
			break;
		}
		else{
			n-=x;
			x=x*26;
			a++;
		}
	}
	return 0;
}

Measured memory_bytes: 1648
N = int(input())
W = [i for i in map(int,input().split())]
ans = 10**9
for i in range(N):
  if (abs(sum(W[:i+1])-sum(W[i+1:])) < ans):
    ans = abs(sum(W[:i+1])-sum(W[i+1:]))
    
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <iomanip>
#define ll long long
using namespace std;

int main(void){
    double l;
    cin >> l;
    double c = l/3;
    double ans = c*c*c;
    cout << std::fixed << std::setprecision(8) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define SORT(c) sort((c).begin(),(c).end())
#define dbug(x) cout<<#x<<"="<<x<<endl
#define m0(x) memset(x,0,sizeof(x))
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define reprs(i, m, n) for(int i = n; i >= m; i--)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pl;
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  return is;
}

ll MOD=1000000007;
ll ans=1;
int K;
const int MAXN = 100001;
vector<int> G[MAXN]; //ノードにつながる辺の集合、どこのnode(int)につながっているか
int depth[MAXN]; //ノードの深さ(スタートからの距離),行ったことあるなら正,ないなら-1
int setsu[MAXN];

ll bfs(int s, int g) {
    fill(depth, depth+MAXN, -1);
    deque<int> dq; //探索予定地
    //set<int> st;//探索終了地 setを使わなくてもdepthで足りてる気がする
    dq.push_back(s); // 始点を探索予定地に
    depth[s]=0; // 始点の深さを0に
    setsu[s]=0;
    while(!dq.empty()) {
        int v = dq.front();
    //    st.insert(v); //vを探索終了地に
        dq.pop_front(); //左から出す
        for(int i = 0; i < (int)G[v].size(); ++i) {
            int e = G[v][i];//行き先
            if(depth[e]==-1) {
              depth[e]=depth[v]+1;
              setsu[e]=1;
              setsu[v]=setsu[v]+1;
              ans=(ans*(K-setsu[v]))%MOD;
              dq.emplace_back(e);
            }
        }
    }
    return ans;
}
int main() {
    int N;
    cin>>N>>K;
    for (int i = 0; i < N-1; i++) {
        int a,b; cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    ans=K;
    std::cout <<bfs(1,1)<<endl; // 始点 s から g への最短距離を計算
    return 0;
}


Measured memory_bytes: 7288
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
  
using namespace std;
  
int f[300000];
  
int cast(int n)
{
  if(f[n] != -1)
  return f[n];

 
  for(int i = 2;i <= n/i;i++)
  {
    if(n / i == (double)(n) / (double)(i))
    {
       f[n] = 0;
       return 0;
    }
  }
 
  f[n] = 1;
  return 1;
}
  
  
  
int main()
{
  
  int n;
  memset(f,-1,300000 * sizeof(int));

  while(cin >> n && n)
  {
    int sum = 0;
    for(int i = n+1;i <= 2*n;i++)
    {
       sum += cast(i);
    }    
  
    cout << sum << endl;
  }
  
  
  return 0;
}

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

using namespace std;

int main() {
  long long A, B, C, K;
  
  cin >> A >> B >> C >> K;
  
  if (A >= K) {
    cout << K << endl;
    return 0;
  }
  
  K -= A + B;
  
  if (K >= 0) {
    cout << A - K << endl;
    return 0;
  }
  
  return 0;
}

Measured memory_bytes: 3596
import numpy as np
import sys
import itertools

def read_data():
    try:
        LOCAL_FLAG
        import codecs
        import os

        lines = []
        file_path = os.path.join(os.path.dirname(__file__), 'data073.dat')
        with codecs.open(file_path, 'r', 'utf-8') as f:
            lines.append(f.readline().rstrip("\r\n"))
            N, M, R = list(map(int, lines[0].split()))
            for i in range(M+1):
                lines.append(f.readline().rstrip("\r\n"))


    except NameError:
        lines = []
        lines.append(input())
        N, M, R = list(map(int, lines[0].split()))
        for i in range(M+1):
            lines.append(input())

    return lines

def dis(D, town_list):
    total = 0
    for i in range(len(town_list)-1):
        total += D[town_list[i]][town_list[i+1]]
    return total


def Travel():

    raw_data = read_data()
    N, M, R = list(map(int, raw_data[0].split()))
    town_list = list(map(int, raw_data[1].split()))
    road_set = set([])

    MAX = 200000
    # D = np.zeros((N+1, N+1), dtype='int32')
    # D += MAX
    D = [[float('inf')]*(N+1) for _ in range(N+1)]


    for i in range(2, M+2):
        a, b, c = list(map(int, raw_data[i].split()))
        D[a][b] = c
        D[b][a] = c

    # for i in range(1, N+1):
    #     for j in range(1, N+1):
    #         dis_two_node = np.min(D[i] + D[j])
    #         if dis_two_node < D[i,j]:
    #             D[i,j] = dis_two_node
    #             D[j,i] = dis_two_node

    # for i in range(N+1):
    #     D[i][i] = 0

    for k in range(1, N+1):
        for i in range(1, N+1):
            for j in range(1, N+1):
                dis_two_node = D[i][k] + D[k][j]
                if dis_two_node < D[i][j]:
                    D[i][j] = dis_two_node
                    D[j][i] = dis_two_node

   
    min_dis = float('inf')
    for each in itertools.permutations(town_list):
        min_dis = min(dis(D, each), min_dis)

    print(min_dis)




Travel()


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

typedef long long ll;
const ll mod=1e9+7;
const ll N=1e5+1;
const double PI=acos(-1.0);

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int n;
	cin>>n;
	vector<int> a(n);
	map<int,ll> cnt;
	for(int i=0;i<n;i++){
		cin>>a[i];
		cnt[a[i]+i]++;
	}
	ll ans=0;
	for(int i=0;i<n;i++) ans+=cnt[i-a[i]];
	cout<<ans;
}


Measured memory_bytes: 26592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define s(x, n) memset(x, n, sizeof(x));
#define pb(x) push_back(x)
#define NIL -1
#define MAXN 11

void solve()
{
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n - 1; i++)
    {
        //cout << ""
        for (int j = 1; j * j <= i; j++)
        {
            if (i % j == 0)
            {
                //cout << i << " " << j << "\n";
                if (i / j == j)
                    ans++;
                else
                    ans += 2;
            }
        }
        // cout << "i= " << i << " " << ans << "\n";
    }
    cout << ans << "\n";
}
int main()
{
#ifdef WIN32
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

#ifndef WIN32
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#endif
    int t;
    t = 1;
    /// cin >> t;
    for (int I = 1; I <= t; I++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3644
package main
import(
  "fmt"
  "bufio"
  "os"
  "strconv"
  "math"
)
var sc=bufio.NewScanner(os.Stdin)
func nextInt() int{
  sc.Scan()
  i, e :=strconv.Atoi(sc.Text())
  if e!=nil{
    panic(e)
  }
  return i
}
func main(){
  var i int
  sc.Split(bufio.ScanWords)
  n:=nextInt()
  d:=nextInt()
  ans:=0
  x:=make([]int, n)
  y:=make([]int, n)
  for i=0;i<n;i++{
    x[i]=nextInt()
    y[i]=nextInt()
    if math.Sqrt(float64(x[i]*x[i]+y[i]*y[i]))<=float64(d){
      ans++
    }
  }
  fmt.Println(ans)
}


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

int main(){
    char str[105];
    int ans = 0;
    int n;
    scanf("%d",&n);
    n = 0;
    scanf("%s",str);
    for(int i=0;str[i];i++)
        ans = max(ans, n += (str[i]=='I'?1:-1));
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>

using namespace std;

int main() {
	int n;
	while (cin >> n, n) {
		vector<pair<double, string> > ans(n);
		for (int i = 0; i < n; ++i) {
			int P, A, B, C, D, E, F, S, M;
			cin >> ans[i].second >> P >> A >> B >> C >> D >> E >> F >> S >> M;
			ans[i].first = -(double)(S * F * M - P) / (A + B + C + (D + E) * M);
		}
		sort(ans.begin(), ans.end());
		for (auto a : ans) cout << a.second << endl;
		cout << "#" << endl;
	}

	return 0;
}


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

using namespace std;
typedef long long ll;


struct UnionFind {
  vector<ll> data;
  UnionFind(ll size) : data(size, -1) { }
  bool connect(ll x, ll y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool isSame(ll x, ll y) {
    return root(x) == root(y);
  }
  ll root(ll x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  ll size(ll x) {
    return -data[root(x)];
  }
};

ll A[100005],B[100005];

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	ll n,m;cin>>n>>m;
	for(ll i=0;i<m;i++){
		cin>>A[i]>>B[i];A[i]--,B[i]--;
	}
	UnionFind uf = UnionFind(n);
	vector<ll> ans;
	ll t=n*(n-1)/2;
	ans.push_back(t);
	for(ll i=m-1;i>=0;i--){
		auto a = A[i], b = B[i];
		if(!uf.isSame(a, b)){
			ll as = uf.size(a);
			ll bs = uf.size(b);
			t -= as * bs;
			uf.connect(a, b);
		}
		ans.push_back(t);
	}
	for(ll i=m-1;i>=0;i--){
		cout<<ans[i]<<endl;
	}
}


Measured memory_bytes: 6608
from bisect import bisect
from bisect import bisect_left

_ = input()
l = input()
l = sorted(list(map(int, l.split())))
count = 0

for i in range(len(l)):
	for j in range(i+1, len(l)):
		
		count += bisect_left(l,l[i]+l[j]) - (j+1)

print(count)


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

int w[100005],d[100005],z[100005];
int f(int x){ return d[x]==x?x:d[x]=f(d[x]); }

priority_queue<int,vector<int>,greater<int>> pq[100005];

int main(){
    int n,m; cin>>n>>m;
    for(int i=1;i<=n;++i)cin>>w[i];
    for(int i=1;i<=n;++i)d[i]=i;
    while(m--){
        int u,v; cin>>u>>v; ++u, ++v;
        d[f(u)]=f(v);
    }
    for(int i=1;i<=n;++i)pq[f(i)].push(w[i]);
    for(int i=1;i<=n;++i)z[i]=i;
    sort(z+1,z+1+n,[&](const int &a,const int &b){ return pq[a].size()>pq[b].size(); });
    long long ans=0;
    for(int x=2;x<=n;++x){
        int i=z[x];
        if(pq[i].size() && !pq[z[1]].size())exit((cout<<"Impossible"<<endl,0));
        if(pq[i].empty())continue;
        ans+=pq[i].top()+pq[z[1]].top();
        pq[i].pop(); pq[z[1]].pop();
        while(pq[i].size()){ pq[z[1]].push(pq[i].top()); pq[i].pop(); }
    }
    cout<<ans<<endl;
}


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

int counter[100001];
int main(){
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n, m;
    cin>>n>>m;

    long long int a[n+1];    
    priority_queue<long long int> que;

    for(int i = 1; i <= n;i++){
        cin>>a[i];
        que.push(a[i]);
    }

    while(m--){
        long long int x = que.top();
        que.pop();

        x = x / 2;
        que.push(x);
    }

    long long int sum = 0;

    while(!que.empty()){
        sum += que.top();
        que.pop();
    }

    cout<<sum;

}

Measured memory_bytes: 1912
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long int l,r;
  cin>>l>>r;
  r=min(r,l+2019);
  long int ans=1e9+2;
  for(long int i=l;i<r;i++)
  {
    for(long int j=i+1;j<=r;j++)
      ans=min(ans,(i*j)%2019);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline

mod=998244353

class BIT:
	def __init__(self,n):
		self.n=n
		self.buf=[0]*n
	
	def add(self,i,v):
		buf=self.buf
		while i<n:
			buf[i]+=v
			if buf[i]>=mod:
				buf[i]-=mod
			i+=(i+1)&(-i-1)
	
	def get(self,i):
		buf=self.buf
		res=0
		while i>=0:
			res+=buf[i]
			if res>=mod:
				res-=mod
			i-=(i+1)&(-i-1)
		return res
	
	def rng(self,b,e):
		res=self.get(e-1)-self.get(b)
		if res<0:
			res+=mod
		return res

n,k=map(int,readline().split())
p=list(map(int,readline().split()))
for i in range(n):
	p[i]-=1

ans=0

bit=BIT(n)
for i in range(n):
	ans+=i-bit.get(p[i])
	bit.add(p[i],1)

z=pow(2,mod-2,mod);
w=1
winv=1
rem=(k-1)*pow(k,mod-2,mod)%mod
reminv=pow(rem,mod-2,mod)

bit=BIT(n)
for i in range(n):
	lw=bit.get(p[i])
	up=bit.rng(p[i],n)
	dif=(lw-up+mod)%mod
	ans=(ans+dif*w*z)%mod
	bit.add(p[i],winv)
	if i>=k-1:
		w=w*rem%mod
		winv=winv*reminv%mod

print(ans)


Measured memory_bytes: 92480
n,m = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(n)]
cost = 0
temp = 0
s_AB = sorted(AB)
for ab in s_AB:
    cost += ab[0]*ab[1]
    temp += ab[1]
    if(temp > m):
        cost -= ab[0]*(temp - m)
        break
    elif(temp == m):
        break
print(cost)
    

Measured memory_bytes: 28652
#include<iostream>
using namespace std;
int main(){
  int candy,num;
  while(cin>>candy){
    if(candy%39!=0){
      num=candy%39;
    }if(candy%39==0){
      num=39;
    }
    if(num<10)cout<<"3C0"<<num<<endl;
    else{
    cout<<"3C"<<num<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1156
#[allow(unused_imports)]
use std::collections::HashSet;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let nx = read_vec::<usize>();
    let n = nx[0];
    let x = nx[1];
    let mut l = read_vec::<usize>();
    l.push(x);
    let answer = solve(n, x, &l);

    println!("{}", answer);
}

fn solve(n: usize, x:usize, l:&[usize]) -> usize {
    let mut pos = 0;
    let mut count = 0;
    for &a in l {
        if pos > x {
            return count;
        }
        pos += a;
        count += 1;
    }
    return count;
}


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

using namespace std;

int main() {
    int N;
    cin >> N;
    int a = (int)log10(N);
    int r = 0;
    if (a % 2 == 0) {
        r += N - (int)pow(10, a) + 1;
    }
    for (int i = 0; i < a; i += 2) {
        if (i == 0) r += 9;
        else r += (int)pow(10, i + 1) - (int)pow(10, i);
    }
    cout << r << endl;

    return 0;
}

Measured memory_bytes: 512
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

d_pls = []
d_mns = []
s = 0
for i in range(N):
    t = a[i] - b[i]
    s += t
    if t > 0:
        d_pls.append(t)
    elif t < 0:
        d_mns.append(t)
# 準備不足なら負

if s < 0:
    print(-1)
    exit()

d_pls = sorted(d_pls, reverse=True)

d_mns = sorted(d_mns)
m_sum = sum(d_mns)
ans = len(d_mns)

i = 0
while m_sum < 0:
    m_sum += d_pls[i]
    ans += 1
    i += 1
print(ans)


Measured memory_bytes: 18524
#include <iostream>
#include <algorithm>

using namespace std;

//n:候補者の人数,p:最初にお椀に入っている小石の数
int solve(int n,int p){
	int *pebbles = new int[n];//それぞれの候補者の持っている小石の数
	fill(pebbles,pebbles+n,0);
	int pos=n-1;//お椀の場所。スタートしたら0の人に渡す
	int inpebble = p;//お椀に入っている小石の数
	while(pebbles[pos] != p){
		pos= (pos+1)%n;
		if(inpebble==0){//お椀が空っぽ
			inpebble += pebbles[pos];
			pebbles[pos] = 0;
		}else{
			inpebble --;
			pebbles[pos]++;
		}
	}
	delete[] pebbles;
	return pos;
}

int main(){
	int n,p;
	while(true){
		cin >> n >> p;
		if(n==0 && p==0){
			break;
		}
		cout << solve(n,p) << endl;
	
	}

}

Measured memory_bytes: 1196
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;
const long long mod=1e9+7;
const long long INF=1LL<<60;

int main(){
   string s;
   cin>>s;
   int n=s.size();
   string k="keyence";
   string ans="NO";
   for(int i=0;i<n;i++){
       if(s[i]=='k'){
           for(int j=i;j<n;j++){
               if(s.substr(i,j)==k.substr(0,j-i)){
                   for(int l=j+1;l<n;l++){
                       if(s.substr(l,n-1)==k.substr(j-i+1,6))ans="YES";
                   }
               }
           }
       }
   }
   cout<<ans<<endl;
   
}

   


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

int main(){
  int n;
  cin >> n;
  int check = 1;
  for (int i = 1; i <= 50000; i++){
    if((i * 108)/100 == n){
      cout << i << endl;
      check = 0;
    }
  }
  if(check > 0) cout << ":(" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const LL MAX = 1e9;
const int SIZE = 410;
LL an;
int d[SIZE][4];
LL val[SIZE];
map<LL,int>H,C;
void ADD(LL& x,LL v){
    x=(x+v);
}
LL fix(LL x){
    LL xx=x;
    int cnt=1;
    LL mi=x;
    REP(k,3){
        LL tmp=x/MAX;
        x=(x-tmp*MAX)*1000+tmp;
        mi=min(mi,x);
        if(x==xx)cnt++;
    }
    C[mi]=cnt;
    return mi;
}
int main(){
    DRI(N);
    REP(i,N){
        //printf("%d:%lld\n",i,an);
        REP(j,4)
            RI(d[i][j]);
        REP(j,i){
            H[val[j]]--;
            REP(r,4){
                map<LL,int>shik;
                REP(k,4){
                    LL v=0;
                    v=v*1000+d[j][(r-k+4)&3];
                    v=v*1000+d[j][(r-k+3)&3];
                    v=v*1000+d[i][(k+1)&3];
                    v=v*1000+d[i][k&3];
                    shik[fix(v)]++;
                }
                LL my_v=1;
                for(map<LL,int>::iterator it=shik.begin();it!=shik.end();it++){
                    if(H.count(it->F)){
                        LL nn=H[it->F];
                        REP(ker,it->S){
                            my_v=my_v*nn;
                            nn--;
                            my_v=my_v*C[it->F];
                        }
                    }
                    else my_v=0;
                }
                ADD(an,my_v);
            }
            H[val[j]]++;
        }
        {
            LL v=0;
            REP(k,4)
                v=v*1000+d[i][k];
            val[i]=fix(v);
            H[val[i]]++;
        }
    }
    cout<<an<<endl;
    return 0;
}

Measured memory_bytes: 80128
#include <iostream>
 
using namespace std;
 
int main()
{
  int n, x;
  cin >> n >> x;
  int sum = 0;
  int count = 1;
  for(int i = 0; i < n; i++)
  {
    int temp;
    cin >> temp;
    sum += temp;
    if(sum > x)
    {
      break;
    }
    count++;
  }
  cout << count;
 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
main(){
    fastio;
    string s;
	cin >> s;
	if(s[0] == s[1] || s[1]==s[2] || s[2]==s[3]){
		cout << "Bad\n";
	}
	else cout << "Good\n";
    
}


Measured memory_bytes: 256
def calc(n,x):
  ans=0
  while 1:
    if x==1:
      break
    elif 2<=x<=lb[n-1]:
      x-=1
      n-=1
    elif x==1+lb[n-1]:
      ans+=pb[n-1]
      break
    elif x==2+lb[n-1]:
      ans+=1+pb[n-1]
      break
    elif 3+lb[n-1]<=x<=1+2*lb[n-1]:
      ans+=1+pb[n-1]
      x-=2+lb[n-1]
      n-=1
    elif x==2+2*lb[n-1]:
      ans+=1+2*pb[n-1]
      break
    elif x==3+2*lb[n-1]:
      ans+=1+2*pb[n-1]
      break
  return ans

n,x=map(int,input().split())
lb=[1]
pb=[1]
for i in range(1,51):
  lb.append(lb[i-1]*2+3)
for i in range(1,51):
  pb.append(pb[i-1]*2+1)
print(calc(n,x))

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n;
	scanf("%d", &n);
	vi a(n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);

	int last = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == last + 1) ++last;
	}

	int ans = last? n - last : -1;
	printf("%d\n", ans);
}


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

al = [a/i for i in range(1,a+1) if a%i ==0]
bl = [b/i for i in range(1,b+1) if b%i ==0]

cd = sorted(list(set(al) & set(bl)))

print(int(cd[-k]))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

int main(){
  ll H,W; cin>>H>>W;
  if(H==1||W==1){
    cout<<1<<endl;
    return 0;
  }
  ll ans=0;
  if(H%2&&W%2){
    ans=(W/2+1)*(H/2+1)+(W/2)*(H/2);
  }else{
    ans=H*W/2;
  }
  cout<<ans<<endl;
  return 0;
}

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

typedef long long ll;

int main() {
    ll N, M, X, ans = 1e18;
    cin >> N >> M >> X;
    vector<ll> C(N);
    vector<vector<ll>> A(N, vector<ll>(M));
    rep(i, N) {
        cin >> C[i];
        rep(j, M) {
            cin >> A[i][j];
        }
    }
    rep(i, 1 << N) {
        vector<ll> B(M, 0);
        ll T = 0;
        rep(j, N) {
            if ((i >> j) & 1) continue;
            T += C[j];
            rep(k, M) {
                B[k] += A[j][k];
            }
        }
        bool f = true;
        rep(j, M) {
            if (B[j] < X) f = false;
        }
        if (f) {
            ans = min(ans, T);
        }
    }
    if (ans == 1e18) ans = -1;
    cout << ans << "\n";
}

Measured memory_bytes: 3628
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val Array(x, y) = sc.nextLine.split(" ").map(_.toInt)
    val groupOne = Array(1, 3, 5, 7, 8, 10, 12)
    val groupTwo = Array(4, 6, 9, 11)
    if ((groupOne.contains(x) & groupOne.contains(y)) | (groupTwo.contains(x) & groupTwo.contains(y))) println("Yes")
    else println("No")
  }
}


Measured memory_bytes: 25648
#include <stdio.h>
int main(void){
    // Your code here!
    int W,H,x,y,r;
    scanf("%d %d %d %d %d", &W,&H,&x, &y, &r);
    
    if(x-r<0 || x+r>W || y-r<0 || y+r>H)printf("No\n");
    
    if(x-r>=0 && x+r <=W && y-r>=0 && y+r<=H)printf("Yes\n");
    
}




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

int main() {
  int N, A, N500;
  cin >> N >> A;
  
  N500 = N % 500;
  
  if(N500 <= A){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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;i>=0;i--)
#define MAX 3004
#define B 100
#define dpb push_back
#define fi first
#define se second
typedef pair<int, int> P;
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e18;
//__gcd(a,b), __builtin_popcount(a);

int sum = 0, ans = 0, ky, kx, a[12][12], f[12][12];
int dy[4] = {0, 0, -1, 1}, dx[4] = {-1, 1, 0, 0};

void dfs(int y, int x, int cnt){
	for(int i = 0;i < 4;i++){
		int yy = y;
		int xx = x;
		while(1){
			yy += dy[i];
			xx += dx[i];
			if(a[yy][xx] == -1)break;
			if(a[yy][xx] == 1 && f[yy][xx] == 0){
				f[yy][xx] = 1;
				dfs(yy, xx, cnt+1);
				f[yy][xx] = 0;
				break;
			}
			if(a[yy][xx] == 2 && cnt == sum){
				ans++;
				break;
			}
		}
	}
}

int main(){
	int w, h;
	while(1){
		scanf("%d%d",&w, &h);
		if(w == 0)break;
		fill((int*)a, (int*)(a+12), -1);
		fill((int*)f, (int*)(f+12), 0);
		sum = ans = 0;
		rrep(i,h)rrep(j,w){
			scanf("%d", &a[i][j]);
			if(a[i][j] == 2){ky = i;kx = j;}
			if(a[i][j] == 1)sum++;
		}
		
		dfs(ky, kx, 0);
		printf("%d\n", ans);
	}
	return 0;
}



Measured memory_bytes: 3136
while true
    l = gets.to_i
    break if l == 0
    sum, count = 0, "NA"
    12.times{|i|
        m, n = gets.chomp.split.map(&:to_i)
        sum += m - n
        count = i + 1 if sum >= l && count == "NA"
    }
    puts count
end


Measured memory_bytes: 6868
#include <stdio.h>
 
int main()
{
    int n, a, b, c, d, ma, mb;
 
    scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
    ma = ((n-1)/a+1)*b;
    mb = ((n-1)/c+1)*d;
    if (ma > mb) ma = mb;
    printf("%d\n", ma);
    return 0;
}


Measured memory_bytes: 1928
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define END << endl;
#define SP << " " << 
using namespace std;

int main(){
	int r,w,c,R;
	cin >> r>>w>>c>>R;
	while(r!=0||w!=0||c!=0||R!=0){
		if(c*w-r >0){cout << ceil((double)(c*w-r)/R) END}
		else{cout << 0 END}
		cin >> r >> w>> c >> R;
	}
	return 0;
}


Measured memory_bytes: 3184
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.Stack;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        List<Long> res = new ArrayList<>();
        long depth = 0;
        int last = 0;
        long tmp = 0;
        long sum = 0;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == '/') {
                if (depth > 0) {
                    depth--;
                }
                tmp += depth;
                if (depth == 0 && tmp != 0) {
                    last = i;
                    sum += tmp;
                    res.add(tmp);
                    tmp = 0;
                }
            } else if (c == '_') {
                tmp += depth;
            } else { // '\'
                depth++;
                tmp += depth;
            }
        }
        depth = 0;
        tmp = 0;
        Stack<Long> stack = new Stack<>();
        for (int i = s.length() - 1; i > last; i--) {
            char c = s.charAt(i);
            if (c == '/') {
                depth++;
                tmp += depth;
            } else if (c == '_') {
                tmp += depth;
            } else { // '\'
                if (depth > 0) {
                    depth--;
                }
                tmp += depth;
                if (depth == 0 && tmp != 0) {
                    sum += tmp;
                    stack.push(tmp);
                    tmp = 0;
                }
            }
        }
        while (!stack.isEmpty()) {
            res.add(stack.pop());
        }
        System.out.println(sum);
        System.out.print(res.size());
        printList(res);
        System.out.println();
    }

    private static <T> void printList(List<T> list) {
        if (list.isEmpty()) {
            return;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < list.size(); i++) {
            sb.append(" ");
            sb.append(list.get(i));
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 29088
#include<stdio.h>
int main(){
  int maxv,min,n,ans;
  scanf("%d",&n);
  if(n<2||n>2000001)return 0;
  int i,a;
  for(i=0;i<n;i++){
    scanf("%d",&a);
    if(a<0||a>1000000001)return 0;
    if(i==1)maxv=a-min;
    if(i==0){min=a;
      continue;
    }
    if(a-min>maxv)maxv=a-min;
    if(a<min)min=a;
  }
      printf("%d\n",maxv);
  return 0;
}



Measured memory_bytes: 2140
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin>>n;
    bool b[300010];
    vll v,ans(n);
    rep2(i,1,30001){
        if(i%2==0||i%3==0){
            v.push_back(i);
        }
    }
    if(n==3){
        cout<<"2 5 63"<<endl;
        return 0;
    }
    ll cnt=0;
    rep(i,n-2){
        ans[i]=v[i];
        b[v[i]]=true;
        cnt+=v[i];
    }
    rep2(i,n-2,v.size()){
        if(cnt%2==0){
            if(v[i]%2==0){
                ans[n-2]=v[i];
                b[v[i]]=true;
                cnt+=v[i];
                break;
            }
        } else{
            if(v[i]%2==1){
                ans[n-2]=v[i];
                b[v[i]]=true;
                cnt+=v[i];
                break;
            }
        }
    }
    for(ll i:v){
        if(b[i]||i%2==1)continue;
        if(cnt%3==0){
            if(i%3==0){
                ans[n-1]=i;
                break;
            }
        }
        else if(cnt%3==1){
            if(i%3==2){
                ans[n-1]=i;
                break;
            }
        }
        else if(cnt%3==2){
            if(i%3==1){
                ans[n-1]=i;
                break;
            }
        }
    }
    rep(i,n){
        cout<<ans[i];
        if(i!=n-1) cout<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 892
fun main(args: Array<String>){
    val N = "0"+readLine()!!
    val K = readLine()!!.toInt()
    val dp = Array(N.length+1){ Array(2){ LongArray(K+2) } }

    dp[0][0][0] = 1L

    for(i in 1 until N.length){
        for(k in 0..K){
            //遷移元が最大値の場合を先にやる
            if(N[i] != '0'){
                dp[i][0][k+1] += dp[i-1][0][k] //最大値を追加 遷移先も最大値
                dp[i][1][k] += dp[i-1][0][k] //0を追加 遷移先はもう最大値ではない
                dp[i][1][k+1] += dp[i-1][0][k] * (N[i].toString().toInt() - 1) //1から最大値未満を追加 遷移先はもう最大値ではない
            }else{
                dp[i][0][k] += dp[i-1][0][k] //0しか追加できない 遷移先も最大値
            }
            //遷移元が最大値でないので遷移先も最大値ではない
            dp[i][1][k] += dp[i-1][1][k] //0を追加
            dp[i][1][k+1] += dp[i-1][1][k] * 9 //0以外を追加
        }
    }
    println(dp[N.length - 1][1][K] + dp[N.length - 1][0][K]) //答えは最大値の場合と最大値でない場合を足す
}

Measured memory_bytes: 33708
#include <iostream>
#include <vector>
#include <cstdlib>

using namespace std;

int K, N;
long long x[50], y[50];
long long rect_min;

void ysearch(long long x_low, long long x_high) {
  int cnt;
  long long rect, y_low, y_high;

  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      cnt = 0;
      if (y[i] < y[j]) {
        y_low = y[i];
        y_high = y[j];
      } else {
        y_low = y[j];
        y_high = y[i];
      }

      for (int n = 0; n < N; n++) {
        if (x[n] >= x_low && x[n] <= x_high && y[n] >= y_low && y[n] <= y_high) {
          cnt++;
        }
      }
      if (cnt >= K) {
        rect = (x_high - x_low) * (y_high - y_low);
        if (rect_min == -1 || rect < rect_min) {
          rect_min = rect;
        }
      }
    }
  }
}

void xsearch() {
  int cnt;
  long long x_low, x_high;

  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      cnt = 0;
      if (x[i] < x[j]) {
        x_low = x[i];
        x_high = x[j];
      } else {
        x_low = x[j];
        x_high = x[i];
      }
      for (int n = 0; n < N; n++) {
        if (x[n] >= x_low && x[n] <= x_high) {
          cnt++;
        }
      }
      if (cnt >= K) {
        ysearch(x_low, x_high);
      }
    }
  }
}

int main() {
  scanf("%d %d", &N, &K);
  for (int i = 0; i < N; i++) {
    scanf("%lld %lld", x + i, y + i);
  }
  rect_min = -1;
  
  xsearch();
  printf("%lld\n", rect_min);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll;
const int mxN=1e5;
const ll mod = 1e9+7;

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

    vector<int> v(n);

    for(int i=0;i<n;i++) cin>>v[i];

    vector<int> dp(n);
    dp[0]=0;
    dp[1]=abs(v[1]-v[0]);

    for(int i=2;i<n;i++){
        dp[i] = min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
    }

    cout<<dp[n-1];
}

Measured memory_bytes: 3980
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        // 入力
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        int max = b/a;

        if (max > c) System.out.println(c);
        else System.out.println(max);
    }
}

Measured memory_bytes: 22740
package main

import "fmt"

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

	p := make([]int, n)
	for i := range p {
		fmt.Scan(&p[i])
	}

	ans := 0
	for i := 1; i < n-1; i++ {
		switch {
		case p[i-1] == p[i] && p[i] == p[i+1]:
			continue
		case p[i] > p[i-1] && p[i] > p[i+1]:
			continue
		case p[i] < p[i-1] && p[i] < p[i+1]:
			continue
		}
		ans++
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<stdio.h>

#define N 100
#define W 0
#define G 1
#define B 2

int n, M[N][N];
int color[N],d[N],f[N],tt;

void dfs_visit(int u){
  int v;

  color[u] = G;
  d[u] = ++tt;
  for(v=0;v<n;v++){
    if(M[u][v] == 0)continue;
    if(color[v] == W){
      dfs_visit(v);
    }
  }
  color[u] = B;
  f[u] = ++tt;
}

void dfs(){
  int u;

  for(u=0;u<n;u++){
    if(color[u] == W)dfs_visit(u);
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}

int main(){
  int u,v,k,i,j;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++)M[i][j]=0;
  }
  
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  dfs();

  return 0;
}
    



Measured memory_bytes: 2112
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int L = stdIn.nextInt();
		String[] S = new String[N];
		for(int i = 0; i < N; i++) {
			S[i] = stdIn.next();
		}
		
		Arrays.sort(S);
		for(int i = 0; i < N; i++) {
			System.out.print(S[i]);
		}
		System.out.println();

	}

}

Measured memory_bytes: 21844
#include<stdio.h>

int main()
{
    int n,m,i,num,ans=0;
	int sosu[25]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
	int sosunum[25]={0};//n!までに2,3,5,...が何個あるか
	int over[5]={0};//over2,4,14,24,74
	scanf("%d",&n);
	for(i=0;i<25;i++)
	{
		num=n;
		while(num!=0)
		{
			num/=sosu[i];
			sosunum[i]+=num;
		}
		if(sosunum[i]>=2)over[0]++;
		if(sosunum[i]>=4)over[1]++;
		if(sosunum[i]>=14)over[2]++;
		if(sosunum[i]>=24)over[3]++;
		if(sosunum[i]>=74)over[4]++;
	}
	//printf("%d,%d,%d,%d,%d\n",over[0],over[1],over[2],over[3],over[4]);
	
	ans+=over[4];//75
	ans+=(over[0]*over[3]-over[3]);//3*25
	ans+=(over[1]*over[2]-over[2]);//5*15
	ans+=((over[0]-over[1])*(over[1]*(over[1]-1)/2));
	ans+=((over[1])*((over[1]-1)*(over[1]-2)/2));//3*5*5
	
	
	printf("%d\n",ans);
}

Measured memory_bytes: 128
H_1,M_1,H_2,M_2,K = map(int,input().split())
if H_2-H_1<0:
    print((H_2-H_1+24)*60+M_2-M_1-K)
else:
    print(H_2*60+M_2-H_1*60-M_1-K)


Measured memory_bytes: 9152