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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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; }

int main(void){
    ll N,K; cin >> N >> K;
    vector<ll> a(N); REP(i,N) cin >> a[i];
    ll ans = LL_INF;
    REP(i,1<<N){
        int n = 0;
        REP(j,N) if(i & 1<<j) n++;
        if(n < K) continue;
        ll tmp = 0;
        ll h = 0;
        REP(j,N){
            if(i & 1<<j){
                if(a[j] <= h){
                    tmp += h+1-a[j];
                    h++;
                }
                else{
                    h = a[j];
                }
            }
            else{
                h = max(h, a[j]);
            }
        }
        chmin(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
attrs = Array.new
while line = $stdin.gets
attrs << line.chomp.split
end
attrs.delete_at(0)
shilist = attrs.map {|item| item.map(&:to_i) }
shilist.length.times{|n| shilist[n].push(n+1)}
#shilist[n]=[県,年,市番号,県ごとの順番]

shilist.sort! do |a, b| 
  (a[0] <=> b[0]).nonzero? || (a[1] <=> b[1])
end
kennum = shilist[0][0]
t=1
kakou = shilist.each{|item|
if item[0] == kennum then
  item.push(t)
  t=t+1
else
  item.push(1)
  t = 2
end
kennum=item[0]
}
kakou.sort!{ |a, b| a[2] <=> b[2] }
kakou.each{|item|
print sprintf("%06d",item[0]),sprintf("%06d",item[3]),"\n"
}

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

int gcd(int x, int y);

const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/


int main() {
    ll n;
    cin >> n;
    vector<ll> l(n + 1);

    l[0] = 2;
    l[1] = 1;
    for (int i = 2; i <= n; i++) {
        l[i] = l[i - 2] + l[i - 1];
    }
    

    cout << l[n] << endl;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

Measured memory_bytes: 256
function main(input: string) {
  let [sa, sb, sc] = input.split("\n").map((str: string) => str.split(""));
  let player: string = "a";
  while (1) {
    if (player === "a") {
      if (sa.length < 1) {
        console.log("A");
        break;
      }
      player = sa.shift();
      continue;
    }
    if (player === "b") {
      if (sb.length < 1) {
        console.log("B");
        break;
      }
      player = sb.shift();
      continue;
    }
    if (player === "c") {
      if (sc.length < 1) {
        console.log("C");
        break;
      }
      player = sc.shift();
      continue;
    }
  }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
class Unionfind:
  def __init__(self,n):
    self.Tree=[i for i in range(n)]
    self.rank=[0]*n
    self.size=[1]*n

  def find(self,x):
    if x==self.Tree[x]:
      return x
    else:
      root=self.find(self.Tree[x])
      self.Tree[x]=root
      return root

  def unite(self,x,y):
    s1=self.find(x)
    s2=self.find(y)
    if s1==s2:
      return 0
    else:
      res=self.size[s1]*self.size[s2]
      self.size[s1],self.size[s2]=self.size[s1]+self.size[s2],self.size[s1]+self.size[s2]
      if self.rank[s1]>self.rank[s2]:
        self.Tree[s2]=s1
      elif self.rank[s1]<self.rank[s2]:
        self.Tree[s1]=s2
      else:
        self.Tree[s2]=s1
        self.rank[s1]+=1
      return res
N,M=map(int,input().split())
uf=Unionfind(N)
ans=[N*(N-1)//2]
edges=[[int(i)-1 for i in input().split()] for i in range(M)]
for e in edges[::-1]:
  ans.append(ans[-1]-uf.unite(e[0],e[1]))
  
ans.reverse()
for a in ans[1:]:
  print(a)
        

Measured memory_bytes: 96928
#include<stdio.h>
int main(){
  char s[100010];
  int i,n,a=1;
  scanf("%s",s);
  for(n=0;s[n];n++);
  for(i=0;i<n-1;i++){
    if(s[i]-s[n-i-2])goto END;
  }
  if(s[0]=='0'||s[n-1]=='1')goto END;
  for(i=0;i<n-1;i++){
    printf("%d %d\n",a,i+2);
    if(s[i]=='1')a=i+2;
  }
  return 0;
 END:;
  printf("-1\n");
  return 0;
}
		   


Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main()
{
	char a[7];
	int i;
	for(i=1;i<=6;i++)
 	{
 		cin>>a[i];
		 }	
		 if(a[3]==a[4]&&a[5]==a[6])
		 cout<<"Yes"<<endl;
		 else
		 cout<<"No"<<endl;
		 } 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	int n;
	int s[];
	int q;
	int t[];
	public static void main(String args[]) {
		new Main().run();
	}
	Main() {
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt();
		s = new int[n];
		for (int i = 0; i < n; i++) {
			s[i] = scan.nextInt();
		}
		q = scan.nextInt();
		t = new int[n];
		for (int i = 0; i < q; i++) {
			t[i] = scan.nextInt();
		}
		scan.close();
	}
	public void run() {
		int cnt = 0;
		for (int j = 0; j < q; j++) {
			for (int i = 0; i < n; i++) {
				if(s[i] == t[j]) {
					cnt++;
					break;
				}
			}
		}
		System.out.println(cnt);
	}
}



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

int main(){
	int a, b;
	cin >> a >> b;

	if(a == b){
		cout << "Draw";
	}else if(a > b){
		if(b == 1){
			cout << "Bob";
		}else{
			cout << "Alice";
		}
	}else{
		if(a == 1){
			cout << "Alice";
		}else{
			cout << "Bob";
		}
	}
	cout << endl;
	return 0;
}

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

using namespace std;

#define	MIN(X, Y)	X < Y ? X : Y

struct SET{
	int pen_n;
	int yen;
};

int main()
{
	int N;
	SET X, Y;
	int x_n, y_n;
	int ans;

	cin >> N >> X.pen_n >> X.yen >> Y.pen_n >> Y.yen;

	x_n = N / X.pen_n;
	if(N % X.pen_n)
		x_n++;

	y_n = N / Y.pen_n;
	if(N % Y.pen_n)
		y_n++;

	ans = MIN(x_n * X.yen, y_n * Y.yen);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
using namespace std;


int main(){
	int tnk[5]={5,7,5,7,7};
	int n;
	while(cin>>n,n){
		string s[40];
		int snum=0,now=0,ans=1;
		REP(i,0,n){
			cin>>s[i];
		}
		int j=0;
		while(1){
			snum+=s[j].size();
			j++;
			if(snum==tnk[now]){
				snum=0;
				now++;
			}else if(snum>tnk[now]){
				snum=0;
				now=0;
				j=ans;
				ans++;
			}
			if(now==5){
				p(ans);
				break;
			}

		}
	}
	return 0;
}

Measured memory_bytes: 3156
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
n = gets.chomp.to_i

ans = ''
while n > 0
  ans += ('a'.ord + (n-1) % 26).chr
  n = (n-1) / 26
end
puts ans.reverse

Measured memory_bytes: 14688
// Author: Tyler Wang

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

using namespace std;

template <class Fun>
class y_combinator_result {
 public:
  template <class T>
  explicit y_combinator_result(T&& fun) : fun_(std::forward<T>(fun)) {}

  template <class... Args>
  decltype(auto) operator()(Args&&... args) {
    return fun_(std::ref(*this), std::forward<Args>(args)...);
  }

 private:
  Fun fun_;
};

template <class Fun>
decltype(auto) y_combinator(Fun&& fun) {
  return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.precision(12);
  std::cerr.precision(12);
  std::mt19937 rng((std::uint_fast32_t)std::chrono::high_resolution_clock::now()
                       .time_since_epoch()
                       .count());
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<long long> pref(n + 1);
  for (int i = 0; i < n; ++i) {
    pref[i + 1] = pref[i] + a[i];
  }
  constexpr long long INF = 1e18;
  vector<vector<long long>> dp(n, vector<long long>(n, INF));
  auto solve = y_combinator([&](auto self, int l, int r) -> long long {
    if (dp[l][r] != INF) {
      return dp[l][r];
    }
    if (l == r) {
      return dp[l][r] = 0;
    }
    for (int i = l; i < r; ++i) {
      dp[l][r] = min(dp[l][r], self(l, i) + self(i + 1, r));
    }
    return dp[l][r] += pref[r + 1] - pref[l];
  });
  cout << solve(0, n - 1) << '\n';
  return 0;
}

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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const char ch[] = "hi";

int n;
char s[15];

void solve() {
	n = readStr(s);
	if (n & 1) {
		printStr("No");
		return;
	}
	for (int i = 0; i < n; ++i) {
		if (s[i] != ch[i % 2]) {
			printStr("No");
			return;
		}
	}
	printStr("Yes");
}

int main() {
	int T = 1;
	// read(T);
	while (T--) {
		solve();
	}
}


Measured memory_bytes: 3604
import java.util.*;
public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    double[] data = new double[1000];
    int v;
    double temp;
    double lenkin;

    for(int i = 0;i<N;i++){

      v  = sc.nextInt();

      data[i]=v;

    }

    for(int i = 0;i<N;i++){
      for(int j = i+1;j<N;j++){
        if(data[i]>data[j]){
          temp = data[i];
          data[i]=data[j];
          data[j]=temp;
        }
      }
    }

    lenkin = (data[0]+data[1])/2;

    for(int i = 2;i<N;i++){
      lenkin = (lenkin+data[i])/2;

    }

    System.out.println(lenkin);

  }
}


Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <climits>
#define endl "\n"
#define ll long long
using namespace std;

int main()
{
    int k;
    int a, b;
    cin >> k;
    cin >> a >> b;

    for(int i = a; i <= b; i ++)
    {
    	if(i % k == 0)
    	{
    		cout << "OK" << endl;
    		return 0;
    	}
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
#define fio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
// #define double long double
// #define mp make_pair
// #define pb push_back
// Upper case English alphabet to lower case ch |= ' ';
// Lower case English alphabet to upper case ch &= '_’ ;
//__builtin_popcount(x)

int INF=(int)1e18+1,t=-1,till=0;
int gcd(int a, int b) { return b!=0 ? gcd(b, a % b) : a; }
// int digits(int n){return floor(log10(n))+1 ;}
// bool ispoweroftwo (int x) { return x && (!(x&(x-1))); }
//vector<int> vis,parent,ti,tout,dis;
vector<vector<int> > adj;
map<int,int> vis;
// vector<int> row={-1,1,0,0};
// vector<int> col={0,0,-1,1};
// //map<pair<int,int>,int> dp;
// int n=1;
// int th=0;
vector<int> dp;

void dfs(int v){
    vis[v]=1;
    for(int x:adj[v]){
        if(!vis[x])
            dfs(x);
        dp[v]=max(dp[v],1+dp[x]);
    }
}




signed main(){
    fio;
    int n,m;
    cin>>n>>m;
    adj.resize(n);
    vector<pair<int,int> >  deg(n);
    for(int i=0;i<n;i++) deg[i]={0,i};
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        x--;y--;
        adj[x].push_back(y);
        deg[y].first++;
    }
    int ans=-1;
    dp.resize(n,0);
    for(int i=0;i<n;i++){
        if(!vis[i]) dfs(i);
    }
    for(int i=0;i<n;i++) ans=max(dp[i],ans);
    cout<<ans<<endl;


}


Measured memory_bytes: 18432
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

template <typename T>
class Dijkstra {
    struct edge { int to; T cost; };
    typedef pair<T, int> P; // <最短距離, 頂点番号>

private:
    int m_V;
    vector<vector<edge> > m_G;
public:
    const T INF = std::numeric_limits<T>::max();
    vector<int> m_prev_path; // 最短パスを辿るため

    Dijkstra(int V) : m_V(V) {
        m_G.resize(m_V);
    }

    // a -> bに片方向のエッジを張る
    void add_dir_edge(int a, int b, T cost) {
        m_G[a].push_back( edge{ b, cost } );
    }

    // a <-> bに両方向のエッジを張る
    void add_undir_edge(int a, int b, T cost) {
        add_dir_edge(a, b, cost);
        add_dir_edge(b, a, cost);
    }

    // 頂点sから各頂点までの距離を計算して返す
    vector<T> shortest_path(int s) {
        m_prev_path.clear(); m_prev_path.resize(m_V, -1);

        vector<T> d(m_V, INF);
        priority_queue<P, vector<P>, greater<P> > que;
        d[s] = 0;
        que.push(P(0, s));

        while(!que.empty()) {
            P p = que.top();
            que.pop();

            auto dist = p.first;
            auto v = p.second;
            if (d[v] < dist) continue;
            REP(i, m_G[v].size()) {
                edge e = m_G[v][i];
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    que.push(P(d[e.to], e.to));
                    m_prev_path[e.to] = v;
                }
            }
        }

        return d;
    }

    // shortest_path()が呼ばれた後に呼ばれることを期待する
    // s -> v1 -> v2 -> v3 -> t の場合、{s, v1, v2, v3, t} からなるvectorを返す
    vector<int> get_path(int t)
    {
        vector<int> path;
        for(; t != -1; t = m_prev_path[t]) path.push_back(t);
        reverse(ALL(path));
        return path;
    }

};

struct Path {
    ll u;
    ll v;
    ll a;
    ll b;
};

int main(void)
{
    cin.sync_with_stdio(false);
    ll N, M, S, T;
    cin >> N >> M >> S >> T;
    --S; --T;
    vector<Path> paths(M);

    Dijkstra<ll> way1(N);
    Dijkstra<ll> way2(N);

    REP(m, M) {
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        --u; --v;
        paths[m] = Path{u, v, a, b};
        way1.add_undir_edge(u, v, a);
        way2.add_undir_edge(u, v, b);
    }

    auto costs1 = way1.shortest_path(S);
    auto costs2 = way2.shortest_path(T);

    ll best = 1e18;
    vector<ll> ans(N);
    for(int i = N-1; i >= 0; --i) {
        best = min(best, costs1[i] + costs2[i]);
        ans[i] = best;
    }

    for(auto a: ans) {
        cout << (ll(1e15) - a) << endl;
    }

    return 0;
}


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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vii = vector<pii>;
using vs = vector<string>;
#define all(x) x.begin(), x.end()
// int di[] = {0, 1, 0, -1};
// int dj[] = {1, 0, -1, 0};
const ll MOD = 1e9 + 7;
const ll INF = 1e9;

vi primeFactorize(int n) {
	vi ret;
	while (n % 2 == 0) {
		ret.push_back(2);
		n /= 2;
	}
	for (ll i = 3; i * i <= n; i += 2)
		while (n % i == 0)
			ret.push_back(i), n /= i;
	if (n > 2) ret.push_back(n);
	return ret;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

	int n; cin >> n;
	unordered_set<int> st;
	bool pairwise = true;
	int g = 0;
	for (int i = 0; i < n; ++i) {
		int a; cin >> a;
		g = __gcd(g, a);
		if (pairwise) {
			vi fact = primeFactorize(a);
			for (auto &j : fact) {
				if (st.find(j) != st.end()) {
					pairwise = false;
					break;
				}
			}
			for (auto &j : fact)
				st.insert(j);
		}
	}

	if (pairwise)
		cout << "pairwise coprime" << endl;
	else if (g == 1)
		cout << "setwise coprime" << endl;
	else
		cout << "not coprime" << endl;
}


Measured memory_bytes: 6656
#include <iostream>

int a, b[100000000],max = 0, min = 999999999;
//std::string b;
int main()
{
	std::cin >> a;
	for(int i = 0; i < a; i++)
	{
		std::cin >> b[a];
		if(b[a] < min)
		{
			min = b[a];
		}
		if(max < b[a])
		{
			max = b[a];
		}
	}
	//std::cout << max << " " <S< min << std::endl; 
	std::cout << max - min << std::endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 500000
#define M 10000
typedef struct{
  int mae,ato,weight;
}Data;
Data hum[N];

void sum();
int num,gum;       
int main(){
  int i,j,beru,xu;
 
  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%d%d",&beru,&xu);
    for(j=0;j<xu;j++){
      
      
      hum[gum].mae=beru;
      scanf("%d%d",&hum[gum].ato,&hum[gum].weight);
      gum++;
     
    }
  }
  sum();
  return 0;
}


void sum(){
  int tum[M];
  int i,flag=1;
  for(i=0;i<num;i++)tum[i]=1000001;
   tum[0]=0;
   while(flag==1){
    flag=0;
    for(i=0;i<gum;i++){
      if(tum[hum[i].mae]==1000001) continue;
      if(tum[hum[i].mae]+hum[i].weight<tum[hum[i].ato]){
	tum[hum[i].ato]=tum[hum[i].mae]+hum[i].weight;
	flag=1;
      }
    
    
    }
  }
  
  for(i=0;i<num;i++){
    if(tum[i]==1000001) printf("%d -1\n",i); 
    else printf("%d %d\n",i,tum[i]);
  }
}




Measured memory_bytes: 7604
#include <cstdio>

using namespace std;

int n, A[50];

int solve(int i, int m) {
    if (m == 0) return 1;
    if (i >= n) return 0;
    int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
    return res;
}

int main() {
    int q, M, i;
    scanf("%d", &n);

    for (int i = 0; i < n; ++i) {
        scanf("%d", &A[i]);
    }
    scanf("%d", &q);
    for (int i = 0; i < q; ++i) {
        scanf("%d", &M);
        if (solve(0, M)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}

Measured memory_bytes: 2560
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

#[allow(unused_macros)]
macro_rules! chmin {
    ( $ x : expr , $ y : expr ) => { if $ x > $ y { $ x = $ y ; true } else { false } };
}

#[allow(unused_macros)]
macro_rules! vec_md {
    ( $ init : expr ; $ ( $ dim : expr ) ;* ) => { vec_md ! ( $ ( $ dim ) ;* => $ init ) };
    ( $ head : expr ; $ ( $ tail : expr ) ;* => $ init : expr ) => { vec ! [ vec_md ! ( $ ( $ tail ) ;* => $ init ) ; $ head ] };
    ( $ head : expr => $ init : expr ) => { vec ! [ $ init ; $ head ] };
}

fn main() {
    input! {
        n: usize,
        a: [u64; n]
    }

    let mut memo = vec_md![None;n+1;n+1];
    for i in 0..n {
        memo[i][i+1] = Some(0);
    }
    let mut s = vec![0u64;n+1];
    for i in 0..n {
        s[i+1] = s[i] + a[i];
    }
    println!("{}", dp(0,n,&mut memo, &s));
}

fn dp(l: usize, r: usize, memo: &mut Vec<Vec<Option<u64>>>, s: &[u64]) -> u64 {
    if let Some(src) = memo[l][r] {
        return src;
    }

    let mut cost = 1u64 << 60;
    for i in l+1..r {
        chmin!(cost, dp(l,i,memo,s) + dp(i,r,memo,s));
    }
    cost += s[r] - s[l];
    memo[l][r] = Some(cost);
    cost
}

Measured memory_bytes: 6396
#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if 1 || defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long,long long> pll; typedef vector<pair<long long,long long> > vpll;
typedef vector<string> vs; typedef long double ld;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

unsigned powmod(unsigned long long a, unsigned long long k, const unsigned MOD) {
	a %= MOD;
	unsigned long long r = MOD == 1 ? 0 : 1;
	while(k) {
		if(k & 1)
			(r *= a) %= MOD;
		(a *= a) %= MOD;
		k >>= 1;
	}
	return (unsigned)r;
}

int vis[10], num[10];
ll sum[11];
int main() {
	ll n; int m, k;
	scanf("%lld%d%d", &n, &m, &k);
	int npowm = powmod(n % 10, m, 10);
	int x = n % 10;
	mset(vis, -1);
	ll ans = 0;
	sum[0] = 0;
	rep(i, k) {
		if(vis[x] != -1) {
			int head = vis[x], cycle = i - head;
			int reps = (k - i) / cycle;
			ans += (ll)reps * (sum[i] - sum[head]);
			i += reps * cycle;
			for(; i < k; i ++)
				ans += num[head + (i - head) % cycle];
			break;
		}
		vis[x] = i;
		num[i] = x;
		ans += x;
		sum[i+1] = ans;
		x = x * npowm % 10;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1192
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def MI() : return map(int, input().split())
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 chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

N = I()
S = input()

def Z_alg(s):
    n = len(s)
    z = [0]*n
    z[0] = n

    L = 0
    R = 0
    for i in range(1, n):
        if(i >= R):  # 過去の結果が全く使えない
            L = i
            R = i
            while(R < n and s[R-L] == s[R]):
                R += 1
            z[i] = R-L
        elif(z[i-L] < R-i):  # 過去の結果が全て使える
            z[i] = z[i-L]
        else:  # 過去の結果が一部使える
            L = i
            while(R < n and s[R-L] == s[R]):
                R += 1
            z[i] = R-L

    return z

ans = 0
for i in range(N):
    z = Z_alg(S[i:])
    
    for j, l in enumerate(z):
        ans = max(ans, min(j, l))

print(ans)


Measured memory_bytes: 54876
#include <cstdint>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main() {
  size_t N;
  std::cin >> N;

  std::vector<int> freq(26);
  for (size_t i = 0; i < N; ++i) {
    std::string S;
    std::cin >> S;
    ++freq[S[0]-'A'];
  }

  using namespace std::string_literals;
  std::vector<intmax_t> march;
  for (int i: "MARCH"s)
    march.push_back(freq[i-'A']);

  intmax_t res = 0;
  res += march[0] * march[1] * march[2];
  res += march[0] * march[1] * march[3];
  res += march[0] * march[1] * march[4];
  res += march[0] * march[2] * march[3];
  res += march[0] * march[2] * march[4];
  res += march[0] * march[3] * march[4];
  res += march[1] * march[2] * march[3];
  res += march[1] * march[2] * march[4];
  res += march[1] * march[3] * march[4];
  res += march[2] * march[3] * march[4];

  std::cout << res << std::endl;
}

Measured memory_bytes: 888
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 3e5 + 5 ;
const ll inf = 1e17 ;
using namespace std ;

int n, st[N] ;
ll sum[N], L[N], R[N], f[N], dp[N], tmp[N] ;

ll g(int x) {
	return 2LL * f[x] + 2LL * sum[x] + (ll) x * x - x ;
}

void pre() {
	rep(i, 1, n) sum[i] += sum[i - 1] ;
	int top = 1 ; st[1] = 0 ;
	rep(i, 1, n) {
		for ( ; top > 1 && 2LL * i * (st[top] - st[top - 1]) >= g(st[top]) - g(st[top - 1]) ; -- top) ;
		f[i] = f[st[top]] + (ll) (i - st[top]) * (i - st[top] + 1) / 2 - sum[i] + sum[st[top]] ;
		f[i] = max(f[i], f[i - 1]) ;
		for ( ; top > 1 && (g(i) - g(st[top])) * (st[top] - st[top - 1]) >= (g(st[top]) - g(st[top - 1])) * (i - st[top]) ; -- top) ;
		st[++ top] = i ;
	}
	for (int i = n ; i; -- i) sum[i] -= sum[i - 1] ;
}

void solve(int l, int r, int c) {
	if (l == r) {
		dp[c ? n - l + 1 : l] = max(dp[c ? n - l + 1 : l], L[l - 1] + R[r + 1] + 1LL - sum[l] + sum[l - 1]) ;
		return ;
	}
	int mid = (l + r - 1) / 2, top = 1 ; st[1] = l - 1 ;
	rep(i, l, mid - 1) {
		for ( ; top > 1 && (g(i) - g(st[top])) * (st[top] - st[top - 1]) >= (g(st[top]) - g(st[top - 1])) * (i - st[top]) ; -- top) ;
		st[++ top] = i ;
	}
	rep(i, mid + 1, r) {
		for ( ; top > 1 && 2LL * i * (st[top] - st[top - 1]) >= g(st[top]) - g(st[top - 1]) ; -- top) ;
		tmp[i] = f[st[top]] + (ll) (i - st[top]) * (i - st[top] + 1) / 2 - sum[i] + sum[st[top]] + R[i + 1];
	}
	for (int i = r - 1 ; i >= mid + 1 ; i --) tmp[i] = max(tmp[i], tmp[i + 1]) ;
	rep(i, mid + 1, r) dp[c ? n - i + 1 : i] = max(dp[c ? n - i + 1 : i], tmp[i]) ;
	solve(l, mid, c), solve(mid + 1, r, c) ;
}

void _() {
	rep(i, 1, n) tmp[i] = L[i] ;
	rep(i, 1, n) L[i] = R[i] ;
	rep(i, 1, n) R[i] = tmp[i] ;
	reverse(L + 1, L + n + 1) ;
	reverse(R + 1, R + n + 1) ;
	reverse(sum + 1, sum + n + 1) ;
}

int main() {
	scanf("%d", &n) ;
	rep(i, 1, n) scanf("%lld", &sum[i]) ;
	pre() ; rep(i, 1, n) L[i] = f[i] ;
	reverse(sum + 1, sum + n + 1) ; pre() ; rep(i, 1, n) R[n - i + 1] = f[i] ;
	reverse(sum + 1, sum + n + 1) ;
	rep(i, 1, n) dp[i] = - inf, sum[i] += sum[i - 1], f[i] = L[i] ;
	solve(1, n, 0) ;
	for (int i = n; i; -- i) sum[i] -= sum[i - 1] ;
	_() ; rep(i, 1, n) sum[i] += sum[i - 1], f[i] = L[i] ; 
	solve(1, n, 1) ;
	for (int i = n; i; -- i) sum[i] -= sum[i - 1] ; _() ;
	int T, x, y ;
	scanf("%d", &T) ;
	rep(cas, 1, T) {
		scanf("%d%d", &x, &y) ;
		printf("%lld\n", max(L[x - 1] + R[x + 1], dp[x] - y + sum[x])) ;
	}
	return 0 ;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0;}
template<class T>bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0;}

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:

const int limit = 5010;

const ll inf = 1LL << 50;
ll dp[limit];



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

	using tll = tuple<ll, ll, ll>;
	vector<tll> ary;

	rep(i, n) {
		ll h, p;
		cin >> h >> p;
		ary.push_back(tll(p + h, p, h));
	}

	sort(begin(ary), end(ary));
	rep(i, limit) dp[i] = inf;
	dp[0] = 0LL;

	for (auto &elem : ary) {
		ll ph, p, h;
		tie(ph, p, h) = elem;
		rrep(i, n)  if (dp[i] <= h) chmin(dp[i + 1], dp[i] + p);
	}

	int ans = 0;
	rep(i, n + 1) if (dp[i] < inf) ans = i;
	cout <<  ans << endl;

	return 0;
}

Measured memory_bytes: 576
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
long long n, m, q;
long long a[101000], b[101000];
long long solve( long long x, long long s[], int a ){
	int i = upper_bound(s, s+a, x) - s;
	long long res = 0x3f3f3f3f3f3f3f3f;
	if( i < a )
		res = min(res, s[i] - x);
	if( i > 0 )
		res = min(res, x - s[i-1]);
	return res;
}
long long solve( long long x, long long s[], long long a, long long t[], long long b ){
	int i = upper_bound(s, s+a, x) - s;
	long long res = 0x3f3f3f3f3f3f3f3f;
	if( i < a )
		res = min(res, s[i] - x + solve(s[i], t, b));
	if( i > 0 )
		res = min(res, x - s[i-1] + solve(s[i-1], t, b));
	return res;
}
int main(){
	scanf("%lld%lld%lld", &n, &m, &q);
	for( int i = 0; i < n; ++i )
		scanf("%lld", &a[i]);
	for( int j = 0; j < m; ++j )
		scanf("%lld", &b[j]);
	a[n] = b[m] = 0x3f3f3f3f3f3f3f3f;
	while( q-- ){
		long long x;
		scanf("%lld", &x);
		printf("%lld\n", min(solve(x, a, n, b, m), solve(x, b, m, a, n)));
	}
	return 0;
}

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

using namespace std;

const int N = 200 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n;
int x[N];

bool read() {
    if (!(cin >> n))
        return false;

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

    return true;
}

void solve() {
    auto ans = 1ll;
    auto pr = 0;

    for (int i = 0; i < n; ++i) {
        x[i] = (i == 0 ? 1 : min(x[i], x[i - 1] + 2));

        if (x[i] == x[i + 1] - 1) {
            ans = ans * (pr + 2) % MOD;
            x[i] = (i == 0 ? -1 : x[i - 1]);
        } else {
            ++pr;
        }
    }

    for (; pr > 0; --pr)
        ans = ans * pr % MOD;

    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

#define F first
#define S second
typedef pair<int, int> Pii;

int main() {
  int m, n;
  while(cin >> m && m) {
    vector<Pii> M;
    for(int i=0; i<m; i++) {
      int x, y; cin >> x >> y;
      M.push_back(Pii(x, y));
    }
    cin >> n;
    set<Pii> st;
    vector<Pii> N;
    for(int i=0; i<n; i++) {
      int x, y; cin >> x >> y;
      N.push_back(Pii(x, y));
      st.insert(Pii(x, y));
    }
    
    for(int i=0; i<n; i++) {
      int mvX = N[i].F - M[0].F;
      int mvY = N[i].S - M[0].S;
      bool ok = true;
      for(int j=1; j<m; j++) {
        ok = ok && st.count(Pii(M[j].F+mvX, M[j].S+mvY));
      }
      if(ok) {
        cout << mvX << " " << mvY << endl;
        goto EXIT;
      }
    }
  EXIT:;
  }
  return 0;
}

Measured memory_bytes: 1260
// Vicfred
// https://atcoder.jp/contests/abc048/tasks/arc064_a
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main() {
    long n, x;
    readf("%s %s\n", &n, &x);

    long[] as = readln.split.map!(to!long).array;

    long ans = 0;
    for(int i = 0; i + 1 < n; i++) {
        if(as[i] + as[i + 1] > x) {
            if(as[i] > x) {
                ans += as[i] - x;
                ans += as[i + 1];
                as[i] = x;
                as[i + 1] = 0;
            } else {
                ans += as[i + 1] + as[i] - x;
                as[i + 1] = x - as[i];
            }
        }
    }
    ans.writeln;
}



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

using namespace std;

int main() {
	int a, b, k;
	cin >> k >> a >> b;
	for (int i=a; i<=b; i++) {
		if (i % k == 0)	{
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	return 0;
}

Measured memory_bytes: 3132
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

def div(n): 
    div = [0 for i in range(n + 1)] 
    for i in range(1,n+1): 
        for j in range(i,n+1,i): 
            div[j] += 1
    return div

n = inp()
x = div(n)
ans = 0
for i in range(1,n+1):
    ans += i*x[i]
print(ans)


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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int n;
	cin >> n;
	int cnt = 0;
	for (int i = 1; i <= n; ++i) {
		if (to_string(i).size() % 2 != 0) cnt++;
	}
	cout << cnt << '\n';
	return 0;
}

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

using namespace std;

#define ll long long

const int mxN = 103;
const int mxK = 1e5 + 5;
const ll mo = 1e9 + 7;

int n, k;
int dp[mxK], val[mxK];
int a[mxN];

int add(int x, int y) {
    ll k=x+y;
    while (k<0) 
        k+=mo;
    return (1ll * k) % mo;
}
int add2(int x, int y) {
    while (x+y<0)
        y+=mo;
    return (1ll * (x + y)) % mo;
}

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

    cin >> n >> k;

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

    val[0] = 1;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= k; j++) {
            dp[j] = 0;
        }
        for (int j = 0; j <= k; j++) {
            dp[j] = add(dp[j], val[j]);
            if (j + a[i] + 1 <= k) {
                dp[j + a[i] + 1] = add(dp[j + a[i] + 1], -val[j]);
            }
        }
        for (int j = 1; j <= k; j++) {
            val[j] = add(val[j - 1], dp[j]);
        }
        //for (int j = 0; j <= k; j++) { cout << val[j] << ' '; } cout << endl;
    }


    cout << val[k] << endl;
}


Measured memory_bytes: 1024
from sys import stdin
import sys
sys.setrecursionlimit(10**8)

def nextLine(): return next(stdin)
def nextStrList(): return nextLine().split()
def nextIntList(): return [int(_) for _ in nextStrList()]


def main():
	n,m=nextIntList()
	aList=nextIntList()
	s=sum(aList)
	th=s/4/m
	
	count=0
	for a in aList:
		if a>=th:
			count+=1
	
	if count>=m:
		print("Yes")
	else:
		print("No")


if __name__=="__main__":
	main()


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

int main() {
  int n;
  cin >> n;
  vector<double> v(n);
  rep(i, n) cin >> v[i];

  sort(v.begin(), v.end());
  double now = v[0];
  for (int i = 1; i < n; ++i) now = (now + v[i]) / 2;
  printf("%.6f\n", now);
  return 0;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  double ans = 0;
  for(int i = 1; i <= N; ++i){
    double p = 1./N;
    if(i >= K){
      ans += p;
      continue;
    }
    int t = i;
    while(t < K) t *= 2, p /= 2;
    ans += p;
  }
  printf("%.12f\n",ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define N 131072
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
int mod=1e6+3;
LL f_pow(LL a,LL b){
    LL res=1,temp=a;
    while(b){
        if(b&1)res=res*temp%mod;
        temp=temp*temp%mod;
        b>>=1;
    }
    return res;
}
LL fra[1000005];
LL rev[1000005];
void build(){
    fra[0]=1;
    for(int i = 1;i<1000003;i++)
        fra[i]=fra[i-1]*i%mod;
    rev[1000002]=f_pow(fra[1000002],mod-2);
    for(int i = 1000001;i>=0;i--)
    rev[i]=rev[i+1]*(i+1)%mod;
    //printf("%lld %lld\n",rev[1000004],rev[1000003]);
}
int main(){
    build();
    int q;
    scanf("%d",&q);
    while(q--){
        LL x,d,n;
        scanf("%lld %lld %lld",&x,&d,&n);
        if(x==0){
            printf("0\n");
            continue;
        }
        if(d==0){
            printf("%lld\n",f_pow(x,n));
            continue;
        }
        x = x*f_pow(d,mod-2)%mod;
        int l=x,r=x+n-1;
        //printf("%lld %lld\n",l,r);
        if(r>=mod){
            printf("0\n");
        }
        else{
           // printf("%lld %lld\n",fra[r],rev[l-1]);
            printf("%lld\n",fra[r]*rev[l-1]%mod*f_pow(d,n)%mod);
        }
    }
}
/*
1 4 2 3
1 3 6 12
k(a+b) = a*b;
k*a+k*b = a*b;
b= (k*a)/(a-k);

k*(k+i)/i
*/

Measured memory_bytes: 16512
/* All men have limits. They learn what they are and learn
   not to exceed them, I ignore mine. -Batman           */
#include <bits/stdc++.h>
//#include <iostream>
//#include <vector>
//#include <Windows.h>
using namespace std;

int main(){
long long int a,b,gg;
while(cin>>a>>b){
	gg=a+b;
	gg=log10(gg)+1;
	cout<<gg<<endl;
}

return 0;
}

Measured memory_bytes: 3232
#include<stdio.h>

int main()
{
   int a,b,flag;
   char  c;

   for(;;)
   {
       flag=0;
       scanf("%d %c %d", &a,&c,&b);
       switch(c)
       {
       case '+':
        printf("%d\n",a+b);
        break;
         case '-':
        printf("%d\n",a-b);
        break;
         case '*':
        printf("%d\n",a*b);
        break;
         case '/':
             if(b==0)
              printf("0\n");
                else
        printf("%d\n",a/b);
        break;
         default:
             flag=1;
       }
       if(flag==1)
        break;
   }

}



Measured memory_bytes: 2068
n = int(input())
a = []
says = []
maxcnt = 0

for i in range(n):
    ai = int(input())
    says.append([])
    for j in range(ai):
        says[i].append(list(map(int, input().split())))
for bit in range(2**n):
    case = list(map(int, format(bit, "0%sb" % n)))
    truthes = []
    liers = []
    match = True
    for i, truth in enumerate(case):
        if truth == 1:
            truthes.append(i+1)
        else:
            liers.append(i+1)
    for i, truth in enumerate(case):
        if truth == 1:
            for say in says[i]:
                if say[1] == 1:
                    if say[0] in liers:
                        match = False
                        break
                else:
                    if say[0] in truthes:
                        match = False
                        break
    # print(truthes, liers, match)
    if match:
        maxcnt = max(maxcnt, len(truthes))
print(maxcnt)

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

int main()
{
    char s[3];
    scanf("%s", s);
    int sum = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == '1') {
            sum++;
        }
    }
    printf("%d", sum);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
 
const int maxn = 0;
vector < vector < int > > v;
 
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(NULL);
	v.resize(50);
	string z;
	cin >> z;
	for(int i=0;i<z.size();i++) v[z[i]-'a'].push_back(i);
	for(int i=0;i<26;i++)
	{
		int one = 0;
		int two = v[i].size() - 1;
		while(two > one)
		{
			if(two - one + 1 > (v[i][two] - v[i][one] + 1) / 2)
			{
				cout << v[i][one] + 1 << " " << v[i][two] + 1;
				return 0;
			}
			if(v[i][one + 1] - v[i][one] > v[i][two] - v[i][two - 1]) one++;
			else two--;
		}
	}
	cout << -1 << " " << -1;
}

Measured memory_bytes: 1104
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int ans = 0;
    if (a <= c) {
        if (d <= b) ans = d-c;
        else ans = max(0,b-c);
    } else {
        if (b <= d) ans = b-a;
        else ans = max(0,d-a);
    }

    cout << ans << endl;

    return 0;
}

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

void fnInput(string& rsColor)
{
  int nColorSiz;
  cin >> nColorSiz >> rsColor;
}

int fnColorCount(string sColor)
{
  int nColorCnt = 0;
  int nBgn = 0;

  while (nBgn < sColor.size())
  {
    int nFoward = nBgn + 1;

    while ( nFoward < sColor.size()  &&
            sColor[nBgn] == sColor[nFoward] )
      nFoward++;

    nColorCnt++;
    nBgn = nFoward;
  }
  return nColorCnt;
}

int main()
{
  string sColor;

  fnInput(sColor);
  cout << fnColorCount(sColor) << endl;

  return 0;
}

Measured memory_bytes: 512
def main():
    import os

    INF = 10 ** 9 + 10

    D = int(input())
    *C, = map(int, input().split())
    # C[type]
    # sum(ci*(d-last(d,i) for ci in C)だけ下がる
    S = [[int(x) for x in input().split()] for _ in range(D)]
    # S[day][type]:=happiness

    last = [-1] * 26

    def diff(d, t):
        ret = S[d][t]
        ret -= sum(ci * (d - last[i]) for i, ci in enumerate(C) if i != t)
        if d != D - 1:
            ret -= sum(ci * (d + 1 - last[i]) for i, ci in enumerate(C) if i != t)
        ret -= C[t]
        return ret

    T = []
    score = 0
    for d in range(D):
        delta = -INF
        take_t = -1
        for t_ in range(26):
            buf = diff(d, t_)
            if delta < buf:
                delta = buf
                take_t = t_
            elif delta == buf and C[t_] > C[take_t]:
                delta = buf
                take_t = t_

        last[take_t] = d
        score += buf
        T.append(take_t + 1)
    print(*T, sep='\n')
    # print(os.path.join(os.path.dirname(__file__), 'output_file.txt'))
    # with open(file=os.path.join(os.path.dirname(__file__), 'output_file.txt'), mode='w', encoding='utf-8') as f:
    #     for t in map(str, T):
    #         f.write(t)
    #         f.write('\n')

    # print(score)


if __name__ == '__main__':
    main()


Measured memory_bytes: 70176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int n;
    cin >> n;
    int a[n - 1], ans[n] = {};
    rep(i, 0, n - 1) {
        cin >> a[i];
        ans[--a[i]]++;
    }
    rep(i, 0, n) { cout << ans[i] << "\n"; }
}


Measured memory_bytes: 6756
#include<stdio.h>
#include<math.h>
int main(){
    double i,j,k,l,r;
    scanf("%lf %lf",&i,&j);
    k = i * j;
    if(i<j){
        l = i;
        i = j;
        j = l;
    }
    r=fmod(i,j);
    while(r != 0){
        i=j;
        j=r;
        r=fmod(i,j);
    }
    printf("%.0f",k/j);


}

Measured memory_bytes: 128