akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>
#include <queue>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

template <class T = int>
class Dinic {
public:
	struct Edge {
		Edge(int a, T b){to = a;cap = b;}
		int to;
		T cap;
	};

	Dinic(int _n) : n(_n) {
		edges.resize(n);
	}

	T maxFlow(int src, int sink) {
		T ans = 0;
		while(bfs(src, sink)) {
			T flow;
			pt = std::vector<int>(n, 0);
			while((flow = dfs(src, sink))) {
				ans += flow;
			}
		}
		return ans;
	}

	void addEdge(int from, int to, T cap = 1) {
		edges[from].push_back(list.size());
		list.push_back(Edge(to, cap));
		edges[to].push_back(list.size());
		list.push_back(Edge(from, 0));
	}
private:
	int n;
	std::vector<std::vector<int> > edges;
	std::vector<Edge> list;
	std::vector<int> h, pt;

	T dfs(int on, int sink, T flow = 1e9) {
		if(flow == 0) {
			return 0;
		} if(on == sink) {
			return flow;
		}
		for(; pt[on] < (int) edges[on].size(); pt[on]++) {
			int cur = edges[on][pt[on]];
			if(h[on] + 1 != h[list[cur].to]) {
				continue;
			}
			T got = dfs(list[cur].to, sink, std::min(flow, list[cur].cap));
			if(got) {
				list[cur].cap -= got;
				list[cur ^ 1].cap += got;
				return got;
			}
		}
		return 0;
	}

	bool bfs(int src, int sink) {
		h = std::vector<int>(n, n);
		h[src] = 0;
		std::queue<int> q;
		q.push(src);
		while(!q.empty()) {
			int on = q.front();
			q.pop();
			for(auto a : edges[on]) {
				if(list[a].cap == 0) {
					continue;
				}
				int to = list[a].to;
				if(h[to] > h[on] + 1) {
					h[to] = h[on] + 1;
					q.push(to);
				}
			}
		}
		return h[sink] < n;
	}
};


int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	const int ms = 10010000;
	std::vector<bool> prime(ms, true);
	prime[0] = prime[1] = false;
	for(int i = 2; i < ms; i++) {
		if(!prime[i]) continue;
		for(int j = i+i; j < ms; j += i) {
			prime[j] = false;
		}
	}
	prime[2] = false;
	std::vector<int> a(ms, 0);
	int n;
	std::cin >> n;
	for(int i = 0; i < n; i++) {
		int x;
		std::cin >> x;
		a[x] ^= 1;
		a[x+1] ^= 1;
	}
	std::vector<int> b;
	int f[2] = {0, 0};
	for(int i = 1; i < ms; i++) {
		if(a[i]) {
			b.push_back(i);
			f[i%2]++;
		}
	}
	n = (int) b.size();
	Dinic<int> graph(n+2);
	int src = n, sink = n+1;
	for(int i = 0; i < n; i++) {
		if(b[i] % 2 == 0) graph.addEdge(src, i, 1);
		else graph.addEdge(i, sink, 1);
		for(int j = 0; j < n; j++) {
			if(prime[abs(b[i] - b[j])] && b[i] % 2 == 0) {
				graph.addEdge(i, j, 1);
			}
		}
	}
	int got = graph.maxFlow(src, sink);
	f[0] -= got;
	f[1] -= got;
	int ans = got + f[0] / 2 * 2 + f[1] / 2 * 2;
	f[0] %= 2;
	f[1] %= 2;
	ans += f[0] * 3;
	assert(f[0] == f[1]);
	std::cout << ans << '\n';
}

Measured memory_bytes: 40832
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

template <typename T>
struct BIT
{
    int n;
    vector<T> bit;
    //1-indexed
    BIT() : n(-1) {}
    BIT(int n_, T d) : n(n_), bit(n_ + 1, d) {}

    T sum(int i)
    {
        T s = bit[0];
        for (int x = i; x > 0; x -= (x & -x))
            s += bit[x];
        return s;
    }
    void add(int i, T a)
    {
        if (i == 0)
            return;
        for (int x = i; x <= n; x += (x & -x))
            bit[x] += a;
    }
};

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

    int n, k;
    cin >> n >> k;
    int sum = 0;
    vector<P> v;
    v.push_back(P(sum, 1));
    rep(i, n)
    {
        int a;
        cin >> a;
        a -= k;
        sum += a;
        v.push_back(P(sum, i + 2));
    }
    sort(all(v));
    int ans = 0;
    BIT<int> bit(n + 2, 0);
    rep(i, n + 1)
    {
        int p = v[i].second;
        ans += bit.sum(p);
        bit.add(p, 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6512
import java.util.LinkedList;
import java.util.Scanner;

//Chain
public class Main{

	class R{
		int c, len;
		public R(int c, int len) {
			this.c = c;
			this.len = len;
		}
	}

	int chain(LinkedList<R> l, int s, int t){
		int res = 0;
		int n = l.size();
		while(s>=0&&t<n){
			if(l.get(s).c==l.get(t).c&&l.get(s).len+l.get(t).len>=4){
				res+=l.get(s).len+l.get(t).len;
				s--; t++;
			}
			else break;
		}
		return res;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			LinkedList<R> l = new LinkedList<R>();
			for(int i=0;i<n;i++){
				int c = sc.nextInt();
				if(l.isEmpty()||l.get(l.size()-1).c!=c){
					l.add(new R(c, 1));
				}
				else l.get(l.size()-1).len++;
			}
			int min = n;
			int N = l.size();
			for(int i=0;i<N;i++){
				R r = l.get(i);
				if(i>0){
					if(l.get(i-1).len==3){
						R t = new R(l.get(i-1).c, 1);
						R in = new R(r.c, r.len-1);
						l.remove(i);
						if(in.len>0)l.add(i, in);
						l.add(i, t);
						int L = chain(l, i-1, i);
						min = Math.min(min, n-L);
						l.remove(i);
						if(in.len>0)l.remove(i);
						l.add(i, r);
					}
				}
				if(i+1<N){
					if(l.get(i+1).len==3){
						R t = new R(l.get(i+1).c, 1);
						R in = new R(r.c, r.len-1);
						l.remove(i);
						l.add(i, t);
						if(in.len>0)l.add(i, in);
						int L = chain(l, i, i+1);
						min = Math.min(min, n-L);
						l.remove(i);
						if(in.len>0)l.remove(i);
						l.add(i, r);
					}
				}
				if(i>0&&i+1<N&&r.len==1&&l.get(i-1).c==l.get(i+1).c&&l.get(i-1).len+l.get(i+1).len>=3){
					R in = new R(l.get(i-1).c, l.get(i-1).len+1);
					R pre = l.get(i-1);
					l.remove(i);
					l.remove(i-1);
					l.add(i-1, in);
					int L = chain(l, i-1, i);
					min = Math.min(min, n-L);
					l.remove(i-1);
					l.add(i-1, pre);
					l.add(i, r);
				}
			}
			System.out.println(min);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define fi first
#define se second
using namespace std;


signed main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(m), sc(n, 0);
    rep(i ,0, n) cin >> a[i];
    rep(i, 0, m) cin >> b[i];
    rep(i, 0, m){
        rep(j, 0, n){
            if(a[j] <= b[i]){
                sc[j]++; break;
            }
        }
    }
    int ans, MAX = 0;
    rep(i ,0, n){
        if(sc[i] > MAX){
            MAX = sc[i];
            ans = i;
        }
    }
    cout << ans + 1 << endl;
}

Measured memory_bytes: 1212
def main

  n = gets.chomp.split.map(&:to_i)
  m = n[1]
  a = gets.chomp.split.map(&:to_i).sort.reverse!

  sum = 0
  a.each do |item|
    sum += item
  end

  target = a[m-1]

  limit = (sum.to_f) / (m * 4)

  if target >= limit
    puts "Yes"
  else
    puts "No"
  end
end

main

Measured memory_bytes: 1788
#include<stdio.h>
#define swap( x, y) {int z; z = y; y = x; x = z;}

int main()
{
	int a, b, i = 1;
	
	while(scanf("%d %d", &a ,&b)) 
	{
		if(a == 0 && b == 0)
		{
			break;
		}
		else
		{
			if(a > b)
			{
				swap(a, b);
			}
		}
		
		
		printf("%d %d\n",a,b);
		
	}
	return 0;
}


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

#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(void) {
    int amt = 700;
    string s;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    REP(i, s.length()) {
        if (s[i] == 'o') {
            amt += 100;
        }
    }
    
    cout << amt << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>

double r;

static const double pi = acos(0.0) * 2.0;

double Equivalent(){
	double S = pi * r * r;
	return S;
}

double Perimeter(){
	double L = 2 * r * pi;
	return L;
}

int main(void){
	scanf("%lf", &r);

	double S = Equivalent();
	double L = Perimeter();

	printf("%.5f %.5f\n", S, L);

	return 0;
}

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n,k;
  string s;
  cin >> n >> k >> s;
  rep(i,n){
    if(i==k-1){
      if(s[i]=='A') cout << 'a';
      if(s[i]=='B') cout << 'b';
      if(s[i]=='C') cout << 'c';
    }
    else cout << s[i];
  }
  cout << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100005
#define NIL -1

typedef struct Node{
  int p,l,r;
}Node;

Node T[MAX];
int n,H,D[MAX];

int getDepth(int u){
  int d = 0;
  for(; T[u].p != NIL ;d++) u = T[u].p;
  return d;
}

void print(int u){
  int i, c;
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].p);
  printf("depth = %d, ", D[u]);

  if ( T[u].p == NIL ) printf("root, ");
  else if ( T[u].l == NIL ) printf("leaf, ");
  else printf("internal node, ");
  
  printf("[");
  for(i = 0, c = T[u].l; c != NIL; i++, c = T[c].r){
    if (i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}

main(){
  int i, j, d, v, c, l;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) T[i].p = T[i].l = T[i].r = NIL;
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &v, &d);
    for ( j = 0; j < d; j++ ){
      scanf("%d", &c);
      if ( j == 0 ) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }
  
  H = 0;
  for ( i = 0; i < n; i++ ){
    D[i] = getDepth(i);
    if ( D[i] > H ) H = D[i];
  }
    for ( i = 0; i < n; i++ ) print(i);
  return 0;
}

  



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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back
#define mp make_pair

int main()
{
    ll A, B, C, K;
    cin >> A >> B >> C >> K;

    if(A >= K) _PR(K);
    else if(A+B >= K) _PR(A);
    else if(A+B+C >= K) _PR(A-(K-A-B));

    return 0;
}

/*



*/

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	int n; cin >> n;
	string a,b,c; cin >> a >> b >> c;
	int ans=0;
	for(int i=0;i<a.size();i++){
		if(a[i]==b[i]&&b[i]==c[i]){
			continue;
		}
		else if(a[i]==b[i]||b[i]==c[i]||c[i]==a[i]){
			ans++;
		}
		else{
			ans+=2;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
n=gets.chomp.to_i
d=gets.chomp.split(" ").map{|s| s.to_i}
if d.count(0)!=1 ||d[0]!=0
  p 0
  exit
end
d.sort!
i,j=0,0
t=Array.new(n,0)
while i!=n
  c=0
  while d[j]==i
    j+=1
    c+=1
  end
  t[i]=c
  i+=1
end
#p t
ans=[]
ans[0]=t[0]
for i in 1..n-1
  ans[i]=(t[i-1]**t[i])*ans[i-1]%998244353 if t[i]!=0
  ans[i]=0 if t[i]==0
end
#p ans
p ans[d.max]

Measured memory_bytes: 11012
#include <iostream>
using namespace std;
int count(int x, int c){
        if(x >= 500){
            return count(x-500,c+1);
        }
        if(x >= 100){
            return count(x-100,c+1);
        }
        if(x >= 50){
            return count(x-50,c+1);
        }
        if(x >= 10){
            return count(x-10,c+1);
        }
        if(x >= 5){
            return count(x-5,c+1);
        }

        if(x == 0){
            return c;
        }
        else{
            return count(x-1,c+1);
        }
    }
int main(void){
    int x;
    while(true){
        cin >> x;
        if(x==0){
            break;
        }
        cout << count(1000-x,0)<<endl;
    }
}


Measured memory_bytes: 3012
i = input().split()

a = i[0]
b = i[1]
c = i[2]
d = i[3]

if int(d) <= int(a):
  print(int(d))
elif int(d) - int(a) <= int(b):
    print(int(a))
else:
  print(int(a) - (int(d) - int(a) -int(b)))

Measured memory_bytes: 8936
#![allow(unused)]

//input
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;

//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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)*}
    };
}

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

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")
    };
}
//入力マクロここまで

const INI: u64 = 0;
const MOD: u64 = 1_000_000_007;

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

    if n == 1 {
        println!("1");
        return;
    }

    let mut safe = vec![true; n + 1];

    for e in a {
        safe[e] = false;
    }

    let mut dp = vec![INI; n + 1];

    dp[0] = 1;
    if safe[1] {
        dp[1] = 1;
    }

    for i in 2..n + 1 {
        if safe[i] {
            dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
        }
    }

    println!("{}", dp[n]);
}

Measured memory_bytes: 6396
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)

using ll = long long;
using Pii = pair<int, int>;

const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;

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

using MIte = multimap<ll, ll, greater<ll> >::iterator;

//2051
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	// long long?
	string S,T;
	cin >> S >> T;

	if (S.length() != T.length()) {
		cout << "No" << endl;
		return 0;
	}
	bool ans = (S == T);
	for (int i = 1; i != S.length(); ++i) {
		string tmp = T.substr(i, T.length() - 1);
		tmp += T.substr(0, i);
		if (S == tmp) {
			ans = true;
			break;
		}
	}

	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
b[-1]= a[-1]
total = 0
mod = 10**9 + 7
cumsum = sum(a)
for i in range(n-1):
    cumsum -= a[i]
    total = (total + (a[i] * cumsum) % mod) % mod
print(total)

Measured memory_bytes: 31660
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<string>
#include<cassert>
using namespace std;
#define N 4
#define N2 16
#define LIMIT 100

static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'r', 'u', 'l', 'd'};
int MDT[N2][N2];

struct Puzzle{
  int f[N2], space, MD;
};

Puzzle state;
int limit;
int path[LIMIT];

int getAllMD(Puzzle pz){
  int sum = 0;
  for(int i = 0; i < N2; i++){
    if(pz.f[i] == N2) continue;
    sum += MDT[i][pz.f[i] - 1];
  }
  return sum;
}

bool isSolved(){
  for(int i = 0; i < N2; i++) if(state.f[i] != i + 1) return false;
  return true;
}

bool dfs(int depth, int prev){
  if(state.MD == 0) return true;
  if(depth + state.MD > limit) return false;

  int sx = state.space / N;
  int sy = state.space % N;
  Puzzle tmp;
  
  for(int r = 0; r < 4; r++){
    int tx = sx + dx[r];
    int ty = sy + dy[r];
    if(tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
    if(max(prev, r) - min(prev, r) == 2) continue;
    tmp = state;
    state.MD -= MDT[tx * N + ty][state.f[tx * N + ty] - 1];
    state.MD += MDT[sx * N + sy][state.f[tx * N + ty] - 1];
    swap(state.f[tx * N + ty], state.f[sx * N + sy]);
    state.space = tx * N + ty;
    if(dfs(depth + 1, r)){
      path[depth] = r;
      return true;
    }
    state = tmp;
  }

  return false;
}

string iterative_deepening(Puzzle in){
  in.MD = getAllMD(in);

  for(limit = in.MD; limit <= LIMIT; limit++){
    state = in;
    if(dfs(0, -100)){
      string ans = "";
      for(int i = 0; i < limit; i++) ans += dir[path[i]];
      return ans;
    }
  }

  return "unsolvable";
}

int main(){
  for(int i = 0; i < N2; i++) for(int j = 0; j < N2; j++) MDT[i][j] = abs(i / N 
- j / N) + abs(i % N - j % N);

  Puzzle in;

  for(int i = 0; i < N2; i++){
    cin >> in.f[i];
    if(in.f[i] == 0){
      in.f[i] = N2;
      in.space = i;
    }
  }
  string ans = iterative_deepening(in);
  cout << ans.size() << endl;

  return 0;
}

Measured memory_bytes: 3192
/*  -*- coding: utf-8 -*-
 *
 * 1593.cc: Star
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000000;
const double PI = acos(-1.0);

/* typedef */

template <typename T>
struct Pt {
  T x, y;

  Pt() {}
  Pt(T _x, T _y) : x(_x), y(_y) {}
  Pt(const Pt<T> &pt) : x(pt.x), y(pt.y) {}

  Pt<T> operator+(const Pt<T> pt) const { return Pt<T>(x + pt.x, y + pt.y); }
  Pt<T> operator-() const { return Pt<T>(-x, -y); }
  Pt<T> operator-(const Pt<T> pt) const { return Pt<T>(x - pt.x, y - pt.y); }
  Pt<T> operator*(T t) const { return Pt<T>(x * t, y * t); }
  Pt<T> operator/(T t) const { return Pt<T>(x / t, y / t); }
  T dot(Pt<T> v) const { return x * v.x + y * v.y; }
  T cross(Pt<T> v) const { return x * v.y - y * v.x; }
  Pt<T> mid(const Pt<T> pt) { return Pt<T>((x + pt.x) / 2, (y + pt.y) / 2); }
  T d2() { return x * x + y * y; }
  double d() { return sqrt(d2()); }

  Pt<T> rot(double th) {
    double c = cos(th), s = sin(th);
    return Pt<T>(c * x - s * y, s * x + c * y);
  }

  Pt<T> rot90() { return Pt<T>(-y, x); }

  bool operator==(const Pt<T> pt) const { return x == pt.x && y == pt.y; }
  bool operator<(const Pt<T> &pt) const {
    return x < pt.x || (x == pt.x && y < pt.y);
  }

  void print() { printf("(%lf,%lf)", x, y); }
};

typedef Pt<double> pt;

struct CL {
  pt p;
  double t0, t1;
  CL() {}
  CL(const pt& _p, double _t0, double _t1) : p(_p), t0(_t0), t1(_t1) {}
};

/* global variables */

/* subroutines */

bool cross_lines(const pt& ap, const pt av, const pt& bp, const pt bv, CL& cl) {
  double op01 = av.cross(bv);
  //if (op01 == 0.0) return false; /* need to handle parallel?? */

  if (op01 == 0.0) {
    pt v = bp - ap;
    if (v.cross(av) != 0.0) return false;

    pt a1 = ap + av;
    pt b1 = bp + bv;

    return
      ((bp - ap).dot(b1 - ap) <= 0.0 ||
       (bp - a1).dot(b1 - a1) <= 0.0 ||
       (ap - bp).dot(a1 - bp) <= 0.0 ||
       (ap - b1).dot(a1 - b1) <= 0.0);
  }

  pt v = bp - ap;
  double op0 = v.cross(av);
  double op1 = v.cross(bv);

  double t0 = op1 / op01;
  double t1 = op0 / op01;

  cl.p = bv * t1 + bp;
  cl.t0 = t0;
  cl.t1 = t1;

  return true;
  //return (0.0 <= cl.t0 && cl.t0 <= 1.0 && 0.0 <= cl.t1 && cl.t1 <= 1.0);
}

/* main */

int main() {
  int n, k;
  scanf("%d%d", &n, &k);

  double th = PI * 2 / n;
  pt p0(cos(0.0), sin(0.0)), p1(cos(th), sin(th));
  double s0 = p0.cross(p1) * 0.5;

  double th2 = th * k, th3 = th * (1 - k + n);
  pt p2(cos(th2), sin(th2)), p3(cos(th3), sin(th3));
  CL cl;
  cross_lines(p0, p2 - p0, p1, p3 - p1, cl);
  double s1 = (p0 - cl.p).cross(p1 - cl.p) * 0.5;

  printf("%.8lf\n", (s0 - s1) * n);
  return 0;
}



Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    string s;
    cin >> s;
    cout << "2018" << s.substr(4, 6) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string>
#include<utility>
#include<vector>
#include<cmath>
#include<algorithm>
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define rFOR(i, a, b) for(int i=b; i>=a; i--)
#define MAX 10
typedef long long ll;
using namespace std;

int main(void){
  string a, b, c; cin >> a >> b >> c;
  if(a[a.length()-1]==b[0]&&b[b.length()-1]==c[0]){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pradyumn
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            char[] s = in.nextString().toCharArray();
            int n = s.length;
            long K = in.nextLong();
            int len = 0;
            for (int i = 0; i < n; ++i) {
                if (s[i] == '1') {
                    ++len;
                } else {
                    break;
                }
            }
            if (K <= len) {
                out.println(1);
            } else {
                out.println(s[len]);
            }
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int pnumChars;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        private int pread() {
            if (pnumChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= pnumChars) {
                curChar = 0;
                try {
                    pnumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (pnumChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public long nextLong() {
            int c = pread();
            while (isSpaceChar(c))
                c = pread();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = pread();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = pread();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public String nextString() {
            int c = pread();
            while (isSpaceChar(c))
                c = pread();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = pread();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long 
#define int long long 
#define vll vector<long long>
#define pii pair<long long ,long long > 
#define vvi vector< vector<long long > > 
#define vpii vector<pair<int,int>> 
#define pll  pair<long long ,long long > 
#define pb  push_back
#define ff  first 
#define sec second  
#define SORT(a) sort(a.begin(),a.end())
#define SORTR(a) sort(a.rbegin(),a.rend()) 
#define m_p make_pair
#define all(x) (x.begin(),x.end()) 
#define sz(v) ((int)(v.size()))
#define endl '\n'
typedef vector< long long > vi ;
const int MOD=1e9 +7 ;
int size=10000000; 
 
int32_t main(){
  fast; 
/*  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif */
    
  int T=1; //cin>>T; 
  while(T--){

    int h,n; cin>>h>>n; 
    int sum=0; 
    vi a(n); for(int i=0;i<n;i++){  cin>>a[i] ; sum+=a[i]; }

    if(sum>=h) cout<<"Yes"<<endl; 
    else cout<<"No"<<endl;  




  






  }
    


  return 0; 
} 

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

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

    int ans = 0;
    while (1) {
        for (int i = 0; i < n; i++) {
            if (a[i] % 2 != 0)
            {
                cout << ans << endl;
                return 0;
            }
        }
        ans++;
        for (int i = 0; i < n; i++)
            a[i] /= 2;
    }
}

Measured memory_bytes: 3632
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef vector<char> vc;
typedef vector<vector<char> > vvc;
typedef vector<double> vd;
typedef vector<vector<double> > vvd;
template<class T> using vv=vector<vector< T > >;
typedef deque<int> di;
typedef deque<deque<int> > ddi;
typedef deque<bool> db;
typedef deque<deque<bool> > ddb;

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

// cout vector<pair>
template<typename T1, typename T2> ostream& operator<<(ostream& s, const vector<pair<T1, T2> >& vp) {
  int len = vp.size(); s << "\n";
  for (int i = 0; i < len; ++i) { s << vp[i]; }
    s << "\n"; return s;
}

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

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

// cout 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]; }
  return s;
}

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

int main() {
  int k, t;
  cin >> k >> t;
  vi a(t);
  rep (i, t) {
    cin >> a[i];
  }
  sort(all(a));
  int x = k - a[t-1];
  int ans = max(0, a[t-1] - x - 1);
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

constexpr ll mod=1000000007;

ll pow(ll a, ll b) {
  ll r = 1;
  while (b != 0) {
    if (b % 2 != 0) {
      r = r * a % mod;
    }
    a = a * a % mod;
    b /= 2;
  }
  return r;
}

int main(){
    ll n,k;
    cin>>n>>k;
    ll gcd=k;
    ll count=0;
    vll d(k+1);
    while(gcd>0){
        ll c=k/gcd;
        d[gcd]=pow(c,n)%mod;
        for(ll i=c;i>1;i--){
            d[gcd]-=d[gcd*i];
        }
        count+=d[gcd]*gcd%mod;
        gcd--;
    }
    count%=mod;
    if(count<0) count+=1000000007;
    cout<<count<<endl;
}

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

#define rep(i,a,b) for(long long i = a; i < b; i++)
#define dump(a) for(auto x : a) cout << x << " "; cout << "\n"
#define print(a) cout << a << "\n"
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr << #x << ": " << x << ", " << #y << ": " << y << "\n"
#define debug3(x,y,z) std::cerr << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << "\n"

typedef long long ll;
using vi   = vector<int>;
using vll  = vector<long long>;
using vs   = vector<string>;
using vvi  = vector<vector<int>>;
using vvll = vector<vector<long long>>;
using vvs  = vector<vector<string>>;

int main() {
  int n,x,t;
  cin >> n >> x >> t;
  ll total = 0;
  while (0 < n) {
    total += t;
    n -= x;
  }
  print(total);
  return 0;
}

Measured memory_bytes: 3632
// https://atcoder.jp/contests/dp/tasks/dp_j

#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>

using namespace std;

int main (int argc, char* argv[]) {
	long long n, k;
	cin >> n >> k;

	vector<long long> takes(n);
	for (long long i = 0; i < n; i++) {
		cin >> takes[i];
	}

	vector<bool> dp(k + 1);
	for (long long i = 1; i <= k; i++) {
		for (long long take : takes) {
			dp[i] = i - take >= 0 && !dp[i - take];
			if (dp[i]) break;
		}
	}
	
	cout << (dp[k] ? "First" : "Second") << endl;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.algorithm;

void main() {
  while (true) {
    string[] input = split(readln());
    int a = to!int(input[0]), b = to!int(input[1]);

    if (a == 0 && b == 0) break;

    if (a > b) swap(a, b);

    writef("%d %d\n", a, b);
  }
}

Measured memory_bytes: 2480
// AtCoder ABC138: C - Alchemist
// 2019.8.26 bal4u

#include <stdio.h>
#include <stdlib.h>
int a[53];

int cmp(const void *u, const void *v) { return *(int *)u - *(int *)v; }

int main()
{
	int i, N; double ans;

	
	scanf("%d", &N);
	for (i = 0; i < N; i++) scanf("%d", a+i);
	qsort(a, N, sizeof(int), cmp);
	ans = 0.5*(a[0]+a[1]);
	for (i = 2; i < N; i++) ans = 0.5*(ans + a[i]);
	printf("%.8lf\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <ctime>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn=100000+10;
const int maxm=1000+10;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
const ll LINF=(1LL<<62);
const double PI=acos(-1.0);
#define mst(a,b) memset(a,b,sizeof(a))
#define rep(i,a,b) for (int i=(a);i<b;i++)
#define ALL(x) x.begin(),x.end()
#define pii pair<int,int>
#define lowbit(x) x&(-x)
#define X first
#define Y second
int a[10];
int main(){
#ifdef local
    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif
    //ios::sync_with_stdio(false); cin.tie(0);
    int n; scanf("%d",&n);
    int k=0;
    while (n){
        a[k++]=n%10;
        n/=10;
    }
    bool flag;
    for (int i=0;i<2;i++){
        int key=a[i];
        flag=true;
        for (int j=i;j<i+3;j++){
            if (a[j]!=key){
                flag=false;
                break;
            }
        }
        if (flag) break;
    }
    if (flag) printf("Yes\n"); else printf("No\n");
    return 0;
}


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

using namespace std;

int n, m;
int lab[1111111], chk[1111111], nxt[1111111];
vector<int> e[1111111];
int d[1111111];
vector<pair<int, int> > c[1111111];

void unite(int a, int b){
	if (lab[a] < lab[b]) swap(a, b);
	if (lab[a] == lab[b]) --lab[b];
	lab[a] = b;
}

int get(int x){
	return lab[x] < 0 ? x : lab[x] = get(lab[x]);
}

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%d%d",&n,&m);
	int tot = n;
	for(int i = 1; i <= m; ++i){
		int x, y, z;
		scanf("%d%d%d",&x,&y,&z);
		e[x].push_back(++tot);
		e[tot].push_back(x);
		e[y].push_back(tot);
		e[tot].push_back(y);
		c[z].push_back(make_pair(x, y));
	}
	memset(lab, -1, sizeof(lab));
	for(int i = 1; i <= 1000000; ++i){
		if (c[i].empty()) continue;
		for(int j = 0; j < c[i].size(); ++j){
			int a = c[i][j].first, b = c[i][j].second;
			a = get(a);
			b = get(b);
			if (a != b) unite(a, b);
		}
		for(int j = 0; j < c[i].size(); ++j){
			int a = c[i][j].first;
			int g = get(a);
			if (!nxt[g]) nxt[g] = ++tot;
			if (!chk[a]) e[a].push_back(nxt[g]), e[nxt[g]].push_back(a); 
			a = c[i][j].second;
			g = get(a);
			if (!nxt[g]) nxt[g] = ++tot;
			if (!chk[a]) e[a].push_back(nxt[g]), e[nxt[g]].push_back(a);
		}
		for(int j = 0; j < c[i].size(); ++j){
			int a = c[i][j].first;
			nxt[a] = chk[a] = 0;
			lab[a] = -1;
			a = c[i][j].second;
			nxt[a] = chk[a] = 0;
			lab[a] = -1;
		}
	}
	queue<int> q;
	q.push(1);
	d[1] = 1;
	while (!q.empty()){
		int u = q.front();
		q.pop();
		for(int i = 0; i < e[u].size(); ++i){
			int v = e[u][i];
			if (!d[v]){
				d[v] = d[u] + 1;
				if (v == n){
					printf("%d",(d[n] - 1) / 2);
					return 0;
				}
				q.push(v);
			}
		}
	}
	printf("-1");
	return 0;
}

Measured memory_bytes: 90080
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long l,r;
    scanf("%lld %lld",&l,&r);
    for(int i=l;i<=r;++i)
        if(i%2019==0){
            puts("0");
            return 0;
        }
    int mn=2018;
    for(int i=(l%2019);i<=(r%2019);++i){
        for(int j=i+1;j<=(r%2019);++j){
            mn=min((i*j)%2019,mn);
        }
    }
    cout<<mn<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <numeric>
#include <iostream>

using namespace std;
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;


int main() {

	long long n; cin >> n;

	vector<long long> spf(n + 1, 0);
	iota(spf.begin(), spf.end(), 0);

	for (long long i = 2; i * i <= n; i++) {
		for (long long j = i * i; j <= n; j += i) spf[j] = min(spf[j], i);
	}

	long long ans = 0;

	for (long long i = 1; i <= n; i++) {
		long long x = i, cnt = 1;
		while (x != 1) {
			long long pfac = spf[x], temp = 0;
			while (x % pfac == 0) x /= pfac, temp++;
			cnt *= (temp + 1);
		}
		ans += (i * cnt);
	}

	cout << ans;


	return 0;
}

Measured memory_bytes: 81344
package main

import "fmt"
import "math"

func main(){
	var n,d int
	var x[11][11] int
	var tot,sqr int
	ans :=0
	fmt.Scan(&n,&d)
	for i:=0;i<n;i+=1 {
		for j:=0;j<d;j+=1 {
			fmt.Scan(&x[i][j])
		}
	}
	for i:=0;i<n;i+=1 {
		for j:=i+1;j<n;j+=1 {
			tot = 0
			for k:=0;k<d;k+=1 {
				tot += int(math.Pow(float64(x[i][k]-x[j][k]),2))
			}
			//fmt.Printf("%d\n",tot)
			sqr = int(math.Sqrt(float64(tot)))
			if tot == int(math.Pow(float64(sqr),2)){
				ans += 1
			}
		}
	}
	fmt.Printf("%d\n",ans)

}

Measured memory_bytes: 512
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [tuple(map(int, l.split())) for l in sys.stdin]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def main():
    s = [int(c) for c in S()]
    l = len(s)
    t = u = 0
    for i in range(l):
        if s[i] == i % 2:
            t += 1
        else:
            u += 1

    return min(t,u)


print(main())



Measured memory_bytes: 7752
A,B=gets.split.map(&:to_i)
num=0
A.upto(B){ |n|
  ns=n.to_s
  tf=true
  (ns.size/2).times{ |i|
    tf = false if ns[i] != ns[-(i+1)]
  }
  num+=1 if tf
}
p num

Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string str;
  cin>>str;

  if(str=="Sunny")
  cout<<"Cloudy";
    else if(str=="Cloudy")
    cout<<"Rainy";
    else if(str=="Rainy")
    cout<<"Sunny";




}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>

#define DEBUG

#ifdef DEBUG

#define printd printf

#else

#define printd(...)

#endif

int main() {
    int k;
    std::cin >> k;
    uint64_t ans = 0;

    for (int a = 1; a <= k; a++) {
        for (int b = 1; b <= k; b++) {
            for (int c = 1; c <= k; c++) {
                auto g = std::gcd(a, b);
                g = std::gcd(g, c);
                ans += g;
            }
        }
    }

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


Measured memory_bytes: 3164
# -*- coding: utf-8 -*-
A_ele = []
B_ele = []
C_ele = []
ele = [int(x) for x in input().split()]
for i in range(ele[0]):
    A_ele.append([int(x) for x in input().split()])
for i in range(ele[1]):
    B_ele.append([int(x) for x in input().split()])
for i in range(ele[0]):
    C_ele.append([])
    for j in range(ele[1]):
        for k in range(ele[2]):
            if j == 0:
                C_ele[i].append(0)
            C_ele[i][k] = C_ele[i][k] + A_ele[i][j] * B_ele[j][k]
for i in range(ele[0]):
    print(' '.join(map(str,C_ele[i])))


Measured memory_bytes: 6904
#include <bits/stdc++.h>
using namespace std;
//vector<vector<int>> a(n, vector<int> (m))
int main(){
    int k, a, b;
    cin >> k >> a >>b;
    int flag = 0;
    for(int i = a; i <= b; i++ ){
        if(i % k == 0){
            flag = 1;
            break;
        }
    }
    
    if(flag == 1){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
    }
}

Measured memory_bytes: 3636
def main():
    n,k = map(int,input().split())
    A = list(map(int,input().split()))
    MOD = 10**9+7


    B = []
    flg_m = 0
    flg_p = 0

    for a in A:
        if a < 0:
            B.append([abs(a),-1])
            flg_m = 1
        else:
            B.append([abs(a),1])
            flg_p = 1

        b = 0
    ans = -10**9
    if k == 1:
        for a in A:
            ans = max(ans,a)
        print(ans)
        exit()

    B.sort(reverse=True)
    # print(B)
    if flg_p == 0 and k%2 == 1:
        B.sort()
        L = B[:k]
        ans = cal_ans(L)
        ans *=-1
        print(ans%MOD)
        exit()
    elif flg_p * flg_m == 0:
        L = B[:k]
        ans = cal_ans(L)
        print(ans)
        exit()

    flg_p = 0
    flg_m = 0
    flg_lm = 0
    flg_lp = 0
    # print(B)
    for i,(n,sign) in enumerate(B):
        if i < k:
            if sign == -1:
                flg_lp = 1
                last_m = n
            else:
                flg_lm = 1
                last_p = n
        else:
            if sign == -1:
                if flg_m == 0:
                    first_m = n
                    flg_m = 1
            else:
                if flg_p == 0:
                    first_p = n
                    flg_p = 1

    L = B[:k]
    ans = cal_ans(L)
    c = 0
    for n,sign in L:
        if sign == -1:
            c += 1
    if c % 2 == 0:
        print(ans)
        exit()
    if flg_p == 1 and flg_m == 1 and flg_lp == 1 and flg_lm == 1:
        if first_p * last_p >= first_m*last_m:
            a = first_p
            b = last_m
        else:
            a = first_m
            b = last_p
    elif flg_p == 1:
            a = first_p
            b = last_m
    elif flg_m == 1:
            a = first_m
            b = last_p
    else:
        ans = 1
        for a in A:
            ans *= a
            ans %= MOD
        print(ans)
        exit()


    ans *= a
    ans %= MOD
    ans *= pow(b,MOD-2,MOD)
    ans %= MOD
    print(ans)

def cal_ans(L):
    MOD = 10**9+7
    ans = 1
    for i,j in L:
        ans *= i
        ans %= MOD
    return ans



main()

Measured memory_bytes: 43004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
 
int main() {
	double n,k;
	cin>>n>>k;
	double sum=0;
	for(ll i=1;i<=n;i++){
		double now=i;
		double nosum=1/n;
		while(now<k){
			now*=2;
			nosum/=2;
		}
		sum+=nosum;
	}
	printf("%.10f",sum);
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
//D - Knapsack 1

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn = 123456;
ll dp[maxn];
int w[110], v[110];
const int inf = 0x7f7f7f7f;
int main(){
//    freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, W;
    cin >> n >> W;
    memset(dp, 0, sizeof(dp));
    for(int i = 0; i < n; ++i){
        cin >> w[i] >> v[i];
//        dp[i][0] = v[i];
    }
    for(int i = 0; i < n; ++i){
        for(int j = W; j >= 0; --j){
            if(w[i] + j <= W){
                dp[j+w[i]] = max(dp[j+w[i]], dp[j] + v[i]);
            }
        }
    }
//    for(int i = 0; i <= n; ++i){
//        for(int j = 0; j <= W; ++j){
//            cout << dp[i][j] << " ";
//        }
//        cout << endl;
//    }
    ll res = 0;
    for(int i = 0; i <= W; ++i){
        res = max(res, dp[i]);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1280
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| min!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| max!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let m: usize = sc.cin();
    let d = (n + m) / 2;
    if d + d == n + m {
        put!(d);
    } else {
        put!("IMPOSSIBLE");
    }
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<ctype.h>
typedef long long LL;
#define rep(i,n) for(LL i=0; i<(LL)(n); i++)

//qsort
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

//比較
int max(int a, int b){
	if (a>b) return a;
	else return b;
}

int min(int a,int b) {
	if(a>b) return b;
	else return a;
}


//main関数
int main(){
	int N;
	scanf("%d",&N);
	
	int A[N];
	int flag[1000010] = {0};
	rep( i , N ){
		scanf("%d",&A[i]);
		flag[ A[i] ] = 1;
	}
	qsort( A, N , sizeof(int), compare_int );
	rep(i,N-1){
		if( A[i] == A[i+1] ) {
			flag[A[i]] = 0;
		}	
	}
	int ans = 0;
	for( int i=0; i<N; i++ ){
		if( flag[A[i]] == 1 ){
			ans++;
		}
		int j=2;
		while( A[i]*j <= A[N-1] ){
			flag[ A[i] * j ] = 0;
			j++;
		}
	}
	
	printf("%d",ans);
}



Measured memory_bytes: 7008
#include<stdio.h>

int main(void){
    int sec=0;
    int h=0,m=0,s=0;
    scanf("%d",&sec);
    h = sec/3600;
    m = (sec%3600)/60;
    s = sec-(h*3600)-(m*60);
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}

Measured memory_bytes: 1852