akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define Maxn 200007
using namespace std;
int n,m,cnt=0;
bool check=true;
int last[Maxn],pre[Maxn],other[Maxn],d[Maxn];
void insert(int u,int v)
{
	other[++cnt]=v,pre[cnt]=last[u],last[u]=cnt;
}
void dfs(int u,int fa)
{
	if (fa==0) d[u]=1; else d[u]=1-d[fa];
	for (int q=last[u];q;q=pre[q])
	{
		int v=other[q];
		if (v!=fa)
		{
			if (d[v]==-1) dfs(v,u);
			else if (d[u]+d[v]!=1) check=false;
		}
	}
	if (d[u]==-1) d[u]=1;
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		insert(u,v),insert(v,u);
	}
	memset(d,-1,sizeof(d));
	for (int i=1;i<=n;i++)
		if (d[i]==-1) dfs(i,0);
	if (!check) printf("%lld\n",(1LL*n*(n-1))/2-m);
	else 
	{
		int now=0;
		for (int i=1;i<=n;i++)
			if (d[i]==1) ++now;
		printf("%lld\n",1LL*now*(n-now)-m);
	}
	return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n); for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()

int main() {
    int n,m;
  cin>>n>>m;
  vector<int> a(n)
    rep(i,n) cin>>a[i];
  ld s=0;
  rep(i,n) s+=a[i];
  double std=s/(4*m);
  int count=0;
  rep(i,n){
if(a[i]>=std) count++;
  }
  if(count>=m) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void print_open(){ cout << "Open" << endl; }
void print_close(){ cout << "Close" << endl; }

int main(void)
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a && !b && !c) print_close();
	if (!a && b && !c) print_close();
	if (a && b && !c) print_open();
	if (!a && !b && c) print_open();
	if (!a && !b && !c) print_close();

	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll dp[1<<21];
ll n;
ll a[23][23];
ll bitcnt[1<<21];

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

    dp[0]=1;
    for(int s=1;s<(1<<n);s++){
        bitcnt[s]=bitcnt[s/2]+s%2;
        for(int l=0;l<n;l++){
            if((s>>l)%2==0) continue;
            dp[s]+=dp[s-(1<<l)]*a[bitcnt[s]-1][l];
            dp[s]%=MOD;
        }
    }
    cout<<dp[(1<<n)-1]<<endl;

}

Measured memory_bytes: 33024
from collections import Counter
n = int(input())
lst = list(map(int, input().split()))
lst1 = []
lst2 = []
for i in range(n):
  lst1.append(i+lst[i])
  lst2.append(i-lst[i])
lst1 = Counter(lst1)
lst2 = Counter(lst2)
count = lst1.most_common()
ans = 0
for i in range(len(count)):
  a = lst1[count[i][0]]
  b = lst2[count[i][0]]
  ans += a*b
print(ans)

Measured memory_bytes: 144016
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    int n,a;
    scanf("%d",&n);
    int min=1000000,max=(-1000000);
    long long int sum=0;
    for (int i=1;i<=n;i++){
        scanf("%d",&a);
        if(a<min){
            min=a;
        }
        if(a>max){
            max=a;
        }
        sum+=a;
        
    }
    printf("%d %d %lld\n",min,max,sum);
    return 0;
}



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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  REP(i,N) cin >> A[i];

  int idx = -1;
  REP(i,N) if(A[i] == 1) idx = i;

  int ret = N;
  REP(i,N) {
    int l = i + K - 1;
    if((idx < i) || (idx > l)) continue;
    int tmp = 1;
    tmp += (i + K - 2) / (K - 1);
    if(l < N) tmp += (N - l - 1 + K - 2) / (K - 1);
    ret = min(ret, tmp);
  }
  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 640
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.List

main :: IO ()
main = do
    (k,n) <- (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 readInt <$> BS.getLine
    as <- VU.unfoldrN n readInt <$> BS.getLine
    let bs = VU.toList as
    let ans = max (fun bs) (VU.head as - VU.last as + k)
    print $ k-ans

fun :: [Int] -> Int
fun xs = maximum $ zipWith (-) (tail xs) xs


readInt :: BS.ByteString -> Maybe (Int,BS.ByteString)
readInt xs = do
    (x,ys) <- BS.readInt xs
    return (x,BS.tail ys)

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

using namespace std;

const int maxN = 105;
const int maxW = 1e5+5;
const int INF = 1e9;

long long DP[maxW];
pair<int, int> A[maxN];
int n, w;

void solve() {
    cin >> n >> w;
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        A[i] = {a, b};
    }
    for(int i = 0; i < n; i++){
        int price = A[i].second;
        int weight = A[i].first;
        for(int j = w; j >= 0; j--){
            if(j-weight < 0) break;
            DP[j] = max(DP[j], DP[j-weight]+price);
        }
    }
    cout << DP[w] << "\n";

}

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

    bool multitest = false;
    //multitest = true;
    if (multitest) {
        int t; cin >> t;
        while (t--)
            solve();
    }
    else
        solve();
}


Measured memory_bytes: 4436
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <numeric>
#include <cmath>

using namespace std;

template<class T>
class Input {
public:
    auto operator()() const {
        T v;
        cin >> v;
        return v;
    }
};

template<class L, class R>
class Input<pair<L, R>> {
public:
    auto operator()() const {
        L l;
        R r;
        cin >> l >> r;
        return make_pair(l, r);
    }
};

template<class U>
class Input<vector<U>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        return (*this)(n);
    }
    auto operator()(size_t n) const {
        vector<U> v;
        v.reserve(n);
        Input<U> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in();
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class U>
class Input<vector<vector<U>>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        auto m = in();
        return (*this)(n, m);
    }
    auto operator()(size_t n, size_t m) const {
        vector<vector<U>> v;
        v.reserve(n);
        Input<vector<U>> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in(m);
            v.emplace_back(move(u));
        }
        return v;
    }
};

class InputType
{
public:
    template<class T>
    operator T() const {
        Input<T> i{};
        return i();
    }
};

class InputType2
{
public:
    InputType2(size_t n)
        : n_(n)
    {}
    template<class T>
    operator T() const {
        Input<T> i{};
        return i(n_);
    }
private:
    size_t n_;
};

auto input() {
    return InputType();
}

template<class... Args>
auto input(Args&&... args) {
    return InputType2(std::forward<Args>(args)...);
}

size_t bitcount(size_t n) {
    size_t c = 0;
    while (n) {
        if (n & 1ull)
            ++c;
        n >>= 1;
    }
    return c;
}

auto make_order(size_t n) {
    vector<size_t> a(n, 0);
    iota(begin(a), end(a), 0);
    return a;
}

template<class T>
auto next_permutation(T&& x) {
    using std::begin;
    using std::end;
    return next_permutation(begin(x), end(x));
}

using ll = long long;
using ull = unsigned long long;

auto gcd(size_t l, size_t r) {
    if (r == 0)
        return l;
    return gcd(r, l % r);
}

auto gcd(size_t a, size_t b, size_t c) {
    return gcd(a, gcd(b, c));
}

int main() {
    ll r = input();
    auto a = 2 * r * 3.14159265358979;
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 3772
#include <iostream>

int main()
{
    int n,k,ans = 0;
    std::cin >> n >> k;
    for(int i = 1;i <= n;i++)
    {
        int cnt;
        std::cin >> cnt;
        if(cnt >= k) ans ++;
    }
    std::cout << ans;
    return 0;
}

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

int main(){
        int a,b,c,d,n;
        int count;


        while(cin >> n != 0){
                count = 0;
                for(int a = 0; a < 10; a++){
                for(int b = 0; b < 10; b++){
                for(int c = 0; c < 10; c++){
                for(int d = 0; d < 10; d++){
                        if(a + b + c + d == n)
                                count++;
                }}}}

                cout << count << endl;
        }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int N;
    cin >> N;
    while(N>=1000){
        N = N - 1000;
    }   
    if(N == 0) cout << N << endl;
    else cout << 1000 - N << endl;
}

Measured memory_bytes: 3616
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define INF 100000000000
#define MAX 200001
#define MOD 1000000007  

int main(){
    ll N, M;
    cin >> N >> M;
    vector<int> X(N);
    vector<pair<int, int>> cards(M + 3,{0, 0});
    for(int i = 0; i < N; i++){
        cin >> X[i];
        cards[X[i] % M].first++;
    }
    sort(X.begin(), X.end());
    ll now = X[0];
    ll cnt = 1;
    for(int i = 1; i < N; i++){
        if(now == X[i]){
            cnt++;
            if(i == N - 1) cards[now % M].second += cnt /2;
        } 
        else{
            cards[now % M].second += cnt / 2;
            now = X[i];
            cnt = 1;
        }
    }
    ll ans = cards[0].first / 2;
    for(int i = 1; i < M / 2 + 1; i++){
        if(M % 2 == 0 && i == M / 2) break;
        int a = cards[i].first;
        int b = cards[M - i].first;
        if(a < b){
            int p = cards[M - i].second;
            while(true){
                if(p == 0 or b - 2 < a) break;
                ans++;
                p--;
                b -= 2;
            }
            ans += a;
        }
        else{
            int p = cards[i].second;
            while(true){
                if(p == 0 or a - 2 < b) break;
                ans++;
                p--;
                a -= 2;
            }
            ans += b;
        }
    }
    if(M % 2 == 0) ans += cards[M / 2].first / 2;
    cout << ans << endl;
}

Measured memory_bytes: 4512
n = int(input())
s1 = input() + " "
s2 = input() + " "
 
mod = 1000000007
 
num = 1
i = 0
b = 0
tmp_t = -1
while(b + i < n):
    if s1[i + b] == s2[i + b]: # t 0
        if tmp_t == 0:
            num = (num * 2) % mod
        elif tmp_t == 1:
            num = (num * 1) % mod
        else:
            num = 3
        tmp_t = 0
    else: # t 1
        if tmp_t == 0:
            num = (num * 2) % mod
        elif tmp_t == 1:
            num = (num * 3) % mod
        else:
            num = 6
        tmp_t = 1
        b += 1
    i += 1
 
print(num)

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;
public class Main{
   public static void main(String[] main) throws Exception{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringTokenizer st = new StringTokenizer(br.readLine());
      PrintWriter out = new PrintWriter(System.out);
      long n = Long.parseLong(st.nextToken());
        long next = Long.parseLong(st.nextToken());
       out.println(n*next);
      out.close();
   }
}



Measured memory_bytes: 32872
num_A = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
A.reverse()

INF = 10 ** 6
dp = [-INF for i in range(N + 1)]    # get the max digit size using i matches
dp[0] = 0
for i in range(1, N + 1):
    next_num = [Ai for Ai in A if num_A[Ai] <= i]
    if next_num != []:
        dpi_candidate = [dp[i - num_A[next_numi]] + 1
                         for next_numi in next_num]
        dp[i] = max(dpi_candidate)

remain_match = N
ans = "0"
while remain_match > 0:
    for Ai in A:
        if remain_match >= num_A[Ai] and dp[remain_match - num_A[Ai]] == dp[remain_match] - 1:
            ans += str(Ai)
            remain_match -= num_A[Ai]
            break

print(int(ans[1:]))


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

struct edge {
    int to;
    int cost;
};

int N, M;
vector<vector<edge>> G(20000);
vector<bool> used(20000);
vector<ll> dist(20000);
bool judge = true;

void dfs(int v, ll cost) {
    if (used[v]) {
        if (dist[v] != cost)
            judge = false;
    } else {
        used[v] = true;
        dist[v] = cost;
        rep(i, G[v].size()) { dfs(G[v][i].to, cost + G[v][i].cost); }
    }
}

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

    cin >> N >> M;
    G.resize(N, vector<edge>());
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        G[a].push_back({b, c});
        G[b].push_back({a, -c});
    }

    used.assign(N, false);
    dist.assign(N, 0);
    rep(i, N) {

        // 連結出ない場合があるので全頂点探索。
        if (!used[i]) {
            dist[i] = 0;
            dfs(i, 0LL);
        }
    }

    if (judge)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 15304
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
typedef long long ll;
typedef struct data {
    ll x,y;
    bool operator<(const data& a) const
    {
        return x < a.x;
    }
} stu;

    vector<int> dp[100008];
    int memo[100009];

int dfs(int x){
    if(memo[x]!=-1)return memo[x];
    int m= 0 ; 
    for (vector<int>::iterator i = dp[x].begin(); i != dp[x].end(); ++i)
    {
        m=max(dfs(*i)+1,m);
    }
    memo[x]=m;
    return m ;
}




ll n,m,k,w;

void solve(){

    for (int i = 0; i < 100009; ++i)
    {
        memo[i]=-1;
    }

int x,y,z,v ;
    cin >> x >> y ;
    for (int i = 0; i < y; ++i)
    {
        cin >> z >> v ;
        dp[z].push_back(v);
    }
    int ans=0;
    for (int i = 0; i < 100005; ++i)
    {
        ans=max(ans,dfs(i));
    }
    cout << ans;
}




int main() {

 
        //clock_t startTime = clock();

    solve();
    //cout << double( clock() - startTime ) / (double)CLOCKS_PER_SEC<<  endl;    
    return 0;
}

Measured memory_bytes: 8192
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

alias Key = Tuple!(int, "cost", int, "mask");

int calc(int num, Key[] keys) {
    int n = cast(int)keys.length;
    auto dp = new int[][](n, 1 << num);
    for (int i = 0; i < dp.length; i++) dp[i][] = int.max;

    dp[0][keys[0].mask] = keys[0].cost;
    for (int i = 1; i < n; i++) {
        int cost = keys[i].cost;
        int mask = keys[i].mask;
        dp[i][mask] = cost;
        for (int j = 0; j < (1 << num); j++) {
            if (dp[i-1][j] == int.max) continue;
            dp[i][j] = min(dp[i][j], dp[i-1][j]);
            dp[i][j | mask] = min(dp[i][j | mask], dp[i-1][j] + cost);
        }
    }
    int ans = dp[n-1][(1 << num) - 1];
    return ans == int.max ? -1 : ans;
}

void main() {
    int n, m; scan(n, m);
    Key[] keys;
    foreach (_; 0..m) {
        int a, b; scan(a, b);
        auto c = readints;
        int mask = 0;
        foreach (e; c) mask |= (1 << (e-1));
        keys ~= Key(a, mask);
    }
    writeln(calc(n, keys));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;


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

int main(){
  
  int a, b; cin >> a >> b;
  
  if(a > b * 2){
    
    cout << a - b * 2 << endl;
    
  }else{
    
    cout << 0 << endl;
    
  }
  
  return 0;
  
}

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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    vector<int> ans(n);
    rep(ri, 2) {
        { // solve R
            int cnt = 0;
            rep(i, n) {
                if (s[i] == 'R') cnt++;
                else {
                    ans[i] += cnt/2;
                    ans[i-1] += (cnt+1)/2;
                    cnt = 0;
                }
            }
        }
        reverse(ans.begin(), ans.end());
        reverse(s.begin(), s.end());
        rep(i, n) {
            if (s[i] == 'L') s[i] = 'R';
            else s[i] = 'L';
        }
    }
    rep(i, n) cout << ans[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <iomanip>

using namespace std;
const int LEN = 2e5 + 10;
int p[LEN];
double sum[LEN];

int main() {
    int N, K;
    double ans = 0.0;
    cin >> N >> K;
    for (int i = 1; i <= N; i++) {
        cin >> p[i];
        sum[i] = sum[i - 1] + (1.0 + p[i]) / 2;
    }
    for (int i = 0; i <= N - K; i++) {
        ans = max(ans, sum[K + i] - sum[i]);
    }
    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647 -> 10桁
// MAX ll 9,223,372,036,854,775,807 -> 19桁
// MAX O(n) 10^8 -> 8回
// double pi = M_PI or acos(-1)
// printf("%.10f\n", ans);

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

    ll ans = 1e18;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i != 0) continue;
        ll j = n / i;
        ans = min(ans, i + j - 2);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3616
H, W, K = map(int, input().split())
c = [list(map(str, input().split())) for _ in range(H)]


def get_turn(num):
    ans = [0]*(H+W)
    for ind in range(H+W):
        if num % 2 == 0:
            ans[ind] = 1
        num //= 2
    return ans

def get_color(turn):
    ans = 0
    for i in range(H):
        for j in range(W):
            # print(i, j)
            # print(c[i][j])
            # print(turn[i])
            # print(turn[H+j])
            if c[i][0][j] == "#" and turn[i] != 1 and turn[H+j] != 1:
                ans += 1
    
    return ans

times = pow(2, H+W)
ans = 0
for i in range(times):
    turn = get_turn(i)
    if K == get_color(turn):
        ans += 1

print(ans)

Measured memory_bytes: 9228
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	
	for(int i = n-1; i >= 0; i--) {
		cout << a[i];
		if(i != 0) cout << " ";
	}
	cout << endl;
}





Measured memory_bytes: 3112
#include <cstdio>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
struct edge{
	int to;
	double cost;
};
int main(){
	while(true){
		int n,m,p,a,b;
		scanf("%d%d%d%d%d",&n,&m,&p,&a,&b);
		a--,b--;
		if(n==0) break;
		int t[8];
		vector<edge> G[30];
		double dp[1<<8][30];
		rep(i,n) scanf("%d",t+i);
		rep(i,p){
			int x,y;
			double z;
			scanf("%d%d%lf",&x,&y,&z);
			x--,y--;
			G[x].push_back({y,z});
			G[y].push_back({x,z});
		}
		double inf=1e9;
		rep(i,1<<n) rep(j,m) dp[i][j]=inf;
		dp[0][a]=0;
		rep(i,1<<n){
			rep(j,m){
				if(dp[i][j]==inf) continue;
				rep(k,n){
					if( (i>>k)&1 ) continue;
					rep(l,G[j].size()){
						edge e=G[j][l];
						dp[i+(1<<k)][e.to]=min(dp[i+(1<<k)][e.to],dp[i][j]+e.cost/t[k]);
					}
				}
			}
		}
		double ans=inf;
		rep(i,1<<n) ans=min(ans,dp[i][b]);
		if(ans==inf) printf("Impossible\n");
		else printf("%.6lf\n",ans);
	}
}

Measured memory_bytes: 1176
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std ;

int main(){
    std::ios_base::sync_with_stdio(0);  cin.tie(NULL);  cout.tie(NULL);
    string text , actions ;
    cin >> actions ;
    for(int i = 0 ; i < actions.size() ; i++){
        if(actions[i] == '1') text += '1' ;
        else if(actions[i] == '0') text += '0' ;
        else {
            if(text.size() > 0)
            text.pop_back() ;
        }
    }
    cout << text ;
    return 0 ;
}

Measured memory_bytes: 3652
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    v = LI()
    acnt = collections.Counter(v[::2])
    bcnt = collections.Counter(v[1::2])
    acnt = list(acnt.items())
    bcnt = list(bcnt.items())
    acnt.sort(key=lambda x: x[1], reverse=True)
    bcnt.sort(key=lambda x: x[1], reverse=True)

    ans = 0

    if len(acnt) == len(bcnt) == 1:
        if acnt[0][0] == bcnt[0][0]:
            ans = n//2
        else:
            ans = 0
    elif len(acnt)==1 or len(bcnt) == 1:
        if acnt[0][0] == bcnt[0][0]:
            if len(acnt) != 1:
                ans = n//2 - acnt[1][1]
            else:
                ans = n//2 - bcnt[1][1]
        else:
            ans = n//2 - min(acnt[0][1], bcnt[0][1])
    else:
        if acnt[0][0] == bcnt[0][0]:
            ans = n - acnt[0][1] - max(acnt[1][1], bcnt[1][1])
        else:
            ans = n - acnt[0][1]*2

    print(ans)

main()


Measured memory_bytes: 95536
#include <iostream>

using namespace std;

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

	long long ans = 0;
	for (int K = 1; K <= N; ++K) {
		ans += 1LL * K * (N / K) * (1 + N / K) / 2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3632
import numpy as np
from scipy.optimize import fmin
import sys
from sys import stdin as s
n,k=map(int,s.buffer.readline().split())
Z=np.array(s.buffer.read().split(), np.float64)
X,Y,C=Z[::3],Z[1::3],Z[2::3]
Z=[Z[i*3:i*3+3]for i in range(n)]
def f(x):
  x,y=x
  t=np.sort(C*np.sqrt((X-x)*(X-x)+(Y-y)*(Y-y)))
  return t[k-1]
A=[fmin(f,(x,y),disp=False,ftol=1e-7,initial_simplex=[(x+0.5,y),(x-0.5,y+0.5),(x-0.5,y-0.5)])for x,y,c in Z]
B=list(map(lambda x:f(x),A))
print(min(B))

Measured memory_bytes: 49720
#include<bits/stdc++.h>
using namespace std;
#define faster() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl '\n'
int main()
{
    faster();
    int x;
    cin>>x;
    if(x==0) cout<<1<<endl;
    else cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <vector>
const int INF = 1e9;
using namespace std;
typedef vector<int> vi;
#define rep(i,n) for(int i=0; i<n; i++)
#define reprev(i,n) for(int i=N-1; i>=0; i--)


int main(void) {
  int N;
  cin >> N;
  vi a(N);
  rep(i,N) {
    cin >> a[i];
  }

  vi left(N+1,0), right(N+11,0);

  rep(i,N) {
    left[i+1] = max(left[i],a[i]);
  }
  reprev(i,N) {
    right[i] = max(right[i+1],a[i]);
  }

  rep(i,N) {
    cout << max(left[i],right[i+1]) << endl;
  }

  return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  else if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
	    Scanner sc = new Scanner(System.in);
	    
	    int n = sc.nextInt();
	    String s = sc.next();
	    int count=0;
	    for(int i=0;i<n-2;i++)
	    {
	        String a  = s.substring(i , i+3);
	        if(a.equals("ABC"))
	            count++;
	    }
		System.out.println(count);
	}
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
     
    using namespace std;
 
    int check(int k){
        int val=7;
        int count=1;
        while(val%k!=0){
            val=(val%k)*10 + 7;
            count++;
        }
        return count;
    }
    int main()
    {
    	
        int k;
        cin>>k;
        if(k%2==0 || k%5==0){
            cout<<-1<<endl;
            return 0;
            
        }
        cout<<check(k)<<endl;

		
		
		return 0;
    }

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>

using namespace std;

#define MAX_N 100010

int main() {
    int N, M, H[MAX_N], MAX[MAX_N];

    cin >> N >> M;

    for (int i = 1; i <= N; i++) { //i = 1から
        cin >> H[i];
        MAX[i] = 0;
    }

    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        MAX[a] = max(MAX[a], H[b]);
        MAX[b] = max(MAX[b], H[a]);
    }

    int answer = 0;
    for (int i = 1; i <= N; i++) { //i = 1から
        answer += H[i] > MAX[i];
    }

    cout << answer << endl;

    return 0;
}

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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


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

  lint sum=0;
  for(lint i=0;i<n;i++) { sum += a[i]; }

  lint ans=0;
  if(sum%n == 0) {
    for(lint i=0;i<n;i++) { ans += (a[i]-sum/n)*(a[i]-sum/n); }
  } else {
    lint ans0=0,ans1=0;
    for(lint i=0;i<n;i++) { ans0 += (a[i]-sum/n)*(a[i]-sum/n); }
    for(lint i=0;i<n;i++) { ans1 += (a[i]-sum/n-1)*(a[i]-sum/n-1); }
    ans = min(ans0,ans1);
  }

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


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>
#include <iomanip>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = n-1; i >= 0; --i)
#define REP(i, s, n) for (int i = s; i< (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
ll inf = ll(1e18);
using ll1d = vector<ll>;
using ll2d = vector<ll1d>;
using ll3d = vector<ll2d>;

void solve(istream &ccin = cin, ostream &ccout = cout) {
  ll n, x;
  ccin >> n >> x;
  vector<ll> a(n);
  rep(i, n) ccin >> a[i];
  sort(all(a));
  ll ans = 0;
  ll cnt = 0;
  bool isSSS = false;
  rep(i, n) {
    cnt += a[i];
    ++ans;
    if (cnt > x) {
      --ans;
      break;
    }
    if (x == cnt) {
      break;
    }
  }
  if (accumulate(all(a), 0) < x and ans == n) --ans;
  ccout << ans << endl;

}

int main() {
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define int long long
using namespace std;
signed main() {
    double a, b;
    cin >> a >> b;
    int temp = (int)min(a / 0.08, b / 0.1);
    for(int i = temp; i <= 1250; i++) {
        if(floor(i * 0.08) == a && floor(i * 0.1) == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}
//x*0.08=a
//x*0.1=b;

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

int main()
{
    int d, t, s;
    cin>>d>>t>>s;
    int temp=0;
    long long int ans=t*s;
    if(ans>=d)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    



    return 0;
}

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

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

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  REP(i, 5) {
    int x;
    cin >> x;
    if(x == 0) {
      cout << i + 1 << endl;
      break;
    }
  }
}


Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = Integer.parseInt(sc.nextLine());
        String s = sc.nextLine();
        String test = s.substring(0,s.length() / 2);
        String test2 = s.substring(s.length() / 2);
        if(test.equals(test2)){
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 21844
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}

int main(){
  string s;
  long long k;
  cin >> s >> k;

  for(int i = 0; i < s.size(); i++){
    if(s[i] != '1'){
      cout << s[i] << endl;
      return 0;
    }else if(k - 1 == 0){
      cout << 1 << endl;
      return 0;
    }else{
      k --;
    }
  }

  return 0;
}


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

using namespace std;

array<int, 20000> generate(){
    int cur = 0;
    array<int, 20000> A = {};
    for (int i = 2; i <= 30000; i++){
        if (i % 2 == 0 or i % 3 == 0){
            A[cur] = i;
            cur += 1;
        }
    }

    return A;
}

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

    if (n == 3){
        printf("%d %d %d\n", 2, 5, 63);
        return 0;
    }

    auto A = generate();
    constexpr array<int, 6> B = {30000, 0, 29996, 29997, 29998, 0};

    vector<int> ans(n - 1);
    copy_n(A.begin(), n - 1, ans.begin());
    int m = accumulate(ans.begin(), ans.end(), 0) % 6;

    if (m == 5){
        ans[3] = B[3];
        ans.push_back(B[4]);
    } else {
        ans.push_back(B[(6 - m) % 6]);
    }

    copy_n(ans.begin(), n, ostream_iterator<int>(cout, " "));
    cout << endl;

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll               long long
#define mod              1000000007
#define endl              "\n"
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb                push_back
#define all(v)             v.begin(),v.end()
#define inp(V,n)      for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)     {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
using namespace std;
ll factorial(ll n)
{
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
ll gcd(ll a, ll b)
{
    if (a == 0)
      return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
   return (a*b)/gcd(a, b);
}
bool sortByVal(const pair<ll,ll> &a,
               const pair<ll,ll> &b)
{
    return (a.second > b.second);
}
ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}
ll sumofdigit(ll n)
{
    ll c=0,d=0,sum=0,i;
    while(n>0)
    {
        c=n%10;
        sum+=c;
        n/=10;
    }
    return sum;
}
int main()
{
     fast;
     int t=1;
     //cin>>t;
     while(t--)
     {
       ll c=0,i,j,d=0,sum=0,e=0,f=0,g=0,h=0,n,maxi=0;
       cin>>n;
       vector<ll> a(n-1);
       map<ll,ll> m;
       for(i=0;i<n-1;i++)
       {
           cin>>a[i];
            m[a[i]]++;
       }
       for(i=1;i<=n;i++)
       {
           cout<<m[i]<<endl;
       }





     }

}



Measured memory_bytes: 17188
#include <iostream>
#include<algorithm>
#define INF 2000001;
using namespace std;
int main(void){
    int N;
    cin >> N;
    int cnt = 0;
    int mn = INF;
    for(int i=0;i<N;i++){
        int temp;
        cin >> temp;
        if(temp < mn){
            mn = temp;
            cnt++;
        }
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int w,h,n,x,y,a,W=0,H=0;
  scanf("%d%d%d",&w,&h,&n);
  while(n--){
    scanf("%d%d%d",&x,&y,&a);
    if(a==1&&W<x)W=x;
    if(a==2&&x<w)w=x;
    if(a==3&&H<y)H=y;
    if(a==4&&y<h)h=y;
  }
  printf("%d",W<w&&H<h?(w-W)*(h-H):0);
  return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int n, l;
	cin >> n >> l;
	vector<string> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	sort(s.begin(), s.end());
	for (int i = 0; i < n; i++) {
		cout << s[i];
	}
	cout << "\n";
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    int b[n-1];
    for (int i = 0; i < n-1; ++i) {
        cin >> b[i];
    }

    std::vector<int> v;
    for (int i = 0; i < n-1; ++i) {
        if ( i == 0 ) {
            v.push_back(b[i]);
            if ( b[i] <= b[i+1] ) {
                v.push_back(b[i]);
            } else {
                v.push_back(b[i+1]);
            }            
        } else {
            if ( i != n-2 ) {
                if ( b[i] <= b[i+1] ) {
                    v.push_back(b[i]);
                } else {
                    v.push_back(b[i+1]);
                }
            } else {
                v.push_back(b[i]);
            }

        }
    }
    cout << accumulate(v.begin(), v.end(), 0LL) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;

ll A[400];
ll B[400];
ll dp[400][400];

ll f(int i, int j) {
  if(i == j) return 0;
  if(dp[i][j]) return dp[i][j];
  ll mx = 1e18;
  for(int k = i; k < j; ++k)
    mx = min(mx, f(i, k) + f(k + 1, j));
  return dp[i][j] = B[j] - B[i] + A[i] + mx;
}

int main() {
  int n; cin >> n;
  for(int i = 0; i < n; ++i)
    cin >> A[i];
  
  B[0] = A[0];
  for(int i = 1; i < n; ++i)
    B[i] = B[i - 1] + A[i];
  
  cout << f(0, n - 1);
  
  return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>

using namespace std;

typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef map<int, int> M;
typedef pair<int, int> P;
typedef stack<int> S;
typedef queue<int> Q;

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

    int n;
    cin >> n;
    for (int i = 0; i <= 25; ++i)
    {
        if (4 * i == n)
        {
            cout << "Yes" << endl;
            return 0;
        }
        for (int j = 0; j <= 15; ++j) 
        {
            if (4 * i + 7 * j > 100) break;
            if (4 * i + 7 * j == n)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout<< "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
int cnt[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    cnt[x]++;
  }
  bool found = false;
  for (int i = n - 1; i >= 0; i -= 2) {
    if (!((i == 0 && cnt[i] == 1) || cnt[i] == 2)) {
      found = true;
      break;
    }
  }
  if (found) {
    puts("0");
  } else {
    int ret = 1;
    for (int i = 0; i < n / 2; ++i) {
      ret = ret * 2 % MOD;
    }
    printf("%d\n", ret);
  }
  return 0;
}


Measured memory_bytes: 640
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
    
    int A,B,C;
    // 入力
    cin >> A >> B >> C;
   
    string ans = "NO";
    if (A == 5 and B == 5 and C == 7){
        ans = "YES";
    }
    if (A == 5 and B == 7 and C == 5){
        ans = "YES";
    }
    if (A == 7 and B == 5 and C == 5){
        ans = "YES";
    }
    
    //　出力
    cout << ans << endl;
}


// if (条件式)｛
     
//    }


Measured memory_bytes: 3624
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-24 18:58:49
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << '}';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << '}';
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << '}';
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

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

  int n; cin >> n;

  for (int i = 0; i <= n; ++i) {
    if ((int)((double)i * 1.08) == n) {
      cout << i << endl; return 0;
    }
  }

  cout << ":(" << endl;

  return 0;
}

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

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

  //init
  int prime[10000];
  int prime_counter = 1;
  for(int i = 0; i < 10000; i++) prime[i] = 0;
  prime[0] = 2;

  //get prime
  for(int i = 3; i <= 55555; i++){
    bool is_prime = true;
    for(int j = 0; j < prime_counter; j++){
      if(i % prime[j] == 0){
        is_prime = false;
        break;
      }
    }
    if(is_prime){
      prime[prime_counter] = i;
      prime_counter++;
    }
  }

  /*
  //test
  int test[5] = {0, 0, 0, 0, 0};
  for(int i = 0; i < prime_counter; i++) test[ prime[i]%5 ]++;
  for(int i = 0; i < 5; i++)
    printf("%d (mod 5) prime counter is %d.\n", i, test[i]);
  //output
  //0 (mod 5) prime counter is 1.
  //1 (mod 5) prime counter is 1408.
  //2 (mod 5) prime counter is 1417.
  //3 (mod 5) prime counter is 1407.
  //4 (mod 5) prime counter is 1404.
  */

  for(int i = 0, ans_counter = 0; ans_counter < N; i++){
    if(prime[i] % 5 == 1){
      printf("%d\n", prime[i]);
      ans_counter++;
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;

    int ans = 0;
    for(int i=a;i<=b;i++){
        string char_i;
        char_i = to_string(i);
        if(char_i[0] == char_i[4]
            && char_i[1] == char_i[3])ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
static const int N = 2001;
using namespace std;
struct data{
  int correctcnt,time,tnum;
  bool operator<(const data& right)const{
    if(correctcnt!=right.correctcnt) return correctcnt>right.correctcnt;
    if(time!=right.time) return time<right.time;
    return tnum>right.tnum;
  }
};
int main(){
  int M,T,P,R,i,j,m[N],t[N],p[N],in_j[N],incorrectcnt;
  while(1){
    cin >> M >> T >> P >> R;
    vector<data> V(T);
    if(M==0&&T==0&&P==0&&R==0) break;
    for(i=0;i<R;i++){
      cin >> m[i] >> t[i] >> p[i] >> in_j[i];
    }
    for(i=0;i<T;i++){
      V[i].tnum=i+1;
      V[i].correctcnt=V[i].time=0;
    }
    for(i=0;i<R;i++){
      if(in_j[i]==0){
    V[t[i]-1].correctcnt++;
    incorrectcnt=0;
    for(j=0;j<i;j++){
      if(t[i]==t[j]&&p[i]==p[j]) incorrectcnt++;
    }
    V[t[i]-1].time+=m[i]+20*incorrectcnt;
      }
    }
    sort(V.begin(),V.end());
    for(i=0;i<T-1;i++){
      cout << V[i].tnum;
      if(V[i].correctcnt==V[i+1].correctcnt&&V[i].time==V[i+1].time) cout << '=';
      else cout << ',';
    }
    cout << V[T-1].tnum << endl;
  }  
  return 0;
}

Measured memory_bytes: 1248
/* 
	بسم الله الرحمن الرحیم
	
	(; طلا یک جهانی
*/

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

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

const int MAX_N = 100 * 1000 + 5;
int n, m, par[MAX_N], h[MAX_N];
map<pair<int, int>, bool> del;
bool mark[MAX_N];
vector<int> adj[MAX_N];

void read_input() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
}

pii dfs(int v, int cur_h = 0) {
	mark[v] = true;
	h[v] = cur_h;
	pii res = {-1, v};
	for (int u: adj[v])
		if (!del[{u, v}]) {
			if (!mark[u]) {
				par[u] = v;
				pii p = dfs(u, cur_h + 1);
				if (~p.F && (!~res.F || h[p.F] > h[res.F] || (h[p.F] == h[res.F] && h[p.S] < h[res.S])))
					res = p;
			}
			else if (u != par[v] && h[u] < h[v] && (!~res.F || h[u] >= h[res.F]))
				res = {u, v};
		}
	return res;
}

bool check(pii p) {
	int u = p.F, v = p.S;
	if (!~u)
		return false;
	int x = v;
	par[u] = v;
	do {
		del[{x, par[x]}] = true;
		del[{par[x], x}] = true;
		x = par[x];
	} while (x != v);
	return true;
}

void solve() {
	for (int i = 0; i < n; i++)
		if ((int) adj[i].size() % 2) {
			cout << "No";
			exit(0);
		}
	for (int i = 0; i < 2; i++) {
		for (int v = 0; v < n; v++) {
			par[v] = -1;	
			if (!mark[v] && check(dfs(v)))
				break;
		}
		memset(mark, false, sizeof mark);
	}
	for (int v = 0; v < n; v++)
		if (!mark[v]) {
			par[v] = -1;
			if (check(dfs(v))) {
				cout << "Yes";
				exit(0);
			}
		}
	cout << "No";
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	read_input();
	solve();
}


Measured memory_bytes: 28544
#include <iostream>

int main(void) {

	const int cake = 4;
	const int donut = 7;
	int N;
	std::cin >> N;

	bool	found = false;
	if (N >= 4) {
		for (int i = 0; i <= (N / cake); i++) {
			int rest = N - (cake * i);
			if (rest == 0) {
				found = true;
			} else {
				int mod = rest % donut;
				if (mod == 0) {
					found = true;
				}
			}
			if (found) {
				break;
			}
		}
	}

	std::cout << (found ? "Yes": "No") << std::endl;

	return 0;
}


Measured memory_bytes: 256
import Control.Applicative

data YesNo = Yes | No deriving (Show)

solver :: Int -> Int -> Int -> Int -> Int -> YesNo
solver w h x y r
  | x + r > w = No
  | y + r > h = No
  | x - r < 0 = No
  | y - r < 0 = No
  | otherwise = Yes

main :: IO()
main = do
  (w:h:x:y:r:_) <- map (read :: String -> Int) . words <$> getLine
  print $ solver w h x y r

Measured memory_bytes: 3624
n = int(input())
plots = []
for i in range(n):
    x, y = map(int, input().split())
    plots.append((x, y, i))
edges = []
plots.sort(key=lambda x: x[0])
for k in range(n-1):
    x0, _, i = plots[k]
    x1, _, j = plots[k+1]
    edges.append((x1 - x0, i, j))

plots.sort(key=lambda x: x[1])
for k in range(n-1):
    _, y0, i = plots[k]
    _, y1, j = plots[k+1]
    edges.append((y1 - y0, i, j))



par = [i for i in range(n)]
size = [1 for _ in range(n)]
rank = [0 for _ in range(n)]
def find(x):  # 木の根を求める
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if rank[x] > rank[y]:
        par[y] = x
        size[x] += size[y]
    else:
        par[x] = y
        size[y] += size[x]
        if rank[x] == rank[y]:
            rank[y] += 1
def same(x, y):
    return find(x) == find(y)


def kruskal():
    edges.sort()

    res = 0
    for i in range(len(edges)):
        cost, u, v = edges[i]
        if not same(u, v):
            unite(u, v)
            res += cost

    return res

print(kruskal())

Measured memory_bytes: 50164
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var t = o.a();
  var x = o.a();
  return t / x;
}

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int a,b;
  cin >> a >> b;
  a--, b--;
  char grid[100][100];
  REP(i,100) REP(j,100){
	grid[i][j] = (i<50 ? '#' : '.');
  }
  int cnt = 0;
  for(int i = 0; i < 50; i+=2){
    if(cnt==a) break;
    for(int j = (i%2==0 ? 0 : 1); j < 100; j+=2){
      if(cnt==a) break;
      grid[i][j] = '.';
      cnt++;
    }
  }
  cnt = 0;
  for(int i = 99; i > 50; i-=2){
    if(cnt==b) break;
    for(int j = (i%2==0 ? 0 : 1); j < 100; j+=2){
      if(cnt==b) break;
      grid[i][j] = '#';
      cnt++;
    }
  }
  puts("100 100");
  REP(i,100){ 
    REP(j,100){
      cout << grid[i][j];
    }
    cout << '\n';
  }
  return 0;
}


Measured memory_bytes: 3616