akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>

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

    string s;
    cin>>s;
    ll k;
    cin>>k;
    int f=0;
    ll sl=s.length();
    for(int i=0;i<min(sl,k);++i)
    {
        if(s[i]!='1')
        {
            cout<<s[i];
            f=1;
            break;
        }
    }
    if(f==0)
    {
        cout<<"1";
    }

return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
        typedef long long ll;
        typedef long double ld;
        typedef pair<ll, ll> l_l;
        typedef pair<int , int> i_i;
        typedef vector<ll> vl;
        typedef vector<int> vi;
        typedef vector<char> vec;
        typedef vector<bool> veb;
        typedef vector<string> ves;
        typedef vector<vector<ll>> vvl;
        typedef vector<vector<int>> vvi;
        typedef vector<vector<char>> vvec;
        typedef vector<vector<bool>> vveb;
        typedef vector<vector<string>> vves;
        #define rep(i,n) for(int i=0;i<(int)(n);i++)
        #define rep1(i,n) for(int i=1;i<(int)(n);i++)
        #define rep2(i,n) for(int i=2;i<(int)(n);i++)
        #define repk(i,k,n) for(int i=k;i<(int)(n);i++)
        #define fs first
        #define sc second
        #define pb push_back
        #define pp pop_back
        #define all(a) a.begin(),a.end()
        #define rall(a) a.rbegin(),a.rend()
        #define maxel(a) *max_element(all(a))
        #define minel(a) *min_element(all(a))
        #define acc accumulate
        #define EPS (1e-7)
        #define INF (1e9)
        #define PI (acos(-1))
        #define mod (1000000007)
        typedef long long int64;
        //const int64 INF = 1LL << 58;
        #define dame { puts("-1"); return 0;}
        #define YES { cout << "YES" << endl; return 0; }
        #define NO { cout << "NO" << endl; return 0; }
        #define Yes { cout << "Yes" << endl; return 0; }
        #define No { cout << "No" << endl; return 0; }
        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; }
        int dx[] = {0, 0, -1, 1};
        int dy[] = {1, -1, 0, 0};
         
        int main(){
        	cin.tie(0);
        	ios::sync_with_stdio(false);
         
          int A[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
          int k;
          cin >> k;
          cout << A[k-1] << endl;
         return 0;
        }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
long long N;
  cin >> N;
  
  long long res;
  
  vector<long long> vec(5);
  for(int i = 0; i < 5; i++) {
    cin >> vec.at(i);
  }
  long long mi = 9999999999999999;
   for(int i = 0; i < 5; i++) {
     if(mi > vec.at(i)) {
       mi = vec.at(i);
     }
   }
  
  if(N % mi == 0) {
  res = N / mi + 4;
  }
  else {
    res = N / mi + 5;
  }
  
  cout << res << endl;
  
  
  return 0;
}

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

int main() {
  string S;
  cin >> S;
  
  if(S == "ABC"){
    cout << "ARC" << endl;
  } 
  if(S == "ARC"){
    cout << "ABC" << endl;
  }
  
  return 0;
  
}


Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int main(){
    long long  N;
    cin >> N;
    long long ans=0;
    for(long long i=1;i<N+1;i++){
        if(i%3==0){
            continue;
        }
        if(i%5==0){
            continue;
        }
        ans+=i;
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<char, ll> P;
//typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

const ll mod = 1000000007;
const ll INF = 100000000000010000;

ll bit[700010];
int kai[2];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

ll sum(ll i)
{
	ll t = 0;
	while (i > 0)
	{
		t += bit[i];
		i -= i & -i;
	}
	return t;
}

void add(ll i, ll x)
{
	while (i <= 700005)
	{
		bit[i] += x;
		i += i & -i;
	}
}

void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll y) {
	if (y == 0) return 1;
	if (y % 2 == 1) {
		return x * pow_mod(x, y - 1) % mod;
	}
	else {
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

ll com(ll x, ll y) {
	return kai[x] * div_mod(kai[y] * kai[x - y] % mod) % mod;
	//毎回オーダーlog(n)かかる
}

string S;
map<char, ll> cnt_char;
ll num[200010];
ll ans;
vector<P> former, latter;
map<P, ll> mp;

void solve() {
	cin >> S;
	for (ll i = 0; i < S.length(); i++) {
		cnt_char[S[i]]++;
		num[i] = cnt_char[S[i]];
	}

	ll odd = 0;
	for (auto itr = cnt_char.begin(); itr != cnt_char.end(); ++itr) {
		if (itr->s % 2 == 1) odd++;
	}
	if (odd > 1) {
		cout << -1 << endl;
		return;
	}

	ll num_latter = 0, num_fomer = 0;
	for (int i = 0; i < S.length(); i++) {
		if (cnt_char[S[i]] % 2 == 1) {
			if (num[i] <= cnt_char[S[i]] / 2) {
				ans += num_latter;
				num_fomer++;
				former.push_back(P(S[i], num[i]));
			}
			else if (num[i] > cnt_char[S[i]] / 2 + 1) {
				num_latter++;
				latter.push_back(P(S[i], num[i]));
			}
			else {
				ans += num_latter;
				ans += S.length() / 2 - num_fomer;
			}
		}
		else {
			if (num[i] <= cnt_char[S[i]] / 2) {
				ans += num_latter;
				num_fomer++;
				former.push_back(P(S[i], num[i]));
			}
			else {
				num_latter++;
				latter.push_back(P(S[i], num[i]));
			}
		}
	}
	reverse(latter.begin(), latter.end());
	
	for (int i = 0; i < latter.size(); i++) {
		char c = latter[i].f;
		ll n = cnt_char[c] + 1 - latter[i].s;
		mp[P(c, n)] = i + 1;
	}
	for (P p : former) {
		ans += sum(S.length()) - sum(mp[p]);
		add(mp[p], 1);
	}

	cout << ans << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	ll N;
	cin >> N;
}
////////////////////////////////////////////////////////////////////////////////////////////jagfhaoi;sd;joi;asdfjzasdi;lfjoi;ernjsdoivcnoizvdfnvdfnon/////////////////////////////////////////////////////////
////////////////////jgoiadhsjgoi;vsjvgfonhjasoivhoivhno

Measured memory_bytes: 16008
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

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

	int ans = 0;
	int ans2 = 0;
	rep(i, n) {
		int a = i + 1;
		int res = 0;
		while (a % 2 == 0) {
			res++;
			a /= 2;
		}
		if (ans < res) {
			ans = res;
			ans2 = i + 1;
		}
	}

	dunk(ans == 0 ? n : ans2);

	return 0;
}

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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
    
    int n,m;
    cin>>n>>m;

    pvec ans;

    int memo=m;
    for(int i=1;i<n;i++){
        if(memo<=0) break;
        ans.eb(i,i+memo);
        memo-=2;
        
    }
    memo=m-1;
    for(int i=n;i>=0;i--){
        if(memo<=0) break;
        ans.eb(i,i-memo);
        memo-=2;
    }
    rep(i,m){
        cout<<ans[i].fs<<" "<<ans[i].sc<<endl;
    }
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

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

constexpr int64_t INF = 1'010'000'000'000'000'017LL;
constexpr int64_t MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define FOR(i, start, end) for(int64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

// 最小公倍数lcm=m*n/gcd
uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// nCm
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

signed main() {
  int64_t n, k;
  cin >> n >> k;

  vector<int64_t> A(n,0);
  int64_t d, ad;
  REP(i, k){
    cin >> d;
	REP(j, d){
      cin >> ad;
      A[ad-1] = 1;
    }
  }
  int answer = 0;
  REP(i, n){
    if(A[i] == 0) answer++;
  }
  cout << answer;
  return 0;
}

Measured memory_bytes: 3632
T,N,P[9],R[9],res,c;
char S[9];
void dfs(char *p,int d)
{
	int i,t;
	char s[9]={0};
	if(p[0]==0)
	{
		for(i=t=0;i<d;i++)t+=P[i];
		if(t==res)c++;
		if(T>=t&&abs(T-t)<abs(T-res)){c=0;memcpy(R,P,sizeof(R));res=t;}
		return;
	}
	for(i=0;i<strlen(p);i++){s[i]=p[i];P[d]=atoi(s);dfs(p+i+1,d+1);P[d]=-1;}
	return;
}
main()
{
	int i;
	for(;scanf("%d %s",&T,S),T;)
	{
		res=-1000000;c=0;
		memset(P,-1,sizeof(P));
		dfs(S,0);
		if(res==-1000000)puts("error");
		else if(c)puts("rejected");
		else{printf("%d",res);for(i=0;R[i]!=-1;i++)printf(" %d",R[i]);puts("");}
	}
	return 0;
}

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

int main(){
  
  string a;
  	cin >> a;
  
  int price = 700;
  
    if(a[0]=='o') price += 100;
    if(a[1]=='o') price += 100;   
    if(a[2]=='o') price += 100;

	cout << price << endl;
}

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

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

#define PB push_back
#define pb push_back

#define MP make_pair
#define mp make_pair
#define PII pair<int,int>
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>

#define ALL(a) (a).begin(),(a).end()
#define all(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define VS vector<string>
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define in scanf
#define out printf
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())

using namespace std;

int main() {
    int N;
    in("%d", &N);
    out("%d\n", N*(N+1)/2);
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define mrep(p,mp) for(auto p : mp)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
int n,d,x;
cin >> n >> d >> x;
vector<int> a(n);
rep(i,n) cin >> a[i];
int ans = 0;
rep(i,n)
    rep(j,d){
    if((a[i]*j+1) <= d){
            ans ++;
    }
    else{
        continue;
    }
    }
ans += x;
cout <<  ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=111;
int a[N],n,s;
int main(){
#ifdef flukehn
	freopen("g.in","r",stdin);
#endif
	cin>>n>>s;
	int i;
	for(i=1;i<=n;++i)
		cin>>a[i];
	sort(a+1,a+n+1);
	for(i=1;i<=n;++i)
		if(a[i]>s)break;
		else s-=a[i];
	printf("%d\n",i-1-(i>n&&s>0));
}

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

int main(void){
    int a[3][3], n, b[10];
    bool res = false;
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++) cin >> a[i][j];
    }
    cin >> n;
    for(int i = 0; i < n; i++) cin >> b[i];

    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            for(int l = 0; l < 3; l++){
                if(b[i] == a[j][l]) a[j][l] = 0;
            }
        }
    }
    if(a[0][0] == 0){
        if(a[0][1] == 0){
            if(a[0][2] == 0) res = true;
        }
        if(a[1][0] == 0){
            if(a[2][0] == 0) res = true;
        }
    }
    if(a[2][2] == 0){
        if(a[1][2] == 0){
            if(a[0][2] == 0) res = true;
        }
        if(a[2][1] == 0){
            if(a[2][0] == 0) res = true;
        }
    }
    if(a[1][1] == 0){
        if(a[0][0] == 0){
            if(a[2][2] == 0) res = true;
        }
        if(a[0][1] == 0){
            if(a[2][1] == 0) res = true;
        }
        if(a[1][0] == 0){
            if(a[1][2] == 0) res = true;
        }
        if(a[2][0] == 0){
            if(a[0][2] == 0) res = true;
        }
    }
    
    if(res) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

namespace ABC115A
{
	class Program
	{
		static void Main(string[] args)
		{
			int n;
			n = int.Parse(Console.ReadLine());

			if (n == 25)
				Console.Write("Christmas");


			else if (n == 24)
				Console.Write("Christmas Eve");

			else if (n == 23)
				Console.Write("Christmas Eve Eve");

			else  
				Console.Write("Christmas Eve Eve Eve");

			Console.ReadKey();

		}
	}
}


Measured memory_bytes: 13140
import std.stdio,std.string,std.conv;

char c[12][12]; 
int dx[4] = [1,0,-1,0];
int dy[4] = [0,1,0,-1];

void dfs(int x,int y)
{
	c[x][y] = '0';

	foreach(i;0..4)
	{
		int nx = x + dx[i];
		int ny = y + dy[i];

		if(0 <= nx && nx < 12 && 0 <= ny && ny < 12)
		{
			if(c[nx][ny] == '1')
			{
				dfs(nx,ny);
			}
		}
	}
}


int main()
{
	string s;
	string s2;
	bool flag = true;
	while(true)
	{
		if(flag)
		{
			s = readln.chomp;
			c[0] = s;
			foreach(i;1..12)
			{
				s = readln.chomp;
				c[i] = s;
			}
			flag = false;
		}
		else
		{
			s = readln.chomp;
			s2 = readln.chomp;
			if(s2.length == 0)
			{
				return 0;
			}
			else
			{
				c[0] = s2;
				foreach(i;1..12)
				{
					s = readln.chomp;
					c[i] = s;
				}
			}
		}

		int count = 0;

		foreach(i;0..12)
		{
			foreach(j;0..12)
			{
				if(c[i][j] == '1')
				{
					dfs(i,j);
					count++;
				}
			}
		}

		count.writeln;
	}
	return 0;
}

Measured memory_bytes: 1052
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <set>

using namespace std;

int main() {
  
    int a,b,c,k ;
    cin>>a>>b>>c>>k ;

   int cnt = 0 ;
   int ans = 0 ;
        for (int i = 0; i < a; i++)
        {
                        if(cnt==k) break ;
            cnt++ ;
            ans+= 1 ;

        }        
    
        for (int i = 0; i < b; i++)
        {
            if(cnt==k) break ;
            cnt++ ;
            ans+= 0 ;
        }        

         for (int i = 0; i < c; i++)
        {

            if(cnt==k) break ;
                        cnt++ ;
            ans+= -1 ;
        }        

 cout << ans << endl ;


  return 0 ;
}

Measured memory_bytes: 3624
# ユークリッドの互除法 => 最大公約数
def gcd(a, b)
  a, b = b, a if a < b
  until b == 0
    a, b = b, a%b
  end
  return a
end

# 最小公倍数
def lcm(a, b)
  a*b/gcd(a, b)
end

while gets do
  a, b = $_.split(' ').map(&:to_i)
  puts "#{gcd(a, b)} #{lcm(a, b)}"
end

Measured memory_bytes: 6096
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << "Line(" << __LINE__ << ") -> " << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, M = 1e9 + 7;

signed main()
{
	IO_OP;
	
	int n, k;
	cin >> n >> k;
	vi dp(k + 1);
	dp[0] = 1;
	for(int i = 0; i < n; i++) {
		for(int i = 1; i <= k; i++) dp[i] = (dp[i] + dp[i - 1]) % M;
		int x;
		cin >> x;
		vi nw_dp(k + 1);
		for(int i = 0; i <= k; i++) {
			int l = i - x;
			if(l > 0) nw_dp[i] = (dp[i] - dp[l - 1] + M) % M;
			else nw_dp[i] = dp[i];
		}
		dp = nw_dp;
	}
	cout << dp[k] << endl;
}



Measured memory_bytes: 4028
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    long long a,b;
    cin >> a >> b;
    if(a<b) swap(a,b);
    if((a-b)%2==1) cout << "IMPOSSIBLE" << endl;
    else cout << (a+b)/2 << endl;
}

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

#define int long long 

signed main()
{
  int n,w;
  cin>>n>>w;
  vector<vector<int>> a(4,vector<int>(0));
  int ww,tmp;
  cin>>ww>>tmp;
  a[0].emplace_back(tmp);
  for(int i=1; i<n; i++)
  {
    int s,t;
    cin>>s>>t;
    a[s-ww].emplace_back(t);
  }
  
  
  rep(i,4) sort(a[i].begin(), a[i].end(), greater<int>());
  rep(i,4) for(int j=0; j+1<a[i].size(); j++) a[i][j+1] += a[i][j];
 
  //rep(i,4){for(auto x:a[i]) cout<<x<<" "; cout<<endl;}
  int res = 0;
  for(int i=0; i<=a[0].size(); i++)
  {
    for(int j=0; j<=a[1].size(); j++)
    {
      for(int k=0; k<=a[2].size(); k++)
      {
        for(int l=0; l<=a[3].size(); l++)
        {
          if((i+j+k+l)*ww + j*1+k*2+l*3 > w) continue;
          int sum = 0;
          if(i) sum += a[0][i-1];
          if(j) sum += a[1][j-1];
          if(k) sum += a[2][k-1];
          if(l) sum += a[3][l-1];
          res = max(res, sum);
        }
      }
    }
  }
  cout<<res<<endl;
  
  //return 0;
}

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

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] arg) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			T[] ts = new T[N];
			for (int i = 0; i < N; ++i) {
				ts[i] = new T();
			}
			Arrays.sort(ts);
			for (int i = 0; i < N; ++i) {
				System.out.println(ts[i].name);
			}
			System.out.println("#");
		}
	}

	static class T implements Comparable<T> {
		String name;
		int[] v = new int[9];

		T() {
			name = sc.next();
			for (int i = 0; i < 9; ++i) {
				v[i] = sc.nextInt();
			}
		}

		public int compareTo(T o) {
			int v = Double.compare(o.p(), p());
			return v == 0 ? name.compareTo(o.name) : v;
		}

		double p() {
			int profit = v[6] * v[7] * v[8] - v[0];
			int time = v[1] + v[2] + v[3] + v[4] + v[5] + (v[4] + v[5]) * (v[8] - 1);
			return 1. * profit / time;
		}

	}
}

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

long long pow2[1000000];
int counter , x , y;

double Distance(int x , int y){
   double Dis = sqrt(pow2[abs(x)] + pow2[abs(y)] ) ;
   return Dis;
}

int main()
{
	for(int i = 0 ; i < 1000000 ; ++i)
		pow2[i] = pow(i , 2);
	
	int t = 0;
	cin>>t;
	double d = 0;
	cin>>d;
	
	while(t--){
		cin>>x>>y;
		if (Distance(x , y) <= d)
		   counter++;
	}
	
	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 10972
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
 */
//入力終了→Ctrl+D
import java.time.Year;
import java.util.*;
import java.awt.*;
import java.awt.Graphics.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        while (sc.hasNext())out.println(gcd(sc.nextInt(),sc.nextInt()));
    }
    static int gcd(int i,int j){
        return j==0?i:gcd(j,i%j);
    }
}


Measured memory_bytes: 26248
import sys

import bisect

# from collections import Counter, deque, defaultdict

# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
import math

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    q = int(input())

    for i in range(q):
        a, b = list(map(int, readline().split()))

        if a > b:
            a, b = b, a

        if a == b or a + 1 == b:
            print(2 * a - 2)
        else:
            ab = a * b
            ok = 0
            ng = int(ab ** 0.5) + 1000000
            while abs(ng - ok) > 1:
                mid = (ok + ng) // 2
                if mid ** 2 < ab:
                    ok = mid
                else:
                    ng = mid
            c = ok

            if c * (c + 1) < ab:
                print(2 * c - 1)
            else:
                print(2 * c - 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 40432
import Control.Applicative
import System.IO
import Control.Monad
import Data.List
import Data.List.Split

bmi h w =  w / h^2

convert :: [String] -> Bool
convert [] = False
convert (a:b:c:_) = 
    let
        h = read c :: Double
        w = read b :: Double
    in
        bmi h w >= 25

main = do
    c <- lines <$> getContents
    mapM_ putStrLn . map (\(c:_) -> c) 
        $ filter convert $ map (splitOn ",") c



Measured memory_bytes: 4040
#include <iostream>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<string>
#include<sstream>
#include<queue>
#include<map>
#include<set>
using namespace std;
int main()
{
    int n,x,y;
    cin>>n;
    x=n%100;
    y=n/100;
    if(y>=1&&y<=12&&x>=1&&x<=12)
        printf("AMBIGUOUS");
    else
    {
        if((x==0||x>12)&&y>=1&&y<=12)
        printf("MMYY");
        else if((y==0||y>12)&&x>=1&&x<=12)
        printf("YYMM");
        else
            printf("NA");
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,ans;
int main()
{
    cin>>a>>b;
    if((a+b)%2==0)
    ans=(a+b)/2;
    else 
    ans=(a+b)/2+1;
    cout<<ans<<endl;
    return 0;
}

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

ball = [0]*n
for i in range(n)[::-1]:
    _sum=0
    for g in range(1,n+1):
        if (i+1)*g-1<n:
            _sum+=ball[(i+1)*g-1]
        else:
            break
    if _sum%2!=a[i]:
        ball[i]=1

print(sum(ball))
if sum(ball)!=0:
    print(*[g+1 for g in range(len(ball)) if ball[g]!=0])

Measured memory_bytes: 13116
import sys
a,b,c,d = map(int,input())
ans = 7 - a
li = ['+','-']
for i in li:
    for j in li:
        for k in li:
            bb = b if i=='+' else -b
            cc = c if j=='+' else -c
            dd = d if k=='+' else -d
            if bb+cc+dd == ans:
                print(str(a)+i+str(b)+j+str(c)+k+str(d)+'=7')
                sys.exit()

Measured memory_bytes: 3064
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define ff first
#define ss second
#define rep(i, n) for (int i = 0; i < (n); i++)
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }	
using namespace std;

ll n,ans;
map<ll,ll> mp;


void solve() {
	cin>>n;
	ll tmp=n;
	ans=0;
	while(tmp%2==0){
		mp[2]++;
		tmp/=2;
	}
	for(int i=3;i<=sqrt(tmp);i+=2){
			while(tmp%i==0){
				mp[i]++;
				tmp/=i;
			}
	}
	if(tmp>1){
		mp[tmp]++;
	}

	for(pair<ll,ll> pr:mp){
			ans+=(-1+sqrt(1+4*2*pr.ss))/2;
	}
	cout<<ans<<endl;
}
 
 


int main(){
    SPEED;
    solve();

}

Measured memory_bytes: 3700
/*
 * 2331.cc: A Way to Invite Friends
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

/* global variables */

int cs[MAX_N + 2];

/* subroutines */

/* main */

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

  for (int i = 0; i < n; i++) {
    int ai, bi;
    cin >> ai >> bi;
    cs[ai - 1]++;
    cs[bi]--;
  }

  for (int i = 0; i < n; i++) cs[i + 1] += cs[i];

  int maxc = 0;
  for (int i = n; i >= 1; i--)
    if (cs[i] >= i) {
      maxc = i;
      break;
    }

  printf("%d\n", maxc);
  return 0;
}

Measured memory_bytes: 1536
using System;
class p
{
  static void Main()
  {
    int A = int.Parse(Console.ReadLine());
    int B = int.Parse(Console.ReadLine());
    int C = int.Parse(Console.ReadLine());
    int X = int.Parse(Console.ReadLine());
    
    int cnt = 0;
    for (int a = A; 0 <= a; a--) {
      for (int b = B; 0 <= b; b--) {
        int n = X - (a * 500 + b * 100);
        if ((0 <= n) && (n / 50) <= C) {
          cnt++;
        }
      }
    }
    Console.WriteLine(cnt);
  }
}

Measured memory_bytes: 11092
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define gcd __gcd
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// ve<ve<要素の型>> 変数名(縦, ve<要素の型>(横, 初期値))

int main() {
  ll N, M;
  ci(N,M);
  ve<ll> a(M);
  ve<ll> D(N + 1, 1);
  repll(i, M){ 
    ci(a.at(i));
    D.at(a.at(i)) = 0;
  }
  repi(i, 2, N + 1){
    if(D.at(i) == 0){
      con;
    }
    else{
      D.at(i) = (D.at(i - 1) + D.at(i - 2)) % 1000000007;
    } 
  }
  co(D.at(N));
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n,a,U,res;
int cnt[1000100];
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a;
		cnt[a]++;
	} 
	for(int i=1;i<=1000000;i++){
		if(cnt[i]){
			U=1000000/i;
			for(int j=2;j<=U;j++) cnt[j*i]=0;
		}
	}
	for(int i=1;i<=1000000;i++) if(cnt[i]>=2) cnt[i]=0;
	res=0;
	for(int i=1;i<=1000000;i++) if(cnt[i]) res++;
	cout<<res<<endl;
	return 0;
}


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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

// #define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline void chmax(T& a,T const& b){a=max(a,b);}
template<class T> inline void chmin(T& a,T const& b){a=min(a,b);}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60; 

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m,d; cin >> n >> m >> d ;
  double n1,m1,d1; n1 = n; m1 = m; d1 = d;
  double ans = 0;
  if(2*d+1<=n){
    if(d!=0) ans = (2*(n1-2*d1)+2*d1)/(n1*n1);
    else ans = 1/n1;
    ans *= (m1-1);
  }else if(d>n-1){
    ans = 0;
  }else{
    ans = max(2*(n1-d1),n1)/(n1*n1);
    dump(ans);
    ans *= (m1-1);
    dump(ans);
  }
  printf("%.10f",ans);
  return 0; 
}


Measured memory_bytes: 256
def toInteger(string):
  integer = int(string)
  return integer

def myInput():
  s = input()
  i = toInteger(s)
  return i

def isEqual(a, b):
  try:
    1 / (a - b)
  except:
    return True
  return False

def isValue1(v):
  boolean = isEqual(v, 1)
  if isEqual(boolean, True) == True:
    return True
  elif isEqual(boolean, False) == True:
    return False
  else:
    None

def isValue2(v):
  boolean = isEqual(v, 2)
  if isEqual(boolean, True) == True:
    return True
  elif isEqual(boolean, False) == True:
    return False
  else:
    None

def printString(String):
  print(String)

def printHelloWorld():
  printString('Hello World')
  
def printInteger(integer):
  print(integer)

def sumTwoValues(a, b):
  c = a + b
  return c

def solve(v):
  boolean1 = isValue1(v)
  boolean2 = isValue2(v)
  if isEqual(boolean1, True) == True:
    printHelloWorld()
  elif isEqual(boolean2, True) == True:
    a = myInput()
    b = myInput()
    c = sumTwoValues(a, b)
    printInteger(c)
  else:
    None

a = myInput()
solve(a)

Measured memory_bytes: 3316
#include <stdio.h>
#include <string.h>
int main() {
	int h, w;
	char s[26][26][6];
	scanf("%d%d", &h, &w);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			scanf("%s", s[i][j]);
			if (strcmp(s[i][j], "snuke") == 0) {
				printf("%c%d\n", j + 'A', i + 1);
			}
		}
	}

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define F first
#define S second
using namespace std;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	ll n,m;
	cin >> n >> m;
	cout << n*(n-1)/2 + m*(m-1)/2;
	
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	long best = Long.MAX_VALUE;

	int[] cost;

	void go(int[] a, int idx, long sum) {

		long optSum = sum;
		for (int i = idx; i < a.length; i++) {
			optSum += a[i] == 0 ? Math.min(cost[i], 0) : cost[i];
		}

		if (optSum >= best) {
			return;
		}

		if (2 * idx >= a.length) {
			best = optSum;
			return;
		}

		go(a, idx + 1, sum + (a[idx] == 0 ? 0 : cost[idx]));
		if (a[idx] == 0) {
			for (int j = idx; j < a.length; j += idx) {
				a[j]++;
			}
			go(a, idx + 1, sum + cost[idx]);
			for (int j = idx; j < a.length; j += idx) {
				a[j]--;
			}
		}
	}

	long fast(int[] a) {
		return 0;
	}

	void submit() {
		int n = nextInt();
		cost = new int[n + 1];
		long sum = 0;
		for (int i = 1; i <= n; i++) {
			cost[i] = nextInt();
			sum += cost[i];
		}
		int[] a = new int[n + 1];
		go(a, 1, 0);
		out.println(sum - best);
	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {
		int n = 100;
		cost = new int[n + 1];
		long sum = 0;
		for (int i = 1; i <= n; i++) {
			cost[i] = rand(-10000, 10000);
			sum += cost[i];
		}
		int[] a = new int[n + 1];
		go(a, 1, 0);
		out.println(sum - best);
	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		// stress();
//		 test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}


Measured memory_bytes: 23504
def main():
    A = input()

    num = dict()
    for s in A:
        num[s] = num.get(s, 0) + 1

    x = 0
    for key1, val1 in num.items():
        for key2, val2 in num.items():
            if key1 != key2:
                x += val1 * val2

    ans = x // 2 + 1
    print(ans)

main()


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int n;
    cin >> n;
    vector<vector<int>> tree(n);
    rep(i,1,n){
        int a;
        cin >> a;
        --a;
        tree[a].push_back(i);
    }
    function<int(int)> rec=[&](int u){
        vector<int> x;
        for(int v:tree[u]) x.push_back(rec(v));
        sort(x.begin(),x.end());
        int res=0;
        rep(i,0,x.size()) res=max<int>(res,x[i]+x.size()-i);
        return res;
    };
    cout << rec(0) << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 13568
#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

int a[15], memo[15][10010];
int need[] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int dp(int pos, int sisa) {
	int ret;
	if (sisa == 0)
		return 0;
	if (pos == 0)
		return -1000000000;
	if (memo[pos][sisa] != -1)
		return memo[pos][sisa];
	ret = dp(pos - 1, sisa);
	if (sisa >= need[a[pos]])
		ret = max(ret, dp(pos, sisa - need[a[pos]]) + 1);
	memo[pos][sisa] = ret;
	return ret;
}

int main() {
	int n, m, ans;
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= m; i++)
		scanf("%d", &a[i]);
	sort(a + 1, a + m + 1);
	memset(memo, -1, sizeof memo);
	ans = dp(m, n);
	for (int i = 1; i <= ans; i++) {
		while (dp(m, n - need[a[m]]) != ans - i)
			m--;
		printf("%d", a[m]);
		n -= need[a[m]];
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int n,m;
int par[100010],rnk[100010];

void init(){
    for(int i=0;i<n;i++){
        par[i]=i;
    }
}

int find(int x){
    if(par[x]==x)return x;
    return par[x]=find(par[x]);
}

void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
    if(rnk[x]<rnk[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(rnk[x]==rnk[y])rnk[x]++;
    }
}

bool same(int x,int y){
    return find(x)==find(y);
}

int main(){
    cin>>n>>m;
    int p[n];
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    init();
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        unite(--x,--y);
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(same(p[i]-1,i))ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
int H[30] = {},D[30] = {};
typedef struct Node{
	int p;
	int l;
	int r;
}Node;

int getSib(Node *t,int u){
	if(t[u].p == -1)return -1;
	if(t[t[u].p].l != u)return t[t[u].p].l;
	if(t[t[u].p].r != u)return t[t[u].p].r;
}

int getDeg(Node *t,int u){
	int deg = 0;
	if(t[u].l != -1)deg++;
	if(t[u].r != -1)deg++;
	return deg;
}

int setHeight(Node *t,int u){
	int h1,h2;
	h1=h2=0;
	if(t[u].l != -1)h1=setHeight(t,t[u].l)+1;
	if(t[u].r != -1)h2=setHeight(t,t[u].r)+1;
	return H[u] = (h1>h2)?h1:h2;
}

void setDepth(Node *t,int u){
	D[t[u].l]=D[t[u].r]=D[u]+1;
	if(t[u].l != -1)setDepth(t,t[u].l);
	if(t[u].r != -1)setDepth(t,t[u].r);
}

void print(Node *t,int n){
	for(int i=0; i<n; i++){
		printf("node %d: ",i);
		printf("parent = %d, ",t[i].p);
		printf("sibling = %d, ",getSib(t,i));
		printf("degree = %d, ",getDeg(t,i));
		printf("depth = %d, ",D[i]);
		printf("height = %d, ",H[i]);
		if(t[i].p == -1)printf("root\n");
		else if(t[i].l == -1 && t[i].r == -1)printf("leaf\n");
		else printf("internal node\n");
	}
}

int main(void) {
	Node *T;
	int n;
	int id;
	int root;
	scanf("%d",&n);
	T = malloc(sizeof(Node) * n + 1);
	for(int i = 0; i < n; i++)T[i].p = T[i].l = T[i].r =-1;
	for(int i = 0; i < n; i++){
		scanf("%d",&id);
		scanf("%d%d",&T[id].l,&T[id].r);
		T[T[id].l].p = T[T[id].r].p = id;
	}
	for(int i = 0; i < n; i++)if(T[i].p == -1)root = i;
	setHeight(T,root);
	setDepth(T,root);
	print(T,n);
	return 0;
}



Measured memory_bytes: 2108
<?php
error_reporting(0);
//list($x,$t) = explode(" ",trim(fgets(STDIN)));
$N = trim(fgets(STDIN));
$a = explode(" ",trim(fgets(STDIN)));
$v = array_count_values($a);
ksort($v);
$maxpos = 0;
$max=1;
$maxwk=0;
foreach($v as $k=>$vv) {
  $maxwk = $vv;
  $flg = 0;
  for($i=$k+1;$i<$k+3;$i++) {
    if (array_key_exists($i,$v)) {
      $maxwk += $v[$i];
    }
  }
  if ($maxwk > $max) {
    $max = $maxwk;
  }
}
printf("%d\n",$max);


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

namespace
{
const int MAX_N	= 100000;

// 1 ～ N
int p[ MAX_N + 5 ];
}

int main( int argc, char *argv[] )
{
int i;
int N;
int iCnt;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

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

	iCnt = 0;
	i = 1;
	while( i < N )
	{
		if( p[ i ] == i )
		{
			iCnt++;
			i++;
		}

		i++;
	}

	if( i == N && p[ N ] == N ) iCnt++;

	cout << iCnt << endl;

	return 0;
}




Measured memory_bytes: 640
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define PB push_back

int main(void) {
    int n, a, ans = 0;
    vector<int>vec;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    REP(i, n) {
        cin >> a;
        vec.PB(a);
    }
    
    sort(vec.begin(), vec.end(), greater<int>());
    REP(i, n) {
        ans += (i % 2)? vec[i] * (-1) : vec[i];
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
def main(n, k):
    ans = 2

    for _ in range(n - 1):
        if (ans * 2) < ans + k:
            ans *= 2  # A
        else:
            ans += k  # B

    print(ans)


if __name__ == "__main__":
    n = int(input())
    k = int(input())

    main(n, k)


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

int main(void){
	int i,j,k,N,v;
	int *A;
	scanf("%d",&N);
	A = (int *)calloc(N, sizeof(int));
	for(i=0;i<N;i++){
		scanf("%d",&A[i]);
	}
	for(i=1;i<N;i++){
		for(k=0;k<N;k++){
			printf("%d",A[k]);
			if(k<N-1) printf(" ");
			else printf("\n");
		}
		v=A[i];
		j=i-1;
		while(j>=0 && A[j]>v){
			A[j+1]=A[j];
			j--;
		}
		A[j+1]=v;
	}
	for(k=0;k<N;k++){
			printf("%d",A[k]);
			if(k<N-1) printf(" ");
			else printf("\n");
		}
	return 0;
}

Measured memory_bytes: 616
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, V, max = 0, next = 0, maxE= 0, nextE= 0, maxO = 0, nextO = 0;
	map<int, int> Even, Odd;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> V;
		if (i % 2 == 0) Even[V]++;
		else Odd[V]++;
	}
	for (auto it = Even.begin(); it != Even.end(); it++) {
		if (it->second > max) {
			next = max;
			max = it->second;
			nextE = maxE;
			maxE = it->first;
		}
		else if (it->second > next) {
			next = it->second;
			nextE = it->first;
		}
	}
	max = 0, next = 0;
	for (auto it = Odd.begin(); it != Odd.end(); it++) {
		if (it->second > max) {
			next = max;
			max = it->second;
			nextO = maxO;
			maxO = it->first;
		}
		else if (it->second > next) {
			next = it->second;
			nextO = it->first;
		}
	}
	if (maxE != maxO) {
		cout << N - Even[maxE] - Odd[maxO];
	}
	else cout << min(N - Even[maxE] - Odd[nextO], N - Even[nextE] - Odd[maxO]);
}

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

int main() {
    int r, D, x_2000;
    cin >> r >> D >> x_2000;

    vector<int> x(11);
    x[0] = x_2000;

    for (int i = 0; i < 10; i++) {
        x[i + 1] = r * x[i] - D;
        cout <<  x[i + 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
object Main extends App {
	val temp = scala.io.StdIn.readLine.split(" ").map(_.toInt)

	val l = temp(0) + temp(1)
	val r = temp(2) + temp(3)

	if(l == r) println("Balanced")
	else if(l > r) println("Left")
	else println("Right")
}

Measured memory_bytes: 27060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007

ll extgcd(ll a, ll b, ll &x, ll &y){
  ll d = a;
  if(b!=0){
    d = extgcd(b,a%b,y,x);
    y -= (a/b)*x;
  }else{
    x = 1; y = 0;
  }
  return d;
}

ll mod_inverse(ll a, ll m){
  ll x, y;
  extgcd(a, m, x, y);
  return (m+x%m)%m;
}

void solve(int N, int lhs, int rhs){
  ll a = N, ax = a;
  ll b = 1, bx = b;
  ll s = lhs + N-1-rhs, sx = s;
  ll t = 0, tx = t;

  REP(i,1,N+1){
    ll res1 = 0, res2 = 0;
    res1 = a * mod_inverse(b, MOD);
    res1 %= MOD;
    res2 = s * mod_inverse(t, MOD);
    res2 %= MOD;
    if(t==0) res2 = 1;

    //cout << s << " " << t << " " ;
    //cout << res1 << " " << res2 << " ";
    cout << (res1 - res2 + MOD)%MOD << endl;

    ax--;
    bx++;
    if(t!=0) sx--;
    tx++;
    a *= ax; a %= MOD;
    b *= bx; b %= MOD;
    if(t!=0) s *= sx; s %= MOD;
    if(t==0) t = 1;
    t *= tx; t %= MOD;
  }
}
  
int main(){
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> v;
  rep(i,N+1){
    int a;
    cin >> a;
    v.push_back(a);
  }
  vector<int> memo(N+2, -1);
  int s = -1, t = -1;
  rep(i,v.size()){
    if(memo[v[i]] != -1){
      s = memo[v[i]];
      t = i;
      break;
    }
    memo[v[i]] = i;
  }

  solve(N+1, s, t);
  
  return 0;
}



Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long  n,ans = 0,k = 0;string p ;
  cin>>n;
  if(n < 10)
  {
    cout<<n;
    return 0;
  }
  stringstream ss;
  ss << n;
  string str = ss.str();
  p = str;
  for(int i =0 ; i < p.size(); i++)
  {
    k+=p[i] - 48;
  }
  p[0]--;
  for(int i = 1 ; i < p.size(); i ++){
    p[i] = '9';
  }
  for(long long i = 0 ; i < p.size(); i ++)
  {
    ans+=p[i] - 48;
  }
  cout<<max(ans,k);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int64_t A,B,M;
  cin >> A >> B >> M;
  M -= A;
  if (M >= 0) {
   cout << "0 "; 
  }
 else {
  M += A;
   A -= M;
     cout << A << " ";
  M = 0;
 }
  M -= B;
  if (M >= 0) {
   cout << "0" << endl; 
  }
 else {
  M += B;
   B -= M;
     cout << B << endl;
 }
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
const int mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define rep2(i,x,n) for(int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
#define F first 
#define S second
#define PB push_back 
#define MP make_pair
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
using vl=vector<long long>;
using vp =vector<pair<int,int>>;

typedef pair<int,int> P;
string s;
int k; 
ll INF = 10000000000000000;



int main(){
    int N,K;
    cin >>N>>K;
    vi H(N);
    rep(i,N) cin>>H[i];
    vi dp(N);
    dp[0]=0;
    rep1(i,N){
        ll step= min(K,i);
        ll mini =dp[i-1]+abs(H[i]-H[i-1]);
        rep1(s,step+1){
            ll cost=dp[i-s]+abs(H[i]-H[i-s]);
            if(cost<mini)  mini = cost;
        }
        dp[i]=mini;
    }
    cout <<dp[N-1]<<endl;
}


Measured memory_bytes: 1024
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int N = Integer.valueOf(s.next());
		if(N >= 30) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 35520