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

struct Network
{
    int N = 2, source = 0, sink = 1;
    struct Edge { int source, target, id, reverse; };
    vector<vector<Edge>> adjacency_lists;
    vector<int> capacities, flows;

    Network() : adjacency_lists(2) {}

    int add_vertex()
    {
        adjacency_lists.push_back({});
        return N++;
    }

    void add_undirected_edge(const int a, const int b, const int capacity)
    {
        add_edge(a, b, capacity);
        add_edge(b, a, capacity);
    }

    void add_edge(const int source, const int target, const int capacity)
    {
        if (source == target) return;
        const auto id = int(capacities.size());
        const auto reverse = id+1;
        adjacency_lists[source].push_back({source, target, id, reverse});
        adjacency_lists[target].push_back({target, source, reverse, id});
        capacities.insert(end(capacities), {capacity, 0});
        flows.insert(end(flows), {0, 0});
    }

    int maxflow()
    {
        auto seen = vector<bool>(N);
        const function<int(int, int)> dfs = [&](const int v, const int flow)
        {
            if (v == sink) return flow;

            if (seen[v]) return 0;
            else seen[v] = true;

            for (const auto e : adjacency_lists[v])
            {
                const auto residual = capacities[e.id] - flows[e.id];
                if (residual == 0) continue;
                if (const auto x = dfs(e.target, min(flow, residual)))
                {
                    flows[e.id] += x;
                    flows[e.reverse] -= x;
                    return x;
                }
            }
            return 0;
        };

        auto flow = 0;
        while (true)
        {
            fill(begin(seen), end(seen), false);
            const auto delta = dfs(source, numeric_limits<int>::max());
            if (delta > 0) flow += delta;
            else break;
        }
        return flow;
    }
};

int main()
{
    int R, C; cin >> R >> C;

    auto network = Network();

    auto rows = vector<int>(R);
    for (auto r = 0; r < R; r++)
        rows[r] = network.add_vertex();

    auto columns = vector<int>(C);
    for (auto c = 0; c < C; c++)
        columns[c] = network.add_vertex();

    const auto infinity = R + C;
    for (auto r = 0; r < R; r++)
    {
        string row; cin >> row;
        for (auto c = 0; c < C; c++)
        {
            if (row[c] == 'o')
                network.add_undirected_edge(rows[r], columns[c], 1);
            else if (row[c] == 'S')
            {
                network.source = rows[r];
                network.add_undirected_edge(rows[r], columns[c], infinity);
            }
            else if (row[c] == 'T')
            {
                network.sink = columns[c];
                network.add_undirected_edge(rows[r], columns[c], infinity);
            }
        }
    }

    const auto mincut = network.maxflow();
    cout << (mincut >= infinity ? -1 : mincut) << endl;
}


Measured memory_bytes: 1408
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int P = sc.nextInt();
    int Q = sc.nextInt();
    int R = sc.nextInt();
    int root1 = P+Q;
    int root2 = P+R;
    int root3 = Q+R;
    if ((root1<=root2)&&(root1<=root3)){
      System.out.println(root1);
    } else if((root2<=root1)&&(root2<=root3)){
      System.out.println(root2);
    }else{
      System.out.println(root3);
    }
  }
}

Measured memory_bytes: 21840
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<char>> c(H, vector<char>(W));
  REP(i, H) REP(j, W) cin >> c[i][j];
  ll ans = 0;
  REP(i, 1 << (H)) {
    REP(j, 1 << (W)) {
      ll black = 0;
      REP(k, H) REP(l, W) {
        if (i & 1 << k || j & 1 << l) continue;
        if (c[k][l] == '#') black++;
      }
      if (black == K) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

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

int n;
int64 p[100], q[100], r[100], b[100];
int64 dp[100];

int64 lcm(int64 a, int64 b){
  return a / __gcd( a, b) * b;
}

int64 rec(int idx){
  if(dp[idx]) return dp[idx];
  int64 left = 1, right = 1;
  if(r[idx] != -1) left = rec(r[idx]);
  if(b[idx] != -1) right = rec(b[idx]);
  int64 ret = lcm( left * p[idx], right * q[idx]);
  return dp[idx] = ret / p[idx] + ret / q[idx];
}

int main(){
  while(cin >> n, n){
    fill_n( dp, 100, 0);

    for(int i = 0; i < n; i++){
      cin >> p[i] >> q[i] >> r[i] >> b[i];
      r[i]--, b[i]--;
    }
    int64 ret = 0;
    for(int i = 0; i < n; i++){
      ret = max( ret, rec(i));
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 1168
#include <stdio.h>

int main(void)
{
    int a, b, c;
    int cnt = 0;

    scanf("%d %d %d", &a, &b, &c);

    for(; a <= b; a++) {
        if(c % a == 0)
            cnt++;
    }
    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
  int n; cin>>n;
  string c; cin>>c;
  int cnt=0;
  rep(i,n){
    if(c[i]=='R')cnt++;
  }
  int cnt1=0;
  rep(i,cnt){
    if(c[i]=='R')cnt1++;
  }
  cout<<cnt-cnt1<<endl;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) FOR(i,0,n)

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;

int main(int argc, char const *argv[])
{
	cin.tie(0);
	ios::sync_with_stdio(false);


	int n, m, x;
	int count_left=0;
	int count_right=0;

	cin >> n >> m >> x;
	int A[m];
	rep(i,m)	cin >> A[i];
	//初期位置Xに対して左側の検査
	for (int i = 0; i < m; ++i)
	{
		if (A[i] < x)
		{
			count_left++;
		}
	}
	//初期位置Xに対して右側の検査
	for (int i = 0; i < m; ++i)
	{
		if (A[i] > x)
		{
			count_right++;
		}
	}

	cout << min(count_left, count_right) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  char s[200010] = {0};
  long long c = 0, b = 0;
  fgets(s, 200010, stdin);
  for(int i = 0; s[i] != 0 && s[i] != '\n'; i++){
    if(s[i] == 'B'){
      b++;
    }else{
      c += b;
    }
  }
  printf("%lld\n", c);
  return 0;
}

Measured memory_bytes: 384
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	h, w := nextInt(), nextInt()
	a := make([]string, h)
	for i := range a {
		a[i] = next()
	}

	puts(strings.Repeat("#", w+2))
	for i := range a {
		putf("#%s#\n", a[i])
	}
	puts(strings.Repeat("#", w+2))
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
	int N;
	cin >> N;
	vector<int> a(N);
	for(int i=0;i<N;i++){
		cin >> a[i];
	}
 
	int cost = 1e9;
	for(int i=-100;i<=100;i++){
		int tmp = 0;
		for(int j=0;j<N;j++){
			tmp += pow(a[j]-i,2);
		}
		cost = min(cost,tmp);
	}
	cout << cost << endl;
	return 0;
}

Measured memory_bytes: 256
x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
np = p[:x]
nq = q[:y]
n = np + nq + r
n.sort(reverse=True)
print(sum(n[:x+y]))

Measured memory_bytes: 23328
from collections import Counter

n = int(input())
count = 0
lists =[]
count_dict = Counter()

for i in range(n):
    input_data = ''.join(sorted(input()))
    if input_data in count_dict:
        count += count_dict[input_data]
        count_dict[input_data] += 1
    else:
        count_dict[input_data] = 1

print(count)

Measured memory_bytes: 18232
S = gets.chomp
S[0,2] = if 1 <= S[0,2].to_i && S[0,2].to_i <= 12 then "MM" else "YY" end
S[2,2] = if 1 <= S[2,2].to_i && S[2,2].to_i <= 12 then "MM" else "YY" end
puts({"MMMM"=>"AMBIGUOUS", "YYMM"=>"YYMM", "MMYY"=>"MMYY", "YYYY"=>"NA"}[S])


Measured memory_bytes: 1788
num = int(input())
A = list(map(int, input().split()))
A_str = [str(a) for a in A]
print(' '.join(A_str))
for i in range(1,len(A)):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j-= 1
    A[j+1] = v
    A_str = [str(a) for a in A]
    print(' '.join(A_str))


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

using namespace std;
typedef long long ll;

int main(void) {
    string N;
    cin >> N;

    for(int i = 0; i < 3; i++) {
        if(N[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        } 
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main(){

   string s;
   cin >> s;
   int count=0;
   int n=s.size();
   int m=(n-1)/2;

   string t=s;
   reverse(t.begin(),t.end());

   if(s==t){
      for(int i=0; i<m; i++){
         if(s.at(i)==s.at(m-i-1)){
            count+=1;
         }
      }
   }

   if(count==m){
      cout << "Yes" << endl;
   }
   else{
      cout << "No" << endl;
   }
}

Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7
const ll MOD=1e9+7;
const int N=1000000;



main(){
    int n=in();
    vec primes(2000,1);
    primes[0]=primes[1]=0;
    for(int i=2;i<=n;i++){
        for(int j=i*2;j<=1000;j+=i) primes[j]=0;
    }
    ll ans=1;
    rep2(i,2,n){
        if(primes[i]==0)continue;
        int res=i;
        ll now=0;
        while(res<=n){
            now+=n/res;
            res*=i;
        }
        ans*=(now+1);
        ans%=MOD;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
//const int MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const double pi = acos(-1.0);
const double EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

struct Graph{
    vector<vector<int>> es;
    vector<double> ex, up, ans;
    vector<int> cnt;
    const int n;

    Graph(int n) : n(n){
        es.resize(n);
        ex.resize(n), up.resize(n), ans.resize(n), cnt.resize(n);
    }

    void add_edge(int from, int to, bool directed = false){
        es[from].pb(to);
        if(!directed) es[to].pb(from);
    }

    double dfs1(int now, int pre){
        ex[now] = 0.0, cnt[now] = 0;
        for(auto &e: es[now]){
            if(e == pre) continue;
            cnt[now]++;
            ex[now] += dfs1(e, now);
        }
        if(cnt[now] == 0) return ex[now];
        return ex[now] = 1.0+ex[now]/cnt[now];
    }

    void dfs2(int now, int pre){
        for(auto &e: es[now]){
            if(e == pre) continue;
            if(pre == -1){
                if(cnt[now] == 1) up[e] = 0.0;
                else up[e] = 1.0+((ex[now]-1.0)*cnt[now]-ex[e])/(cnt[now]-1);
            }
            else{
                up[e] = 1.0+((ex[now]-1.0)*cnt[now]-ex[e]+up[now])/cnt[now];
            }
            dfs2(e, now);
        }
    }

    void solve(int root = 0){
        dfs1(root, -1), dfs2(root, -1);
        rep(i, n){
            if(i == root) ans[i] = ex[i];
            else ans[i] = 1.0+((ex[i]-1.0)*cnt[i]+up[i])/(cnt[i]+1);
        }
        rep(i, n) cout << sp(10) << ans[i] << endl;
    }
};

int main(){
    int N;
    cin >> N;
    Graph G(N);
    rep(i, N-1){
        int u, v; cin >> u >> v; u--, v--;
        G.add_edge(u, v);
    }
    G.solve();
}

Measured memory_bytes: 21424
s = input()
x = s[0]
ans = 0
if x == "A":
    y = s[2:len(s)-1]
    z = y.count("C")
    if z == 1:
        a = y.replace("C","")
        word = s[1] + a + s[len(s)-1]
        if word.islower():
            ans += 1
if ans == 1:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};



int main(){
  int n;
  cin >> n;
  vector<int > h(n);
  rep(i,n) cin >> h[i];
  int cnt = 1;
  int ma=h[0];
  rep(i,n-1){
    if(h[i+1]>=ma){
      cnt++;
      ma=h[i+1];
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main() {
    // input cost X from A to B
    int X;
    cin >> X;
    // input cost Y from B to C
    int Y;
    cin >> Y;
    // calculate cost 
    int result;
    result = X + Y / 2;
    // output
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = input()
b = input()
c = input()
ans = 0
for i in range(n):
  if a[i]==b[i] and b[i]==c[i]:
    pass
  elif a[i]==b[i]:
    ans += 1
  elif b[i]==c[i]:
    ans += 1
  elif c[i]==a[i]:
    ans += 1
  else:
    ans += 2
print(ans)
    
  

Measured memory_bytes: 38256
#include<stdio.h>
#include<math.h>

int main()
{
	double limit;
	int floor;
	while (scanf("%lf", &limit) != EOF)
	{
		for (floor = 0;; floor++)
		{
			double speed = sqrt(19.6 * 5 * (floor - 1));
			if (speed >= limit)
			{
				printf("%d\n", floor);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1064
#include<iostream>
#include<vector>
#include<iterator>
#include<algorithm>
using ifs = std::istream_iterator<int>; 
int main(){
	auto v = std::vector<int>(ifs(std::cin),ifs());
	std::sort(v.begin(),v.end());
	std::cout << v[0] + v[1];
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    string s;
    cin >> s;
    int q;
    cin >> q;
    bool rev = false;
    rep(i, q) {
        int t;
        cin >> t;
        if (t == 1) {
            rev = !rev;
        }
        else {
            int f;
            cin >> f;
            string c;
            cin >> c;
            if (f == 1) {
                s.insert(rev?s.size():0, c);
            }
            else {
                s.insert(rev?0:s.size(), c);
            }
        }

    }
    if (rev) reverse(all(s));
    cout << s << endl;
    return 0;
}



Measured memory_bytes: 900
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P; 

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, init, n) for(ll i = init; i <(ll)(n); i++)

int main() {

    double a, b;
    cin >> a >> b;

    int c = (int)ceil((a + b) / 2.0);

    cout << c << endl;


    return 0;
}

Measured memory_bytes: 256
import itertools
N = int(input())
L = sorted(list(map(int,input().split())))
SS = itertools.combinations(L,3)
count = 0

for x,y,z in SS:
    if x + y > z and x + z > y and y + z > x and x != y != z:
        count += 1
print(count)

Measured memory_bytes: 9128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int getInt(){
  int ret = 0, c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

#define mask (0xFF)
int cnt[mask];

int main(){
  int n, i;
  while(n = getInt()){
    const int n2 = n / 2;
    memset(cnt, 0, sizeof(cnt));

    for(i = 0; i < n; i++){
      int a = getInt();
      if(++cnt[a & mask] > n2){
	printf("%d\n", a);
	for(++i; i < n; i++)
	  getInt();
	goto end;
      }
    }

    puts("NO COLOR");

  end:;
  }
  return 0;
}

Measured memory_bytes: 368
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937_64 mt64(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/


int n, dp[5005][5005];
string s;
signed main() {
	cin >> n >> s;
	rep(i, n) {
		rep(j, n) {
			if (s[i] == s[j])chmax(dp[i + 1][j + 1], dp[i][j] + 1);
		}
	}
	int ans = 0;
	REP(i, n + 1)REP(j, n + 1) {
		chmax(ans, min(j - i, dp[i][j]));
	}
	cout << ans << endl;
}

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

template <typename T> T load() { T r; cin >> r; return r; }
template <typename T> vector<T> loadMany(int n) { vector<T> rs(n); generate(rs.begin(), rs.end(), &load<T>); return rs; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	auto s = load<string>();
	auto t = load<string>();
	auto link = vector<array<int, 26>>(s.size());
	auto n = (int)s.size();
	for (auto c=0; c<26; ++c) {
		auto first = (int)(find(s.begin(), s.end(), (char)('a' + c)) - s.begin());
		link[n-1][c] = s[n-1] == (char)('a' + c) ? n-1 : first;
		for (auto i=n-2; i>=0; --i)
			link[i][c] = s[i] == (char)('a' + c) ? i : link[i+1][c];
	}
	auto answer = 0ll;
	auto i = 0;
	for (auto chr : t) {
		auto c = chr - 'a';
		if (link[i][c] == n) {
			cout << "-1\n";
			return 0;
		}
		auto pos = link[i][c];
		if (pos >= i)
			answer += pos - i + 1;
		else
			answer += (n - i + 1) + pos;
		i = (pos + 1) % n;
	}
	cout << answer << '\n';
}


Measured memory_bytes: 10704
from collections import deque

N=int(input())
A=list(map(int,input().split()))

B=deque([])
for i in range(N):
    if i%2==0:
        B.append(A[i])
    else:
        B.appendleft(A[i])

if N%2==0:
    print(*list(B))
else:
    print(*list(B)[::-1])

Measured memory_bytes: 25416
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b && b == c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    int n = Integer.parseInt(sl[0]);
    int k = Integer.parseInt(sl[1]);
    HashSet<Integer> hs = new HashSet<>();
    for(int i = 1; i <= n; i++)
    {
      hs.add(i);
    }

    for(int i = 0; i < k; i++)
    {
      s = r.readLine();
      int d = Integer.parseInt(s);
      s = r.readLine();
      sl = s.split(" ");
      for(int j = 0; j < d; j++)
      {
        hs.remove(Integer.parseInt(sl[j]));
      }
    }

    System.out.println(hs.size());
  }

}

class RemRing
{
  long module;

  public RemRing(long module)
  {
    this.module = module;
  }

  public long sum(long a, long b)
  {
    return (a + b + module) % module;
  }

  public long sub(long a, long b)
  {
    return (a - b + module) % module;
  }

  public long prod(long a, long b)
  {
    return (a * b) % module;
  }

  public long div(long a, long b)
  {
    return (a * inv(b)) % module;
  }

  public long inv(long a)
  {
    long b = this.module;
    long u = 1;
    long v = 0;
    while (b > 0)
    {
      long t = a / b;
      a -= t * b;
      u -= t * v;
      long z = a;
      a = b;
      b = z;
      z = u;
      u = v;
      v = z;
    }
    u %= this.module;
    if (u < 0)
      u += this.module;
    return u;
  }
}

Measured memory_bytes: 38180
n = int(input())
a = list(map(int, input().split()))
min_a = 1000000
max_a = -1000000
sum_a = 0
for i in range(n):
    if min_a > a[i]:
        min_a = a[i]
    
    if max_a < a[i]:
        max_a = a[i]

    sum_a += a[i]

print(min_a, max_a, sum_a)

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

int main(){
	int ng,og,od,ans=0;
	cin >> ng >> og >> od;
	if (od - (og + ng+1) <= 0) {
		ans = od+og;
	}
	else {
		ans = (od + og) - (od - (og + ng+1));
	}
	cout << ans << endl;

}

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

using namespace std;

#define ll long long
#define endl '\n'
#define pb push_back
#define inf 1e9

const ll mod = 1e9+7;
const ll m = 1e9+7;

ll expo_mod(ll x, ll n) //Exponenciação rápida com módulo
{
    if (n == 0)
        return 1;

    ll t = expo_mod(x, n/2); //O resultado já é em módulo

    ll result = (t * t)%mod;

    if (n%2 == 1) //Se n é ímpar
        return (result * (x%mod))%mod; //(a * b) mod m = (a mod m * b mod m) mod m

    return result;
}

int main ()
{
    double n, contador = 0; cin >> n;

    for (int i = 1; i <= n; i++) {
        if (i%2 == 1) {
            contador++;
        }
    }

    cout << setprecision(10) << fixed << (contador/n) << endl;

    return 0;
}


Measured memory_bytes: 256
import heapq

N, M = map(int, input().split())
A = [-int(x) for x in input().split()]
heapq.heapify(A)
for i in range(M):
    x = heapq.heappop(A)
    x = int(x / 2)
    heapq.heappush(A, x)  # pop minimum
print(-sum(A))

Measured memory_bytes: 14180
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define in(a) a=read()
#define out(a) printf("%d\n",a)
ll read(){
    ll f=1,x=0;char c=getchar();
    while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    return x*f;
}
#define inf 0x7fffffff
#define maxn 200010
int main(){
	int n,m;
	in(n);in(m);
	if((n-1)%(m-1))out((n-1)/(m-1)+1);
	 else out((n-1)/(m-1));
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 
 
void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}
 
double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}
 
ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}
 
ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}
 
vec modncrlistp,modncrlistm;
 
ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}
 
ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}
 
ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}
 
ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
int main(){
  startupcpp();
  ll i=1,cnt,N;
  cin>>N;
  vec v(N);
  rep(i,N){
    cin>>v[i];
    if((v[i]+N)%2==0){
      cout<<0<<endl;
      return 0;
    }
  }
  cnt=(N+1)&1;
  if(N&1){v.pb(0);N++;}
  vsort(v);
  i=1;
  while(i<N){
    if(v[i]!=v[i-1]||v[i]!=cnt){
      cout<<0<<endl;
      return 0;
    }
    cnt+=2;
    i+=2;
  }
  cnt=(cnt+1)/2-1;
  cout<<modpow(2,cnt)<<endl;
  return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	int X, A, B;
	cin >> X >> A >> B;

	X = X - A;

	int num = X / B;

	X = X - num * B;

	cout << X << endl;

}






Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
using namespace std;
 
int main(){
    int N,Y;
    cin>>N>>Y;
    bool s=true;

    for(int i=0;i<=N;i++){
        for(int j=0;j<=N-i;j++){
            if(10000*i+5000*j+1000*(N-j-i)==Y){
                cout<<i<<" "<<j<<" "<<N-i-j<<endl;
                s=false;
              	break;
            }
        }
    if(s==false)break;
    }
    if(s)cout<<"-1 -1 -1"<<endl;
}

Measured memory_bytes: 256
//My Conquest Is the Sea of Stars.
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define gcd __gcd
#define pb push_back
#define mp make_pair
#define lowbit(x) x & (-x)
#define PII  pair<int, int> 
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(__typeof(b) i = a; i <= (b); i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i >= (b); i--)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
typedef long long ll;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)1e6 + 5;
const ll INF = 0x3f3f3f3f3f3f3f3f;
using namespace std;

int cnt[5];

int main()
{
	rep(i, 1, 3){
		int u, v; cin >> u >> v;
		cnt[u]++, cnt[v]++;
	}
	int t1 = 0, t2 = 0;
	rep(i, 1, 4){
		if(cnt[i] == 1) t1++;
		else if(cnt[i] == 2) t2++;
	}
	if(t1 == 2 && t2 == 2) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 1000000007
#define MOD 1e9+7
int main(){
  //input
  lint n,i,j,cnt;cin>>n;
  vint a(n);for(i=0;i<n;i++){cin>>a[i];}
  //caricurate
  vsort(a);llint ans=0;
  for(i=0;i<n;i++){
   j=i;cnt=0;
   while((a[i]==a[j])&&(j<n)){
   j++;cnt++;
   }
   if(cnt>a[i]){ans+=cnt-a[i];}else if(cnt<a[i]){ans+=cnt;}
   i=j-1;
  }
  //output
  cout<<ans<<endl;

}

Measured memory_bytes: 640
good_odd = ['R', 'U', 'D']  # Kisuu, Right
good_even = ['L', 'U', 'D']  # Guusuu, Left
is_Right_good = True
is_Left_good = True
S = list(input().rstrip())
result = False
for i, s in enumerate(S, start=1):
    if i % 2 == 0 and is_Left_good:
        if s not in good_even:
            is_Left_good = False
    elif i % 2 == 1 and is_Right_good:
        if s not in good_odd:
            is_Right_good = False
if is_Right_good and is_Left_good:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MP make_pair
#define pb push_back
#define ff first
#define ss second
#define sz(x) x.size()
#define all(c) c.begin(),c.end()
#define int long long
#define fr(i,j,x) for(int i=j;i<x;i++)
#define rep(i,j,x) for(int i=j;i<=x;i++)
#define mem(x,val) memset(x,val,sizeof(x))
//#define endl '\n'
#define vi vector<int>
#define pii pair<int,int>
#define piii pair<int,pii>
 
const int mod=1e9+7;
const int N=1e5+10;
const int MAXN=2e6+10;
const int INF=1e18;

void solve(){
    int n,x,t;
    cin>>n>>x>>t;
    int to=(n+x-1)/x;
    cout<<to*t<<endl;
}


int32_t main()
{
//     #ifndef ONLINE_JUDGE
//         freopen("inputf.in", "r", stdin);
//         //freopen("outputf.in", "w", stdout);
//     #endif
    SPEED;
    int T=1;
    //cin>>T;
    int t1=1;
    while(true)
    {  
        //cout<<"Case #"<<t1<<": ";
        solve();
        t1++;
        if(t1>T)
            break;
    }
}


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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/f.in", "r", stdin);
//  freopen("../IO/f.out", "w", stdout);
#else

#endif
  solve(std::cin, std::cout);
  return 0;
}

const int64_t MOD = 1000000007;
const int64_t M = 128;
const int64_t X = 32768; // >= sqrt(N)

int64_t a[M][X], b[M][X];
void solve(std::istream &in, std::ostream &out) {
  int N, K;
  in >> N >> K;
  for (int i = 1; i < X; i++) {
    a[1][i] = min(i, N);
    b[1][i] = N / i;
  }
  for (int m = 2; m <= K; m++) {
    a[m][0] = 0;
    for (int i = 1; i < X; i++) {
      a[m][i] = (a[m][i - 1] + b[m - 1][i]) % MOD;
    }
    b[m][X - 1] = a[m][N / (X - 1)];
    for (int i = X - 2; i >= 1; i--) {
      b[m][i] = (b[m][i + 1] + a[m - 1][i] * (N / i - N / (i + 1))) % MOD;
    }
  }
  out << b[K][1] << '\n';
}


Measured memory_bytes: 53248
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b,c;cin>>a>>b>>c;
    if(a%2==0||b%2==0||c%2==0){cout<<0<<endl;return 0;}
    else cout<<min(a*b,min(b*c,a*c))<<endl;
}


Measured memory_bytes: 256
using System;

namespace AtCoderBeginnerContest169
{
    class Multiplication1_1
    {
        static void Main(string[] args)
        {
            string[] c = Console.ReadLine().Split();
            var a = int.Parse(c[0]);
            var b = int.Parse(c[1]);
            Console.WriteLine(a * b);
        }
    }
}

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

int main() {
    char ch;
    
    while(1){
        scanf("%c", &ch);
        if ( isalpha(ch) ) {
            if ( islower(ch)) printf("%c", toupper(ch));
            else printf("%c",tolower(ch));
        } else printf("%c", ch);
        
        if (ch == '\n') break;
    }
    return 0;
}


Measured memory_bytes: 3108
#include <stdio.h>

int main(void) {
	int cards[128][14] = {{0}};
	int i, N;
	scanf("%d", &N);
	for(i = 0; i < N; i++) {
	char c; int cn;
	scanf("%c", &c); 
	scanf("%c %d", &c, &cn);
	cards[c][cn] = 1;
	}
	for(i = 1; i <= 13; i++) {
    	if(cards['S'][i] == 0) {
    	printf("S %d\n", i);
    }
  }
	for(i = 1; i <= 13; i++) {
    	if(cards['H'][i] == 0) {
    	printf("H %d\n", i);
    }
}
	for(i = 1; i <= 13; i++) {
		if(cards['C'][i] == 0) {
		printf("C %d\n", i);
	}
}
	for(i = 1; i <= 13; i++) {
		if(cards['D'][i] == 0) {
		printf("D %d\n", i);
	}
}
	return 0;
}



Measured memory_bytes: 2140
import sys
import math

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline

MOD = 10 ** 9 + 7

def main():
    N, K = [int(x) for x in input().split()]

    ans = [0] * (K + 1)
    for i in range(K, 0, -1):
        ans[i] = pow((K // i), N, MOD)
        a = 2
        while i * a <= K:
            ans[i] -= ans[i * a]
            a += 1

    ans2 = 0
    for i in range(1, K + 1):
        ans2 += i * ans[i]
        ans2 %= MOD

    print(ans2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 82564
#include<bits/stdc++.h>
#define int long long
#define rep(i,m,n) for(int i=m;i<n;i++)
#define repr(i,n,m) for(int i=n;i>=m ;i--)
#define mod 1000000007
#define float long double
#define pb push_back
#define pi pair<int,int>
#define mp make_pair
#define do int n; cin>>n; vector<int>v1(n); rep(i,0,n) cin>>v1[i];
#define oset tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define print(v1) rep(i,0,v1.size()){cout<<v1[i]<<" ";} cout<<"\n";

// oset s;s.insert(1);*s.find_by_order(index);=value(logn)order_of_key(k)=index

using namespace std;
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.first > b.first);
}
int modulo(int n,int m=1000000007){
    if(n<0){
        return (m-abs(n)%m)%m;
    }
    if(n%m>=0)return n%m; return n%m+m;;
}
bool isPrime(int n){
  for(int i=2;i*i<=n;i++){
    if(n%i==0)
      return false;
  }
  return true;
}
int power(int a,int n){
    if(n==0) return 1;
    if(n==1) return a;
    if(n==2) return (a*a)%mod;
    if(n&1){
        n--;
        return (a*power(power(a,2),n/2))%mod;
    }
    else return (power(power(a,2),n/2))%mod;
}
int fact(int n){
  int total=1;
  rep(i,2,n+1){
    total=(total*i)%mod;
    // cout<<total+mod<<"\n";
  }
  return (total)%mod;
}
int isLeap(int i){
  if(i%4==0){
    if(i%100==0&&i%400!=0)
      return 0;
    return 1;
  }
  return 0;
}
void solve()
{ 
  int n,z=0;
  cin>>n;
  rep(i,0,n){
    int a,b;
    cin>>a>>b;
    if(a==b)
      z++;
    else
      z=0;
    if(z==3)
    {
      cout<<"Yes";
      return;
    }
  }
  cout<<"No";
    
} 
 
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
   // #ifndef ONLINE_JUDGE
   // freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
   // #endif
   int t=1;
   //cin>>t;
   while(t--)
   {
      solve();
      cout<<"\n";
   }
   cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
  return 0;
 }

Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int makePrimes(int m,int n){
    vector<int>  pr(7368792, 1);
    int res;
    int cnt=0;
    pr[0] = pr[1] = 0;
    for(int p=m;p<7368792&&cnt<n;p++){
    	if (pr[p]){
         pr[p] =0;
         cnt ++;
    	 for (int x = p * 2; x <= 7368792; x += p){
           pr[x] = 0;
         }
        }
    }
    for(int p=m;p<7368792;p++){
     if (pr[p] && cnt==n){
       res=p;
       return res;
     }
    }
}
    
    

int main(){
	while(true){
		int M,N;cin >> M>>N;
		if(M==0 && N ==0) break;
		int ans=makePrimes(M,N);
		cout << ans << endl;

	}
}


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

using namespace std;

const int N = 2500;

long long f[51][N + 10];
int n, m;

int main() {
	scanf("%d%d", &n, &m);
	f[0][0] = 1;

	long long ans = 0;
	
	for (int i = 1; i <= n; ++i) {
		int a;
		scanf("%d", &a);
		for (int j = n; j >= 1; --j) {
			for (int k = N; k >= a; --k) {
				f[j][k] += f[j - 1][k - a];
			}
		}
	}
	
	for (int i = 1; i <= n; ++i) {
		ans += f[i][i * m];
	}
	
	printf("%lld", ans);
	return 0;
}

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

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

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

    int ans = 0x3f3f3f3f;
    for (int i = 0; i <= 150; i++){
        int tmp = 0;
        for (auto j: a)
            tmp += (j - i) * (j - i);
        ans = min(ans, tmp);
    }

    cout << ans << '\n';
    
    return 0;
}


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

int main()
{
	int n, m, p;
	while (cin >> n >> m >> p, n || m || p) {
		vector<vector<vector<int>>> bo(n, vector<vector<int>>(n, vector<int>(n)));
		vector<int> a(p), b(p);
		for (int i = 0; i < p; i++) {
			cin >> a[i] >> b[i];
			a[i]--;
			b[i]--;
		}
		int tmp = 1;
		bool f = true;
		for (int i = 0; i < p; i++) {
			int id = 0;
			while (bo[a[i]][b[i]][id]) id++;
			bo[a[i]][b[i]][id] = tmp;
			bool flag = false;
			for (int j = 0; j < n; j++) {
				for (int k = 0; k < n; k++) {
					for (int l = 0; l < n; l++) {
						if (bo[j][k][l]) {
							for (int x = -1; x <= 1; x++) {
								for (int y = -1; y <= 1; y++) {
									for (int z = -1; z <= 1; z++) {
										if (x || y || z) {
											int tx = j + x * (m - 1), ty = k + y * (m - 1), tz = l + z * (m - 1);
											if (tx >= 0 && tx < n && ty >= 0 && ty < n && tz >= 0 && tz < n) {
												bool ff = true;
												for (int t = 1; t < m; t++) {
													if (bo[j][k][l] != bo[j + t * x][k + t * y][l + t * z]) {
														ff = false;
														break;
													}
												}
												if (ff) {
													flag = true;
													goto EXIT;
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		EXIT:
			if (flag) {
				f = false;
				cout << (tmp == 1 ? "Black" : "White") << ' ';
				cout << i + 1 << endl;
				break;
			}
			tmp = 3 - tmp;
		}
		if (f) {
			cout << "Draw" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3124
x, y, a, b, c = map(int,input().split())
red = list(map(int,input().split()))
green = list(map(int,input().split()))
non = list(map(int,input().split()))


red_trunc = sorted(red,reverse=True)[:x]
green_trunc = sorted(green,reverse=True)[:y]
# print(red_trunc)
# print(green_trunc)
total = non + red_trunc + green_trunc
total = sorted(total, reverse=True)
print(sum(total[:x+y]))

Measured memory_bytes: 22752
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define INF 100000000
#define MOD 1000000007
using namespace std;


int main(){
    long long H,W;
    cin>> H>>W;
    
    if(H%3==0 || W%3==0){
        cout<<0<<endl;
        return 0;
    }
    
    long long m=min(H,W);
    
    for(long long w=1; w<=W-1; w++){
        long long s1=H*w;
        long long s2=(W-w)*(H/2);
        long long s3=(W-w)*H - s2;
        
        long long L=max(s1,max(s2,s3));
        long long S=min(s1,min(s2,s3));
        
        m=min(m,L-S);
    }
    
    for(long long h=1; h<=H-1; h++){
        long long s1=h*W;
        long long s2=(H-h)*(W/2);
        long long s3=(H-h)*W - s2;
        
        long long L=max(s1,max(s2,s3));
        long long S=min(s1,min(s2,s3));
        
        m=min(m,L-S);
    }
    
    cout<<m<<endl;
    return 0;
}


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

int n, ara[105];
int fun(int pos){
    int sum = 0;
  	for(int i=0; i<n; i++)
      	sum += (ara[i]-pos)*(ara[i]-pos);
    return sum;
}

int main(){
  	int sum=0; cin >> n;
  	for(int i=0; i<n; i++)
      	cin >> ara[i], sum += ara[i];
  	int pos = sum / n;
  	cout << min(fun(pos), fun(pos+1)) << '\n';
 	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

enum {
    A = 0,
    C,
    G,
    T
};

int const MOD = 1e9+7;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;

    ll cnt[4][4][4];
    ll cntnext[4][4][4];
    memset(cnt, 0, sizeof(cnt));
    memset(cntnext, 0, sizeof(cntnext));

    rep(i, 4){
        rep(j, 4){
            rep(k, 4){
                if(i == A && j == C && k == G) continue;
                if(i == G && j == A && k == C) continue;
                if(i == A && j == G && k == C) continue;

                cnt[i][j][k] = 1;
            }
        }
    }

    reps(in, 3, n){
        
        rep(i, 4){
            rep(j, 4){
                rep(k, 4){
                    rep(s, 4){
                        if(j == A && k == G && s == C) continue;
                        if(j == G && k == A && s == C) continue;
                        if(j == A && k == C && s == G) continue;
                        if(i == A && j == G && k == G && s == C) continue;
                        if(i == A && j == T && k == G && s == C) continue;
                        if(i == A && j == G && k == T && s == C) continue;

                        cntnext[j][k][s] += cnt[i][j][k] % MOD;
                    }
                }
            }
        }

        rep(i, 4){
            rep(j, 4){
                rep(k, 4){
                    cnt[i][j][k] = cntnext[i][j][k];
                }
            }
        }
        memset(cntnext, 0, sizeof(cntnext));
    }

    ll ans = 0;
    rep(i, 4){
        rep(j, 4){
            rep(k, 4){
                ans = (ans + cnt[i][j][k]) % MOD;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var A, B, C, D int
	fmt.Scan(&A, &B, &C, &D)

	for A > 0 && C > 0 {
		if C - B > 0 {
			C = C - B
		} else {
			fmt.Println("Yes")
			break
		}
		if A - D > 0 {
			A = A - D
		} else {
			fmt.Println("No")
			break
		}
	}
}

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

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

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}




void _main() {
        int n; cin >> n;
        vector<double> a(n); cin >> a;
        sort(all(a), greater<>());
        while (a.size() > 1) {
                double x = a.back(); a.pop_back();
                double y = a.back(); a.pop_back();
                a.emplace_back((x + y) / 2);
        }

        cout << a.back();
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

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

typedef long long int ll;

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int sum;
    cin >> sum;
    
    double dimension = (double) sum / 3.0;
    double maxVol = dimension * dimension * dimension;
    
    cout.precision(12);
    cout << fixed << maxVol << "\n";

    return 0;
}


Measured memory_bytes: 256