akhauriyash/Code-Regression huggingface dataset:
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

def warshall_floyd(d,n):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k] + d[j][k])

    return d

N, M, L = list(map(int, input().split()))

d = [[INF for j in range(N)] for i in range(N)]
for i in range(M):
    a, b, c = map(int,input().split())
    d[a-1][b-1] = c
    d[b-1][a-1] = c

d = warshall_floyd(d, N)

dd = [[INF for j in range(N)] for i in range(N)]
for i in range(N):
    for j in range(i+1, N):
        if d[i][j] <= L:
            dd[i][j] = 1
            dd[j][i] = 1

dd = warshall_floyd(dd, N)

Q = int(input())
for q in range(Q):
    s, t = map(int, input().split())
    ans = dd[s-1][t-1]-1
    if ans == INF-1:
        print(-1)
    else:
        print(ans)



Measured memory_bytes: 83500
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long ans = 0;
        long cnt = 1;
        while(h >= 1){
            ans += cnt;
            h /= 2;
            cnt *= 2;
        }
        System.out.println(ans);
    }
}
 

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

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

    int n;
    cin >> n;
    string s;
    cin >> s;

    int total[n] = {};
    
    total[0] = (s[0] == 'E');
    for(int i = 1; i < n; i++){
        total[i] += (s[i] == 'E') + total[i - 1];
    }

    int ans = 1e9;
    for(int i = 0; i < n; i++){
        if(i > 0){
            ans = min(ans, total[n - 1] - total[i] + (i - total[i - 1]));
        }else{
            ans = min(ans, total[n - 1] - total[i]);
        }
    }

    cout << ans << endl;



    return 0;
}

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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

struct edge{
	int from, to;
	edge(int from, int to):from(from), to(to){}
};
using node = vector<edge>;
using graph = vector<node>;
void addedge(graph &g, int from, int to, bool bidirectional = false){
	g[from].emplace_back(edge(from, to));
	if(bidirectional)g[to].emplace_back(edge(to, from));
}

class Solution {
public:
	void solve() {
		int n;
		cin >> n;
		vector<vector<int>> idx(n, vector<int>(n, 0));
		int cnt = 0;
		for(int i=0; i < n; i++)for(int j=i+1; j < n; j++)idx[i][j] = idx[j][i] = cnt++;
		graph g(cnt);
		vector<vector<int>> a(n, vector<int>(n-1, 0));
		vector<int> in(cnt, 0);
		for(int i=0; i<n; i++)for(int j=0; j<n-1; j++)cin >> a[i][j];
		for(int i=0; i<n; i++)for(int j=0; j<n-1; j++)a[i][j]--;
		for(int i=0; i < n; i++)for(int j=1; j < n-1; j++)addedge(g, idx[i][a[i][j-1]], idx[i][a[i][j]]), in[idx[i][a[i][j]]]++;
		queue<int> q[2];
		for(int i=0; i < cnt; i++)if(in[i] == 0)q[0].push(i);
		int ret = 0;
		while(1){
			ret++;
			while(!q[0].empty()){
				int tmp = q[0].front();
				q[0].pop();
				cnt--;
				for(auto e: g[tmp]){
					in[e.to]--;
					if(in[e.to] == 0)q[1].push(e.to);
				}
			}
			if(q[1].empty())break;
			swap(q[0], q[1]);
		}
		if(cnt)ret = -1;
		cout << ret << "\n";
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 37376
#include<bits/stdc++.h>
#define rep(i, x) for (ll i = 0; i < (x); i++)

using namespace std;
typedef long long int ll;
// {{{ Modint
// using mint = modint<1000000007>;
// mint x = 2;
// mint y = mint::P(5, 2);
// std::cout << x.a << std::endl;
template <std::int64_t M>
class modint {
 public:
  int64_t a;
  static vector<modint> fact;
  static vector<modint> inv_fact;
  explicit constexpr modint(const int64_t x = 0) noexcept :
    a((x % M + M) % M) {}
  constexpr int64_t &value() noexcept { return a; }
  constexpr const int64_t &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= M) {
      a -= M;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += M;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % M;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    int64_t exp = M - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
  constexpr modint pow(ll t) const {
    if (!t) return modint(1);
    modint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  static modint P(ll n, ll k) {
    if (fact.size() == 0) {
      const ll T = 3000000;
      fact.resize(T, modint(1));
      inv_fact.resize(T, modint(1));
      for (ll i = 2; i < T; i++) fact[i] = fact[i-1] * modint(i);
      for (ll i = 2; i < T; i++) inv_fact[i] = inv_fact[i-1] / modint(i);
    }
    if (n < k) return modint(0);
    if (n < 0 || k < 0) return modint(0);
    return fact[n] * inv_fact[n - k];
  }

  static modint C(ll n, ll k) {
    if (n < k) return modint(0);
    if (n < 0 || k < 0) return modint(0);
    return P(n, k) * inv_fact[k];
  }
};
template <std::int64_t M>
vector<modint<M>> modint<M>::fact;
template <std::int64_t M>
vector<modint<M>> modint<M>::inv_fact;
// }}}

using mint = modint<1000000007>;

int main(void) {
  ll N, M;
  cin >> N >> M;
  auto C = mint::P(M, N);
  auto E = mint(0);
  for (ll i = 1; i <= N; i++) {
    E += mint(-1).pow(i+1) * mint::C(N,i) * mint::P(M-i,N-i);
  }
  auto D = mint::P(M, N) - E;
  cout << (C * D).value() << endl;
  return 0;
}


Measured memory_bytes: 50228
# include<stdio.h>
#include <stdlib.h>
int main()
{
	long double A, B;
	int r;
	r=scanf("%Lf%Lf", &A,&B);
	if (r == 2)
	{
		if (A == B)
		{
			printf("EQUAL\n");
		}
		if (A > B)
		{
			printf("GREATER\n");
		}
		if (A < B)
		{
			printf("LESS\n");
		}
	}
	system("pause");
}

Measured memory_bytes: 504
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
//#include<algorithm>
//#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(ll X) {
	int keta = 0;
	char C[11];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

ll mod = 1e9 + 7;
ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}

const int IMAX = 100001;
ll fac[IMAX + 1], ifac[IMAX + 1];
inline ll comb(int A, int B) {
	return fac[A] * ifac[B] % mod * ifac[A - B] % mod;
}

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


	fac[0] = 1;
	rep1(i, IMAX) fac[i] = fac[i - 1] * i % mod;
	ifac[IMAX] = modpow(fac[IMAX], mod - 2);
	for (int i = IMAX; i > 0; i--) ifac[i - 1] = ifac[i] * i % mod;

	int N = getint();
	int A[100001] = {};
	int kazu = 0;
	rep1(i, N) {
		int a = getint();
		if (A[a]) kazu = A[a] + N - i;
		else A[a] = i;
	}

	rep1(i, N + 1) {
		ll kotae = comb(N + 1, i);
		if (kazu >= i - 1) {
			kotae = kotae - comb(kazu, i - 1);
			if (kotae < 0) kotae += mod;
		}
		putint(kotae);
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
//#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////



#define MAX_N (ll)2E4///変更！！！！！！！
vector<ll>prime;
bool is_prime[MAX_N+1];
void precal(){
    rep(i,0,MAX_N)is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    rep(i,2,MAX_N){
        if(is_prime[i]){
            prime.pb(i);
            for(ll j=2*i;j<=MAX_N;j+=i)is_prime[j]=false;
        }
    }
}
vector<l_l> fact(ll n){
    vector<l_l>v;
    for(ll p:prime){
        if(p*p>n)break;
        ll c=0;
        while(n%p==0){
            n/=p;
            c++;
        }
        if(c)v.pb(l_l(p,c));//pという素因数がc個入っている
    }
    if(n!=1){
        ll vsize=v.size();
        if(vsize>=1&&v[vsize-1].first==n)v[vsize-1].second++;
        else v.pb(l_l(n,1));
    }
    if(v.size()==0){
        v.pb(l_l(1,1));
    }
    return v;
}
/////////////////////////////////////////////////////


ll po(ll i,ll p){
    if(p==0)return 1;
    else{
        i=mod(i);
        if(p==1)return i;
        if(p%2==0)return po(mod(i*i),p/2);
        return mod(i*po(i,p-1));
    }
}
ll bunbo(ll n){
    return po(n,i_5);
}

int main(){fastio
    precal();
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    map<ll,ll>mp;
    rep(i,0,n-1){
        vector<l_l>v=fact(a[i]);
        for(auto x:v){
            if(x.fi==1)continue;
            Max(mp[x.fi],x.se);
        }
    }
    ll ret=1;
    for(auto x:mp){
        ret=mod(ret*po(x.fi,x.se));
    }
    //cout<<ret<<endl;
    ll sum=0;
    rep(i,0,n-1){
        Add(sum,ret*bunbo(a[i]));
    }
    cout<<sum<<endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <map>
#include <string.h>
#include <math.h>
#include <set>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(a) (a).begin(), (a).end()
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<long> a(n);
    rep(i,n) cin >> a[i];
    sort(All(a));
    vector<long> b(n);
    b[0] = a[0];
    for(int i = 1; i < n; i++){
        b[i] = b[i-1] + a[i];
    }
    int cnt = 1;
    int k = n-1;
    while(k > 0){
        if(a[k] <= b[k-1] * 2) cnt++;
        else break;
        k--;
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
    int n, p, a;
    cin >> n >> p;
    
    bool e = true;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a % 2) e = false;
    }
    
    ll ans;
    if (e) ans = (p == 0 ? pow(2, n) : 0);
    else ans = pow(2, n-1);
    
    cout << ans << endl;
}


Measured memory_bytes: 256
n, k, q = map(int, input().split())
point = [k-q for _ in range(n)]
for i in range(q):
    idx = int(input()) - 1
    point[idx] += 1
for j in range(len(point)):
    if point[j] > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 7848
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

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

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<ll> A,B,C;
void input(){
    fast_io();
    cin >> N;
    A = fetch_vec<ll>(N);
    B = fetch_vec<ll>(N);
    C = fetch_vec<ll>(N);
    sort(begin(A),end(A));
    sort(begin(B),end(B));
    sort(begin(C),end(C));
}

vector<ll> count_num(vector<ll> up, vector<ll> bottom, vector<ll> count){
    vector<ll> ret;
    vector<ll> count_sum(N+1,0);
    for (size_t i = 0; i < N; i++) count_sum[i+1] = count_sum[i] + count[i];
    
    for (size_t i = 0; i < N; i++)
    {
        auto itr = upper_bound(begin(bottom),end(bottom),up[i]);
        ll idx = itr - bottom.begin();
        ll cnt = count_sum[N] - count_sum[idx];
        ret.push_back(cnt);
    }
    return ret;
}

int solve(){
    vector<ll> cnt_init(N,1);
    auto cnt_sec = count_num(B,C,cnt_init);
    auto cnt_thr = count_num(A,B,cnt_sec);
    ll ans = accumulate(begin(cnt_thr),end(cnt_thr),0LL);
    cout << ans << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 9140
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ky112233
 */
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);
        BATCoder solver = new BATCoder();
        solver.solve(1, in, out);
        out.close();
    }

    static class BATCoder {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String str = in.next();
            Set<Character> set = new HashSet<>();
            set.add('A');
            set.add('C');
            set.add('G');
            set.add('T');
            int j = 0;
            int mx = 0;
            for (int i = 0; i < str.length(); i++) {
                if (set.contains(str.charAt(i))) {
                    mx = Math.max(mx, i - j + 1);
                } else {
                    j = i + 1;
                }
            }
            out.println(mx);
        }

    }
}



Measured memory_bytes: 23764
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
# import math
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)
def gcd(x,y):
    if(x<y):
        x,y=y,x
    if(y==0):
        return x
    return gcd(y,x%y)

n=l()[0]
A=l()
ans=A[0]
for i in range(1,n):
    ans=gcd(ans,A[i])
print(ans)


Measured memory_bytes: 16304
k = int(input())

from math import gcd

#gcd_sum = [0] * 201
ans = 0

'''
for i in range(1, k+1):
    for j in range(1, k+1):
        gcd_sum[i] += gcd(i,j)
        #print(gcd(i,j))
        #print(gcd_sum[i])
'''
       
for a in range(1,k+1):
    for b in range(1,k+1):
        g = gcd(a,b)
        for c in range(1,k+1):
            ans += gcd(g,c)
        #print(g)
        #print(ans)

print(ans)

Measured memory_bytes: 68552
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    for(int i=1; i<=N; i++){
        if((i*108-(i*108%100)) == N*100){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
#define A 1
#define C 2
#define G 3
#define T 4
int n;
int mem[101][5][5][5];
long MOD = 1e9+7;
long dfs(int p, int c3 ,int c2, int c1){
    if(mem[p][c3][c2][c1] != -1) return mem[p][c3][c2][c1];
    if(p == n) return 1;
    long a = 0;
    a += dfs(p+1, c2, c1, A);
    a += dfs(p+1, c2, c1, T);
    if(!(c1 == C && c2 == A))
        a += dfs(p+1, c2, c1, G);
    if(!(c1 == G && c2 == A || c1 == A && c2 == G ||
        c1 == G && c3 == A || c2 == G && c3 == A))
        a += dfs(p+1, c2, c1, C);
    a = a % MOD;
    mem[p][c3][c2][c1] = a;
    return a;
}
int main(){
    memset(mem, -1, sizeof(mem));
    cin >> n;
    cout << dfs(0, 0, 0, 0) << endl;
}

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

#define MAX (10^5)

int main(void) {
  int N = 0;
  //int A[MAX] = {0};
  //int X[MAX] = {0};
  cin >> N;

  vector<int> A(N);
  vector<int> X(N);

  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  
  int a[2];
  {
    int sum = 0;
    for(int i = 0; i < N; i+=2) {
      //sum += A[i];
      sum += A.at(i);
    }
    for(int i = 1; i < N; i+=2) {
      //sum -= A[i];
      sum -= A.at(i);
    }
    X[0] = sum;
  }
  for(int j = 0; j < N - 1;j++) {
    X[j+1] = 2 * A[j] - X[j]; 
  }
  for(int j = 0; j < N; j++) {
    cout << X[j] << " ";
  }
  
  cout << endl;
  
  return 0; 
}

Measured memory_bytes: 2048
import java.util.Scanner;

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

    int S_len = S.length();
    int T_len = T.length();

    int same_char = 0;
    int longlen = 0;
    int ans = 0;
    int k = 0;

    int hikaku_len = S_len - T_len + 1;

    for (var i = 0;i<hikaku_len;i++){
      same_char = 0;
      k = i;
      for (var j = 0;j < T_len;j++){
        if ( S.charAt(k) == T.charAt(j) ) {
          same_char++;
        }
        k++;
      }
      if (longlen < same_char){
        longlen = same_char;
      }
    }

    ans = T_len - longlen;

    System.out.println(ans);
    scan.close();
  }
}

Measured memory_bytes: 35552
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/
int A, B;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> A >> B;
    int ans = (A - 1) * (B - 1);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(a,b)<<" ";
    if (a+b>=n) {
        cout<<(a+b)-n;
    } else {
        cout<<0;
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
   int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if(W >= x + r && x - r >= 0 && H >= y + r && y - r >= 0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


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

long long dfs (string s, int count) {

  if (count == s.size() - 1) {

    vector<string> s_(s.size());
    int current = 0;

    for (int i = 0; i < s.size(); i++) {
      if (s[i] != '+') {
        s_[current] += s[i];
      } else {
        current++;
      }
    }

    long long result_ = 0;

    for (int i = 0; i < s_.size(); i++) {
      result_ += atoll(s_[i].c_str());
    }

    return result_;

  }

  long long result = 0;

  // +を入れない
  result += dfs(s, count + 1);

  // +を入れる
  s = s.substr(0, count + 1) + "+" + s.substr(count + 1);

  result += dfs(s, count + 2);

  return result;

}

int main() {

  string S;
  cin >> S;

  cout << dfs(S, 0) << endl;
  
  return 0;

}

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

int main(void){
   ll n;cin>>n;
   map<string,ll> mp;
   rep(i,n){
       string s;cin>>s;
       sort(s.begin(),s.end());
       mp[s]++;
   }
   ll res=0;
   for(auto& p:mp){
       ll buf=p.second;
       res+=buf*(buf-1)/2;
   }
   cout<<res<<endl;
}




Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
using namespace std;


main()
{
	ios_base::sync_with_stdio(false);
	cout.tie(nullptr);
	int n,m;
	cin>>m>>n;
	vector<int>a(n);
	int s=0;
	for(int i=0;i<n;i++)
    {
        cin>>a[i];
        s+=a[i];
    }
    if(s>m) return cout<<-1,0;
    cout<<m-s;
}


Measured memory_bytes: 3704
#include<iostream>

using namespace std;

int main(){
    int N;
    int a[7] = {1,2, 4, 8, 16, 32, 64};

    cin >> N;
    for (int i = 1; i < 7;i++){
        if(a[i]>N){
            cout << a[i-1];
            return 0;
        }
    }
    cout << "64";
}

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

int main(){
  int n;
  ll a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  for(int i=0;i<n;i++){
    int j=n-i-1;
    ll maxb=a+i*d-j*c;
    ll minb=a+i*c-j*d;
    if(minb<=b&&b<=maxb){
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
}

Measured memory_bytes: 3592
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1e5+10;
struct node
{
	int num,dis;
	friend bool operator < (node p,node q)
	{
		return p.dis<q.dis;
	}
}a[N];
int n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i].dis);
		a[i].num=i;
	}
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++)
		printf("%d ",a[i].num);
	return 0;
}

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

using namespace std;

#define int long long

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

const int MAXN = 10000;

int pr[MAXN][256];

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 0; i < n; ++i)
    {
        pr[i + 1]['R' - 'A'] = pr[i]['R' - 'A'] + (bool)(s[i] == 'R');
        pr[i + 1]['G' - 'A'] = pr[i]['G' - 'A'] + (bool)(s[i] == 'G');
        pr[i + 1]['B' - 'A'] = pr[i]['B' - 'A'] + (bool)(s[i] == 'B');
    }
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        for (int j = i + 1; j < n; ++j)
        {
            set<char> a = {'R', 'G', 'B'};
            if (s[i] == s[j])
            {
                continue;
            }
            a.erase(s[i]);
            a.erase(s[j]);
            if (i - (j - i) >= 0 && (*a.begin()) == s[i - (j - i)])
            {
                --ans;
            }
            ans += pr[i][(*a.begin()) - 'A'];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11576
#include <iostream>
#include <fstream>
#include <algorithm>       // for next_permutation
#include <vector>
#include <queue>
#include <bits/stl_numeric.h>

#define DEBUG 0
#define REP(i, n) for (long long i = 0; i < (n); i++) 
using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;


int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    //先頭がiで終わるやつの数
    //先頭がiで終わるやつの数

    vector <vector<int> > sen(10, vector<int>(10, 0));

    for(int i = 1; i <= N; ++i)
    {
        string tmp = to_string(i);

        sen[tmp[0] - '0'][tmp[tmp.size()-1] - '0']++;
    }

    int res = 0;
    for(int i = 1; i <= 9; ++i)
    {
        for(int j = 1; j <= 9; ++j)
        {
            //
            res += sen[i][j] * sen[j][i];
        }
    }



    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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 T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


// 入力
int N;
long long a[100010][3]; // a[i], b[i], c[i] をそれぞれまとめて a[i][0], a[i][1], a[i][2] にしてしまう

// DP テーブル
long long dp[100010][3];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];


    //遷移
    for (ll i = 0;i<N;i++) {
        for (ll j = 0;j<3;j++) {
            for (ll k = 0;k<3;k++) {
                if (j==k) continue;
                chmax(dp[i+1][k],dp[i][j] + a[i][k]);
            }
        }
    }
    ll ans = max(dp[N][0],dp[N][1]); //dp[i] はi日目なので注意,
    ans = max(ans,dp[N][2]);         //N日目はN-1でなく、dp[N]なので注意
    cout << ans << endl;
}

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


int topdown(int*a,int*dp,int n)
{
	dp[n-1]=0;
	dp[n-2]=abs(a[n-1]-a[n-2]);

	for(int i=n-3;i>=0;i--)
	{
		dp[i]=min(abs(a[i]-a[i+1])+dp[i+1] , abs(a[i]-a[i+2])+dp[i+2]);
	}
	return dp[0];
}

int main()
{  	
  	int dp[100000];
	int n,a[100000];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];

	cout<<topdown(a,dp,n);

	return 0;
}


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

vector<int> forintinput(int n) {
	vector<int> x(100000);
	for(int i = 0;i < n;i++) cin >> x[i];
	return x;
}
int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a == b && b == c){
		cout << "No" << endl;
	}else{
		if(a == b || b == c || c == a){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
}

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

int main()
{
    int n, sum = 0;
    vector<int> w;
    cin >> n;
    w.resize(n);
    for (int i = 0; i < n; i++)
    {
        cin >> w[i];
        sum += w[i];
    }
    int minsum = 1e7, karui, omoi;
    for (int t = 0; t < n; t++)
    {
        karui = omoi = 0;
        for (int i = 0; i < n; i++)
        {
            if (t < i)
                omoi += w[i];
            else
                karui += w[i];
        }
        // cout << t << " " << omoi << " " << karui << endl;
        int a = abs(omoi - karui);
        if (a < minsum)
            minsum = a;
    }
    cout << minsum << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"

using namespace std;
//vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x0f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m) { return (a + (abs(a) / m) * m + m) % m; }

int main() {
    IOS

    string st;
    cin >> st;
    vector<string> v = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    for (int i = 0; i < 7; ++i) {
        if (st == v[i]) {
            cout << 7 - i;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

using namespace std;

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

int main(){
    int result;
    int K;
    cin >> K;
    result=0;

    for(int a=1; a<=K; a++){
        for(int b=1; b<=K; b++){
            for(int c=1; c<=K; c++){
                result += gcd(a, gcd(b, c));
            }
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <cstring>
using namespace std;
typedef long long ll;
const int mod=998244353;
const int N=3010;
ll f[N][N][2];
int a[N];
int main()
{
    int n,s;
    cin>>n>>s;
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    for(int i=0;i<=n;i++)f[i][0][0]=1;
    // f[0][0][1]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=s;j++)
        {
            (f[i][j][0]+=f[i-1][j][0])%=mod;
            if(j>=a[i]){
                (f[i][j][0]+=f[i-1][j-a[i]][0])%=mod;
            }
        }
    }
    ll sum=0;
    for(int i=1;i<=n;i++)(sum+=f[i][s][0])%=mod;
    cout<<sum<<endl;
}

Measured memory_bytes: 141568
main = do
  (n:a:b:_) <- map read . words <$> getContents
  print $ sum $ filter (decSumIn a b) [1 .. n]

decSumIn a b n = a <= s && s <= b
  where s = decSum n

decSum n
  | q == 0 = r
  | otherwise = decSum q + r
  where (q, r) = n `divMod` 10


Measured memory_bytes: 892
#include "bits/stdc++.h"
#define int long long int
using namespace std;
const int N = 1e6 + 2; 

int32_t main() {
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);    
    int a , b;
    cin >> a >> b;
    cout << max(0ll , a - 2 * b );   

    return 0;
}

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

using ll = long long;
using pp = pair<ll,ll>;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)

int main(){
	string s,t;
	cin >> s >> t;
	int count = 0;
	if(s[0] == t[0])count++;
	if(s[1] == t[1])count++;
	if(s[2] == t[2])count++;
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define vl vector<long long>
long long INF = 1e10;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
/******************************define**********************************/

/*****************************functions********************************/

/****************************main function*****************************/
int main(void){
    int N; cin >> N;
    priority_queue<int> pr;
    for(ll i = 0;i < N;i++){
        int p; cin >> p;
        pr.push(p);   
    }
    int M; cin >> M;
    priority_queue<int> st;
    for(ll i = 0;i < M;i++){
        int s; cin >> s;
        st.push(s);
    }
    while(!st.empty()){
        if(pr.empty()){
            cout << "NO" << endl;
            return 0;
        }
        int s = st.top();
        int p = pr.top();
        pr.pop();
        if(p < s){
            cout << "NO" << endl;
            return 0;
        }else if(s == p){
            st.pop();
            continue;
        }else{
            continue;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 2548
import java.util.*;
 
class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      List<Integer> list = new ArrayList<Integer>();
      List<Integer> listAns = new ArrayList<Integer>();
      for(int i=1; i<N; i++){
        list.add(sc.nextInt());
      }
      for(int i=0; i<N; i++){
        listAns.add(0);
      }
      for(int i=1; i<N; i++){
        listAns.set(list.get(i-1) - 1, listAns.get(list.get(i-1) - 1) + 1);
      }
      for(Integer ans : listAns){
        System.out.println(ans); 
      }
    }
}

Measured memory_bytes: 67128
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
        int i,j;
        String str;
        int a,b;
        while(true){
            a=scan.nextInt();
            b=scan.nextInt();
            if(a==0&&b==0)System.exit(0);
            str="";
            for(i=0;i<b;i++)str=str+"#";
            for(i=0;i<a;i++)System.out.println(str);
            System.out.println();
        }
   }
}


Measured memory_bytes: 27320
#include<stdio.h>

int main(void)
{
	int a, b;
	scanf("%d %d", &a, &b);
	int d = a / b;
	int r = a%b;   //あまり（整数）
	double f = (double)a / (double)b;
	

	printf("%d %d %f\n", d, r, f);

	return 0;
}


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

int main(void) {
    int i, n;
    double x[100], y, tmp, p0, p1, p2, p3;
    p0 = p1 = p2 = p3 = 0;

    scanf("%d", &n);
    for(i = 0; i < n; i++) {
        scanf("%lf", x + i);
    }

    for(i = 0; i < n; i++) {
        scanf("%lf", &y);
        tmp = fabs(*(x + i) - y);
        p0 < tmp && (p0 = tmp);
        p1 += tmp;
        p2 += tmp * tmp;
        p3 += tmp * tmp * tmp;
    }

    printf("%f\n%f\n%f\n%f\n", p1, sqrt(p2), cbrt(p3), p0);
    return 0;
}

Measured memory_bytes: 672
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

M=0
i=0

while i < N:
  M += B[A[i]-1]
  if i>=1:
    if A[i]-A[i-1]==1:
      M +=  C[A[i-1]-1]
  i += 1

print(M)

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

long int M = 1e+9+7;
int main(void){
    int x;
    cin >> x;
 
    ll a,b,d=0;
    bool flag=false;
    while(!flag){
        ll pa = pow(d,5),ma = -pa;
        if(pa > x){
            rep(j,1){
                ll sa = pa-pow(j,5);
                if(sa > x) continue;
                else if(sa < x) break;
                else{
                    a = d; b = j;
                    flag = true;
                }
            }
        }else if(pa < x){
            for(int j= -1; 1; j--){
                ll sa = pa-pow(j,5);
                if(sa < x) continue;
                else if(sa > x) break;
                else{
                    a = d; b = j;
                    flag = true;
                }
            }
        }else if(pa == x){
            a = d; b = 0;
            flag = true;
        }


        for(int j= -1; 1; j--){
            ll sa = ma-pow(j,5);
            if(sa < x) continue;
            else if(sa > x) break;
            else{
                a = -d; b = j;
                flag = true;
            }
        }

        d++;
    }

    cout << a << " " << b << endl;
    return 0;
}

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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  int eat_day = (a * -1) + b;
  if (eat_day <= 0) {
    cout << "delicious" << endl;
  }
  else if (eat_day <= x) {
    cout << "safe" << endl;
  }
  else {
    cout << "dangerous" << endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define tp(A, B, C) tuple<A, B, C>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define si set<int>
#define msi map<string, int>
#define rsz(a) resize(a)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> a, pair<int, int> b){return a.se < b.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define pt(a, b, c) emplace_back(make_tuple(a, b, c))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; ++i)
#define foris(i, a, b) for(ll i = a; i < b; ++i)
#define forise(i, a, b) for(ll i = a; i <= b; ++i)
#define ford(i, n) for(ll i = n; i >= 0; --i)
#define fords(i, a, b) for(ll i = a; i >= b; --i)
#define fordse(i, a, b) for(ll i = a; i > b; --i)
#define fora(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define umap unordered_map
#define uset unordered_set
#define pq(T) priority_queue<T>
#define rpq(T) priority_queue<T, vector<T>, greater<T> >
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;
int digits(int n) {
  n = abs(n);
  if(n < 10) return 1;
  elif(n < 100) return 2;
  elif(n < 1000) return 3;
  elif(n < 10000) return 4;
  elif(n < 100000) return 5;
  elif(n < 1000000) return 6;
  elif(n < 10000000) return 7;
  elif(n < 100000000) return 8;
  elif(n < 1000000000) return 9;
  else return 10;
}


int main() {
  io();
  
  int n;
  cin >> n;
  double a = (double)(n)/3.0;
  double b = a * a * a;
  cout << fixed << setprecision(12) << b;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  rep(ki, k)
  {
    vector<int> b(n + 1);
    rep(i, n)
    {
      int l = max(0, i - a[i]);
      int r = min(n, i + a[i]+1);
      b[l]++;
      b[r]--;
    }

    rep(i, n)
    {
      b[i + 1] += b[i];
    }

    b.pop_back();
    if (a == b)
      break;
    a = b;
  }
  rep(i, n)
  {
    cout << a[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 4844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N+1];
		for(int i = 1; i < N+1; i++){
			a[i] = sc.nextInt();
		}
		sc.close();

		int prev = 0;
		int cur = 1;
		int count = 0;

		while(cur != 2 && cur != 0){
			prev = cur;
			cur = a[cur];
			a[prev] = 0;
			count++;
		}
		if(cur == 2){
			System.out.println(count);
		}
		else{
			System.out.println(-1);
		}
	}

}


Measured memory_bytes: 53020
import collections
N = int(input())
S = ["".join(sorted(input())) for i in range(N)]
c = collections.Counter(S).values()
cand = list(c)
cand = [i for i in cand if i > 1]
for i in range(len(cand)):
    cand[i] = cand[i]*(cand[i]-1)//2
print(sum(cand))

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

int main(){
long long  n,m,x;
  x=0;
  cin>>n>>m;
  vector<long long> h(n);
  vector<long long> a(m);
  vector<long long> b(m);
  vector<long long> sum(n);
  for(int i=0;i<n;i++){
cin>>h.at(i);
  }
  for(long long i=0;i<m;i++){
cin>>a.at(i)>>b.at(i);
  }
  for(long long i=0;i<m;i++){
  if(h.at(a.at(i)-1)<=h.at(b.at(i)-1)){
sum.at(a.at(i)-1)=1;
  }
      if (h.at(a.at(i)-1)>=h.at(b.at(i)-1)){
sum.at(b.at(i)-1)=1;
    }
  }
          for(long long i=0;i<n;i++){
            if(sum.at(i)==0){
x++;
            }
          }
cout<<x<<endl;
          }
            
          


Measured memory_bytes: 6420
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    string s;
    cin >> s;
    int n = s.length();
    string s2 = s;
    reverse(s2.begin(), s2.end());
    int res = 0;

    if (s == s2) res++;

    string s3 = "";
    rep(i, (n - 1) / 2) {
        s3 += s[i];
    }
    string s4 = s3;
    reverse(s4.begin(), s4.end());
    if (s3 == s4) res++;

    string s5 = "";
    rep(i, (n - 1) / 2) {
        s5 += s2[i];
    }
    string s6 = s5;
    reverse(s6.begin(), s6.end());
    if (s6 == s5) res++;
    
    if (res == 3) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, M, A[1010101];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M;
	rep(i, 0, M) cin >> A[i];

	ll tot = 0;
	rep(i, 0, M) tot += A[i];

	if (N < tot) cout << -1 << endl;
	else cout << N - tot << endl;
}







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

vector<vector<int>> g;
vector<int> dep;
bool poss = 1;

pair<int, int> dfs(int x, int d) {
  pair<int, int> ret = {0, 0};
  if (d&1)  ret.first++;
  else ret.second++;
  dep[x] = d;

  for (auto to : g[x]) {
    if (dep[to] != -1) {
      poss &= (dep[x] - dep[to])&1;
    } else {
      auto p = dfs(to, d + 1);
      ret.first += p.first;
      ret.second += p.second;
    }
  }
  return ret;
}

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int n, m;
  cin >> n >> m;

  dep.resize(n, -1);
  g.resize(n);
  vector<vector<bool>> cg(n, vector<bool> (n, 1));

  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;

    --u; --v;
    cg[u][v] = cg[v][u] = 0;
  }

  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (cg[i][j]) {
        g[i].push_back(j);
        g[j].push_back(i);
      }
    }
  }

  vector<pair<int, int>> comp;
  for (int i = 0; i < n; ++i) {
    if (dep[i] != -1) continue;
    comp.push_back(dfs(i, 0));
  }

  if (!poss) {
    cout << -1 << '\n';
    return 0;
  }

  vector<bool> dp(n + 1, 0);
  dp[0] = 1;

  for (int i = 0; i < (int)comp.size(); ++i) {

    vector<bool> cur(n + 1, 0);
    int x = comp[i].first, y = comp[i].second;
    for (int j = n; j >= 0; --j) {
      if (!dp[j]) continue;
      if (j + x <= n) cur[j + x] = 1;
      if (j + y <= n) cur[j + y] = 1;
    }
    dp = cur;
  }

  int ans = n * (n - 1) / 2;
  for (int i = 1; i <= n; ++i) {
    if (dp[i]) {
      ans = min(ans, (i * (i-1) + (n-i) * (n-i-1)) / 2);
    }
  }

  cout << ans << '\n';
}


Measured memory_bytes: 3328
n, k = map(int, input().split())
sn = [i for i in range(1, n+1)]
sn = set(sn)
l = []
for i in range(k):
    d = int(input())
    mini_l = list(map(int, input().split()))
    l.extend(mini_l)

l = set(l)
ans = len(sn - l)
print(ans)

Measured memory_bytes: 9216