akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    ll n, x, m;
    cin >> n >> x >> m;
    vector<int> id(m, -1);
    vector<int> a;
    int len = 0;
    ll tot = 0;
    while (id[x] == -1) {
        a.push_back(x);
        id[x] = len;
        len++;
        tot += x;
        x = (x*x)%m;
    }

    int c = len-id[x];
    ll s = 0;
    for (int i = id[x]; i < len; i++) s += a[i];

    ll ans = 0;
    if (n <= len) {
        rep(i,n) ans += a[i];
    }
    else {
        ans += tot;
        n -= len;
        ans += s*(n/c);
        n %= c;
        rep(i,n) ans += a[id[x]+i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4060
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
    int k,n; cin >> k >> n;
    int a[200005];
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a,a+n);
    int ans = 1001001001;
    for(int i=0;i<n;i++){
        if(i == 0){
            ans = min(ans, k-abs(k+a[i]-a[n-1]));
        }else{
            ans = min(ans, k-abs(a[i]-a[i-1]));
        }

        if(i == n-1){
            ans = min(ans, k-abs(k+a[0]-a[i]));
        }else{
            ans = min(ans, k - abs(a[i+1]-a[i]));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
n = gets.chomp.to_i
t = gets.chomp.split(' ').map {|v| v.to_i}
t.unshift(0)
t.push(0)

ot = Array.new(t.length, 0)

all = 0
for i in 1...t.length do
  v = t[i] - t[i - 1]
  ot[i] = v
  all += v.abs
end

for i in 1...t.length - 1 do
  f = all - ot[i].abs - ot[i + 1].abs
  v = t[i + 1] - t[i - 1]
  f += v.abs

  puts f
end




Measured memory_bytes: 13452
#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, m;
  cin >> n >> m;
  vector<int> v(n, 0);
  rep(i, 0, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    v[a]++;
    v[b]++;
  }

  rep(i, 0, n) cout << v[i] << endl;
}


Measured memory_bytes: 256
# 2019-11-18 17:34:23(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
# import numpy as np 


def main():
    n, s = sys.stdin.read().split()
    n = int(n)

    res = 0
    l, r = 0, 1
    while r <= l + (n - l) // 2:
        t = s[l:r]
        if t in s[r:]:
            res = max(res, r - l)
            r += 1
        else:
            l += 1
            if l == r:
                r += 1
    print(res)

if __name__ == "__main__":
    main()

# しゃくとり法的なやつ

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

long long enc(string s){
	string table = "0123456789abcdef";
	long long ans = 0;
	for(int i = 0 ; i < s.size() ; i++){
		ans = ans * 16 + table.find(s[i]);
	}
	return ans;
}
string dec(long long n){
	if( n == 0 ) return "0";
	string table = "0123456789abcdef";
	string ans = "";
	while(n){
		ans = table[n%16] + ans;
		n /= 16;
	}
	return ans;
}

/*
	1 1 1 1 1 1 1 1 8
	001
	001
	001
	001
	001
	001
	001
	001
	100
	
	048
	100
	
*/

int main(){
	int n,m;
	cin >> n;
	while(n--){
		vector<long long> d;
		for(int i = 0 ; i < 9 ; i++){
			string s;
			cin >> s;
			d.push_back(enc(s));
		}
		long long ans = 0;
		int carry = 0;
		for(int i = 0 ; i < 32 ; i++){
			int c = 0;
			int lastBit = (d[8] >> i & 1);
			for(int j = 0 ; j < 8 ; j++){
				c += (d[j] >> i & 1);
			}
			int tmp = 0;
			if( ((c+carry)&1)^lastBit){
				ans += (1ll << i);
				tmp = 8 - c;
			}else{
				tmp = c;
			}
			carry = (tmp + carry) / 2;
		}
		cout << dec(ans) << endl;
	}
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  int N;
  cin >> N;
  rep(i, N) {
    int temp;
    cin >> temp;
    if(temp % 2 == 0) {
      if(temp % 3 != 0 && temp % 5 != 0) {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}

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

template <class T> void chmin(T& a, const T b){a=min(a,b);}

int main(){
	string s;
	cin >> s;
	
	reverse(s.begin(),s.end());
	s += '0';
	int dp[s.size()+1][2];
	
	const unsigned long long int inf = 1000000000;
	for(int i=0;i<s.size()+1;++i){
		dp[i][0] = dp[i][1] = inf; 
	}
	//cout << s << endl;
	dp[0][0] = 0;
	for(int i=1;i<s.size()+1;++i){
		int tmp = s[i-1] - '0';
		chmin(dp[i][0],dp[i-1][0] + tmp);
		chmin(dp[i][0],dp[i-1][1] + tmp + 1);
		chmin(dp[i][1],dp[i-1][0] + 10 - tmp);
		chmin(dp[i][1],dp[i-1][1] + 10 - tmp -1);
		//cout <<tmp << " " << dp[i][0] << " " << dp[i][1] << " " << dp[i-1][0] + 10 - tmp << " " <<  dp[i-1][1] + 10 - tmp -1<<endl;		
	}
	
	
	cout << min(dp[s.size()][0],dp[s.size()][1]) <<endl;
	
	return 0;
}




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

using namespace std;
void insertion_sort(vector<int>& objective_array,int len_array){
    for(int i = 1;i < len_array;i++){
        int v = objective_array[i];
        int j = i-1;
        while(j>=0 && objective_array[j] > v){
            objective_array[j+1] = objective_array[j];
            j--;
        }
        objective_array[j+1] = v;
        for (int k =0; k < len_array; k++){
            cout << objective_array[k];
            if(k<len_array-1) cout << " ";
        }
        cout << "\n";
    }
}

int main(){
    int len_array;
    cin >> len_array;
    vector<int> objective_array(len_array,0);
    for(int i = 0;i < len_array;i++){
        cin >> objective_array[i];
        cout << objective_array[i];
        if(i < len_array-1) cout << " ";
    }
    cout << "\n";
    insertion_sort(objective_array,len_array);

    return 0;   
}



Measured memory_bytes: 3092
/***

    Muammad Imdad-Ul-Haque Rakib(Attari)
    CSE'19
    Chittagong,Bangladesh

***/


#include<bits/stdc++.h>


/**Definitions**/

#define               ek               first
#define               dui              second
#define               ld               long double
#define               ll               long long
#define               boost_           ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define               pb               push_back
#define               ppb              pop_back
#define               ull              unsigned long long
#define               over             return 0
#define               scan(i,n,a)      for(i=0;i<n;i++) cin>>a[i]
#define               MP               make_pair
#define               spc              " "
#define               Yes              cout<<"Yes"<<endl
#define               YES              cout<<"YES"<<endl
#define               yes              cout<<"yes"<<endl
#define               No               cout<<"No"<<endl
#define               NO               cout<<"NO"<<endl
#define               no               cout<<"no"<<endl
#define               loop(i,n)        for(i=0;i<n;++i)

using namespace std;


/** User-defined Functions **/


ll gcd(ll x,ll y){
    if(x==0) return y;
    else return gcd(y%x,x);
}
bool sortbysec(const pair<int,int>&a, const pair<int,int>&b){ return (a.second<b.second); }
bool sortbysecinrev(const pair<int,int>&a, const pair<int,int>&b){ return (a.second>b.second); }
bool sortbysize(string &s1,string &s2){ return s1.size() < s2.size(); }
bool sortinrev(const pair<int,int> &a, const pair<int,int> &b){ return (a.first > b.first); }



/** Main Function **/


int main(){

    boost_;

    int n;
    cin>>n;
    if(n%1000) cout<<1000-n%1000<<endl;
    else cout<<0<<endl;
    over;
}


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

using namespace std;

const int maxn = 1000010;

int n, m, K, X[maxn<<1], Y[maxn<<1], sta[maxn<<1], top;
char buf[maxn];

void print(int *a) {
    int ok = 0;
    for (int i = 2000000; i >= 1; i--) {
        if (a[i]) ok = 1;
        if (ok) printf("%d", a[i]);
    }
    puts("");
}

int main() {
    scanf("%d%d%d", &n, &m, &K);
    scanf("%s", buf+1); for (int i = 1; i <= n; i++) X[n-i+1] = (buf[i] == '1');
    scanf("%s", buf+1); for (int i = 1; i <= m; i++) Y[m-i+1] = (buf[i] == '1');
    sta[++ top] = 0x3f3f3f3f;
    for (int i = max(n, m); i >= 1; i--) {
        if (X[i] && Y[i]) {
            X[i] = Y[i] = 0;
            int k = K, cur_p = i;
            stack<int> st; // cur_p 经过的 0 1
            while (cur_p && cur_p + k >= sta[top]) {
                int c = sta[top] - cur_p;
                cur_p = sta[top];
                k -= c;
                -- top;
                int add = 1, ty = 0;
                if (X[cur_p]) {
                    X[cur_p] = 0;
                    Y[cur_p] = 1;
                    ty = 1;
                } else {
                    X[cur_p] = 1;
                    Y[cur_p] = 0;
                    ty = 2;
                }
                st.push(cur_p);
                while (add) {
                    ++ cur_p;
                    if (X[cur_p] || Y[cur_p]) {
                        // 不会同时为 1
                        -- top;
                        if (X[cur_p]) {
                            if (ty == 1) {
                                add = 1;
                                X[cur_p] = 0;
                            } else {
                                add = 0;
                                X[cur_p] = 0;
                                // Y[cur_p] = 1;
                            }
                        } else {
                            if (ty == 2) {
                                add = 1;
                                Y[cur_p] = 0;
                            } else {
                                add = 0;
                                Y[cur_p] = 0;
                                // X[cur_p] = 1;
                            }
                        }
                    } else {
                        add = 0;
                        if (ty == 1) X[cur_p] = 1;
                        else Y[cur_p] = 1;
                        st.push(cur_p);
                        cur_p = 0;
                    }
                }
            }
            while (!st.empty()) {sta[++top] = st.top(); st.pop();}
            if (cur_p) {
                X[cur_p+k] = Y[cur_p+k] = 1;
            }
        } else if (X[i] || Y[i]) sta[++ top] = i;
    }
    print(X);
    print(Y);
    return 0;
}

Measured memory_bytes: 20480
N = int(input())
count = 0

c = [[0 for i in range(10)]for j in range(10)]

for i in range(1,N+1):
    str_i = str(i)
    c[int(str_i[0])][int(str_i[-1])] += 1

for j in range(10):
    for k in range(10):
        count += c[j][k] * c[k][j]

print(count)




Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int a, b;
    char c;
    cin >> a >> c >> b;
    if(c=='+') cout << a+b << endl;
    else cout << a-b << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int root[10010];
int rank[10010];

void init(int n){
	REP(i,n){
		root[i]=i;
		rank[i]=0;
	}
}

int find(int x){
	if(root[x]==x) return x;
	else return root[x]=find(root[x]);
}

void unite(int x,int y){
	x=find(x); y=find(y);
	if(x==y) return;
	if(rank[x]<rank[y]){
		root[x]=y;
	}else{
		root[y]=x;
		if(rank[x]==rank[y]) rank[x]++;
	}
}

bool same(int x,int y){
	return find(x)==find(y);
}

int main(void){
	int i;

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

	int n,q;
	cin >> n >> q;
	init(n);
	for(i=0;i<q;i++){
		int c,x,y;
		cin >> c >> x >> y;
		if(c==0) unite(x,y);
		else cout << same(x,y) << endl;
	}

	return 0;
}

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

int main() {
    long t, ans;
    for(int i = 0; i < 5; i++){
        cin >> t;
        if(t == 0){
            ans = i + 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3564
N,*as=$<.read.split.map(&:to_i)
MOD=10**9+7

h=Hash.new(0)
as.each do |a|
    h[a] += 1
end

if h[0] == 1
    h[0] = 2
    if h.all? {|k,v| k.even? && v == 2 }
        puts 2 ** (h.size - 1) % MOD
        exit 0
    end
elsif h.all? {|k,v| k.odd? && v == 2 }
    puts 2 ** h.size % MOD
    exit 0
end

puts 0

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int A, B;
    cin >> A >> B;
    int ans = max({A+B, A-B, A*B});
    print(ans);
}

signed main() {
    solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
long long sum=0;

int main()
{
    long long H;
    cin >> H;
    long long Count=0;
    while(H!=0)
    {
        H/=2;
        Count++;
    }
    for(long long i=0;i<Count;i++)
        sum+=pow(2,i);
    cout << sum <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll A, B, ans;
    scanf("%lld %lld", &A, &B);
    ll Base = 0;
    if ( A < B ){
        REP(int,i,0,B-1){
            Base += 1;
            Base *= 10;
        }
        Base += 1;
        ans = Base * A;
    }
    else{
        REP(int,i,0,A-1){
            Base += 1;
            Base *= 10;
        }
        Base += 1;
        ans = Base * B;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef priority_queue<int> Pr; typedef vector<int> V; typedef vector<P> Vp; typedef map<int,int> MP;
const int mod = 1000000007; const Int INF = 1145141919810893931;
#define END {cout<<ans<<'\n'; return 0;}
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<int MOD>
struct ModInt {
	static const int Mod = MOD;
	unsigned x;
	ModInt() : x(0) {}
	ModInt(signed sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; }
	ModInt(signed long long sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	ModInt &operator+=(ModInt that) { if((x += that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator-=(ModInt that) { if((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
	ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }

	ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
	ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
	ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }

	ModInt inverse() const {
		signed a = x, b = MOD, u = 1, v = 0;
		while(b) {
			signed t = a / b;
			a -= t * b; std::swap(a, b);
			u -= t * v; std::swap(u, v);
		}
		if(u < 0) u += Mod;
		ModInt res; res.x = (unsigned)u;
		return res;
	}

	bool operator==(ModInt that) const { return x == that.x; }
	bool operator!=(ModInt that) const { return x != that.x; }
	ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
	ModInt<MOD> r = 1;
	while(k) {
		if(k & 1) r *= a;
		a *= a;
		k >>= 1;
	}
	return r;
}
typedef ModInt<mod> mint;

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

  int n; cin>>n; string s; cin>>s; mint ans=1; int a[26]={};
  for (int i = 0; i < n; i++)a[s[i]-'a']++;
  for (int i = 0; i < 26; i++)if(a[i])ans*=a[i]+1;
  cout<<(ans-1).get()<<'\n';
}

Measured memory_bytes: 512
#include <stdio.h>


int main() {
	int A, B, max;
	scanf("%d %d", &A, &B);
	max = A + B;
	if (max < A - B) {
		max = A - B;
	}
	if (max < A*B) {
		max = A*B;
	}

	printf("%d\n", max);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k, x;
  cin >> k >> x;
  for (int i = 0; i < 2*k-1; i++)
    if (-2000000 <= x-k+1+i && x-k+1+i <= 2000000)
      cout << x-k+1+i << " ";
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(x) (int)((x).size())
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define FOR(i, a, n, step) for (int (i) = (a); (i) < (int)(n); (i) += (step))
#define ROF(i, a, n, step) for (int (i) = (a); (i) >= (int)(n); (i) -= (step))
#define FOREACH(it, v) for (auto (it) : (v))

using namespace std;

typedef unsigned long long ull;
typedef long long ll ;
typedef long double ld;
typedef pair <int, int> pii;

template <class T>
const bool is_impar(const T &x) {return (bool) (x & 1);}

int X[105], Y[105], H[105], a[105][105];
int n, h, hmax, xmax, ymax;

bool check(int xstart, int ystart) {
    h = hmax + abs(xstart - xmax) + abs(ystart - ymax);
    FOR (i, 0, 101, 1)
        FOR (i1, 0, 101, 1)
            if (a[i][i1] != -1 && max(h - abs(xstart - i) - abs(ystart - i1), 0) != a[i][i1])
                return false;
    return true;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    memset(a, -1, sizeof a);
    FOR (i, 1, n + 1, 1) {
        cin >> X[i] >> Y[i] >> H[i];
        if (H[i] > hmax)
            hmax = H[i],
            xmax = X[i],
            ymax = Y[i];
        a[X[i]][Y[i]] = H[i];
    }
    FOR (i, 0, 101, 1)
        FOR (i1, 0, 101, 1)
            if (check(i, i1))
                return !(cout << i << ' ' << i1 << ' ' << h);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}
ll ebob(ll a, ll b){
	if(!a)return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (a*b)/ebob(a, b);
}
double fonk(double x, double y){
	return x*x + y*y;
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int a, b; cin>>a>>b;
	int l = 0, r = 1e6;
	while(l < r){
		int mid = (l+r)/2;
		if(mid * 2 / 25 >= a && mid / 10 >= b) r = mid;
		else l = mid+1;
	}
	if(l * 2 / 25 != a || l / 10 != b) cout<<-1;
	else cout<<l;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	ios::sync_with_stdio(false);
	long long x,y,d;
	long long n,sum=0;
	cin>>n>>d;
	for(int i=0;i<n;++i)
	{
		cin>>x>>y;
		if(x*x+y*y<=d*d)
		sum++;
	}
	cout<<sum<<'\n';
} 

Measured memory_bytes: 3684
import Data.Char (digitToInt)

f :: [Int] -> (Int, Int)
f [] = (0, 1)
f (x:xs)
  | x == 9    = (a + x, min (a + 1) b)
  | otherwise = (min (a + x) (b + x + 1), min (a + 10 - x) (b + 10 - (x + 1)))
  where (a, b) = f xs

main = do
  n <- map digitToInt <$> getLine :: IO [Int]
  let (a, b) = f n
  print $ min a (b + 1)

Measured memory_bytes: 178556
#include<stdio.h>

int main(void){
  int n,a[10][10];
  int sum_line[10],sum_row[10],sum_all;
  while(1){
    scanf("%d",&n);
    if(n==0) break;

    for(int i=0;i<10;i++){
      sum_line[i]=0;    sum_row[i]=0;
    }
    sum_all=0;

    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        scanf("%d",&a[i][j]);
        sum_line[i]+=a[i][j];
        sum_row[j]+=a[i][j];
        sum_all+=a[i][j];
      }
    }

    for(int i=0;i<=n;i++){
      for(int j=0;j<=n;j++){
        if(i==n && j==n)printf("%5d",sum_all);
        else if(i==n && j!=n)printf("%5d",sum_row[j]);
        else if(i!=n && j==n)printf("%5d",sum_line[i]);
        else printf("%5d",a[i][j]);
      }
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 1996
#include<bits/stdc++.h>
using namespace std;
#define Mod(n) n % 1000000007
const int dx[8] = {1, 0, -1, 0, -1, 1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};


int main()
{
    string X;
    cin >> X;
    X.pop_back();
    if(X.size() % 2 == 1)
            X.pop_back();
    
    for(int i = 0;;i++)
    {
        if(X.substr(0,X.size()/2) == X.substr(X.size()/2))
        {
            cout << X.size() << '\n';
            return 0;
        }
        X.pop_back();
        X.pop_back();
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
char S[5] , T[5];

int main(){
    int Ans = 0 , i;
    scanf( "%s%s" , S , T );

    for( i = 0 ; i < 3 ; ++i ){
        if( S[i] == T[i] ) ++Ans;
    }

    printf( "%d\n" , Ans );
    return 0;
}

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

int main() {
    char b;
    cin >> b;
    if (b == 'A') {
        cout << "T" << endl;
    } else if (b == 'C') {
        cout << "G" << endl;
    } else if (b == 'G') {
        cout << "C" << endl;
    } else if (b == 'T') {
        cout << "A" << endl;
    }
    return 0;
}


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int mx = max(A,max(B,max(C,D)));
  int mn = min(A,min(B,min(C,D)));
  cout << max((B-A)+(D-C)-(mx - mn),0) << endl;
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        s:chars,
    }
    let mut red = 0;
    let mut blue = 0;
    for i in 0..s.len() {
        match s[i] {
            '0' => red+=1,
            '1' => blue+=1,
            _ => unreachable!()
        }
    }
    let min = std::cmp::min(red, blue);
    let ans = min*2;
    println!("{}", ans);

}

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

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n;
  string s;

  cin >> n >> s;

  int left = 0;
  int ans = 0;
  REP(i,(int)s.length()){
    if(s[i] == ')'){
      if(left == 0){
        s.insert(0, "(");
        i++;
      }else{
        left--;
      }
    }else{
      left++;
    }
  }

  ans += left;
  REP(i,left){
    s = s + ')';
  }

  cout << s << "\n";

  return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



int popcount32(unsigned int x) {
	x = x - ((x >> 1) & 0x55555555);
	x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
	x = (x + (x >> 4)) & 0x0F0F0F0F;
	x = x + (x >> 8);
	x = x + (x >> 16);
	return x & 0x0000003F;
}

int n;
int a[15];
int x[15][15];
int y[15][15];


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

	cin >> n;
	rep(i,n) {
		cin >> a[i];
		rep(j, a[i]) {
			cin >> x[i][j] >> y[i][j];
			x[i][j]--;
		}
	}
	
	int ans = 0;
	rep(h,1<<n) {
		bool ok = true;

		rep(i,n) {
			if (h >> i & 1) {
				rep(j, a[i]) {
					if ((h >> x[i][j] & 1) != y[i][j]) {
						ok = false;
					}
				}
			}
		}

		if(ok) ans = max(ans, popcount32(h));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.math.BigDecimal

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toBigDecimal() }

    if (BigDecimal(0) in a) {
        println(0)
        return
    }

    var answer = a[0]
    val upper = BigDecimal(10).pow(18)
    for (i in 1 until n) {
        answer *= a[i]
        if (answer > upper) {
            answer = BigDecimal(-1)
            break
        }
    }

    println(answer)
}


Measured memory_bytes: 65836
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        double[] x = new double[n];
        double[] y = new double[n];

        for(int i = 0;i < n;i++){
            x[i] = sc.nextDouble(); 
        }

        for(int i = 0;i < n;i++){
            y[i] = sc.nextDouble(); 
        }

        double tmp,d = 0;
        //p = 1
        for(int i = 0;i < n;i++){
            if(x[i] - y[i] < 0) tmp = -(x[i] - y[i]);
            else    tmp = x[i] - y[i];
            d += tmp;
        }
        System.out.printf("%.8f\n",d);
        //p = 2
        d = 0;
        for(int i = 0;i < n;i++){  
            d += (x[i] - y[i]) * (x[i] - y[i]);
        }
        System.out.printf("%.8f\n",Math.sqrt(d));
        //p = 3
        d = 0;
        for(int i = 0;i < n;i++){
            if(x[i] - y[i] < 0) tmp = -(x[i] - y[i]);
            else    tmp = x[i] - y[i];
            d += (tmp * tmp * tmp);
        }
        System.out.printf("%.8f\n",Math.cbrt(d));
        //p = ∞
        double max = Double.MIN_VALUE;
        for(int i = 0;i < n;i++){
            if(i == 0){
                max = x[i] - y[i];
                if(max < 0) max = -max;
            }
            else{
                tmp = x[i] - y[i];
                if(tmp < 0) tmp = -tmp;
                if(tmp > max)   max = tmp;
            }
        }
        System.out.printf("%.8f\n",max);


    }
}


Measured memory_bytes: 29144
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>

typedef long long ll;

using namespace std;

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


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

typedef long long ll;

int main()
{
    int i;
    int n;
    cin >> n;
    set<int> a;
    int b;
    for(i = 0;i < n;++i){
        cin >> b;
        a.insert(b);
    }
    if(a.size() != n){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
    return 0;
}

Measured memory_bytes: 9600
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    H, W = MAP()
    C = [LIST() for _ in range(10)]
    A = [LIST() for _ in range(H)]

    for k in range(10):
        for i in range(10):
            for j in range(10):
                C[i][j] = min(C[i][j], C[i][k] + C[k][j])

    ans = 0
    for h in range(H):
        for w in range(W):
            if A[h][w] != -1:
                ans += C[A[h][w]][1]

    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
    string s;
    cin >> s;
    int counter = 700;
    if (s[0] == 'o') counter+=100;
    if (s[1] == 'o') counter+=100;
    if (s[2] == 'o') counter+=100;
    cout << counter << endl;
}

Measured memory_bytes: 256
N = int(input())
X = sorted(map(int, input().split()))

ans = 10 ** 9
for P in range(X[0], X[N - 1] + 1):
  cons_pow = sum(map(lambda x: pow(x - P, 2), X))
  if cons_pow < ans:
    ans = cons_pow
    
print(ans)

Measured memory_bytes: 9116
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
using namespace std;
int main() {
	long long n, k, num=0;
	cin >> n >> k;
	vector<int>vec(n);
	vector<int>vis(n+1, 0);
	vector<int>pos(n+1, 0);
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		vec[i] = a - 1;
	}
	int p = 0;
	do {
		if (num == k) {
			cout << p + 1<< endl;
			return 0;
		}
		vis[p] = num;
		num++;
		p = vec[p];
		pos[num] = p;
		if (p == 0) {
			cout << pos[k % num]+1 << endl;
			return 0;
		}
	} while (!vis[p]);
	k -= vis[p];
	k %= num - vis[p];
	num = 0;
	while (k--) {
		p = vec[p];
	}
	cout << p + 1 << endl;
	return 0;
}

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

typedef long long ll;

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

ll a2, a1, b2, b1;

void step1(){
  // 相手をできるだけ減らさない
  ll pls = a2 + a1;
  ll sb = min(b2, pls);
  pls -= sb;
  b2 -= sb;
  b1 += sb;
  sb = min(b1, pls);
  pls -= sb;
  b1 -= sb;
  swap(a1,b1);swap(a2,b2);
}
void step2(){
  // 相手をできるだけ減らす
  ll pls = a2 + a1;
  if(pls>0 && b1>0){
    b1--;pls--;
  }
  ll sb = min(b2, pls/2);
  pls -= sb*2;
  b2 -= sb;
  if(pls>0 && b2>0){
    pls--;
    b2--;
    b1++;
  }
  swap(a1,b1);swap(a2,b2);
}

int main(){
  ll n,m;
  cin>>n>>m;
  ll ans = max(n,m)*2ll;
  {
    a2=n,a1=0,b2=m,b1=0;
    ll tmp = 0;
    while(true){
      step1();
      if(a1+a2==0)break;
      tmp++;
      step2();
      if(a1+a2==0)break;
      tmp++;
    }
    ans = min(ans,tmp);
  }
  {
    a2=n,a1=0,b2=m,b1=0;
    ll tmp = 0;
    while(true){
      step2();
      if(a1+a2==0)break;
      tmp++;
      step1();
      if(a1+a2==0)break;
      tmp++;
    }
    ans = min(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>

using namespace std;

const int INF = 1000000001;
const int MAX = 500000;
int cnt;
int S[MAX] = {0}, L[1 + MAX/2] = {0}, R[1 + MAX/2] = {0};


void merge(int* A,int left,int mid,int right)
{
	int n1,n2,n,i,j;
	n1 = mid - left;
	n2 = right - mid;

	for(int i = 0; i < n1; i++)
	{
		L[i] = A[left + i];
	}
	for(int i = 0; i < n2; i++)
	{
		R[i] = A[mid + i];
	}

	L[n1] = INF;
	R[n2] = INF;

	i = 0;
	j = 0;

	for(int k = 0; k < right - left; k++)
	{
		if (L[i] <= R[j] )
		{
			A[left + k] = L[i];
			i++;
		}else
		{
			A[left + k] = R[j];
			j++;
		}

		cnt++;
	}
}


void mergesort(int* A,int left,int right)
{
	int mid;

	if(left + 1 < right)
	{
		mid = (left + right) / 2;
		mergesort(A,left,mid);
		mergesort(A,mid,right);
		merge(A,left,mid,right);
	}
}

int main()
{
	int N;
	cnt = 0;

	cin >> N;

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

	mergesort(S,0,N);

	for(int i = 0; i < N; i++)
	{
		if (i == N-1)
		{
			cout << S[i] <<endl;
		}else
		{
			cout << S[i] << " ";
		}
	}

	cout << cnt << endl;

	return 0;
}
	

Measured memory_bytes: 6992
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)
 
struct UnionFind {
	vector<int>Par, Rank;
	UnionFind(int n) {
		Par.resize(n);
		Rank.resize(n);
		for (int i = 0; i < n; i++) {
			Par[i] = i;
			Rank[i] = 0;
		}
	}
 
	int find(int x) {
		if (Par[x] == x) {
			return x;
		}
		else {
			return Par[x] = find(Par[x]);
		}
	}
 
	void unite(int  x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (Rank[x] < Rank[y]) {
			Par[x] = y;
		}
		else {
			Par[y] = x;
			if (Rank[x] == Rank[y])Rank[x]++;
		}
	}
 
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};
 
int n, k, l;
int p, q;
 
int main() {
	cin >> n >> k >> l;
	UnionFind uf(n * 2+120);
	REP(i, k) {
		cin >> p >> q;
		p--, q--;
		uf.unite(p, q);
	}
	REP(i, l) {
		cin >> p >> q;
		p--, q--;
		uf.unite(n + p, n + q);
	}
	vector<pair<int, int>> pa;
	map<pair<int, int>,int> mp;
	REP(i, n) {
		pa.emplace_back(make_pair(uf.find(i), uf.find(n + i)));
	}
 	REP(i, n) {
		mp[pa[i]]++;
	}
	REP(i, n) {
		if (i)cout << " ";
		cout << mp[pa[i]];
	}
	cout << endl;
	//system("pause");
}

Measured memory_bytes: 16624
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

void replace( string &s, char src, char dst ) {
    replace( s.begin(), s.end(), src, dst ); 
}

void reverse( string &s ) {
    reverse( s.begin(), s.end() );
}

string add( string a, string b ) {
    reverse( a );
    reverse( b );
    if ( a.size() < b.size() ) swap( a, b );
    int n = min( a.size(), b.size() );
    a += '0';
    b += '0';
    for ( int i = 0; i < n; ++ i ) {
        int na = a[i] - '0';
        int nb = b[i] - '0';
        int nc = ( na + nb ) % 10;
        a[i] = nc + '0';
        if ( na + nb >= 10 ) {
            int t = i + 1;
            a[t] ++;
            while ( a[t] > '9' ) {
                a[t] = '0';
                t ++;
                a[t] ++;
            }
        }
    }
    reverse( a );
    
    int m = a.size();
    string t;
    bool f = false;
    for ( int i = 0; i < m; ++ i ) {
        if ( a[i] != '0' ) {
            f = true;
        }
        if ( f ) {
            t += a[i];
        }
    }
    if ( t == "" ) t = "0";
    return t;
}

bool check( string a, string b, string c ) {
    return add( a, b ) == c;
}

void solve( string A, string B, string C ) {
    for ( char i = '0'; i <= '9'; ++ i ) {
        if ( i == '0' ) {
            if ( ( A.size() > 1 && A[0] == 'X' ) ||
                 ( B.size() > 1 && B[0] == 'X' ) ||
                 ( C.size() > 1 && C[0] == 'X' ) ) continue;
        }
        string a = A;
        string b = B;
        string c = C;
        replace( a, 'X', i );
        replace( b, 'X', i );
        replace( c, 'X', i );
        if ( check( a, b, c ) ) {
            cout << i << endl;
            return;
        }
    }
    cout << "NA" << endl;
}

int main() {
    string line;
    while ( cin >> line ) {
        replace( line, '+', ' ' );
        replace( line, '=', ' ' );
        istringstream iss( line );
        string a, b, c;
        iss >> a >> b >> c;
        solve( a, b, c );
    }
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
  
  ll n,m;
  cin >> n >>m;
  ll s=0;
  for(ll i=0 ; i<m  ; ++i) {
    ll x;
    cin >> x;
    s+=x;
  }
  cout << max(-1LL,n-s) << endl;
  
  return 0;
}

Measured memory_bytes: 3644
/* B - An Odd Problem */

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

int main(){
  int N, ans = 0;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a.at(i);
  }
  for(int i = 0; i < N ; i += 2){
    if(a.at(i) % 2 != 0){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
//
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mx 100010
#define pi acos(-1)
#define endl '\n'
#define Fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0)
//
int main()
{
    ll n, count = 0, i, x;

    cin >> n;
    for (i = 1; i < n; i++)
    {
        x = n / i;
        if (x * i == n)
        {
            count += (x - 1);
        }
        else
            count += x;
    }
    cout << count << endl;
}


Measured memory_bytes: 3608
from collections import Counter
MOD = 998244353
n = int(input())
d = list(map(int, input().split()))
if d[0] != 0 or 0 in d[1:]:
    print(0)
    exit(0)
c = [0] * n
for x in d:
    c[x] += 1
t = 1
ans = 1
for i in range(n - 1):
    ans *= pow(t, c[i], MOD)
    t = c[i]
    ans %= MOD
print(ans)

Measured memory_bytes: 14780
#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
      
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

import sys
input = sys.stdin.readline 
n,m = [int(i) for i in input().split()]
par = [-1]*n
for i in range(m):
  x,y,z = [int(i)-1 for i in input().split()]
  unite(x,y)
   
import collections
chk = []
chk = collections.deque(chk)
for i in range(n):
  chk_append = chk.append
  chk_append(find(i))
  
chk = set(chk)
print(len(chk))

Measured memory_bytes: 14316
#include<iostream>
using namespace std;
struct sison{
char have[51];
char sche[31];
};
int main(){
sison sison[51];
int i,j,n,c,s,day[51],p;
while(1){
scanf("%d",&n);
if(n==0)
break;
for(i=1;i<=n;i++){
for(j=1;j<=n;j++)
sison[i].have[j]=0;
for(j=1;j<=30;j++)
sison[i].sche[j]=0;
}
for(i=1;i<=n;i++){
scanf("%d",&c);
for(j=0;j<c;j++){
scanf("%d",&s);
sison[i].sche[s]=1;
}
sison[i].have[i]=1;
}
for(p=1;p<=30;p++){
for(i=1;i<=50;i++)
day[i]=0;
for(i=1;i<=n;i++){
if(sison[i].sche[p]==0)
continue;
for(j=1;j<=n;j++){
if(sison[i].have[j]==1)
day[j]=1;
}
}
for(i=1;;i++){
if(day[i]==0)
break;
if(i==n)
goto A;
}
for(i=1;i<=n;i++){
if(sison[i].sche[p]==0)
continue;

for(j=1;j<=n;j++)
sison[i].have[j]=day[j];
}
}
A:
if(p==31){
cout<<"-1"<<endl;
}else{
printf("%d\n",p);
}
}
}

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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}

int main()
{
	fast;
	cout << fixed << setprecision(10);
	int n, k;
	cin >> n >> k;
	vector<long double> p(n + 1, 0);
	for (int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		p[i] = ((x + 1) / 2.0) + p[i - 1];
	}
	long double ans = 0;
	FOR(n - k + 1)
	chmax(ans, p[i + k] - p[i]);
	cout << ans;
}

Measured memory_bytes: 6316
#include <bits/stdc++.h>
using namespace std;
int a[300005];
int st[3000005];
void update(int n, int s, int e, int i, int val){
    if(s == e) st[n] = max(st[n], val);
    else{
        int mid = (s+e)/2;
        if(i <= mid) update(n+n, s, mid, i, val);
        else update(n+n+1, mid+1, e, i, val);
        st[n] = max(st[n+n], st[n+n+1]);
    }
}
int query(int n, int s, int e, int l, int r){
    if(s > r || l > e) return 0;
    if(l <= s && e <= r) return st[n];
    int mid = (s+e)/2;
    return max(query(n+n, s, mid, l, r), query(n+n+1, mid+1, e, l, r));
}
int dp[300005];
int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    int ans = 0;
    for(int i=1;i<=n;i++){
        scanf("%d", &a[i]);
        dp[i] = query(1, 0, 300000, max(0, a[i]-k), min(300000, a[i]+k)) + 1;
        update(1, 0, 300000, a[i], dp[i]);
        ans = max(ans, dp[i]);
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 10200
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int A_MAX = 1000000;

int main() {
	int n;
	cin >> n;
	int A[n];
	for (int i = 0; i < n; i++) cin >> A[i];
	sort(A, A+n);
	bool sieve[A_MAX+1]; fill(sieve, sieve+A_MAX+1, false);
	bool table[n]; fill(table, table+n, false);
	for (int i = 0; i < n; i++) {
		if (i > 0 && A[i-1] == A[i]) table[i-1] = false;
		if (!sieve[A[i]]) {
			table[i] = true;
			for (int j = A[i]; j <= A_MAX; j += A[i]) {
				sieve[j] = true;
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) if (table[i]) ans++;
	cout << ans << endl;
	return 0;
}

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

using namespace std;

vector<int> pre,in,post;

int pos;

void dfs(int l,int r)
{
    if(l>=r)
    {
        return;
    }

    int root=pre[pos++];

    int idx=find(in.begin(),in.end(),root)-in.begin();

    dfs(l,idx);
    dfs(idx+1,r);
    post.push_back(root);
}

int main()
{

    int n;

    while(cin>>n)
    {
        pre.clear();in.clear();post.clear();

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

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

        pos=0;
        dfs(0,n);

        for(int i=0;i<n;i++)
        {
            if(i)
            {
                cout<<" ";
            }

            cout<<post[i];
        }
        cout<<endl;
    }

    return 0;
}



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

int main() {
    int a,b;
    cin>>a>>b;
    int ans=0;
    if(a==1 && b==2) ans =3;
    if(a==1 && b==3) ans =2;
    if(a==2 && b==1) ans =3;
    if(a==2 && b==3) ans =1;
    if(a==3 && b==1) ans =2;
    if(a==3 && b==2) ans =1;
    
    cout << ans << endl;
    
    
    return 0;
}


Measured memory_bytes: 256