akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
using namespace std;
ll pow1(ll a,int b)
{
    ll res=1;
    while(b)
    {
        if(b%2)
            res=res*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return res;
}
int main()
{
    int n;
    ll ans;
    cin>>n;
    ans=pow1(10,n);
    ans=(((ans-pow1(9,n)+mod)%mod-pow1(9,n)+mod)%mod+pow1(8,n))%mod;
    cout<<ans;
    return 0;
}


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

int main()
{
    int a[26] = {0};
    string s;
    cin >> s;

    for(int i=0; s[i]!='\0'; i++)
    {
        a[s[i]-'a'] += 1;
    }

    for(int i=0; i<26; i++)
    {
        if(a[i]==0)
        {
            cout << (char)('a'+ i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

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

using namespace std;

int main(void) {
  int K, S; cin >> K >> S;
  int sum = 0;

  for (int x = 0; x <= K; x++) {
    if (S-x > 2*K) continue;
    for (int y = 0; y <= K; y++) {
      if (0 <= S-x-y && S-x-y <= K) {
        sum++;
      }
    }
  }

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int d, t, s; cin >> d >> t >> s;
  cout << (d <= t * s ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 3636
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

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

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

const MOD = 1000000007

var dp [100005][13]int
var n int

func main() {
	var s string

	fmt.Scan(&s)
	n := len(s)

	dp[0][0] = 1
	for i := 0; i < n; i++ {
		var c int
		if s[i] == '?' {
			c = -1
		} else {
			c = int(s[i] - '0')
		}

		for j := 0; j < 10; j++ {
			if c != -1 && c != j {
				continue
			}
			for ki := 0; ki < 13; ki++ {
				dp[i+1][(ki*10+j)%13] += dp[i][ki]
			}
		}

		for j := 0; j < 13; j++ {
			dp[i+1][j] %= MOD
		}
	}
	res := dp[n][5]

	fmt.Println(res)
}


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

const int MAXN = 1e5 + 10;

int X, Y, A, B, C;

int a[MAXN];
int b[MAXN];
int c[MAXN];

long long solve() {
  long long ans = 0;
  priority_queue<int> Q;

  sort(a + 1, a + 1 + A);
  sort(b + 1, b + 1 + B);
  sort(c + 1, c + 1 + C);
  
  for (int i = A; i > A - X; i--) {
    Q.push(-a[i]);
    ans += a[i];
  }

  for (int i = B; i > B - Y; i--) {
    Q.push(-b[i]);
    ans += b[i];
  }

  for (int i = C; i >= 1; --i) {
    int q = -Q.top();

    if (c[i] > q) {
      Q.pop();
      ans -= q;
      ans += c[i];
    }
    else break;
  }

  return ans;
}

int main() {
  scanf("%d %d %d %d %d", &X, &Y, &A, &B, &C);
  
  for (int i = 1; i <= A; ++i)
    scanf("%d", &a[i]);

  for (int i = 1; i <= B; ++i)
    scanf("%d", &b[i]);

  for (int i = 1; i <= C; i++)
    scanf("%d", &c[i]);

  printf("%lld\n", solve());
  return 0;
}

Measured memory_bytes: 2552
#include <stdio.h>

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

Measured memory_bytes: 128
N=int(input())
Al=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
s=''
M=[26**i for i in range(12)]
k=0
for i in range(12):
    k=k+M[i]
    if N<k:
        m=k-M[i]
        N=N-m
        L=[0]
        n=0
        for j in range(1, i+1):
            L.append(N%M[j])
            s=Al[(L[j]-L[j-1])//M[j-1]]+s
        break
print(s)

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

using namespace std;

int main(){

	int n,s[1010];
	
	while(1){
		cin>>n;
		if(n==0) break;
		for(int i=0; i<n; i++){
			cin>>s[i];
		}
		sort(s,s+n);
		int sum = 0;
		for(int i=1; i<n-1; i++){
			sum += s[i];
		}
		cout<<sum/(n-2)<<endl;
	}

	return 0;
}

Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

class UF {
private:
	std::vector<int> parent;
	std::vector<int> level;
	std::vector<int> num_member; // 同じグループに属するメンバーの数

public:
	// コンストラクタ　※注意※　0～nまでのn+1個を作る
	UF(int n) {
		for (int i = 0; i <= n; i++) {
			parent.push_back(i); //
			level.push_back(1);  // 木の深さ
			num_member.push_back(1);
		}
	}
	// 木の根を求める
	int root(int x) {
		if (parent[x] == x)return x;
		else return parent[x] = root(parent[x]);
	}

	// 同じ集合に属するメンバーの数を求める
	int numOfmember(int x) {
		if (parent[x] == x) return num_member[x];
		else return num_member[x] = numOfmember(parent[x]);
	}

	// xとyの属する集合を合併
	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry) return; // 元々合併済みの場合
		if (level[rx] < level[ry]) {
			num_member[ry] = numOfmember(ry) + numOfmember(rx);
			parent[rx] = ry;
		}
		else {
			num_member[rx] = numOfmember(ry) + numOfmember(rx);
			parent[ry] = rx;
			if (level[rx] == level[ry]) level[rx]++;
		}
	}
	// xとyが同じ集合に属するか否か
	bool same(int x, int y) {
		return root(x) == root(y); // rootが同じなら同じ集合に含まれる
	}
};

int p[100001];
int pos[100001]; // pos[i] : 整数iがある位置

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

	int N, M;
	cin >> N >> M;
	UF uf(N);

	for (int i = 1; i <= N; i++) {
		cin >> p[i];
		pos[p[i]] = i;
	}
	for (int i = 0; i < M; i++) {
		int x, y; cin >> x >> y;
		uf.unite(x, y);
	}

	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (uf.same(i, pos[i])) {
			ans++;
			// swap
			// p[i] と p[a] を交換
			int a = pos[i]; 
			p[a] = p[i]; p[i] = i;
			pos[p[a]] = a; pos[i] = i;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2540
#include <cstdio>
#include <iostream>

struct range {
	int left;
	int right;
	long long left_mult;
	long long right_mult;
};
int N;
long long as[200008];
long long bs[200008];
using namespace std;
int comp(long long va, long long a_mult, long long vb, long long b_mult) {
	if(a_mult < b_mult) return -comp(vb, b_mult, va, a_mult);
	long long diff = a_mult - b_mult;
	for(int i=0;i<diff;i++) {
		va *= 2;
		if(va > vb) return 1;
	}
	if(va == vb) return 0;
	if(va > vb) return 1;
	return -1;
}
range ranges[200002];
long long update(int cur, long long *values) {
	if(ranges[cur].right == N) return 0;
	long long ret = 0;
	int next = ranges[cur].right + 1;
	if(comp(values[ranges[cur].right], ranges[cur].right_mult, values[ranges[next].left], ranges[next].left_mult) <= 0) return 0;
	while(comp(values[ranges[cur].right], ranges[cur].right_mult, values[ranges[next].left], ranges[next].left_mult) == 1) {
		ret += 2 * (ranges[next].right - ranges[next].left + 1);
		ranges[next].left_mult += 2;
		ranges[next].right_mult += 2;
	}
	ranges[cur].right = ranges[next].right;
	ranges[cur].right_mult = ranges[next].right_mult;
	return ret + update(cur, values);
}
void calc(long long *dp, long long *values) {
	for(int i=1;i<=N;i++) {
		ranges[i].left = i;
		ranges[i].right = i;
		ranges[i].left_mult = 0;
		ranges[i].right_mult = 0;
	}
	for(int i = N - 1;i>0;i--) dp[i] = dp[i+1] + update(i, values); 
}
long long dp1[200008];
long long dp2[200008];
int main() {
	scanf("%d", &N);
	for(int i=1;i<=N;i++) {
		scanf("%lld", &as[i]);
		bs[N - i + 1] = as[i] * 2;
	}
	calc(dp1, as);
	calc(dp2, bs);
	for(int i=1;i<=N;i++) dp2[i] += N - i + 1;
	long long sol = dp1[1];
	for(int i=2;i<=N;i++) {
		if(sol > dp1[i] + dp2[N - i + 2]) sol = dp1[i] + dp2[N - i + 2];
	}
	printf("%lld\n", sol);
	return 0;
}

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

#define maxn 100000008
#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int a[55][55];

int main(int argc, char *argv[])
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		char s[55];
		scanf("%s", s);
		for (int j = 0; j < strlen(s); ++j) {
			a[i][s[j]-'a']++;
		}
	}

	for (char c = 'a'; c <= 'z'; ++c) {
		int foo = 123;
		for (int i = 0; i < n; ++i) {
			foo = min(foo, a[i][c-'a']);
		}
		for (int i = 0; i < foo; ++i) {
			printf("%c", c);
		}
	}
	return 0;
}


Measured memory_bytes: 384
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>   
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(ll i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int n;
vi in,to;
ll vtol(vi a){
	ll t=0;
	rep(i,a.size()){
		t*=10;
		t+=a[i];
	}
	return t;
}
map<ll,int>tmp;
void f(vi a,int c){
	if(c==(n-1)/2)return;
	rep(i,n-1)loop(j,i+1,n){
		vi t=a;
		loop(k,i,j+1)if(k<j-k+i)
			swap(t[k],t[j-k+i]);
		ll s=vtol(t);
		if(tmp.count(s))tmp[s]=min(tmp[s],c+1);
		else tmp[s]=c+1;
		f(t,c+1);
	}
}
int main(){
	cin>>n;
	in=vi(n);
	rep(i,n)cin>>in[i];
	to=vi(n);
	rep(i,n)to[i]=i,in[i]--;
	tmp[vtol(to)]=0;
	f(to,0);
	map<ll,int>A=tmp;
	tmp.clear();
	tmp[vtol(in)]=0;
	f(in,0);
	map<ll,int>B=tmp;
	int out=n-1;
	for(auto it:A)if(B.count(it.first)){
		out=min(out,A[it.first]+B[it.first]);
	}
	cout<<out<<endl;
}
















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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	int ans=0;
	REP(i, 4){
		if(s[i]=='+'){
			++ans;
		}
		if(s[i]=='-'){
			--ans;
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys


def is_yymm(S):
    return 1 <= int(S[2:]) <= 12

def is_mmyy(S):
    return 1 <= int(S[:2]) <= 12

S = input()
if is_yymm(S):
    if is_mmyy(S):
        print('AMBIGUOUS')
    else:
        print('YYMM')
elif is_mmyy(S):
    if is_yymm(S):
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    print('NA')



Measured memory_bytes: 7988
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll ;
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
 const ll inf=1e9+7;
string a,b,c;

ll mod(ll a)
{
	if(a<inf)return a;
	else 
	return a%inf;
}
 void test_cases()
{

ll n,m;
cin>>n>>m;
vector<string>a,b;
for(ll i=0;i<n;i++)
{
	string x;
	cin>>x;
	a.push_back(x);
}

for(ll i=0;i<m;i++)
{
	string x;
	cin>>x;
	b.push_back(x);
}


for(ll i=0;i<n;i++)
{
	for(ll j=0 ;j<n;j++)
	{
		
		if(j+m-1<n&&i+m-1<n)
		{
			bool yes=true;
			for(ll k=i;k<i+m;k++)
			{
				for(ll z=j;z<j+m;z++)
				{
					if(a[k][z]!=b[k-i][z-j])
					{
						yes=false;
						break;
					}
				}
				if(!yes)break;
			}
			
			if(yes)
			{
				cout<<"Yes";
				return;
			}
		}
	}
}

cout<<"No";

}


int main()
{
    fast;
  ll t;
 // cin>>t;
 t=1;
  while(t--)
  test_cases();

  	
}

		
	
	
	
	


Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7,mod=1e9+7;
int n,m,a[N],f[N];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1,x;i<=m;i++)scanf("%d",&x),a[x]=1;
	f[0]=1;
	for(int i=1;i<=n;i++)if(!a[i])f[i]=(f[i-1]+f[i-2])%mod;
	printf("%d\n",f[n]);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define vec(x) vector<x>
ll gcd(ll a,ll b){while(b){ll tmp = a % b;a = b;b = tmp;}return a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define out(x) for(auto i : x) cout << i << " "; cout << endl;
#define outln(x) for(auto i : x) cout << i << " " << endl;
#define vec_cpy(to,from) copy(all(to),back_inserter(from))
#define ary_cpy(to,from) memcpy(to, from, sizeof from)
#define MOD = 1000000007; 
#ifdef DEBUG
#define debug_echo(e) cout << "L" << __LINE__ << ": " << e << endl
#define debug_var(e) cout << "L" << __LINE__ << ": " << #e << " = " << e << endl
#else
#define debug_echo(e)
#define debug_var(e)
#endif
#ifdef DEBUG
#define debug_echo_dp1(dp, N) { cout << "[ "; rep(i, N) cout << dp[i] << " ";  cout << "]" << endl; }
#else
#define debug_echo_dp1(dp, N)
#endif

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

#define MAX_N 5000

int N;
int p[MAX_N];
int z[MAX_N];

int main() {
  cin >> N;
  rep(i, N) cin >> p[i];

  int ans = INT_MAX;
  for (int t=0; t<=p[0]; t++) {
    int cost = t;
    memset(z, 0, sizeof(z));
    z[0] = t;
    for (int i=1; i<N; i++) {
      cost += (p[i-1]-z[i-1])*2;
      z[i] += p[i-1]-z[i-1];
      chmin(z[i], p[i]);
    }
    cost += p[N-1]-z[N-1];
    chmin(ans, cost);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3068
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long n,tt;
    scanf("%ld%ld", &n, &tt);

    vector<long> t(n);
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld", &t[i]);
    }

    ll sum=0;
    for(i=0; i<n; i++) {
        if(i==n-1) {
            sum+=tt;
        }
        else {
            sum += (t[i+1]-t[i]>tt? tt: (t[i+1]-t[i]) );
        }
    }
    printf("%lld\n", sum);

    return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s; cin >> s;
	ll res = 0;;
	FOR(i,0,sz(s)) res += (i % 2) - (s[i] == 'p');
	cout << res << endl;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;
template <typename T>
T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}

ll n;

void solve(){
    cin >> n;
    ll res = 0;
    VV<> lef(n), rig(n);
    REP(i, n){
        ll k, l, r; cin >> k >> l >> r; k--;
        res += min(l, r);
        if(l > r) lef[k].pb(l - r);
        if(l < r) rig[k].pb(r - l);
    }
    priority_queue<ll,vector<ll>,greater<ll>> lq, rq;
    REP(i, n){
        for(auto v:lef[i]) lq.push(v);
        while(SZ(lq) > i + 1) lq.pop();
    }
    RREP(i, n){
        for(auto v:rig[i]) rq.push(v);
        while(SZ(rq) > n - i - 1) rq.pop();
    }
    while(SZ(lq)){res += lq.top(); lq.pop(); }
    while(SZ(rq)){res += rq.top(); rq.pop(); }
    cout << res << '\n';
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t; cin >> t;
    while(t--) solve();
}

Measured memory_bytes: 19636
#include<stdio.h>
int main(void){
  int k,s,i,j,l,ans;
  scanf("%d%d",&k,&s);
  for(i=0;i<=k;i++){
   for(j=0;j<=k;j++){
     int l=s-i-j;  
     if(0<=l&&l<=k) ans++;
   }
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
  	int a,b,c,d,e;
  scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
  if(a == 0){
    	printf("1");
  }else if(b == 0){
    	printf("2");
  }else if(c == 0){
    	printf("3");
  }else if(d == 0){
    	printf("4");
  }else if(e == 0){
    	printf("5");
  }
  return 0;
}


Measured memory_bytes: 1644
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        String replaceStr = S.replaceAll("ABC", "");
        System.out.println((N - replaceStr.length()) / 3);
    }
}


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

int main(){
  int n;
  cin>>n;
  int count=0,a=0,b=0,c=0;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    for(int i=0;i<s.size()-1;i++){
      if(s[i]=='A'&&s[i+1]=='B'){
        count++;
      }
    }
    if(s[0]=='B'&&s[s.size()-1]=='A'){
      c++;
    }
    else if(s[0]=='B'){
      b++;
    }
    else if(s[s.size()-1]=='A'){
      a++;
    }
  }
  int answer=count;
  if(c==0){
    answer+=min(a,b);
  }
  else if(a+b>0){
    answer+=min(a,b)+c;
  }
  else{
    answer+=c-1;
  }
  cout<<answer<<endl;
}

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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    int mn = n + 1;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        mn = min(mn, a[i]);
        if (a[i] <= mn) {
            ans++;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 1024
def divide(h):
    counter = 0
    counter1 = 0
    for i in range(1, h, 2):
        for j in range(1, i+1):
            if i % j == 0:
                counter += 1
        if counter == 8:
            counter1 += 1
        counter = 0
    return counter1

                         
if __name__ == '__main__':
    n = int(input())
    if n % 2 != 0:
        print(divide(n+1))
    else:
        print(divide(n))

Measured memory_bytes: 3060
from collections import deque

nameq = deque()
timeq = deque()
n, q = map(int, raw_input().split())
for _ in xrange(n):
  name, time = raw_input().split()
  nameq.append(name)
  timeq.append(int(time))

t = 0
while nameq:
  name = nameq.popleft()
  time = timeq.popleft()
  if time > q:
    time -= q
    nameq.append(name)
    timeq.append(time)
    t += q
  else:
    t += time
    print "%s %d" % (name, t)

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

int main() {
  string line;
  getline(cin, line);
  for(unsigned int i=0; i<line.length(); i++) {
    if('a' <= line[i] && line[i] <= 'z') {
      line[i] -= 32;
    }
    else if('A' <= line[i] && line[i] <= 'Z') {
      line[i] += 32;
    }
  }
  cout << line << endl;
  return 0;
}

Measured memory_bytes: 3188
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

int N, M;
V<V<PII>> d;
V<int> p;

int dfs(int n) {
    n--;
    if(n == -1) {
        REP(i,d.size()) {
            int cnt = 0;
            REP(j,d[i].size()) {
                if(d[i][j].second == 1) cnt++;
            }
            if(cnt % 2 != p[i]) return 0;
        }
        return 1;
    }
    int ans = 0;
    REP(i,d.size()) {
        REP(j,d[i].size()) {
            if(d[i][j].first == n) d[i][j].second = 1;
        }
    }
    ans += dfs(n);
    REP(i,d.size()) {
        REP(j,d[i].size()) {
            if(d[i][j].first == n) d[i][j].second = 0;
        }
    }
    ans += dfs(n);
    return ans;
}

int main(){
    INIT;
    cin >> N >> M;
    d.resize(M);

    REP(i,M) {
        int k; cin >> k;
        REP(j,k) {
            int s; cin >> s;
            d[i].push_back(PII(s-1,0));
        }
    }

    REP(i,M) {
        int x; cin >> x;
        p.push_back(x);
    }

    cout << dfs(N);
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
 
using namespace std;
 
struct dice{
    int q1,q2,q3,q4,q5,q6;
};
 
void mN(dice &d){
    int tmp=d.q1;
    d.q1=d.q2;
    d.q2=d.q6;
    d.q6=d.q5;
    d.q5=tmp;
}
 
void mE(dice &d){
    int tmp=d.q1;
    d.q1=d.q4;
    d.q4=d.q6;
    d.q6=d.q3;
    d.q3=tmp;
}
void mW(dice &d){
    int tmp=d.q1;
    d.q1=d.q3;
    d.q3=d.q6;
    d.q6=d.q4;
    d.q4=tmp;
}
void mS(dice &d){
    int tmp=d.q1;
    d.q1=d.q5;
    d.q5=d.q6;
    d.q6=d.q2;
    d.q2=tmp;
}
 
void spin(dice &d){
    int tmp=d.q2;
    d.q2=d.q3;
    d.q3=d.q5;
    d.q5=d.q4;
    d.q4=tmp;
}
 
int main(){
    dice y, z;
    bool flag = false;
     
    scanf(" %d %d %d %d %d %d", &y.q1, &y.q2, &y.q3, &y.q4, &y.q5, &y.q6);
    scanf(" %d %d %d %d %d %d", &z.q1, &z.q2, &z.q3, &z.q4, &z.q5, &z.q6);
     
    for(int i=0; i<4; ++i){
        for(int j=0; j<4; ++j){
            //printf("now: %d %d %d %d %d %d\n", y.q1, y.q2, y.q3, y.q4, y.q5, y.q6);
         
            if(y.q1==z.q1 && y.q2==z.q2 && y.q3==z.q3 && y.q4==z.q4 && y.q5==z.q5 && y.q6==z.q6) {
                flag = true;
                break;
            }
            spin(y);    
        }
        if(flag) break;
        mN(y);
    }
     
    mE(y);
     
    //printf("now: %d %d %d %d %d %d\n", y.q1, y.q2, y.q3, y.q4, y.q5, y.q6);
     
    for(int i=0; i<4; ++i){
        for(int j=0; j<4; ++j){
            //printf("now: %d %d %d %d %d %d\n", y.q1, y.q2, y.q3, y.q4, y.q5, y.q6);
         
            if(y.q1==z.q1 && y.q2==z.q2 && y.q3==z.q3 && y.q4==z.q4 && y.q5==z.q5 && y.q6==z.q6) {
                flag = true;
                break;
            }
            spin(y);    
        }
        if(flag) break;
        mN(y);
    }   
             
    if(flag)printf("Yes\n");
    else printf("No\n");
         
    return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int K, result;
  cin >> K;
  if (K == 1 || K == 2 || K == 3 || K == 5 || K == 7 || K == 11 || K == 13 || K == 15 || K == 17 || K == 19 || K == 23 || K == 29 || K == 31) {
    result = 1;
  }
  else if (K == 4 || K == 6 || K == 9 || K == 10 || K == 14 || K == 21 || K == 22 || K == 25 || K == 26) {
    result = 2;
  }
  else if (K == 28 || K == 30) {
    result = 4;
  }
  else if (K == 8 || K == 12 || K == 18 || K == 20 || K == 27) {
    result = 5;
  }
  else if (K == 16) {
    result = 14;
  }
  else if (K == 24) {
    result = 15;
  }
  else {
    result = 51;
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include<iostream>

#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)

using namespace std;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if (a > b) swap(a, b);
  if (b > c) swap(b, c);
  if (a > b) swap(a, b);
  cout << (a + b == c ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
	public static final MyScanner in = new MyScanner();
 
	public static void main(String[] args) {
 
		int K = in.nextInt();
		char[] S = in.next().toCharArray();


		StringBuilder sb = new StringBuilder();
		if (S.length > K) {
			for(int i=0;i<K;i++) {
				sb.append(S[i]);
			}
			sb.append("...");
		} else {
			sb.append(S);
		}


		System.out.println(sb.toString());
 
	}

 
	public static class MyScanner {
		Scanner sc = new Scanner(System.in);
		String next() { return sc.next();}
		int nextInt() { return Integer.valueOf(sc.next());}
		long nextLong() { return Long.valueOf(sc.next()); }
	}
}

Measured memory_bytes: 35748
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N, M;

            string[] s = Console.ReadLine().Split(' ');
            N = int.Parse(s[0]);
            M = int.Parse(s[1]);


            int[] ans = new int[N];

            for (int i = 0; i < N; i++)
            {
                ans[i] = 0;
            }

            for (int i = 0; i < M; i++)
            {
                string[] t = Console.ReadLine().Split(' ');
                int a = int.Parse(t[0]);
                int b = int.Parse(t[1]);

                ans[a - 1]++;
                ans[b - 1]++;
            }

            for(int i = 0; i<N; i++)
            {
                Console.WriteLine(ans[i]);
            }
        }
    }
}


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

#define ll long long
#define ar array
#define vi vector<int>
#define INF 1000000000

void boxSwap(int arr[]){
	int temp = arr[0];
	arr[0] = arr[1];
	arr[1] = temp;
	temp = arr[0];
	arr[0] = arr[2];
	arr[2] = temp;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int x, y, z;
	cin >> x >> y >> z;

	int boxes[3] = {x, y, z};
	boxSwap(boxes);
	for(int i=0; i < 3; i++){
		cout << boxes[i] << " ";
	}
	cout << endl;	
	return 0;
}


Measured memory_bytes: 3632
a,b,c = map(int, input().split())
m = max(a,b,c)
if (3*m-(a+b+c))%2 == 0:
    t = 3*m-(a+b+c)
    print(t//2)
else:
    t = 3*(m+1)-(a+b+c)
    print(t//2)

Measured memory_bytes: 9180
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
using ll = long long;
using itn = int;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
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; }

ll dp[100010][3];

int main() {

    int n;
    cin >> n;

    int a[100010][3];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a[i][j];
        }
    }

    for (int i = 0; i < 100010; i++) {
        for (int j = 0; j < 3; j++) {
            dp[i][j] = 0;
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
            
                if(j != k) {
                    chmax(dp[i+1][k], dp[i][j] + a[i][k]);
                }
            }
        }
    }

    ll ans = 0;
    for (int i = 0; i < 3; i++) {
        chmax(ans, dp[n][i]);
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

ll Xor(ll x){
    if(x % 4 == 0){
        return x;
    }else if(x % 4 == 2){
        return 1 ^ x;
    }else if(x % 4 == 1){
        return (x-1) ^ x;
    }else{
        return 1 ^ (x-1) ^ x;
    }
}


int main(){
    ll a,b; cin >> a >> b;
    cout << (Xor(a-1) ^ Xor(b)) << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std; 
# define INF 0x3f3f3f3f 
  
typedef pair<int, int> iPair; 
  
class Graph 
{ 
    int V;
    list< pair<int, int> > *adj; 
  
public: 
    Graph(int V);
    void addEdge(int u, int v, int w); 
    void shortestPath(int s); 
}; 
  
Graph::Graph(int V) 
{ 
    this->V = V; 
    adj = new list<iPair> [V]; 
} 
  
void Graph::addEdge(int u, int v, int w) 
{ 
    adj[u].push_back(make_pair(v, w)); 
    adj[v].push_back(make_pair(u, w)); 
} 
  
void Graph::shortestPath(int src) 
{ 
    priority_queue< iPair, vector <iPair> , greater<iPair> > pq; 
    vector<int> dist(V, INF); 
    vector<int> next(V, 0);
    pq.push(make_pair(0, src)); 
    dist[src] = 0; 
    next[src] = 0;
    while (!pq.empty())
    { 
        int u = pq.top().second; 
        pq.pop(); 
        list< pair<int, int> >::iterator i;
        for (i = adj[u].begin(); i != adj[u].end(); ++i) 
        { 
            int v = (*i).first; 
            int weight = (*i).second; 
            if (dist[v] > dist[u] + weight) 
            { 
                dist[v] = dist[u] + weight; 
                pq.push(make_pair(dist[v], v)); 
                next[v] = u;
            } 
        } 
    }
    for(int i = 1; i< V; ++i){
        if(dist[i]==0){
            printf("No");
            return;
        }
    }
    printf("Yes\n");
    for (int i = 1; i < V; ++i) 
        printf("%d\n", next[i]+1); 
}
  
int main() 
{ 
    int N, M;
    cin  >> N>> M;
    Graph g(N); 
    for (int i = 0; i< M; i++){
        int a, b;
        cin >> a >> b;
        g.addEdge(a-1, b-1, 1);
    }
    g.shortestPath(0);
    return 0; 
} 

Measured memory_bytes: 19812
#include<bits/stdc++.h>
using namespace std;
int n,ans,maxx;
char a;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		if(a=='I') ans++;
		else ans--;
		if(ans>maxx) maxx=ans;
	}
	cout<<maxx<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <queue>
#include <vector>
#include <cmath>
#include <map>
#include <stack>
#include <algorithm>
typedef long long int ll;
using namespace std;

bool isp(int a)
{
    bool flag=true;
    for (int i=2; i*i<=a; i++) {
        if (!(a%i)) {
            flag=false;
        }
    }
    return flag;
}
int main(){
    //freopen("/Users/mac/Desktop/C++?¨????/test/test.txt", "r", stdin);
    int n;
    int sum=0;
    scanf("%d",&n);
    for (int i=0; i<n; i++) {
        int p;
        scanf("%d",&p);
        if (isp(p)) {
            sum++;
        }
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 3216
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

public class Program
{

    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int sq = 0;
        int ans = 0;
        while (true)
        {
            sq = Convert.ToInt32(Math.Round(Math.Sqrt(N)));
            if (sq * sq == N) { ans = N; break; }
            N--;
        }
        Console.WriteLine(ans);
    }


    static int[] s_to_i(string[] s)
    {
        int[] ret = Array.ConvertAll<string, int>(s, delegate (string value) { return int.Parse(value); });
        return ret;
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
const int N=200010;
int n,p[N],t,ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&t),p[t]=i;
	t=0;
	for(int i=1;i<=n;i++){
		t=max(t,i);
		while(t<=n&&p[t]<p[t+1]) t++;
		ans=max(ans,t-i+1);
	}
	printf("%d",n-ans);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int main() {
  int a, b; cin >> a >> b;
  if ( a<=0 && 0<=b ) {
    cout << "Zero" << endl;
    exit(0);
  }
  if ( 0<a && a<=b )  cout << "Positive" << endl;
  if ( a<=b && b<0 )  {
    if ( (b-a+1)%2 == 0 )  cout << "Positive" << endl;
    if ( (b-a+1)%2 == 1 )  cout << "Negative" << endl;
  }
}

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

int binarySearch(int A[], int value, int n) {
    int left = 0;
    int right = n;

    while (left < right) {
        int mid = (left + right) / 2;

        if (value == A[mid]) {
            return 1;
        }

        if (value < A[mid])
            right = mid;
        else
            left = mid + 1;
    }

    return 0;
}

int main() {

    int n;
    cin >> n;

    int *A = new int[n];
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }

    int q;
    cin >> q;
    int sum = 0;
    for (int i = 0; i < q; ++i) {
        int j;
        cin >> j;
        if (binarySearch(A, j, n)) ++sum;
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1568
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  int n;
  
  cin >> n;
  
  int total=0,count=1;
  
  for(int i=0;i<n;i++){
    total+=800;
    if(count%15==0){
      total-=200;
    }
    count++;
  }
  
  cout << total;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  cout << n * n * n << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int qNumber = sc.nextInt();
        ArrayList<Integer> answerTimes = new ArrayList<>();
        for (int i = 0; i < qNumber; i++) {
            answerTimes.add(sc.nextInt());
        }
        int sum = 0;
        for (Integer time : answerTimes) {
            sum += time;
        }
        int drinkTypes = sc.nextInt();
        int updatedQuestionId;
        int updatedTime;
        int answer;
        for (int i = 0; i < drinkTypes; i++) {
            updatedQuestionId  = sc.nextInt();
            updatedTime = sc.nextInt();
            answer = sum - answerTimes.get(updatedQuestionId-1) + updatedTime;
            System.out.println(answer);
        }


    }
}


Measured memory_bytes: 20820
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)       for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF                 (int)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef long long           ll;
typedef pair<ll, ll>	    P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	double L;
	cin >> L;
	
	double hen = L / 3;

	double ans = hen * hen * hen;
	
	cout << setprecision(16) << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
original_ary = sorted(list(map(int, input().split())))

bool_ary = [0] * original_ary[-1]

for num in original_ary:
    bool_ary[num-1] += 1
    if bool_ary[num-1] == 1:
        for multiple in range(num * 2, original_ary[-1]+1, num):
            bool_ary[multiple-1] = 2

print(bool_ary.count(1))


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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans = 1e9;
    for (int x = -100; x <= 100; x++) {
        int cur = 0;
        for (int i = 0; i < n; i++) {
            cur += (a[i] - x) * (a[i] - x);
        }
        ans = min(ans, cur);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <vector>
using namespace std;
typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64, int64> pll;

const int INF = 0x3f3f3f3f;
const int MAX_N = 100000;

const int MAX_V = MAX_N;
vector<int> G[MAX_V];

int que[MAX_V];
int dist[MAX_V];

int ans[MAX_V];
bool bfs(int s,int V){
	int qs = 0, qt = 0;
	memset(dist,-1,sizeof(dist));
	que[qt++] = s, dist[s] = 0;
	while(qs < qt){
		int v = que[qs++];
		int d = dist[v];
		for (int i = 0; i < G[v].size(); ++i){
			int u = G[v][i];
			if(dist[u] != -1)	continue;
			que[qt++] = u, dist[u] = d+1;

			ans[u] = v;
		}
	}

	assert(qt <= V);
	if(qt != V)	return false;

	return true;
}


int main(){
	int N,M; scanf("%d%d",&N,&M);
	for (int i = 0; i < M; ++i){
		int A,B;	scanf("%d%d",&A,&B); --A, --B;
		G[A].push_back(B);
		G[B].push_back(A);
	}
	if(bfs(0,N)){
		puts("Yes");
		for (int i = 1; i < N; ++i)
			printf("%d\n",ans[i]+1);

	}else{
		puts("No");
	}

}



Measured memory_bytes: 10592
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << 0; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

const int N = 2e5 + 7;

vector <int> g[N], ord[N];
int t, sz[N], tin[N], col[N], p[N];

void dfs(int v, int pr) {
    tin[v] = ++t;
    sz[v] = 1;
    p[v] = pr;
    for (int u : g[v])
        if (u != pr) {
            dfs(u, v);
            sz[v] += sz[u];
        }
    ord[col[v]].pb(v);
}

int process(int c) {
    int ans = 0;
    vector <int> child;
    for (int v : ord[c]) {
        reverse(all(g[v]));
        for (int u : g[v]) {
            if (u == p[v])
                continue;
            int mns = 0;
            while (!child.empty() && tin[child.back()] >= tin[u]) {
                mns += sz[child.back()];
                child.pop_back();
            }
            ans += (sz[u] - mns) * (sz[u] - mns + 1) / 2;
        }
        child.pb(v);
    }
    return ans;
}

void solve() {
    int n; cin >> n;
    loop1(i, n)
        cin >> col[i];
    loop(i, n - 1) {
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    g[0].pb(1);
    dfs(0, 0);
    loop1(i, n) {
        ord[i].pb(0);
        cout << n * (n + 1) / 2 - process(i) << "\n";
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 45360
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner s=new Scanner(System.in);
        int n=s.nextInt();
        double d=s.nextInt();
        int count=0;

        for(int i=0;i<n;i++){
            long x=s.nextInt();
            x=x*x;
            long y=s.nextInt();
            y=y*y;
            long p=x+y;
            double dist=Math.sqrt(p);
            if(dist<=d){
                count++;
            }
        }

        System.out.println(count);

    }
}

Measured memory_bytes: 61444
let () =
  Scanf.scanf "%d" @@ fun n ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  Array.sort (fun x y -> abs x - abs y) a;

  let s = Array.fold_left (fun x y -> x + abs y) 0 a in
  let c = Array.fold_left (fun x y -> if y < 0 then x+1 else x) 0 a in
  Printf.printf "%d\n" (if c mod 2 = 0 then s else s - 2 * abs a.(0))

Measured memory_bytes: 5504
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int N;
  while(cin>>N && N){
    vector<int> a(N + 1);
    vector<int> ans;
    REP(i, N + 1) cin>>a[i];
    REP(i, N + 1){
      vector<int> b;
      REP(j, N + 1) if(i != j) b.push_back(a[j]);
      set<int> s;
      REP(j, b.size() - 1) s.insert(b[j + 1] - b[j]);
      if(s.size() == 1){
        ans.push_back(a[i]);
      }
    }
    //assert(ans.size() == 1);
    cout<<ans[0]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1220
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int[] a = sc.nextIntArray(n);
    if (n == 1) {
      System.out.println(1);
      return;
    }
    Arrays.sort(a);
    Map<Integer, Integer> counter = new HashMap<>();
    for (int ai: a) counter.merge(ai, 1, Integer::sum);
    Set<Integer> forbidden = new HashSet<>();
    for (int ai: counter.keySet()) {
      if (counter.get(ai) > 1) forbidden.add(ai);
    }
    int count = 0;
    for (int ai: a) {
      if (!forbidden.contains(ai)) count++;
      for (int i = 1; ai * i <= a[n - 1]; i++) forbidden.add(ai * i);
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 127724