akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int[] an = in.nextIntArray(n);

			int q = (int)Math.pow(10, 8)+1;
			boolean[] primes = MathUtils.isPrime(q);

			int count = 0;
			for (int i : an) {
				if (primes[i]) {
					count++;
				}
			}
			out.println(count);
		}

	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}
	}

	static class MathUtils {
		public static boolean[] isPrime(int q) {;
			boolean[] primes = new boolean[q];
			Arrays.fill(primes, true);
			primes[0] = primes[1] = false;

			for (int i = 2; i < Math.sqrt(q); i++) {
				if (primes[i]) {
					for (int j = 2*i; j < q; j = j + i) {
						primes[j] = false;
					}
				}
			}
			return primes;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}



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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

int partition(vi& A, const int p, const int r) {
    int x = A[r];
    int i = p - 1;

    rep(j, p, r) {
        if (A[j] <= x) {
            ++i;
            swap(A[i], A[j]);
        }
    }
    swap(A[i + 1], A[r]);
    return i + 1;
}

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

    vi A(n);
    rep(i, 0, n) { cin >> A[i]; }

    int q = partition(A, 0, n - 1);
    rep(i, 0, n) {
        if (i == q) { cout << "["; }
        cout << A[i];
        if (i == q) { cout << "]"; }

        if (i != n - 1) { cout << " "; }
        else { cout << endl; }
    }

    return 0;
}


Measured memory_bytes: 3136
macro_rules! input { (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
    }
    let MOD = 1_000_000_007;
    let mut p = 1;
    for i in 0..n {
        p *= i + 1;
        p %= MOD;
    }
    println!("{}", p);
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
const int INF = 0x3f3f3f3f;
#define int long long

const double EPS = 1e-9;

double bisectionMethod(double l, double r, function<double(double)> f) {
	double yl = f(l), yr = f(r);
	if (yl > yr)swap(l, r);
	assert((yl - EPS) * (yr + EPS) <= 0);
	for (int i = 0; i < 200; i++) {
		double m = (l + r) / 2;
		if (f(m) > 0)
			r = m;
		else
			l = m;
	}
	return l;
}

signed main() {
	cout << fixed << setprecision(10);
	for (int n; cin >> n && n;) {

		vector<double> px(n), py(n), pz(n)
			, vx(n), vy(n), vz(n)
			, r(n), vr(n);
		rep(i, 0, n) {
			cin >> px[i] >> py[i] >> pz[i] >> vx[i] >> vy[i] >> vz[i] >> r[i] >> vr[i];
		}

		auto cx = [&](double i, double t) {
			return px[i] + vx[i] * t;
		};
		auto cy = [&](double i, double t) {
			return py[i] + vy[i] * t;
		};
		auto cz = [&](double i, double t) {
			return pz[i] + vz[i] * t;
		};
		auto cr = [&](double i, double t) {
			return r[i] - vr[i] * t;
		};

		vector<tuple<double, int, int>> v;

		rep(i, 0, n)rep(j, i + 1, n) {
			auto d = [&](double t) {
				double x = (cx(i, t) - cx(j, t)) * (cx(i, t) - cx(j, t));
				double y = (cy(i, t) - cy(j, t)) * (cy(i, t) - cy(j, t));
				double z = (cz(i, t) - cz(j, t)) * (cz(i, t) - cz(j, t));
				return sqrt(x + y + z);
			};
			auto f = [&](double t) {
				return d(t) - cr(i, t) - cr(j, t);
			};

			double t1, t2;

			auto ternarySearch = [&](double l, double r) {
				for (int i = 0; i < 200; i++) {
					double m1 = l + (r - l) / 3, m2 = r - (r - l) / 3;
					if (f(m1) > f(m2)) {
						l = m1;
					}
					else {
						r = m2;
					}
				}
				return r;
			};

			t2 = min(r[i] / vr[i], r[j] / vr[j]);
			t1 = ternarySearch(0, t2);

			if (f(0) + EPS > 0 && f(t1) + EPS > 0)continue;

			double t = bisectionMethod(0, t1, f);

			v.emplace_back(t, i, j);

		}

		rep(i, 0, n) {
			v.emplace_back(r[i] / vr[i], i, -1);
		}

		sort(v.begin(), v.end());

		vector<double> ans(n, -1);

		for (auto u : v) {
			double t; int p, q;
			tie(t, p, q) = u;
			if (q == -1) {
				if (ans[p] != -1)continue;
				ans[p] = t;
			}
			else {
				if (ans[p] != -1 || ans[q] != -1)continue;
				ans[p] = ans[q] = t;
			}
		}

		rep(i, 0, n) {
			cout << ans[i] << endl;
		}
	}
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//get the biggest element.
template<typename KeyType, typename ValueType>
std::pair<KeyType,ValueType> get_max( const std::map<KeyType,ValueType>& x ) {
  using pairtype=std::pair<KeyType,ValueType>;
  return *std::max_element(x.begin(), x.end(), [] (const pairtype & p1, const pairtype & p2) {
        return p1.second < p2.second;
  });
}
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;

int main() {
  ll l, r;
  cin >> l >> r;
  ll ans = INF;
  vector<ll> a;

  int pl = l;
  while (l <= r && l <= (pl + 2019)) a.push_back(l++); 

  for (int i = 0; i < a.size() - 1; i++) {
    for (int j = i + 1; j < a.size(); j++) {
      ans = min(ans, a[i] * a[j] % 2019);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3660
// problem: "https://atcoder.jp/contests/abc143/tasks/abc143_b"

#include<bits/stdc++.h>

using namespace std;

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

    int i,x;
    vector<int>V;

    for(i=0;i!=n;i++)
    {
        cin>>x;
        V.push_back(x);
    }

    int s,S;

    s = S = 0;
    for(i=0;i!=n;i++)
    {
        s += V[i];
        S += V[i]*V[i];
    }

    cout<<(s*s-S)/2;

    return 0;
}


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

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

  int counter = 0;

  for(int i = A; i <= B; i++){
    
    vector<int> N(5);
    int n = i;
    
    for(int j = 0; j < 5; j++){
      N.at(4 - j) = n % 10; 
      n /= 10;
    }
    
    if(N.at(0) == N.at(4) && N.at(1) == N.at(3)){
      counter++;
    }
  }
  
  cout << counter << endl;
  
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#define INF (1LL<<50LL)

typedef long long ll;

using namespace std;

ll n;
ll a,b;

int main() {
	cin >> n >> a >> b;
	vector<ll> arr(5001);
	vector<ll> dp(5001);
	for(int i = 0; i < n; i++) {
		int p;
		cin >> p;
		arr[p] = i+1;
	}
	for(int num = 1; num <= n; num++) {
		int pos = arr[num];
		ll temp_min = INF;
		for(int i = 0; i <= n; i++) {
			temp_min = min(temp_min,dp[i]);
			if(pos>i) {
				dp[i] = temp_min+b;
			}
			if(pos==i) {
				dp[i] = temp_min;
			}
			if(pos<i) {
				dp[i] = temp_min+a;
			}
			//cout << dp[i] << endl;
		}
		//cout << "-----" << endl;
	}
	ll ans = INF;
	for(int i = 0; i <= n; i++) {
		ans = min(ans,dp[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
n,q = [int(s) for s in input().split()]
queue = []
for i in range(n):
	name,time = input().split()
	queue.append([name,int(time)])

time = 0
while queue:
	processing = queue.pop(0)
	t = min(processing[1], q)
	time += t
	processing[1] -= t
	if processing[1] == 0:
		print(processing[0],time)
	else:
		queue.append(processing)

Measured memory_bytes: 15856
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
  int n, k;
  cin >> n >> k;
  double max, p[n], psum[n]={0};
  for(int i=0; i<n; i++){
    double pi;
    cin >> pi;
    p[i]=(1.0+pi)/2.0;
  }
  for(int i=0; i<k; i++){
    psum[0]+=p[i];
  }
  max=psum[0];
  for(int i=1; i<n-k+1; i++){
    psum[i]=psum[i-1]-p[i-1]+p[i+k-1];
    if(psum[i]>max) max=psum[i];
  }
  cout << setprecision(10) << max;
  return 0;
}


Measured memory_bytes: 3328
N, M = map(int, input().split())
a_lis = [int(input()) for _ in range(M)]
a_lis.insert(0, -1) # size: M+1
a_lis.append(N+1) # size: M+2

dif = [a_lis[j+1]-a_lis[j]-2 for j in range(M+1)]
fib_lis = []

def fib(n):
  for k in range(n+1):
    if k==0 or k==1:
      fib_lis.append(1)
    else:
      fib_lis.append(fib_lis[k-2]+fib_lis[k-1])

  return fib_lis[-1]

max_ = max(dif)
fib(max_)
  
t = 1

for d in dif:
  if d < 0:
    t *= 0
  else:
    t *= fib_lis[d]
  t = t % 1000000007
  
print(t)


  
    

Measured memory_bytes: 460020
// C - Traveling Salesman around Lake
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(int)(n); i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main(){
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ma = 0;
    for(int i=0; i<n-1; i++){
        ma = max(abs(a[i]-a[i+1]), ma);
    }
    if(a[0] == 0) ma = max(k-a[n-1], ma);
    else ma = max(a[0]+(k-a[n-1]), ma);
    int ans = k-ma;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
auto fl = [](auto a, auto b) { assert(b != 0); return a / b - (a % b != 0 && ((a >= 0) != (b >= 0)) ? 1 : 0); };
auto ce = [](auto a, auto b) { assert(b != 0); return a / b + (a % b != 0 && ((a >= 0) == (b >= 0)) ? 1 : 0); };
auto mo = [](auto a, auto b) { assert(b != 0); a %= b; if(a < 0) { a += abs(b); } return a; };
LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	LL a, b;
	cin >> a >> b;
	
	cout << lcm(a, b) << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<map>
using namespace std;
typedef long long int lli;
typedef long long ll;
#define mod 10000000007
int main()
{
  ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
  lli n;
  cin>>n;
  if(n%1000==0)
    cout<<0<<"\n";
  else
  {
    lli i=((n/1000)+1);
    cout<<((i*1000)-n)<<"\n";
  }
}

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

//#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;

Node root;

/*preorder関数*/
void preorder(Node u)
{
  if(u != NULL){
    printf(" %d", (*u).key);
    preorder((*u).left);
    preorder((*u).right);
  }
}

/*treeMinimum関数*/
Node treeMinimum(Node x)
{
  while((*x).left != NULL)
    x = (*x).left;
  return x;
}

/*treeSearch関数*/
Node treeSearch(Node u, int k)
{
  if(u == NULL && k == (*u).key)
    return u;
  else if(k < (*u).key)
    return treeSearch((*u).left, k);
  else
    return treeSearch((*u).right, k);
}

/*treeSuccessor関数*/
Node treeSuccessor(Node x)
{
  Node y;
  if((*x).right != NULL)
    return treeMinimum((*x).right);
  y = (*x).parent;
  while(y != NULL && x == (*y).right){
    x = y;
    y = (*y).parent;
  }
  return y;
}

/*inorder関数*/
void inorder(Node u)
{
  if(u != NULL){
    inorder((*u).left);
    printf(" %d", (*u).key);
    inorder((*u).right);
  }
}

/*treeDelete関数*/
void treeDelete(Node z)
{
  Node y; // node to be deleted
  Node x; // child of y

  if((*z).left == NULL || (*z).right == NULL)
    y = z;
  else
    x = (*y).right;
  if(x != NULL)
    (*x).parent = (*y).parent;
  if((*y).parent == NULL)
    root = x;
  else if(y == (*y).parent->left)
    (*y).parent->left = x;
  else
    (*y).parent->right = x;
  if(y != z)
    (*z).key = (*y).key;
}

/*treeMaximum関数*/
Node treeMaximum(Node x)
{
  while((*x).right != NULL)
    x = (*x).right;
  return x;
}

/*insert関数*/
void insert(int k)
{
  Node y = NULL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  (*z).key = k;
  (*z).left = NULL;
  (*z).right = NULL;

  while(x != NULL){
    y = x;
    if((*z).key < (*x).key)
      x = (*x).left;
    else
      x = (*x).right;
  }
  (*z).parent = y;
  if(y == NULL)
    root = z;
  else if((*z).key < (*y).key)
    (*y).left = z;
  else
    (*y).right = z;
}

/*ここからがmain関数*/
int main()
{
  int n, count, w;
  char com[30];
  
  scanf("%d", &n);

  for(count = 0; count < n; count++){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &w);
      
      Node t = treeSearch(root, w);
      
      if(t != NULL)
	printf("yes\n");
      else
	printf("no\n");
    } else if(com[0] == 'i'){
      scanf("%d", &w);
      insert(w);
    } else if(com[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if (com[0] == 'd'){
      scanf("%d", &w);
      treeDelete(treeSearch(root, w));
    }
  }
  return 0;
}



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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> food(M);
  vector<vector<int> > like(N, vector<int>(0));
  for(int i=0;i<N;i++) {
    int K;
    cin >> K;
    for(int j=0;j<K;j++) {
      int f;
      cin >> f;
      food[f-1]++;
    }
  }

  int ans = 0;

  for(int i=0;i<M;i++) {
    if(food[i] == N) {
      ans++;
    }
  }
  cout << ans << endl;

  return 0;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a, b, c, d, e, f;
    double x, y;

    while (~scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f)) {
        x = (b * f - c * e) / (double)(b * d - a * e);
        y = (a * f - d * c) / (double)(a * e - b * d);

        printf("%.3f %.3f\n", x + 0, y + 0);
    }

    return 0;
}

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

#define MOD 1000000007
#define f first
#define s second
#define es " "
#define pb push_back
#define endl "\n"
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define ll long long int
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

char matriz[1005][1005];
int n, m;

ll dp[1005][1005];

int solve(int x, int y){
    if(dp[x][y]!=-1){
        return dp[x][y];
    }
    if(x>n || y>m || matriz[x][y]=='#'){
        return dp[x][y]=0;
    }
    if(x==n && y==m){
        return dp[x][y]=1;
    }
    dp[x][y]=solve(x+1, y)+solve(x, y+1);
    return dp[x][y]%=MOD;
}

int main(){
    fastio;
    memset(dp, -1, sizeof(dp));
    cin >> n >> m;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            cin >> matriz[i][j];
        }
    }
    cout << solve(1, 1) << endl;
    return 0;
}

Measured memory_bytes: 12640
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <random>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

const Int alp = 26;

Int compute_score(Int &D, vector<vector<Int>> &s, vector<Int> &c, vector<Int> &out) {
    Int score = 0;
    vector<Int> last(alp, 0);

    Int count = out.size();
    for (Int d = 0; d < count; d++) {
        last[out[d]] = d + 1;

        for (Int i = 0; i < alp; i++) {
            score -= (d + 1 - last[i]) * c[i];
        }
        score += s[d][out[d]];
    }

    return score;
}

Int evaluate(Int &D, vector<vector<Int>> &s, vector<Int> &c, vector<Int> &out, Int &k) {
    Int score = 0;
    vector<Int> last(alp, 0);

    Int count = out.size();
    for (Int d = 0; d < count; d++) {
        last[out[d]] = d + 1;

        for (Int i = 0; i < alp; i++) {
            score -= (d + 1 - last[i]) * c[i];
        }
        score += s[d][out[d]];
    }

    count = min(D, (Int)(out.size() + k));
    for (Int d = out.size(); d < count; d++) {
        for (Int i = 0; i < alp; i++) {
            score -= (d + 1 - last[i]) * c[i];
        }
    }

    return score;
}

vector<Int> solve(Int &D, vector<vector<Int>> &s, vector<Int> &c, Int &k) {
    vector<Int> out;

    for (Int _ = 0; _ < D; _++) {
        Int max_score = -INF;
        Int best_i = 0;

        for (Int i = 0; i < alp; i++) {
            out.push_back(i);

            Int score = evaluate(D, s, c, out, k);
            if (max_score < score) {
                max_score = score;
                best_i = i;
            }

            out.pop_back();
        }

        out.push_back(best_i);
    }

    return out;
}

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

    Int D;
    cin >> D;
    vector<Int> c(alp);
    vector<vector<Int>> s(D, vector<Int>(alp));
    for (Int i = 0; i < alp; i++) {
        cin >> c[i];
    }
    for (Int i = 0; i < D; i++) {
        for (Int j = 0; j < alp; j++) {
            cin >> s[i][j];
        }
    }

    Int k = 13;
    auto ans = solve(D, s, c, k);
    for (auto e : ans) {
        cout << e + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3784
import itertools
import math

n = int(input())
x = []
y = []
for i in range(n):
    xx, yy = map(int, input().split())
    x.append(xx)
    y.append(yy)

dd = 0
patterns = list(itertools.permutations(list(range(n))))
for p in patterns:
    xd = 0
    for i in range(len(p) - 1):
        d = math.sqrt((x[p[i]] - x[p[i + 1]]) * (x[p[i]] - x[p[i + 1]]) + (y[p[i]] - y[p[i + 1]]) * (y[p[i]] - y[p[i + 1]]))
        xd += d
    dd += xd
print(dd / len(patterns))

Measured memory_bytes: 7972
#include<bits/stdc++.h>
using namespace std;
#define ll long long
///The greatest enemy of knowledge is not ignorance, it is illusion of knowledge

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


#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpll vector<pll>
#define vpii vector<pii>
#define umap unordered_map
#define uset unordered_set
#define PQ priority_queue

#define printa(a,L,R) for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?'\n':' ')
#define printv(a) printa(a,0,a.size())
#define print2d(a,r,c) for(int i=0;i<r;i++) for(int j=0;j<c;j++) cout<<a[i][j]<<(j==c-1?'\n':' ')
#define pb push_back
#define eb emplace_back
#define mt make_tuple
#define fbo find_by_order
#define ook order_of_key
#define MP make_pair
#define UB upper_bound
#define LB lower_bound

#define F first
#define S second
#define mem(a,x) memset(a,x,sizeof(a))
#define inf 1e18
#define PI (acos(-1.0))
#define E 2.71828182845904523536
#define gamma 0.5772156649
#define nl "\n"
#define lg(r,n) (int)(log2(n)/log2(r))
#define pf printf
#define sf scanf
#define _ccase printf("Case %lld: ",++cs)
#define _case cout<<"Case "<<++cs<<": "
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; }

#define asche cerr<<"Ekhane asche\n";
#define rev(v) reverse(v.begin(),v.end())
#define srt(v) sort(v.begin(),v.end())
#define grtsrt(v) sort(v.begin(),v.end(),greater<ll>())
#define all(v) v.begin(),v.end()
#define mnv(v) *min_element(v.begin(),v.end())
#define mxv(v) *max_element(v.begin(),v.end())
#define toint(a) atoi(a.c_str())
#define fast ios_base::sync_with_stdio(false)
#define valid(tx,ty) (tx>=0&&tx<n&&ty>=0&&ty<m)
#define one(x) __builtin_popcount(x)
#define Unique(v) v.erase(unique(all(v)),v.end())
#define stree ll l=(n<<1),r=l+1,mid=b+(e-b)/2
#define fout(x) fixed<<setprecision(x)

#define SQ(x) ((x)*(x))
#define issq(x) (((ll)(sqrt((x))))*((ll)(sqrt((x))))==(x))
#define AMR std::ios::sync_with_stdio(false);cin.tie(NULL);
void min_self(ll &a, ll b){
a=max(a,b);
}

int main(){
AMR;
ll n,W,v[105],w[105];
cin>>n>>W;
for(int i=1; i<=n; i++)cin>>w[i]>>v[i];
ll sum_val=0;

for(int i=1 ;i<=n; i++)sum_val+=v[i];
vector<ll >dp(W+10,0);
dp[0]=0;
for(int item=1 ;item<=n ;item++){

    for(int i=W-w[item];i>=0 ;i--){
        min_self( dp[i+w[item]],dp[i]+v[item]);
    }

}
cout<<dp[W]<<endl;

}










Measured memory_bytes: 1024
// /*
// power code taken from geeks for geeks
// */
// cout << setprecision (2) << fixed << 1.2;

#include <bits/stdc++.h>
#define MODD 1000000007LL
#define MAX_SIZE 100000000
#define MAX_N 1000001LL
#define INF 1000000000LL
using namespace std;
typedef long long ll;
typedef long double ld;

ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
double max(double a,double b){return a>b?a:b;}
double min(double a,double b){return a<b?a:b;}

ll modd(ll a){if(a<0LL) return a*-1LL;return a;}
double modd(double a){if(a<0.0) return a*-1.0;return a;}

ll modulo(ll a){return a % MODD; }

ll power(ll k, ll p){
    if (p == 0)
    return 1LL;

    ll P = power(k, p/2LL);
    P = (P * P) % MODD;

    if (p % 2 == 1)
    P = (P * k) % MODD;

return P;
}


struct p_str{
    ll a, b;
};


void solve(){
    ll n;
    cin>>n;

    ll a[n][3];
    for(ll i=0;i<n;i++){
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    
    ll dp[n][3];
    memset(dp, 0, sizeof(dp));
    
    for(ll i=0;i<n;i++){
        for(ll j=0;j<3;j++){
            ll t=0;
            for(ll k=0;k<3;k++){
                if(i-1>=0 && k!=j){
                    t=max(t, dp[i-1][k]);
                }
            }
            dp[i][j]=a[i][j]+t;
        }
    }

    // cout<<"dp ";
    // for(ll i=0;i<n;i++){
    //     for(ll j=0;j<3;j++){
    //         cout<<dp[i][j]<<" ";
    //     }cout<<endl;
    // }

    ll ans=0;
    for(ll i=0;i<3;i++){
        ans=max(ans, dp[n-1][i]);
    }

    cout<<ans<<endl;
}



int main(){



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

    ll t=1;

    // init();

    // cin>>t;

    while(t--){

        solve();
    }
    return 0;
}


Measured memory_bytes: 8316
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
int dx[]={0,1,-1,1,0,1};
int dy[]={-1,-1,0,0,1,1};
int dx2[]={-1,0,-1,1,-1,0};
int dy2[]={-1,-1,0,0,1,1};
int a[200][200],ans,h,w;
void dfs(int x,int y){
  a[y][x]=2;
  if(y%2==0)r(i,6){
    int yy=y+dy[i];
    int xx=x+dx[i];
    if(yy<0||xx<0||yy>190||xx>190)continue;
    if(a[yy][xx]==0) dfs(xx,yy);
  }
  else r(i,6){
    int yy=y+dy2[i];
    int xx=x+dx2[i];
    if(yy<0||xx<0||yy>190||xx>190)continue;
    if(a[yy][xx]==0) dfs(xx,yy);
  }
}
main(){
  cin>>w>>h;
  r(i,h)r(j,w)cin>>a[i+50][j+50];
  dfs(0,0);
  r(i,200)r(j,200)if(a[i][j]==1){
    if(i%2==0)r(k,6){
      int y=i+dy[k];
      int x=j+dx[k];
      if(a[y][x]==2)ans++;
    }
    else r(k,6){
      int y=i+dy2[k];
      int x=j+dx2[k];
      if(a[y][x]==2)ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define isin(i,a,b) ((a) <= (i) && (i) < (b))
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll  = long long;
using unit= unsigned;
using ull = unsigned long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vvi = vector<vi>;
using vp  = vector<P>;
void _main(); int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
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; }
template<class T>T gcd(T a, T b){ if (b==0){ return a; }else{ return gcd(b, a%b); }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
constexpr double eps = 1e-10;
constexpr int inf = INT_MAX / 2;
constexpr ll infl = 1LL << 60;

void _main() {
  int A, B, C;
  cin >> A >> B >> C;

  int m = max({A, B, C});
  int ans = A + B + C - m;;
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		String a=sc.next();
		String b=sc.next();
		if(a.length()>18 && b.length()>18){
			if(a.length()>b.length())System.out.println("GREATER");
			else if(a.length()<b.length())System.out.println("LESS");
			else if(a.length()==b.length()){
				for(int i=0;i<a.length()-1;i++){
					if(Integer.parseInt(a.substring(i, i+1))>Integer.parseInt(b.substring(i, i+1))){
						System.out.println("GREATER");
						return;
					}
					else if(Integer.parseInt(a.substring(i, i+1))<Integer.parseInt(b.substring(i, i+1))){
						System.out.println("LESS");
						return;
					}
				}
				System.out.println("EQUAL");
			}
		}else{
			if(Long.parseLong(a)>Long.parseLong(b))System.out.println("GREATER");
			else if(Long.parseLong(a)<Long.parseLong(b))System.out.println("LESS");
			else System.out.println("EQUAL");
		}
	}
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int l;
    cin >> l;
    long double ans = l / 3.0;
    ans = ans * ans * ans;
    printf("%llf\n", ans);
    //cout << ans << endl;
    /*
    ull ans = l * 100 / 3;
    ans = ans * ans * ans;
    ull a, b;
    a = ans / 1000000;
    b = ans % 1000000;
    cout << a << '.' << b << endl;
    */
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	long long int n, x, m;
	scanf("%lld %lld %lld", &n, &x, &m);
	long long int i, j;
	long long int v[100005];
	for (i = 0; i < m; i++)
		v[i] = -1;
	j = x;
	for (i = 1;; i++)
	{
		j %= m;
		if (v[j] > 0)
			break;
		v[j] = i;
		j *= j;
	}
	long long int ans = 0;
	if (i >= n)
	{
		j = x % m;
		for (i = 0; i < n; i++)
		{
			ans += j;
			j = j * j % m;
		}
		printf("%lld\n", ans);
		return 0;
	}
	i = x % m;
	while (i != j)
	{
		ans += i;
		i = i * i % m;
		n--;
		if (n == 0)
			break;
	}
	if (n == 0)
	{
		printf("%lld\n", ans);
		return 0;
	}
	n--;
	ans += i;
	if (n == 0)
	{
		printf("%lld\n", ans);
		return 0;
	}
	long long int c = 0, d = 0;
	for (i = j;;)
	{
		c++;
		d += i;
		i = i * i % m;
		if (i == j)
			break;
	}
	ans += n / c * d;
	n %= c;
	i = j;
	for (; n > 0; n--)
	{
		i = i * i % m;
		ans += i;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2504
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  Int n,a,b;
  cin>>n>>a>>b;
  vector<Int> x(n);
  for(Int i=0;i<n;i++) cin>>x[i];
  Int ans=0;
  for(Int i=1;i<n;i++)
    ans+=min(b,(x[i]-x[i-1])*a);
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

#define int long long

constexpr int INF = 1LL << 60;
constexpr double EPS = 1.0e-11;

typedef pair<int, int> pii;
typedef pair<int, pii> pipii;

constexpr int MAX_N = 100005;

struct SegTree
{
    int n, seg[MAX_N * 4];

    void init(const int pn)
    {
        n = 1;
        while (n < pn) n *= 2;
    }

    void add(int i, const int a)
    {
        i += n - 1;
        seg[i] += a;
        do
        {
            i = (i - 1) / 2;
            seg[i] = seg[i * 2 + 1] + seg[i * 2 + 2];
        } while (0 < i);
    }

    int sum(const int l, const int r) const
    {
        return sum(l, r, 0, n, 0);
    }

    int sum(const int l, const int r, int xl, int xr, int k) const
    {
        if (r <= xl || xr <= l) return 0;
        if (l <= xl && xr <= r) return seg[k];
        const int len = xr - xl;
        return sum(l, r, xl, xl + len / 2, k * 2 + 1) + sum(l, r, xl + len / 2, xr, k * 2 + 2);
    }
};

int n, a[MAX_N], sorted[MAX_N], sum[2][MAX_N];
unordered_map<int, int> nmap;
SegTree seg[2];

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(16);
    cout << fixed;

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        sorted[i] = a[i];
    }
    sort(sorted, sorted + n);
    for (int i = 0; i < n; i++)
    {
        nmap.emplace(sorted[i], i);
    }

    for (int i = 0; i < 2; i++)
    {
        seg[i].init(n);
        for (int j = 0; j < n; j++)
        {
            const int idx = nmap[a[j]];
            sum[i][j] = j - seg[i].sum(0, idx + 1);
            seg[i].add(idx, 1);
        }
        reverse(a, a + n);
    }

    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans += min(sum[0][n - 1 - i], sum[1][i]);
    }

    cout << ans << endl;
}



Measured memory_bytes: 13364
<?php
$n = int();
$A = ints();
//o($n);
//o($A);
$sum = 0;
$As[] = 0;
foreach($A as $a){
    $sum+=$a;
    $As[] = $sum; 
}
for($r = 0; $r < $n; $r++){
    $dp[$r][$r] = 0;
    for($l = $r-1; $l >= 0; $l--){
        $sum = $As[$r+1]-$As[$l];
        $min = 10**18;
        for($m = $l; $m < $r; $m++){
            $tmp = $dp[$l][$m] + $dp[$m+1][$r];
            if($min > $tmp){
                $min = $tmp;
            }
        }
        $dp[$l][$r] = $sum+$min;
    }
}
echo $dp[0][$n-1];

function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array: ";
            echo implode(" ", addIndex($val))."\n";
        }else{
            echo "array:array\n";
            if(isCleanArray($val)){
                foreach($val as $row)echo implode(" ", addIndex($row))."\n";
            }else{
                foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row))."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}
function addIndex($val){
    if(!isCleanArray($val)){
        $val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);
    }
    return $val;
}
function isCleanArray($array){
    $clean = true;
    $i = 0;
    foreach($array as $k => $v){
        if($k != $i++)$clean = false;
    }
    return $clean;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

const long long MOD = 1000000007;

int main(){
  int q;
  cin >> q;
  rep(x,q){
      string s,t;
      cin >> s >> t;

     int a=s.size(),b=t.size();

     vector<vector<int>> dp(a+1,vector<int>(b+1,0));
     
     rep(i,a){
         rep(j,b){
             if(s.at(i)==t.at(j)) dp.at(i+1).at(j+1)=dp.at(i).at(j)+1;
             else dp.at(i+1).at(j+1) = max(dp.at(i+1).at(j),dp.at(i).at(j+1)); 
         }
     }
     cout << dp[a][b] << endl;
  }
}


Measured memory_bytes: 6852
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] arg) {
		while (true) {
			int K = sc.nextInt();
			if (K == 0) break;
			String s = sc.next();
			String t = sc.next();
			int[] d = new int[K];
			for (int i = 0; i < K; ++i) {
				d[i] = (10 + t.charAt(i) - s.charAt(i)) % 10;
			}
			System.out.println(solve(d, 0));
		}
	}

	static int solve(int[] d, int pos) {
		if (pos == d.length) return 0;
		if (d[pos] == 0) return solve(d, pos + 1);
		int prev = d[pos];
		int ret = 99;
		for (int i = pos; i < d.length; ++i) {
			d[i] = (d[i] + 10 - prev) % 10;
			ret = Math.min(ret, solve(d, pos + 1) + 1);
		}
		for (int i = pos; i < d.length; ++i) {
			d[i] = (d[i] + prev) % 10;
		}
		return ret;
	}
}

Measured memory_bytes: 21852
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define fop(i,m,n) for (int i=(m);i<(n);i++)
#define FOP(i,m,n) for (int i=(m)-1;i>=(n);--i)
#define test(x) cout << #x << ' ' << x << endl;
#define eb emplace_back
#define pb push_back
#define mp make_pair 
#define pii pair<int,int> 
#define X first
#define Y second
#define MAXN 200000

struct Line {
	long long m, k; // y = mx + k
	long long v(int x) {
		return 1ll * m * x + k;
	}
};

struct LiChao {
	int l, r, m;
	Line line;
	LiChao* ch[2];
	LiChao (int l, int r) : l(l), r(r), m(l + r >> 1) {
		line.m = 0;
		line.k = 1ll << 60;
		if (r - l != 1) {
			ch[0] = new LiChao(l, m);
			ch[1] = new LiChao(m, r);
		}
	}
	void insert(Line seg) {
		if (r - l == 1) {
			if (seg.v(l) < line.v(l)) {
				line = seg;
			}
		} else {
			if (line.m > seg.m) swap(seg, line);
			if (line.v(m) > seg.v(m)) {
				swap(seg, line);
				ch[1]->insert(seg);
			} else {
				ch[0]->insert(seg);
			}
		}
	}
	long long query(int x) {
		if (r - l == 1) return line.v(x);
		if (x < m) return min(ch[0]->query(x), line.v(x));
		else return min(ch[1]->query(x), line.v(x));
	}
};

int main () {
	int n;
	long long c;
	cin >> n >> c;
	long long dp[n];
	int tmp;
	/* dp[i] = dp[j] + (h_j - h_i)^2 + c 
			 = dp[j] + h_j^2 - 2 * h_i * h_j + h_i^2 + c
			 = h_i^2 + c + (dp[j] + h_j^2 - 2 * h_j * h_i)*/
	LiChao root(1, 1000001);
	fop (i,0,n) {
		cin >> tmp;
		if (i) dp[i] = root.query(tmp) + (1ll * tmp * tmp) + c;
		else dp[i] = 0;
		Line A;
		A.m = -2 * tmp;
		A.k = (1ll * tmp * tmp) + dp[i];
		root.insert(A);
	}
	cout << dp[n-1] << endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pi;

const ll MOD = 1e9+7;

static long gcd(long a, long b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}
/*
long long int facctorialMethod(int k){//階乗
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}*/

long long int tousasum(long long int n){//等差数列
    return n*(n+1)/2;
}

unsigned GetDigit(unsigned num){//桁数
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

bool IsPrime(int num)//素数判定
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

map< ll, ll > prime_factor(ll n) {//素因数分解
    map< ll, ll > ret;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

ll calcNumOfCombination(ll n, ll r){
    ll num = 1;
    for(ll i = 1; i <= r; i++){
        num = num * (n - i + 1) / i;
    }
    return num;
}

int bubblesort(vector<int> array,int size){//バブルソート　転倒数
    int kaisu = 0;
    for(int i = 0; i < size; i++){
        for(int j = i + 1; j < size; j++){
            if(array[i] > array[j]){
                int number = array[i];
                array[i] = array[j];
                array[j] = number;
                kaisu++;
            }
        }
    }
    return kaisu;
}

ll facctorialMethod(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum = (sum * i)%MOD;
    }
    return sum;
}

int main() {
    int N;
    cin >> N;
    int L[N];
    for(int i=0;i<N;i++){
        cin >> L[i];
    }
    sort(L,L+N);
    set<string> st;
    int result = 0;
    for(int i=0;i<N-2;i++){
        bool flag = true;
        for(int j=i+1;j<N-1;j++){
            for(int k=j+1;k<N;k++){
                if(L[i]+L[j]>L[k]){
                    //string str = to_string(L[i])+to_string(L[j])+to_string(L[k]);
                    //st.insert(str);
                    result++;

                }else{
                    break;
                }

            }


        }

    }

    cout << result << endl;


}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A_500,B_100,C_50;

  cin >> A_500;
  cin >> B_100;
  cin >> C_50;
  
  int cnt = 0;

  if(A_500 == B_100) cnt++;
  if(B_100 == C_50) cnt++;
  if(A_500 == C_50) cnt++;
  
  if(cnt == 1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;    
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  string s, t;
  cin >> s >> t;

  for (int i = 0; i != s.size(); ++i) {
    if (s[i] == t[i]) continue;

    char c1 = s[i], c2 = t[i];

    for (int j = 0; j != s.size(); ++j) {
      if (s[j] == c1) {
        if (j < i) {
          cout << "No" << endl;
          return 0;
        }
        s[j] = c2;
      } else if (s[j] == c2) {
        if (j < i) {
          cout << "No" << endl;
          return 0;
        }
        s[j] = c1;
      }
    }
  }

  if (s == t) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 776
import java.util.*;

class Main{

    static boolean isNum(String n) {
	try {
	    Integer.parseInt(n);
	    return true;
	} catch (NumberFormatException e) {
	    return false;
	}
    }
 
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	ArrayList<Integer> num = new ArrayList<>();

	while(sc.hasNext()){
	    String str = sc.next();
	    if(isNum(str)){
		num.add(Integer.parseInt(str));
	    }
	    else{
		int x = num.get(num.size()-2);
		int y = num.get(num.size()-1);
		num.remove(num.size()-2);
		num.remove(num.size()-1);
		switch(str){
		case "+":
		    num.add(x+y);
		    break;
		case "-":
		    num.add(x-y);
		    break;
		case "*":
		    num.add(x*y);
		    break;		
		}
	    }
	}
	System.out.println(num.get(0));

    }

}


Measured memory_bytes: 26324
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        long countYen = 0;

        PriorityQueue<long[]> q = new PriorityQueue<>(Comparator.comparingLong(a -> a[0]));
        for (int i = 0; i < n; i++) {
            q.add(new long[]{sc.nextLong(), sc.nextLong()});
        }

        while (!q.isEmpty()) {
            long[] store = q.poll();
            if (store[1] < m) {
                countYen += store[0] * store[1];
                m -= store[1];
            } else {
                countYen += store[0] * m;
                break;
            }
        }
        System.out.println(countYen);
    }
}

Measured memory_bytes: 69260
#include<bits/stdc++.h>
using namespace std;
long long n;
typedef long long ll;
const int mod=1e9+7;
ll Pow(ll a, ll b, ll m){
	if(b == 0)
		return 1;
	else if(b % 2 == 1)
		return a * Pow(a, b - 1, m) % m;
	else{
		ll num = Pow(a, b/2, m) % m;	//优化 
		return num * num % m;// 不直接写成return binaryPow(a, b/2, m) * binaryPow(a, b/2, m)
	}
	
}
int main()
{
	cin>>n;
	cout<<((Pow(10,n,mod)-Pow(9,n,mod)-Pow(9,n,mod)+Pow(8,n,mod))%mod+mod)%mod;
}

Measured memory_bytes: 3608
#!/usr/bin/env python3

S = input()
T = input()

s_t = {}
t_s = {}

for s, t in zip(S, T):
    if s not in s_t:
        s_t[s] = t
    else:
        if s_t[s] != t:
            print("No") 
            exit()
            
    if t not in t_s:
        t_s[t] = s
    else:
        if t_s[t] != s:
            print("No") 
            exit()
print("Yes")

Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
using namespace std;

void solve(){
	int ans=0;
	int N;
	cin>>N;
	string s;
	cin>>s;
	int cur=0;
	for(auto i:s){
		if(i=='I')cur++;else if(i=='D')cur--;
		ans=max(cur,ans);		
	}
	cout<<ans;
}

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


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

using namespace std;
typedef long long ll;

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

    for(auto v : a){
        mp[v]++;                
    }

    int ans = 0;

    for(auto v : mp){
        if(v.second % 2 != 0){
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 5376
N = int(input())
T,A = map(int, input().split())
H = list(input().split())
L = []

for i in range(N):
    point = T - int(H[i]) * 0.006
    focus_point = A - point
    L.append(abs(focus_point))

print(L.index(min(L))+1)
    

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

int main(){
  vector<long long> L(86 + 1);
  L[0] = 2;
  L[1] = 1;
  for(int i = 2; i <= 86; i++){
    L[i] = L[i - 1] + L[i - 2];
  }

  int N;
  cin >> N;

  cout << L[N] << endl;
}


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

bool CheckCondition(int a) {
  if (a % 2 != 0) {
	return true;
  } else {
	if (a % 3 == 0 || a % 5 == 0) {
	  return true;
    } else {
	  return false;
    }
  }
};

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a.at(i);
  
  rep(i,n) {
	if (!CheckCondition(a.at(i))) {
//      cout << "i = " << i << endl;
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}

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

int main()
{
    int N, M;
    map < string , int > mp;
    cin >> N;
    for ( int i = 0; i < N; i++ ) {
        string S;
        cin >> S;
        if ( mp.find(S) != mp.end() ) {
            mp[S]++;
        } else {
            mp[S] = 1;
        }
    }
    cin >> M;
    for ( int i = 0; i < M; i++ ) {
        string S;
        cin >> S;
        if ( mp.find(S) != mp.end() ) {
            mp[S]--;
        } else {
            mp[S] = -1;
        }
    }
    int maxv = 0;
    for ( auto &x : mp ) {
        maxv = max(maxv, x.second);
    }
    cout << maxv << endl;
    return ( 0 );
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 hh, nn, tmp, sum = 0;
	cin >> hh >> nn;
	for(int64 ii = 0;ii < nn;ii++)
	{
		cin >> tmp;
		sum += tmp;
	}
	if(hh <= sum)
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}
	return 0;
}


Measured memory_bytes: 3620