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

int main(){
    int n;
    cin>>n;
    int a;
    int c[3]={};
    for(int i=0;i<n;i++){
        cin>>a;
        c[a-1]++;
    }
    double dp[n+1][n+1][n+1]={};
    
    for(int k=0;k<=n;k++)for(int j=0;j<=n;j++)for(int i=0;i<=n;i++){
        int t=i+j+k;
        if(t>n) continue;
        if(i) dp[i][j][k]+=(double)dp[i-1][j][k]*i/t;
        if(j) dp[i][j][k]+=(double)dp[i+1][j-1][k]*j/t;
        if(k) dp[i][j][k]+=(double)dp[i][j+1][k-1]*k/t;
        if(i+j+k>0) dp[i][j][k]+=(double)n/t;
    }
    printf("%.10f",dp[c[0]][c[1]][c[2]]);
}

Measured memory_bytes: 213248
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;

class Point{
public:
  int n1,n2;
  string right,down;
  char c;
};

int main(){
  int i,j,n;
  string str,str2,str3,ans;
  while(1){
    queue<Point> Q;
    Point u,v;
    cin >> str;
    if(str == "-") break;
    cin >> str2 >> str3;

    u.right = "";
    u.down = "";
    u.n1 = 0;
    u.n2 = 1;
    u.c = str2[0];
    Q.push(u);

    while(!Q.empty()){
      u = Q.front();
      Q.pop();

      if(u.n1 == str.size() && u.n2 == str2.size()){
	ans = u.right + u.c;
	break;
      }

      if(u.n1 < str.size()){
	v = u;
	v.down += v.c;
	v.c = str[v.n1++];
	for(i=0;i<v.down.size();i++){
	  if(v.down[i] != str3[i]) break;
	}
	if(i == v.down.size()) Q.push(v);
      }

      if(u.n2 < str2.size()){
	v = u;
	v.right += v.c;
        v.c = str2[v.n2++];
	Q.push(v);
      }
    }

    cout << ans << endl;

  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long  ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<double, double>  iidb;
typedef pair<ii, ll>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e18+7;
const double PI = acos(-1);
#define initseg ll new_nodo=(nodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 210000
#define offset 200
#define ptr nodo*


using namespace std;
const int mod=1e6+3;
int cants[tam];
int main()
{
	forr(i,1,101)
	{
		forr(j,1,101)
		{
			forr(k,1,101)
			{
				cants[i*i+j*j+k*k+i*j+j*k+i*k]++;
			}
		}
	}
	int n;
	cin>>n;
	forr(i,1,n+1)
	cout<<cants[i]<<endl;
}

Measured memory_bytes: 3840
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        int q = stdin.nextInt();
        long[] a = new long[q];
        long[] b = new long[q];
        for (int i = 0; i < q; i++) {
            a[i] = stdin.nextLong();
            b[i] = stdin.nextLong();
        }

        for (int i = 0; i < q; i++) {
            System.out.println(f(a[i], b[i]));
        }
    }

    private static long f(long a, long b) {
        if (a == b) {
            return (a - 1) * 2;
        }

        long c = (long)Math.floor(Math.sqrt(a * b));
        if (c * c < a * b) {
            if (c * (c + 1) < a * b) {
                return c * 2 - 1;
            } else {
                return c * 2 - 2;
            }
        } else {
            return (c - 1) * 2 - 1;
        }
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
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;}

const int INF = 100000; 

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

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

    int num = 1;
    int cnt;
    for(cnt = 1; cnt < n; cnt++){
        num = a[num-1];
        if(num == 2) break;
    }

    if(cnt < n) cout << cnt << endl;
    else cout << -1 << endl;
   
    return 0;
}


Measured memory_bytes: 640
N,K,Q = gets.split.map(&:to_i)
h = Hash.new(0)

Q.times do |i|
  a = gets.to_i
  h[a] += 1
end

N.times do |i|
  if Q-h[i+1] >= K
    puts 'No'
  else
    puts 'Yes'
  end
end

Measured memory_bytes: 6396
#include <cmath>
#include <iostream>
#include <string>

using namespace std;

int main() {
	int N, K, count = 0;
	cin >> N >> K;
	long long ans1=0,ans2=0,i;
	if (K % 2 == 1) {//Kが奇数の時は，Kの倍数のみを数える
		for (i = 1; i <= N; ++i) {
			if (i%K == 0)
				ans1++;
		}
	}
	else{
		for (i = 1; i <= N; ++i) {
			if (i%K == 0)
				ans1++;
			if (i%K == K / 2)
				ans2++;
		}
	}
	cout << ans1 * ans1*ans1 + ans2 * ans2*ans2 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define l(a,p,q) (a%400==0||(a%100&&a%4==0))?p:q
int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31},a,b,c,x,y,z,i,j,r;

int main()
{
	for(;scanf("%d%d%d%d%d%d",&a,&b,&c,&x,&y,&z),a!=-1;)
	{
		r=-c;
		i=a%4;
		d[2]=l(a,29,28);
		for(i=b;i<=(a==x?y-1:12);i++)
			r+=d[i];
		for(i=a+1;i<x;i++)
			r+=l(i,366,365);
		d[2]=l(x,29,28);
		for(i=(a==x?13:1);i<y;i++)
			r+=d[i];
		printf("%d\n",r+z);
	}
	return 0;
}

Measured memory_bytes: 596
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int w = Integer.parseInt(sc.next());
		int h = Integer.parseInt(sc.next());
		boolean ebishu = false;
		if(w == 2 * Integer.parseInt(sc.next()) && h == 2 * Integer.parseInt(sc.next())) ebishu = true;
		ou.print(w * (long)h / 2.0 + " ");
		if(ebishu) ou.print(1 + "\n");
		else ou.print(0 + "\n");
		ou.flush();
    }
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int ceil(int a, int b){
	if(a == 0) return 0;
	return a % b == 0 ? a / b: a / b + 1;
}

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

	int n, k;
	cin >> n >> k;

	if(k == n) {
		cout << 1 << endl;
		return 0;
	}else if(k == 2){
		cout << n - 1 << endl;
		return 0;
	} 

	int a[n];
	rep(i, n) cin >> a[i];

	int p;
	rep(i, n){
		if(a[i] == 1){
			 p = i;
			 break;
		}
	}

	int ans = n;
	rep(i, k){
		int t = 1;
		t += p-k+1+i < 0 ? 0 : ceil(p-k+1+i, k-1);
		t += n-p-1-i < 0 ? 0 : ceil(n-p-1-i, k-1);

		//cout << i << "," << (p-k+1+i < 0 ? 0 : ceil(p-k+1+i, k-1)) << "," << (n-p-1-i < 0 ? 0 : ceil(n-p-1-i, k-1)) << endl;

		ans = min(ans, t);
	}

	cout << ans << endl;
}

Measured memory_bytes: 640
using System;

public class Hello
{
    public static void Main()
    {
        var a = new double[] { 35.5, 37.5, 40, 43, 50, 55, 70 };
        var b = new double[] { 71, 77, 83, 89, 105, 116, 148 };
        var c = new string[] { "AAA", "AA", "A", "B", "C", "D", "E" };
        string s;
        for (; (s = Console.ReadLine()) != null;)
        {
            string[] line = s.Trim().Split(' ');
            var t1 = double.Parse(line[0]);
            var t2 = double.Parse(line[1]);
            for (int i = 0; i < 7; i++)
                if (t1 < a[i] && t2 < b[i]) { Console.WriteLine(c[i]); goto next; }
            Console.WriteLine("NA");
            next:;
        }
    }
}


Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
const double eps = 1e-8;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto si : s) os << si << " "; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += (b % mod + mod)) %= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12);
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    // a*b=n-c
    int n;
    cin >> n;
    
    // a*bがn未満, a>0,b>0より掛け算は正
    ll cnt = 0;
    rep3(a, 1, n) {
        cnt += n / a;
        if (a * (n / a) == n) --cnt;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, l;
  cin >> n >> l;
  
  int x = 10000;
  int sum = 0;
  rep(i, 1, n+1) {
    int aji = l+i-1;
    sum += aji;
    if(abs(x) > abs(aji))
      x = aji;
  }
  
  cout << sum-x << "\n";

}

Measured memory_bytes: 256
//#pragma GCC target ("avx2,sse2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree <pair <ll, int>, null_type, less <pair <ll, int> >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define db double
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define fi first
#define se second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define endl "\n"

#define left fsdsdfoisf
#define sum dpsdfioppsf
#define assign xcvjlkdjfio
#define trie fksdfkjkfnjuiv
#define next sidlfjsfkl
#define merge sdfksdkfsldf

#define int long long

using namespace std;

void dout() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 1e5 + 7, MOD = 1e9 + 7;
int n, dp[2][N];
vector <int> q[N];

void dfs(int v, int p) {
    int child = 0, A = 1, B = 1;
    for (auto i : q[v]) {
        if (i == p) {
            continue;
        }
        dfs(i, v);
        A = A * (dp[0][i] + dp[1][i]) % MOD;
        B = B * dp[0][i] % MOD;
        child++;
    }
    if (child == 0) {
        dp[0][v] = dp[1][v] = 1;
        return;
    }
    dp[0][v] = A;
    dp[1][v] = B;
}

void solve(int tc) {
    // check for (int i = 0; i < n; j++)
    cin >> n;
    for (int i = 1; i <= n - 1; i++) {
        int x, y;
        cin >> x >> y;
        q[x].pb(y);
        q[y].pb(x);
    }
    dfs(1, 1);
    cout << (dp[0][1] + dp[1][1]) % MOD;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int tc = 1;
//    cin >> tc;
    for (int i = 0; i < tc; i++) {
        solve(i);
//        cleanup();
    }
}


Measured memory_bytes: 14208
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int ans = 0;
    REP(i, 5) {
        int tmp;
        cin >> tmp;
        if (tmp == 0) ans = i + 1;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>

int main(void) {
	int max = 1000000;
	int pn[max];
	int n, count, i, j;
	for(i = 2; i < max; i++) pn[i] = 1;
	pn[0] = pn[1] = 0;
	for(i = 2; i < max/2; i++){
		if(pn[i] == 1){
			for(j = 2*i; j < max; j += i){
				pn[j] = 0;
			}
		}
	}
	while(scanf("%d", &n) != EOF){
		count = 0;
		for(i = 1; i <= n; i++) count += pn[i];
		printf("%d\n", count);
	}
	return 0;
}

Measured memory_bytes: 4500
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, b;
    cin >> a >> b;
    cout << a * b << '\n';
}


Measured memory_bytes: 3568
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll N;
  cin >> N;
  bool result = true;
  rep (i, N) {
    ll tmp;
    cin >> tmp;
    if (tmp % 2 == 0 and tmp % 3 != 0 and tmp % 5 != 0) result = false;
  }
  if (result) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 256
a,b=input().split()
a=int(a)
b=int(b)
ll=[]
l2=[]
for i in range(b):
    c,d=input().split()
    c=int(c)
    d=int(d)
    ll.append(c)
    l2.append(d)
x=max(ll)
y=min(l2)
z=y-x
if z>=0:
    print(z+1)
else:
    print(0)


Measured memory_bytes: 11020
#include<iostream>
#include<vector>
#include<math.h>
using namespace std;


int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    vector<int> b(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b.begin(),b.end());
    int max,smax;
    max=b[n-1];
    smax=b[n-2];

    for(int i=0;i<n;i++)
    {
        if(a[i]==max)
        {
            cout<<smax<<endl;
        }
        else
        {
            cout<<max<<endl;
        }
    }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  int odd = 0;
  rep(i, 0, n) {
    int a;
    cin >> a;
    if (a & 1)
      odd++;
  }

  if (odd & 1)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long double PI = 3.14159265358979323846;
const int maxSize = 2e5 + 3;

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

    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        --a[i];
    }
    deque<int> cycle;
    bitset<maxSize> vis;
    int i = 0;
    ll inac = 0;
    while (true) {
        //cout << i << '\n';
        if (vis[i]) {
            if (cycle.size() - 1 == k) {
                cout << cycle.back() + 1 << '\n';
                return 0;
            } else if (cycle.size() - 1 > k) {
                while (!cycle.empty()) {
                    if (k == 0) {
                        cout << cycle.front() + 1 << '\n';
                        return 0;
                    }
                    --k;
                    cycle.pop_front();
                }
            }
            while (!cycle.empty()) {
                //cout << cycle.front() << ' ';
                if (cycle.front() == i) {
                    break;
                }
                ++inac;
                cycle.pop_front();
            }
            break;
        }
        cycle.push_back(i);
        vis[i] = true;
        i = a[i];
    }
    ll m = cycle.size();
    //cout << m << '\n';
    int target = (k - inac) % m;
    while (!cycle.empty()) {
        if (target == 0) {
            cout << cycle.front() + 1 << '\n';
            break;
        }
        --target;
        cycle.pop_front();
    }

    return 0;
}


Measured memory_bytes: 4852
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<assert.h>
#define gc getchar()
#define lint long long
#define INF 1000000000000000000ll
using namespace std;
inline int inn()
{
	int x,ch;while((ch=gc)<'0'||ch>'9');
	x=ch^'0';while((ch=gc)>='0'&&ch<='9')
		x=(x<<1)+(x<<3)+(ch^'0');return x;
}
int main()
{
	int a=inn(),b=inn(),c=inn();
	lint k;scanf("%lld",&k);
	if(k&1ll) printf("%d\n",-a+b);
	else printf("%d\n",a-b);return c-c;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

ll f(ll a){
	DEBUG("f(%lld) = ", a);
	for(ll x = 100; x >= 1; x--){
		if(x * (x+1) / 2 <= a){
			DEBUG("%lld\n", x);
			return x;
		}
	}
	exit(1);
}

int main(){
	ll n; scanf("%lld", &n);
	ll ans = 0;
	for(ll p = 2; p < 1'200'000; p++){
		int c = 0;
		while(n % p == 0) {
			n /= p;
			c++;
		}
		if(c) ans += f(c);
	}
	if(n > 1) ans += f(1);
	printf("%lld\n", ans);
}


Measured memory_bytes: 3824
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <cstring>
#include <cmath>
using namespace std;
#define MAXA 1001
#define MAXB 1001
#define MAXH 1000000001
#define MAXW 405
#define INF 5000
#define MAXN 100001
#define MAXM 100001
#define MAXK 100002
#define MAXP 1000001
#define MOD 1000000007
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
ll A, B, C;

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

int main(){
    cin >> A >> B >> C;
    if(C % gcd(A, B) == 0){
        printf("YES\n");
        return 0;
    }

    printf("NO\n");
    return 0;
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;

int32_t main()
{
	IOS;
	int n,k;
	cin >> n >> k;
	int ans = k;
	for(int i=2;i<=n;i++)
	{
		ans = ans*(k-1);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <sstream>

using namespace std;

int main()
{
	long long n,k,ans = 1;

	cin >> n >> k;

	for (long long i = 0; i < n; i++)
	{
		if (i == 0)
			ans *= k;
		else
			ans *= k - 1;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
import math

a,b,C=map(float,input().split())
S = min(a,b)*max(a,b)*math.sin(math.radians(C))/2
L = a+b+math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(C)))
h = 2*S/a

print("{:.10f}".format(S))
print("{:.10f}".format(L))
print("{:.10f}".format(h))


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

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

    int chang=s.size();
    for(int i=0;i<min(k,chang);i++){
        printf("%c",s[i]);
    }
    if(k<s.size()){
        cout<<"...";
    }
    return 0;
}

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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

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

int factorial(double k){
    double result=1;
     for (double i=1;i<=k;++i){
         result*=i;
    }
    return result;
}


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

    vector<double>x(n),y(n),num;
    rep(i,n){
        cin>>x[i]>>y[i];
        num.push_back(i);
    }

    double kosuu=factorial(n),sum=0;

    do{
        rep(i,n-1){
            double X=x[num[i]]-x[num[i+1]],
                    Y=y[num[i]]-y[num[i+1]];
            sum+=sqrt(X*X+Y*Y);
        }
    }while(next_permutation(num.begin(),num.end()));

    sum/=kosuu;

    cout<<fixed<<setprecision(10)<<sum<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++) {
    cin >> a.at(i);
  }

  int alice = 0, bob = 0;
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  for (int i = 0; i < N; i++) {
    if(i % 2 == 0) {
      alice += a.at(i);
    } else {
      bob += a.at(i);
    }
  }

  cout << alice - bob << endl;
  
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  vector<ll> res(n);
  for(int i = 0;i < n;i++){
    res[i] = 0;
  }
    for(int x = 1;x <= sqrt(n);x++){
      for(int y = 1;y <= sqrt(n);y++){
        if(x*x + y*y + x*y > n)break;
        for(int z = 1;z <= sqrt(n);z++){
          ll now = x*x + y*y + z*z + x*y + y*z + z*x;
          //if(x == 1 && y == 1 && z == 1)cout << "!" << now << endl;
          if(now > n){
            break;
          }
          res[now - 1]++;
          //cout << res[now - 1] << endl;
        }
      }
    }
  for(int i = 0;i < n;i++)cout << res[i] << endl;
}

Measured memory_bytes: 3772
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

using namespace std;
using ll = long long;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI = acos(-1.0);

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

int main() {
    int N, K; cin >> N >> K;
    string S; cin >> S;
    S[K - 1] += 0x20;
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 256
import math

a,b, x = map(int,input().split())

get_line = a*a*b/2

if x < get_line:
    theta = math.atan((a*b*b)/(2*x))
else:
    theta = math.atan((-2*x+2*a*a*b)/(a*a*a))

theta = math.degrees(theta)

print(theta)

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

#define f(X,Y) ((X)*(X)+(Y)*(Y))
int main(void){
	double X,Y;
  	double L;
  	int N;
  	double D;
  	scanf("%d %lf",&N,&D);
  	int count;
  	count = 0;
  	for(int i=0; i < N; i++){
    	scanf("%lf %lf",&X,&Y);
      	L = sqrt(f(X,Y));
        if( L <= D )
          count++;
    }
  printf("%d\n",count);
}

Measured memory_bytes: 2212
N = int(input())
A = list(map(int, input().split()))
ans = 0
count = 0
for i in range(N-1):
    if A[i]>=A[i+1]:
        count += 1
    else:
        ans = max(ans,count)
        count = 0
ans = max(ans,count)
print(ans)

Measured memory_bytes: 15020
#include <iostream>
#include <cmath>

#define calc(x1, x2) ((x1-x2)*(x1-x2))

using namespace std;

int n, m;
double l[3], x[31], y[31], z[31];

bool check(int i, int j, int k)
{
  double t[3];
  t[0] = sqrt(calc(x[j], x[k])+calc(y[j], y[k])+calc(z[j], z[k]));
  t[1] = sqrt(calc(x[k], x[i])+calc(y[k], y[i])+calc(z[k], z[i]));
  t[2] = sqrt(calc(x[i], x[j])+calc(y[i], y[j])+calc(z[i], z[j]));

  for(int i = 0; i < 3; ++i)
    if(fabs(l[i]/l[(i+1)%3] - t[i]/t[(i+1)%3]) >= 0.0001) return false;

  return true;
}

void solve()
{
  for(int i = 0; i < m; ++i)
    for(int j = 0; j < m; ++j)
      if(i != j) 
	for(int k = 0; k < m; ++k)
	  if(i != k && j != k && check(i, j, k)){
	    cout << (i+1) << " " << (j+1) << " " <<  (k+1) << endl;
	    return;
	  }
}

int main()
{
  while(cin>>n && n)
    while(n--){
      for(int i = 0; i < 3; ++i) cin >> l[i];
      cin >> m;
      for(int i = 0; i < m; ++i)
	cin >> x[i] >> y[i] >> z[i];

      solve();
    }

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<int>;
using P = pair<int,int>;

ll cho(ll x){
    return x*(x-1)/2;
}

int main()
{
    int n;cin >>n;
    V a(n);rep(i,n)cin >>a[i];
    rep(i,n)a[i]--;
    V c(n,0);
    rep(i,n)c[a[i]]++;
    ll sum=0;
    rep(i,n)sum+=cho(c[i]);
    rep(i,n){
        ll ans=sum;
        ans-=cho(c[a[i]]);
        ans+=cho(c[a[i]]-1);
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 4096
// Written by newbiechd
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>

// Delete the debugging information!
#define debug(x) std::cerr << #x << " = " << x << std::endl;

const int BUFFER_SIZE = 1 << 25 | 1;
struct InputOutputStream {
  char ibuf[BUFFER_SIZE], *s, *oh;
  InputOutputStream() : s(ibuf) {
    ibuf[fread(ibuf, 1, BUFFER_SIZE, stdin)] = '\0';
  }
  template <typename T>
  inline InputOutputStream &operator>>(T &x) {
    while (!isdigit(*s)) ++s;
    for (x = 0; isdigit(*s); ++s)
      x = x * 10 + (*s ^ '0');
    return *this;
  }
}IO;

template <typename lhs, typename rhs>
inline lhs min(const lhs &x, const rhs &y) { return x < y ? x : y; }
template <typename lhs, typename rhs>
inline lhs max(const lhs &x, const rhs &y) { return x > y ? x : y; }

const int MAXN = 200003;
int n, p[MAXN], suf[MAXN];
bool flag[MAXN];

const int MAXT = 800003, inf = 0x3f3f3f3f;
#define mid ((l + r) >> 1)
#define lSon (k << 1)
#define rSon (k << 1 | 1)
struct SegmentTree {
  int mx[MAXT];
  inline void init() { memset(mx, -0x3f, sizeof mx); }
  inline void pushup(int k) { mx[k] = max(mx[lSon], mx[rSon]); }
  void modify(int k, int l, int r, int x, int v) {
    if (l == r) {
      mx[k] = v;
      return ;
    }
    x <= mid ? modify(lSon, l, mid, x, v) : modify(rSon, mid + 1, r, x, v);
    pushup(k);
  }
  int query(int k, int l, int r, int x, int y) {
    if (x <= l && r <= y)
      return mx[k];
    int o = -inf;
    if (x <= mid)
      o = max(o, query(lSon, l, mid, x, y));
    if (mid < y)
      o = max(o, query(rSon, mid + 1, r, x, y));
    return o;
  }
}tree[2];
#undef mid
#undef lSon
#undef rSon

int f[MAXN][2], arrA[MAXN], arrB[MAXN];
char ans[MAXN];

int cntA, cntB, mxA, mxB;
inline bool check(int i) {
  int temp = cntA + (p[i] > mxA) + suf[i + 1] - cntB;
  if (temp >= 0 && tree[temp & 1].query(1, 1, n, mxB, n) >= temp)
      return 1;
  temp = cntB + suf[i + 1] - cntA - (p[i] > mxA);
  if (temp >= 0 && tree[temp & 1].query(1, 1, n, max(mxA, p[i]), n) >= temp)
    return 1;
  return 0;
}

int main() {
  IO >> n;
  for (int i = 1, mx = 0; i <= n; ++i) {
    IO >> p[i];
    if (p[i] > mx)
      flag[i] = 1, mx = p[i];
  }
  tree[1].init();
  for (int i = n; i; --i) {
    suf[i] = suf[i + 1] + flag[i];
    for (int j = 0; j < 2; ++j)
      f[i][j] = tree[j ^ (!flag[i])].query(1, 1, n, p[i], n) + 1 + flag[i];
    for (int j = 0; j < 2; ++j)
      tree[j].modify(1, 1, n, p[i], f[i][j]);
  }
  
  for (int i = 1; i <= n; ++i) {
    tree[0].modify(1, 1, n, p[i], 0);
    tree[1].modify(1, 1, n, p[i], -inf);
    if (check(i)) {
      ans[i] = '0';
      if (p[i] > mxA)
        mxA = p[i], ++cntA;
    }
    else {
      ans[i] = '1';
      if (p[i] > mxB)
        mxB = p[i], ++cntB;
    }
  }
  if (cntA == cntB)
    printf("%s\n", ans + 1);
  else
    printf("-1\n");
  return 0;
}


Measured memory_bytes: 13184
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vector< ll > >;
using st = set<ll>;
using kiwi = queue<ll>;
using mp = map<ll,ll>;
using ump = unordered_map<ll,ll>;
#define MOD 1000000007
const ll mx = 1e5+123;
#define REP(i,n) for (ll i=1;i<=n;++i)

#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main(){
    fastio;
    ///freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    ll n; cin>>n;
    if(n%1000==0) cout<<0<<endl;
    else if(n<1000) cout<<1000-n<<endl;
    else if(n>1000) cout<<((n/1000)+1)*1000-n<<endl;

return 0;
}


Measured memory_bytes: 3648
n, p = map(int, input(). split())
s = list(map(int, input()[::-1]))

cnt = 0
if 10 % p == 0:
    for i, c in enumerate(s):
        if int(c) % p == 0:
            cnt += n - i
else:
    accmod = [0] * p
    accmod[0] = 1
    num = 0
    for i in range(n):
        num = (num + s[i] * pow(10, i, p)) % p
        accmod[num] += 1
    for v in accmod:
        if v > 1:
            cnt += v * (v - 1) // 2
print(cnt)


Measured memory_bytes: 5156
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

int n;
int a;
vector<int> arr;

int main()
{
	cin >> n;

	for(int i = 0;i < n;i++)
	{
		cin >> a;
		arr.push_back(a);
	}

	sort(arr.rbegin(),arr.rend());

	int cou = 0;

	int A = 0;
	int B = 0;

	for(int i = 0;i < n;i++)
	{
		if(cou % 2 == 0)
		{
			A += arr[i];
		}
		else
		{
			B += arr[i];
		}
		cou++;
	}

	cout << A - B << endl;
	return 0;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}

signed main(){
	ll a,b,c;
	cin >> a >> b >> c;
	cout << 6 - a - b << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

ans = []
while True:
    N = int(input())
    if N == 0: break
    W = list(map(int, input().split()))
    # dp[i][j]: iからjのブロックを全て除外可能か
    dp = [[False]*N for _ in range(N)]
    for i in range(N-1):
        if abs(W[i]-W[i+1]) <= 1:
            dp[i][i+1] = True
    for d in range(4, N+1):
        for i in range(N-d+1):
            j = i+d-1
            for k in range(i, j):
                if dp[i][k] and dp[k+1][j]:
                    dp[i][j] = True
            if abs(W[i]-W[j]) <= 1 and dp[i+1][j-1]:
                dp[i][j] = True
    # dp2[i]: iまでで除外可能なブロックの最大値(1-indexed)
    dp2 = [0]*(N+1)
    for i in range(N):
        for j in range(i+1, N):
            if dp[i][j]:
                dp2[j+1] = max(dp2[j+1], dp2[i]+j-i+1)
        dp2[i+1] = max(dp2[i+1], dp2[i])
    ans.append(dp2[N])
print(*ans, sep="\n")



Measured memory_bytes: 7088
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>
#include <memory.h>

using namespace std;

typedef long long ll;

// 0 -> '.', 1 -> '#'
bool grid[101][101];


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int W, B; cin >> W >> B;
	int cntW = W - 1, cntB = B - 1;
	for(int i=1;i<=50;i++){
		for(int j=1;j<=100;j++){
			if(cntB > 0 && i %2 == 0 && j %2 == 0){
				cntB--;
				grid[i][j] = 1;
			}else{
				grid[i][j] = 0;
			}
		}
	}
	for(int i=51;i<=100;i++){
		for(int j=1;j<=100;j++){
			if(cntW > 0 && i %2 == 0 && j %2 == 0){
				cntW--;
				grid[i][j] = 0;
			}else{
				grid[i][j] = 1;
			}
		}
	}
	cout << 100 << " " << 100 << endl;
	for(int i=1;i<=100;i++){
		for(int j=1;j<=100;j++){
			if(grid[i][j]) cout << '#';
			else cout << '.';
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(stringLineScan())
	k, _ := strconv.Atoi(stringLineScan())
	x := 1
	for i := 1; ; i++ {
		x *= k
		if n < x {
			fmt.Println(i)
			break
		}
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int n, k, a;
	cin >> n >> k;

	vector<long long> cumuls(n + 1, 0);
	for (int i = 0; i < n; i++) {
		cin >> a;
		cumuls[i + 1] = cumuls[i] + a;
	}

	vector<long long> nums;
	for (int i = 0; i < n + 1; i++) {
		for (int j = i + 1; j < n + 1; j++) {
			auto sum = cumuls[j] - cumuls[i];
			nums.emplace_back(sum);
		}
	}

	for (int i = 44; i >= 0; i--) {
		long long mask = 1LL << i;

		vector<long long> tmp;
		for (auto x: nums) {
			if (x & mask) {
				tmp.emplace_back(x);
			}
		}
		if (tmp.size() >= k) {
			nums = tmp;
		}
	}


	auto ans = nums[0];
	for (auto x: nums) {
		ans &= x;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6388
#include <iostream>
#include <vector>
#include <set>

using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::set;

bool intension(set<int>& s1, set<int>& s2) {
	if (s1.size() < s2.size()) {
		return false;
	}

	for (set<int>::iterator itr = s2.begin(); itr != s2.end(); ++itr) {
		if ((s1.find(*itr)) == s1.end()) {
			return false;
		}
	}
	return true;
}

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

	while (N != 0) {
		vector< set<int> > data(N+1);
		int cri = -1;
		int count = 0;
		int temp;
		int M;
		for (int i = 0; i < N+1; i++) {
			cin >> M;
			for (int j = 0; j < M; j++) { 
				cin >> temp;
				data[i].insert(temp);
			}
			
		}

		for (int i = 0; i < N; i++) {
			if (count < 2) {
				if (intension(data[i], data[N])) {
					cri = i+1;
					count++;
				}
			}
		}
		if (count > 1) {
			cout << -1 << endl;
		}
		else {
			cout << cri << endl;
		}

		cin >> N;
	}

	return 0;
}

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
#define VI vector<int>
#define VL vector<LL>
#define VII vector< vector<int> >
#define VLL vector< vector<LL> >
#define VS  vector<string>
#define VSS vector< vector<string> >
#define PII pair<int,int>
#define PIS pair<int,string>
#define PSI pair<string,int>
#define PLL pair<LL,LL>
const LL MOD = 1000000007;
const LL INF = 1e16;
LL facctorialMethod(int k);
int main(){
    LL n,s_len;
    string s;
    cin >> n;
    cin >> s;
    for(int i = 0; i < s.size(); i++) {
        s_len = s[i] - 'A';
        s_len = (s_len + n) % 26;
        s[i] = s_len + 'A'; 
//        cout << "s_len :" << s_len << endl;
    }
    cout << s << endl;

//    s_len = 'A';
//    cout << "s_len :" << s_len << endl;
    return 0;
}

LL facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i){
        sum *= i;
    }
    return sum;
}


Measured memory_bytes: 3664
// https://atcoder.jp/contests/abc128/tasks/abc128_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    vector<set<int>> V(M);
    REP(i, M) {
        int k;
        cin >> k;
        REP(j, k) {
            int t;
            cin >> t;
            V[i].insert(t - 1);
        }
    }
    vector<bool> P(M);
    REP(i, M) {
        int t;
        cin >> t;
        P[i] = (t == 1);
    }
    int ans = 0;
    // ビット全探索
    REP(i, 1UL << N) {
        vector<int> cnt(M);
        REP(j, N) {
            if (i & (1UL << j)) {
                REP(k, M) {
                    if (V[k].count(j) > 0) {
                        cnt[k]++;
                    }
                }
            }
        }
        bool flag = true;
        REP(k, M) {
            if (cnt[k] % 2 != P[k]) {
                flag = false;
                break;
            }
        }
        if (flag) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3604
fn main() {
 loop {
  let v: Vec<i32> = {
   let mut b = String::new();
   let s = std::io::stdin();
   s.read_line(&mut b).unwrap();
   b.split_whitespace().flat_map(str::parse).collect()
  };
  if v[0] == 0 && v[1] == 0 { break; }
  let n = v[0];
  let c = (1..n - 1).flat_map(|a| (a + 1..n).flat_map(move |b| (b + 1..n + 1).map(move |c| (a, b, c)))).filter(|&(a, b, c)| a + b + c == v[1]).count();
  println!("{}", c);
 }
}


Measured memory_bytes: 5024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    static BufferedReader input = null;

    static {
        input = new BufferedReader(new InputStreamReader(System.in));
    }

    public static void main(String ar[]) throws IOException {
        char str[] = input.readLine().toCharArray();

        int first = (str[1] - '0') + ((str[0] - '0') * 10);
        int second = (str[3] - '0') + ((str[2] - '0') * 10);


        boolean first_is_month = first >= 1 && first <= 12;
        boolean second_is_month = second >= 1 && second <= 12;


        if (first_is_month && second_is_month)
            System.out.println("AMBIGUOUS");
        else if (!first_is_month && !second_is_month) {
            System.out.println("NA");
        } else if (first_is_month) {
            System.out.println("MMYY");
        } else if (second_is_month) {
            System.out.println("YYMM");
        }
    }
}


Measured memory_bytes: 22484
using System;

namespace Character
{
    class Ring
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var p = Console.ReadLine();
            var ss = s + s;
            for (int i = 0; i < s.Length; i++)
                if (p == ss.Substring(i, p.Length))
                {
                    Console.WriteLine("Yes");
                    return;
                }
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 8928
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class AtCoderr
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            long ans = 0;
            for (int i = 0; i < n; i++)
            {
                for (int j = i+1; j < n; j++)
                {
                    ans += s[i] * s[j];
                }
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
str = input()

n = len(str)
# 先頭を1で固定する場合と、0で固定する場合の2パターン

str1 = "10"*(n//2) + "1"*(n%2)
str0 = "01"*(n//2) + "0"*(n%2)

v1 = 0
v0 = 0
for i in range(n):
	if str[i] == str1[i]: v1 += 1
	if str[i] == str0[i]: v0 += 1
	
print(min([v1,v0]))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RREP(i,n) for(long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define llINF (long long) 9223372036854775807
#define loINF (long) 2147483647
#define shINF (short) 32767
#define SORT(c) sort((c).begin(),(c).end())

using namespace std;
typedef vector<long> VI;
typedef vector<VI> VVI;

int main(void){
	long H,W;
	cin >> H >> W;
	if (H*W % 3 == 0) {
		cout << 0 << endl;
		exit(0);
	}
	long ans = loINF;

	FOR(i,1,H){
		// 高さiを使う
		long sec = (H - i) * (W / 2);
		long thi = ((H - i) * W) - sec;
		ans = min(ans,max({abs(i*W - sec),abs(i*W - thi),abs(sec - thi)}));
		sec = W * ((H - i) / 2);
		thi = ((H - i) * W) - sec;
		ans = min(ans,max({abs(i*W - sec),abs(i*W - thi),abs(sec - thi)}));

	}

	FOR(i,1,W) {
		long sec = (W - i) * (H / 2);
		long thi = ((W - i) * H) - sec;
		ans = min(ans,max({abs(i*H - sec),abs(i*H - thi),abs(sec - thi)}));
		sec = H * ((W - i) / 2);
		thi = ((W - i) * H) - sec;
		ans = min(ans,max({abs(i*H - sec),abs(i*H - thi),abs(sec - thi)}));
	}

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

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

int f(std::vector<int> d) {
    std::set<int> s;
    for (int i = 0; i < d.size(); i++) {
        s.insert(d[i]);
    }
    return s.size();
}

int main() {

    int n;
    std::cin >> n;

    std::vector<int> d;
    for (int i = 0; i < n; i++) {
        int tmp;
        std::cin >> tmp;
        d.push_back(tmp);
    }

    int result = f(d);
    std::cout << result << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, M; cin >> N >> M;
    priority_queue<int> Q;
    for (int i = 0; i < N; i++) {
        int A; cin >> A;
        Q.push(A);
    }
    for (int i = 0; i < M; i++) {
        int t = Q.top();
        Q.pop();
        Q.push(t / 2);
    }
    long long ans = 0;
    while (!Q.empty()) {
        ans += Q.top();
        Q.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 892
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
 
Node root;
 
Node treeMinimum(Node x){
 
 
}
 
Node treeSearch(Node u, int k){
  if(u == NIL || u->key == k) return u;
  else if(u->key > k) return treeSearch(u->left, k);
  else if(u->key < k) return treeSearch(u->right, k);
}
 
Node treeSuccessor(Node x){
 
 
}
 
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
 
 
 
}
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
 
}
 
void inorder(Node u){
  if(u->left != NIL) inorder(u->left);
  printf(" %d", u->key);
  if(u->right != NIL) inorder(u->right);
}
void preorder(Node u){
  printf(" %d", u->key);
  if(u->left != NIL) preorder(u->left);
  if(u->right != NIL) preorder(u->right);
}
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
 
  return 0;
}

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

using namespace std;

using ll = long long;

const int N = 2e5 + 5;
const int M = 1e6 + 5;
int n;
int a[N], d[M];

int main() {
	cin>>n;
	
	for (int i = 1; i <= n; i++) {
		cin>>a[i];
		if (!d[a[i]]) {
			for (int j = a[i]; j <= 1e6; j += a[i]) 
			d[j]++;
		}
		else {
			d[a[i]]++;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) if (d[a[i]] == 1) ans++;
	printf("%d\n", ans);
}


Measured memory_bytes: 8396
N = int(input())
A = [int(input()) for _ in range(N)]
m = max(A)
ans = list(map(str, [m for _ in range(N)]))
if A.count(m) > 1:
    print('\n'.join(ans))
    exit()
AA = A[:]
AA.remove(m)
mm = max(AA)
for n in range(N):
    if A[n] == m:
        ans[n] = str(mm)
        break
print('\n'.join(ans))

Measured memory_bytes: 29200