akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000



int main(){
	
	int a,b;
	cin>>a>>b;
	
	string s = "";
	
	for(int i=0;i<b;i++){
		s += (char)('0' + a);
	}
	
	string t = "";
	
	for(int i=0;i<a;i++){
		t += (char)('0'+b);
	}
	
	cout<<min(s,t)<<endl;
	
	return 0;
}


Measured memory_bytes: 256
n=int(input())
#A=list(map(int, input().split()))
B=list(input().split())
C=B.copy()

def bubblesort(A,n):
    #print(A)
    count=0
    flag=1
    while flag:
        flag=0
        for j in reversed(range(1,len(A))):
            if int(A[j][1])<int(A[j-1][1]):
                tmp=A[j-1]
                A[j-1]=A[j]
                A[j]=tmp
                flag=1
                count+=1
    return(A,count)

def selectsort(A,n):
    count=0
    for i in range(len(A)):
        minj=i
        #flag=0
        for j in range(i,len(A)):
            if int(A[j][1])<int(A[minj][1]):
                minj=j
                #flag=1
        if i!=minj:
            A[i],A[minj]=A[minj],A[i]
            count+=1
    #print(A)
    return(A,count)

#バブルソートの結果と比較する
def isStable(result1, result2):
    if result1 == result2:
        return True
    return False


result1,count1=bubblesort(B,n)
print(" ".join([str(i) for i in result1]))
print("Stable")
result2,count2=selectsort(C,n)
print(" ".join([str(i) for i in result2]))
if isStable(result1, result2) == True:
    print("Stable")
else:
    print("Not stable")

#print(count)



Measured memory_bytes: 5616
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC152
{
    class D
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            Dictionary<Tuple<int, int>, int> dict = new Dictionary<Tuple<int, int>, int>();
            for (int i = 1; i <= N; i++)
            {
                int head = 0;
                int tail = 0;
                int num = i;
                tail = num % 10;
                num /= 10;

                if (1 <= i && i <= 9)
                {
                    // 一桁の時
                    head = i;
                }
                else
                {
                    // 二桁以上の時
                    while (0 < num)
                    {
                        head = num % 10;
                        num /= 10;
                    }
                }

                Tuple<int, int> t = Tuple.Create(head, tail);
                if (!dict.ContainsKey(t)) dict.Add(t, 1);
                else dict[t]++;
            }

            long res = 0;
            for (int i = 1; i < 10; i++)
            {
                for (int j = 1; j < 10; j++)
                {
                    Tuple<int, int> t2 = Tuple.Create(i, j);
                    Tuple<int, int> t3 = Tuple.Create(j, i);
                    if (dict.ContainsKey(t2) && dict.ContainsKey(t3)) res += dict[t2] * dict[t3];
                }
            }
            Console.WriteLine(res);
        }
    }
}


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

const int N = 1e5 + 7;
int dp[N], h[N];

int main() {
	int n;
	scanf("%d", &n);
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &h[i]);
		dp[i] = 1;
		if (i > 1 && h[i - 1] >= h[i]) dp[i] += dp[i - 1];
		ans = max(ans, dp[i]);
	}
	printf("%d\n", ans - 1);
	return 0;
}

Measured memory_bytes: 1024
#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 FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

class Zp {
	const int p = 1000000007;
	ll r;
	void set(ll x) {
		while (x < 0) x += p;
		r = x % p;
	}

public:
	Zp(ll x) { set(x); }
	Zp() { set(0); }

	Zp operator-() const { return Zp(-r); }
	Zp &operator=(ll y) {
		set(y);
		return *this;
	}
	Zp &operator=(const Zp &y) { return *this = y.r; }

	Zp &operator+=(ll y) {
		set(r + y);
		return *this;
	}
	Zp &operator-=(ll y) { return *this += -y; }
	Zp &operator*=(ll y) {
		set(r * y);
		return *this;
	}
	Zp &operator/=(ll y) { return *this *= inv(y); }
	Zp operator+(ll y) const { return Zp(r + y); }
	Zp operator-(ll y) const { return *this + (-y); }
	Zp operator*(ll y) const { return Zp(r * y); }
	Zp operator/(ll y) const { return *this * inv(y); }

	Zp &operator+=(const Zp &y) { return *this += y.r; }
	Zp &operator-=(const Zp &y) { return *this -= y.r; }
	Zp &operator*=(const Zp &y) { return *this *= y.r; }
	Zp &operator/=(const Zp &y) { return *this /= y.r; }
	Zp operator+(const Zp &y) const { return *this + y.r; }
	Zp operator-(const Zp &y) const { return *this - y.r; }
	Zp operator*(const Zp &y) const { return *this * y.r; }
	Zp operator/(const Zp &y) const { return *this / y.r; }

	Zp pow(int n) const {
		if (n == 0) return 1;
		if (n % 2) return *this * pow(n - 1);
		Zp tmp = pow(n / 2);
		return tmp * tmp;
	}
	Zp inv(int x) const { return Zp(x).pow(p - 2); }
	Zp inv() const { return inv(r); }

	ll get() const { return r; }

	friend istream &operator>>(istream &istr, Zp &x) {
		istr >> x.r;
		x.set(x.r);
		return istr;
	}
	friend ostream &operator<<(ostream &ostr, const Zp &x) {
		ostr << x.r;
		return ostr;
	}
};
class Comb {
	vector<Zp> fact, ifact;

public:
	Comb(int N) : fact(N + 1), ifact(N + 1) {
		fact[0] = 1;
		REP(i, N)
		fact[i + 1] = fact[i] * (i + 1);
		ifact[N] = fact[N].inv();
		REPR(i, N)
		ifact[i] = ifact[i + 1] * (i + 1);
	}
	Zp operator()(int n, int k) const {
		return fact[n] * ifact[n - k] * ifact[k];
	}
	Zp f(int k) const { return fact[k]; }
	Zp invf(int k) const { return ifact[k]; }
};

Zp dp[100001];
int memo[3];

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

	int N;
	cin >> N;
	vector<ll> A(N);
	REP(i, N) { cin >> A[i]; }
	dp[0] = 1;
	REP(i, N) {
		int cnt = 0;
		int idx = -1;
		REP(j, 3) {
			if (memo[j] == A[i]) {
				++cnt;
				idx = j;
			}
		}
		dp[i + 1] = dp[i] * cnt;
		if (idx >= 0) {
			memo[idx]++;
		}
	}
	cout << dp[N] << endl;

	return 0;
}

Measured memory_bytes: 2560
import sys
sys.setrecursionlimit(10**6)
from collections import deque
MOD = 1000000007

N =  int(input())
childs = [[] for i in range(N+1)]
for i in range(N-1):
    a, b = map(int, input().split())
    childs[a].append(b)
    childs[b].append(a)

dp = [0] * (N + 1) # represent the # if i is the root (1)
tree_size = [0]*(N + 1)
ans = [0] * (N + 1)

n_inv = [1, 1]
n_j_mod = [1, 1]

for i in range(2, N+1):
    n_inv.append((pow(i, MOD-2, MOD) * n_inv[-1]) % MOD)
    n_j_mod.append((n_j_mod[-1] * i) % MOD)


def dfs(i, father=-1):
    method_num = 1
    t_size = 1
    for child in childs[i]:
        if child != father:
            num, size = dfs(child, i)
            method_num = (method_num * num * n_inv[size]) % MOD
            t_size += size
    method_num = (method_num * n_j_mod[t_size - 1]) % MOD
    dp[i] = method_num
    tree_size[i] = t_size
    return method_num, t_size

def rdfs(i, f_num, father=-1):
    ans[i] = (dp[i] * f_num * n_j_mod[N-1] * n_inv[N - tree_size[i]] * n_inv[tree_size[i] - 1]) % MOD

    for child in childs[i]:
        if child != father:
            cf_num = (ans[i] * n_j_mod[tree_size[child]] * n_j_mod[N - tree_size[child] - 1] * n_inv[N - 1] * pow(dp[child], MOD-2, MOD)) % MOD
            rdfs(child, cf_num, i)
dfs(1)

rdfs(1, 1)
print('\n'.join(list(map(str, ans[1:]))))


Measured memory_bytes: 85728
N = list(input())
nlen = len(N)
if N[nlen - 1] == "3":
	print("bon")
elif N[nlen - 1] == "0" or N[nlen - 1] == "1" or N[nlen - 1] == "6" or N[nlen - 1] == "8":
	print("pon")
else:
	print("hon")


Measured memory_bytes: 9040
#include <iostream>
using namespace std;
int N,M,Q;
int L,R,p[100000],q[100000];
int x[501][501],sum[501][501];

int main(){
    cin>>N>>M>>Q;
    for(int i=0;i<M;i++)cin>>L>>R,x[L][R]++;
    for(int i=0;i<Q;i++)cin>>p[i]>>q[i],p[i]--;

    for(int i=1;i<=N;i++)
        for(int j=1;j<=N;j++)
            sum[i][j]=x[i][j]+sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
    
    for(int i=0;i<Q;i++){
        cout<<sum[q[i]][q[i]]-sum[p[i]][q[i]]-sum[q[i]][p[i]]+sum[p[i]][p[i]]<<endl;
    }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;

int main(){
    int n;cin>>n;
    int a[n];
    rep(i,n)cin>>a[i];
    ll ans  =INFL;
    rep2(i,-100,101){
        ll sum =0;
        rep(j,n){
            sum+=(a[j]-i)*(a[j]-i);
        }
        ans =min(ans,sum);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import math
a, b, n = list(map(int, input().split()))

ans = 0
for i in range(1, a+1):
    x = math.ceil(i*b/a)-1
    if x <= n:
        diff = math.floor(a*x/b) - a*math.floor(x/b)
        ans = max(ans, diff)
    elif n < x:
        diff = math.floor(a*n/b) - a*math.floor(n/b)
        ans = max(ans, diff)
        break
print(ans)

Measured memory_bytes: 9144
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define fi first
#define se second
#define reset(n,k) memset((n),k,sizeof(n))
#define all(n) n.begin(),n.end()
#define pb push_back
using namespace std;
using ll=long long;
using pii=pair<ll,ll>;
ll dp[200005];
ll r[200005];
pii arr[200005];
stack<int> stk;
bool cmp(pii &a,pii &b){
	return (a.fi<b.fi);
}
int main(){
	IOS;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>arr[i].fi>>arr[i].se;
		arr[i].se += arr[i].fi;
	}
	sort(arr+1,arr+1+n,cmp);
	arr[n+1] = {1e18,2e18};
	dp[n+1] = 1;
	stk.push(n+1);
	for(int i=n;i>=1;i--){
		//cout<<arr[i].fi<<" "<<arr[i].se<<'\n';
		while(arr[i].se > arr[stk.top()].fi) stk.pop();
		r[i] = stk.top();
		stk.push(i);
		dp[i] = dp[i+1] + dp[r[i]];
		//cout<<r[i]<<" "<<dp[i]<<'\n';
		dp[i] %= 998244353;
	}
	cout<<dp[1]<<'\n';

}


Measured memory_bytes: 6912
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    ll n;
    cin >> n;
    map<ll,ll> mp;
    REP(i,n){
        ll tmp;
        cin >> tmp;
        mp[tmp]++;
    }
    ll ans = 0;
    
    for(auto p : mp){
        if(p.second%2==1) ans++;
    }
        
    cout << ans << ENT;
    return 0;
}

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


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "YES" << '\n'; exit(0); }
inline void no() { cout << "NO" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int n; cin >> n;
  unordered_map<int, int> D;
  rep(i, n) {
    int d; cin >> d;
    D[d]++;
  }
  int m; cin >> m;
  rep(i, m) {
    int t; cin >> t;
    if (D.count(t) == 0 || D[t] == 0) no();
    D[t]--;
  }
  yes();
}


Measured memory_bytes: 8520
#include <iostream>


int main(){
	int N;
	int A;
	float total=0;
	std::cin >> N;
	for(int i=0; i<N; i++){
		std::cin >> A;
		total += 1.0/A;
	}
	total=1.0/total;
	std::cout<< total << std::endl;
	return 0;
}

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

// 「チケットが手元にある限り，その時点で一番高価な品物に適用する」を繰り返すのが最適

int main()
{
    int n, m;
    cin >> n >> m;
    priority_queue<int> pq;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        pq.push(a);
    }
    for (int i = 0; i < m; i++)
    {
        int item = pq.top();
        pq.pop();
        pq.push(item / 2);
    }
    long long ans = 0;
    for (int i = 0; i < n; i++)
        ans += pq.top(), pq.pop();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 892
#include<stdio.h>
int main(){
  long long int h, i=1;
  scanf("%lld", &h);
  if(h==1){
    printf("1\n");
    return 0;
  }
  while(1){
    if(h==1){
      i=i*2-1;
      printf("%lld",i);
      return 0;
    }
  if(h%2==0){
    h=h/2;
    i=i*2;
  }
    else{
      h=(h-1)/2;
      i=i*2;
    }
  }
}


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

int main() {
    ll n;  cin >>n;
    ll arr[n];
    for(ll i=0;i<n;i++){
        cin >>arr[i];
    }
    ll dp[n];
    dp[0]=0;
    dp[1] = abs(arr[1]-arr[0]);
    
    for(ll i=2;i<n;i++){
        dp[i] = min( dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i]-arr[i-2]) );
    }
    
    cout<<dp[n-1];
    
    return 0;
}

Measured memory_bytes: 5188
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int Max = 2e5;

int n, a[Max + 5];

int main ()
{
	scanf ("%d", &n);
	for (int i = 1; i <= n; i++)	scanf ("%d", &a[i]);
	if (n %	2 == 0){
		for (int i = n; i >= 2; i-=2)	printf ("%d ", a[i]);
		for (int i = 1; i <= n - 3; i+=2)	printf ("%d ", a[i]);
		printf ("%d\n", a[n - 1]);
	}
	else{
		if (n == 1)	{printf ("%d\n", a[1]);	return 0;}
		else{
			for (int i = n; i >= 1; i-=2)	printf ("%d ", a[i]);
			for (int i = 2; i <= n - 3; i+=2)	printf ("%d ", a[i]);
			printf ("%d\n", a[n - 1]);
		}
	}
}



Measured memory_bytes: 2816
#include <stdio.h>

int N = 1;
int M = 0;
int edges[128][3];

void addEdge(int from, int to, int omomi) {
	if (from > N) N = from;
	if (to > N) N = to;
	edges[M][0] = from;
	edges[M][1] = to;
	edges[M][2] = omomi;
	M++;
}

int main(void) {
	int L;
	int delta = 1;
	int sumipe = 1;
	int maaya = 0;
	int i;
	if (scanf("%d", &L) != 1) return 1;
	while (L >= (delta << 1)) {
		sumipe++;
		delta <<= 1;
	}
	for (i = 1; i < sumipe; i++) {
		addEdge(i, i + 1, 1 << (sumipe - i - 1));
		addEdge(i, i + 1, 0);
	}
	L -= delta;
	sumipe = 1;
	maaya += delta;
	while (L > 0) {
		if (L >= delta) {
			addEdge(1, sumipe, maaya);
			L -= delta;
			maaya += delta;
		}
		delta >>= 1;
		sumipe++;
	}

	printf("%d %d\n", N, M);
	for (i = 0; i < M; i++) {
		printf("%d %d %d\n", edges[i][0], edges[i][1], edges[i][2]);
	}
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int n, m;
	cin >> n >> m;
	VL a(n);
	// X=ai/2*(2*p+1)とする
	ll lcms = 1;
	rep(i, n) {
		cin >> a[i];
		a[i] /= 2;
		lcms = lcm(lcms, a[i]);
	}
	int cnt = 0;
	while (a[0] % 2 == 0) {
		a[0] /= 2;
		cnt++;
	}
	rep1(i, n - 1) {
		int cnt2 = 0;
		while (a[i] % 2 == 0) {
			a[i] /= 2;
			cnt2++;
		}
		if (cnt != cnt2) {
			cout << 0 << endl;
			return 0;
		}
	}
	if (lcms > m) cout << 0 << endl;
	else {
		int ans = m / lcms;
		cout << (ans + 1) / 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		for(int i=0;i<s[2];i++){
			if(s[i%2]%2==1){
				s[i%2]--;
			}
			s[i%2]/=2;
			s[(i%2)^1]+=s[i%2];
		}
		Console.WriteLine("{0} {1}",s[0],s[1]);
	}
}

Measured memory_bytes: 13268
X,Y=map(int, raw_input().split())

ans=0
if X==3: ans+=100000
elif X==2: ans+=200000
elif X==1: ans+=300000

if Y==3: ans+=100000
elif Y==2: ans+=200000
elif Y==1: ans+=300000

if X==1 and Y==1: ans+=400000

print ans

Measured memory_bytes: 28012
#include"bits/stdc++.h"
    using namespace std;
    long long gcd(int a,int b){ return b==0?a:gcd(b,a%b); }
    int main(){
    	int n;
    	cin>>n;
    	long long ans=0;
    	for(int i=1;i<=n;i++){
    		for(int j=1;j<=n;j++){
    			for(int k=1;k<=n;k++){
    				ans+=gcd(i,gcd(j,k));
    			}
    		}
    	}
    	cout<<ans<<endl;
    } 

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  int ans = 0;
  rep(i, n){
    if(i % 2 == 0 && a.at(i)%2 == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3580
// Lets go to the next level 
// AIM CM at CF *__* asap 
// Hit A,B,C and D faster and reach Candidate Master
// Remember you were also a novice when you started, 
// hence never be rude to anyone who wants to learn something
// Never open a ranklist untill and unless you are done with solving problems, wastes 3/4 minuts 
// Donot treat CP as a placement thing, love it and enjoy it, you will succeed for sure.  


#include <bits/stdc++.h>
using namespace std;
#define mod (int)1000000007
#define MOD (int)10000000007
// Big two primes 
#define X 1001100011100001111ll
#define M 26388279066623ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for0e(i, n) for (int i = 0; i <= n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int long long 
#define ll long long
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int> 
#define F first
#define S second
#define pi pair<int, int>
#define ppi pair<pair<int,int> , int >
#define vii vector<pi>
const int MAXN = (int)((1e5) + 100);
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}  
int cbrt(int x){ int lo=1,hi=min(2000000ll,x);while(hi-lo>1){int mid=(lo+hi)/2;if(mid*mid*mid<x){lo=mid;}else hi=mid;}if(hi*hi*hi<=x) return hi;else return lo;} 
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const int N =  (int)(1e6+5); 


signed main(){
  fio;
    int n;
    cin>>n;
   
    int a = -1;

    for(int i=1;i<=n;i++){
        if((int)( i*1.08) == n){
            a = i;
        }
    }

    if( a != -1){
        cout<<a;
    }
    else{
        cout<<":(";
    }

  rr;
}

Measured memory_bytes: 384
import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new
		// File("D:\\UserArea\\J0124567\\Downloads\\ALDS1_6_A-in9.txt"));

		int n = scan.nextInt();
		Tree t = new Tree(n);

		for (int i = 0; i < n; i++) {
			int id = scan.nextInt();
			t.setLeftChild(id, scan.nextInt());
			t.setRightChild(id, scan.nextInt());
		}

		System.out.print("Preorder\n");
		t.printPre(t.getRoot());
		System.out.print("\nInorder\n");
		t.printIn(t.getRoot());
		System.out.print("\nPostorder\n");
		t.printPost(t.getRoot());
		System.out.print("\n");

		scan.close();
		System.exit(0);
	}
}

class Tree {
	private class Node {
		int Parent = -1;
		int LeftChild = -1;
		int RightChild = -1;

		public int getDepth() {
			if (Parent == -1)
				return 0;
			else
				return (node[Parent].getDepth() + 1);
		}

		public String getType() {
			if (Parent == -1)
				return "root";
			else if (LeftChild == -1 && RightChild == -1)
				return "leaf";
			else
				return "internal node";
		}

		public int getSib(int id) {
			if (Parent == -1)
				return -1;
			else if (node[Parent].LeftChild == id)
				return (node[Parent].RightChild);
			else
				return (node[Parent].LeftChild);
		}

		public int getDegree() {
			int r = 2;
			if (LeftChild == -1)
				r--;
			if (RightChild == -1)
				r--;
			return r;
		}

		public int getHeight() {
			if (getDegree() == 0)
				return 0;
			int l = 0, r = 0;
			if (LeftChild != -1)
				l = node[LeftChild].getHeight();
			if (RightChild != -1)
				r = node[RightChild].getHeight();
			return Math.max(l, r) + 1;
		}
	}

	private Node[] node;

	public Tree(int n) {
		node = new Node[n];
		for (int i = 0; i < n; i++) {
			node[i] = new Node();
		}
	}

	public void printPost(int id) {
		if (id == -1)
			return;
		printPost(node[id].LeftChild);
		printPost(node[id].RightChild);
		System.out.print(" " + id);
	}

	public void printIn(int id) {
		if (id == -1)
			return;
		printIn(node[id].LeftChild);
		System.out.print(" " + id);
		printIn(node[id].RightChild);
	}

	public void printPre(int id) {
		if (id == -1)
			return;
		System.out.print(" " + id);
		printPre(node[id].LeftChild);
		printPre(node[id].RightChild);
	}

	public int getRoot() {
		return getRoot(0);
	}

	private int getRoot(int id) {
		if (node[id].Parent == -1)
			return id;
		else
			return getRoot(node[id].Parent);
	}

	public void setRightChild(int id, int c) {
		node[id].RightChild = c;
		if (c != -1)
			node[c].Parent = id;
	}

	public void setLeftChild(int id, int c) {
		node[id].LeftChild = c;
		if (c != -1)
			node[c].Parent = id;
	}

	public void printDetail(int id) {
		System.out.println("node " + id + ": parent = " + node[id].Parent + ", sibling = " + node[id].getSib(id)
				+ ", degree = " + node[id].getDegree() + ", depth = " + node[id].getDepth() + ", height = "
				+ node[id].getHeight() + ", " + node[id].getType());
	}
}

Measured memory_bytes: 26476
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;
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; }
template<typename A, size_t N, typename T> inline void Fill(A (&array)[N], const T &val){ std::fill( (T*)array, (T*)(array+N), val ); }
#define INF 1e9
#define PI (acos(-1))
#define mod (int)1e9+7  
int main() {
    int n;
    cin>>n;
    vector<int> p(n);
    REP(i,n)cin>>p[i];
    int min=p[0];
    int sum=0;
    REP(i,n){
        if(min>=p[i]){
            min=p[i];
            sum++;
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

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

        int A = sc.nextInt();
        int B = sc.nextInt();

        if(A*B%2==0){
            System.out.println("No");
        }
        else{
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 21844
def main():
	SA = input()
	SB = input()
	SC = input()
	c = SA[0]
	SA = SA[1:]
	while True:
		if c == "a":
			if SA or "a" in SA:
				c = SA[0]
				SA = SA[1:]
			else:
				print("A")
				return
		elif c == "b":
			if SB or "b" in SB:
				c = SB[0]
				SB = SB[1:]
			else:
				print("B")
				return
		elif c == "c":
			if SC or "c" in SC:
				c = SC[0]
				SC = SC[1:]
			else:
				print("C")
				return


if __name__ == '__main__':
	main()

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


n,w = map(int,input().split())
W = [0 for i in range(n)];V = [0 for i in range(n)]
for i in range(n):
    W[i],V[i] = map(int,input().split())
dp = [[0 for i in range(w+1)] for j in range(n+1)]

for i in range(n):
    for j in range(w+1):
        if j >= W[i]:
            dp[i+1][j] = max(dp[i][j],dp[i][j-W[i]]+V[i])
        else:
            dp[i + 1][j] = dp[i][j]
print(dp[n][w])

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


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define sec second
#define fir first
#define pb push_back



/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
//const int inf = pow(2, 62);
//const int mod = 1e9 + 7;
const int mod = 100000;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};



/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
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; }




/* main */



signed main(){

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

    
    int a, b, h; cin >> a >> b >> h;

    print((a + b) * h / 2);


    
    



    
    

    







   




    

    

    




    



    



    

 
    
    


    

    
   
    













}






    










    




    










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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

bool isPrime(int n) {
    if(n == 2) return true;
    for(int i=2;i*i<=n;i++){
        if(n%i == 0) return false;
    }
    return true;
}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    vector<int> p;
    inc(i, 1, 1000){
        if(isPrime(10*i+1)){
            p.push_back(10*i+1);
            //cout << 10*i-1 << endl;
        }
        if(p.size() == 60){
            break;
        }
    }

    int n;cin >> n;
    inc(i, 0, n){
        cout << p[i];
        if(i != n-1){
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {

      string S, T;
      cin >> S >> T;

      int n;
      n = 0;
      
      for(int i = 0; i < S.size(); i++){
        if (S.at(i) != T.at(i)){
          n = n+1;
        } 
       }
      cout << n << endl;
    }

Measured memory_bytes: 3916
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-5;
const int inf=1e8;
int main(){
	int n,m;
	bool q=false;
	while(cin>>n,n){
		cin>>m;
		n++;m++;
		if(q)cout<<endl;
		vvi in(n,vi(m,inf));
		vp ha;
		rep(i,n)rep(j,m){
			string s;
			cin>>s;
			if(s=="?")ha.pb(pii(i,j));
			else in[i][j]=stoi(s);
		}
		int co=ha.size();
		while(co){
			int cnt=0;
			rep(i,n){
				int c=0;
				rep(j,m)if(in[i][j]==inf)c++;
				if(c==1){
					cnt++;
					int sum=0;
					rep(j,m-1)if(in[i][j]!=inf)sum+=in[i][j];
					rep(j,m-1)if(in[i][j]==inf)in[i][j]=in[i][m-1]-sum;
				}
			}
			rep(i,m){
				int c=0;
				rep(j,n)if(in[j][i]==inf)c++;
				if(c==1){
					cnt++;
					int sum=0;
					rep(j,n-1)if(in[j][i]!=inf)sum+=in[j][i];
					rep(j,n-1)if(in[j][i]==inf)in[j][i]=in[n-1][i]-sum;
				}
			}
			if(cnt==0)break;
			co-=cnt;
		}
		if(co)cout<<"NO"<<endl;
		else{
			rep(i,ha.size())cout<<in[ha[i].first][ha[i].second]<<endl;
		}
		q=true;
	}
}

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

using namespace std;

int main(){
    string S;
    cin >> S;
    if(S[0]=='S'){
        cout << "Cloudy" << endl;
    }else if(S[0]=='C'){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int A = sc.nextInt();
      	int B = sc.nextInt();
      
      	for(int i = 0; i <= 1100; i++){
        	if((int)(i*0.08)==A && (int)(i*0.1)==B){
            	System.out.println(i);
              	return;
            }
        }
      	System.out.println(-1);
    }
}

Measured memory_bytes: 35952
from bisect import bisect_left
N,K=[int(a) for a in input().split(" ")]
X=[int(a) for a in input().split(" ")]
i = bisect_left(X,0)
if 0 in X:
    K=K-1
else:
    X.insert(i, 0)
ans = 10**10
for left in range(max(i-K, 0), i+1):
    right = left+K
    if right>=len(X):
        break
    lw, rw = -X[left], X[right]
    ans = min(ans, lw+rw+min(lw,rw))
print(ans)

Measured memory_bytes: 14480
import Control.Applicative
import Data.List

main = do
    n <- readLn
    s <- getLine
    print $ solve n s

solve :: Int -> String -> Int
solve n s = maximum nums
    where nums = map (g s) [1..(n-1)]

g s n = f l r
    where (left,right) = splitAt n s
          l = nub left
          r = nub right

f xs ys = common xs ys 0
common :: String -> String -> Int -> Int
common [] _ n = n
common _ [] n = n
common (x:xs) ys n = if elem x ys then common xs ys (n+1) else common xs ys n

Measured memory_bytes: 1020
from collections import defaultdict
import sys
sys.setrecursionlimit(10000)
N, M = map(int, input().split())
in_path = defaultdict(lambda: [])
out_path = defaultdict(lambda: [])

for m in range(M):
    x, y = map(int, input().split())
    in_path[y].append(x)
    out_path[x].append(y)

check = [False]*(N+1)
memo = [0]*(N+1)


def dp(i):
    if check[i]:
        return memo[i]
    else:
        check[i] = True
        if not out_path[i]:
            return 0
        else:
            max_path = 0
            for node in out_path[i]:
                max_path = max(dp(node), max_path)
            max_path += 1
            memo[i] = max_path
            return max_path


ans = 0
for i in range(1, N+1):
    ans = max(ans, dp(i))

print(ans)


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

int main(){
  int tim[5];
  cin>>tim[0]>>tim[1]>>tim[2]>>tim[3]>>tim[4];
  int sum[5]={};
  int i,j;
  int timup[5];

  for(i=0;i<5;i++){
    if(tim[i]%10>0){
    timup[i] = (tim[i]/10)*10+10;
    //cout<<timup[i]<<"\n";
  }else{
    timup[i] = tim[i];
    //cout<<timup[i]<<"\n";
  }
  }

 sum[0]=timup[0]+timup[1]+timup[2]+timup[3]+tim[4];
 sum[1]=timup[0]+timup[1]+timup[2]+timup[4]+tim[3];
 sum[2]=timup[0]+timup[1]+timup[4]+timup[3]+tim[2];
 sum[3]=timup[0]+timup[4]+timup[2]+timup[3]+tim[1];
 sum[4]=timup[4]+timup[1]+timup[2]+timup[3]+tim[0];


sort(sum,sum+5);


  cout<<sum[0];

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int tmp = -1;
    vector<int> buff;
    for(int i = 0; i < n; i++)
    {
        int x; cin >> x;
        if(x == tmp + 1) buff.push_back(tmp - 1);
        tmp = x;
    }
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        int x; cin >> x;
        ans += x;
    }
    vector<int> C(n);
    for(int i = 0; i < n - 1; i++) cin >> C[i];
    for(int i = 0; i < buff.size(); i++)
    {
        ans += C[buff[i]];
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    long long n, k;
    cin >> n >> k;
    long long ans;

    if (k%2 == 0) {
        ans = (n/k)*(n/k)*(n/k) + (2*n/k-n/k)*(2*n/k-n/k)*(2*n/k-n/k);
    } else {
        ans = (n/k)*(n/k)*(n/k);
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int S,h,m,s;
    scanf("%d",&S);
    h=S/3600;
    m=(S-h*3600)/60;
    s=S-h*3600-m*60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2104
N = int(input())
X_LIST = list(map(int, input().split()))

mid = sorted(X_LIST)[int(N / 2) - 1]
next_mid = sorted(X_LIST)[int(N / 2)]

for x in X_LIST:
    if x <= mid:
        print(next_mid)
    else:
        print(mid)

Measured memory_bytes: 25220
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  int c = 0;
  rep(i, N) {
    int a; cin >> a;
    while (a%2 == 0) a/=2, c++;
  }
  cout << c << "\n";
  return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


int main() {
    set<int> st;
    string s;
    cin >> s;
    rep(i,0,s.size()){
        if(st.find(s[i]-'a') == st.end()){
            st.insert(s[i] - 'a');
        }else{
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
    return 0;
}


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

  const int MOD = 1000000007;
  const double PI = acos(-1); 

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

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

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
      if(n % i) continue;
      res.emplace_back(i, 0);
      while(n % i == 0){
        n /= i;
        res.back().second++;
      }
    }
  if(n != 1) res.emplace_back(n, 1);
  return res;
  }



  //二分探索(最小値を出す問題は疑う)

// bool C(ll x){
//     ll res = 0;
//     for(int i = 0; i < n; ++i){
// 		res += max(0ll, a[i]-x/f[i]);
//     }
//     return res <= k;
// }

//   ll binary_search(ll ok, ll ng){
//     while(abs(ok - ng) > 1){
//       ll mid = (ok + ng) / 2;
//       if(C(mid)) ok = mid;
//       else ng = mid;
//     }
//     return ok;
//   }



int main(){
  ll N, M; cin >> N >> M;
  string S, T; cin >> S >> T;
  ll L = N * M / gcd(N, M);

  ll LN = L / N; ll LM = L / M;
  ll LG = LN * LM / gcd(LN, LM);
  ll a = LG / LN; ll b = LG / LM;

  for(int i = 0; L > LN * a * i; i++){
    if(S.at(a * i) != T.at(b * i)){
      print(-1);
      return 0;
    }
  }
  
  print(L);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int n;
int a[100100];
struct node {
	int x,y;
}s[100100];
int main(){
	cin>>n;
	for (int i=1;i<=n;i++) cin>>a[i];
	int cnt=0,ans=0;
	sort(a+1,a+1+n);
	if (a[1]>=0){
	 	ans=a[1];
		for (int i=2;i<n;i++){
			s[++cnt].x=ans;
			s[cnt].y=a[i];
			ans=ans-a[i];
		}
		s[++cnt].x=a[n];
		s[cnt].y=ans;
		ans=a[n]-ans;
	}else if (a[n]<=0){
		ans=a[n];
		for (int i=n-1;i>=1;i--){
			s[++cnt].x=ans;
			s[cnt].y=a[i];
			ans=ans-a[i];
		}
	}
	if (a[1]<0&&a[n]>0){
		int w=1;
		while (a[w]<=0) w++;
		w--;
		for (int i=1;i<=n;i++)
			ans+=abs(a[i]);
		int ans1=a[1];
		for (int i=w+1;i<n;i++){
			s[++cnt].x=ans1;
			s[cnt].y=a[i];
			ans1=ans1-a[i];
		}
		int ans2=a[n];
		for (int i=2;i<=w;i++){
			s[++cnt].x=ans2;
			s[cnt].y=a[i];
			ans2=ans2-a[i];
		}
		s[++cnt].x=ans2;
		s[cnt].y=ans1;
			
	}

	cout<<ans<<endl;
	for (int i=1;i<=cnt;i++)
		cout<<s[i].x<<" "<<s[i].y<<endl;
	return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
using namespace std;
using ll = long long;

int main(void) {
    int n;
    cin >> n;
    int cntk = 0, cntg = 0;
    rep (i, n) {
        int a;
        cin >> a;
        if (a % 2 == 0) cntg++;
        else cntk++;
    }

    if (cntk % 2 == 0) {
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
    
    return 0;
}

Measured memory_bytes: 384
# coding: utf-8

def main():
    s = input()
    t = input()

    ans = len(t)
    
    for i in range(len(s) - len(t) + 1):
        a = s[i:i+len(t)]
        # print(a, t)
        ans_list = [1 for x, y in zip(a, t) if x!=y]
        tmp_ans = sum(ans_list)
        ans = min(ans, tmp_ans)
        
        if ans == 0:
            break
        
    print(ans)
    
        

main()

Measured memory_bytes: 8960
#include<bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
#define PINT pair<int,int>
#define f1 first
#define s2 second
const int INF = 1e9 + 7;
 
using namespace std;
 
int main(){
    cin.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<PINT> red(n),blue(n);
    REP(i,n) cin >> red[i].f1 >> red[i].s2;
    REP(i,n) cin >> blue[i].f1 >> blue[i].s2;
    sort(red.begin(),red.end());
    sort(blue.begin(),blue.end());
    vector<bool> jud(n,false);
    int ans=0;
    REP(i,n){
        int max;
        bool flg=false;
        for(int j=0;j<n;j++){
            if(jud[j]) continue;
          	if(red[j].f1>=blue[i].f1) break;
            else{
                //cout << blue[i].f1 << ":" << red[j].f1 << endl;
                if(red[j].s2 < blue[i].s2){
                    if(!flg){
                        max=j;
                        flg=true;
                    }
                    if(red[max].s2 < red[j].s2) max = j;
                }
            }
        }
        if(flg){
            jud[max] = true;
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
      author  : nishi5451
      created : 12.08.2020 22:03:33
*/

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


int main(){
    int n,m;
    cin >> n;
    vector<int> t(n+1);
    int sum = 0;
    for(int i=1; i<=n; i++){
        cin >> t[i];
        sum += t[i];
    }
    cin >> m;
    vector<int> p(m+1),x(m+1);
    for(int i=1; i<=m; i++){
        cin >> p[i];
        cin >> x[i];
    }
    for(int i=1; i<=m; i++)
        cout << sum-t[p[i]]+x[i] << endl;
    return 0;
}

Measured memory_bytes: 3644
n = input()

S = [[0 for j in xrange(13)] for i in xrange(4)]
    
for i in xrange(n):
    tmp1, tmp2 = map(str, raw_input().split())
    if tmp1 == "S":
        S[0][int(tmp2) - 1] = 1
    elif tmp1 == "H":
        S[1][int(tmp2) - 1] = 1
    elif tmp1 == "C":
        S[2][int(tmp2) - 1] = 1
    elif tmp1 == "D":
        S[3][int(tmp2) - 1] = 1
        
for i in xrange(4):
    for j in xrange(13):
        if S[i][j] == 0:
            if i == 0:
                print "S",
            elif i == 1:
                print "H",
            elif i == 2:
                print "C",
            elif i == 3:
                print "D",
            print "%d" % (j + 1)

Measured memory_bytes: 6472
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	int N;
	cin >> N;
	string S, T;
	cin >> S >> T;


	int n_same = 0;
	for (int i = 0; i < N; i++) {

		for (int j = 0; i + j < N; j++) {
			if (S[i+j] == T[j]) {
				n_same = max(n_same, j+1);
			}
			else {
				break;
			}
		}

	}

	cout << 2 * N - n_same;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    vector<int> b(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i]-(i+1);
    }
    sort(b.begin(),b.end());
    long long ans=0;
    for(int i=0;i<n;i++){
        ans+=abs(a[i]-(b[n/2]+i+1));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define reg register
#define ll long long
using namespace std;
multiset<string>s;
ll a,b,c;
int main()
{
	scanf("%lld%lld%lld",&a,&b,&c);
	for(reg int i=1;i<=a;i++)s.insert("a");
    for(reg int i=1;i<=b;i++)s.insert("b");
    for(reg int i=1;i<=c;i++)s.insert("c");
    while(s.size()>1)
	{
        string a=*s.begin(),b=*s.rbegin();
        s.erase(s.lower_bound(a));
        s.erase(s.lower_bound(b));
        s.insert(a+b);
    }
    cout<<(*s.begin()).c_str()<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.14159265359
#define rep(i,n) for(int i=0;i<(n);i++)
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};


main()
{
    string s;
    cin >> s;
    if(s[s.size()-1] == 's')
        cout << s << "es" << endl;
    else
        cout << s << "s" << endl;
    return 0;
}


Measured memory_bytes: 3600