akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
ll n;
ll dp[405][405];
ll pre[405],a[405];
int main(){FAST;
cin>>n;
for(ll i=1;i<=n;++i){
  cin>>a[i];
  pre[i] = pre[i-1]+a[i];
}
for(ll len = 2;len <= n;++len){
  for(ll i=1,j=i+len-1;j<=n;++i,++j){
    dp[i][j] = INF;
    for(ll mid=i;mid<j;++mid){
      dp[i][j] = min(dp[i][mid]+dp[mid+1][j]+pre[j]-pre[i-1],dp[i][j]);
    }
  }
}
cout<<dp[1][n];
return 0;
}

/*
 WA? check edge cases, N=1,M=1 etc. Read code fully once and check all variables.
 Read the question again and see what you might have missed.
 Consider changing your solution or find more cases.
 */


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

#define ll long long int
#define endl '\n'

void testCase()
{
    //ll t; cin>>t; while(t--)
    {
        ll n;
        cin>>n;
        ll m=n;
        vector<pair<ll,ll>>v;
        while(n--)
        {
            ll x,y;
            cin>>x>>y;
            v.push_back({x,y});
        }

        bool flag=false;
        for(int i=0;i<v.size();i++)
        {
            ll cnt=0;
            flag=false;
            for(int j=i;j<v.size();j++)
            {
                if(v[j].first==v[j].second)
                cnt++;
                if(v[j].first!=v[j].second)
                cnt=0;

                if(cnt==3)
                {
                    cout<<"Yes\n";
                    flag=true;
                    break;
                }
            }
            if(flag)
            break;
        }
        if(!flag)
        cout<<"No";
    }   
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    testCase();
    return 0;
}

Measured memory_bytes: 3628
N, M = gets.split.map(&:to_i)
#As = Array.new(2)
#Bs = Array.new(2)

arr = []

d_n = 0
cost = 0


N.times do |i|
  a, b = gets.split.map(&:to_i)
  arr.push([a, b])
end

arr.sort! { |a, b| a[0] <=> b[0] }



N.times do |i|

 if (d_n + arr[i][1] >= M)
   cost += (M - d_n) * arr[i][0]
   break
 end

 d_n += arr[i][1]  
 cost += arr[i][1] * arr[i][0]

end

puts cost

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

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

int main()
{
    int N, Q;
    cin >> N >> Q;
    vector<vector<int>> data(N, vector<int>(3));
    REP(i, N){
        cin >> data[i][1] >> data[i][2] >> data[i][0];
        data[i][1] -= data[i][0];
        data[i][2] -= data[i][0];
    }
    set<pair<int,int>> s;
    REP(i, Q){
        int D;
        cin >> D;
        s.insert({D,i});
    }

    sort(data.begin(), data.end());

    vector<int> ans(Q, -1);
    REP(i, N){
        auto itr = s.lower_bound({data[i][1], -1});
        while(itr != s.end() and itr != s.upper_bound({data[i][2], -1})){
            ans[(*itr).second] = data[i][0];
            s.erase(itr++);
        }
    }

    REP(i, Q) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 23040
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define VS vector<string>
int main(void) {                                                                                     
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a*b>c*d) cout << a*b << endl;
    else cout << c*d << endl;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;

int main() {
	int ans = INF;
	int n;
	cin >> n;
	int a[100];
	for (int i = 0; i < n; i++)cin >> a[i];
	
	for (int i = -100; i <= 100; i++) {
		int sum = 0;
		for (int j = 0; j < n; j++) {
			sum += abs(a[j] - i)*abs(a[j] - i);
		}
		ans = min(sum, ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
int dp[1100][5500];
void chmin(int &a,int b){
    if(a > b)a = b;
}
const int INF = 1e18;
signed main(){
    rep(i,1100)rep(j,5500)dp[i][j] = INF;
    int n,m;cin >>n >> m;
    vector<P> res(m);
    dp[0][0] = 0;
    rep(i,m){
        int a,b;cin >> a >> b;
        int tmp = 0;
        while(b--){
            int x;cin >> x;
            x--;
            tmp |= 1<<x;
        }
        res[i] = P(tmp,a);
    }
    rep(i,m)rep(j,1<<n){
        chmin(dp[i+1][j|res[i].first],dp[i][j]+res[i].second);
        chmin(dp[i+1][j],dp[i][j]);
    }
    int ret = dp[m][(int)(1<<n)-1];
    if(ret == INF)ret = -1;
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 50900
// =====================================================
//   File    :   main.cpp
//   Author  :   eezyl
//   Synopsis:   codeforces/atcoder template
//   Address :
//   Date    :   2020/08/15
// =====================================================

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

#define rep(i, a, b) for (int i = (a); i < int(b); ++i)
typedef long long LL;

const int INF = (1<<31)-1;
const LL LL_INF = (1ll << 63)-1;
const int MOD = 1e9+7;

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

void solve() {
    int n;
    cin >> n;
    vector<LL> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    if (n < 3) {
        printf("0\n");
        return;
    }
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            if (a[i] == a[j])
                continue;
            for (int k = j+1; k < n; ++k) {
                if (a[k] == a[j])
                    continue;
                if (a[i]+a[j] > a[k])
                    ++ans;
            }
        }
    }
    cout << ans << endl;
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
//#define LOCAL
#ifdef LOCAL
freopen("data.in", "r", stdin);
while (!feof(stdin)) {
#endif // LOCAL

    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }

#ifdef LOCAL
}
printf("Time used = %.2lf\n", (double)clock() / CLOCKS_PER_SEC);
#endif // LOCAL
    return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int x, y;
    
    while (1) {
        scanf("%d %d", &x, &y);
        
        if (x == 0 && y == 0) {
            break;
        }else if (x < y) {
            printf("%d %d\n", x, y);
        }else {
            printf("%d %d\n", y, x);
        }
    }
    
    return 0;
}



Measured memory_bytes: 1976
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n;
	cin >> n;
	vector<int> cards(n);
	for (int i=0; i<n; i++) {
		cin >> cards[i];
	}

	sort(cards.begin(), cards.end());
	reverse(cards.begin(), cards.end());
	
	int dif = 0;
	for (int j=0; j<n; j++) {
		if (j%2 == 0) {
			dif += cards[j];
		}
		else{
			dif -= cards[j];
		}
	}

	cout << dif << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
 
int main () {
string a,b,c;
  cin >> a >> b >>c;
  cout << "A" << b[0] << "C";
}


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

using namespace std;

int main()
{
	long long int N;
	while(cin >> N , N)
	{
		map<string , pair<long long int , long long int>>data;
		set<string>IO;
		bool f = false;
		string today;
		for(size_t i = 0; i < N; i++)
		{
			string MD , who;
			cin >> MD;
			int h , m;
			char c;
			cin >> h >> c >> m;
			cin >> c;
			cin >> who;
			if(c == 'I')
			{
				if(who == "000")
				{
					f = true;
					for(auto x : IO)
					{
						data[x].first = h * 60 + m;
					}
				} else
				{
					IO.insert(who);
					if(f)
					{
						data[who].first = h * 60 + m;
					}
				}
			} else
			{
				if(who == "000")
				{
					f = false;
					for(auto x : IO)
					{
						data[x].second += h * 60 + m - data[x].first;
					}
				} else
				{
					IO.erase(who);
					if(f)
					{
						data[who].second += h * 60 + m - data[who].first;
					}
				}
			}
		}
		long long int ans = 0;
		for(auto x : data)
		{
			if(x.second.second > ans)
			{
				ans = x.second.second;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1272
#include <stdio.h>

int main(){
	int i,n,m;
	int num[8];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		int max=0;
		int min=0;
		scanf("%d",&m);
		int j,k;
		for(j=0;j<8;j++){
			num[j]=m%10;
			m/=10;
		}
		for(j=0;j<8;j++){
		for(k=j;k<8;k++){
			int t;
			if(num[j]>num[k]){
				t=num[j];
				num[j]=num[k];
				num[k]=t;
			}
		}
		}
		
		for(j=0;j<8;j++){
			min+=num[j];
			if(j<7)min*=10;
		}
		for(j=7;j>=0;j--){
			max+=num[j];
			if(j>0)max*=10;
		}
		printf("%d\n",max-min);
	}
	return 0;
}

Measured memory_bytes: 600
n=int(input())
a=list(map(int,input().split()))
d=[0]*(2*10**5+1)
ans=0
for i in a:
  d[i]+=1
for v in d:
  ans+=v*(v-1)//2
for i in range(n):
  v=d[a[i]]
  print(ans-v*(v-1)//2+(v-1)*(v-2)//2)

Measured memory_bytes: 26140
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define INF 9223372036854775807
#define MOD 1000000007
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

//-------------------------------------------------------------------------------

#define MAX 10000

int main(void) {
  cin >> s;
  ans = INF;
  FOR(i, 0, s.length() - 1) {
	ans = s[i] != s[i + 1] ? min(ans, max(i + 1, (ll)s.length() - i - 1)) : ans;
  }
  if (ans == INF) ans = s.length();
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    if(k == 0){
        cout << (n * (long long)n) << endl;
        return 0;
    }

    long long ans = 0;
    for(int b=k+1; b<=n; ++b){
        ans += (n + 1) / b * (b - k);
        int x = (n + 1) % b;
        ans += max(0, x - k);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import deque

# 入力
n, m = map(int, input().split())
path = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    path[a].append(b)
    path[b].append(a)

# BFSで大きさの最大を求める
## DFSでもよい
ans = 0
visited = [0] * n
queue = deque()
for i in range(n):
    if visited[i]: continue
    now = i
    queue.append(now)
    visited[now] = 1
    size = 0
    while queue:
        now = queue.popleft() # popleft()をpop()に変えるとDFSになる
        size += 1
        for nxt in path[now]:
            if visited[nxt]: continue
            queue.append(nxt)
            visited[nxt] = 1
    ans = max(ans, size)

# 出力
print(ans)


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

#define ll long long
#define ull unsigned long long

using namespace std;


struct Edge {
	int to, id;
};

using Graph = vector<vector<Edge>>;

int degree;
vector <int> edgeColor;

void dfs(const Graph& graph, int v, int p, int pcolor) {
	int color = 1;
	for (auto tmp : graph[v]){
		int nv = tmp.to;
		int idx = tmp.id;
		if (nv == p) continue;
		if (color == pcolor){
			color++;
		}
		edgeColor[idx] = color;
		dfs(graph, nv, v, color);
		color++;
	}
}

int main() {
	//木の構造を与える
	int N;
	cin >> N;

	Graph graph(N);
	for (int ii = 0; ii < N-1; ++ii){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		Edge e1, e2;
		e1.to = b; e1.id = ii;
		e2.to = a; e2.id = ii;
		graph[a].push_back(e1);
		graph[b].push_back(e2);
	}

	//最大次数を求める
	degree = 0;
	for (int ii = 0; ii < N-1; ++ii){
		degree = max(degree, (int)graph[ii].size());
	}

	//初期化
	edgeColor.assign(N-1, 0);

	int root = 0;
	dfs(graph, /*v=*/root, /*p=*/-1, /*pcolor=*/0);

	cout << degree << endl;
	for (int ii = 0; ii < N-1; ++ii){
		cout << edgeColor[ii] << endl;
	}

	return 0;
}


Measured memory_bytes: 11024
#include <iostream>
#include <string>
using namespace std;
int main() {
	int k, x;
	cin >> k >> x;
	for (int i = x - k + 1; i < k + x; i++) {
		cout << i;
		if (i != k + x - 1) {
			cout << " ";
		}
	}
	cout << endl;
	return 0;
}

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

bool    F(long &m, vector<long> &w, long &k) {
    long S=0;
    long j=1;
    for (long i=0; i<w.size(); i++) {
        if (m<w.at(i))
            return false;
        if (m>=S+w.at(i))
            S +=w.at(i);
        else {
            S=w.at(i);
            j++;
            if (j>k)
                return false;
        }
    }
    return true;
}

int main() {
    long n, k;
    cin >>n >>k;
    vector<long> w(n);
    for (long i=0; i<n; i++)
        cin >>w.at(i);
    long l=0;
    long r=10000000000;
    long m=(l+r)/2;
    while (r-l>1) {
        m=(r+l)/2;
        if (F(m, w, k))
            r=m;
        else
            l=m;
    }
    cout <<r <<endl;
    return 0;
}


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

int edges[110][110];
bool picked[110];
int n,m;

// ??????u??\?????????????????????????±?(u??????
// ?????????????????????????±????????¨????????????§????????????????????????????????\?????????????????°??????
// (= ???????????????????????¢??????????????????
int _solve(int u) {
    // ?????¨?????¶??????????????¢????¨????
    int ret = 0;
    for (int i=0; i<n; ++i) if (picked[i]) {
        int score = 999999999;
        for (int j=0; j<n; ++j) if (i != j && picked[j]) {
            score = min(score, edges[i][j]);
        }
        ret += score;
    }
 
    for (int i=u; i<n; ++i) if (!picked[i]) { // ?¬?????????¶?????????????£?
        // ????????????????????¨????????¨????????£?????????
        bool ok = true;
        for (int k=0; k<n; ++k) if (picked[k]) {
            if (edges[i][k] == 0) {
                ok = false;
                break;
            }
        }
        if (ok) {
            picked[i] = true;
            ret = max(ret, _solve(i + 1));
            picked[i] = false;
        }
    }
   return ret;
}

int solve() {
    int ret = 0;
    for (int i=0; i<n; ++i) {
        for (int j=i+1; j<n; ++j) if (edges[i][j]) { // ?????????2??????????????¶
            picked[i] = picked[j] = true;
            ret = max(ret, _solve(max(i,j) + 1));
            picked[i] = picked[j] = false;
        }
    }
    return ret;
}

int main() {
    cin >> n >> m;
    for (int i=0; i<m; ++i) {
        int u,v,f; cin >> u >> v >> f;
        u--; v--;
        edges[u][v] = edges[v][u] = f;
    }

    cout << solve() << endl;

    return 0;
}

Measured memory_bytes: 3112
n=int(input())

if n == 1:
    print(1)
    exit()

ball_xy = []
for _ in range(n):
    x, y = (int(x) for x in input().split())
    ball_xy.append([x, y])

distance = {}

for i in range(n):
    for j in range(n):
        if i == j:
            continue
        if (ball_xy[i][0]-ball_xy[j][0], ball_xy[i][1]-ball_xy[j][1]) in distance:
            distance[(ball_xy[i][0]-ball_xy[j][0], ball_xy[i][1]-ball_xy[j][1])] += 1
        else:
            distance[(ball_xy[i][0]-ball_xy[j][0], ball_xy[i][1]-ball_xy[j][1])] = 1

cost_0 = max(distance.values())

print(n-cost_0)

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



int main(){

    int N; cin >> N;
    set<int> A;
    rep(i, N){
        int tmp; cin >> tmp;
        A.insert(tmp);
    }

    if((int)A.size()==N){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long ll;
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

int main()
{
    ll N, M;
    cin >> N >> M;
    ll max = M / N;

    vector<ll> yakusu;

    for(ll i = max;i >= 1;i--)
    {
        // cout << "i" << i << endl;
        if(M % i == 0)
        {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n)  RFOR(i,0,n)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
#define P pair<int,int>
#define PPi pair<P,int>
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};
const int MAX_V = 100;
const int MAX_E = 1000;

struct edge{ int from,to,cost,No;};
int V,E;
vector<edge> G[MAX_V];
int d[MAX_V];
int pd[MAX_V];

int used[MAX_E];

#define T tuple<int,int,int>

void dijkstra(int s){
	priority_queue<T,vector<T>,greater<T>> que;
	fill(d,d+V,INF);
	fill(pd,pd+V,-1);

	d[s]=0;
	que.push(T(0,s,-1));

	while(!que.empty()){
		T p=que.top();
		que.pop();

		int v=get<1>(p);
		if(d[v]<(get<0>(p))) continue;

		if(get<2>(p)!=-1) used[get<2>(p)]=1;

		REP(i,(int)G[v].size()){
			edge e=G[v][i];
			if(d[e.to]>d[v]+e.cost){
				d[e.to]=d[v]+e.cost;
				pd[e.to]=v;
				que.push(T(d[e.to],e.to,e.No));
			}
		}
	}
}

vector<int> get_path(int t){
	vector<int> path;
	for(;t!=-1;t=pd[t]) path.pb(t);
	reverse(path.begin(),path.end());
	return path;
}


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

	fill(used,used+MAX_E,0);
	cin>>V>>E;

	edge e;
	REP(i,E){
		cin>>e.from>>e.to>>e.cost;
		e.from--; e.to--; e.No=i;
		G[e.from].pb(e);
		swap(e.from,e.to);
		G[e.from].pb(e);
	}
	REP(i,V) dijkstra(i);
	
	int result=0;
	REP(i,E) if(used[i]==0) result++;
	print(result);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
  
/*------------------------------------------------------------------*/

int main(){
    ll n, p; cin >> n >> p;
    ll ans = 1;
    if(n == 1){
        cout << p << endl;
        return 0;
    }
    if(n >= p){
        cout << 1 << endl;
        return 0;
    }

    _rep(i, 1, 1000001){
        if(p % ll(pow(i, n)) == 0) ans = i;
        if(ll(pow(i, n)) > p) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * Greatest Common Divisor
 *
 */
public class Main {
    
    public static void main(String[] args) {
        // input data
        List<String> input = inputLines();
        
        // get data
        int counter = 0;
        
        // main logic
        for (String target : input) {
            counter += isPrimeNumber(Integer.valueOf(target)) ? 1 : 0;
        }
        output(counter);
    }

    private static boolean isPrimeNumber(int n) {
        if (n < 2) {
            return false;
        }
        if (n == 2) {
            return true;
        }
        
        // ??¶??°
        if (n % 2 == 0) {
            return false;
        }
        
        // ?\???°
        for (int i = 3; i <= n / i; i += 2) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }
    
    private static List<String> mocups() {
        List<String> input = Arrays.asList(
                "6",
                "1",
                "3",
                "6",
                "4",
                "5",
                "17",
                "3"
                );
        return input;
    }

    /** output data */
    private static void output(Object o) {
        System.out.println(o);
    }
    private static void output(String[] o) {
        System.out.println(Arrays.toString(o));
    }
    private static void output(int[] o) {
        System.out.println(Arrays.toString(o));
    }
    private static void output(Object[] o) {
        System.out.println(Arrays.toString(o));
    }

    /** input data */
    private static List<String> inputLines() {
        Scanner in = new Scanner(System.in);
        List<String> input = new ArrayList<String>();
        while(in.hasNext()) {
            String buf = in.nextLine();
            input.add(buf);
        }
        in.close();
        return input;
    }

}

Measured memory_bytes: 58380
N, Q = map(int,input().split())
S = input()
lr = [list(map(int,input().split())) for _ in range(Q)]

dp = [0]*(N+1)
for i in range(N):
  if S[i:i+2]=="AC":
    dp[i+1] = dp[i] +1
  else:
    dp[i+1] = dp[i]

for i in range(Q):
  print(dp[lr[i][1]-1]-dp[lr[i][0]-1])

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

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

    int norm_height = h[0];
    int possible_location_number = 0;
    for (int i=0;i<n;i++){
        if (norm_height <= h[i]){
            norm_height = h[i];
            possible_location_number += 1;
        }
    }
    cout<<possible_location_number<<endl;
    return 0;
}


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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!{
      n: usize,
      s: chars,
    }

    use std::collections::HashMap;
    let is_ok = |len| {
        let mut seen = HashMap::new();
        for i in 0..n-len+1 {
            let k = &s[i..i+len];
            if seen.contains_key(k) {
                let idx = seen[k];
                if idx+len <= i {
                    return true;
                }
            } else {
                seen.insert(k, i);
            }
        }
        false
    };
    let mut ng = n as i64;
    let mut ok = 0;
    while (ok-ng).abs() > 1 {
        let mid = (ok + ng) / 2;
        if is_ok(mid as usize) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    puts!("{}\n", ok);
}


Measured memory_bytes: 4352
#include<stdio.h>

#define NIL -1
#define MAX 100000

typedef struct Node {
  int left;
  int right;
  int p;
} node;

node T[MAX];
int n;

void preParse(int u);
void inParse(int u);
void postParse(int u);



int main(void){
  int x;
  int l,r;
  int i;
  int root;

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    T[i].p = NIL;
  }

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

    T[x].left = l;
    T[x].right = r;

    if(l != NIL){
      T[l].p = x;
    }
    
    if(r != NIL){
      T[r].p = x;
    }
    
  }

  for(i = 0;i < n;i++){
    if(T[i].p == NIL){
      root = i;
    }
  }

  puts("Preorder");
  preParse(root);
  puts("");
  
  puts("Inorder");
  inParse(root);
  puts("");
  
  puts("Postorder");
  postParse(root);
  puts("");

  return 0;
}
  
	      

       




void preParse(int u){
  if(u == NIL){
    return;
  }
  printf(" %d",u);

  preParse(T[u].left);
  preParse(T[u].right);
}


void inParse(int u){
  if(u == NIL){
    return;
  }

  inParse(T[u].left);
  printf(" %d",u);
  inParse(T[u].right);
}


void postParse(int u){
  if(u == NIL){
    return;
  }

  postParse(T[u].left);
  postParse(T[u].right);
  printf(" %d",u);
}



Measured memory_bytes: 2104
import itertools
n=int(input())
l=[i for i in range(1,n+1)]
p=list(map(int,input().split()))
q=list(map(int,input().split()))
m=list(itertools.permutations(l))
for i in range(len(m)):
  if p==list(m[i]):
    p=i
  if q==list(m[i]):
    q=i
print(abs(p-q))

Measured memory_bytes: 8052
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int a,b,i,x,cnt;
	x=1;
	cnt=0;
	cin>>a>>b;
	while(1){
		if(x-b>=0) break;
		x=x+a-1;
		cnt=cnt+1;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e5+10 , OO = 0x3f3f3f3f ;
//const int mod = 1000000007;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
double startTime;
double getCurrentTime() {
	return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define xloop(i,a,b) for(int i = int(a);i <= int(b);i++)
#define range(vec) for(auto &x : vec) cin >> x;
#define ALL(v) ((v).begin()) , ((v).end())
#define SZ(v)  ((int)((v).size()))
//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction

int n , weight;
int w[105] , v[105] ;
ll dp[105][100005];

ll solve(int idx , int remV){

    if(idx >= n){
        if(remV == 0) return 0;
        return 1LL*OO*OO;
    }
    ll &ret = dp[idx][remV];
    if(~ret) return ret;
    ret = 1LL*OO*OO;
    ret = min(ret  , solve(idx+1 , remV));
    if(remV >= v[idx])
        ret = min(ret , solve(idx+1 , remV-v[idx]) + w[idx]);
    return ret;
}



int main()
{
    startTime = (double)clock();
    #ifndef ONLINE_JUDGE
        //freopen("in.in", "r", stdin);
        //freopen("out.in", "w", stdout);
    #endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
    
    cin >> n >> weight;
    int sum = 0;
    for(int i =  0 ; i  < n ; ++i){
        cin >> w[i] >> v[i];
        sum += v[i];
    }
    clr(dp , -1);
    for(int value = sum ; value >= 0 ; --value){
        ll leastW = solve(0 , value);
        if(leastW <= weight){
            cout << value << "\n";
            return 0;
        }

    }



    return 0;
}

Measured memory_bytes: 82304
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define mod2 998244353
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define sz(v) ((ll)(v).size())
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
	#define forn(i,n) for (ll i=0; i<(n); ++i)
	#define fornd(i,n) for (ll i=(n)-1; i>=0; --i)
	#define forab(i,a,b) for (ll i=(a); i<=(b); ++i)
	#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
	using namespace std;
	bool isPowerOfTwo(int x) {
    return x && (!(x & (x - 1)));
	}
	int takemod(int x) {
    return (x % mod + mod) % mod;
	}
 
	int fpow(int base, int power, int MOD) {
    int result = 1;
    base = base % MOD;
    while (power) {
        if (power & 1)
            result = (result * base) % MOD;
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result;
	}
 
	int modinv(int x) {return fpow(x, mod - 2, mod);}
    ll prime[int(1e7+10)]={0}; 
	#define N 10000010
void Sieve(ll n) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    //memset(prime, true, sizeof(prime)); 
  
    for (ll p=1; p<=N+10; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
         
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p; i<=N+10; i += p) 
                	prime[i]++; 
         
    } 
  
    // Print all prime numbers 
    
} 
	void solve()
	{
		ll n;cin>>n;
		unsigned long long ans=0;
		Sieve(n);
		// forab(i,1,n+3)
		// 	cout<<prime[i]<<" ";
		// 	cout<<endl;
		forab(i,1,n)
		{
			
				ans+=i*(prime[i]);
		}
		cout<<ans<<endl;
	}
	int main()
	{	
		#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		#endif
		fast_io;
		int T=1;
		//cin>>T;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			solve();
		}
		return 0;
	}


Measured memory_bytes: 81776
import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():
    N=int(input())
    D=sorted(list(map(int,input().split())))

    print(D[N//2]-D[N//2-1])

resolve()

Measured memory_bytes: 52780
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int main()
{
	ll n,m;
	cin>>n>>m;
	ll ans1=(n+1)/2;
	ll ans2=(m+1)/2;
	ull sum=ans1*ans2;
	ll ans3=n/2;
	ll ans4=m/2;
	ull sum2=ans3*ans4;
	if(n==1||m==1)cout<<1<<endl;
	else
	cout<<sum+sum2<<endl;
	return 0;
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

flg = 0
for i in A:
    if i % 2 == 0 and (i % 3 == 0 or i % 5 == 0) and flg != 2:
        flg = 1
    elif i % 2 == 0:
        flg = 2
      
if flg == 0 or flg == 1:
    print('APPROVED')  
else:
    print('DENIED')

Measured memory_bytes: 3060
K,_=gets.chomp.split(' ').map{|n| n.to_i}
A=gets.chomp.split(' ').map{|n| n.to_i}
min = 2
max = 2
(A.size-1).downto(0){|i|
	min = (min / A[i] + (min%A[i]==0 ? 0 : 1)) * A[i]
	max = max / A[i] * A[i] + A[i] - 1
	if(min>max)
		puts -1
		exit(0)
	end
}
puts "#{min} #{max}"


Measured memory_bytes: 9612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MN = 320;
const ll M = 998244353;
inline ll mul(ll a, ll b) {return (a*b)%M;}
ll bp(ll b, ll p) {
	ll ac = 1;
	while(p) {
		if(p&1) ac = mul(ac,b);
		b = mul(b,b);
		p >>= 1;
	}
	return ac;
}
ll dp[MN*MN];
ll ds[MN*MN];
const ll hf = bp(2,998244351);
int v[MN];
int main() {
	int n;
	scanf("%d ",&n);
	memset(dp,0,sizeof(dp));
	ll ts = 0;
	for(int i=0;i<n;i++) {
		int t;
		scanf("%d ",&t);
		v[i] = t;
		ts += t;
	}
	ll sm = (ts+1)/2;
	int cr = 0;
	dp[0] = bp(2,n);
	ds[0] = 1;
	for(int i=0;i<n;i++) {
		for(int j=ts;j>=0;j--) {
			dp[j+v[i]] += mul(dp[j],hf);
			if(dp[j+v[i]] >= M) {dp[j+v[i]] -= M;}
			ds[j+v[i]] += ds[j];
			if(ds[j+v[i]] >= M) {ds[j+v[i]] -= M;}
		}
	}
	ll tot = 0;
	for(int i=sm;i<=ts;i++) {
		tot += dp[i];
		if(tot >= M) {tot -= M;}
	}
	ll res = bp(3,n);
	res -= tot*3;
	if(sm*2 == ts) {res += 3*ds[sm];}
	res = ((res%M)+M)%M;
	printf("%lld\n",res);
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <bitset>
using namespace std;

template <std::size_t N>
std::string to_string(const std::bitset<N>& bs)
{
  return bs.to_string<char, std::char_traits<char>, std::allocator<char> >();
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	long R, G, B, N;
	cin >> R >> G >> B >> N;
  	long count = 0;
  	for(int r=N/R;r>=0;r--)
    {
      for(int g=(N-r*R)/G;g>=0;g--)
      {
        if((N-r*R-g*G) % B == 0) count++;
      }
    }
  	cout << count << endl;
  	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

def main():
	s = input()
	ans = 0
	countw = 0
	for i in range(len(s)-1,-1,-1):
		if s[i] == "W":
			countw += 1
		else:
			ans += countw
	print(ans)

main()
			

Measured memory_bytes: 3628
#include <stdio.h>

int main(void) {
  int n;
  scanf("%d", &n);
  int ret = 0;
  for(int i = 0;i < n;i++) {
    int a;
    scanf("%d", &a);
    if(i % 2 == 0 && a % 2 == 1) {
      ret++;
    }
  }
  printf("%d\n", ret);
  return 0;
}

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


int main(){
    ll n,a,b,c,d,e;
    cin >> n >> a >> b >> c >> d >> e;
    ll ans = ceil(n*1.0 / min(e,min(d,min(c,min(a,b))))) + 4;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main(){
    int weeks;
    double money = 100.0;
    cin >> weeks;

    for(int i = 0; i < weeks; i++) {
        money = ceil(money * 1.05);
    }

    cout << int(money*1000) << endl;

    return 0;
}


Measured memory_bytes: 3032
a,b=io.read():match("(.+)%s(.+)")
A=a+(a*1==1 and 13 or 0)
B=b+(b*1==1 and 13 or 0)
if A==B then
  print("Draw")
elseif A>B then
  print("Alice")
else
  print("Bob")
end

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

from collections import Counter

c=Counter(a).most_common()[:k]

s=set([i[0] for i in c])

ans=0
for i in range(n):
    if a[i] not in s:
        ans+=1

print(ans)

Measured memory_bytes: 43080
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <utility>
#define N 1020
using namespace std;

int a[N][N];
int k[N];
vector<int> v, t;
set<pair<int, int> > f;

int main(void)
{
    int n;
    int i, j, s, o;

    scanf("%d", &n);
    for(i = 1; i <= n; i ++)
    {
        for(j = 1; j < n; j ++)
            scanf("%d", &a[i][j]);
        k[i] = 1;
        v.push_back(i);
    }

    for(o = 0; !v.empty(); o ++)
    {
        t.clear();
        // for(int xx:v)cout<<xx<<' ';cout<<endl;
        for(i = 0; i < (signed)v.size(); i ++)
        {
            s = v.at(i);
            f.insert(make_pair(s, a[s][k[s]]));
            if(f.count(make_pair(a[s][k[s]], s)))
            {
                // printf("match %d %d\n",s,a[s][k[s]]);
                f.erase(make_pair(s, a[s][k[s]]));
                f.erase(make_pair(a[s][k[s]], s));
                k[a[s][k[s]]] ++;
                if(k[a[s][k[s]]] < n)
                    t.push_back(a[s][k[s]]);
                k[s] ++;
                if(k[s] < n)
                    t.push_back(s);
            }
        }
        v = t;
    }
    printf("%d\n", *min_element(k + 1, k + n + 1) == n ? o : -1);

    return 0;
}


Measured memory_bytes: 4352
import math

N = int(input())

def xyzTriplets(N):
    store = {}
    upTo = math.sqrt(N)
    for x in range(1, int(upTo) + 1):
        for y in range(1, int(upTo) + 1):
            for z in range(1, int(upTo) + 1):
                res = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
                if (res not in store):
                    store[res] = 1
                else:
                    store[res] += 1
    for i in range(1, N+1):
        if (i in store):
            print(store[i])
        else:
            print(0)



xyzTriplets(N)


Measured memory_bytes: 11612
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
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; }
///////////////////////////////////////////////////////////////////////////////////
ll n,m;
matrix fri(200030);
vi seen(200030,0);
ll dfs(ll p){
    ll ctr=1;
    seen[p]=1;
    for(auto nxt:fri[p]){
        if(seen[nxt]==0){
            seen[nxt]=1;
            ctr+=dfs(nxt);
        }
    }
    return ctr;
}
void solve(){
    cin >> n >> m;
    rp(i,m){
        ll a,b;
        cin >> a >> b;
        a--; b--;
        fri[a].pb(b);
        fri[b].pb(a);
    }
    ll ans=0;
    rp(i,n){
        if(seen[i]==0){
            seen[i]=1;
            chmax(ans,dfs(i));
        }
    }
    print(ans);

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

Measured memory_bytes: 21156
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

typedef long long ll;
typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}
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;
}


int main() {
   int n;
   cin >> n;
   string S;
   cin >> S;
   int r = 0;
   int b = 0;
   for (int i = 0; i < (int)S.size(); i++) {
      if (S[i] == 'R') r++;
      if (S[i] == 'B') b++;
   }
   if (r > b) cout << "Yes" << endl;
   else cout << "No" << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s;cin>>s;
int ans=0;
for(int i=0;i<s.length()/2;i++){
  if(s[i]!=s[(s.length()-1)-i]){
    ans++;
  }
}
cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int N=sc.nextInt();
    int M=sc.nextInt();
    
    if(N==M){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 23636
#include<stdio.h>
int main()
{
	char c,str[2][4]={"No","Yes"},flag1=0,flag2=0;
	while((c=getchar())!=EOF)
	{
		if(c=='C') flag1=1;
		else if(flag1&&c=='F')
		{
			flag2=1;
			break;
		}
	}
	printf("%s",str[(int)(flag2)]);
 	return 0;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ALL(a) (a).begin(),(a).end()
#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

signed main() {
    int n;
    cin >> n;

    string ans = "";
    int r;
    int c;
    while (n != 0) {
        r = n % 2;
        if (r < 0) r += 2;
        n = (n - r) / -2;
        c = '0' + r;
        ans += c;
    }
    reverse(ans.begin(), ans.end());
    if (ans == "") ans = "0";

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

Measured memory_bytes: 256
using System;
using System.Linq;

class Program {
    static void Main (string[] args) {

        var ary = Console.ReadLine ().Split (' ');
        int A = int.Parse (ary[0]);
        int B = int.Parse (ary[1]);
        int C = int.Parse (ary[2]);

        if ((C > A && C < B) || (C < A && C > B)) {
            Console.WriteLine ("Yes");
        } else {
            Console.WriteLine ("No");
        }
    }
}

Measured memory_bytes: 11092