akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

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

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

void prework(){

}

void read(){

}

ll a[1000];

ll gao(ll n, ll m){
	ll ret = 1ll << 60;
	for(int i = 1; i < n; i++){
		a[0] = i * m;
		ll p = n - i;
		ll q = m;
		if (p % 2 == 0 || q % 2 == 0)
			a[1] = a[2] = p * q / 2;
		else{
			if (p > q) swap(p, q);
			a[1] = (q - 1) / 2 * p;
			a[2] = (q + 1) / 2 * p;
		}
		sort(a, a + 3);
		ret = min(ret, a[2] - a[0]);
	}
	return ret;
}

void solve(int casi){
//	cout << "Case #" << casi << ": ";
	cin >> n >> m;
	ll ans = min(gao(m, n), gao(n, m));
	cout << ans << endl;
}

void printans(){

}


int main(){
//	std::ios::sync_with_stdio(false);
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define txt freopen("ip.txt", "r", stdin); freopen("op.txt", "w", stdout)
#define a3 INT_MAX
#define i3 INT_MIN
#define a6 INT64_MAX
#define i6 INT64_MIN
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define div2(a) (!(a&1))
#define deb(x) cout<<(#x)<<" "<<(x)<<"\n";
#define newl cout<<"\n" 
#define pi 3.14159265358979323846
#define mod 1000000007
#define all(s) s.begin(),s.end()
#define fp(x) fixed<<setprecision(x)<<
#define split(x) while ((cout<<s[i],i+=1) && (i<n-1) && (cout<<x));
int digit(ll a)
{
    vector<long long> dig = {
        0,
        9,
        99,
        999,
        9999,
        99999,
        999999,
        9999999,
        99999999,
        999999999,
        9999999999,
        99999999999,
        999999999999,
        9999999999999,
        99999999999999,
        999999999999999,
        9999999999999999,
        99999999999999999,
        999999999999999999,
        INT64_MAX};
    auto it = lower_bound(dig.begin(), dig.end(), a);
    int idx = (it - dig.begin());
    return idx;
}
int main(){
    quickie;
    //txt;
    int n; cin>>n;
    vi  a(n);
    ll sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
        sum += a[i];
    }
    int m; cin>>m;
    for (int i = 0; i < m; i++)
    {
        int x,y;
        cin>>x>>y;
        --x;
        int diff = a[x] - y;
        ll temp = sum - diff;
        cout<<temp;
        newl;
    }
    
    
    
    return 0;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define N 200050
#define M 200
#define int long long
#define pb push_back
#define x first
#define y second
#define all(v) v.begin(),v.end()
#define coffee prince
#define sz(a) (int)a.size()
#define ll long long
#define SIZE N
#define MOD mod
using namespace std;

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
    int n; cin>>n;
    int ans = 0;
    for(int i=1;i<=n;i++){
        int a; cin>>a;
        if(i%2&&a%2)ans++;
    }
    cout<<ans;
  	return 0;
}



Measured memory_bytes: 3648
#include<iostream>
#include<cmath>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<cstdlib>
#include<queue>
#include<list>
using namespace std;

int main(){
    int a, b;
    char c;
    cin>>a>>c>>b;
    if(c=='+')cout<<a+b<<endl;
    else cout<<a-b<<endl;
}


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

int main() {
  int N;
  cin >> N;
  int T = 0, X = 0, Y = 0;
  for (int i = 0; i < N; i++) {
    int t, x, y;
    cin >> t >> x >> y;
    int tmp = (t - T) - abs(X - x) - abs(Y - y);
    if (tmp < 0) return cout << "No" << "\n", 0;
    if (tmp % 2) return cout << "No" << "\n", 0;
    T = t, X = x, Y = y;
  }
  cout << "Yes" << "\n";
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

bool is_prime(int n){
    if(n <= 3){
        return n > 1;
    }
    else if(n % 2 == 0 || n % 3 == 0){
        return false;
    }
    else{
        for(int i = 5; i * i <= n; i += 6){
            if(n % i == 0 || n % (i + 2) == 0){
                return false;
            }
        }
    }
    
    return true;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    
    int cnt = 0;
    for(int i = 2; i <= 55555; i += 5){
        if(is_prime(i)){
            cout << i << " ";
            ++cnt;
        }
        
        if(cnt >= n){
            cout << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main () {
  ll n, m;
  cin >> n >> m;
  vector<ll> a(m);
  ll s=0;
  rep(i, m) {
    cin >> a.at(i);
      s += a.at(i);
  }
  if(s<=n) cout << n-s << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 3664
N = int(input())
high = list(map(int,input().split()))
count = 0
a = []

for i in range(1,N):
  a=[]
  for j in range(i):
    if high[i]-high[j]>=0:
      a.append(high[j])
  else:
    if len(a) == i:
      count += 1

print(count+1)  


Measured memory_bytes: 3060
STDIN.read.chomp.split("\n").each do |list|
  a, b, c, d, e, f = list.split.map(&:to_f)
  x = (b * f - c * e) / (b * d - a * e)
  y = (a * f - c * d) / (a * e - d * b)
  puts [x, y].map { |i| format('%.3f', i.zero? && i.abs || i) }.join(' ')
end

Measured memory_bytes: 8660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

int main(){
  string S; cin>>S;
  int l=0;
  ll ans=0;
  rep(i,S.length()){
    if(S[i]=='B'){
      break;
    }
    l++;
  }
  for(int i=l+1;i<S.length();i++){
    if(S[i]=='W'){
      ans+=1LL*(i-l++);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
  int n;
  string s, t;
  cin >> n >> s >> t;
  string ans;
  for (int i = 0; i < n; i++) ans += s[i], ans += t[i];
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
string a;
int main()
{
  cin>>a;
  int l=a.length();
  for(int i=0;i<l;i++)
    {
	  if(a[i]=='C')
	    for(int j=i+1;j<l;j++)
	      if(a[j]=='F')
	        {
	          cout<<"Yes";
	          return 0;
			}
	}
  cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pii pair<int,int>
using namespace std;
map<pii, int>Map;
int n, res;
pii w[60];
int main() {
	int i, j, k;
	cin>>n;
	res=n;
	for (i = 1; i <= n; i++) {
		cin>>w[i].first>>w[i].second;
		Map[w[i]] = 1;
	}
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= n; j++) {
			if (i == j)
				continue;
			int x = w[j].first - w[i].first, y = w[j].second - w[i].second;
			int c = 0;
			for (k = 1; k <= n; k++)
			{
				if (Map.count({ w[k].first + x,w[k].second + y }))
					c++;
			}
			res = min(res, n - c);
		}
	}
	cout<<res<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
    int n, ans=0;
    ll h, w;
    cin >> n >> h >> w;
    for(int i=0; i<n; i++){
        ll a, b;
        cin >> a >> b;
        if(h<=a && w<=b) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int N;
const int MAX_N = 20;
int H[MAX_N];

int main(){
  cin >> N;
  REP(i, N) cin >> H[i];
  int m = H[0];
  int ans = 1;
  REP(i, N - 1) {
    if(H[i + 1] >= m) {
      ans++;
      m = H[i + 1];
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int M = 1e9 + 7;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define vi vector
#define f(i,n) for(int i=0;i<n;++i)
#define endl "\n"
using namespace std;

//vector<ll> adj[1000001];
//int vis[1000001]; 
//
//int dfs(int node){
//	vis[node]=1;
//	for(int child: adj[node]){
//		if(!vis[child])
//		dfs(child);
//	}
//}


void solve()
{	
	int n,d,c=0; cin>>n>>d;
	for(int i=0;i<n;++i){
		double a,b; cin>>a>>b;
		double all =(sqrt((a*a)+(b*b)));
		if(all<=d){
			c++;
		}
	}
	cout<<c<<"\n"; 
}

int main(void)
{
    fast;
//	ll t;
//	cin>>t;
//    while(t--)
        solve();
}


Measured memory_bytes: 3856
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <map>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

class UnionFind {
private:
	unsigned size_; 
	std::vector<unsigned> par, rank;
public:
	UnionFind() : size_(0), par(std::vector<unsigned>()), rank(std::vector<unsigned>()) {};
	UnionFind(unsigned size__) : size_(size__) {
		par.resize(size_); rank.resize(size_);
		for (unsigned i = 0; i < size_; i++) par[i] = i, rank[i] = 0;
	}
	unsigned size() { return size_; }
	//unsigned root(unsigned x) { return par[x] == x ? x : par[x] = root(par[x]); }
	unsigned root(unsigned x)
	{
		while(par[x] != x)
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	bool same(unsigned x, unsigned y) { return root(x) == root(y); }
	void unite(unsigned x, unsigned y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++;
		else par[y] = x;
	}
	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N;
	map<ll, int> m;
	cin >> N;
	bool find = false;
	rep(i, N)
	{
		ll tmp;
		cin >> tmp;
		if (m.find(tmp) != m.end())
		{
			find = true;
		}
		m[tmp]++;
	}

	if (!find)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl; 
	}
	

	
	return 0;
}


Measured memory_bytes: 12800
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTS(s) printf("%s\n",(s))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))



int main() {
	int A, B, C, D;
	scanf("%d %d %d %d", &A, &B, &C, &D);
	if (A + B > C + D) {
		PRINTS("Left");
	}
	else if (A + B < C + D) {
		PRINTS("Right");
	}
	else {
		PRINTS("Balanced");
	}
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int k = K / 2;
		if(K % 2 == 0) {
			System.out.println(k*k);
		}else {
			System.out.println(k*(k+1));
		}
	}
}

Measured memory_bytes: 23252
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;


ll n,k,a[200010],f[200010],suma=0;
ll cost[200010];

bool ok(ll M){
    ll sum=0;
    rep(i,n){
        // cout<<i<<" "<<cost[i]<<" ";
        if(cost[i]<=M) continue;
        if(f[i]>M){
            sum+=a[i];
            continue;
        }
        ll s=M/f[i];
        sum+=(a[i]-s);
        // cout<<cost[i]<<" "<<sum<<endl;;
    }
    if(sum<=k) return true;
    else return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    cin>>n>>k;
    rep(i,n){
        cin>>a[i];
        suma+=a[i];
    }
    rep(i,n){
        cin>>f[i];
    }
    sort(a,a+n);
    sort(f,f+n);
    reverse(f,f+n);
    rep(i,n){
        cost[i]=a[i]*f[i];
    }
    if(suma<=k){
        cout<<0<<endl;
        return 0;
    }
    ll low=0,high=LLINF;
    while(high-low>=2){
        ll mid=(low+high)/2;
        if(ok(mid)){
            high=mid;
        }
        else{
            low=mid;
        }
    }
    // cout<<high<<" "<<low<<endl;
    cout<<high<<endl;
    return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

int main() {
  ll n, c, k;
  cin >> n >> c >> k;
  vl t(n);
  rep (i, n) {
    cin >> t[i];
  }
  sort(all(t));
  int ans = 1;
  int start = t[0];
  int cnt = 1;
  rep1 (i, n - 1) {
    if (cnt == c) {
      ans++;
      start = t[i];
      cnt = 1;
    }
    else if (t[i] - start > k) {
      ans++;
      start = t[i];
      cnt = 1;
    }
    else {
      cnt++;
    }
  }
  cout << ans << endl;
}


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

using namespace std;
int main(){
    int n,t;
    cin >> n >> t;
    int ans = 20000,count,c,d;
    for(int i=0; i<n; i++){
       cin >> c >> d;
       if(d<=t){
         ans=min(ans,c);
       }
    }
    if(ans==20000) cout << "TLE" << endl;
    else cout << ans << endl;
    return 0;   
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m;i>n;i--)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define mod 1000000007
#define MAX 510000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A=INF,B=0,C=INF,D=INF,E,F,N,M,K,sum=0,num=0,cnt=1,next=0;
  cin >> N;
  M=N-1;
  Out(N*M/2);
}


Measured memory_bytes: 256
#include <stdio.h>


int main(int argc, char const *argv[])
{
    int a, b, sub;
    int a_height;
    scanf("%d %d", &a, &b);
    sub = b - a;
    
    while(sub > 0){
        a_height += --sub;
    }
    
    printf("%d\n", a_height - a); 
    return 0;
}


Measured memory_bytes: 128
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int n,ans=-1;
    cin >> n;
    int a[110000];
    for(int i=0;i<n;i++){
        int b;
        cin >> b;
        a[b]++;
    }
    for (int i=1;i<=100000;i++) {
        ans = max(ans,a[i-1]+a[i]+a[i+1]);
    }
    cout << ans;
}

Measured memory_bytes: 640
N=int(input())
e=[0]*(N+1)
for i in range(2,N+1):
    cur=i
    for j in range(2,i+1):
        while cur%j==0:
            e[j]+=1
            cur//=j

def num(m):
    return len(list(filter(lambda x:x>=m-1,e)))

print(num(75)+num(25)*(num(3)-1)+num(15)*(num(5)-1)+num(5)*(num(5)-1)*(num(3)-2)//2)

Measured memory_bytes: 9084
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdio>
using namespace std;

static const int INF=100000;
typedef long long ll;
typedef pair<int,int> P;

int main(){
   int N,D;
   cin >> N >> D;
   int X[N][D];
   for(int i=0;i<N;i++){
      for(int j=0;j<D;j++){
         cin >> X[i][j];
      }
   }
   int cnt=0;
   for(int i=0;i<N;i++){
      for(int j=i+1;j<N;j++){
         double x=0;
         for(int k=0;k<D;k++){
            x+=pow(abs(X[i][k]-X[j][k]),2);
         }
         x=sqrt(x);
         if(ceil(x)==floor(x)) cnt++;
      }
   }
   cout << cnt << endl;
}


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

using namespace std;
typedef long long ll;

const ll INF = 1e18;
int a[300010];
ll A[100010], B[100010];

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

    ll sumA = 0, sumB = 0;
    priority_queue<int, vector<int>, greater<int> > queA;
    priority_queue<int> queB;
    for (int i = 0; i < 3 * n; i++) {
        cin >> a[i];
        if (i < n) {
            queA.push(a[i]);
            A[0] += a[i];
        } else if (i >= 2 * n) {
            queB.push(a[i]);
            B[n] += a[i];
        }
    }
    
    int v;
    for (int i = n; i < 2 * n; i++) {
        queA.push(a[i]);
        v = queA.top();
        queA.pop();
        A[i - n + 1] = A[i - n] + a[i] - v;
    }
    for (int i = 2 * n - 1; i >= n; i--) {
        queB.push(a[i]);
        v = queB.top();
        queB.pop();
        B[i - n] = B[i - n + 1] + a[i] - v;
    }

    ll ans = -INF;
    for (int i = 0; i <= n; i++)
        ans = max(ans, A[i] - B[i]);
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3832
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, string> pls;

int main()
{
	int N,K;
	cin >> N >> K;
	vector<int> v(N);

	for (int i = 0; i < N; i++)
		cin >> v[i];

	sort(all(v));
	reverse(all(v));

	ll ans = 0;
	for (int i = 0; i < K; i++)
		ans += v[i];

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


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

int main(void)
{
	int a, b;
	char op;
	int res;
	
	while (1){
		cin >> a >> op >> b;
	
		if (op == '?'){
			break;
		}
		if (op == '+'){
			res = a + b;
		}
		else if (op == '-'){
			res = a - b;
		}
		else if (op == '*'){
			res = a * b;
		}
		else if (op == '/'){
			res = a / b;
		}
		
		cout << res << endl;
	}
	
	return (0);
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include <vector>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
const ll MOD = 1e9 + 7;

int main() {
	int n;
	ll y;
	cin >> n >> y;
	int a = -1, b = -1, c = -1;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n - i; j++) {
			int k = n - i - j;
			if (y == 10000 * i + 5000 * j + 1000 * k) {
				a = i;
				b = j;
				c = k;
			}
		}
	}
	cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 256
#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>;

int main() {
  int d;
  cin >> d;
  vector<int> c(26);
  rep(i, 26) cin >> c[i];
  vector<vector<int>> s(d, vector<int>(26));
  rep(i, d) rep(j, 26) cin >> s[i][j];
  ll score = 0;
  vector<int> last(26, 0);
  for (int i = 1; i < d+1; i++) {
    // i日目
    int t;
    cin >> t;
    --t;
    last[t] = i;
    score += s[i-1][t];
    rep(j, 26) {
      score -= c[j] * (i - last[j]);
    }
    cout << score << '\n';
  }
  return 0;
}

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



int main()
{
	ll x;
	cin >> x;
	ll ans = 0;
	ll now = 0;
	for(int i = 1;;i++)
	{
		now += i;
		ans ++;
		if(now>=x)break;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
K,N = list(map(int, input().split()))
MAX = K+N+3
mod = 998244353

fac = [1]*(MAX+1)
for i in range(1,MAX+1):
	fac[i] = (fac[i-1]*i)%mod

rev_m = [1]*(MAX+1)
rev_m[MAX] = pow(fac[MAX],mod-2,mod)
for i in range(MAX,0,-1):
	rev_m[i-1] = (rev_m[i]*i)%mod

def Comb(n,k):#nCk
	return (fac[n]*rev_m[k]*rev_m[n-k])%mod


def f(n,k,i):
	if i == 2:
		if n < 0 or (k==1 and n>=2): #例外処理
			return 0
		elif n == 0:
			return 1
		else:
			return (Comb(k-2+n,n)+Comb(k-2+n-1,n-1)) % mod
	else: #i>2
		Sp = i//2-1
		ans = 0
		for p in range(Sp+1):
			ans += g(n,k,i,p)
		return ans % mod

def g(n,k,i,p):
	Sp = i//2-1
	if p == 0:
		return f(n-Sp,k-Sp,2) * pow(2,Sp,mod) % mod
	else: #p>0
		return g(n,k-2*p,i-2*p,0) * Comb(Sp,p)

ans = []
for i in range(2,K+2):
	if i%2 == 0:
		tmp = f(N,K,i)
	ans.append(tmp)
	print(tmp)

ans = ans[::-1]
for i in range(1,K):
	print(ans[i])


Measured memory_bytes: 3568
function main()
  
  (N,K) = map(x -> parse(Int,x), split(readline()))
  A = map(x -> parse(Int,x), split(readline()))
  
  dict = Dict()
  
  for i in A
    dict[i] = get(dict,i,0) + 1
  end
  
  vals = []
  for i in values(dict)
    push!(vals,i)
  end
  
  sort!(vals)
  
  cnt_keys = 0
  for i in keys(dict)
    cnt_keys += 1
  end
  
  ans = 0
  num = 1
  
  while cnt_keys > K
    ans += vals[num]
    cnt_keys -= 1
    num += 1
  end
  
  println(ans)
  
end

main()

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

using namespace std;

int N;

bool rec(int n, list<int>&l){
  if(n == 0)return true;
  auto it = l.begin();
  for(int i = n; i > 0; --i){
    if(*it == i){
      l.erase(it);
      if(!rec(n - 1, l))return false;
      cout << i << endl;
      return true;
    }
    it++;
  }
  return false;
}
  
int main(){
  cin >> N;
  list<int> l;
  for(int i = 0 ; i < N; ++i){
    int x; cin >> x; l.push_front(x);
  }
  if(!rec(N, l))cout << -1 << endl; 
  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using ll=long long; 
using ld=long double; 
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int mod=1e9+7;
#define MAX (int)1e6+3  
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x+=0x9e3779b97f4a7c15; x=(x^(x>>30))*0xbf58476d1ce4e5b9; x=(x^(x>>27))*0x94d049bb133111eb; return x^(x>>31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM=chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x+FIXED_RANDOM);
    }
};
int f[1000003]; 
int spf[MAX]; 
void spf_compute() 
{ 
    spf[1]=1; for(int i=2;i<MAX;i++) spf[i]=i; for(int i=4;i<MAX;i+=2)spf[i]=2; 
    for(int i=3;i*i<MAX;i++){ if(spf[i]==i){ for(int j=i*i;j<MAX;j+=i)if(spf[j]==j)spf[j]=i; } } 
} 
void getPF(int x,int& flag)
{ 
  unordered_map<int,int,custom_hash>repeat; 
  while(x!=1){ if(!repeat[spf[x]]){ f[spf[x]]++; if(f[spf[x]]>1){flag=1; break; } repeat[spf[x]]=1; } x=x/spf[x]; }
} 
int main()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout); 
  #endif 
  spf_compute(); 
  int n; cin>>n; vector<int>a(n); for(int i=0;i<=n-1;i++) cin>>a[i]; 
  int g=a[0]; for(int i=1;i<=n-1;i++) g=__gcd(g,a[i]); 
  if(g!=1){ puts("not coprime"); return 0; } int flag=0; 
  for(int i=0;i<=n-1;i++)
  {
    getPF(a[i],flag); 
    if(flag){ puts("setwise coprime"); return 0; }
  }
  puts("pairwise coprime"); return 0; 
}

Measured memory_bytes: 11504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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(){
    ll h1, m1, h2, m2, k; 
    cin>>h1>>m1>>h2>>m2>>k;
    ll t1 = h1*60 + m1;
    ll t2 = h2*60 + m2;
    cout<<t2-t1-k<<endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a > d || b < c)
    cout << 0 << endl;
  else {
    cout << min(b, d) - max(a, c) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int a, b;
int main(){
	scanf("%d %d", &a, &b);
	if (a < b){
		printf("a < b\n");
	}else if (a > b){
		printf("a > b\n");
	}else {
		printf("a == b\n");
	}
	return 0;
}


Measured memory_bytes: 2076
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
int main(){
  int n,q;
  string s;
  cin >> n >> s >> q;
  set<int> a[26];
  for(int i = 0;i < s.size();i++)a[(int)(s[i] - 'a')].insert(i);
  vector<int> ans;
  for(int i = 0;i < q;i++){
    int t;
    cin >> t;
    if(t == 1){
      int num = 0;
      char change;
      cin >> num >> change;
      num--;
      a[(int)(s[num] - 'a')].erase(num);
      a[(int)(change - 'a')].insert(num);
      s[num] = change;
    }
    else{
      int l,r;
      cin >> l >> r;
      l--,r--;
      int res = 0;
      for(int i = 0;i < 26;i++){
        auto moji = a[i].lower_bound(l);
        if(moji != a[i].end()){
          if(*moji <= r)res++;
        }
      }
      ans.push_back(res);
    }
  }
  for(auto item:ans) cout << item << endl;
  //cout << ans[ans.size() - 1] << endl;
}

Measured memory_bytes: 24452
n=int(raw_input())
a=map(int,raw_input().split())
a.sort()
s=a[0]
from math import fabs
for i in range(n-1):
	if fabs(a[n-1]/2.0-a[i])<fabs(a[n-1]/2.0-s):
		s=a[i]
print a[n-1],s

Measured memory_bytes: 11308
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M,X,Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N), y(M);
  for (int i=0;i<N;i++) {
    cin >> x.at(i);
  }
  for (int i=0;i<M;i++) {
    cin >> y.at(i);
  }
  
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  
  if (max(X, x.at(N-1)) < min(Y, y.at(0))) {
    cout << "No War" << endl;
  }
  else {
    cout << "War" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL (1LL<<62) // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

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

Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
using namespace std;
typedef long long ll;
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(ll i=0;i<(n);i++)

const ll mod = 1000000007;

int main(void){
	ll n; ll t;
	cin >> n >> t;
	vector<ll> d(n);
	rep(i, n) scanf("%lld", &d[i]);

	sort(all(d));
	ll ans = 1;
	//????????\????????´????????¢?????????????????????????¢??????????????????¨??????????????????????????§???????????¢?´¢??¨???lower_bound??¢??°(???????????????"??\???"???????´?????????????????????????????????????)
	//i + 1????????§?????\??£???????????°???????????¨??????????°??????°????????\?????????
	//lower_bound????????£???????????¶????????????????????°???????????????????????¶????????????????????°??????????¨?????¨???????????????¨???(i + 1)??????????????°??????????????°???????????????????????????
	rep(i, n){
		ans = ans * (i + 1 - (ll)(lower_bound(d.begin(), d.begin() + i + 1, d[i] - t) - d.begin())) % mod;
	}

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

Measured memory_bytes: 3616
#include<cstdio>
#include<vector>
#define MAX 1000000

using namespace std;

int numbers[MAX], cnt;
vector<int> G;

void insertionSort(int n, int g)
{
    int i, j, pivot;
    for (i = g; i < n; i++) {
        pivot = numbers[i];
        j = i - g;
        while (j >=0 && numbers[j] > pivot) {
            numbers[j + g] = numbers[j];
            j = j - g;
            cnt++;
        }
        numbers[j + g] = pivot;
    }
}

void shellSort(int n)
{
    int h;
    for(h = 1;;) {
        G.push_back(h);
        h = 3 * h + 1;
        if (h > n) break;
    }
    for (int i = G.size() - 1; i >= 0; i--) {
        insertionSort(n, G[i]);
    }
}

int main()
{
    int n, i;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &numbers[i]);
    }
    cnt = 0;
    shellSort(n);
    printf("%d\n", G.size());
    for (i = G.size() - 1; i >= 0; i--) {
        printf("%d", G[i]);
        if (i) printf(" ");
    }
    printf("\n%d\n", cnt);
    for (i = 0; i < n; i++) printf("%d\n", numbers[i]);

    return 0;
}

Measured memory_bytes: 6560
#include <iostream>
#include <vector>
using namespace std;
const int MOD =1000000007;
int main(){
  int N,M;cin>>N>>M;
  vector<bool>issafe;
  issafe.assign(N+1,true);
  for (int i=0;i<M;++i){
    int a;cin>>a;
    issafe[a]=false;
  }
  vector<int>dp(N+1,0);
  dp[0] = 1;
  if (issafe[1]) dp[1] = 1;
  for (int i = 2; i <= N; ++i) {
    if (issafe[i-1])dp[i]+=dp[i-1];
    if (issafe[i-2])dp[i]+=dp[i-2];
    dp[i]%=MOD;
  }
  cout<<dp[N]<<endl;
}

Measured memory_bytes: 640
def main():
    H, N = map(int, input().split())
    ABN = []
    for _ in range(N):
        A, B = map(int, input().split())
        ABN.append((A, B))

    dp = [999999999999999999999 for _ in range(H + 1)]
    dp[H] = 0

    for h in range(H - 1, -1, -1):
        for A, B in ABN:
            if h + A <= H:
                dp[h] = min(dp[h], dp[h + A] + B)
            else:
                dp[h] = min(dp[h], B)

    print(dp[0])


main()


Measured memory_bytes: 42348
// D - Coloring Edges on Tree
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

inline void write(int x){
	if(x<0){putchar('-'),write(-x);}
	else{if(x>9)write(x/10);putchar('0'+x%10);}
}

int main(){
	int N; cin>>N;
	int G[N], C[N-1];
	rp(i, 0, N-1){
		int p; scanf("%d%d", &p, C+i);
		G[--C[i]] = p-1;
	}

	int K = 1;
	int pre_colors[N]; rp(i, 0, N) pre_colors[i] = 0;

	rp(c, 1, N){
		int p = G[c];
		int color = pre_colors[p] + 1;
		pre_colors[p] = G[c] = color==G[p]? ++color: color;
		K = max(K, color);
	}

	write(K);puts("");
	for(int c:C) write(G[c]),puts("");
}

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

using namespace std;

int main()
{
  int N, M;
  while(cin >> N >> M, N) {
    string S[12], T;
    int sum = 0;
    for(int i = 0; i < N; i++) cin >> S[i], sum += S[i].size();
    for(int i = 0; i < M; i++) {
      string q;
      cin >> q;
      T += q;
    }

    vector< int > pos(1 << N, 0);
    for(int i = 0; i < 1 << N; i++) {
      for(int j = 0; j < N; j++) if((i >> j) & 1) pos[i] += S[j].size();
    }

    long long ret = 0LL;
    for(int i = 0; i <= (int) T.size() - sum; i++) {
      bitset< 1 << 12 > dp;
      dp[0] = true;
      for(int j = 0; j < 1 << N; j++) {
        if(!dp[j]) continue;
        for(int k = 0; k < N; k++) {
          if((j >> k) & 1) continue;
          if(dp[j | (1 << k)]) continue;
          if([&]()
          {
            for(int l = 0; l < S[k].size(); l++) {
              if(S[k][l] != T[i + l + pos[j]]) return (false);
            }
            return (true);
          }())
            dp[j | (1 << k)] = true;
        }
      }
      ret += dp[(1 << N) - 1];
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  for (int i = 0; i < n; i++){
    vector<int> a;
    while (1){
      int x;
      cin >> x;
      if (x == 0){
        break;
      }
      a.push_back(x);
    }
    int m = a.size();
    int V = 0;
    vector<vector<int>> E;
    vector<pair<int, int>> R;
    for (int j = 0; j < m; j++){
      if (a[j] > 0){
        R.push_back(make_pair(V, a[j]));
        E.push_back(vector<int>(0));
        V++;
        if (R.size() > 1){
          int v = R[R.size() - 2].first;
          int w = R[R.size() - 1].first;
          E[v].push_back(w);
          E[w].push_back(v);
          R[R.size() - 2].second--;
          R[R.size() - 1].second--;
        }
      } else {
        int v = R[R.size() - 1].first;
        int w = R[R.size() - 1 + a[j]].first;
        E[v].push_back(w);
        E[w].push_back(v);
        R[R.size() - 1].second--;
        R[R.size() - 1 + a[j]].second--;
      }
      while (R.back().second == 0){
        R.pop_back();
        if (R.empty()){
          break;
        }
      }
    }
    for (int j = 0; j < V; j++){
      sort(E[j].begin(), E[j].end());
      cout << j + 1;
      for (int k : E[j]){
        cout << ' ' << k + 1;
      }
      cout << endl;
    }
  }
}


Measured memory_bytes: 3032
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = null;
		PrintStream out = null;
		try {
			sc = new Scanner(System.in);
			out = System.out;
			exec(sc, out);
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			if(out != null) {
				out.close();
			}
			if(sc != null) {
				sc.close();
			}
		}
		System.exit(0);
	}
	public static void exec(final Scanner sc, final PrintStream out) throws Exception{
		final String s = sc.next();
		final String t = sc.next();

		final int index[][] = new int[s.length()+1][26];
		Arrays.fill(index[s.length()], -1);

		for(int i=s.length()-1;i>=0;i--) {
			for(int l=0;l<26;l++) {
				index[i][l]=index[i+1][l];
			}
			int l = s.charAt(i) - 'a';
			index[i][l]=i;
		}

		/*
		for(int i=0;i<index.length;i++) {
			out.print(index[i][0]);
			for(int l=1;l<26;l++) {
				out.print("\t"+index[i][l]);
			}
			out.println();
		}
		*/

		long offset = 0;
		int cursor = 0;

		for(int i=0;i<t.length();i++) {
			final int letter = t.charAt(i)-'a';
			final int next = index[cursor][letter];
			if(next == -1) {
				if(cursor == 0) {
					out.println("-1");
					return;
				}else {
					offset += s.length();
					cursor = 0;
					i--; // unread
					continue;
				}
			}else {
				cursor = next+1;
			}
		}
		out.println(offset + cursor);

		/*
		final int[] pos = new int[s.length()];
		for(int i=0;i<s.length();i++) {
			final int letter = s.charAt(i)-'a';
			pos[i] = (letter<<24 | i);
		}
		Arrays.sort(pos);
		final int[] index = new int[26];
		int head = 'a' << 24;
		int curIndex = 1;
		for(int i=0;i<pos.length;i++) {
			if((pos[i]&head)!=head) {
				head = pos[i]&0xFF000000;
				index[curIndex]=i;
				curIndex++;
			}
		}



		final int[] scnt = new int[26];
		final int[] tcnt = new int[26];

		for(int i=0;i<s.length();i++) {
			final int letter = s.charAt(i)-'a';
			scnt[letter]++;
		}
		for(int i=0;i<t.length();i++) {
			final int letter = t.charAt(i)-'a';
			tcnt[letter]++;
		}

		int loop = 0;

		for(int i=0;i<26;i++) {
			if(scnt[i]==0 && tcnt[i]!=0) {
				out.println(-1);
				return;
			}
			if(scnt[i] < tcnt[i]) {
				loop = Math.max(loop, tcnt[i]/scnt[i]);
			}
		}




		final int head[] = new int[26];
		Arrays.fill(head, Integer.MAX_VALUE);

		final boolean contains[] = new boolean[26];

		for(int i=0;i<s.length();i++) {
			final int letter = s.charAt(i)-'a';
			head[letter] = Math.min(head[letter], i);
		}
		for(int i=0;i<t.length();i++) {
			final int letter = t.charAt(i)-'a';
			contains[letter] = true;
		}

		for(int i=0;i<26;i++) {
			if(contains[i] && (head[i]==Integer.MAX_VALUE)) {
				out.println("-1");
				return;
			}
		}
		final int headLetter = t.charAt(0)-'a';
		out.println(head[headLetter]);
	*/
	}
}


Measured memory_bytes: 40788
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      long H = sc.nextLong();
      long count =0;
      if(H==1){
        System.out.println(1);
      }else{
      while(true){
        H/=2;
        count++;
        if(H==1){
          break;
        }
      }
      long ans =1+2*((long)Math.pow(2,count)-1);
      System.out.println(ans);
      }
    }
}

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

using namespace std;


int main()
{
    int x,y;

    scanf("%d %d", &x, &y);

    if(x==2 && y==2)
        printf("Yes\n");
    else if((x==4 || x==6 || x==9 || x==11) && (y==4 || y==6 || y==9 || y==11))
        printf("Yes\n");
    else if((x==1 || x==3|| x== 5|| x==7 || x==8 || x==10 || x==12) && (y==1 || y==3|| y== 5|| y==7 || y==8 || y==10 || y==12))
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
d=[0]
w=set([0])
x=0
for i in range(n):
    if a[x]-1 not in w:
        d.append(a[x]-1)
        w.add(a[x]-1)
        x=a[x]-1
    else:
        f=a[x]-1
        break

#print(d)
if k<len(d):
    print(d[k]+1)
else:
    x=k-len(d)
    y=d.index(f)
    z=len(d)-y
    #print(d,f,x,y,z)
    #exit()
    print(d[y+x%z]+1)


Measured memory_bytes: 125168
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N;
  cin>>N;
  vector<Int> cnt(N);
  for(Int i=1;i<N;i++){
    Int p;
    cin>>p; p--;
    cnt[p]++;
  }

  for(Int i=0;i<N;i++) cout<<cnt[i]<<endl;

  return 0;
}


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

int ctoi(char c) {
	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}


int main() {
  string X;
  cin >> X;
  
  int sum=0;
  int N=X.size();
  //文字列として認識
  for(int i=0; i<N; i++){
    sum += ctoi(X[i]);
  }
  
  //各桁の和が９の倍数か判定　0の場合を排除
  if(sum % 9 == 0 ) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3676
#include<iostream>
#include<string>
using namespace std;
int main(){
  string a;
  cin >> a;
  if(a=="SUN"){
      cout<<7<<endl;
  }else if(a=="MON"){
      cout<<6<<endl;
  }else if(a=="TUE"){
      cout<<5<<endl;
  }else if(a=="WED"){
      cout<<4<<endl;
  }else if(a=="THU"){
      cout<<3<<endl;
  }else if(a=="FRI"){
      cout<<2<<endl;
  }else if(a=="SAT"){
      cout<<1<<endl;
  }
     
  
  return 0;
  
}

Measured memory_bytes: 256
s = gets.chomp
a = s[0..1].to_i
b = s[2..-1].to_i

if a == 0 && b == 0
  print("NA")
elsif a == 0
  if b > 12
    print("NA")
  else
    print("YYMM")
  end
elsif b == 0
  if a > 12
    print("NA")
  else
    print("MMYY")
  end
elsif a > 12 && b > 12
  print("NA")
elsif a > 12
  print("YYMM")
elsif b > 12
  print("MMYY")
else
  print("AMBIGUOUS")
end

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

/*これが一番いいとは思わないが...ごり押し*/
int main(){
  string S;
  cin >> S;
  int n = stoi(S);
  int a = n / 100;
  int b = n - 100 * a;

  if(a == 0){                                 //上2桁0  ->下二桁は0か13以上はアウト
    if(1 <= b && b <= 12)
      cout << "YYMM" << endl;
    else
      cout << "NA" << endl;
  }else if(1 <= a && a <= 12){        //上二桁1以上12以下 -> 下二桁がなんでも、存在
    if(1 <= b && b <= 12)
      cout << "AMBIGUOUS" << endl;
    else
      cout << "MMYY" << endl;
  }else{
    if(1 <= b && b <= 12)                   //上二桁が13以上 -> 下二桁は1以上12以下しかない...
      cout << "YYMM" << endl;
    else
      cout << "NA" << endl;
  }

  return 0;
}

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

int main(){
	int h,w;
	while(1){
		scanf("%d %d",&h,&w);
		if(h==0&&w==0){break;}
		
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){printf("#");}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1000
#include<stdio.h>
#include<iostream>
using namespace std;
int count = 0;
int b[101];
int i;
int n;
int main(void)
{
	scanf("%d",&n);
	for(i = 1;i<n;i++) scanf("%d",b+i);
	
	for(i = 2;i<=n-1;i++) count+=min(b[i-1],b[i]);
	
	count+=b[1]+b[n-1];
	printf("%d",count);
	return 0;
}

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

int main(){
  int n;
  int tmp,tmp2;
  cin>>n;
  long long int x[n],y[n];
  long long int ans[n];
  long long min;

  for(int i=0;i<n;i++)cin>>x[i];
  for(int i=0;i<n;i++)y[i]=x[i];


  // for(int i=0;i<n/2+1;i++){
  //   min = 0;
  //   for(int j=0;j<n;j++){
  //     if(min>x[j])min=j;
  //   }
  //   tmp=x[min];
  //   x[min]=x[i];
  //   x[i]=tmp;
  // }
  sort(x,x+n);

  for(int i=0;i<n;i++){
    tmp=0;
    if(y[i]>=x[n/2+tmp])tmp=-1;
    cout<<x[n/2+tmp]<<endl;
  }
}


Measured memory_bytes: 5248
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 998244353
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0};
int dy[8]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll x,y;cin>>x>>y;
    ll cnt=0;
    while(x<=y){
        x*=2;
        cnt++;
    }
    cout<<cnt<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256