akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
template <typename T>
struct Dinic {
  struct Edge {
    int dst, rev;
    T cap;
    Edge(int dst, T cap, int rev) : dst(dst), cap(cap), rev(rev) {}
  };

  vector<vector<Edge> > graph;

  Dinic(int n) : graph(n), level(n), itr(n) {}

  void add_edge(int src, int dst, T cap) {
    graph[src].emplace_back(dst, cap, graph[dst].size());
    graph[dst].emplace_back(src, 0, graph[src].size() - 1);
  }

  T maximum_flow(int s, int t, T limit) {
    T res = 0;
    while (true) {
      bfs(s);
      if (level[t] == -1) return res;
      fill(ALL(itr), 0);
      T tmp;
      while ((tmp = dfs(s, t, limit)) > 0) res += tmp;
    }
  }

private:
  vector<int> level, itr;

  void bfs(int s) {
    fill(ALL(level), -1);
    queue<int> que;
    level[s] = 0;
    que.emplace(s);
    while (!que.empty()) {
      int ver = que.front(); que.pop();
      for (Edge e : graph[ver]) if (level[e.dst] == -1 && e.cap > 0) {
        level[e.dst] = level[ver] + 1;
        que.emplace(e.dst);
      }
    }
  }

  T dfs(int ver, int t, T flow) {
    if (ver == t) return flow;
    for (; itr[ver] < graph[ver].size(); ++itr[ver]) {
      Edge &e = graph[ver][itr[ver]];
      if (level[ver] < level[e.dst] && e.cap > 0) {
        T tmp = dfs(e.dst, t, min(flow, e.cap));
        if (tmp > 0) {
          e.cap -= tmp;
          graph[e.dst][e.rev].cap += tmp;
          return tmp;
        }
      }
    }
    return 0;
  }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> a(n), b(n), c(n), d(n);
  REP(i, n) cin >> a[i] >> b[i];
  REP(i, n) cin >> c[i] >> d[i];
  Dinic<int> dinic(n * 2 + 2);
  REP(i, n) REP(j, n) {
    if (a[i] < c[j] && b[i] < d[j]) {
      dinic.add_edge(i, n + j, 1);
    }
  }
  REP(i, n) {
    dinic.add_edge(n * 2, i, 1);
    dinic.add_edge(n + i, n * 2 + 1, 1);
  }
  cout << dinic.maximum_flow(n * 2, n * 2 + 1, INF) << '\n';
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long  
int main()
{ int n,k;
 cin>>n>>k;
 vector<int> a(n);
 for(auto &x:a)
 cin>>x;
 sort(a.begin(),a.end());
 ll answer =0;
 for(int i=0;i<n-k;i++) 
  answer+=a[i];
  cout<<answer;
 
}

Measured memory_bytes: 4004
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<utility>

using namespace std;

int n;

int p[10010];

int cnt;

int people;

int main(void)
{

	while (cin >> n, n)
	{
		fill(&p[0], &p[10010], -1);
		for (int i = 0; i < n; i++)
		{
			int pn, d1, d2;

			cin >> pn >> d1 >> d2;

			p[pn] = d1 + d2;
		}

		int ans = max_element(&p[0], &p[10010]) - p;



		

		cout << ans  << " " << p[ans] << endl;

	}
	return 0;
}


Measured memory_bytes: 3000
import numpy as np
n = int(input())
d = np.array([[int(i) for i in input().split()]for _ in range(2)])
ans = [0 for i in range(n)]
for i in range(n):
  ans[i] = d[0,0:i].sum()+d[1,i:].sum()+d[0,i]
print(max(ans))


Measured memory_bytes: 12412
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        int[] numbers = new int[n];

        for (int i = 0; i <n ; i++) {
            numbers[i] = sc.nextInt();
        }

        Arrays.sort(numbers);

        int count = 0;
        for (int i = 0; i < n-2; i++) {
            for (int j = i+1; j < n-1; j++) {
                for (int k = j+1; k < n; k++) {

                    int a = numbers[i];
                    int b = numbers[j];
                    int c = numbers[k];

                    if (a != b && b!=c && a!=c) {
                        if (a+b > c) {
                            count++;
                        }
                    }


                }
            }
        }

        System.out.println(count);

    }
}

Measured memory_bytes: 36540
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		boolean gg=true;
		Integer[] array = new Integer[n];
		int a = 1;
		int b = 0;
		for(int i = 0;i<n;i++) {
			array[i] = s.nextInt();
			if(i!= 0) {
				if(array[i]< b) {
					b=array[i];
					a++;
				}else {
					
				}
				
			}else {
				b = array[i];
			}
		}
		System.out.print(a);
		
		
	}
}

Measured memory_bytes: 91904
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;
import java.awt.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    /* 変数宣言 */
    final int N;
    final String S;

    AtCoder(FastScanner sc) {
        N = sc.nextInt();
        S=sc.next();
    }

    void solve(PrintWriter out) {
        String str=S.replaceAll("ABC", "");

        int result=(S.length()-str.length())/3;

        out.println(result);


    }

}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

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


Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

	int n;
	cin >> n;
	int a[n+1];
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	int s = 1000;
	int x=0;
	a[n]=0;
	for(int i=0; i<n; i++){
		s += x*a[i];
		x=0;
		if(a[i+1]>a[i]){
			x = s/a[i];
			s -= x*a[i];
		}
	}
	cout << s;



	
	

	return 0;
}

Measured memory_bytes: 3628
// Problem : E - Picking Goods
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_e
// Memory Limit : 1024 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 3000 + 5;
const ll MOD = 1e9 + 7;

ll dp[maxN][maxN][4];
int val[maxN][maxN];

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int r, c, k;
	cin >> r >> c >> k;
	REP(_, k) {
		int a, b, v;
		cin >> a >> b >> v;
		val[a][b] = v;
	}
	if (val[1][1] != 0) dp[1][1][1] = val[1][1];
	RI(i, r) {
		RI(j, c) {
			ll mx = 0;
			dp[i][j][0] = max(dp[i - 1][j][0], dp[i][j - 1][0]);
			RI(ile, 3) {
				dp[i][j][ile] = max(dp[i][j][ile], dp[i][j - 1][ile - 1] + val[i][j]);
				dp[i][j][ile] = max(dp[i][j][ile], dp[i][j - 1][ile]);
				mx = max(mx, dp[i - 1][j][ile]);
			}
			dp[i][j][1] = max(dp[i][j][1], mx + val[i][j]);
			// REP(ile, 4) {
				// cout << i << " " << j << " " << ile << " " << dp[i][j][ile] << endl;
			// }
		}
	}
	ll ans = 0;
	REP(ile, 4) ans = max(ans, dp[r][c][ile]);
	cout << ans;
	return 0;
}
 


Measured memory_bytes: 320596
from bisect import bisect_left as bl
ox, n = map(int, input().split())
if n == 0:
    print(ox)
    exit()
a = list(map(int, input().split()))
a.sort()
x = ox
i = bl(a, x)
while i < n and a[i] == x:
    i += 1
    x += 1
up = x
x = ox
i = bl(a, x)
while i >= 0 and a[i] == x:
    i -= 1
    x -= 1
down = x
if up-ox < ox-down:
    print(up)
else:
    print(down)

Measured memory_bytes: 62164
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main()
{
    int n, m;
    cin >> n;
    vector<int> t(n);
    REP(i, 0, n) cin >> t[i];
    cin >> m;
    vector<int> p(m), x(m);
    REP(i, 0, m) cin >> p[i] >> x[i];

    REP(i, 0, m) {
        int sum = 0;
        REP(j, 0, n) {
            if (j + 1 == p[i]) sum += x[i];
            else sum += t[j];
        }
        cout << sum << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxN = 3e3 + 10;

double f[2][maxN][maxN];
double p[maxN];
int n;

int main(){
//  freopen("abc.inp", "r", stdin); freopen("abc.out", "w", stdout);
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> p[i];
  }
  f[1][0][1] = 1 - p[1]; f[1][1][0] = p[1];
  for (int i = 2; i <= n; ++i) {
    int stt = i & 1, op = 1 ^ stt;
    for (int j = 0; j <= i; ++j) {
      int k = i - j;
      if (j > 0) f[stt][j][k] = (f[stt][j][k] + f[op][j-1][k] * p[i]);
      if (k > 0) f[stt][j][k] = (f[stt][j][k] + f[op][j][k-1] * (1-p[i]));
    }
    for (int j = 0; j <= i - 1; ++j) {
      f[op][j][i-j] = 0;
    }
  }
  double ans = 0;
  for (int j = (n - 1) / 2 + 1; j <= n; ++j) {
    ans = ans + f[n % 2][j][n-j];
  }
  cout << fixed << setprecision(10) << ans;
return 0;
}


Measured memory_bytes: 96084
#include "bits/stdc++.h"

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

int n, A, B, C;
vector<int> l;

int min_mp = INF;

void dfs(vector<int>& l, int a, int b, int c, int used, int i) {
	if (i == l.size()) {
		if (a == 0 || b == 0 || c == 0) return;
		else min_mp = min(min_mp, used + abs(a - A) + abs(b - B) + abs(c - C));
		return;
	}
	else {
		dfs(l, a, b, c, used, i + 1);
		dfs(l, a + l[i], b, c, used + (a == 0 ? 0 : 10), i + 1);
		dfs(l, a, b + l[i], c, used + (b == 0 ? 0 : 10), i + 1);
		dfs(l, a, b, c + l[i], used + (c == 0 ? 0 : 10), i + 1);
	}
}

int main(void){
	cin>>n>>A>>B>>C;
	for (int i = 0; i < n; i++) {
		int x; cin>>x;
		l.push_back(x);
	}

	dfs(l, 0, 0, 0, 0, 0);

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, W;

    cin>>n>>W;
    vector<pair<int, int> > item(n);
    for(int i =0; i<n; i++)
        cin>>item[i].first>>item[i].second;

    vector<ll> dp(W+1);


    for(int i =0; i< n; i++)
    {
        for(int j = W; j>= item[i].first ; j--)
        {  
            dp[j] = max(dp[j] , item[i].second + dp[j-item[i].first]);
        }
    }

    cout<<dp[W]<<"\n";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

template<class T>
T rec(T n)
{
  return n ? n + rec(n - 1) : 0;
}

void solve(void)
{
  ull a, b; cin >> a >> b;
  auto c = b - a;
  auto ans = rec(c) - b;

  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

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

	h := make([]bool, 10)
	for i := 0; i < k; i++ {
		var d int
		fmt.Scan(&d)
		h[d] = true
	}

	for {
		flag := true
		t := n

		for t > 0 && flag {
			if h[t%10] {
				flag = false
			}
			t /= 10
		}

		if flag {
			fmt.Println(n)
			break
		}
		n++
	}
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ar array
#define endl '\n'
#define ll long long
#define in insert
#define pb push_back
#define vt vector
#define P_Q(x) priority_queue<x>
#define p_q(x) priority_queue<x, vector<x>, greater<x>>
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(ll i=a;i>=b;i--)
#define FOR(m) Rep(i,1,m)
#define For(m) Rep(i,0,m-1)
#define Rbl(x,a) for(auto &x : a)
#define FIO ios::sync_with_stdio(0);   cin.tie(0);
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define vpii vector<pii>
#define vpll vector<pll>
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
const ll INF = 0x3f3f3f3f3f3f3f3fll;
#define mod 1000000007
 
const int mxN = 301;
double dp[mxN][mxN][mxN] = {};
double p[mxN][mxN][mxN] = {};
ll n;
 
int main()
{
FIO
 
    cin >> n;
    int c[3] = {}, num;
    For(n) cin >> num, c[--num]++;
    ll one = c[0], two = c[1], three = c[2];
    p[one][two][three] = 1;
    for(int k = n; k >= 0; k--)
    {
        for(int j = n; j >= 0; j--)
        {
            for(int i = n; i >= 0; i--)
            {
                if(i+j+k == 0 || i+j+k > n)
                    continue;
                dp[i][j][k] += p[i][j][k] * n / (i+j+k);

                if(i > 0)
                {
                    p[i-1][j][k] += p[i][j][k] * i / (i+j+k);
                    dp[i-1][j][k] += dp[i][j][k] * i / (i+j+k);
                }
                if(j > 0)
                {
                    p[i+1][j-1][k] += p[i][j][k] * j / (i+j+k);
                    dp[i+1][j-1][k] += dp[i][j][k] * j / (i+j+k);
                }
                if(k > 0)
                {
                    p[i][j+1][k-1] += p[i][j][k] * k / (i+j+k);
                    dp[i][j+1][k-1] += dp[i][j][k] * k / (i+j+k);
                }
            }
        }
    }

    cout << fixed << setprecision(10) << dp[0][0][0] << endl;
     
}

Measured memory_bytes: 218492
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	char a,b,c;
	a=getchar();
	b=getchar();
	c=getchar();
	if(a=='1')putchar('9');
	else putchar('1');
	if(b=='1')putchar('9');
	else putchar('1');
	if(c=='1')putchar('9');
	else putchar('1');
	return 0;
}

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

using namespace std;

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

  string s;
  int w;
  cin >> s >> w;

  for (int i = 0; i < s.size(); ++i) {
    if (i % w == 0)
      cout << s[i];
  }
  cout << endl;
  return 0;
}



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

typedef long long int ll;
void solved(){
	int k;cin>>k;
	int s = 0;
	for(int i = 1; i <= k; i++){
		for(int j = 1; j <= k; j++){
			for(int p = 1 ; p <= k; p++){
				s += __gcd(__gcd(i,j),p);
			}
		}
	}
	cout<<s<<endl;
}
int main(){
	solved();
	return 0;
} 

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
#define SELECTOR(_1, _2, _3, SELECT, ...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__, _rep1, _rep0)(__VA_ARGS__)
#define _rep0(i, n) for (ll i = 0; i < n; ++i)
#define _rep1(i, k, n) for (ll i = k; i < n; ++i)

void solve(){
  // main coding
  ll n,m; cin>>n>>m;
  ll INF=1<<15;
  vector<vector<ll>> dist(n,vector<ll>(n,INF)); // adjacency matrix
  vector<vector<ll>> E(n); // adjacency list
  rep(_,m) {
    ll a,b; cin>>a>>b;
    --a; --b; // 0-indexed
    dist[a][b]=1;
    E[a].push_back(b);
  }
  // Warshall-Floyd
  rep(k,n) rep(i,n) rep(j,n) {
    dist[i][j]=min(dist[i][k]+dist[k][j],dist[i][j]);
  }
  // loop detection
  ll len=n+1,v;
  rep(i,n) {
    if(dist[i][i]<len) {
      v=i;
      len=dist[i][i];
    }
  }
  if(len==n+1) {
    cout<<-1<<"\n";
    return;
  }
  const ll vm=v;
  vector<ll> ans;
  while(len){
    ans.push_back(v);
    --len;
    rep(i,n) if(dist[v][i]==1 && dist[i][vm]==len){
      v=i;
      break;
    }
  }
  cout<<ans.size()<<"\n";
  for(ll v:ans) cout<<v+1<<"\n";
}

int main(){
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 10240
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n)  FOR(i,0,(n))
typedef vector<int> vec;


class CMarch {
public:
	void solve(std::istream& in, std::ostream& out) {
    int n;
    in >> n;
    map<char, int> m;
    REP(i,n){
      string s;
      in >> s;
      m[s[0]]++;
    }
    const char a[] = {'M', 'A', 'R', 'C', 'H'};
    const int p[] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
    const int q[] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
    const int r[] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};
    int res = 0;
    vec d = {m[a[0]], m[a[1]], m[a[2]], m[a[3]], m[a[4]]};
    REP(i, 10){
      res += d[p[i]] * d[q[i]] * d[r[i]];
    }
    out << res << endl;
	}
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
	CMarch solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    map<string, ll> cnt;
    string s;
    for (int i = 0; i < N; ++i) {
        cin >> s;
        sort(s.begin(), s.end());
        cnt[s]++;
    }
    ll ans = 0;
    for (auto i = cnt.begin(); i != cnt.end(); ++i) {
        ll now = i->second;
        ans += now * (now - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11264
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

N, M = LI()
A = LI()
a = sum(A)

print(-1 if a > N else N-a)


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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if(a == b && b == c) cout << "1" << endl;
	else if(a == b || b == c) cout << "2" << endl;
	else if(a == c) cout << "2" << endl;
	else cout << "3" << endl;
	return 0;
}

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

int main(){
  int n, w;
  while(cin >> n >> w, n){
    double ans = 0.01;
    vector<int> H(101,0);
    for(int i = 0; i < n; ++i){
      int v;
      cin >> v;
      ++H[v/w];
    }
    int c = 100;
    while(!H[c]) --c;
    int m = 0;
    for(int i = 0; i <= c; ++i) m = max(m,H[i]);
    for(int i = 0; i < c; ++i){
      ans += (double)(c-i)/c*H[i]/m;
    }
    printf("%.12f\n",ans);
  }
  return 0;
}



Measured memory_bytes: 3156
package main

import "fmt"

func main() {
    var n, k, q, a int
    fmt.Scan(&n, &k, &q)
    ary := make([]int, n)
    for i := 0; i < q; i++ {
        fmt.Scan(&a)
        ary[a - 1]++
    }
    for i := 0; i < n; i++ {
        if q - ary[i] < k  {
            fmt.Println("Yes")
        } else {
            fmt.Println("No")
        }
    }
}


Measured memory_bytes: 5888
#include"iostream"
#include"string"
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    if (s[k - 1] == 'A') {
        s[k - 1] = 'a';
    }
    if (s[k - 1] == 'B') {
        s[k - 1] = 'b';
    }
    if (s[k - 1] == 'C') {
        s[k - 1] = 'c';
    }

    cout << s << endl;
   
}

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

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

    long long sum = 0;
    for (auto x : mp) sum += (long long)x.second * (x.second - 1) / 2;

    for (int i = 0; i < N; i++) {
        cout << sum - (mp[A[i]] - 1) << endl;
    }
}

Measured memory_bytes: 8320
#include <stdio.h>

int N, K, A[100000];

void solve();

int main() {
	int i;
	scanf("%d%d", &N, &K);
	for (i = 0; i < N; i++) scanf("%d", &A[i]);
	solve();
	return 0;
}

void solve() {
	int n = N, cnt = 0;
	while (n > 0) {
		if (cnt > 0) n++;
		n -= K;
		cnt++;
	}
	printf("%d", cnt);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.setf(ios::fixed);
    cout.precision(10);
    int n;
    cin >> n;
    set<int> as, bs, isec;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        as.insert(a);
    }
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        bs.insert(a);
    }

    set_difference(as.begin(), as.end(), bs.begin(), bs.end(), inserter(isec, isec.end()));
    vi vs;
    for (int i: isec) {
        vs.push_back(i);
    }
    sort(vs.begin(), vs.end());
    for (int v: vs) {
        cout << v << endl;
    }
}


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

int main(){
    int n; cin >> n;
    vector<int> c(n),v(n);
    rep(i,n) cin >> v[i];
    rep(i,n) cin >> c[i];
    
    int ans = 0;
    rep(i,n){
        if(v[i] > c[i]) ans += v[i] - c[i];
    }
    cout << ans << endl;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    int N, P;
    cin >> N >> P;
    string S;
    cin >> S;

    if (10 % P == 0) { // 2, 5
        ll ans = 0;
        rep(r, N) {
            if ((S[r] - '0') % P == 0) ans += r + 1;
        }
        cout << ans << endl;
        return 0;
    }

    vector<int> d(N + 1);
    int ten = 1;
    for (int i = N - 1; i >= 0; i--) {
        int a = (S[i] - '0') * ten % P;
        d[i] = (d[i + 1] + a) % P;
        ten *= 10;
        ten %= P;
    }

    vector<int> cnt(P);
    ll ans = 0;
    for (int i = N; i >= 0; i--) {
        ans += cnt[d[i]];
        cnt[d[i]]++;
    }

    cout << ans << endl;
}


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

int main() {
  int k,a;
  cin>>k;
  a=0;
for(int i=1;i<k+1;i++){
for(int j=1;j<k+1;j++){
for(int l=1;l<k+1;l++){
a+=gcd(gcd(i,j),l);
}}}  
  cout<<a<<endl;
}


Measured memory_bytes: 3640
n = gets.to_i
line_1 = gets.split(" ").map(&:to_i)
line_2 = gets.split(" ").map(&:to_i)
array = [line_1, line_2]
sums = []
for i in 0..n-1
  sum = array[0][0..i].inject(:+) + array[1][i..line_2.length-1].inject(:+)
  sums << sum
end

p sums.max

Measured memory_bytes: 1788
n, m  = [int(i) for i in input().split()]
ab = []
for i in range(m):
    ab.append([int(i) for i in input().split()])

ab.sort()
op_sum = 1
left = ab[0][0]
right = ab[0][1]

for a, b in ab:
    if right <= a:
        op_sum += 1
        left = a
        right = b
    else:
        left = a
        right = min(right, b)

print(op_sum)

Measured memory_bytes: 21656
#include <stdio.h>
int main(void)
{
	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)puts("No");
	else if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H)puts("Yes");







	return 0;
}


Measured memory_bytes: 2108
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

typedef long long ll;
const ll M = 1000000007;
const int N = 100000;

int n,r,s,t;
ll fact[N+1];
int bit[N+1],v[N+1];

void init_bit(int n){ for(int i=0;i<=n;i++)bit[i]=0; }

int sum(int i){
  ll res = 0;
  while(i > 0){
    res += bit[i];
    i -= i & -i;
  }
  return res;
}
 
void inc(int i){
  while(i <= n){
    bit[i]++;
    i += i & -i;
  }
}

int main(){
  fact[0] = 1;
  rep(i,N)fact[i+1] = (fact[i]*(i+1)) % M;

  while(cin >> n,n){
    cin >> r;
    rep(i,n)v[i] = i+1;
    rep(i,r){
      cin >> s >> t; s--; t--;
      swap(v[s],v[t]);
    }

    init_bit(n);
    ll ans = 0;
    rep(i,n){
      ans += fact[i]*sum(v[n-1-i]);
      ans %= M;
      inc(v[n-1-i]);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 2716
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> P;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<string,int>> vpsi;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;



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

int n;
cin >> n;
vi a(n);
rep(i,n)cin >> a[i];
Sort(a);
rep(i,n-1)if(a[i] == a[i+1]){
    fin("NO");
    return 0;
}
fin("YES");

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int gcd(int a, int b){
    if (a < b) swap(a, b);
    int r = a % b;
    if (r == 0) return b;
    else return gcd(b, r);
}

int main(){
    int N, X;
    cin >> N >> X;
    vector<int> y(N);
    rep(i, 0, N) {
        int x;
        cin >> x;
        y.at(i) = abs(x - X);
    }
    int ans = y.at(0);
    rep(i, 1, N){
        ans = gcd(ans, y.at(i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound 
    #define ub upper_bound
    #define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define vi vector<int> 
	#define vvi vector<vi>
    #define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)	
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size() 
	#define PI 3.14159265358979323846
    
	const int N =1e6;
    
     int mod= 1e9+7;
     
     int dx[4]={0,0,+1,-1};
     int dy[4]={+1,-1,0,0};
   
     void solve(){
          
          int q;
          cin>>q;
          
          map<vi,int > mp;          
          int sum=0,mx=0;
          
          while(q--){
			   string s;
			   cin>>s;
			   vi h(26,0);
			  rep(i,0,sz(s))
			    h[s[i]-'a']++;
			  mp[h]++;			 		 	   
		  }
		  
		  for(auto it:mp){
			  int yan = it.se;
			  sum+=yan*(yan-1)/2; 
		  }
		   
		  
		  //int wyn=mx*(mx-1)/2;
		  cout<<sum<<endl;  
           
     }
   
   
   
   
      int32_t main() {
	    cool;
	    int t=1;
        //cin>>t;
	    while(t--)
	       solve();
	       
	       
	       return 0;	   
	   }


Measured memory_bytes: 29952
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <string>
#include <sstream>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<ll> VL;

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

  char b;
  cin >> b;

  if (b == 'A') {
    cout << 'T' << endl;
  } else if (b == 'C') {
    cout << 'G' << endl;
  } else if (b == 'G') {
    cout << 'C' << endl;
  } else {
    cout << 'A' << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

int N, M;
vector<pair<int, int>> requests;

bool cmp_terminate(pair<int, int> p1, pair<int, int> p2){
    return p1.second < p2.second;
}

int main(){
    scanf("%d %d", &N, &M);
    requests.resize(M);
    int a, b;

    for(int i=0;i<M;i++){
        scanf("%d %d", &a, &b);
        requests[i] = make_pair(a, b);
    }

    sort(requests.begin(), requests.end(), cmp_terminate);

    int now_idx = requests[0].second;
    int ans = 1;
    for(auto &req:requests){
        // printf("now idx = %d, req st=%d, req ed = %d\n", now_idx, req.first, req.second);
        if(now_idx > req.first){
            continue;
        }else{
            ans += 1;
            now_idx = req.second;
        }

    }

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

}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n;
    cin>>n;
    ll ans=0;
    if(n%2==1){
        cout<<ans<<endl;
        return 0;
    }

    REP(i,1,40){
        ll div = pow(5,i);
        ans += n/2/div;
    }

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


Measured memory_bytes: 640
/* 
   AOJ 2013
   Osaki
   2015/9/8
*/

#include<stdio.h>
#include<stdlib.h>

#define MAX_TIMETABLE 10000

struct timetable
{
  int start, end;
};


struct timetable time_table[MAX_TIMETABLE];
int train[MAX_TIMETABLE];


struct node
{
  int val;
  struct node *link;
};

struct node *head = NULL;

void init()
{
  head = NULL;
}

int empty()
{
  return head == NULL;
}

int get()
{
  int get_val = head->val;
  struct node *get_node = head->link;
  free(head);
  head = get_node;
  return get_val;
}

int peak()
{
  return head->val;
}

void insert(int new_val)
{
  struct node *new_node = malloc(sizeof(*new_node)), *next = head, *prev = head;

  new_node->val = new_val;

  if(head == NULL)
    {
      head = new_node;
      new_node->link = NULL;
    }
  else
    {
      while(next != NULL && next->val <= new_val)
	{
	  prev = next;
	  next = next->link;
	}
      if(head == next)
	{
	  if(head->val > new_val)
	    {
	      new_node->link = head;
	      head = new_node;
	    }
	  else
	    {
	      new_node->link = NULL;
	      head->link = new_node;
	    }
	}
      else
	{
	  prev->link = new_node;
	  new_node->link = next;	  
	}
    }
}

void traverse()
{
  struct node *pres;
  for(pres = head; pres != NULL; pres = pres->link)
    {
      printf("%6d", pres->val);
    }
  printf("\n");
}


int count_enable_train(int start_t)
{
  struct node *pres;
  int count = 0;
  for(pres = head; pres != NULL && pres->val >= start_t; pres = pres->link)
    {
      count++;
    }
  return count - 1;
}

int ans_f(int timetable_n)
{
  int i, train_counter = 0, enable_train = 0;

  init();

  for(i = 0; i < timetable_n; i++)
    {
      insert(time_table[i].end);

      if(time_table[i].start >= peak())
	{
	  /* have some enable trains */
	  get();		/* use the peak train */
	}
      else
	{
	  /* have no enable train */
	  train_counter++;	/* add an one train */
	}
    }
  return train_counter;
}

int comp(const void *a, const void *b)
{
  struct timetable x = *(struct timetable*)a, y = *(struct timetable*)b;
  if(x.start < y.start)
    {
      return -1;
    }
  else
    {
      return 1;
    }
}

int main(void)
{
  int timetable_n, i, start_h, start_m, start_s, end_h, end_m, end_s;
  while(1)
    {
      scanf("%d", &timetable_n);
      if(timetable_n == 0)
	{
	  break;
	}
      for(i = 0; i < timetable_n; i++)
	{
	  scanf("%d:%d:%d %d:%d:%d", &start_h, &start_m, &start_s, &end_h, &end_m, &end_s);
	  time_table[i].start = start_h * 10000 + start_m * 100 + start_s;
	  time_table[i].end = end_h * 10000 + end_m * 100 + end_s;
	}
      qsort(time_table, timetable_n, sizeof(struct timetable), comp);
      printf("%d\n", ans_f(timetable_n));
    }
  return 0;
}

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

int main(){
  int x;
  int ans=1;
  cin>>x;
  for(int b=2;b<=x;b++){
    int power=b*b;
    for(int p=1;;p++){
      if(power>x){
        break;
      }
      
      ans=max(ans,power);
      power*=b;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a;
    cin >> a;
    vector<int> v(a);
    for(int i=0;i<a;i++)cin >> v[i];
    sort(v.begin(),v.end());
    int x = v[a/2-1],y = v[a/2];
    cout << y-x << endl;
}

Measured memory_bytes: 3744
n = gets.chomp.to_i
a = readlines.map{|a| a.to_i}

if a.index(2).nil?
  puts "-1"
  exit 
end

a.unshift(0)
count = Array.new(n+1){0}

idx = a[1]
count = 1

while idx != 2 && count <= n
  prv_idx = idx
  idx = a[idx]
  count += 1
  if prv_idx == a[idx] || prv_idx == idx || count > n
    puts "-1"
    exit 
  end
end

puts count

Measured memory_bytes: 9468
H, N = map(int, input().split())
INF = 10 ** 12

M = []
for i in range(N):
    A, B = map(int, input().split())
    M.append((A, B))


dp = [[INF for j in range(H+10**4+1)] for i in range(N+1)]


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

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

for i in range(1, N+1):  # 1<= i <= N
    # for j in range(1, H+10**4+1):  # 1 <= j <= H
    for j in range(1, H+1):  # 1 <= j <= H
        # print(i, j)
        if j - M[i-1][0] >= 0:
            dp[i][j] = min(dp[i-1][j], dp[i-1][j - M[i-1][0]] + M[i-1][1],
                           dp[i][j - M[i-1][0]] + M[i-1][1])
        else:
            dp[i][j] = min(dp[i-1][j], dp[i][0]+M[i-1][1])


# for i in range(N+1):
#     print(dp[i][H])

# ans = INF
# for i in range(H, H+10**4+1):
#     ans = min(ans, dp[N][i])
# print(ans)

print(dp[N][H])


Measured memory_bytes: 268808
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
}


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  n := 5
  a := make([]int, n)
  for i:=0; i < n; i++ {
    fmt.Scan(&a[i])
  }

  b := make([]int, n)
  c := 0
  d := 0
  for i:=0;i<n;i++{
    c = a[i] / 10
    d = a[i] % 10
    if d != 0 {
      b[i] = 10 * (c + 1)
    } else {
      b[i] = 10 * c
    }
  }

  ans_r := make([]int,n)
  for i:=0; i<n; i++ {
    for j:=0; j<n; j++ {
      if i == j {
        ans_r[i] += a[j]
      } else {
        ans_r[i] += b[j]
      }
    }
  }

  ans:= ans_r[0]
  for i:=1; i<n; i++ {
    if ans_r[i] < ans {
        ans = ans_r[i]
    }
  }
  fmt.Println(ans)


}


Measured memory_bytes: 512
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(n):#AtCoder Beginner Contest 101 b
    s=0
    for c in str(n):
        s=s+int(c)#'int'数値ではないものを数値にする'str'文字列じゃないものを文字列にする関数
    if n%s==0:
        return 'Yes'
    else:
        return'No'

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    return int(line)

def main():
    n = readQuestion()
    answer = solve(n)
    print(answer)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

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

    static class Solver {
        public void solve(Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int M = in.nextInt();

            Map<Integer, Integer> map = new HashMap<>();

            boolean ng = false;
            for (int i = 0; i < M; i++) {
                int s = in.nextInt();
                int c = in.nextInt();

                if (map.get(s) == null) {
                    map.put(s, c);
                }
                else if (map.get(s) != c) {
                    ng = true;
                }

                if (N > 1 && s == 1 && c == 0) {
                    ng = true;
                }
            }

            if (ng) {
                out.println(-1);
                return;
            }

            String[] ans = new String[N];
            for (Map.Entry<Integer, Integer> entry: map.entrySet()) {
                int s = entry.getKey();
                int c = entry.getValue();
                ans[s - 1] = String.valueOf(c);
            }
            for (int i = 0; i < N; i++) {
                if (ans[i] == null) {
                    if (i == 0) {
                        if (N == 1) {
                            ans[i] = "0";
                        }
                        else {
                            ans[i] = "1";
                        }
                    }
                    else {
                        ans[i] = "0";
                    }
                }
            }
            out.println(String.join("", ans));
        }
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 1000000007
//#define M 998244353
const int inf=4e18;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int k;cin>>k;
	string o[k+1];
	int i,j;o[1]="1";
	for(i=2;i<=k;i++)
	{
		int n=o[i-1].size();
		for(j=n-2;j>=0;j--)
		{
			if(o[i-1][j]!=o[i-1][j+1]-1)
				break;
		}
		j++;
		for(;j>=0;j--)
		{
			if(o[i-1][j]!='9')
				break;
		}
		if(j==-1)
		{
			o[i].push_back('1');
			for(int p=0;p<n;p++)
				o[i]+="0";
		}
		else
		{
			for(j=j-1;j>=0;j--)
			{
				if(j==-1)
					break;
				if(o[i-1][j]!=o[i-1][j+1]-1)
					break;
			}
			j++;
			o[i]=o[i-1];
			o[i][j]++;
			for(int p=j+1;p<n;p++)
				o[i][p]=((o[i][p-1]=='0')?'0':(o[i][p-1]-1));
		}
	}
	cout<<o[k]<<endl;
}

Measured memory_bytes: 5760
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

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



class DKnight {
public:
    int dy[4]={-1,1,0,0};
    int dx[4]={0,0,1,-1};
    ll x, y;

    ll mod_pow(ll x, ll n) {
        ll a = 1;
        while (n) {
            if (n % 2) a = a * x % INF;
            x = x * x % INF;
            n /= 2;
        }
        return a;
    }

	void solve(std::istream& in, std::ostream& out) {
        in >> x >> y;
        if ((x + y) % 3) {
            out << 0 << endl;
            return;
        }
        ll v = (x + y) / 3;
        if (x < v || y < v) {
            out << 0 << endl;
            return;
        }
        ll bunshi = 1;
        ll bunbo = 1;
        REP(i, min(x, y) - v) {
            bunshi *= v-i;
            bunshi %= INF;
            bunbo *= i+1;
            bunbo %= INF;
        }
        ll ret = bunshi * mod_pow(bunbo, INF-2) % INF;
        out << ret << endl;
	}
};


int main() {
    ios::sync_with_stdio(false);
	DKnight solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
N = int(input())
cnt = 0
for a in range(1, 10**6+1):
    if (a * a) < N :
        cnt = cnt + 1
    else:
        break
    for b in range(a+1, 10**6+1):
        if a*b < N:
            cnt = cnt + 2
        else:
            break
print(cnt)

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

int main(){
	int N,M; cin>>N>>M;
	rep(i, M){
		int a; cin>>a;
		N -= a;
	}
	cout<< (N<0? -1:N) <<endl;
}

Measured memory_bytes: 3568