akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
const int INF = 1e9;

using namespace std;

class Edge
{
public:
    Edge(int t, int c, int r) : to(t), cap(c), rev(r){}
    int to;
    int cap;
    int rev;
};

class Graph
{
private:
    vector< vector < Edge > > graph;
    vector<bool> used;
    int max_v;
    
    int dfs (int v, int t, int f)
    {
        if (v == t) return f;
        used[v] = true;
        for (auto& e : graph[v]) {
            if (!used[e.to] and e.cap > 0) {
                int d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    graph[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

public:
    explicit Graph (int v)
    {
        graph = vector< vector < Edge > >(v);
        max_v = v;
    }

    void add_edge (int from, int to, int cap)
    {
        graph[from].push_back((Edge){to, cap, static_cast<int>(graph[to].size())});
        graph[to].push_back((Edge){from, 0, static_cast<int>(graph[from].size()-1)});
    }
    
    int max_flow (int s, int t)
    {
        int flow = 0;
        while (true) {
            used = vector<bool>(max_v, false);
            int f = dfs(s, t, INF);
            if (f == 0) return flow;
            flow += f;
        }
    }
};


int main()
{
    int a,b,c;
    int V,E; cin >> V >> E;
    Graph g = Graph(V);
    for(int i = 0 ; i < E ; i++){
        cin >> a >> b >> c;
        g.add_edge(a,b,c);
    }
    cout << g.max_flow(0,V-1) << endl;
    return 0;
}



Measured memory_bytes: 3120
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  while (cin >> n) {
    int ans = 0;
    REP(a, 10) REP(b, 10) REP(c, 10) {
      int d = n - a - b - c;
      if (0 <= d && d < 10) ans++;
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 2980
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Ord

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    (ai:as) <- sortOn Down <$> getIntList
    let aj = solve ai as
    putStr $ show ai
    putStr " "
    putStrLn $ show aj

solve m as | null bs = s
           | null ss = b
           | even m = if mid - s < b - mid then s else b
           | odd m = if mid - s < b - (mid+1) then s else b
    where mid = m `div` 2
          (bs,ss) = span (> mid) as
          b = last bs
          s = head ss

Measured memory_bytes: 24956
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
2 10 20
---+/

void main(string[] args) {
  long r, D, x2000;
  readf(" %d %d %d ", &r, &D, &x2000);

  long ans = x2000;
  foreach (i; 0..10) {
    ans = r*ans - D;
    ans.writeln;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

const long long N = 100100;
long long n, l[N], r[N];
set <pair<long long, long long> > sl, sr;

void err(long long i) {
	sl.erase({-l[i], i});
	sr.erase({r[i], i});
}

void go_left(long long & ans, long long & last, long long &ok) {
	if(sl.empty())  ok = 0;
	auto x = *sl.begin();
	x.st *= -1;
	// dbg(x, last);
	if(x.st > last) ans += (x.st - last), last = x.st;
	else ok = 0;
	
	err(x.nd);
}

void go_right(long long & ans, long long &last, long long &ok) {
	if(sr.empty())  ok = 0;
	auto y = *sr.begin();
	// dbg(y, last);
	if(y.st < last) ans += (last - y.st), last = y.st;
	else ok = 0;

	err(y.nd);
}

long long try1() {
	long long ok = 1, ans = 0;

	long long last = 0;

	while(ok) {
		go_left(ans, last, ok);
		if(!ok) break;
		go_right(ans, last, ok);
	}
	ans += abs(last);
	return ans;
}


long long try2() {
	long long ok = 1, ans = 0;

	long long last = 0;

	while(ok) {
		go_right(ans, last, ok);
		if(!ok) break;
		go_left(ans, last, ok);
	}
	ans += abs(last);
	return ans;
}

int main() {
	ios_base::sync_with_stdio(false);

	cin >> n;
	for(long long i = 1; i <= n; i++) {
		cin >> l[i] >> r[i];
		sl.insert({-l[i], i});
		sr.insert({r[i], i});
	}

	auto ssl = sl;
	auto ssr = sr;
	long long ans1 = try1();
	dbg_ok;
	sl = ssl;
	sr = ssr;
	long long ans2 = try2();

	dbg(ans1, ans2);

	cout << max(ans1, ans2) << '\n';
}	



Measured memory_bytes: 28928
K=int(input())
from collections import deque
q=deque([1,2,3,4,5,6,7,8,9])

for k in range(K):
    x=q.popleft()
    if x%10!=0:
        q.append(10*x+(x%10-1))
    q.append(10*x+(x%10))
    if x%10!=9:
        q.append(10*x+(x%10+1))
print(x)

Measured memory_bytes: 12384
#include <iostream>

using namespace std;

int main(void) {
	int a[5], i = 0, k;
	for (; i < 5; i++)
		cin >> a[i];
	cin >> k;
	if (a[4] - a[0] > k)
		cout << ":(\n";
	else
		cout << "Yay!\n";
	return 0;
}

Measured memory_bytes: 256
/*
      author  : nishi5451
      created : 14.08.2020 14:11:26
*/

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


int main(){
    int n,k;
    cin >> n >> k;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(l.begin(),l.end(),greater<int>());
    int sum = 0;
    rep(i,k) sum += l[i];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<math.h>
int main (void)
{
  int x,y;
  scanf("%d %d",&x,&y);
  if (x>y) {
    printf("a > b\n");
  }
  else if (x<y){
    printf("a < b\n");
  }
  else{
    printf("a == b\n");
  }

  return 0;
}



Measured memory_bytes: 2044
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long r = inputLongArray[0];
            long D = inputLongArray[1];
            long x = inputLongArray[2];
            string[] result = new string[10];
            for(int j =0;j<10;j++)
            {
                x = r * x - D;
                result[j] = x.ToString();
            }
            string str = "";
            for (int z = 0; z < 10; z++)
            {
                if (z != 9)
                {
                    str += result[z] + "\n";
                }
                else
                {
                    str += result[z];
                }
            }
            Console.WriteLine(str);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


Measured memory_bytes: 11348
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f
#define pi 3.1415926535898
using namespace std;
const int mod=1e9+7;
ll m,n,p;
ll zero[1010];
ll one[1010];
ll pows(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1)
        {
            ans=ans*a%mod;
        }
        a=a*a%mod;
        n=n>>1;
    }
    return ans;
}

int main()
{
    cin>>n;
    ll ans=0;
    for(int i=1; i<=n; i++)
    {
        ll x;
        cin>>x;
        for(int k=64; k>=1; k--)
        {
            if(x&(1ll<<(k-1)))
            {
                ans+=zero[k]*pows(2,k-1);
                one[k]++;
                ans%=mod;
            }
            else
            {
                ans+=one[k]*pows(2,k-1);
                zero[k]++;
                ans%=mod;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The Value Of " << #val << " is : " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 1e5+5;
ll n, ans=0;
unordered_map<char, ll>cnt; 
ll store[]={0, 0, 0, 0, 0};

int main(){
	IOS
	cin >> n;
	for(int i=0;i<n;i++){
		string s;
		cin >> s;
		cnt[s[0]]++;	
	}
	for(int i=0;i<5;i++){
		if(i==0) store[i]=cnt['M'];
		if(i==1) store[i]=cnt['A'];
		if(i==2) store[i]=cnt['R'];
		if(i==3) store[i]=cnt['C'];
		if(i==4) store[i]=cnt['H'];
	}
	for(int mask=0;mask<(1<<5);mask++){
		if(__builtin_popcount(mask)!=3) continue;
		ll temp=1;
		for(int i=0;i<5;i++){
			if((mask>>i)&1){
				temp*=store[i];
			}
		}
		ans+=temp;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3624
import math
def facts(n):
    ans = []
    for  i in range(1, int(math.sqrt(n)+1)):
        if(n%i==0):
            ans.append(i)
            ans.append(n//i)
    ans = sorted(ans)
    return ans


x = int(input())
ans = 1
cnt = 101
while(cnt < x):
    ans+=1
    cnt+=(cnt//100)
print(ans)


Measured memory_bytes: 63288
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 100010;
ll a[N], b[N], c[N], A[N], B[N], C[N], ans, n;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for (ll i = 1; i <= n; i++)
		cin >> a[i];
	for (ll i = 1; i <= n; i++)
		cin >> b[i];
	for (ll i = 1; i <= n; i++)
		cin >> c[i];
	sort(a + 1, a + 1 + n);
	sort(b + 1, b + 1 + n);
	sort(c + 1, c + 1 + n);
	fill(C, C + 1 + n, 1);
	for (ll i = n; i; i--)
		C[i] = C[i] + C[i + 1];
	for (ll i = 1; i <= n; i++)
	{
		ll k = upper_bound(c, c + 1 + n, b[i]) - c;
		B[i] = C[k];
	}
	for (ll i = n; i; i--)
		B[i] = B[i] + B[i + 1];
	for (ll i = 1; i <= n; i++)
	{
		ll k = upper_bound(b, b + 1 + n, a[i]) - b;
		A[i] = B[k];
	}
	for (ll i = 1; i <= n; i++)
		ans += A[i];
	cout << ans;
}

Measured memory_bytes: 4992
n = int(input())
h = list(map(int, input().split()))
res = 0

while max(h) > 0:
    i = 0
    while i < n:
        if h[i] == 0:
            i += 1
        else:
            res += 1
            while i < n and h[i] > 0:
                h[i] -= 1
                i += 1
    
print(res)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>

typedef long long ll;

using namespace std;

int n,m;

bool calc(unordered_map<int,unordered_map<int,bool> > &graph) {
	vector<int> below(n+1);
	vector<int> upper(n+1);
	int s = 0;
	int s_max = 0;
	for(int i = 1; i <= n; i++) {
		if(s_max<graph[i].size()) {
			s_max = graph[i].size();
			s = i;
		}
	}
	//cout << "S=" << s << endl;
	queue<int> q;
	q.push(s);
	below[s] = -1;
	while(!q.empty()) {
		int q_size = q.size();
		//cout << "Q_SIZE=" << q_size << endl;
		for(int loop = 0; loop < q_size; loop++) {
			int now = q.front();q.pop();
			for(pair<int,bool> p : graph[now]) {
				int next = p.first;
				//cout << "(now,next)=" << now << "," << next << endl;
				//cout << next << "," << s << "," << below[now] << "," << below[now] << endl;
				if(((below[next]!=0))&&(below[now]!=next)) {
					int back_start = next;
					int back_end = now;
					int c = 0;
					while(back_end!=-1) {
						//return false;
						//cout << "(" << back_start << "->" << back_end << ")" << endl;
						/*
						c++;
						if(c>5) return false;
						*/
						graph[back_start].erase(back_end);
						graph[back_end].erase(back_start);
						int temp = below[back_end];
						back_start = back_end;
						back_end = temp;
					}
					back_start = next;
					back_end = below[next];
					while(back_end!=-1) {
						//return false;
						//cout << "(" << back_start << "->" << back_end << ")" << endl;
						/*
						c++;
						if(c>5) return false;
						*/
						graph[back_start].erase(back_end);
						graph[back_end].erase(back_start);
						int temp = below[back_end];
						back_start = back_end;
						back_end = temp;
					}
					return true;
				}
				else {
					if(below[next]==0) {
						below[next] = now;
						upper[now] = next;
						q.push(next);
					}
				}
			}
		}
	}
	return false;
}

int main() {
	cin >> n >> m;
	unordered_map<int,unordered_map<int,bool> > graph(n+1);
	vector<int> cnts(n+1);
	for(int i = 0; i < m; i++) {
		int a,b;
		cin >> a >> b;
		graph[a][b] = true;
		graph[b][a] = true;
		cnts[a]++;
		cnts[b]++;
	}
	for(int i = 1; i <= n; i++) {
		if(cnts[i]%2!=0) {
			cout << "No" << endl;
			return 0;
		}
	}
	/*
	for(int i = 0; i < 3; i++) {
		cout << calc(graph) << endl;
	}
	*/
	for(int i = 0; i < 3; i++) {
		if(!calc(graph)) {
			cout << "No" << endl;
			return 0;
		}
		//cout << endl;
	}
	cout << "Yes" << endl;
	return 0;
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(15);

    int N, K;
    cin >> N >> K;

    int ans = INT_MAX;

    vi x(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i];

        if (i >= K - 1) {
            int l = x[i - K + 1];
            int r = x[i];

            int cand;
            if (r < 0) {
                cand = abs(l);
            } else if (l > 0) {
                cand = r;
            } else {
                cand = abs(l) + r + min(abs(l), r);
            }

            ans = min(ans, cand);
        }
    }

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



Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int mod=1e9+7;
const int N=2000010,maxn=2000000;

int l[4],r[4],u[4],d[4];
int cj[N],inv[N];

int ans,sum;

int power(int x,int y){
	int ret=1;
	for(;y;y>>=1,x=1ll*x*x%mod){
		if(y&1)	ret=1ll*ret*x%mod;
	}
	return ret;
}

void init(){
	int i;
	cj[0]=1;rep(i,1,maxn)	cj[i]=1ll*cj[i-1]*i%mod;
	inv[maxn]=power(cj[maxn],mod-2);inv[0]=1;
	for(i=maxn-1;i;i--)	inv[i]=1ll*inv[i+1]*(i+1)%mod;
}

int C(int i,int j){
	return 1ll*cj[i]*inv[j]%mod*inv[i-j]%mod;
}

int work1(int x,int y){
	int tmp1=0;int i,j;
	tmp1=(C(x-r[1]+y-d[1],y-d[1])+C(x-l[1]+1+y-u[1]+1,x-l[1]+1)-C(x-l[1]+1+y-d[1],y-d[1])-C(x-r[1]+y-u[1]+1,x-r[1]))%mod;
	tmp1=(tmp1+mod)%mod;
//	rep(i,l[1],r[1]){
//		rep(j,u[1],d[1]){
//			tmp1=(tmp1+C(x-i+y-j,y-j))%mod;
//		}
//	}
	return tmp1;
}
int work2(int x,int y){
	int i,j,tmp2=0;
	tmp2=(C(l[3]-x+u[3]-y,l[3]-x)+C(r[3]+1-x+d[3]+1-y,r[3]+1-x)-C(l[3]-x+d[3]+1-y,l[3]-x)-C(r[3]+1-x+u[3]-y,u[3]-y))%mod;
	tmp2=(tmp2+mod)%mod;
//	rep(i,l[3],r[3]){
//		rep(j,u[3],d[3]){
//			tmp2=(tmp2+C(i-x+j-y,j-y))%mod;
//		}
//	}
	return tmp2;
}

/*void work(int x,int y){
	return 1ll*work1(x,y)*work2(x,y)%mod;
}*/

int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	int i,j;int tmp1,tmp2,tmp3;
	init();
	scanf("%d%d%d%d%d%d",&l[1],&r[1],&l[2],&r[2],&l[3],&r[3]);
	scanf("%d%d%d%d%d%d",&u[1],&d[1],&u[2],&d[2],&u[3],&d[3]);
	
//	rep(i,l[2],r[2])
//		rep(j,u[2],d[2])
//			work(i,j);
	rep(i,l[2],r[2]){
		tmp1=work2(i,d[2]+1);
		tmp2=work1(i,d[2]);
		tmp3=1ll*tmp1*tmp2%mod;
		sum=(sum+tmp3)%mod;
		ans=(ans-1ll*tmp3*(r[2]-i)%mod+mod)%mod;
		tmp1=work2(i,u[2]);
		tmp2=work1(i,u[2]-1);
		tmp3=1ll*tmp1*tmp2%mod;
		ans=(ans-1ll*tmp3*(i-l[2])%mod+mod)%mod;
	}
	rep(j,u[2],d[2]){
		tmp1=work2(r[2]+1,j);
		tmp2=work1(r[2],j);
		tmp3=1ll*tmp1*tmp2%mod;
		sum=(sum+tmp3)%mod;
		ans=(ans-1ll*tmp3*(d[2]-j)%mod+mod)%mod;
		tmp1=work2(l[2],j);
		tmp2=work1(l[2]-1,j);
		tmp3=1ll*tmp1*tmp2%mod;
		ans=(ans-1ll*tmp3*(j-u[2])%mod+mod)%mod;
	}
	ans=(ans+1ll*(r[2]-l[2]+d[2]-u[2]+1)*sum)%mod;
			
	printf("%d\n",ans);
}
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		

Measured memory_bytes: 15744
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <cctype>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

#define inf 0x3f3f3f3f
typedef long long LL;
#define cls(x) memset(x,0,sizeof(x))
#define For(i,j,k) for(register int i=(j);i<=(k);++i)
#define Rep(i,j,k) for(register int i=(j);i>=(k);--i)
#define rint register int
#define il inline


const int N=2000+5;
int n,k,tot=1;
int head[N],ver[N<<1],nxt[N<<1],edge[N<<1];

il void add(int x,int y,int z)
{ ver[++tot]=y; nxt[tot]=head[x]; head[x]=tot; edge[tot]=z; }
int d[N][N];
int v[N];
void dfs(int x,int u)
{
    v[x]=u;
    for(rint i=head[x];i;i=nxt[i])
    {
        int y=ver[i]; if(v[y]==u) continue;
        d[u][y]=d[u][x]+edge[i];
        dfs(y,u);
    }
}

int ans=inf;
int main()
{
    scanf("%d %d",&n,&k);
    For(i,1,n-1) {int x,y; scanf("%d%d",&x,&y); add(x,y,1); add(y,x,1);}
    For(i,1,n) dfs(i,i);

    if(k&1)
    {
        for(rint i=2;i<=tot;i+=2)
        {
            int x=ver[i],y=ver[i^1]; int c=0;
            for(rint z=1;z<=n;++z)
                c+=(d[x][z]>k/2 && d[y][z]>k/2);
            ans=min(ans,c);
        }
    }
    else
    {
        for(rint x=1;x<=n;++x)
        {
            int c=0;
            for(rint y=1;y<=n;++y)
                c+=(d[x][y]>k/2);
            ans=min(ans,c);
        }
    }
    printf("%d\n",ans);
    return 0;
}

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

int main(){
    int N, K; cin >> N >> K;
    vector<int> HPs;
    for(int i=0; i<N; i++){
        int H; cin >> H;
        HPs.push_back(H);
    }
    sort(HPs.begin(), HPs.end());
    //cout << "hoge " << endl;
    for(int i=0; i<K; i++){
        if(HPs.size()==0) break;
        HPs.erase(HPs.end()-1);
    }
    //cout << "hoge2 " << endl;

    long sum = 0;
    for(int i=0; i<HPs.size(); i++){
        sum+=HPs[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	vector<int> v;
	int flag = 0;
	int cnt = 0;
	rep(i,n) {
		if ((flag == 0 && s[i] == 'L') || (flag == 1 && s[i] == 'R')) {
			cnt++;
		} else {
			v.push_back(cnt);
			cnt = 1;
			flag = 1 - flag;
		}
	}
	if (cnt) v.push_back(cnt);
	int ans = 0;
	for (int t: v) {
		if (t > 1) ans += t - 1;
	}
	cout << min(ans + 2 * k, n - 1) << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep2(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 100100100;

// Binary indexed tree (0-indexed)
template<typename T>
struct BIT {
  int n; vector<T> d;
  BIT(int n=0) : n(n), d(n+1) {}
  void add(int i, T a) {for (i++; i <= n; i += i & -i) d[i] += a;}
  T sum(int i) {T x = 0; for (i++; i > 0; i -= i & -i) x += d[i]; return x;}
};

int main(){
  ll N, D, A;
  cin >> N >> D >> A;
  vector<P> XH(N);
  rep(i, N){
    ll x, h;
    cin >> x >> h;
    XH[i] = P(x, (h + A - 1) / A);
  }
  sort(ALL(XH));

  BIT<ll> bit(N);
  ll ans = 0;

  rep(i, N){
    ll x, h;
    tie(x, h) = XH[i];
    h -= bit.sum(i);
    if(h <= 0) continue;
    int j = upper_bound(ALL(XH), P(x + 2*D, INF)) - XH.begin();
    bit.add(i, h);
    if(j < N) bit.add(j, -h);
    ans += h;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <stack>

using namespace std;

int main() {
    int n;
    stack<int> s;
    while (true) {
        cin >> n;
        if (cin.eof()) {
            return 0;
        }
        if (n == 0) {
            cout << s.top() << endl;
            s.pop();
        }
        else {
            s.push(n);
        }
    }
}

Measured memory_bytes: 1200
def sep():
    return map(int,input().strip().split(" "))
def lis():
    return list(sep())
import sys
sys.setrecursionlimit(10**6)

x,y,a,b,c=sep()
red=lis()
green=lis()
colorless=lis()
red.sort(reverse=True)
green.sort(reverse=True)
colorless.sort()
red=red[:x][::-1]
green=green[:y][::-1]
i=0
j=0
while(colorless):
    if j>=y and i>=x:
        break
    elif j<y and i>=x:
        if colorless[-1]>green[j]:
            green[j]=colorless[-1]
            colorless.pop()
            j+=1
        else:
            break
    elif i<x and j>=y:
        if colorless[-1]>red[i]:
            red[i]=colorless[-1]
            colorless.pop()
            i+=1
        else:
            break

    elif red[i]<=green[j]:
        if colorless[-1]>red[i]:
            red[i]=colorless[-1]
            colorless.pop()
            i+=1
        else:
            break
    else:
        if colorless[-1]>green[j]:
            green[j]=colorless[-1]
            colorless.pop()
            j+=1
        else:
            break
#print(red,green)
print(sum(red) + sum(green))





Measured memory_bytes: 100316
private const val MOD = 1000000007L

fun main() {
    val (n, k) = readLine()!!.split(" ").map { it.toLong() }
    val result = (k..n + 1).asSequence().map { (n + 1 - it) * it + 1 }.map { it % MOD }.sum()
    println(result % MOD)
}

Measured memory_bytes: 52444
#include <iostream>
using namespace std;
    int main(void){
        int a, b;
        char op;
        while(true){
            cin >> a >> op >> b;
            if ( op == '+' ){
                cout << a+b ;
                }
            else if ( op == '-' ){
                cout << a-b ;
                }
            else if ( op == '*' ){
                cout << a*b ;
                }
            else if ( op == '/' ){
                cout << a/b ;
                }
            else {
                break;
                }
            cout << endl;
            }
        cin >> a >> op >> b;
    }


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll MOD = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	int N, ans=0;
	string S1, S2;

	cin >> N;
	cin >> S1 >> S2;

	ll dp[60][3][3]={};
	rep(i,3) rep(j,3){
		if( (S1[0] == S2[0]) ^ (i == j) ) continue;
		dp[0][i][j] = 1;
	}
	rep(i,N-1) rep(k,3) rep(l,3) rep(x,3) rep(y,3){
		if( S1[i] != S1[i+1] && k == x ) continue;
		if( S1[i] == S1[i+1] && k != x ) continue;
		if( S2[i] != S2[i+1] && l == y ) continue;
		if( S2[i] == S2[i+1] && l != y ) continue;
		if( (S1[i+1] == S2[i+1]) ^ (x == y) ) continue;
		dp[i+1][x][y] += dp[i][k][l];
		dp[i+1][x][y] %= MOD;
	}

	rep(x,3) rep(y,3) ans += dp[N-1][x][y];
	ans %= MOD;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

vector<vector<int> > g;

int main()
{
	int n,m;
	cin>>n>>m;
	g.resize(4*n,vector<int>());
	for(int i = 0; i < m; i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		g[a].push_back(b+n);
		g[a+n].push_back(b+2*n);
		g[a+2*n].push_back(b);
	}
	int s,t;
	cin>>s>>t;
	s--;t--;

	vector<ll> dist(4*n,-1);

	// priority_queue<ll,vector<ll>,greater<ll> > q;
	queue<ll> q;
	dist[s] = 0;
	q.push(s);
	while(!q.empty()){
		int p = q.front();
		q.pop();
		// if(dist[p]>=0) continue;
		for(int i = 0; i < g[p].size(); i++){
			if(dist[g[p][i]] < 0){
				dist[g[p][i]] = dist[p]+1;
				q.push(g[p][i]);
			}
		}
	}

	// ll ans = INF*INF;
	// for(int i = 0; i < 3; i++){
	// 	if(dist[t+n*i]%3==0 && dist[t+n*i]/3 < ans ) ans = dist[t+n*i]/3;
	// }
	// cout<<(ans==INF*INF?-1:ans)<<endl;
	cout<<(dist[t]%3==0?dist[t]/3:-1)<<endl;

	
	return 0;
}

Measured memory_bytes: 22144
//
// Created by yuu on 2019-06-29.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>

using namespace std;


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

    int p[100];
    for (int i = 0; i < n; ++i) {
        cin>>p[i];
    }

    int count = 0;

    for (int i = 0; i < n-2; ++i) {
        if((p[i]<p[i+1] && p[i+1]<p[i+2])|| (p[i]>p[i+1] && p[i+1] > p[i+2])){
            count++;
        }
    }

    cout<<count<<endl;

    return 0;
}

Measured memory_bytes: 256
def main():
  from collections import deque
  k=int(input())
  e=[[]for _ in range(k)]
  for i in range(k):
    e[i].extend([(i*10%k,0),(-~i%k,1)])
  q=deque([1])
  p,l,r=q.pop,q.appendleft,q.append
  f=[10**18]*k
  f[1]=1
  while q:
    v=p()
    for w,d in e[v]:
      c=f[v]+d
      if f[w]>c:
        (r,l)[d](w)
        f[w]=c
  print(f[0])
main()

Measured memory_bytes: 57392
#include <stdio.h>
   
int main(void){
   
  int house[4][3][10] = {0};
  int n,b,f,r,v;
  register int i,j,s;
   
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d %d %d %d",&b,&f,&r,&v);
    house[b-1][f-1][r-1] += v;
  }
  for(s = 0;s < 4;s++){
    for(j = 0;j < 3;j++){
      for(i = 0;i < 10;i++){
        printf(" %d",house[s][j][i]);
      }
      printf("\n");
    }
    if(s != 3){
      printf("####################\n");
    }
  }
  return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <string>
#include <sstream>
#include <cstring>
#include <cmath>

using namespace std;

#ifdef DEBUG
#define LOG(args) cout << args << "\n"
#define debug(x) x
#else
#define LOG(args)
#define debug(x)
#endif

#define vi vector<int>
#define ii pair<int, int>
#define vii vector< ii >
#define vvi vector< vi >
#define mp make_pair
#define pb push_back
#define ms(x, v) memset(x, v, sizeof(x))
#define all(x) x.begin(), x.end()
#define REP(x, n) for(int x = 0; x < n; x++)
#define REPV(x, v, n) for(int x = v; x < n; x++)
#define REVE(x, n) for(int x = n; x >= 0; x--)

typedef long long ll;

class Fenwick
{
	int idx, N;
	vector<ll> bit;

public:
	Fenwick(int N): N(N)
	{
		bit.assign(N + 1, 0);
	}

	ll sum(int idx)
	{
		ll ret = 0;
		for(; idx; idx -= (idx & (-idx)))
			ret += bit[idx];
		return ret;
	}

	ll sum(int l, int r)
	{
		return sum(r) - sum(l - 1);
	}

	void upd(int idx, ll val)
	{
		for(; idx <= N; idx += (idx & (-idx)))
			bit[idx] += val;
	}
};

struct Query
{
	int l, r, idx;

	bool operator<(const Query &rhs) const
	{
		return r < rhs.r;
	}
};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int N, Q;
	cin >> N >> Q;
	vi vals(N);
	for(auto &x : vals)
		cin >> x;
	vector<Query> queries(Q);
	REP(i, Q)
	{
		cin >> queries[i].l >> queries[i].r;
		queries[i].idx = i;
	}
	sort(all(queries));
	Fenwick bit(N);
	vi last(N + 5, -1), ans(Q);
	int qno = 0;
	REPV(i, 1, N + 1)
	{
		if(last[vals[i - 1]] != -1)
			bit.upd(last[vals[i - 1]], -1);
		bit.upd(i, 1);
		last[vals[i - 1]] = i;
		while(queries[qno].r == i && qno < Q)
		{
			ans[queries[qno].idx] = bit.sum(queries[qno].l, queries[qno].r);
			qno++;
		}
		if(qno >= Q)
			break;
	}
	for(int v : ans)
		cout << v << "\n";
	return 0;
}













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

using ll = long long;

const int MAXN = 20;
int N;
ll A[MAXN];

ll mem[MAXN * MAXN / 2][1 << 19];

ll solve(int i, int j, ll wi, ll wj, uint32_t state) {
	if (j - i <= 1) {
		return 0;
	}
	int ind = (j - 1) * (j - 2) / 2 + i;
	if (mem[ind][state] != -1) {
		return mem[ind][state];
	}
	ll ans = 1e18;
	ll wk = wi + wj;
	for (int k = i+1; k <= j-1; k++) {
		ll cnd = wk * A[k];
		cnd += solve(i, k, wi, wk, state * 2 + 0);
		cnd += solve(k, j, wk, wj, state * 2 + 1);
		ans = min(ans, cnd);
	}
	return mem[ind][state] = ans;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	memset(mem, -1, sizeof(mem));
	ll ans = A[0] + A[N-1] + solve(0, N-1, 1, 1, 1);
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 819584
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.14159265359
#define all(v) v.begin(),v.end()
#define vil vector<long int>
#define vi vector<int> 
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ub upper_bound
#define lb lower_bound
#define INF 1000000007 
#define MOD 998244353
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define fill(s,x,n) vector
 x(n); rep(i,0,n) cin>>x[i];
#define sec second
#define fir first
#define acc(v) accumulate(v.begin(),v.end(),0)
bool mysort(const pair<int,int> &a,  
               const pair<int,int> &b){
                   if(a.first==b.first){
                       return a.sec<b.sec;
                   }
                   return a.first<b.first;
    
}
 
ll power(ll a, ll b){
	ll res=1;
	while(b--){
		res*=a;
	}
	return res;
}
void solve(){
int n,k;
cin>>n>>k;
fill(int,a,n);
vector<bool> dp(k+1,false);
for(int i=1;i<=k;i++){
    for(int j=0;j<n;j++){
        if(i<a[j]){break;
        }
        if(!dp[i-a[j]]){
         dp[i]=true;
    }
}
}
if(dp[k]){
    cout<<"First"<<endl;
}
else{
    cout<<"Second"<<endl;
}
}

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

Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a*a+b*b == c*c) cout << a*b/2 << endl;
  if(b*b+c*c == a*a) cout << b*c/2 << endl;
  if(a*a+c*c == b*b) cout << a*c/2 << endl;
}

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


using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vll a(n);
		vll b(n);
		vll p(n);

		for(int i=0;i<n;i++)
		{
			scanf("%lld", &a[i]);
		}
		for(int i=0;i<n;i++)
		{
			scanf("%lld", &b[i]);
		}

		int ans=0;
		ll lack=0;
		for(int i=0;i<n;i++)
		{
			if(b[i]>a[i])
			{
				ans++;
				lack+=b[i]-a[i];
			}
			p[i]=a[i]-b[i];
		}
		sort(p.rbegin(), p.rend());
		for(int i=0;i<n;i++)
		{
			if(lack<=0) break;
			lack-=p[i];
			ans++;
		}
		if(lack>0) ans=-1;
		printf("%d\n", ans);
	}

	return 0;
}



Measured memory_bytes: 2560
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N,K;
    cin>>N>>K;
    
    cout<<N+1-K<<endl;
    
    return 0;
}


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

using namespace std;

#define FC ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define FIN freopen("in.txt","r",stdin)
#define FOUT freopen("out.txt","w",stdout)
#define deb(x) cerr<<"DEBUG------"<<'\n';cerr<<#x<<"------>";err(x)

template<typename T>
void err(T a){
    cerr<<a<<'\n';
    cerr<<"END OF DEBUG"<<'\n'<<'\n';
}

const long double PI=acos(-1.0);  
const long double eps=1e-6;
const long long maxw=(long long)1e17+(long long)10;

using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

/*head------[@cordercorder]*/

const ll maxn=(ll)3010;

double dp[maxn][maxn];
int N;
double p[maxn];

void solve(){
    dp[0][0]=1.0;
    for(int i=1;i<=N;i++){
        for(int j=0;j<=i;j++){
            if(i-1>=j){
                if(j==0){
                    dp[i][j]=dp[i-1][j]*((double)1-p[i]);
                }
                else{
                    dp[i][j]=dp[i-1][j]*((double)1-p[i])+dp[i-1][j-1]*p[i];
                }
            }
            else{
                dp[i][j]=dp[i-1][j-1]*p[i];
            }
        }
    }
    double ans=0;
    for(int i=(N+1)/2;i<=N;i++){
        ans+=dp[N][i];
    }
    printf("%.11lf\n",ans);
}

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

Measured memory_bytes: 69120
n, k, q = map(int, input().split())
a_answer = []
for i in range(q):
    a = int(input())
    a_answer.append(a)

a = [k]*n

for i in range(q):
    a[a_answer[i]-1] += 1

for i in range(n):
    a[i] -= q

for i in range(n):
    if a[i]<=0:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 11948
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
   ll int n,i,ans=0;
   string s;
   char p;
   cin>>n;
   cin>>s;
   ans=1;
   p=s[0];
   for(i=1;i<n;i++)
   {
       if(p!=s[i])
       {
           ans++;
           p=s[i];
       }
   }
   cout<<ans<<endl;

return 0;
}

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

int main(void){
	int n;
	std::map<char,int> m;
	std::map<int,int> m2;

	string s;
	cin>>n;
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(s[i]!='+'){
			m[s[i]]++;
		}
	}
	int c=0;

	for(map<char,int>::iterator it=m.begin();it!=m.end();it++){
		m2[it->second]++;
	}

	for(map<int,int>::iterator it=m2.begin();it!=m2.end();it++){
		if(it->first>1){
			// 2*(a+b)
			c+=2; // 2*
			c+=it->second; // a b c
			c+=it->second-1; // +
			c+= 2; // ()
			if(it->second==1) c-=2;
		}else if(it->first==1){
			c+=it->second; // a b c
			c+=it->second-1; // +
		}
		c++;
	}
	c--;
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 3220
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<algorithm>
#include<map>
#include<bitset>
#include<math.h>
///////////////////////////////////////////
using namespace std;
#define _GLIBCXX_DEBUG
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define vl vector<long long>
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define F first
#define S second
long long qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
int qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e18;


//////////////////////////////////////////////////

int main() {
	vector<int> pn(55556, 1);
	for (int i = 2; i <= sqrt(55555); i++) {
		for (int j = 1; j <= 55555; j++) {
			if (i != j && j %i == 0) pn[j] = 0;
		}
	}

	/////////////////////////
	int n; cin >> n;
	////////////////////////

	vector<int> ans;
	ans.pb(2);
	for (int i = 3; i <= 55555; i+=10) {
		if (pn[i] == 1) ans.pb(i);
	}
	if (ans.size() >= n) {
		for (int i = 0; i < n; i++) {
			printf("%d ", ans[i]);
		}
		printf("\n");
		return 0;
	}
	else {
		vector<int>ans2;
		ans2.pb(2);
		for (int i = 11; i <= 55555; i += 10) {
			if (pn[i] == 1) ans2.pb(i);
		}
		for (int i = 0; i < n; i++) {
			printf("%d ", ans2[i]);
		}
		printf("\n");
		return 0;
	}
}

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

map<pair<string,string>,int> info;
pair<string,string> t;
int main(){
  /*pair<string,sring> A;
  A.first = "abc";
  A.second = "ABC";
  info[A] ++;
  cout<<info[A]<<endl;
  */
  int N,F,a,ans=0;
  cin>>N>>F;
  string s[10];;
  for(int i=0;i<N;++i){
    cin>>a;
    for(int j=0;j<a;++j)cin>>s[j];
    sort(s,s+a);
    for(int j=0;j<a;++j){
      for(int k=j+1;k<a;++k){
	t.first=s[j];
	t.second=s[k];
	info[t]++;
	if(info[t]==F) ans++;
      }
    }
  }


  cout<<ans<<endl;
  map<pair<string,string>,int> :: iterator it;
  for(it = info.begin();it!=info.end();it++){
    if(it->second < F) continue;
    string a = it->first.first;
    string b = it->first.second;
    cout<<a<<" "<<b<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3508
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <climits>
#include <cmath>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
using namespace std;

#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef pair<int,int> pii;
template<typename T> using min_queue=priority_queue<T,vector<T>,greater<T>>;

const ll MOD=1e9+7;

int N;
ll M, a[100100];

ll lcm(ll a, ll b) {return a/__gcd(a,b)*b; }
int main(){
  ios::sync_with_stdio(0);cin.tie(0);

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

  ll p=a[0] - (a[0] & (a[0]-1));

  ll m = a[0]>>1;
  for(int i=1;i<N;i++) {
    if ((a[i]&(p-1)) || !((a[i]/p)&1)){
      cout<<"0\n";
      return 0;
    }
    m = lcm(m, a[i]>>1);
  }

  // cout << p << ' ' << m << endl;
  cout << M/m - M/(2*m) << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <set>
using namespace std;
const int MAX = 300001;


int main(){
	int list[MAX];
	for(int i = 2; i < MAX; i++){
		if(i % 7 == 1 || i % 7 == 6){
			list[i] = 1;
		}
		else{
			list[i] = 0;
		}
	}
	for(int i = 2; i < MAX; i++){
		if(list[i]){
			for(int j = i*2; j < MAX; j+=i){
				list[j] = 0;
			}
		}
	}
	list[1] = 0;
	list[0] = 0;

	int x;
	while(1){
		cin >> x;
		if(x == 1) break;

		cout << x << ":";
		for(int i = 2; i <= x; i++){
			if(list[i]){
				if(x % i == 0){
					cout << " " << i; 
				}
			}
		}
		cout << endl;
	}
} 

Measured memory_bytes: 2328
import java.awt.Point;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();

        char[][] c = new char[h][w];
        List<Point> startPointList = new ArrayList<>();
        for(int y = 0;y < h;y++) {
            char[] line = sc.next().toCharArray();
            for(int x = 0;x < w;x++) {
                c[y][x] = line[x];
                if(line[x] == '#') startPointList.add(new Point(x, y));
            }
        }

        int[][] costMap = new int[h][w];
        costMap = bfs(startPointList, h, w, c);

        int answer = -1;
        for(int y = 0;y < h;y++) {
            for(int x = 0;x < w;x++) {
                if(c[y][x] =='#') continue;
                answer = answer < costMap[y][x] ? costMap[y][x] : answer;
            }
        }
        
        answer = answer == -1 ? 0 : answer;
        System.out.println(answer);
    }

    private static int[][] bfs(List<Point> startPointList, int h, int w, char[][] c) {
        Deque<Point> q = new ArrayDeque<>();
        boolean[][] footprints = new boolean[h][w];

        int[][] costMap = new int[h][w];
        for(int y = 0;y < h;y++) for(int x = 0;x < w;x++) costMap[y][x] = Integer.MAX_VALUE;
        for(Point p : startPointList) {
            q.offer(p);
            footprints[p.y][p.x] = true;
            costMap[p.y][p.x] = 0;
        }
        
        int[] dx = {0, 0, 1, -1};
        int[] dy = {1, -1, 0, 0};
        while(!q.isEmpty()) {
            Point p = q.poll();

            for(int i = 0;i < 4;i++) {
                int nextX = p.x + dx[i];
                int nextY = p.y + dy[i];
                if(canGo(nextX, nextY, h, w, c, footprints)) {
                    q.offer(new Point(nextX, nextY));
                    footprints[nextY][nextX] = true;
                    int pScore = costMap[p.y][p.x];
                    if(pScore + 1 < costMap[nextY][nextX]) costMap[nextY][nextX] = pScore + 1;
                }
            }
        }

        return costMap;
    }

    private static boolean canGo(int x, int y, int h, int w, char[][] c, boolean[][] footprints) {
        if(x < 0 || x >= w || y < 0 || y >= h) return false;
        if(footprints[y][x]) return false;
        if(c[y][x] == '#') return false;

        return true;
    }

}

Measured memory_bytes: 110344
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<string> s(N);
	for (int i = 0; i < N; ++i) { cin >> s[i]; }

	vector<pair<int, int>> a, b;
	for (int i = 0; i < N; ++i) {
		int sum = 0, min_s = 1e8;
		for (auto c : s[i]) {
			if (c == '(') { ++sum; }
			else { --sum; }
			min_s = min(min_s, sum);
		}
		if (sum >= 0) { a.emplace_back(-min_s, i); }
		else { b.emplace_back(min_s - sum, i); }
	}

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	int sum = 0;
	for (auto p : a) {
		for (auto c : s[p.second]) {
			if (c == '(') { ++sum; }
			else { --sum; }
			if (sum < 0) {
				cout << "No\n";
				return 0;
			}
		}
	}
	for (auto p : b) {
		for (auto c : s[p.second]) {
			if (c == '(') { ++sum; }
			else { --sum; }
			if (sum < 0) {
				cout << "No\n";
				return 0;
			}
		}
	}
	cout << (sum == 0 ? "Yes" : "No") << endl;
	
	return 0;
}


Measured memory_bytes: 42532
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1000000007;
const long double PI=3.1415926535;

long long modpow(long long x,long long y,long long z){
  long long ans=1;
  while(y>0){
    if(y&1){
      ans*=x%z;
    }
    x*=x%z;
    x%=z;
    ans%=z;
    y>>=1;
  }
  return ans;
}
 
long long modC(long long x,long long y,long long z){
  long long X=1,Y=1;
  for(long long i=x;i>=(x-y+1);i--){
    X*=i;
    X%=z;
  }
  for(long long i=1;i<=y;i++){
    Y*=i;
    Y%=z;
  }
  Y=modpow(Y,z-2,z);
  X*=Y;
  X%=z;
  return X;
}

int main() {
  ll N,ans=0,x=1;
  cin>>N;
  ll a[N];
  for(ll i=0;i<N;i++){
    cin>>a[i];
    ans+=a[i];
    ans%=MOD;
  }
  ans*=(N-1);
  for(int i=0;i<60;i++){
    x*=2;
    x%=MOD;
    ll c=0;
    for(int j=0;j<N;j++){
      if(a[j]%2==1){
        c++;
      }
      a[j]>>=1;
    }
    ans-=modC(c,2,MOD)*x;
    ans%=MOD;
  }
  while(ans<0){
    ans+=MOD;
  }
  
    
  cout<<ans;
  //cout<<-1000000008%MOD;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 99999999999999999;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;

int main() {
	int a, b, c, k[25], l[25][25], ans = 0;
	cin >> a >> b >> c;
	for (int i = 0; i < b; ++i) { cin >> k[i]; }
	for (int i = 0; i < a; ++i) {
		int sum = 0;
		for (int j = 0; j < b; ++j) {
			cin >> l[i][j];
			sum += l[i][j] * k[j];
		}
		if (sum + c > 0) { ++ans; }
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main{

	public void solve(){
		String str = next();
		out.println(str.substring(0, str.length() - 8));
	}
	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

Measured memory_bytes: 24916