akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int, int>
#define all(x) (x).begin(), (x).end()
using namespace std;

vector<int> g[500500];
int col[500500];
bool used[500500];
vector<int> order;
int dp[500500];
map<int, int> m;

void dfs(int v) {
	col[v] = 1;
	for (auto to : g[v]) {
		if (col[to] == 0) {
			dfs(to);
		} else if (col[to] == 1) {
			cout << -1 << endl;
			exit(0);
		}
	}
	col[v] = 2;
}

void dfs2(int v) {
	used[v] = true;
	for (auto to : g[v]) {
		if (!used[to]) {
			dfs2(to);
		}
	}
	order.pb(v);
}

void solve(int qq) {
	int n; cin >> n;
	int temp = 1;
	for (int i = 0; i < n; i++) {
		int prev;
		for (int j = 1; j < n; j++) {
			int k; cin >> k;
			k--;
			if (j == 1) {
				int a = min(i, k);
				int b = max(i, k);
				prev = a * n + b;
				if (m[prev] == 0) {
					m[prev] = temp;
					temp++;
				}
				continue;
			} else {
				int a = min(i, k);
				int b = max(i, k);
				int cur = a * n + b;
				if (m[cur] == 0) {
					m[cur] = temp;
					temp++;
				}
				g[m[prev]].pb(m[cur]);
				prev = cur;
			}
		}
	}

	for (int i = 1; i < temp; i++) {
		if (!col[i]) {
			dfs(i);
		}
	}

	for (int i = 1; i < temp; i++) {
		if (!used[i]) {
			dfs2(i);
		}
	}

	reverse(order.begin(), order.end());
	int mx = 0;
	for (int i = 0; i < order.size(); i++) {
		int v = order[i];
		for (auto to : g[v]) {
			dp[to] = max(dp[to], dp[v] + 1);
			mx = max(mx, dp[to]);
		}
	}

	cout << mx + 1 << endl;

}
 
int main()
{
	int t; t = 1;
	for (int i = 1; i <= t; i++) {
		solve(i);
	}
	return 0;
}

Measured memory_bytes: 57584
N = int(input())
c0 = 0
c1 = 0
c2 = 0
c3 = 0
for i in range(N):
  a = str(input())
  if a == 'AC':
    c0 += 1
  elif a == 'WA':
    c1 += 1
  elif a == 'TLE':
    c2 += 1
  else:
    c3 += 1
print('AC x '+str(c0))  
print('WA x '+str(c1)) 
print('TLE x '+str(c2)) 
print('RE x '+str(c3)) 
  

Measured memory_bytes: 69824
def main():

    from bisect import bisect_left as bl, bisect_right as br, insort
    import sys
    import heapq
    # from math import *
    from collections import defaultdict as dd, deque
    def data(): return sys.stdin.readline().strip()
    def mdata(): return map(int, data().split())
    out = sys.stdout.write
    # sys.setrecursionlimit(100000)

    s,w=mdata()
    if w>=s:
        print("unsafe")
    else:
        print("safe")




if __name__ == '__main__':
    main()

Measured memory_bytes: 64896
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
const int INF = 1<<30;

int main(){
  int ans=0;
  for(int i=0;i<4;i++){
  	char c;cin>>c;
    if(c=='+')ans++;
    else ans--;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
def prime_factorize(n):
    ans = []
    while True:
        if n % 2 == 0:
            ans.append(2)
            n //= 2
        else:
            break
    div = 3

    while div*div <= n:
        if n % div == 0:
            ans.append(div)
            n //= div
        else:
            div += 2

    if n != 1:
        ans.append(n)

    return ans


def eratosthenes_shieve(n):
    is_prime = [True for i in range(n+1)]
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        if not is_prime[i]:
            continue
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    
    return [i for i in range(len(is_prime)) if is_prime[i]]


def eratosthenes_shieve_pf(n):
    primes = eratosthenes_shieve(int(n**0.5)+1)
    ans = []
    for p in primes:
        while n % p == 0:
            ans.append(p)
            n //= p

    if n != 1:
        ans.append(n)

    return ans


def main():
    n = int(input())
    # ans = prime_factorize(n)
    ans = eratosthenes_shieve_pf(n)
    s = "{}: ".format(n)
    for i in ans:
        s += str(i) + " "
    print(s[:-1])


if __name__ == "__main__":
    main()



Measured memory_bytes: 5992
#include<cstdio>
#include<array>
#include<algorithm>
int main(){
std::array<int,9> a={1,2,3,5,6,9,10,13,17};
int n;
scanf("%d",&n);
puts(std::find(a.cbegin(),a.cend(),n)==a.cend()?"Yes":"No");
return 0;
}


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

using namespace std;

int main() {
  long n;
  cin >> n;
  unordered_map<string, int> s;
  for (long i = 0; i < n; i++) {
    string key;
    cin >> key;
    s[key] = 1;
  }
  
  cout << s.size();
  
  return 0;
}

Measured memory_bytes: 17524
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> a(N);
    for(auto& in:a) cin >> in;
    vector<ll> cusum(N+1,0);
    for(int i = 1; i <= N;i++){
        cusum[i] = cusum[i-1] + a[i-1];
    }
    ll res = LINF;
    for(int i = 1; i < N;i++){
        res = min(res,abs(cusum[i] - (cusum[N] - cusum[i])));
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <queue>
#include <tuple>

using namespace std;

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

typedef vector<int> vi;
typedef pair<int, int> pii;

int d[10] = {0, -1, 0, 1, 0, -1, 0, 1, 0, -1};
int w, h, s1, s2, t1, t2;

char ss[100][100];
int encode(int x, int y, int d){
	return x*16*4 + y*4 + d;
}

unsigned char dp[64*16*4][64*16*4];
unsigned char dp2[64*16*4];
int main(){
	while(cin >> w >> h, w){
		REP(i, h) cin >> ss[i];
		vector<vi> g(64*16*4, vi(2, -1));
		vector<vector<vi>> invg(64*16*4, vector<vi>(2));
		REP(i, h)REP(j, w)if(ss[i][j] != '#'){
			REP(k, 4)if(ss[i+d[k]][j+d[k+1]] == '.'){
				int dx=j, dy=i;
				while(ss[dy+d[k]][dx+d[k+1]] != '#'){
					dy+=d[k]; dx+=d[k+1];
				}
				if(ss[i][j] == 'K'){
					s1 = encode(dx, dy, k);
					s2 = encode(j, i, k);
				}
				if(ss[i][j] == 'M'){
					t1 = encode(j, i, k^2);
					t2 = encode(dx, dy, k);
				}
			}
			REP(k, 4)REP(l, 2){
				int dx=j, dy=i;
				int dir = (k+1+l*2)%4;
				while(ss[dy+d[dir]][dx+d[dir+1]] != '#'){
					dy+=d[dir]; dx+=d[dir+1];
				}
				int u = encode(j, i, k);
				int v = encode(dx, dy, dir);
				invg[v][!l].push_back(u);
				g[u][l] = v;
			}
		}
		memset(dp, 0, sizeof(dp));
		memset(dp2, 0, sizeof(dp2));
		queue<pii> q;
		REPS(i, 3) q.emplace(s1, s2^i);
		int ans = 0;
		while(!q.empty()){
			int u1, u2; tie(u1, u2) = q.front(); q.pop();
			if((u1|3) == (t1|3)) ans = 1;
			if((u1|3)== (t1|3) && u2 == t2){
				ans = 2; break;
			}
			REP(l, 2){
				int v1 = g[u1][l];
				if(u2 == -1 || invg[u2][l].empty()){
					if(!dp2[v1]){
						dp2[v1] = 1;
						q.emplace(v1, -1);
					}
				}else for(int v2 : invg[u2][l]){
					if(!dp[v1][v2]){
						dp[v1][v2] = 1;
						q.emplace(v1, v2);
					}
				}
			}
		}
		if(ans == 0) puts("He cannot bring tea to his master.");
		if(ans == 1) puts("He cannot return to the kitchen.");
		if(ans == 2) puts("He can accomplish his mission.");
	}
	return 0;
}

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

using namespace std;

#define int long long

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

    int n;
    cin >> n;
    vector<int> vec(n);
    for (int i = 0; i < n; i++)
        cin >> vec[i];
    sort(vec.begin(), vec.end());
    vector<pair<int, int>> log;
    int ans = vec[0];
    int cur = n - 2;
    while (cur > 0 && vec[cur] >= 0)
    {
        log.push_back({ans, vec[cur]});
        ans -= vec[cur];
        cur--;
    }

    log.push_back({vec.back(), ans});
    ans = vec.back() - ans;
    while (cur > 0)
    {
        log.push_back({ans, vec[cur]});
        ans -= vec[cur];
        cur--;
    }

    cout << ans << endl;
    for (auto i: log)
        cout << i.first << " " << i.second << endl;

    return 0;
}


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

long long n, m, p, ans, cnt[100005];
bitset<100005> solved;
string s;

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

    cin >> n >> m;

    while (m--) {
    	cin >> p >> s;
    	if (s == "AC") {
    		if (!solved[p]) {
    			solved[p] = 1;
    			ans += cnt[p];
    		}
    	}
    	else {
    		if (!solved[p]) {
    			cnt[p]++;
    		}
    	}
    }

    cout << solved.count() << " " << ans << '\n';
   	
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define fi1-n for(i=1;i<=n;i++)
#define stpn setprecision
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	int n,k;
	cin>>n>>k;
	if (n%k==0) cout<<n/k;
	else cout<<n/k+1;
    return 0;
}


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

#define mod 1000000007

#define rep(i, n) for(ll i=1; i<=n; ++i)

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	ll N;
    cin >> N;

    ll ans = 0;

    rep(i, N){
        if(i % 3 != 0 && i % 5 != 0)
            ans += i;
    }

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

Measured memory_bytes: 3636
sx, sy, tx, ty = gets.chomp.split.map(&:to_i)
res = ""
p1 = "U" * (ty - sy) + "R" * (tx - sx)
p2 = "D" * (ty - sy) + "L" * (tx - sx)
p3 = "LU" + p1 + "RD"
p4 = "RD" + p2 + "LU"
puts p1 + p2 + p3 + p4

Measured memory_bytes: 14192
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin >> a>>b>>c;
	for (int i = b; i <= c; i++)
	{
	
		if (i%a == 0) {
			cout << "OK";
			exit(0);
		}
	}
	cout << "NG";
    return 0;
}



Measured memory_bytes: 3624
#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>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    string s;
    cin>>n>>s;
    bool flag=true;
    if(n%2==1)flag=false;
    else{
        rep(i,n/2){
            if(s[i]!=s[n/2+i])flag=false;
        }
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3616
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

void Comp(const set<int> &remNums, const int value, vector<int> &dict)
{
    if (remNums.empty())
    {
        dict.push_back(value);
        return;
    }
    auto newRemNums = remNums;
    for (const int num : remNums)
    {
        newRemNums.erase(num);
        Comp(newRemNums, value * 10 + num, dict);
        newRemNums.insert(num);
    }
}

int main()
{
    int N;
    cin >> N;
    set<int> nums;
    vector<int> dict;
    for (int i = 1; i <= N; ++i) nums.insert(i);
    Comp(nums, 0, dict);
    int P = 0, Q = 0;
    for (int i = 0; i < N; ++i)
    {
        P *= 10;
        int Vi;
        cin >> Vi;
        P += Vi;
    }
    for (int i = 0; i < N; ++i)
    {
        Q *= 10;
        int Vi;
        cin >> Vi;
        Q += Vi;
    }
    int distP = distance(dict.begin(), find(dict.begin(), dict.end(), P));
    int distQ = distance(dict.begin(), find(dict.begin(), dict.end(), Q));
    cout << abs(distP - distQ) << endl;
}


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

int main() {
int64_t n;
cin>>n;
  vector<int> v(n);
  vector<int> c(n);
  int count=0;
  for(int i=0;i<n;i++){
    cin>>v.at(i);
  }
  for(int i=0;i<n;i++){
    cin>>c.at(i);
  }
  for(int i=0;i<n;i++){
    if((v.at(i)-c.at(i))>0){
      count+=v.at(i)-c.at(i);
    }
  }
  cout<<count;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; i>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'
template <class T> bool updmax(T& a, T b) { if (b > a) { a = b; return true;} return false;}
template <class T> bool updmin(T& a, T b) { if (b < a) { a = b; return true;} return false;}
template <class T> T permutation(T n, T k, T mod) { T f(1); for (T i=0; i<k; ++i, --n) f = f*n % mod; return f; }
template <class T> T factorial(T n, T mod) { return permutation<T>(n,n,mod); }
template <class T> T powmod(T e, T p, T mod) { if(p == -1) p=mod-2; T a=1; while(p>0){ if(p&1){ a=a*e%mod; } e=e*e%mod; p>>=1; } return a; }
template <class T> T binomial(T n, T k, T mod) { return permutation<T>(n,k,mod) * powmod(factorial<T>(k,mod), -1, mod); }
const ll Mod = 1'000'000'007;

int main() {
    fastio;
    ll N,K;
    cin >> N >> K;
    vector<set<int>> tree(N);
    vector<bool> r(N);
    rep(i,N-1) {
        int a,b;
        cin >> a >> b;
        --a; --b;
        tree[a].insert(b);
        tree[b].insert(a);
    }
    queue<int> q;
    q.push(0);
    r[0] = true;
    ll ans=1;
    while(!q.empty()) {
        int v = q.front(); q.pop();
        int n;
        int k;
        if (v == 0) {
            n = tree[v].size()+1;
            k = K;
        } else {
            n = tree[v].size()-1;
            k = K-2;
        }
        if (n > k) {
            ans = 0;
            break;
        }
        ans *= permutation<ll>(k,n,Mod);
        ans %= Mod;
        for (int c : tree[v]) {
            if (!r[c]) {
                q.push(c);
                r[c] = true;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 17788
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//inline int in() { int x; scanf("%d",&x); return x;}
template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

int main () {
  ll h, w;
  cin >> h >> w;
  if (h == 1 || w == 1) cout << 1 << endl;
  else cout << dup(w,2)*dup(h,2) + (w/2)*(h/2) << endl;
  return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int> h(n);
    for(int i=0; i<n; i++)cin>>h[i];
    int M = 0;
    for(int i=1; i<n; i++){
       M=max(M,h[i-1]);
       if(M>h[i]+1){
           cout<<"No";
           return 0;
       }
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 640
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;

int main()
{
    int m1, d1, m2, d2;
    cin >> m1 >> d1;
    cin >> m2 >> d2;
    
    if(m1 == m2) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    ll n;
    cin >> n;
    vector<ll> A(n);
    for (auto & a : A) cin >> a;
    map<ll,ll> P, M;
    for (ll i = 0; i < n; ++i) {
        P[i+A[i]]++;
        M[i-A[i]]++;
    }

    ll res = 0;
    for (auto & p : P) {
        res += p.second * M[p.first];
    }
    cout << res  << endl;
}


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

int main() {

    int ans = 0;

    int n;
    string s;

    cin >> n >> s;

    int x = 0;

    for(int i=0; i<n; i++){

        x--;
        if(s[i] == 'I'){
            x+=2;
        }

        ans = max(ans,x);

    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
<?php
  	$weight_num = fgets(STDIN);
	$input = rtrim(fgets(STDIN));
	$weight = explode(' ', $input);

	$sum_weight = array_sum($weight);
	$half_weight = (int) ($sum_weight / 2);
	$left_weight = 0;
	foreach($weight as $value){
      	$left_weight += $value;
      	if($left_weight >= $half_weight){
          	$result = min($left_weight * 2 - $sum_weight, $sum_weight - $left_weight * 2 + $value * 2);
          	echo $result;
          	exit;
        }
    }
      

Measured memory_bytes: 4604
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main{
    public static void main(String[] args) {
	try {
	    BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
	    String line;
	    while ((line = stdReader.readLine()) != null) {
		String[] splits = line.split(" ");

		Long a = Long.parseLong(splits[0]);
		Long b = Long.parseLong(splits[1]);

		Long d = a / b;
		Long r = a % b;

		Double f = Double.parseDouble(splits[0]) / Double.parseDouble(splits[1]);
		System.out.println( String.format("%d %d %.5f", d, r, f));
	    }
	    stdReader.close();
	} catch (Exception e) {
	    System.out.println(Arrays.toString(e.getStackTrace()));
	    System.exit(0);
	}
    }
}

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

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 20000005;
bool isPrime[MAXN];
vector<int> pr;
vector<pair<int,int>> ans;
void sieve()
{
    memset(isPrime, 1, sizeof isPrime);
    isPrime[0] = isPrime[1] = 0;

    for (int i = 2; i * i <= MAXN; i += 1 + (i & 1))
    {
        if (isPrime[i])
        {

            for (int j = i * i; j < MAXN; j += i)
                isPrime[j] = 0;
        }
    }
    for(int i=0; i<MAXN; i++)
    {
        if(isPrime[i])
        {
            if(!pr.empty())
            {
                if(i-pr.back()==2)
                {
                    ans.push_back({pr.back(),i});
                }
            }
            pr.push_back(i);

        }
    }
}

ld power(ld x, ll y)
{
    ll temp;
    if (y == 0)
        return 1;
    temp = power(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
        return x * temp * temp;
}

void debug_out()
{
    cerr << endl;
}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << H;
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int main()
{
  int a;
  cin>>a;
  cout<<a+a*a+a*a*a<<endl;

    return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;
public class Main{
	public static void main(String[]args){
    	Scanner sc=new Scanner(System.in);
     	int n=sc.nextInt();
      	int total=0;
      	int p[]=new int[n];
      
      	for(int t=0;t<n;t++){
        	p[t]= sc.nextInt();
        }
      	
      	for(int k=0;k<n-2;k++){
        	if(p[k]<p[k+1]){
            	if(p[k+1]<p[k+2]){
                	total+=1;
                }
            }else{
            	if(p[k+2]<p[k+1]){
                	total+=1;
                }
            }
        }
      	
      	System.out.println(total);
      
      
    }
}

Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		String str=scn.next();
		int flag=0;
		for(int i=1;i<str.length();i++) {
				if(str.charAt(i)==str.charAt(i-1)) {
					flag=1;
					System.out.println("Bad");
					break;
				}
		}
		if(flag==0) {
			System.out.println("Good");
		}
	}

}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define op_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fo(i,a,b) for(int i=a; i <b; i++)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef map<int,int> mpii;
typedef map<ll,ll> mpll;
typedef map<int,ll> mpil;
typedef map<ll,int> mpli;

int main(){
  op_io;
  int k;
  cin>>k;
  string s;
  cin>>s;
  if(s.size() <= k){
    cout<<s<<endl;
  }else{
    string n = s.substr(0,k)+"...";
    cout<<n<<endl;
  }
  return 0;
}


Measured memory_bytes: 3620
def main():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    total_T_in_A = [0] * (N+1)
    total_T_in_B = [0] * M
    total_T_in_B[0] = B[0]

    for i in range(1, N+1):
        total_T_in_A[i] = total_T_in_A[i-1] + A[i-1]

    for i in range(1, M):
        total_T_in_B[i] = total_T_in_B[i-1] + B[i]

    result = 0
    for i in range(N+1):
        # A から i 冊読むときにかかる時間
        i_A_T = total_T_in_A[i]
        
        if K < i_A_T:
            continue

        if K == i_A_T:
            result = max(result, i)
            continue

        rem_T = K - i_A_T

        # total_T_in_B は累積和を格納した、ソート済の配列
        # B_i <= rem_T < B_i+1 となるような B_i を二分探索によって探す
        first = total_T_in_B[0]
        last = total_T_in_B[M-1]
        if rem_T < first:
            result = max(result, i)
            continue
        if last <= rem_T:
            result = max(result, i + M)
            continue

        # assume that first <= rem_T <= last
        first_i = 0
        last_i = M - 1
        while first_i < last_i:
            if abs(last_i - first_i) == 1:
                break
            mid_i = (first_i + last_i) // 2
            if rem_T < total_T_in_B[mid_i]:
                last_i = mid_i
            else:
                first_i = mid_i
        result = max(result, i + first_i + 1)

    print(result)

main()


Measured memory_bytes: 118168
#include <iostream>
#include <cstdio>
using namespace std;
int w[100000];
int n,k;
int work(int p)
{
    int sum,i=0,j=k;
    while(j--)
    {
        sum=0;
        while(sum+w[i]<=p)
        {
            sum += w[i];
            i++;
            if(i==n)
                return n;
        }
    }
    return i;
}
int main()
{
    int i,left=0,right=1000000000,mid;
    cin>>n>>k;
    for(i=0;i<n;i++)
        cin>>w[i];
        //scanf("%d",&w[i]);
    while(right-left>1)
    {
        mid = (right+left)/2;
        if(work(mid)<n)
            left = mid;
        else
            right = mid;
    }
    cout<<right<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    ll apos = s.size(), zpos = 0;
    for(ll i = 0; i < s.size(); ++i){
        if(s.at(i) == 'A'){
            apos = min(apos, i);
        }
        if(s.at(i) == 'Z'){
            zpos = max(zpos, i);
        }
    }
    cout << zpos - apos + 1 << endl;
    return 0;
}


Measured memory_bytes: 832
h, w = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]

ans = []
for y in range(h - 1):
    for x in range(w):
        if a[y][x] % 2 == 1:
            a[y + 1][x] += 1
            X = x + 1
            Y = y + 1
            ans.append([Y, X, Y + 1, X])
y = h - 1
for x in range(w - 1):
    if a[y][x] % 2 == 1:
        a[y][x + 1] += 1
        X = x + 1
        Y = y + 1
        ans.append([Y, X, Y, X + 1])

cnt = len(ans)
print(cnt)
for op in ans:
    print(' '.join(map(str, op)))

Measured memory_bytes: 27920
from sys import exit, stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 1
if 0 in A:
    print(0)
    exit()
for a in A:
    ans *= a
    if ans > 10**18:
        print(-1)
        exit()
print(ans)


Measured memory_bytes: 21596
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  int d;
  cin>>d;
  for(int x=0;x<d;x++){
    cout<<"Case "<<x+1<<":"<<endl;
    int n;
    cin>>n;
    for(int i=0;i<10;i++){
      string s=to_string(n*n);
      while(s.size()<8) s='0'+s;
      n=stol(s.substr(2,4));
      cout<<n<<endl;
    }
  }
  return 0;
}

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

typedef long long ll;
typedef pair<string, string> pss;

ll n, ans;
string s;
map<pss, int> cnt;

int main() {
	cin >> n >> s;
	for (int i = 0; i < (1 << n); i++) {
		string a = "", b = "";
		for (int j = 0; j < n; j++)
			if(i & (1 << j))
				a.push_back(s[j]);
		for (int j = n - 1; j >= 0; j--)
			if((i & (1 << j)) == 0)
				b.push_back(s[j]);
		cnt[pss(a, b)]++;
	}
	
	for (int i = 0; i < (1 << n); i++) {
		string a = "", b = "";
		for (int j = 0; j < n; j++)
			if(i & (1 << j))
				a.push_back(s[n + j]);
		for (int j = n - 1; j >= 0; j--)
			if((i & (1 << j)) == 0)
				b.push_back(s[j + n]);
		ans += cnt[pss(b, a)];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 91904
/******************************************
* AUTHOR : Ashish Joshi* 
* INSTITUTION : NIT Hamirpur *
******************************************/
#include <bits/stdc++.h>
using namespace std;

#define N 100005
#define MOD 1000000007
#define PI 3.141592653589793

#define dd double
#define loop(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define set(b,i) (b|(1<<i))
#define unset(b,i) (b&!(1<<i))
#define cbit(b,i) bool(b&(1<<i))

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<long long,long long> > vpll;
typedef vector<vector<ll> > vvll;

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//ios_base& scientific (ios_base& str);
double l;
cin>>l;
std::cout << std::fixed;
 // d=(l/3);
std::cout << std::setprecision(6)<<(l*l*l)/27<<endl;


return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int satisfied = 0;
        int[] a = new int[n], c = new int[n-1];

        for(int i = 0; i < n; i++)
        	a[i] = sc.nextInt()-1;

        for(int i = 0; i < n; i++)
        	satisfied += sc.nextInt();

        for(int i = 0; i < n-1; i++)
        	c[i] = sc.nextInt();

        for(int i = 0; i < n-1; i++) {
        	if(a[i] +1 == a[i+1])
        		satisfied += c[a[i]];
        }

        System.out.println(satisfied);
    }
}

Measured memory_bytes: 23124
a, b, c, k = map(int, input().split())

import sys

ans = 0
if a != 0 and a >= k:
    # a = 1
    print(k)
    sys.exit()
elif a != 0:
    ans += a
    k -= a

if b != 0 and b >= k:
    print(ans)
    sys.exit()
elif b != 0:
    k -= b

ans += k * -1
print(ans)


Measured memory_bytes: 9208
#!/usr/bin/env python
# coding: utf-8

# In[6]:


X = int(input())


# In[7]:


ans = X
while True:
    flg = False
    for i in range(2,ans+1):
        if i < ans:
            if ans%i == 0:
                ans += 1
                break
        else:
            flg = True
    if flg:
        break
print(ans)


# In[ ]:






Measured memory_bytes: 2940
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Contest.E
{
	class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			Scanner cin = new Scanner();

			int n = cin.nextInt();
			int a = cin.nextInt();
			int b = cin.nextInt();

			int ans = 0;

			for (int i = 1; i <= n; i++)
			{
				int sum = 0;
				int num = i;
				while (num >= 1)
				{
					sum += num % 10;
					num /= 10;
				}
				if (a <= sum && sum <= b) ans += i;
			}
			
			Console.WriteLine(ans);

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return next();
			i = 0;
			return s[i++];
		}

		public int nextInt()
		{
			return int.Parse(next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextInt() + add;
			}
			return Array;
		}

		public long nextLong()
		{
			return long.Parse(next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextLong() + add;
			}
			return Array;
		}

		public double nextDouble()
		{
			return double.Parse(next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 11092
w, h, t = gets.split.map(&:to_i)
n = gets.to_i
a = (1..n).map { gets.split.map(&:to_i) }
b = (1..h).map { gets.split.map(&:to_i) }
k = 0
a.each do |x, y, _|
    k += 1 if b[y][x] == 1
end
p k


Measured memory_bytes: 6884
//Be Name Khoda, Besmellah Rahmane Rahim, In The Name Of God;
//#include<bits/stdc++.h>
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include <stdio.h>
#include <string.h>
#include<iomanip>
#include<unordered_map>
#include<unordered_set>


 
using namespace std;

const int N = 1e5 + 5;
int a[N];
int n;
int odd = 0;
int even = 0;
int maxi = 0;
vector<int> board;
string ans[2];

void solver(vector<int> a, int turn)
{
    odd = 0;
    even = 0;
    maxi = 0;
    for (int i = 0; i < n; i++)
    {
        //cout << a[i] << " ";
        if (a[i] % 2)
        {
            odd++;
        }
        else
        {
            even++;
        }
        maxi = max(maxi, a[i]);
    }
    //cout << endl;
    if (maxi == 1)
    {
        cout << ans[(turn + 1) % 2] << endl;
        exit(0);
    }
    if (even % 2)
    {
        cout << ans[turn] << endl;
        exit(0);
    }
    if (odd >= 2)
    {
        cout << ans[(turn + 1) % 2] << endl;
        exit(0);
    }
    for (int i = 0; i < n; i++)
    {
        if (a[i] % 2)
        {
            if (a[i] == 1)
            {
                cout << ans[(turn + 1) % 2] << endl;
                exit(0);
            }
            a[i]--;
            int g = 0;
            for (int j = 0; j < n; j++)
            {
                g = __gcd(a[j], g);
            }
            for (int j = 0; j < n; j++)
            {
                a[j] = a[j] / g;
            }
            solver(a, (turn + 1) % 2);
        }
    }

}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        board.push_back(tmp);
    }   
    ans[0] = "First";
    ans[1] = "Second";
    solver(board, 0);
    


}


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

using LL = long long;
using LD = long double;
 
LL mod = 998244353;

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

	vector<LL> a(n);
	static LL f[200001] = {0};
	static LL ans[200001] = {0};

	for (LL i = 0; i < n; ++i) {
		cin >> a[i];
	}

	vector<LL> b;

	for (LL i = 0; i < n; ++i) {
		if (!f[a[i]]) {
			b.push_back(a[i]);
		}
		f[a[i]]++;
	}
	LL anst = 0;
	for (auto e : b) {
		anst += f[e]*(f[e]-1)/2;
	}
	for (LL i = 0; i < n; ++i) {
		cout << anst - f[a[i]]+1 << "\n";
	}

}

Measured memory_bytes: 5876
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}



int main(void){
  fast_io
  cout<<fixed<<setprecision(15);
  ll n, k;
  cin >> n >> k;
  vector<int> as(n);
  int m = 0;
  rep(i,n){
	  cin >> as[i];
	  m = max(m, as[i]);
  }
  if(k==0){
	  cout << m << endl;
	  return 0;
  }
  ll ans = m;
  ll p = m;
  ll q = 0;
  while(1){
	  ll s = (p+q)/2;
	  if(s == 0){
		  cout << "1" << endl;
		  return 0;
	  }
	  ll cnt = 0;
	  rep(i,n){
		  cnt += (as[i]-1)/s;
	  }
	  if(cnt > k){
		  q=s;
	  }else{
		  p=s;
		  ans = min(ans,s);
	  }
	  if(p == q+1 || p == q){
		  break;
	  }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3988
let () =
    let main () =
        let n, m = Scanf.sscanf (read_line ()) "%d %d" (fun n m -> n, m) in
        let a = Array.init m (fun _ -> int_of_string (read_line ())) in
        let f = Array.make (n + 1) true in
        let () = Array.iter (fun v -> f.(v) <- false) a in
        let c = Array.make (n + 1) 0 in
        let () = c.(0) <- 1 in
        let mm = 1_000_000_007 in
        for i = 0 to n - 1 do
            if               f.(i + 1) then c.(i + 1) <- (c.(i + 1) + c.(i)) mod mm;
            if i + 2 <= n && f.(i + 2) then c.(i + 2) <- (c.(i + 2) + c.(i)) mod mm
        done;
        Printf.printf "%d\n" c.(n)
    in
    main ()

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

using namespace std;

int main (void) {
    int t[100] = {0}, m = 0;
    while (1) {
        int n;
        cin >> n;
        if (cin.eof()) break;
        t[n - 1]++;
        m = max(m, t[n - 1]);
    }
    for (int i = 0; i < 100; i++) {
        if (t[i] == m) {
            cout << (i + 1) << endl;
        }
    }
    return 0;
}

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

int main(){
	string s;
	int k;
	cin >> s >> k;
	for(int i =0; i<(int)s.length();i++){
		if(s[i]=='1' && k==i+1) {cout << 1; return 0;}
		if(s[i]!='1') {cout << s[i]; return 0;}
	}
		
 }


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

using namespace std;

int main() {
    int x, n;
    cin >> x >> n;
    vector<int> a(n);
    map<int, int> m;
    for(int i = 0 ; i < n ; i++){
        cin >> a[i];
        m[a[i]] = 1;
    }
    int ans = 0, mn = 1e9;
    for(int i = -100 ; i <= 103 ; i++){
        if(m[i] != 1){
            if(abs(i - x) < mn){
                mn = abs(i - x);
                ans = i;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>

using namespace std;

int main()
{
    
    char S[4];
    cin>>S;
    
    int a,b,c,d;
    a=S[0]-48;
    b=S[1]-48;
    c=S[2]-48;
    d=S[3]-48;
    
    int x=a*10+b;
    int y=c*10+d;
    
    if(x>=1&&x<=12)
    {
        if(y>=1&&y<=12)
        cout<<"AMBIGUOUS";
        else
        cout<<"MMYY";
    }
    
    else
    {
         if(y>=1&&y<=12)
        cout<<"YYMM";
        else
        cout<<"NA";
    }
    
}


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

const double PI = 3.141592653589;

void call(int n) {
	for(int i = 1; i <= n; i++){
		int x = i;

		if(x % 3 == 0){ 
			cout << " " << i;
		} else {
			while(x){
				if( x % 10 == 3) {
					cout << " " << i;
					break;
				}
				x /= 10;
			}
		}
	}
	cout << endl;
}

int main() {
	int n;

	cin >> n;

	call(n);

	return 0;
}


Measured memory_bytes: 3084
n, q = map(int, input().split())
s = input()
tmp = [0 for i in range(len(s))]
for i in range(len(s)-1):
  if s[i] == "A" and s[i+1] == "C":
    tmp[i] = 1
    
ans = [0 for i in range(len(s)+1)]
for i in range(1, len(ans)):
  ans[i] = ans[i-1] + tmp[i-1]
  
for i in range(q):
  l, r = map(int, input().split())
  count = 0
  print(ans[r-1] - ans[l-1])
    
  
  



Measured memory_bytes: 10476
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  char a, b, c;
  cin >> a >> b >> c;
  ll count = 0;
  if(a=='1'){
    count++;
  }
  if(b=='1'){
    count++;
  }
  if(c=='1'){
    count++;
  }
  print(count);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
using namespace std;
bool isprime(int n)
{
    for (int i=3; i*i<=n; i+=2) {
        if (n%i==0) return false;
    }
    return true;
}
int main()
{
    int n;
    while (scanf("%d",&n)&&n!=0) {
        int res=0;
        for (int i=3; i<=n/2; i+=2) if (isprime(i)&&isprime(n-i)) res++;
        printf("%d\n",res);
    }
}

Measured memory_bytes: 760
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fio;
    double r;
    cin>>r;
    printf("%.20lf\n",2*pi*r);
    return 0;
}


Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

int ans[501][501];

void solve(int l,int r,int level){
    if(r-l==1)return;
    int b=(l+r)/2;
    for(int i=l;i<b;i++){
        for(int j=b;j<r;j++){
            ans[i][j]=level;
        }
    }
    solve(l,b,level+1);
    solve(b,r,level+1);
}

int main(){
    int n;
    cin>>n;
    solve(0,n,1);
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            cout<<ans[i][j]<<" ";
        }
        cout<<endl;
    }
}

Measured memory_bytes: 1408
local n, m = io.read("*n", "*n")
local t = {}
local mod = {}
local pr = {}
for i = 1, m do mod[i] = 0  pr[i] = 0 end
for i = 1, n do
  local a = io.read("*n")
  local v = a % m
  if v == 0 then v = m end
  mod[v] = mod[v] + 1
  t[i] = a
end
table.sort(t)
local pos = 1
while pos <= n - 1 do
  if t[pos] == t[pos + 1] then
    local v = t[pos] % m
    if v == 0 then v = m end
    pr[v] = pr[v] + 1
    pos = pos + 2
  else
    pos = pos + 1
  end
end
local mmi, mfl = math.min, math.floor
local ret = 0
local hm = mfl((m - 1) / 2)
for i = 1, hm do
  local v = mmi(mod[i], mod[m - i])
  ret = ret + v
  mod[i] = mod[i] - v
  mod[m - i] = mod[m - i] - v
end
do
  local v = mfl(mod[m] / 2)
  ret = ret + v
  mod[m] = mod[m] - v * 2
end
if m % 2 == 0 then
  local z = mfl(m / 2)
  local v = mfl(mod[z] / 2)
  ret = ret + v
  mod[z] = mod[z] - v * 2
end
for i = 1, m do
  local v = mmi(pr[i], mfl(mod[i] / 2))
  ret = ret + v
end
print(ret)


Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long MOD = 1_000_000_007;
        long ans = 1;
        for (int i = 1; i <= n; i++) {
            ans *= i;
            ans %= MOD;
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 35664
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)

	sc.Scan()
	x, _ := strconv.Atoi(sc.Text())
	if x >= 30 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1772
M, K = map(int, input().split())
if K == 0:
    l = [i // 2 for i in range(2 ** (M + 1))]
    print(*l)
elif K >= 2 ** M:
    print(-1)
else:
    if M == 1:
        # K==1のときしかここに入ってきてないので
        print(-1)
    else:
        left = [i for i in range(2 ** M) if i != K]
        right = [i for i in reversed(range(2 ** M)) if i != K]
        ans = left + [K] + right + [K]
        print(*ans)


Measured memory_bytes: 69892
#include <iostream>
using namespace std;
int main()
{
	int A[30] = {};
	int P[1000000] = {};
	int c = 0, j;
	for (int k = 2; k < 1000000; ++k){
		if (P[k] == 0){
			P[k] = ++c;
			for (j = 2; j * k < 1000000; ++j)
				P[j * k] = -1;
		}
		else if (P[k] == -1)
			P[k] = c;		
	}
	int k;
	while (cin >> k)
		cout << P[k] << "\n";
	return 0;
}

Measured memory_bytes: 5072
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	int a, b, c;
	cin >> a >> b >> c;
	int min = a + b;
	if (a+c < min) min = a+c;
	if (b+c < min) min = b+c;
	cout << min << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"

const int N = 1e6;

int a[1 + N];

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

    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    int j = 1;
    for (int i = 1; i <= n; i++) {
        if (a[i] == j)
            j++;
    }
    if (j == 1)
        j = n + 2;
    cout << n - (j - 1) << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    ll n;
    cin >> n;
    cout << n*(n-1)/2 << endl;
}



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

using namespace std;

const int mod = 1e9 + 7;

using int64 = long long;
const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N;
  cin >> N;
  vector< int > rev(N);
  for(int i = 0; i < N; i++) {
    int x;
    cin >> x;
    rev[--x] = i + 1;
  }
  cout << rev << endl;
}



Measured memory_bytes: 1280