akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main() {
    int n, a;
    cin >> n;
    int c = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        while (a % 2 == 0) {
            a /= 2;
            ++c;
        }
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
 
int main(){
	int a,b;scanf("%d%d",&a,&b);
	int d=1;
	if(a){a--;d*=100;}
	if(a){a--;d*=100;}
	
	for(int i=1;;i++){
		if(i%d)continue;
		if(i%(d*100)==0)continue;
		b--;
		if(b==0){
			printf("%d\n",i);return 0;
		}
	}
}

Measured memory_bytes: 128
/*
    author: Salam_35
    Created at :

*/

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

/*        speed up       */
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF    1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));
#define tst() _fastio;int testsalam;cin >> testsalam;while(testsalam--)
#define Mod 100000007
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;
#define endl '\n'
//void inversemod(ll n, ll mod, ll invmod[],ll MOD){for(int i=2; i<=n; ++i) invmod[i]=MOD-MOD/i*invmod[MOD%i]%MOD;}
//void bigmod( ll a, ll b ,ll mod){ll r = 1;a = a%mod;while(b){if( b%2 ) r = (r*a)%mod;b = b/2;a = (a*a)%mod; }return (ll)r;}
string inttostr(ll n){std::stringstream ss;ss << n;string out=ss.str();return out;}
ll stringtoint(string s){istringstream iss (s);ll n;iss >> n;return n;}
template <typename T> T gcd(T a,T b){if(a < 0)return gcd(-a,b);if(b < 0)return gcd(a,-b);return (b == 0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a < 0)return lcm(-a,b);if(b < 0)return lcm(a,-b);return a*(b/gcd(a,b));}
typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;

int main()
{
    
   ll a;
  cin >> a;
  cout<<(ll)(a+a*a+a*a*a)<<endl;
}
/*
 		remember:
 		ll vs int
 		array size
 		case for 1 2 3 
*/


Measured memory_bytes: 3552
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int ans=0;
		for(int i=1;i<=N;i+=2) {
			int count=0;
			for(int n=1;n<=i;n++) {
				if(i%n==0)count++;
			}
			if(count==8) ans++;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23124
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
 
public class Main {
    public static void main(String[] args) {
        printAnswer();
    }
 
    private static void printAnswer() {
        Logger logger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            List<Integer> trainList = new ArrayList<>();
            String dataset = br.readLine();
 
            while (dataset != null) {
                int integer = Integer.parseInt(dataset);
                if(integer != 0){
                    trainList.add(integer);
                }else{
                    System.out.println(trainList.get(trainList.size()-1));
                    trainList.remove(trainList.size()-1);
                }
                dataset = br.readLine();
            }
        } catch (IOException e) {
            logger.info("Error:  Reading input data is failed.");
        }
    }
}

Measured memory_bytes: 24644
n = int(input())
s = {}
for _ in range(n):
    i = input()
    if i in s:
        s[i] += 1
    else:
        s[i] = 1
ans = []
b = 0
for i in s:
    if b < s[i]:
        ans = []
        b = s[i]
    if b == s[i]:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    map<ll, ll> cnt;
    ll ans = 0;
    rep(i, N) {
        ans += cnt[i + 1 - A[i]];
        cnt[i + 1 + A[i]]++;
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 27472
N = int(input())
A = list(map(int, input().split()))
i = 0
d = 0
s = 0
while (i < N-1):
    A[i] = A[i] + d
    if (A[i] > A[i+1]):
        d = A[i] - A[i+1]
        s = s + d
    else:
        d = 0
    i += 1
print(s)

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;

constexpr int INF = 1e9;

struct RMQ {
  int N;
  vector<int> dat;

  RMQ(int n) {
    N = 1;
    while (N < n) N *= 2;
    dat.resize(N * 2, INF);
  }

  void update(int k, int v) {
    k += N;
    dat[k] = v;
    while (k > 1) {
      k >>= 1;
      dat[k] = min(dat[k * 2], dat[k * 2 + 1]);
    }
  }

  int query(int l, int r) {
    l += N;
    r += N - 1;
    int res = INF;
    while (l <= r) {
      if ((l & 1) == 1) res = min(res, dat[l++]);
      if ((r & 1) == 0) res = min(res, dat[r--]);
      l >>= 1;
      r >>= 1;
    }
    return res;
  }
};




int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll N; cin >> N;
  RMQ rmq(N), rmq2(N);
  vector<int> P(N); rep(i, N) cin >> P[i];
  vector<int> pos(N + 1);
  rep(i, N) {
    cin >> P[i];
    pos[P[i]] = i;
  }
  ll ans = 0;
  for (int i = N; i >= 1; i--) {
    int k = pos[i];
    ll r = rmq.query(k, N);
    ll r2 = r != INF ? rmq.query(r + 1, N) : INF;
    ll l = -rmq2.query(0, k);
    ll l2 = l != -INF ? -rmq2.query(0, l) : -INF;
    ans += i * (k - max(l, -1LL)) * (min(N, r2) - min(r, N));
    ans += i * (max(l, -1LL) - max(l2, -1LL)) * (min(r, N) - k);
    rmq.update(k, k);
    rmq2.update(k, -k);
  }
  cout << ans << endl;
}

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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


template <typename T>
struct DisjointSparseTable{
    function<T(T, T)> f;
    vector<vector<T>> v;

    DisjointSparseTable(vector<T>& inp, function<T(T, T)> f) : f(f){
        int n = inp.size();
        int b;
        for(b = 0; (1 << b) <= inp.size(); ++b);
        v.assign(b, vector<T>(n));
        for(int i = 0; i < n; ++i)
            v[0][i] = inp[i];
        for(int i = 1; i < b; ++i){
            int siz = 1 << i;
            for(int j = 0; j < n; j += siz << 1){
                int t = min(j + siz, n);
                v[i][t - 1] = inp[t - 1];
                for(int k = t - 2; k >= j; --k)
                    v[i][k] = f(inp[k], v[i][k + 1]);
                if(t >= n)
                    break;
                v[i][t] = inp[t];
                int r = min(t + siz, n);
                for(int k = t + 1; k < r; ++k)
                    v[i][k] = f(v[i][k - 1], inp[k]);
            }
        }
    }

    T get(int l, int r){
        if(l >=r)
            return MOD;
        if(l >= --r)
            return v[0][l];
        int p = 31 - __builtin_clz(l ^ r);
        return f(v[p][l], v[p][r]);
    }
};



signed main(){

    int n;
    cin >> n;
    vector<int> l(n), r(n);
    for(int i = 0; i < n; ++i){
        cin >> l[i] >> r[i];
        --l[i];
    }

    int l_ma = 0, l_ma_idx = 0;
    int r_mi = MOD, r_mi_idx = 0;
    for(int i = 0; i < n; ++i){
        if(chmax(l_ma, l[i]))
            l_ma_idx = i;
        if(chmin(r_mi, r[i]))
            r_mi_idx = i;
    }
    int ans = 0;
    for(int i = 0; i < n; ++i){
        if(i != l_ma_idx && i != r_mi_idx)
            chmax(ans, max(r_mi - l_ma, 0) + r[i] - l[i]);
    }
    if(l_ma_idx != r_mi_idx){
        vector<pair<int,int>> v;
        for(int i = 0; i < n; ++i){
            if(i != l_ma_idx && i != r_mi_idx){
                // 一定までfirstを、それ以降はsecondを見て、総和の最大化をする
                v.emplace_back(max(0, r[i] - l_ma), max(0, r_mi - l[i]));
            }
        }
        sort(v.begin(), v.end(), greater<>());
        int m = v.size();
        vector<int> v1, v2;
        for(int i = 0; i < m; ++i){
            v1.push_back(v[i].first);
            v2.push_back(v[i].second);
        }
        DisjointSparseTable<int> d1(v1, [](auto x, auto y){return min(x, y);});
        DisjointSparseTable<int> d2(v2, [](auto x, auto y){return min(x, y);});
        for(int i = 0; i <= m; ++i){
            chmax(ans, min(d1.get(0, i), r[l_ma_idx] - l[l_ma_idx]) + min(d2.get(i, m), r[r_mi_idx] - l[r_mi_idx]));
        }
    }
    cout << ans << endl;

}



Measured memory_bytes: 16756
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node {
    int key;
    Node *prev, *next;
};

Node *nil;

void init() {
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void insert(int key) {
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

Node *listSearch(int key) {
    Node *cur = nil->next;
    while(cur!=nil && cur->key!=key) {
        cur = cur->next;
    }
    return cur;
}

void deleteNode(Node *t) {
    if(t==nil) {
        return;
    }
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->prev);
}

void deleteKey(int key) {
    deleteNode(listSearch(key));
}

void printList() {
    Node *cur = nil->next;
    int isf = 0;
    while(1) {
        if(cur==nil) {
            break;
        }
        if(isf++>0) {
            printf(" ");
        }
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

int main() {
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for(i=0; i<n; i++) {
        scanf("%s%d", com, &key);
        if(com[0]=='i') {
            insert(key);
            np++;
            size++;
        }
        else if(com[0]=='d') {
            if(strlen(com)>6) {
                if(com[6]=='F') {
                    deleteFirst();
                }
                else if(com[6]=='L') {
                    deleteLast();
                }
            }
            else {
                deleteKey(key);
                nd++;
            }
            size--;
        }
    }
    printList();

    return 0;
}


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


int main (void)
{
    char s[100];
    int slen;
    int  count;
    scanf("%s", s);
    slen = strlen(s);
    for (unsigned int i = 0; i < slen/2; i++) {
        if (s[i] != s[strlen(s)-1-i]) {
            count++;
        }
    }

    printf("%d", count);

    return EXIT_SUCCESS;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int main(int argc, char const *argv[]){
int N;
cin >>N;
int D[N];
for (int i = 0; i < N; ++i) cin >> D[i]; 
int *last_size_index = max_element(D,D+N);
int last_size=*last_size_index;
int count=1;
int flag=1;
// cout<<"-------"<<endl;
sort(D, D + N, greater<int>()); 
while(true){
    flag=0;
    for(int j=0;j<N;j++){
        if (D[j]<last_size){
            last_size=D[j];
            // cout<<last_size<<endl;
            count+=1;
            flag=1;
        }
    }
    if(flag==0)break;
}
cout<<count<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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(int argc, char const *argv[]) {
  int n,m;
  cin >> n >> m;
  vector<vector<int>> jobs(m);
  priority_queue<int> pq;
  rep(i,n){
    int a,b; cin >> a >> b;
    if(a > m)continue;
    jobs[m-a].pb(b);//jobs[i]:=i日目までに開始しなきゃいけない仕事
  }
  ll ans=0;
  for(int i=m-1; i>=0; i--){//後ろからみる
    for(int b:jobs[i]){
      pq.push(b);
    }
    if(!pq.empty()){
      ans+=pq.top();
      pq.pop();
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5632
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 200009 /// I wanna be the wind
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e17 + 9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;
    cin>>n>>k;
    ll pe[n+2],c[n+2];
    rep(i,0,n)cin>>pe[i],pe[i]--;
    rep(i,0,n)cin>>c[i];
    ll ans = -INF;
    rep(i,0,n){
        ll tamcic=0;
        ll vcic=0;
        ll v = i;
        ll k2=k;
        while(true){
            tamcic++,vcic+=c[v];
            v = pe[v];
            if(v==i)break;
        }
        ll valact=0;
        ll cont2=0;
        while(true){
            cont2++;
            valact+=c[v];
            k2--;
            if(k2<0)break;
            ans = max(ans,valact+((k-cont2)/tamcic)*max(0LL,vcic));
            v = pe[v];
            if(v==i)break;
        }
    }
    cout<<ans<<'\n';
    return 0;  
}   

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
typedef pair<ll,ll> ll_pair;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,a,b;
	cin>>n>>a>>b;
	if((a-b)%2==0){
		cout<<"Alice"<<endl;
	}else{
		cout<<"Borys"<<endl;
	}


	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  string s;
  cin >> s;
  if( (int)s.length() >= 4)
    if(s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I')
    {
      cout << "Yes" << endl;
      return 0;
    }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 1000000007
#define INF ((1LL<<62LL) - 1)

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

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

    cout << ans << "\n";



}


Measured memory_bytes: 5212
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Object o = run();
        if (o != null)
            System.out.println(o);
    }

    static Object run() {
        try (Scanner sc = new Scanner(System.in)) {
            String s = sc.next();
            String t = sc.next();
            int resultMin = 10000;
            for (int i = 0; i < s.length() - t.length() + 1; i++) {
                String sSub = s.substring(i, i + t.length());
                int result = 0;

                char[] sa = sSub.toCharArray();
                char[] ta = t.toCharArray();

                for (int j = 0; j < sSub.length(); j++) {
                    if (sa[j] != ta[j]) {
                        result++;
                    }
                }
                resultMin = Math.min(result, resultMin);
            }
            return resultMin;
        }
    }
}

class ChenNumberUtil {
    static Collection<Integer> getDivisors(int n) {
        ArrayList<Integer> al = new ArrayList<>();
        for (int i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                al.add(i);
                if (n / i != i)
                    al.add(n / i);
            }
        }
        Collections.sort(al);
        return al;
    }
}

class ChenBitUtil {
    static int popCount(int bit) {
        return Integer.bitCount(bit);
    }

    static boolean isFlag(int bit, int i) {
        return 0 != (bit & (1 << i));
    }

    static int setTrue(int bit, int i) {
        return bit |= (1 << i);
    }

    static int setFalse(int bit, int i) {
        return bit &= ~(1 << i);
    }

    static int setReverse(int bit, int i) {
        return isFlag(bit, i) ? setFalse(bit, i) : setTrue(bit, i);
    }

    static int reverseAll(int bit) {
        return ~bit;
    }
}

Measured memory_bytes: 29672
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

#define PI 3.141592653589793238
#define INF 1050000000

using namespace std;



//cout << fixed << setprecision(15) << << endl;
//cout << << endl;

int main() {

	char c;

	cin >> c;

	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o' )cout << "vowel" << endl;
	else cout << "consonant" << endl;


	return 0;
}

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

typedef long long lll;

int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    char c = s[s.size() - 1];
    set<string> S = {s};
    for(int i = 1; i < n; i++) {
        cin >> s;
        if(s[0] != c || S.count(s)) {
            cout << "No" << endl;
            return 0;
        }
        c = s[s.size() - 1];
        S.insert(s);
    }
    cout << "Yes" << endl;
}



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

using namespace std;

int main()
{
   string S;
   cin >> S;

   if(S[0] == S[1]){
      if(S[0]!=S[2]&&S[2]==S[3]) cout << "Yes" << endl;
      else cout << "No "<< endl;
   } else {
      if(S[0]==S[2]&&S[1]==S[3]) cout << "Yes" << endl;
      else if(S[0]==S[3]&&S[1]==S[2]) cout << "Yes" << endl;
      else cout << "No" << endl;
   }

   return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;
 
#define BUFF ios::sync_with_stdio(false)
#define rep(i,a,b) for (int i=a; i<b; i++)
#define pb push_back
#define vvi vector<vector<int>> 
#define vi vector<int>
#define vb vector<bool>
#define vvb vector<vector<bool>> 
 
vi p;
vector<int> cor;
pair<int, int> par = {-1, -1}; 

bool valid(vvb & mp, vi & p, int i, int j) {
	int k = i;
	vector<int> w;
	while (k != j) {
		w.push_back(k);
		k = p[k];
	}
	w.push_back(k);

	int ct = 0;
	for(int i=0; i<w.size(); i++) {
		for(int j=i+1; j<w.size(); j++) {
			if (mp[w[i]][w[j]]) ct++; 
			if (mp[w[j]][w[i]]) ct++; 
		}
	}
	return (ct == w.size());
}

void dfs_visit(vvb & mp, vvi & adj, int i) {
		cor[i] = 1;
		for (int j : adj[i]) {
			if (cor[j] == 1) {
				par = {i, j};
				if (valid(mp, p, i, j)) {
					for(int i=1; i<cor.size(); i++) {
						cor[i] = 2;
					}
				} else par = {-1, -1};
			}
			if (cor[j] == 0) {
				p[j] = i;
				dfs_visit(mp, adj, j);
			}
		}
		cor[i] = 2;
}
 
void dfs(vvb & mp, vvi & adj, int n) {
	p.assign(n+1, 1);
	cor.assign(n+1, 0);
	for(int i=1; i<=n; i++) {
		if (cor[i] == 0) {
			dfs_visit(mp, adj, i);
		}
	}
}
 
int main() {
	int n, m, a, b;
	cin >> n >> m;
 
	vvb mp(n+1, vb(n+1, 0));
	vi vetor;
	vetor.assign(n+1, 0);
 
	vvi adj;
	vi lista;
	lista.clear();
	adj.assign(n+1, lista);
	for (int i=1; i<=m; i++) { 
		cin >> a >> b;
		adj[a].pb(b);
		mp[a][b] = 1;
	}
	dfs(mp, adj, n);

	if (par.first == -1) cout << -1 << endl;
	else {
		vector<int> w;
		int k = par.first;
		while (k != par.second) {
			w.push_back(k);
			k = p[k];
		}
		w.push_back(k);
		cout << w.size() << endl;
		for(int i=0; i<w.size(); i++) {
			cout << w[i] << endl;
		}
	}
   
   return 0;
 
}


Measured memory_bytes: 640
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
//#pragma GCC target("popcnt")
//#pragma GCC target("sse4")
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.rbegin(),a.rend()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i > -1; i--)
#define rer(i, x, n) for (int i = x; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef long double ld;














#define int long long
signed main(){
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    for (int i = 0; i < a; i++) cin >> p[i];
    for (int i = 0; i < b; i++) cin >> q[i];
    for (int i = 0; i < c; i++) cin >> r[i];
    sort(rng(p));
    sort(rng(q));
    sort(rng(r));
    vector<int> qqq;
    for (int i = 0; i < x; i++) qqq.pb(p[i]);
    for (int i = 0; i < y; i++) qqq.pb(q[i]);
    for (int i = 0; i < c; i++) qqq.pb(r[i]);
    sort(rng(qqq));
    int ans = 0;
    for (int i = 0; i < x + y; i++) ans += qqq[i];
    cout << ans;

}


Measured memory_bytes: 8688
#include  <stdio.h>

int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a==1&&b==2) {
        printf("3");
    }
    if(a==2&&b==1) {
        printf("3");
    }
    if(a==1&&b==3) {
        printf("2");
    }
    if(a==3&&b==1) {
        printf("2");
    }
    if(a==3&&b==2) {
        printf("1");
    }
    if(a==2&&b==3) {
        printf("1");
    }
    
    
    return 0;
}

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

int gcd(int a, int b) {
	if (!b)return a;
	return gcd(b, a%b);
}
bool b[1400000][7], c[1400000][7];
int a[100000];
int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };
int main() {
	ll n; int m, q; scanf("%lld%d%d", &n, &m, &q);
	int l = m / gcd(m, 7) * 7;
	rep(i, q) {
		scanf("%d", &a[i]);
		for (int j = a[i]; j < 2 * l; j += m) {
			c[j / 7][j % 7] = 1;
			if (j <= l)b[j / 7][j % 7] = 1;
		}
	}
	queue<P>que;
	ll c1 = 0;
	rep(i, l / 7)rep(j, 7) {
		if (b[i][j])continue;
		c1++; que.push(P(i, j));
		while (!que.empty()) {
			P p = que.front(); que.pop();
			rep(k, 4) {
				int nx = p.first + dx[k], ny = p.second + dy[k];
				if (0 <= nx&&nx < l / 7 && 0 <= ny&&ny < 7 && !b[nx][ny]) {
					b[nx][ny] = 1; que.push(P(nx, ny));
				}
			}
		}
	}
	ll c2 = 0;
	rep(i, 2 * l / 7)rep(j, 7) {
		if (c[i][j])continue;
		c2++; que.push(P(i, j));
		while (!que.empty()) {
			P p = que.front(); que.pop();
			rep(k, 4) {
				int nx = p.first + dx[k], ny = p.second + dy[k];
				if (0 <= nx&&nx < 2 * l / 7 && 0 <= ny&&ny < 7 && !c[nx][ny]) {
					c[nx][ny] = 1; que.push(P(nx, ny));
				}
			}
		}
	}
	printf("%lld\n", (c2 - c1)*(7*n / l - 1) + c1);
}

Measured memory_bytes: 5760
mod = 10**9 + 7

def C(n, r, mod):
    x, y = 1, 1
    for _ in range(r):
        x *= n; y *= r
        x %= mod; y %= mod
        n -= 1; r -= 1
    return x * pow(y, mod - 2, mod) % mod


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

print((pow(2, n, mod) - 1 - C(n, a, mod) - C(n, b, mod)) % mod)


Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
using namespace std;
int N,ptr,res;
int A[100000];
int main()
{
    scanf("%d", &N);
    for (int i=0;i<N;i++)scanf("%d",&A[i]);
    sort(A,A+N);
    while(ptr<N)
    {
        int cc=A[ptr],f=0;
        while(ptr<N&&A[ptr]==cc)f++,ptr++;
        res+=f%2;
    }
    printf("%d\n",res);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll h, w;
  cin >> h >> w;
  vector<string> s(h);

  rep(i, h) {
    cin >> s[i];
  }

  vector<vll> cnt(h, vll(w));
  rep(i, h) {
    vll done(w);
    rep(j, w) {
      if (s[i][j] == '#') {
        continue;
      }
      if (done[j]) {
        continue;
      }
      ll l = 0;

      while (j + l < w) {
        if (s[i][j + l] == '#') {
          break;
        }
        ++l;
      }
      rep(k, l) {
        cnt[i][j + k] += l;
        done[j + k] = 1;
      }
    }
  }

  rep(j, w) {
    vll done(h);
    rep(i, h) {
      if (s[i][j] == '#') {
        continue;
      }
      if (done[i]) {
        continue;
      }
      ll l = 0;

      while (i + l < h) {
        if (s[i + l][j] == '#') {
          break;
        }
        ++l;
      }
      rep(k, l) {
        cnt[i + k][j] += l;
        done[i + k] = 1;
      }
    }
  }
  ll ans = 0;
  rep(i, h) {
    rep(j, w) {
      ans = max(ans, cnt[i][j] - 1);
    }
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 35712
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T,V> &x){cerr<<'{';__print(x.first);cerr<<',';__print(x.second);cerr<<'}';}
template<typename T>
void __print(const T &x){int f=0;cerr<<'{';for(auto &i:x)cerr<<(f++ ? "," : ""),__print(i);cerr<<"}";}
void _print(){cerr<<"]\n";}
template<typename T,typename... V>
void _print(T t, V... v) {__print(t);if(sizeof...(v))cerr<<", ";_print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define sz(x) (int)x.size()                         					
#define all(x) x.begin(), x.end()           		
#define lb lower_bound                  	
#define ub upper_bound             		
                                   	
typedef long long ll;           		
typedef pair<int, int> pii;     	
typedef pair<ll, ll> pll;       	
typedef long double ld;
          						
template<typename T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;    
template<typename T> void print(T x){cerr<<x<<'\n';}
inline ll bip(ll x,ll n,ll mod){ll res=1;while(n){if(n&1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}                 		
																															 
const int maxn = 1e9;
const ll inf = 1e18;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const int N = 1e7 + 10;

ll f[N];
bool prime[N];

void resheto(int n) {
	for (int i = 2; i <= n; i++)	
		if (prime[i] && i * 1ll * i <= n)
			for (int j = i * i; j <= n; j += i)
				prime[j] = 0;
}
							        	 	
void solve() {
	int n; cin >> n;

	for (int i = 1; i <= n; i++) f[i] = 1, prime[i] = 1;
	
	resheto(n);

	for (int i = 2; i <= n; i++) {
		if (prime[i]) {
			for (int j = i; j <= n; j += i) {
				int k = j, l = 0;
				while (k % i == 0) {
					k /= i;
					l++;
				}
				f[j] *= (l + 1);
			}
		}
	}
	ll ans = 0;
	for (int i = 1; i <= n; i++) ans += f[i] * i;
	cout << ans;
}
 
int main() {
    SpeedForce;
    int tt = 1;
    //cin >> tt;
    while (tt--) {
        solve();
        cout << '\n';
    }
}    

Measured memory_bytes: 91488
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define all(v) v.begin(),v.end()
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }

class Solver {
  public:
    bool solve() {
        int N; cin >> N;
        vector<ll> A(1 << N); cin >> A;

        vector<pii> g(1 << N);
        rep(k, g.size()) g[k] = pii(k, -1);

        auto f = [&] (pii a, pii b) {
            vector<int> x = {a.first, a.second, b.first, b.second};
            sort(all(x)); x.erase(unique(all(x)), x.end());
            sort(all(x), [&] (int i, int j) { return i >= 0 and j >= 0 ? A[i] > A[j] : i > j; });
            return pii(x[0], x[1]);
        };
        // ref: http://d.hatena.ne.jp/todo314/20120614/1339695202
        rep(i, N) {
            rep(s, 1 << N) { // s is K
                if(s & (1 << i)) {
                    g[s] = f(g[s], g[s^(1 << i)]);
                }
            }
        }

        auto sum = [&] (pii p) { assert(p.first >= 0 and p.second >= 0); return A[p.first] + A[p.second]; };
        ll ans = sum(g[1]);
        rep(i, (1 << N) - 1) {
            set_max(ans, sum(g[i + 1]));
            cout << ans << endl;
        }

        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 7168
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < n; ++i)
        cout << s[i] << t[i];
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt(),b=sc.nextInt();
		double f;
		f=1.0*a/b;
		System.out.println(a/b+" "+a%b+" "+String.format("%.6f", f));
	}
}


Measured memory_bytes: 26548
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int n;
  cin >> n;
  n = gcd(n, 360);
  cout << 360 / n << endl;
  return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int N, M; cin >> N >> M;
    vector<vector<int>> G(N);
    for (int i = 0; i < M; i++) {
        int a, b; cin >> a >> b; a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<bool> visited(N);
    function<int(int)> count = [&](int node) {
        if (visited[node]) return 0;
        visited[node] = true;
        int ans = 1;
        for (auto next : G[node]) ans += count(next);
        return ans;
    };
    auto f = [&](int node) {
        Int c = count(node);
        return c * (c-1) / 2 + (N-c) * (N-c-1) / 2 - M;
    };
    cout << max(f(0), f(1)) << endl;
    return 0;
}

Measured memory_bytes: 12032
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static Tuple<long[], string[]> Solve(int[][] P)
        {
            var C = new int[2];
            foreach (int[] p in P) { ++C[(p[0] + p[1]) & 1]; }
            if (C[0] != 0 && C[1] != 0) { return null; }
            int N = (C[0] == 0) ? 39 : 40;
            var S = new string[P.Length];
            for (int i = 0; i < S.Length; ++i)
            {
                var s = new char[N];
                long x = (N == 40) ? P[i][0] + 1 : P[i][0];
                long y = P[i][1];
                if (N == 40) { s[0] = 'L'; }
                for (int j = 38; j >= 0; --j)
                {
                    int k = j + N - 39;
                    if (Math.Abs(x) > Math.Abs(y))
                    {
                        if (x < 0)
                        {
                            s[k] = 'L';
                            x += 1L << j;
                        }
                        else
                        {
                            s[k] = 'R';
                            x -= 1L << j;
                        }
                    }
                    else
                    {
                        if (y < 0)
                        {
                            s[k] = 'D';
                            y += 1L << j;
                        }
                        else
                        {
                            s[k] = 'U';
                            y -= 1L << j;
                        }
                    }
                }
                Debug.Assert(x == 0 && y == 0);
                S[i] = new string(s);
            }
            var D = new List<long>();
            if (N == 40) { D.Add(1); }
            for (int i = 0; i < 39; ++i) { D.Add(1L << i); }
            return new Tuple<long[], string[]>(D.ToArray(), S);
        }
        static void Main(string[] args)
        {
            int N = ReadInt();
            var P = new int[N][];
            for (int i = 0; i < N; ++i) { P[i] = ReadInts(); }
            var ans = Solve(P);
            if (ans == null) { Console.WriteLine(-1); }
            else
            {
                Console.WriteLine(ans.Item1.Length);
                Console.WriteLine(string.Join(" ", ans.Item1));
                foreach (var s in ans.Item2) { Console.WriteLine(s); }
            }
        }
    }
}


Measured memory_bytes: 13500
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

bool G[101][101];

void solve(int N,int K) {
    int M=(N-1);

    //init
    for(int i = 2;i <= N;i++) {
        G[1][i] = 1;
        G[i][1] = 1;
    }

    vector<pair<int,int> >next;
    for(int i = 2;i < N;i++) {
        for(int j = i+1;j <= N;j++) {
            next.push_back(make_pair(i,j));
        }
    }

    int s = 0;
    for(int i = ((N-1)*(N-2))/2-K;i > 0;i--) {
        pair<int,int> ij;
        ij = next[s++];
        G[ij.first][ij.second] = 1;
        G[ij.second][ij.first] = 1;
        M++;
    }

    cout<<M<<endl;

    for(int i = 1;i < N;i++) {
        for(int j = i+1;j <= N;j++) {
            if(G[i][j]) {
                cout<<i<<" "<<j<<endl;
            }
        }
    }

    return;
}
int main(void) {
    int N,K;
    cin>>N>>K;

    if(K > ((N-1)*(N-2))/2) {
        cout<<-1<<endl;

        return 0;
    }

    solve(N,K);

    return 0;
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define forr(i,a,b) for(int i=a;i<b;i++)
#define eb emplace_back
#define mp make_pair
typedef long long int lli;
typedef unsigned long long int ulli;
const int INF=INT_MAX;
const lli MOD=10e8+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    std::cout.precision(30);
	int n;cin>>n;
	vector<double> dp(n+2);//where dp[i]=(probablity of i heads)
	dp[0]=1;
	forr(i,0,n)
	{
		double p;cin>>p;
		for(int k=i+1;k>=0;k--)		///we do this to avoid repition
		{
			dp[k]=dp[k-1]*p+dp[k]*(1-p);	//each coin either adds up or it does not
		}
	}
	
	double sum=0;
	for(int i=n/2+1;i<n+1;i++)	sum+=dp[i];
	cout<<sum<<endl;
	
    return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::min;
fn main() {
    input!{
        s: chars,
    }
    let mut s = s;
    s.sort();
    println!("{}", if s.iter().fold(String::new(), |acc, c| acc+&c.to_string()) == "abc".to_string() {"Yes"} else {"No"});
}


Measured memory_bytes: 4352
N = int(input())
# sはそれぞれ10文字
s = [str(sorted(input())) for i in range(N)]

# 組み合わせ総数
ans = 0
# 既に見た文字列 : 累計出現回数
cnt = {}

for i in range(N):
    # 既に見た文字列の場合
    if s[i] in cnt:
        ans += cnt[s[i]]
        cnt[s[i]] += 1
    # 始めて見る文字列
    # 辞書に1を入れておく
    else:
        cnt[s[i]] = 1

print(ans)


Measured memory_bytes: 28588
#include <bits/stdc++.h>
using namespace std;
int ct[10][10];
int getfirstdigit(int x){
    while (x >= 10) x /= 10;
    return x;
}
int main(){
    int n;
    scanf("%d",&n);
    for (int i = 0; i <= n; i++){
        ct[getfirstdigit(i)][i%10]++;
    }
    int ans = 0;
    for (int i = 0; i < 10; i++){
        for (int j = 0; j < 10; j++){
            ans += ct[i][j]*ct[j][i];
        }
    }
    printf("%d",ans-1);


}


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

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll x=n/(a+b)*a;
  ll y=n%(a+b);
  if (y>=a) cout << x+a << endl;
  else cout << x+y << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int a, b, c;
  cin >> a >> b >> c;
  auto swap = [](int& x, int& y) {
    auto z = x;
    x = y;
    y = z;
  };
  if (a > b) {
    swap(a, b);
  }
  if (b > c) {
    swap(b, c);
  }
  if (a > b) {
    swap(a, b);
  }
  cout << a << ' ' << b << ' ' << c << endl;
  return 0;
}


Measured memory_bytes: 3092
n = int(raw_input())
a = []
for i in range(n):
	a.append(int(raw_input()))

num = 1
count = 0

for i in range(n):
	num = a[num-1]
	count += 1
	if num == 2:
		break
	elif i == n - 1:
		count = -1

print count

Measured memory_bytes: 8964
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n, k = 1, a, ans;
signed main() {
	cin >> n;
	while (n--) {
		cin >> a;
		if (k == a)k++;
		else ans += (a - 1) / k;
		if (k == 1)k++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<utility>
 
using namespace std;
 
const int MAX=10000;
typedef pair<int,int> P;
 
int n;
vector<P> G[MAX];
int dph[MAX][MAX];//vertex number, edge number
int h[MAX];
 
int dfs(int u,int e)
{
    if(dph[u][e]>=0)return dph[u][e];
    dph[u][e]=G[u][e].second;
    int v=G[u][e].first;
     
    for(int i=0;i<G[v].size();i++)
    {
        if(G[v][i].first==u)continue;
        dph[u][e]=max(dph[u][e],dfs(v,i)+G[u][e].second);
    }
     
    return dph[u][e];
}
 
void getheight()
{
    for(int i=0;i<n;i++)
    {
        h[i]=0;
        for(int j=0;j<G[i].size();j++)
        {
            dph[i][j]=-1;
        }
    }
     
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<G[i].size();j++)
        {
            if(dph[i][j]<0)dph[i][j]=dfs(i,j);
        }
    }
     
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<G[i].size();j++)
        {
            h[i]=max(h[i],dph[i][j]);
        }
    }
     
    return;
}
 
int main()
{
    cin>>n;
    int u,v,s;
    for(int i=0;i<n-1;i++)
    {
        cin>>u>>v>>s;
        G[u].push_back(P(v,s));
        G[v].push_back(P(u,s));
    }
     
    getheight();
     
    for(int i=0;i<n;i++)cout<<h[i]<<endl;
     
    return 0;
}


Measured memory_bytes: 44620
#include<stdio.h>

int main(){
	int dishes[5];
	for(int i=0; i<5; i++){
		scanf("%d", &dishes[i]);
	}
	int min=124, count=0;
	for(int i=0; i<5; i++){
		if(dishes[i]%10 == 0) count++;
		else if(dishes[i]%10 < min){
			min= dishes[i]%10;
		}
	}
	int time=0;
	for(int i=0; i<5; i++){
		if(dishes[i]%10 == 0) time += dishes[i];
		else time += (dishes[i]/10)*10+10;
	}
	if(count != 5) time -= 10-min;
	printf("%d",time);
	
	return 0;
}

Measured memory_bytes: 128
package main

import "os"
import "fmt"
import "bufio"
import "strconv"

func main() {
    var sc = bufio.NewScanner(os.Stdin)
    sc.Split(bufio.ScanWords)
    sc.Scan()
    n, _ := strconv.Atoi(sc.Text())
    f := fn(n)
    if n == (n / f * f) {
        fmt.Printf("Yes\n")
    } else {
        fmt.Printf("No\n")
    }
}

func fn(v int) int {
    r := 0
    for i := 0; v >= 10; i++ {
        r = r + (v - (v / 10 * 10))
        v = v / 10
    }
    r = r + v
    return r
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {


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

		int a = n/2;
		int b = n%2;

		int k = a * (a+b);
		System.out.println(k);
	}
}


Measured memory_bytes: 22740