akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

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


int main(){

	vector<int>v(30,0);
	int n;

	rep(i,28){
	cin >> n;
	v[n-1]=1;
	}

	rep(i,30)
	if(v[i]==0)
	cout << i+1 << endl;

	return 0;
}

Measured memory_bytes: 1192
#include<stdio.h>
#define length 2000
int match(int,int);
int A[length];
int n;

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


int match(int x,int y){
  int sum;
  if(y==0)return 1;
  if(x>=n)return 0;

  sum = match(x+1,y)|| match(x+1,y-A[x]);
  return sum;
}



Measured memory_bytes: 2104
#include <stdio.h>
#include <stdlib.h>

#define INIT_CAP 10
#define INF 1000000000

#define min(a, b) (((a) < (b)) ? (a) : (b))

const int di[4] = {-1, 0, 1, 0};
const int dj[4] = {0, 1, 0, -1};

typedef struct {
	int to, w;
} Edge;

typedef struct {
	Edge *elem;
	int cap, size;
} VecEdge;

typedef struct {
	int num, d;
} PNumDis;

VecEdge adj[30 * 30 * 4];
PNumDis heap[30 * 30 * 4 * 4];
int hsize;
int d[30 * 30 * 4];

int w, h;
int field[30][30];

void init(int n) {
	while (n--)
		adj[n] = (VecEdge){malloc(sizeof(Edge) * INIT_CAP), INIT_CAP, 0};
}

void add(int from, int to, int w) {
	if (adj[from].size == adj[from].cap) {
		adj[from].cap <<= 1;
		adj[from].elem = realloc(adj[from].elem, sizeof(Edge) * adj[from].cap);
	}
	adj[from].elem[adj[from].size++] = (Edge){to, w};
}

void freeAll(int n) {
	while (n--)
		free(adj[n].elem);
}

void insert(int num, int d) {
	int i;
	for (i = hsize++; i > 0 && d < heap[i - 1 >> 1].d; i = i - 1 >> 1)
		heap[i] = heap[i - 1 >> 1];
	heap[i] = (PNumDis){num, d};
}

int calcNextIdx(int i) {
	return i * 2 + 1 + (i * 2 + 2 < hsize && heap[i * 2 + 1].d > heap[i * 2 + 2].d);
}

PNumDis delete(void) {
	int i;
	int nextIdx;
	const PNumDis root = heap[0], last = heap[--hsize];

	for (i = 0; i * 2 + 1 < hsize && last.d > heap[nextIdx = calcNextIdx(i)].d; i = nextIdx)
		heap[i] = heap[nextIdx];
	heap[i] = last;

	return root;
}

void dijkstra(int n, int s) {
	int i;

	for (i = 0; i < n; i++)
		d[i] = INF;

	d[s] = 0;
	insert(s, 0);
	while (hsize > 0) {
		const PNumDis fromP = delete();

		if (fromP.d > d[fromP.num])
			continue;

		for (i = 0; i < adj[fromP.num].size; i++) {
			const Edge e = adj[fromP.num].elem[i];
			if (fromP.d + e.w < d[e.to]) {
				d[e.to] = fromP.d + e.w;
				insert(e.to, d[e.to]);
			}
		}
	}
}

int main(void) {
	int i, j, k, l;

	while (scanf("%d %d", &w, &h), w) {
		int c[4];

		for (i = 0; i < h; i++)
			for (j = 0; j < w; j++)
				scanf("%d", field[i] + j);

		for (i = 0; i < 4; i++)
			scanf("%d", c + i);

		init(h * w * 4);

		for (i = 0; i < h; i++)
			for (j = 0; j < w; j++)
				for (k = 0; k < 4; k++)
					for (l = 0; l < 4; l++) {
						int nd = k + l & 3;
						int ni = i + di[nd], nj = j + dj[nd];
						if (ni >= 0 && ni < h && nj >= 0 && nj < w)
							add(i * w * 4 + j * 4 + k, ni * w * 4 + nj * 4 + nd, l == field[i][j] ? 0 : c[l]);
					}

		dijkstra(h * w * 4, 1);

		printf("%d\n", min(d[(h - 1) * w * 4 + (w - 1) * 4 + 1], d[(h - 1) * w * 4 + (w - 1) * 4 + 2]));

		freeAll(h * w * 4);
	}

	return 0;
}

Measured memory_bytes: 1036
#include <iostream>


int main() {


	std::string O, E; std::cin >> O >> E;

	for (int i = 0; i < (O.size() > E.size() ? O.size() : E.size()); i++)
	{
		if (i < O.size())std::cout << O[i];
		if (i < E.size())std::cout << E[i];
	}


	return 0;


}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <climits>
#include <bitset>
#include <cassert>
#include <random>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple

using namespace std;

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

const int N = 310;
int dist[N][N];

struct SCC{
	int n, k;
	vector<vector<int>> G, RevG;
	vector<int> vs, used, cmp;

	SCC(int _n) :n(_n){
		G = RevG = vector<vector<int>>(n);
		used = cmp = vector<int>(n);
		k = -1;
	}

	void add_edge(int s, int t){
		G[s].push_back(t);
		RevG[t].push_back(s);
	}

	void dfs(int v){
		used[v] = 1;
		for (auto to : G[v]){
			if (!used[to]) dfs(to);
		}
		vs.push_back(v);
	}

	void rdfs(int v, int k){
		used[v] = 1;
		cmp[v] = k;
		for (auto to : RevG[v]){
			if (!used[to]) rdfs(to, k);
		}
	}

	int calcSCC(){
		fill(used.begin(), used.end(), 0);
		vs.clear();
		for (int i = 0; i < n; ++i) if(!used[i]) dfs(i);
		fill(used.begin(), used.end(), 0);
		k = 0;
		for (int i = n - 1; i >= 0; --i) if(!used[vs[i]]) rdfs(vs[i], k++);

		return k;
	}
};

vector<vector<int>> make_DAG(SCC &scc){
	if (scc.k < 0) scc.calcSCC();
	const auto &G = scc.G;
	const auto &cmp = scc.cmp;
	const int k = scc.k;

	vector<vector<int>> DAG(k);
	int n = G.size();
	for (int i = 0; i < n; ++i){
		for (auto to : G[i]){
			if(cmp[i] != cmp[to]) DAG[cmp[i]].push_back(cmp[to]);
		}
	}

	for (auto &v : DAG){
		sort(v.begin(), v.end());
		v.erase(unique(v.begin(), v.end()), v.end());
	}
	return DAG;
}

vector<vector<int>> G;

const ll mod = 1e9 + 7;
int used[1010];

ll dfs(int v){
	used[v] = 1;
	ll res = 1;
	for (auto to : G[v]){
		res *= dfs(to);
		res %= mod;
	}
	return res + 1;
}


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

	int n, m;
	cin >> n >> m;
	SCC scc(n);
	rep(i, m){
		int a, b;
		cin >> a >> b;
		scc.add_edge(b - 1, a - 1);
	}

	scc.calcSCC();
	G = make_DAG(scc);

	ll ans = 1;
	for (int i = 0; i < G.size(); ++i){
		if (used[i]) continue;
		ans *= dfs(i);
		ans %= mod;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1384
#include <limits>
#include <vector>
#include <functional>

template<typename T, typename E, typename F, typename G, typename ID, typename AB>
std::vector<T> bellman_ford(const std::vector<std::vector<int>> &adj,
                            const std::vector<std::vector<E>> &cost,
                            int s,
                            F f,
                            G g,
                            ID id,
                            AB ab) {
    struct edge {
        int from, to;
        T cost;
    };
    int n = adj.size();
    std::vector<edge> edges;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < adj[i].size(); j++) { edges.push_back({i, adj[i][j], cost[i][j]}); }
    }
    std::vector<T> ret(n, ab());
    ret[s] = id();
    for (int i = 0; i < n; i++) {
        bool update = false;
        for (int j = 0; j < edges.size(); j++) {
            edge e = edges[j];
            T dist = f(ret[e.from], e.cost);
            if (g(ret[e.to], dist)) { ret[e.to] = dist, update = true; }
        }
        if (!update) { return ret; }
    }
    return std::vector<T>();
}

template<typename T>
std::vector<T> basic_bellman_ford(const std::vector<std::vector<int>> &adj,
                                  const std::vector<std::vector<T>> &cost,
                                  int s) {
    auto id = []() -> T { return 0; };
    auto ab = []() -> T { return std::numeric_limits<T>::max(); };
    auto f = [&](const T &a, const T &b) -> T { return a == ab() ? ab() : a + b; };
    return bellman_ford<T>(adj, cost, s, f, std::greater<T>(), id, ab);
}

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

int main() {
    int V, E, r;
    cin >> V >> E >> r;
    vector<vector<int>> adj(V, vector<int>()), cost(V, vector<int>());
    for (int i = 0; i < E; i++) {
        int s, t, d;
        cin >> s >> t >> d;
        adj[s].push_back(t), cost[s].push_back(d);
    }
    vector<int> dist = basic_bellman_ford(adj, cost, r);
    if (dist.empty()) {
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
    }
    for (int i = 0; i < V; i++) { cout << (dist[i] < INT_MAX ? to_string(dist[i]) : "INF") << endl; }
}


Measured memory_bytes: 3424
import sys
n,m =map(int,input().split())
ls =[list(map(int,input().split())) for _ in range(n)]
ls.sort()
i = 0
j = 0
while True:
    if m - ls[i][1] > 0:
        m = m - ls[i][1]
        j += ls[i][0]*ls[i][1]
        i += 1
    else:
        j += m*ls[i][0]
        print(j)
        sys.exit()

Measured memory_bytes: 27880
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<cassert>

#define f first
#define s second
#define mp make_pair

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

using namespace std;

typedef unsigned int uint;
typedef long long ll;

template<int m>
class Prime{
  std::vector<bool> p;
public:
  std::vector<int> ps;
  Prime(){
    p = std::vector<bool>(m,true);
    assert(m>1);
    p[0]=p[1]=false;
    for(int i=4;i<m;i+=2)
      p[i]=false;
    ps.push_back(2);
    for(int i=3;i<m;i+=2){
      if(p[i]){
        ps.push_back(i);
        for(int j=i+i;j<m;j+=i)
          p[j]=false;
      }
    }
  }

  bool isPrime(int n){
    assert(m>n);
    return p[n];
  }

  int operator [] (int n){
    if(n<ps.size()) return ps[n];
    else return 0;
  }

  int size(){
    return ps.size();
  }
};

int main(){
  Prime<100000+10000> p;
  int n,m;
  while(scanf("%d%d",&n,&m), n + m != -2){
    vector<int> v;
    int base = lower_bound(ALL(p.ps), n) - p.ps.begin();
    if(p.ps[base] == n) base++;

    for(int i=0; i<m; i++)
      for(int j=i; j<m; j++)
        v.push_back(p.ps[base + i] + p.ps[base + j]);

    sort(v.begin(), v.end());
    printf("%d\n",v[m-1]);
  }
  return 0;
}

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

using namespace std;

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

    for (int i = 0 ; i < s.size(); i++)
    {
    	if (s[i] == t[i])
    	{
    		counter++;
    	}
    }
    if (counter == s.size())
    {
    	if (t.size() - 1 == s.size())
	    {
	    	cout << "Yes";
	    }
	    else
	    {
	    	cout << "No";
	    }
    }
    else{
    	cout << "No";
    }
	
	return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,a,n) for(ll i=(a); i<(ll)(n); i++)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(v) (v).begin(), (v).end()

int main(void) {
    int H,W;
    cin >> H >> W;
    char s[H][W];
    int ans[H][W];
    for (int i=0; i<H; i++) cin >> s[i];
    for (int i=0; i<H; i++) for (int j=0; j<W; j++) ans[i][j] = 0;
    for (int i=0; i<H; i++) for (int j=0; j<W; j++) {
        if (s[i][j] == '#') {
            for (int k=i-1; k<=i+1; k++) for (int l=j-1; l<=j+1; l++) {
                if (k == -1 || k == H || l == -1 || l == W) continue;
                ans[k][l]++;
            }
        }
    }
    for (int i=0; i<H; i++) {
        for (int j=0; j<W; j++) {
            if (s[i][j] == '#' ) cout << "#";
            else if (s[i][j] == '.') cout << ans[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
T = list(map(int,input().split()))
A = list(map(int,input().split()))
ans = 1; MOD = pow(10,9)+7
if N == 1:
  if A[0] == T[0]:
    print(1)
  else:
    print(0)
  exit()
for i in range(N):
  if i == 0: #T[0]じゃないとダメ
    if A[i] == A[i+1]: #なんでもおk
      fac = 1
    else: #A[i]じゃなとダメ
      if A[i] > T[0]: #矛盾
        fac = 0
      else:
        fac = 1
  elif i < N-1: #間
    if T[i] == T[i-1]: #T[i]以下ならなんでもおｋ
      if A[i] == A[i+1]: #A[i]以下ならなんでもおｋ
        fac = min(T[i],A[i])
      else: #A[i]じゃないとダメ
        if A[i] > T[i]: #矛盾
          fac = 0
        else:
          fac = 1
    else: #T[i]じゃないとだめ
      if A[i] == A[i+1]: #A[i]以下ならなんでもｋ
        if T[i] > A[i]: #矛盾
          fac = 0
        else:
          fac = 1
      else: #A[i]じゃないとだめ
        if T[i] == A[i]:
          fac = 1
        else:
          fac = 0
  else: #i = N-1。A[i]じゃないとダメ
    if T[i] == T[i-1]: #T[i]以下ならなんでもおｋ
      if A[i] > T[i]: #矛盾
        fac = 0
      else:
        fac = 1
    else: #T[i]じゃないとダメ
      if T[i] == A[i]:
        fac = 1
      else:
        fac = 0
  ans = (ans*fac)%MOD
print(ans%MOD)
      
      
        
        
      
        
      
      
      
    

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

int main() {
  string a,b;
  cin>>a>>b;
  if(a.size()>b.size()){
    cout<<"GREATER"<< endl;
    return 0;
  }
  if(a.size()<b.size()){
    cout<<"LESS"<< endl;
    return 0;
  }
  
  for(int i=0;i<a.size();i++){
    if(a.at(i)-'0'>b.at(i)-'0'){
      cout<<"GREATER"<< endl;
      return 0;
    }
    if(a.at(i)-'0'<b.at(i)-'0'){
      cout<<"LESS"<< endl;
      return 0;
    }
  }
  cout<<"EQUAL"<< endl;
}


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

void main(){
	auto S = readln.split.to!(int[]);
	auto A = S[0];
	auto B = S[1];
 if(A+B>=10) writeln("error");
 else writeln (A+B);
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    char rafi[102];
    cin>>rafi;
    int k=strlen(rafi);
    for(int i=0;i<k;i++)
    {
        rafi[i]='x';
    }
    cout<<rafi<<endl;
    return 0;


}


Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------


int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.
	LL N;
	cin >> N;
	VL L;
	L.push_back(2);
	L.push_back(1);
	FOR(i, 2, N+1) {
		L.push_back(L[i - 1] + L[i - 2]);
	}
	cout << L[N] << endl;
	return 0;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#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, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int r;
    cin >> r;
    cout << 2 * r * M_PI << endl;
    return 0;
}


Measured memory_bytes: 3780
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"log"
	"os"
	"strconv"
	"strings"
)

func solve(sum int, elem []int, idx, limit int) bool {
	if sum == 0 {
		// 合計が一致
		return true
	}
	if idx >= limit {
		return false
	}

	//     使わないパターン               || 使うパターン
	return solve(sum, elem, idx+1, limit) || solve(sum-elem[idx], elem, idx+1, limit)
}

func main() {
	reader := bufio.NewScanner(os.Stdin)
	n := eGetInt(reader)
	a := eGetInts(reader)
	eGetInt(reader)
	ms := eGetInts(reader)
	for _, m := range ms {
		if solve(m, a, 0, n) {
			fmt.Println("yes")
		} else {
			fmt.Println("no")
		}
	}
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(max int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), max)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	var ints []int
	for _, f := range fields {
		ints = append(ints, eAtoi(f))
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}

type ints []int

func (s ints) String() string {
	var buf bytes.Buffer
	sep := ""
	for _, v := range s {
		buf.WriteString(fmt.Sprintf("%s%d", sep, v))
		sep = " "
	}
	return buf.String()
}

func reverse(a ints) ints {
	r := make(ints, len(a))
	for i := 0; i < len(a); i++ {
		r[i] = a[len(a)-1-i]
	}
	return r
}
func max(a ints) (int, bool) {
	if len(a) == 0 {
		return 0, false
	}
	m := a[0]
	for _, e := range a {
		if e > m {
			m = e
		}
	}
	return m, true
}
func sum(a ints) int {
	if len(a) == 0 {
		return 0
	}
	sum := 0
	for _, e := range a {
		sum += e
	}
	return sum
}

/*
func eGetLine(r *bufio.Reader) string {
	s, err := r.ReadString(byte('\n'))
	if err != nil {
		if err != io.EOF {
			log.Fatal(err.Error())
		}
		return s
	}
	return strings.TrimRight(s, "\r\n")
}
func eGetInt(r *bufio.Reader) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInts(r *bufio.Reader) []int {
	line := eGetLine(r)
	fields := strings.Split(line, " ")
	var ints []int
	for _, f := range fields {
		ints = append(ints, eAtoi(f))
	}
	return ints
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
*/



Measured memory_bytes: 1188
#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define int long long
#define fori(j,n) for(int i=j;i<n;i++)
#define forb(n,j) for(int i=n-1;i>=0;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define PI 3.141592653589793
#define M 1000000007
using namespace std;
int fast(int a,int b)
{
    int ans=1;
    a=a%M;
    if(a==0)
        return 0;
    while(b>0)
    {
        if(b&1)
        {
            ans=(ans*a)%M;
        }
        b>>=1;
        a=(a*a)%M;
    }
    return ans;
}

int32_t main()
{
   	int x,y;
   	cin>>x>>y;
   	bool flag=false;
    for(int i=0;i<=x;i++)
    {
		if(2*i+4*(x-i)==y)
            flag=true;
	}
	if(flag)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 3588
#include<iostream>
#include<cmath>
using namespace std;
int	main()
{
	int x,y,z,w;
	cin>>x>>y>>z>>w;
	if(fabs(x-z)<=w||(fabs(y-x)<=w&&fabs(y-z)<=w))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	
	
	
	
	
	
	return 0;
}

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


ll N, M;


void input() {
    cin >> N >> M;
}


vector<ll> divisor(int n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(rbegin(ret), rend(ret));
  return (ret);
}


bool judge(ll x) {
    ll v = x * N;
    if (M < v) return false;
    int m = M - v;
    if (m % x == 0) return true;
    return false;
}


int main() {
    input();
    vector<ll> w = divisor(M);
    for (ll x : w) {
        if (judge(x)) {
            cout << x << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        if (a * b > c * d) {
            _out.println(a * b);
        } else {
            _out.println(c * d);
        }
    }
    private long C(long n, long r) {
        long res = 1;
        for (long i = n; i > n - r; --i) {
            res *= i;
        }
        for (long i = r; i > 1; --i) {
            res /= i;
        }
        return res;
    }
    private long P(long n, long r) {
        long res = 1;
        for (long i = n; i > n - r; --i) {
            res *= i;
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 10324
A, B, C, X, Y = map(int, input().split())
cost = A*X + B*Y
new_cost = cost
plus = 0
for i in range(1, max(X, Y)+1):
  if i <= min(X, Y):
    plus = - A - B + 2*C
  else:
    plus = -A + 2*C if X > Y else -B + 2*C
  if plus < 0:
    new_cost += plus
  else:
    break
print(new_cost)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
#define x1 qeerdx
#define y1 qeerdy
 
#define lb lower_bound
#define ub upper_bound
 
#define endl '\n'
#define fast_in ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
#define mp  make_pair
#define pb  push_back
 
#define fi first
#define se second
 
#define   sz(x)  (int)x.size()
#define  all(x)  x.begin(), x.end()
#define  bit(x)  __builtin_popcountll(x)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
typedef pair <int,int> pii;
 
const int inf = (int) 1e9+99999, mod = (int)1e9+7;
const ll linf = (ll) 2e18+99999;
 
int kob (int x, int y) { return ((ll)x * y) % mod; } 
int aza (int x, int y) { x -= y; if (x < 0) return x + mod; return x; } 
int kos (int x, int y) { x += y; if (x >= mod) return x - mod; return x; }
 
const int maxn = (int)3e5, maxn2 = (int) 1e6+55;
 
static long holdrand = 1L;
void srand(unsigned int seed){holdrand = (long) seed;} 
int rand() {return (((holdrand = holdrand * 214013L + 2531011L) >> 16) & 0x7fff);}

int s[maxn], t[maxn], x[maxn];
vector <pair < pii, int > > v;

map <pii, int> myp;

int main () {
	int n, q; cin >> n >> q;
	for (int i = 1; i <= n; i ++) {
		cin >> s[i] >> t[i] >> x[i];

		s[i] -= x[i];
		t[i] -= x[i];

		v.pb (mp (mp (s[i], 1), x[i]));
		v.pb (mp (mp (t[i], -1), x[i]));
	}

	sort (all (v));
	
	set <int> st;
	int id = 0;
	for (int i = 1; i <= q; i ++) {
		int c; cin >> c;
		while (id < sz (v) && c >= v[id].first.first) {
			if (v[id].first.second == 1) {
				st.insert (v[id].second);
			} else {
				st.erase (v[id].second);	
			}
			++ id;
		}

		if (!st.empty ())
			cout << *st.begin () << endl;
		else
			cout << -1 << endl;
	}
}



Measured memory_bytes: 18540
/*=============================================================================================================================/*
                                               Bismillahir Rahmanir Rahim

      _     ____  ___  ____   _   _  _         ___  ____   _         _     __  __
     / \   / ___||_ _|| __ ) | | | || |       |_ _|/ ___| | |       / \   |  \/  |
    / _ \  \___ \ | | |  _ \ | | | || |        | | \___ \ | |      / _ \  | |\/| |
   / ___ \  ___) || | | |_) || |_| || |___     | |  ___) || |___  / ___ \ | |  | |
  /_/   \_\|____/|___||____/  \___/ |_____|   |___||____/ |_____|/_/   \_\|_|  |_|

   _   __           __  __  __
  |_) (_  _  o__   /   (_  |_
  |_)o__)(_  || |  \__ __) |__

    ___                    _   _      _                _ _               __   ___                 _         _        _
   / __|_ _ ___ ___ _ _   | | | |_ _ (_)_ _____ _ _ __(_) |_ _  _   ___ / _| | _ ) __ _ _ _  __ _| |__ _ __| |___ __| |_
  | (_ | '_/ -_) -_) ' \  | |_| | ' \| \ V / -_) '_(_-< |  _| || | / _ \  _| | _ \/ _` | ' \/ _` | / _` / _` / -_|_-< ' \
   \___|_| \___\___|_||_|  \___/|_||_|_|\_/\___|_| /__/_|\__|\_, | \___/_|   |___/\__,_|_||_\__, |_\__,_\__,_\___/__/_||_|
                                                            |__/                           |___/


   FB: https://facebook.com/SIAsibul
   Gmail: asibulislam8@gmail.com

/*=============================================================================================================================*/

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vii;
typedef vector<pil> vil;
typedef vector<pli> vli;
typedef vector<pll> vll;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,n) for(ll i=0;i<(n);i++)
#define f1(i,n) for(ll i=1;i<=(n);i++)
#define f2(i,a,n) for(ll i=(a);i<=(n);i++)
#define fr(i,n,a) for(ll i=(n);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))
#define nl "\n"


const int INF = 1e9 + 5;
const int MXN = 2e5 + 5;
const int MOD = 1e9 + 7;

void solve(){
    string s; cin >> s;
    int cnt = 0, m = 0;
    f0(i, s.size()){
        if(s[i] == 'R') cnt++;
        else cnt = 0;
        m = max(m, cnt);
    }
    cout << m << nl;
}



int main(){
    ll t;
    //cin >> t;
    t = 1;
    while(t--){
        solve();
    }
    return 0;
 }


Measured memory_bytes: 3604
require 'matrix'

r, c = gets.split.map(&:to_i)
tmp = []
r.times do
  tmp << gets.split.map(&:to_i)
end
m = Matrix.rows(tmp, true)
tmp = []
c.times do
  tmp << gets.to_i
end
v = Vector[*tmp]
(m * v).each {|i| puts i }



Measured memory_bytes: 9160
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)
 
  val N = in.next().toInt
  val A = Array.ofDim[Long](N+1, N+1)
  for(y <- 1 to N)
    for(x <- 1 to N)
      A(y)(x) = in.next().toLong


  // d[a][b] は辺 e = (a, b) のコスト(存在しない場合はINF, ただし d[i][i] = 0 とする)
  val d = Array.ofDim[Long](N+1, N+1)

  // 初期化
  for(y <- 1 to N)
    for(x <- 1 to N)
      d(y)(x) = A(y)(x)

  // function
  def warshall_floyd() =
    for(k <- 1 to N; i <- 1 to N; j <- 1 to N){
      d(i)(j) = Math.min(d(i)(j), d(i)(k) + d(k)(j))
    }


  // main
  warshall_floyd()

  var flag = true
  breakable {
  for(y <- 1 to N)
    for(x <- 1 to N){
      if(d(y)(x) != A(y)(x)){
        flag = false
        break
      }
    }
  }

  val dp = Array.ofDim[Boolean](N+1, N+1)

  for(i <- 1 to N-1; j <- i+1 to N) {
    if(i != j){
      for(k <- 1 to N){
        if(d(i)(k) + d(k)(j) == A(i)(j) && k != i && k != j) {
          dp(i)(j) = true
        }
      }
    }
  }

  var ans = 0L
  for(i <- 1 to N-1; j <- i+1 to N) {
    if(!dp(i)(j))
      ans += d(i)(j)
  }

  if(flag)
    println(ans)
  else
    println(-1)
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 44216
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));

int main() {
	int n;
	cin >> n;
	int cnt = 0;
	int i = 1;
	while (i <= n) {
		i *= 2;
		cnt++;
	}
	cout << i / 2;
	return 0;
}





Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
 long long int p=100,i,amm;
  float r=0.1;
  cin>>amm;
  i=0;
  while(p<amm)
  {
    p=p*(1+0.01);
    i++;
  }
  cout<<i;
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<math.h>

using namespace std;

void call(int n) {
  int i = 1;
  while(1) {
    int x = i;
    if (x % 3 == 0){
      cout << " " << i;
    } else {
      while(x) {
	if (x % 10 == 3){
	  cout << " " << i;
	  break;
	}
	x /= 10;
      }
    }
    if (++i > n) break;
  }
}

int main () {
  int n;
  cin >> n;
  call(n);
  cout << endl;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp(a,b) std::make_pair(a,b)
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int main(){
  int x;
  cin>>x;
  if(x<1200) prin("ABC");
  else prin("ARC");
  return 0;
}


Measured memory_bytes: 256
N,K = input().split()
D = list(map(int,input().split()))

def check(num,D):
    numStr = str(num)
    for i in range(len(numStr)):
        if int(numStr[i]) in D:
            return False
    return True

n = int(N)
for i in range(n,100000):
    if check(i,D):
        print( i )
        break




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

double distance(double arr[][2], int i, int num[]){
	int ind = num[i];
	int ind1 = num[i+1];
	double x1 = arr[ind][0];
	double y1 = arr[ind][1];
	double x2 = arr[ind1][0];
	double y2 = arr[ind1][1];
	double d = (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
	d = pow(d, 0.5);
	return d;
}

int main(){
	int n;
	cin>>n;
	double arr[n][2];
	int num[n];
	for (int i = 0; i<n; i++){
		cin>>arr[i][0]>>arr[i][1];
		num[i] = i;
	}
	double ans = 0;
	double div = 1;
	for (int i = n; i>=1; i--){
		div*=i;
	}
	do{
		for (int i = 0; i<n-1; i++){
			ans+=distance(arr,i,num);
		}
	}while(next_permutation(num,num+n));
	cout<<fixed<<setprecision(12)<<ans/div;
	return 0;
}

Measured memory_bytes: 4232
N = int(input())
A = [int(i) for i in input().split()]

count_4 = 0
count_2 = 0
for i in A:
    count_4 += int(i % 4 == 0)
    count_2 += int(i % 2 == 0)
no_mul = N - count_2
count_2 -= count_4
if(no_mul <= count_4 or (count_2 == 0 and no_mul <= count_4 +1)):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

#define __m int mid=(l+r)>>1
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1

template<class T>
inline bool rd(T &num) {
    char in;
    bool IsN = false;
    while(in = getchar(), in != '-' && (in < '0' || in > '9'))if(in == EOF)return false;
    in == '-' ? (IsN = true, num = 0) : num = in - '0';
    while(in = getchar(), in >= '0' && in <= '9')num = num * 10 + in - '0';
    return IsN ? num = -num : num, true;
}

#define rep(i,a,b) for(register int i = (a); i< (b); i++)
#define per(i,a,b) for(register int i = (a); i> (b); i--)
#define clr(a) memset(a,0,sizeof(a));
#define inf(a) memset(a,0x3f,sizeof(a));
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define rd2(a,b) rd(a)&&rd(b)
#define rd3(a,b,c) rd(a)&&rd(b)&&rd(c)
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))

string nico;
#ifdef LOCAL
#define bug(x) cout<<#x<<" : "<<x<<endl
#define infile(x) freopen(x,"r",stdin)
#define outfile(x) freopen(x,"w",stdout)
#else
#define bug(x)
#define infile(x)
#define outfile(x)
#endif

const int maxn = 2e5 + 7;
const int inf  = 0x3f3f3f3f;
const LL linf  = (LL)inf << 32 | inf;
const int mod  = 1e9 + 7;

int main() {
    IO;
    LL n,m,d;
    cin>>n>>m>>d;
    LL type=0;
    if(d){
        type=n-d;
        type*=2;
    } else {
        type = n;
    }
    double ans = (1.0*type*(m-1))/(n*n*1.0);
    printf("%.10lf\n",ans);
    bug(type);
    return 0;
}


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


void solve(string N){

	  int l = N.size();
	  int ans = 0;
	  while(l>1){
			int maxi = 0;
			for(int i=1; i<l; i++){
				  int pre = stoi( N.substr(0,i) );
				  int suf = stoi( N.substr(i,l-i) );
				  maxi = max(maxi,pre*suf);
			}
			N = to_string(maxi);
			l = N.size();
			ans++;
	  }
	  cout << ans << endl;

}


int main(){

	  int Q; cin >> Q;
	  for(int i=0; i<Q; i++){
			string N; cin >> N;
			solve(N);
	  }

}

Measured memory_bytes: 3256
import java.io.PrintWriter
import java.util.*

val pw = PrintWriter(System.out)
val sc = Scanner(System.`in`)

fun main(args: Array<String>) {
    val n = sc.nextInt()
    abc161c(n)
}

fun abc161c(n:Int) {
    var summ =0L
    for(i in 1..n){
        for(j in 1..n){
            for(k in 1..n){
                summ += gcd(gcd(i.toLong(),j.toLong()), k.toLong())
            }
        }
    }
    println(summ)
}

fun gcd(a : Long, b : Long) : Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextListOfString() = next().split(" ")
fun nextListOfInt() = nextListOfString().map { it.toInt() }
fun nextListOfLong() = nextListOfString().map { it.toLong() }
fun nextListOfDouble() = nextListOfString().map { it.toDouble() }



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

int main() {
  int n; cin >> n;
  if (n % 2 == 0) {
    cout << n / 2 << endl;
  } else {
    cout << n / 2 + 1 << endl;
  }
  return 0;
}


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

int main() {
  int A;
  cin >> A;
  vector<int> B(A);
  int C;
  C = 0;
  for(int i = 0; i < B.size(); i++){
    cin >> A;
    B.at(A - 1) = C;
    C = C + 1;
  }
  C = 0;
  for(int j = 0; j < B.size(); j++){
    cout << B.at(C) + 1;
    cout << " ";
    C = C + 1;
  }
}

Measured memory_bytes: 1152
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
typedef long long ll;

using namespace std;
char a[100];
char b[100];
int main()
{
    cin >> a;
    cin >> b;
    int len1 = strlen(a);
    int len2 = strlen(b);
    char ans[100];
    char ans1[100];
    int o = 0;
    for(int i = 0; i < len1; i++)
    {
        int sum1 = 0;
        int sum = 0;
        if(i <= len1-len2)
        {for(int j = 0; j < len2; j++)
        {
            if(a[i+j] != '?')
            {
                sum++;
                if(a[i+j] == b[j])
                {
                    sum1++;
                }
            }
        }
//        cout << sum1 << ' ' << sum << endl;
        if(sum1 == sum)
        {
            o++;
            int ji = 0;
            for(int j = 0; j < i; j++)
            {
                if(a[j] == '?')ans[ji++] = 'a';
                else ans[ji++] = a[j];
            }
            for(int j = i; j < len1; j++)
            {
                if(j-i < len2)ans[ji++] = b[j-i];
                else if(a[j] == '?')ans[ji++] = 'a';
                else ans[ji++] = a[j];
                ans[ji] = '\0';
            }
//            cout << ans << endl;
            if(o != 1 && strcmp(ans1, ans) > 0)
            {
                strcpy(ans1, ans);
            }
            if(o == 1)strcpy(ans1, ans);
        }
        }
    }
    if(o != 0)cout << ans1 << endl;
    else cout << "UNRESTORABLE" << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque
class HopcroftKarp:
    def __init__(self, N0, N1):
        self.N0 = N0
        self.N1 = N1
        self.N = N = 2+N0+N1
        self.G = [[] for i in range(N)]
        for i in range(N0):
            forward = [2+i, 1, None]
            forward[2] = backward = [0, 0, forward]
            self.G[0].append(forward)
            self.G[2+i].append(backward)
        self.backwards = bs = []
        for i in range(N1):
            forward = [1, 1, None]
            forward[2] = backward = [2+N0+i, 0, forward]
            bs.append(backward)
            self.G[2+N0+i].append(forward)
            self.G[1].append(backward)

    def add_edge(self, fr, to):
        #assert 0 <= fr < self.N0
        #assert 0 <= to < self.N1
        v0 = 2 + fr
        v1 = 2 + self.N0 + to
        forward = [v1, 1, None]
        forward[2] = backward = [v0, 0, forward]
        self.G[v0].append(forward)
        self.G[v1].append(backward)

    def bfs(self):
        G = self.G
        level = [None]*self.N
        deq = deque([0])
        level[0] = 0
        while deq:
            v = deq.popleft()
            lv = level[v] + 1
            for w, cap, _ in G[v]:
                if cap and level[w] is None:
                    level[w] = lv
                    deq.append(w)
        self.level = level
        return level[1] is not None

    def dfs(self, v, t):
        if v == t:
            return 1
        level = self.level
        for e in self.it[v]:
            w, cap, rev = e
            if cap and level[v] < level[w] and self.dfs(w, t):
                e[1] = 0
                rev[1] = 1
                return 1
        return 0

    def flow(self):
        flow = 0
        G = self.G
        bfs = self.bfs; dfs = self.dfs
        while bfs():
            *self.it, = map(iter, G)
            while dfs(0, 1):
                flow += 1
        return flow

    def matching(self):
        return [cap for _, cap, _ in self.backwards]

def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n

while 1:
    M, N = map(int, input().split())
    if M == N == 0:
        break
    B = []
    while len(B) < M:
        B.extend(map(int, input().split()))
    R = []
    while len(R) < N:
        R.extend(map(int, input().split()))
    hk = HopcroftKarp(M, N)
    for i in range(M):
        for j in range(N):
            if gcd(B[i], R[j]) > 1:
                hk.add_edge(i, j)
    print(hk.flow())



Measured memory_bytes: 41320
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

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

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int[] x = new int[n];
            int[] xsorted = new int[n];
            for (int i = 0; i < n; i++) {
                x[i] = Integer.parseInt(in.next());
                xsorted[i] = x[i];
            }
            Arrays.sort(xsorted);
            int med1 = xsorted[n / 2];
            int med2 = xsorted[(n - 1) / 2];
            for (int i = 0; i < n; i++) {
                if (x[i] <= med2) {
                    out.println(med1);
                } else {
                    out.println(med2);
                }
            }

        }

    }
}



Measured memory_bytes: 61664
n = int(input())
s1 = int(n * (n+1)/2)
s2 = int(n//3 * (n//3 + 1) * 3/2)
s3 = int(n//5 * (n//5 + 1) * 5/2)
s4 = int(n//15 * (n//15 + 1) * 15/2)
 
print(s1 - s2 - s3 + s4)

Measured memory_bytes: 9184
n = int(input())
li = [-1]*n

for i in range(n):
    li[i] = [int(w) for w in input().split()]

dp = [[-1] * 3 for i in range(n)]
dp[0][0] = li[0][0]
dp[0][1] = li[0][1]
dp[0][2] = li[0][2]


for i in range(1, n):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i][j] = max(dp[i][j], dp[i - 1][k] + li[i][j])

print(max(dp[n - 1]))


Measured memory_bytes: 48768
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
// clang-format on

int main() {
    int n, k, c;
    string s;
    cin >> n >> k >> c >> s;

    vector<int> v;
    rep(i, n) if (s[i] == 'o') v.pb(i);

    vector<int> dp(n, -1);
    int mx = 0;
    for (int i = n - 1; i >= 0; --i) {
        if (s[i] == 'o') dp[i] = mx + 1;
        if (i + c < n) mx = max(mx, dp[i + c]);
    }

    int ct = 0, pre = -n;
    for (int i : v) {
        auto itr = upper_bound(all(v), max(i, pre + c));
        int x = 0;
        if (itr != v.end()) x = dp[*itr];

        if (ct + x < k) cout << i + 1 << "\n";

        if (i - pre > c) {
            ++ct;
            pre = i;
        }
    }
    return 0;
}


Measured memory_bytes: 3448
n,k = map(int,input().split())
h = list(map(int,input().split()))

# dp[i] = 足場i(0~n-1)に到着するコストの最小値
dp = [10**18]*(n)
dp[0] = 0

for i in range(n) :
    for j in range(1,k+1) :
        if i+j >= n :
            continue
        dp[i+j] = min(dp[i+j],dp[i]+abs(h[i]-h[i+j]))

print(dp[n-1])

Measured memory_bytes: 52448
#include <bits/stdc++.h>
using namespace std;
string s[2005];
int val[2005][2005];
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)
		cin>>s[i];
	for(int i=0;i<n;i++)
	{
		int cur=0;
		for(int j=0;j<m;j++)
		{
			val[i][j]+=cur;
			if(s[i][j]=='.')
				cur++;
			else
				cur=0;
		}
		cur=0;
		for(int j=m-1;j>=0;j--)
		{
			val[i][j]+=cur;
			if(s[i][j]=='.')
				cur++;
			else
				cur=0;
		}
	}
	for(int j=0;j<m;j++)
	{
		int cur=0;
		for(int i=0;i<n;i++)
		{
			val[i][j]+=cur;
			if(s[i][j]=='.')
				cur++;
			else
				cur=0;
		}
		cur=0;
		for(int i=n-1;i>=0;i--)
		{
			val[i][j]+=cur;
			if(s[i][j]=='.')
				cur++;
			else
				cur=0;
		}
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(s[i][j]=='.')
				ans=max(ans,val[i][j]);
		}
	}
	cout<<ans+1<<"\n";
	return 0;
}



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

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define For(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
// const ll MOD=1000000007ll;
const ll MOD=998244353ll;
const int MAX=510000;



int main(){
    int k, n;
    cin >> k >> n;
    int a[n];
    rep(i, n){
        cin >> a[i];
    }

    int b[n];
    rep(i, n-1){
        b[i] = a[i+1] - a[i];
    }
    b[n-1] = a[0] + k - a[n-1];

    

    int m = b[0];
    rep(i, n){
        m = max(m, b[i]);
    }

    cout << k - m << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    ll x;
    cin >> x;
    cout << x/500*1000+(x%500)/5*5 << "\n";
    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=2e5+10,inf=0x3f3f3f3f;
int n,m,Min[maxn],fa[maxn];
struct Edge{
	int x,y,z;
	bool operator <(const Edge &rhs) const{
		return z<rhs.z;
	}
}E[maxn<<1];
int find(int x){
	if(fa[x]==x) return x;
	return fa[x]=find(fa[x]);
}
int main(){
	memset(Min,inf,sizeof(Min));
	n=read(),m=read();
	REP(i,1,m){
		E[i].x=read(),E[i].y=read(),E[i].z=read();
		chkmin(Min[E[i].x],E[i].z+1);
		chkmin(Min[E[i].y],E[i].z+2);
	}
	int cur=inf;
	REP(i,0,2*n){
		cur+=2;
		chkmin(Min[i%n],cur);
		chkmin(cur,Min[i%n]);
	}
	REP(i,0,n-1) E[++m]=(Edge){i,(i+1)%n,Min[i]};
	sort(E+1,E+m+1);
	REP(i,0,n-1) fa[i]=i;
	ll ans=0;
	REP(i,1,m){
		int x=E[i].x,y=E[i].y,z=E[i].z;
		if(find(x)==find(y)) continue;
		fa[find(x)]=find(y);
		ans+=z;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 9600