akhauriyash/Code-Regression huggingface dataset:
import math
N,K = map(int,input().split())
M = 10**9+7

As = [0]*(K+1)
X = K
while X>0:
    # 最大公約数がXの倍数となる数列の個数
    As[X] = pow((K//X),N,M)
    m = 2
    while m*X<=K:
        As[X] -= As[m*X]
        m += 1
    X -= 1
# print(As)
# print(sum(As))
c = 0
for i in range(1,K+1):
    c = (c+i*As[i]%M)%M
print(c)

Measured memory_bytes: 11160
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod. m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>=1;
    }
    return res;
}



int main(){
    int a;
    cin >> a;
    int ans = a;
    ans += a*a;
    ans += a * a * a;

    cout << ans << endl;
}



Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define read(x) scanf("%d",&x)
#define readl(x) scanf("%lld",&x)
#define ll long long 
#define ull unsigned long long
ll a,b,n;
ll x;
int main()
{
	cin>>a>>b>>n;
	if(n<b) x=n;
	else x=b-1;
	cout<<floor((double)a*(double(x)/b-floor(double(x)/b)))<<endl;
	return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
using ll = long long;

vector<ll> find_path(vector<vector<ll>> &g, ll from, ll to, ll parent = -1) {
  // cout << parent << " " << from << " " << to << endl;
  if (from == to) return vector<ll> {to};
  for (ll next : g[from]) {
    if (next == parent) continue;
    vector<ll> found = find_path(g, next, to, from);
    if (!found.empty()) {
      found.push_back(from);
      return found;
    }
  }
  return {};
}

ll find_longest(vector<vector<ll>> &g, ll from, ll parent = -1) {
  // cout << parent << " " << from << endl;
  ll max = 0;
  vector<ll> found = {from};
  for (ll next : g[from]) {
    if (next == parent) continue;
    ll submax = find_longest(g, next, from);
    found.push_back(from);
    if (max < submax) max = submax;
  }
  max++;
  return max;
}

int main() {
  ll n, u, v;
  cin >> n >> u >> v;

  vector<vector<ll>> g(n + 1);
  ll a, b;
  for (ll i = 0; i < n - 1; i++) {
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  ll up;
  vector<ll> path = find_path(g, u, v);
  if (path.size() >= 4) {
    up = (path.size() - 2) / 2;
  } else {
    up = 0;
  }
  u = path[path.size() - 1 - up];
  v = path[up + path.size() % 2];

  if (path.size() % 2 == 1) {
    up++;
  }

  ll longest = find_longest(g, u, v);
  // for (ll p : longest) {
  //   cout << p << " ";
  // }
  // cout << endl;
  
  ll down = longest - 1;
  // cout << u << " " << v << endl;
  // cout << up << " " << down << endl;
  cout << up + down << endl;
}


Measured memory_bytes: 16384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int m; ll k; cin >> m >> k;
  if(m == 1) {
    if(k == 0) cout << 0 << ' ' << 0 << ' ' << 1 << ' ' << 1 << endk;
    else cout << -1 << endk;
  } else if(k >= pow(2,m)) cout << -1 << endk;
  else {
    rep(i, 1<<m) if(i != k) cout << i << ' ';
    cout << k << ' ';
    rrep(i, (1<<m)) if(i != k) cout << i << ' ';
    cout << k << endk;
  }
  return 0;
}


Measured memory_bytes: 4000
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int N;
    cin>>N;
    int A=0;
    int B=0;
    vector<int> card(N);
    for(int i=0; i<N; i++){
        cin>>card.at(i);
    }
    sort(card.begin(),card.end());
    reverse(card.begin(),card.end());
    
    for(int j=0; j<N; j++){
        if(j%2==1){
            A=A+card.at(j);
        }
        else{
            B=B+card.at(j);
        }
    }
    
    cout<<B-A<<endl;
    return 0;

}


Measured memory_bytes: 256
n = int(input())
p_li = list(map(int,input().split()))
dum = 0
ans = 0
flag = 0
count = 0
for i in range(n):
    if i+1 == p_li[i]:
        ans += 1
        if flag == 1:
            if dum == i-1:
                count += 1
                flag = 0
        else:
            flag = 1
        dum = i

#div,mod = divmod(dum,2)
print(ans-count)


Measured memory_bytes: 13880
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
	ll n;
	cin>>n;
	vector<ll> a(n);
	vector<ll> b(n);
	vector<ll> c(n);
	
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
		cin>>b[i];
	for(int i=0;i<n;i++)
		cin>>c[i];	
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());
	ll ans = 0;
	for(int j=0;j<n;j++)
	{
		vector<ll>::iterator lower,higher;
		lower = lower_bound(a.begin(),a.end(),b[j]);
		ll i = lower - a.begin();
		higher = upper_bound(c.begin(),c.end(),b[j]);
		ll k = n - (higher - c.begin());
		ans += i*k;
	}
	cout<<ans;
	return 0;
}


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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

const int maxn = 41;

bool e[maxn][maxn];
ll dp[maxn][maxn][maxn];

//[l, r], s->selected

ll calc(int l, int r, int s) {
    if (l == r && s == l) {
        return 1;
    }
    if (dp[l][r][s] != -1) {
        return dp[l][r][s];
    }
    ll& res = dp[l][r][s];
    res = 0;
    for (int p = l; p < s; ++p) {
        for (int q = s + 1; q <= r; ++q) {
            if (!e[p][q]) continue;
            for (int u = p; u < s; ++u) {
                for (int v = s + 1; v <= q; ++v) {
                    res +=
                        calc(l, u, p) * calc(u + 1, v - 1, s) * calc(v, r, q);
                }
            }
        }
    }
    return res;
}

int main() {
    int N;
    cin >> N;
    N *= 2;
    rep(i, N) {
        string s;
        cin >> s;
        rep(j, N) e[i][j] = s[j] == '1';
    }
    memset(dp, -1, sizeof(dp));
    ll ans = 0;
    for (int to = 1; to < N; ++to)
        if (e[0][to]) {
            ans += calc(1, N - 1, to);
        }
    cout << ans << endl;
    return 0;
}

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

#define ll long long
#define mod 998244353

int main() {
    int n, x;
    cin >> n;
    int a[n];
    memset(a, 0, sizeof(a));
    ll res = 1;
    for (int i = 0; i < n; i++) {
        cin >> x;
        a[x]++;
        if (i == 0 and x != 0) res = 0;
    }
    if (a[0] != 1) res = 0;
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < a[i]; j++) {
            res *= a[i - 1];
            res %= mod;
        }
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    string a="aa",b="bb";
    a[0]=s[0];
    a[1]=s[1];
    b[0]=s[2];
    b[1]=s[3];
    
    bool aok=true,bok=true;
    
    if(a<"01" || a>"12") aok=false;
    if(b<"01" || b>"12") bok=false;
    
    if(aok && !bok) cout<<"MMYY"<<endl;
    else if(!aok && bok) cout<<"YYMM"<<endl;
    else if(aok && bok) cout<<"AMBIGUOUS"<<endl;
    else cout<<"NA"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
    if     (ch=='A')return 1;
    else if(ch=='C')return 2;
    else if(ch=='G')return 3;
    else if(ch=='T')return 4;
    else return 0;
}

long long getKey(char str[]){
    long long sum=0,p=1,i;
    for(i=0; i<strlen(str);i++){
        sum+=p*(getChar(str[i]));
        p*=5;
    }
    return sum;
}

int h1(int x){
    return x%M;
}
int h2(int x){
    return 1+(x%(M-1));
}

int find(char str[]){
    long long x,i,h;
    x=getKey(str);
    for(i=0;;i++){
        h=(h1(x)+i*h2(x))%M;
        if(strcmp(H[h],str)==0)return 1;
        else if(strlen(H[h])==0)return 0;
    }
    return 0;
}

int insert(char str[]){
    long long x,i,h;
    x=getKey(str);
    for(i=0;;i++){
        h=(h1(x)+i*h2(x))%M;
        if(strcmp(H[h],str)==0)return 1;
        else if(strlen(H[h])==0){
            strcpy(H[h],str);
            return 0;
        }
    }
    return 0;
}

int main(){
    int i,n,h;
    char str[L],com[9];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s %s",com,str);

        if(com[0]=='i'){
            insert(str);
        } else {
            if(find(str))printf("yes\n");
            else printf("no\n");
        }
    }
    return 0;
}


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

int main(){
  int N, K;   cin >> N >> K;
  string S;   cin >> S;
  if (S.at(K - 1) == 'A') S.at(K - 1) = 'a';
  else if(S.at(K - 1) == 'B') S.at(K - 1) = 'b';
  else if(S.at(K - 1) == 'C') S.at(K - 1) = 'c';
  cout << S;
}

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

#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define endl '\n'
#define int long long

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, a[N], x[N];

int32_t main()
{
	IOS
	//freopen("input.txt", "r", stdin);
	cin >> n;
	int sum = 0;
	for(int i=1; i<=n; i++){
		cin >> a[i];
		sum += a[i];
		if (i%2 == 0) sum -= 2*a[i];
	}
	x[1] = sum;
	for(int i=2; i<=n; i++){
		x[i] = 2*a[i-1] - x[i-1];
	}
	for(int i=1; i<=n; i++){
		cout << x[i] << ' ';
	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 2944
# -*- coding: utf-8 -*-
"""
Created on Sun May 20 20:55:50 2018
AGC024B
@author: maezawa
"""

n = int(input())
q = [None for _ in range(n)]
for i in range(n):
    p = int(input())
    q[p-1] = i+1

max_cnt = 0
cnt = 1
qpre = q[0]
 
for i in range(1,n):
    if q[i] > qpre:
        cnt += 1
    else:
        if max_cnt < cnt:
            max_cnt = cnt
        cnt = 1
    qpre = q[i]
if max_cnt < cnt:
    max_cnt = cnt

print(n-max_cnt)


Measured memory_bytes: 13000
n, a, b = map(int, input().split())

MOD = 10 ** 9 + 7

ans = pow(2, n, MOD) - 1
na = 1
for i in range(a):
    na *=(n - i)
    na %= MOD
    na *= pow(i + 1, MOD - 2, MOD)
    na %= MOD
ans -= na
nb = 1
for i in range(b):
    nb *= (n - i)
    nb %= MOD
    nb *= pow(i + 1, MOD - 2, MOD)
    nb %= MOD
ans -= nb
print(ans % MOD)

Measured memory_bytes: 67336
#include<stdio.h>

int main(){
  int n,i,j,ans;
  int t[100];
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    ans=0;
    for(i=0;i<n;i++){
      scanf("%d",&t[i]);
      for(j=0;j<i;j++){
        if(t[j]>t[i]){
          ans++;
        }
      }
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}

bool is_left_ok(ll i, std::string& s, std::vector< std::pair<char, ll> >& vq)
{
  for (auto q : vq) {
    if (s[i] == q.first) i += q.second;
    if (i < 0) return true;
    if (i >= (ll)s.size()) return false;
  }

  return false;
}

bool is_right_ok(ll i, std::string& s, std::vector< std::pair<char, ll> >& vq)
{
  for (auto q : vq) {
    if (s[i] == q.first) i += q.second;
    if (i < 0) return false;
    if (i >= (ll)s.size()) return true;
  }

  return false;
}


int main()
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  //std::ifstream ifs("input.def");
  //std::cin.rdbuf(ifs.rdbuf());

  ll N, Q;
  std::cin >> N >> Q;

  std::string s;
  std::cin >> s;

  std::vector< std::pair<char, ll> > vq(Q);
  for (ll i = 0; i < Q; i++) {
    char t, d;
    std::cin >> t >> d;
    vq[i].first = t;
    vq[i].second = d == 'L' ? -1 : +1;
  }

  ll left = -1;
  if (is_left_ok(0, s, vq)) {
    ll ok = 0;
    ll ng = N;
    while (ng - ok > 1) {
      ll mid = (ok + ng) / 2;
      if (is_left_ok(mid, s, vq)) {
	ok = mid;
      } else {
	ng = mid;
      }
    }
    left = ok;
  }

  ll right = N;
  if (is_right_ok(N-1, s, vq)) {
    ll ng = -1;
    ll ok = N-1;
    while (ok - ng > 1) {
      ll mid = (ok + ng) / 2;
      if (is_right_ok(mid, s, vq)) {
	ok = mid;
      } else {
	ng = mid;
      }
    }
    right = ok;
  }

  ll sum = std::max(0LL, right - (left + 1));
  print(sum);

  return 0;
}


Measured memory_bytes: 3732
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n=I()
lis=[[]for i in range(n)]
lis[0].append([1])
for i in range(n-1):
    for j in lis[i]:
        for m in range(max(j)+1):
            lis[i+1].append(j+[m+1])
        #print(max(j))
#print(lis[n-1])
alpha=["a","b","c","d","e","f","g","h","i","j"]
for u in lis[n-1]:
    ans=""
    for j in u:
        ans+=alpha[j-1]
    print(ans)

Measured memory_bytes: 27840
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可

const ll INF=1000000000000000000;

signed main(){
    ll n,k;
    cin>>n>>k;
    map<ll,ll> mp;
    for(ll i=1;i<=n;i++) mp[i%k]++;
    ll ans=0;
    ll cnt=mp[0];
    ans+=cnt;
    if(cnt>=3) ans+=cnt*(cnt-1)*(cnt-2);
    if(cnt>=2)ans+=3*(cnt-1)*cnt;
    if(k%2==0){
        k/=2;
        cnt=mp[k];
        ans+=cnt;
        if(cnt>=3) ans+=cnt*(cnt-1)*(cnt-2);
        if(cnt>=2)ans+=3*(cnt-1)*cnt;
    }
    cout<<ans<<endl;
}

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

int	main()
{
	const static int	inf = 2000 * 10000 + 1;
	int	V, E, r;
	cin >> V >> E >> r;
	vector<int>	v_cost(V, inf);
	map<int, map<int, int>>	e_cost;
	int	s, t, d;
	for (int i = 0; i < E; ++i) {
		cin >> s >> t >> d;
		if (!e_cost.count(s))
			e_cost[s] = map<int, int>();
		e_cost.at(s)[t] = d;
	}
	bool	updated = false;
	v_cost.at(r) = 0;
	int		tmp_cost;
	for (int i = 0; i < V; ++i) {
		updated = false;
		for (s = 0; s < V; ++s) {
			if (v_cost.at(s) == inf)
				continue;
			if (!e_cost.count(s))
				continue;
			for (auto pr : e_cost.at(s)) {
				t = pr.first;
				tmp_cost = pr.second + v_cost.at(s);
				if (tmp_cost < v_cost.at(t)) {
				   v_cost.at(t) = tmp_cost;
				   updated = true;
				}
			}
		}
		if (!updated)
			break;
	}
	if (updated) {
		cout << "NEGATIVE CYCLE" << endl;
		return 0;
	}
	for (int i = 0; i < V; ++i) {
		if (v_cost.at(i) == inf)
			cout << "INF" << endl;
		else
			cout << v_cost.at(i) << endl;
	}
}



Measured memory_bytes: 3292
/*
СТРОИМ СТЕНУ РАБОТЯГИ!
█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
*/
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
    
     
     
using namespace std;
template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; }
/** Interface */
     
inline int readChar();
template <class T = int> inline T readInt(); 
template <class T> inline void writeInt( T x, char end = 0 );
inline void writeChar( int x ); 
inline void writeWord( const char *s );
     
/** Read */
     
static const int buf_size = 4096;
     
inline int getChar() {
    static char buf[buf_size];
    static int len = 0, pos = 0;
    if (pos == len) {
        pos = 0, len = fread(buf, 1, buf_size, stdin);
    }
    if (pos == len) {
        return -1;
    }
    return buf[pos++];
}
     
inline int readChar() {
    int c = getChar();
    while (c <= 32) {
        c = getChar();
    }
    return c;
}
     
template <class T>
inline T readInt() {
    int s = 1, c = readChar();
    T x = 0;
    if (c == '-')
        s = -1, c = getChar();
    while ('0' <= c && c <= '9')
        x = x * 10 + c - '0', c = getChar();
    return s == 1 ? x : -x;
}
     
/** Write */
     
static int write_pos = 0;
static char write_buf[buf_size];
     
inline void writeChar( int x ) {
    if (write_pos == buf_size)
        fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
    write_buf[write_pos++] = x;
}
     
template <class T> 
inline void writeInt( T x, char end ) {
    if (x < 0)
        writeChar('-'), x = -x;
     
    char s[24];
    int n = 0;
    while (x || !n)
        s[n++] = '0' + x % 10, x /= 10;
    while (n--)
        writeChar(s[n]);
    if (end)
        writeChar(end);
}
     
inline void writeWord( const char *s ) {     while (*s)
writeChar(*s++); }
     
struct Flusher {
    ~Flusher() {
        if (write_pos)
            fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
    }
} flusher;   
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define left left228
#define right right228
#define next next228
#define rank rank228
#define prev prev228
#define y1 y1228   


string s;


int main() {
    cin >> s;
    cout << ((sz(s) >= 4 && s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') ? "Yes\n": "No\n");
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=1e5+9;
int a[N];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int l,r,k;
    cin>>k;
    cin>>l>>r;
    for(int i=l;i<=r;i++){
        if(i%k==0){ 
            cout<<"OK";
            return 0;
        }
    }
    cout<<"NG";
        
    
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n, x;
    cin >> n >> x;
    vector<int> m(n);
    rep(i, n) cin >> m[i];
    sort(m.begin(), m.end());
    int ans = 0;
    int i = 0;
    while(1) {
        int tmp_m;
        if ( i == n ) tmp_m = m[0];
        else          tmp_m = m[i];
        if ( x - tmp_m < 0 ) break;
        x -= tmp_m;
        ++ans; 
        if ( i < n ) i++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define CMAX(m, x)  m = max(m,x);
#define CMIN(m, x)  m = min(m,x);
#define itn int
typedef long long lint;
const int INF = 1e9;
const lint LINF = 1e18;
int main(){
    int n;
    cin >> n;
    if(n % 10 == 7){
        cout << "Yes"<<endl;
        return 0;
    } else{
        n /= 10;
        if(n % 10 == 7){
        cout << "Yes"<<endl;
        return 0;
        }else{
            n /= 10;
            if(n % 10 == 7){
                if(n % 10 == 7){
                    cout << "Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef struct res{
	int index;
	string s;
	int p;

	bool operator < (const res& r) const{
		if(r.s == s) return p > r.p;
		else return s < r.s;
	}
}RESTAURANT;

int main(){
	int N;
	cin >> N;
	vector<RESTAURANT> restaurant(N);
	for(int i = 0; i < N; i++){
		cin >> restaurant[i].s >> restaurant[i].p;
		restaurant[i].index = i+1;
	}
	sort(restaurant.begin(), restaurant.end());
	for(int i = 0; i < N; i++) cout << restaurant[i].index << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int H, W, t, ans = 0;
    int c[10][10];

    cin >> H >> W;

    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> c[i][j];
        }
    }

    for (int k = 0; k < 10; k++) {
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }
    for (int i = 0; i < W; i++) {
        for (int j = 0; j < H; j++) {
            cin >> t;
            if (t != -1) { ans += c[t][1]; }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        String s="CODEFESTIVAL2016";
        String in=scan.next();
        int cnt=0;
        for(int i=0;i<s.length();i++){
            if(in.charAt(i)!=s.charAt(i))
                cnt++;
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 10068
N = int(input())
H = [int(i) for i in input().split()]

dp = [0]*N
dp[1] = abs(H[0] - H[1])

if N == 2:
    print(dp[-1])

else:
    for i in range(2, N):
        dp[i] = min(dp[i-2] + abs(H[i]-H[i-2]), dp[i-1] + abs(H[i]-H[i-1]))
    print(dp[-1])

Measured memory_bytes: 13928
s = str(input())
if s == ('hi'):
    print('Yes')
elif s == ('hihi'):
    print('Yes')
elif s == ('hihihi'):
    print('Yes')
elif s == ('hihihihi'):
    print('Yes')
elif s == ('hihihihihi'):
    print('Yes')
else:
    print('No')



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

int main(void) {
  long long int n;
  scanf("%lld", &n);
  long long int res = n - 1;

  for (long long int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      long long int j = n / i - 1;
      if (i+j-1 < res) res = i+j-1;
    }
  }

  printf("%lld\n", res);

  return 0;
}


Measured memory_bytes: 128
n, m = gets.chomp.split(' ').map(&:to_i)

a = []
m.times do
  a << gets.chomp.to_i
end

fib = [1, 1, 2]
for i in 3..100000
  fib << fib[i-2] + fib [i-1]
end

a.push(n+1)

ds = []
ds << a[0] + 1
if a.count > 1
  for n in 1..(a.count-1)
    ds << a[n] - a[n-1] 
  end
end

if ds.include?(0) || ds.include?(1)
  puts 0
else
  prd = 1
  ds.each do |d|
    prd *= fib[d - 2]
  end
  puts (prd % 1000000007)
end



Measured memory_bytes: 453624
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9+7;
const ll inf_l = 1e18;
const int MAX = 1e6;

int main() {
    string x; cin >> x;
    stack<char> s;
    rep(i,x.size()) {
        if (x[i] == 'S') s.push(x[i]);
        else {
            if (s.size() != 0 && s.top() == 'S') s.pop();
            else s.push(x[i]);
        }
    }
    cout << s.size() << endl;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(abs(c-a) <= d || (abs(a-b) <= d && abs(b-c) <= d)) {
    cout << "Yes";
  }else{
	cout << "No";
  }
}

Measured memory_bytes: 256
package main
import (
   "fmt"
   "os"
   "bufio"
   "strconv"
)
var sc = bufio.NewScanner(os.Stdin)

func main() {
  sc.Split(bufio.ScanWords)
  for{
    first := nextInt()
    op := getStdin()
    second := nextInt()
    if op == "?" {
        break
    }
    if op == "+" {
      fmt.Println(first + second)
    }else if op == "-" {
      fmt.Println(first - second)
    }else if op == "*" {
      fmt.Println(first * second)
    }else if op == "/" {
      fmt.Println(first / second)
    }
  }
}

func getStdin() (string) {
    sc.Scan()
    v := sc.Text()
    return v
}

func nextInt() (int) {
    sc.Scan()
    v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}

func nextFloat() (float64) {
    sc.Scan()
    v, e := strconv.ParseFloat(sc.Text(), 64)
    if e != nil { panic(e) }
    return v
}


Measured memory_bytes: 1128
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;


int main(){FIN

    ll n;
    cin>>n;

    vector<double> a(n), b(n);
    REP(i,n) cin>>a[i]>>b[i];
    VSORT(a); VSORT(b);
    double low, high;
    if(n%2==0){
        low = (a[n/2-1] + a[n/2]) /2;
        high = (b[n/2-1] + b[n/2]) /2;
        cout<<ll((high-low) * 2 + 1)<<endl;
        return 0;
    } 

    low = a[(n-1)/2];
    high = b[(n-1)/2];
    cout << ll(high-low+1)<<endl;
    return 0;
}

Measured memory_bytes: 6376
#include<bits/stdc++.h>
using namespace std;
int zero,one;
int main()
{
    char ch[100009];
    scanf("%s",&ch);
    int len=strlen(ch);
    for(int i=0; i<len; i++)
    {
        if(ch[i]=='0')++zero;
        else if(ch[i]=='1')++one;
    }
    printf("%d\n",min(zero,one)*2);
}


Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <set>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
    ll N,M;
	cin >> N >> M;
	vector<ll> A(N);
	cin >> A[0];
	for(int i=1; i<N; i++){
		ll tmp;
		cin >> tmp;
		A[i]=tmp+A[i-1];
	}
	ll ans=0;
	map<int, int> mp;
	for(auto a: A){
		ll tmp=a%M;
		if(tmp==0) ans++;
		ans+=mp[tmp];
		mp[tmp]++;
	}
	cout << ans << endl;

	

    return 0;
}


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

using namespace std;

int main(){
	string str1, str2;
	cin >> str1 >> str2;
	int len1 = str1.size();
	int len2 = str2.size();

	int dp[len1+1][len2+1];
	memset(dp, 0, sizeof(dp));

	for(int i=1;i<=len1;i++){
		for(int j=1;j<=len2;j++){
			if(str1[i-1] == str2[j-1])
				dp[i][j] = 1 + dp[i-1][j-1];
			else
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		}
	}
	string ans = "";
	int i=len1;
	int j=len2;
	while(i!=0 && j!=0){
		if(dp[i][j] == dp[i-1][j])
			i--;
		else if(dp[i][j] == dp[i][j-1])
			j--;
		else {
			ans = str1[i-1] + ans;
			i--;
			j--;

		}

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

}


Measured memory_bytes: 38768
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#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 <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

#define INF 93193111451418101
#define LEP(a, n) for(int a = 0; a < n; ++a)
#define FOR(a, s, n) for(int a = s; a < n; ++a)

#define IN std::cin
#define OUT std::cout
using std::endl;

#define LL long long int
#define ll long long int

#define itn int
#define fro for

int main()
{

	ll X, Y, ans = 0;;

	IN >> X >> Y;

	while (true)
	{
		if (X <= Y) ans++;
		else break;
		X *= 2;
	}

	OUT << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
m=(n-1)*(n-2)//2
c=0
if k>m:
    print(-1)
else:
    e=n-1+m-k
    print(e)
    i=0
    while c<e:
        for j in range(i+1,n):
            if c<e: print(i+1,j+1)
            c+=1
        i+=1

Measured memory_bytes: 42736
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>
#include <cfenv>
#include <random>
#include <numeric>
#include <cmath>
#include <iosfwd>
#include <iostream>
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cstdlib>

#define SIZE 100002
typedef long long ll;
 
using namespace std;
 
const long long INF = 1LL << 60;
int main(){
     ll h[SIZE];
     int N;
     cin >> N;
     for(int i = 0 ; i < N ; i++){
         cin >> h[i];
     }
     ll DP[SIZE];
     for(int i = 0 ; i < SIZE ; i++){
        DP[i] = INF;    
     }
     DP[0] = 0;
     for(int i = 1 ; i < N ; i++){
         ll tmp = DP[i - 1] + abs(h[i] - h[i - 1]);
         if(DP[i] > tmp){
             DP[i] = tmp;
         }
         if(i > 1){
           tmp = DP[i - 2] + abs(h[i] - h[i - 2]);
            if(DP[i] > tmp){
                 DP[i] = tmp;
            }
         }
     }
     cout << DP[N-1];
     return 0;
 }

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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

    int H, W, A, B;
    std::cin >> H >> W >> A >> B;

    REP(hi, H) {
        REP(wi, W) {
            if(wi < A) {
                if(hi < B) {
                    std::cout << 1;
                }
                else {
                    std::cout << 0;
                }
            }
            else {
                if(hi < B) {
                    std::cout << 0;
                }
                else {
                    std::cout << 1;
                }
            }
        }
        std::cout << std::endl;
    }

    return 0;
}


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

int main()
{
    set<int> s1, s2;
    int n, m;

    cin >> n;
   
    int a;

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

    cin >> m;

    for( int i = 0; i < m; i++ )
    {    
        cin >> a;
        s2.insert(a);
    }

    set<int>::iterator itr1 = s1.begin(), itr2 = s2.begin();
    for(; itr1 != s1.end() && itr2 != s2.end(); )
    {
        if( *itr1 < *itr2 )
        {
            cout << *itr1 << endl;
            itr1++;
        }
        else if( *itr1 > *itr2 )
        {       
            cout << *itr2 << endl;
            itr2++;
        }
        else
        {    
            itr1++;
            itr2++;
        }
    }

    for(; itr1 != s1.end(); itr1++ )
        cout << *itr1 << endl;

    for(; itr2 != s2.end(); itr2++ )
        cout << *itr2 << endl;

    return 0;
}


Measured memory_bytes: 21812
#include<iostream>
#include<vector>

using namespace std;

int main(){

  string s,t;
  
  cin>>s>>t;
  
  vector<int>start(26,-1);
  vector<int>goal(26,-1);
  
  for(int i=0; i<s.size();i++){
    int a=s[i]-'a';
    int b=t[i]-'a';
    
    if(start[a] != -1 || goal[b] != -1){
      if(start[a] != b || goal[b] != a){
        cout<<"No"<<endl;
        return 0;
      }
    }
    
    start[a]=b;
    goal[b]=a;
    
  }
  
  cout<<"Yes"<<endl;

  return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std ;

 
int main()
{
	ios::sync_with_stdio(false) ;

	string s ;

	cin >> s ;

	int ans = 0 ;
	char cur = s[0] ;

	for(int i = 0 ; i < s.size() ; i++)
	{
		char tmp = s[i] ;

		if(tmp != cur)
		{
			cur = tmp ;
			ans++ ;
		}
	}

	cout << ans ;
	
	return 0;
} 

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define INF 1e9

void init()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
}

int main()
{
    init();
    char c;
    cin>>c;
    if('A'<=c && c<='Z')cout<<'A'<<endl;
    else
        cout << 'a' << endl;
}


Measured memory_bytes: 3580
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<list>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
#define MK make_pair
const ll E=1e18+7;
const ll MOD=1000000007;

pll Ex_Euc(ll a,ll b){
    if(b==0){return {1,0};}
    pll ret=Ex_Euc(b,a%b);
    ret.F-=a/b*ret.S;
    return {ret.S,ret.F};
}




int main(){
    ll n,m;
    cin>>n>>m;
    pll ans=Ex_Euc(n,m);
    cout<<ans.F<<" "<<ans.S<<endl;
    
    
    return 0;
}



Measured memory_bytes: 3116
public class Main {
	
	public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		String in = scan.nextLine();
		String[] ins = in.split(" ");
		int n = Integer.parseInt(ins[0]);
		int m = Integer.parseInt(ins[1]);
		int[] count = new int[n];
		for(int i=0; i<n; i++){
			count[i] = 0;
		}
		for(int i=0; i<m; i++){
			String ab = scan.nextLine();
			String[] tmp = ab.split(" ");
			int a = Integer.parseInt(tmp[0]);
			int b = Integer.parseInt(tmp[1]);
			count[a-1]++;
			count[b-1]++;
		}
		for(int i=0; i<n; i++){
			System.out.println(count[i]);
		}
	}
}

Measured memory_bytes: 23508
n = gets.to_s.to_i
a = gets.to_s.split.map{|e|e.to_i}.sort.reverse

if a[-1] == 0
  puts 0
  exit
end

ans = 1
inf = 10 ** 18
a.each do |t|
  ans *= t
  if ans > inf
    puts "-1"
    exit
  end
end

puts ans

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N; ll x; cin >> N >> x;
  ll a[N]; rep(i,N) cin >> a[i];
  ll mi[N][N];
  rep(i,N) {
    if (i==0) rep(j,N) mi[i][j] = a[j];
    else rep(j,N) mi[i][j] = min(mi[i-1][(j+N-1)%N], mi[i-1][j]);
  }
  ll result = LLINF;
  rep(i,N) {
    ll tmp = 0; rep(j,N) tmp += mi[i][j];
    result = min(result, tmp+x*i);
    // rep(j,N) cout << mi[i][j] << " "; cout << endl;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 31488
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Xinyi Tao
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AHarmonyABC135 solver = new AHarmonyABC135();
        solver.solve(1, in, out);
        out.close();
    }

    static class AHarmonyABC135 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            if (a == b) out.println(0);
            else if ((a + b) % 2 == 1) out.println("IMPOSSIBLE");
            else out.println((a + b) / 2);
        }

    }
}



Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    int N;
    string S;
    cin >> N >> S;
    map<pair<string, string>, long> first, second;
    for(int i = 0; i < (1 << N); i++){
        pair<string, string> first_string, second_string;
        for(int j = 0; j < N; j++){
            if((i >> j) & 1){
                first_string.first.push_back(S[j]);
                second_string.first.push_back(S[N * 2 - j - 1]);
            }else{
                first_string.second.push_back(S[j]);
                second_string.second.push_back(S[N * 2 - j - 1]);
            }
        }
        first[first_string]++;
        second[second_string]++;
    }
    long ans = 0;
    for(auto i: first){
        ans += i.second * second[{i.first.second, i.first.first}];
    }
    cout << ans << endl;
}


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

int main() {

  int H, W;
  cin >> H >> W;
  
  vector<string> a(H);
  for (int i = 0; i < H; i++) {
    cin >> a[i];
  }

  vector<bool> deleteH(H);
  vector<bool> deleteW(W);

  for (int i = 0; i < H; i++) {
    bool valid = true;
    for (int j = 0; j < W; j++) {
       if (a[i][j] == '#') {
         valid = false;
       }
    }
    if (valid) {
      deleteH[i] = true;
    }
  }

  for (int i = 0; i < W; i++) {
    bool valid = true;
    for (int j = 0; j < H; j++) {
       if (a[j][i] == '#') {
         valid = false;
       }
    }
    if (valid) {
      deleteW[i] = true;
    }
  } 

  for (int i = 0; i < H; i++) {
    if (!deleteH[i]) {
      for (int j = 0; j < W; j++) {
        if (!deleteW[j]) {
          cout << a[i][j];
        }
      }
      cout << endl;
    }
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define v vector
#define ll long long 
#define vpll vector<pair<long long,long long> > 
#define F first
#define S second
#define mp make_pair
#define lf long float
#define pb push_back
 
using namespace std; 
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    map<multiset<char>,ll> m;
    set<multiset<char> > p;
    for(ll i = 0 ; i < n ; i++)
    {
        multiset<char> temp;
        string s;
        cin>>s;
        for(int i = 0 ; i < 10 ; i++)
        {
            temp.insert(s[i]);
        }
        p.insert(temp);
        if(m.find(temp) == m.end())
        m[temp] = 1;
        else
        m[temp]++;
    }
    ll ans = 0;
    std::set<multiset<char> >::iterator it;
    for(it = p.begin() ; it != p.end() ; it++)
    {
        ll temp = m[*it];
        ans += (temp*(temp-1))/2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 112768
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <functional>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)					(a).begin(),(a).end()
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						(1000 * 1000 * 1000 * 2)
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int n;
	static int wordCnt[26][50];
	cin >> n;
	REP(i, n) {
		string str;
		cin >> str;
		REP(j, str.size()) {
			wordCnt[str[j] - 'a'][i]++;
		}
	}

	string ans;
	REP(i, 26) {
		int minMum = 100;
		REP(j, n) {
			minMum = min(minMum, wordCnt[i][j]);
		}
		REP(j, minMum) {
			ans += ('a' + i);
		}
	}

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



Measured memory_bytes: 256