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

using namespace std;

#define ll long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,n) for(int i=1;i<=n;i++)
#define DEBUG 0
#define all(v) begin(v),end(v)
#define inf 1LL<<55

#define NORMAL 0
#define REVERSE 1

int main() {
    ll N, C;
    cin >> N >> C;

    vector<ll> x(N + 2), v(N + 2);
    for (ll i = 1; i <= N; i++) {
        cin >> x[i] >> v[i];
    }
    x[0] = 0;
    x[N + 1] = C;

    ll cal = 0;
    vector<vector<ll>> dp(2, vector<ll>(100010, 0));

    for (ll i = 1; i <= N; i++) {
        cal -= x[i] - x[i - 1];
        cal += v[i];
        dp[0][i] = max(dp[0][i - 1], cal);
        // ここでそれまでのカロリーの最大値をメモ
    }

    cal = 0;
    for (ll i = N; i >= 1; i--) {
        cal -= x[i + 1] - x[i];
        cal += v[i];
        dp[1][i] = max(dp[1][i + 1], cal);
    }

    ll maxcal = 0;
    for (ll i = 0; i <= N; i++) {
        // 時計回り
        cal = dp[0][i] + dp[1][i + 1] - x[i];
        maxcal = max(maxcal, cal);

        // 反時計回り
        cal = dp[0][i] + dp[1][i + 1] - C + x[i + 1];
        maxcal = max(maxcal, cal);
    }

    cout << maxcal << endl;

    return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    for(int i = 0 ; i < n;  i++)
    {
    	int x;
    	cin >> x;
    	if(x % 2 == 0 and (x % 5 and x % 3))
    	  {
    	  	cout << "DENIED";
    	  	return 0;
    	  }
    }
    cout << "APPROVED";
}

Measured memory_bytes: 256
N = int(input())
L = [int(x) for x in input().split()]
#L = list(set(L))
L.sort()
n = len(L)
cnt = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if L[i] + L[j] > L[k] and L[i] != L[j] != L[k]:
                cnt += 1
            #print(L[i], L[j], L[k])
print(cnt)

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

using ll=long long;
#define max_sum 1000000000000000000

int main(){

  ll n;
  cin >> n;
  ll a;
  long long  sum=1;
  bool flag = 0;


  for(int i=0;i<n;i++){
    cin >> a;
    if(a==0){
      cout << 0 << endl;
      return 0;
    }
    if(flag || max_sum/sum<a){
      flag = 1;
      sum=0;
    }else{
      sum*=a;
    }
  }

  if(flag==1){
    cout << -1 << endl;
  }else{
    cout << sum << endl;
  }
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#define Cin(T, x) T x; cin >> x
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cout(x) cout << (x) << "\n"
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) find(Range(c), x) != c.end()
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, vs, n, m) vector<vector<T>> vs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]

using namespace std;
using ll = long long;

int main(void){
    Cin(int, a);
    Cin(int, b);
    int c = 0;
    for(int i = 100; i <= 999; i ++){
        int k = 100*i + 10*(i % 100 / 10) + (i / 100);
        if(a <= k && k <= b) c ++;
    }
    Cout(c);
}


Measured memory_bytes: 256
#include<cstdio>

int main(){
    int n;
    bool a,b,c;
    char event[20];
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        int score=0;
        a=b=c=false;
        int out =0;
        while(1){
            scanf("%s", event);
            if(event[1]=='I'){
                if(c)score++;
                c=b;
                b=a;
                a=true;
            }else if(event[1]=='O'){
                score++;
                if(a)score++;
                if(b)score++;
                if(c)score++;
                a=b=c=false;
            }else out++;
            if(out==3){
                printf("%d\n", score);
                break;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 2568
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
 
#include <stdio.h>
#include <bits/stdc++.h>
 
using namespace std;
 
#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  
#define pb push_back
#define mp make_pair
#define in insert
#define f first
#define s second
#define ll long long
#define dd double
  
const int mod = 1e9 + 7;
const int N = 2e5 + 7;
const int inf = 2e9;
const ll INF = 1e18;

ll dp[21][(1 << 21)], a[21][21];

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	// freopen("*.in", "r", stdin);freopen("*.out", "w", stdout);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}

	for (int i = 0; i < n; i++) {
		if (a[0][i]) {
			dp[0][1 << i] = 1;
		}
	}

	for (int i = 1; i < n; i++) {
		for (int j = 0; j < (1 << n); j++) {
			if (__builtin_popcount(j) == i + 1)
			for (int k = 0; k < n; k++) {
				if (a[i][k]) {
					dp[i][j] += dp[i - 1][j ^ (1 << k)];
					dp[i][j] %= mod;
				}
			}
		}
	}

	cout << dp[n - 1][(1 << n) - 1];
}

Measured memory_bytes: 307456
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    map<int, int> cnt;
    int kind = 0;

    cin >> N;
    rep(i, N) {
        int a;
        cin >> a;
        if (cnt.count(a)) {
            cnt[a]++;
        }
        else {
            cnt[a] = 1;
            kind++;
        }
    }

    bool flag = false;
    if (kind == 1 && cnt.count(0) != 0) flag = true;
    if (kind == 2 && cnt.count(0) != 0 && cnt[0] == N / 3 && N % 3 == 0) flag = true;
    else if (kind == 3 && N % 3 == 0) {
        int check = 0;
        for (auto itr = cnt.begin(); itr != cnt.end(); itr++) {
            //cout << itr->second << endl;
            if (itr == cnt.begin()) check = itr->first;
            else check ^= itr->first;
            if (itr->second == N / 3) flag = true;
            else {
                flag = false;
                break;
            }
        }
        if (flag && check != 0) flag = false;
    }

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007 
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	fast_io();
	int x,y,z,k;
	cin >> x >> y >> z >> k;
	vector<ll> a(x);
	cu(i,0,x)cin >> a[i];
	vector<ll> b;
	cu(i,0,y){
		ll val;
		cin >> val;
		cu(j,0,x){
			b.pb(a[j] + val);
		}
	}
	sort(all(b), greater<ll>());
	vector<ll> c(z);
	vector<ll> cur(z);
	cu(i,0,z)cin >> c[i];
	sort(all(c), greater<ll>());
	cu(i,0,k){
		ll sum = 0,ind = -1;
		cu(j,0,z){
			if(cur[j] < b.size() && c[j] + b[cur[j]] > sum){
				sum = c[j] + b[cur[j]];
				ind = j;
			}
		}
		cout << sum << '\n';
		++cur[ind];
	}
}


Measured memory_bytes: 10604
#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool is_prime[100009];

int main(){
  int n=100009;
  int x;
  for(int i=0;i<=n;i++)is_prime[i]=true;
  is_prime[0]=is_prime[1]=false;
  for(int i=2;i<=n;i++){
    if(is_prime[i]){
      for(int j=i*2;j<=n;j+=i)is_prime[j]=false;
    }
  }

  cin>>x;
  for(int i=x;i<=n;i++){
    if(is_prime[i]){
      cout<<i<<endl;
      return(0);
    }
  }
  return(0);
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int x[101];
int main(void){
    for(int i=0;i<12;i++){
        int num;
        cin>>num;
        x[num]++;
    }
    for(int i=1;i<=100;i++){
        if(x[i]%4){
            cout<<"no"<<endl;
            return 0;
        }
    }
    cout<<"yes"<<endl;
    return 0;
}

Measured memory_bytes: 3072
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int a[2010],b[2010],n,k,Q,ans=1e9,c[2010],tot;
bool vis[2010];
priority_queue<int,vector<int>,greater<int> >q;
void solve(int w)
{
	tot=0;
	for (int i=1;i<=n;i++) if (b[i]<w) vis[i]=1;
	for (int i=1;i<=n;i++)
	{
		if (vis[i]==1)
		{
			while (q.size()>=k) c[++tot]=q.top(),q.pop();
			while (!q.empty()) q.pop();
		}
		else q.push(b[i]);
	}
	while (q.size()>=k) c[++tot]=q.top(),q.pop();
	while (!q.empty()) q.pop();
	sort(c+1,c+1+tot);if (tot<Q) return;
	ans=min(ans,c[Q]-c[1]);
}
int main()
{	
	scanf("%d%d%d",&n,&k,&Q);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),b[i]=a[i];
	sort(a+1,a+1+n);
	for (int i=1;i<=n;i++) solve(a[i]);
	printf("%d",ans);
}

Measured memory_bytes: 384
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace Atcoder_Answer
{
    class Program
    {
        const int mod = 1000000007;

        static void Main(string[] args)
        {
            string[] Reader = ReadLine().Split(' ');
            string S = Reader[0];
            string T = Reader[1];
            Reader = ReadLine().Split(' ');
            int A = int.Parse(Reader[0]);
            int B = int.Parse(Reader[1]);
            string U = ReadLine();

            if (U == S) A--;
            if (U == T) B--;

            WriteLine(A + " " + B);
        }

    }

    public static class Extension
    {
        #region 拡張:bool
        #region キャスト関連
        public static int ToInt(this bool Bool)
        {
            if (Bool) return 1;
            else return 0;
        }

        public static string ToString(this bool Bool, string TrueStr, string FalseStr)
        {
            if (Bool) return TrueStr;
            else return FalseStr;
        }
        #endregion
        #endregion

        #region 拡張:int
        #region キャスト関連
        public static char ToAlphaBets(this int Base) => (char)Base;
        #endregion
        #endregion

        #region 拡張:char
        #region 変換関連
        public static char NextAlpha(this char Char) => (char)((Char) + 1); //次の文字を取得
        #endregion
        #endregion

        #region 拡張:int[]
        public static long Sum(this int[] Array)
        {
            int Ret = 0;
            for (int loop = 0; loop < Array.Length; loop++) Ret += Array[loop];
            return Ret;
        }
        #endregion
    }
}


Measured memory_bytes: 13140
n = int(input())
s = [input() for i in range(n)]

b = 0
a = 0
ba = 0

cnt = 0
for x in s:
    if x[0] == "B" and x[-1] == "A":
        ba+=1
    if x[0] == "B":
        b+=1
    if x[-1] == "A":
        a+=1
    cnt += x.count("AB")

cnt2 = 0
if ba==b and ba==a and ba!=0:
    cnt2 = ba-1
else:
    cnt2 = min(a,b)

print(cnt+cnt2)

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

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N, A;
            N = int.Parse(Console.ReadLine());
            A = int.Parse(Console.ReadLine());

            int kotae = N * N - A;

            Console.Write(kotae);

        }
    }
}


Measured memory_bytes: 13140
import heapq as hq

def main():
    n,m = list(map(int,input().split(' ')))
    shop = []
    cnt = 0
    total = 0
    for i in range(n):
        hq.heappush(shop,list(map(int,input().split(' '))))
    for i in range(n):
        price,item=hq.heappop(shop)
        if cnt + item <=m:
            cnt += item
            total += price*item
            if cnt ==m:
                break
        else:
            total += price*(m - cnt)
            break

    print(total)

if __name__ == '__main__':
    main()

Measured memory_bytes: 27384
import java.util.Scanner;
public class Main{
 
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
		int x, y ,n;
		x = sc.nextInt();
		y = sc.nextInt();
		n = sc.nextInt();
		System.out.println(plainting(x,y,n));
    
  }
  
  public static int plainting(int x,int y ,int n) {
		
		//aは大きい辺，bは小さい辺
		int a = 0;
		int b =0;
		
		if(x>=y) {
			a = x; 
			b = y;
		}else {
			a= y;
			b= x;
		}
		int k = 1;
		while(n >a*k) {
			k =k+1;
		}
		return k;
	}
}

Measured memory_bytes: 23252
#include <iostream>

using namespace std;

int main() {
  long long input;
  cin >> input;
  int left = input % 11;
  int plus;
  if (left == 0) {
    plus = 0;
  } else if (left <= 6) {
    plus = 1;
  } else {
    plus = 2;
  }
  cout << (input / 11) * 2 + plus << endl;
  return 0;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>s;
      rep(i,Size(s)){
        if(s[i]!=s[i+1])ans++;
      }
      Cout(ans-1);

       
return 0;
}


Measured memory_bytes: 512
#!/usr/bin/env python3

import array
import heapq


def topological_sort(num_vs, adj_vs):
    """ Performs topological sorting of the given DAG.

    This function computes the lexicographically least
    topological order of the given DAG.

    :param num_vs int: The number of vertices.
    :param adj_vs list: The adjacency list.
    :return: The lexicographically least topological order.
    :rtype: :obj:`array.array`
    :raises TopologicalSortError: if the given graph is not a DAG
    """
    in_deg = array.array("L", (0 for _ in range(num_vs)))
    for dests in adj_vs:
        for dest in dests:
            in_deg[dest] += 1
    sorted_vs = array.array("L")
    pq = []
    for s in range(num_vs):
        if in_deg[s] == 0:
            heapq.heappush(pq, s)
    while pq:
        u = heapq.heappop(pq)
        sorted_vs.append(u)
        for v in adj_vs[u]:
            in_deg[v] -= 1
            if in_deg[v] == 0:
                heapq.heappush(pq, v)
    if all(x == 0 for x in in_deg):
        return sorted_vs
    else:
        raise TopologicalSortError("The graph has a cycle")


def main():
    v, e = map(int, input().split())
    adj_vs = [set() for _ in range(v)]
    for _ in range(e):
        s, t = map(int, input().split())
        adj_vs[s].add(t)
    for u in topological_sort(v, adj_vs):
        print(u)


if __name__ == '__main__':
    main()

Measured memory_bytes: 14084
#include<stdio.h>

int main(void){


int a,b,c;


int tmp,i,j;


scanf("%d %d %d",&a,&b,&c);


if(a>b){


tmp = a;


a = b;


b = tmp;


}


if(a>c){


tmp = a;


a = c;


c = tmp;


}


if(b>c){


tmp = b;


b = c;


c = tmp;


}


printf("%d %d %d\n",a,b,c);


return 0;


}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
    
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
#define int long long
#define double long double
    
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
    
#define ff first
#define ss second
#define mp make_pair
         
#define pb push_back
#define endl "\n" 
         
#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)    

#define bp __builtin_popcountll
#define inf 1e18
    
const int N=1e6+5;
const int M=1e9+7;
void solve()
{
	int a,v,b,w,tt;
	cin>>a>>v>>b>>w>>tt;
	swap(a,b);
	swap(v,w);
	int aa,bb;
	if(a<b)
	{
		aa=a-v*tt;
		bb=b-w*tt;
	}
	else
	{
		aa=a+v*tt;
		bb=b+w*tt;
	}
	
	if((a<b && aa>=bb) || (a>b && aa<=bb))
	{
		cout<<"YES";
	}
	else
	{
		cout<<"NO";
	}
}
signed main()  
{
	FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
}


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

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


int gcd(int a, int b){
  int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}

int f(int n){
  if(n%2==0){
    return n/2;
  }
  else{
    return 3*n+1;
  }
}

/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int n;
  scanf("%d",&n);

  int A[2000000];
  for(int i=0;i<2000000;i++){
    A[i]=0;
  }

  A[n]++;

  int ans=1;
  while(1){
    n=f(n);
    A[n]++;
    ans++;

    if(A[n]>1){
      printf("%d\n",ans);
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 9520
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(100000)
class Node(object):
    # left????????¨??????????????????(leaf), right???s?????¨??????????????????????????????
    # ???????????????????????????????????¨???????????´??????parent???-1?????????
    def __init__(self, N):
        self.p = [-1 for i in range(N)]
        self.l = [-1 for i in range(N)]
        self.r = [-1 for i in range(N)]
        self.D = [0 for i in range(N)]

    def set_depth_rec(self, u, p):
        self.D[u] = p
        if self.r[u] is not -1:
            self.set_depth(self.r[u], p)
        if self.l[u] is not -1:
            self.set_depth(self.l[u], p+1)

    def set_depth(self, u):
        d = 0
        pre_u = u
        while self.p[u] is not -1:
            u = self.p[u]
            d += 1
        self.D[pre_u] = d

    def print_children(self, u):
        children = []
        flag = self.l[u]
        while flag is not -1:
            children.append(flag)
            flag = self.r[flag]
            
        return children
        

N = int(input())
T = Node(N)

for j in range(N):
    A = [int(i) for i in input().split()]
    
    # left????±????
    if len(A) > 2:
        T.l[A[0]] = A[2]
    else:
        T.l[A[0]] = -1

    # parent???right????±????
    for index, i in enumerate(A[2:]):
        if(A[-1] == i):
            T.p[i], T.r[i] = A[0], -1
        else:
            T.p[i], T.r[i] = A[0], A[index+3]
    
#T.set_depth_rec(T.p.index(-1), 0)
for i in range(N):
    T.set_depth(i)

for i in range(N):
    if T.p[i] is -1:
        node = "root"
    elif T.l[i] is -1:
        node = "leaf"
    else:
        node = "internal node"
        
    print("node {0}: parent = {1}, depth = {2}, {3}, {4}".format(i, T.p[i], T.D[i], node, T.print_children(i)))

Measured memory_bytes: 21528
#include <iostream>

using namespace std;

int main(){

	int s1[5] , s2[5];
	int ans1 = 0 , ans2 = 0;

	for(int i = 0; i < 4; i++){
		cin >> s1[i];

		ans1 += s1[i];
	}

	for(int i = 0; i < 4; i++){
		cin >> s2[i];

		ans2 += s2[i];
	}

	if(ans1 < ans2) cout << ans2 << endl;
	else  cout << ans1 << endl;

	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,k;
	scanf("%d %d %d %d %d %d",&a, &b,&c, &d,&e,&k);
	
	if(k >= e-a){
	printf("Yay!");
	}else{
		printf(":(");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,h,w;
	cin>>n>>h>>w;
	int ans=0;
	rep(i,n){
		int a,b;
		cin>>a>>b;
		if(h<=a and w<=b)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	ll n; cin >> n;
	vector<ll> v(n);
	rep(i, n) cin >> v[i];
	ll sum = accumulate(ALL(v), 0LL);
	// print(sum);
	sort(ALL(v));
	// print(v);
	ll ans = sum;
	bool ok = false;
	if(sum % 10 == 0){
		rep(i, n){
			if(v[i] % 10 == 0) continue;
			ans -= v[i];
			ok = true;
			break;
		}
	}
	else ok = true;

	if(!ok){
		cout << 0 << endl;
	}
	else{
		cout << ans << endl;
	}

	return 0;
}


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

using namespace std;

int main() {
  int N, L;
  cin >> N >> L;

  vector<string> s(N);

  for (int i = 0; i < N; i++) {
    cin >> s.at(i);
  }

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

  for (int j = 0; j < N; j++) {
    cout << s.at(j);
  }
  cout << endl;
}


Measured memory_bytes: 256
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	var (
		n   int
		err error
	)
	if sc.Scan() {
		n, err = strconv.Atoi(sc.Text())
		if err != nil {
			panic(err)
		}
	}

	list := make([]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		in, err := strconv.Atoi(sc.Text())
		if err != nil {
			panic(err)
		}
		list[i] = in
	}

    // O(n)
    min := list[0]
    max := list[n-1] - list[n-2]
    for i := 1; i < n; i++ {
        if max < list[i]-min {
            max = list[i] - min
        }

        if min > list[i] {
            min = list[i]
        }
    }

	fmt.Println(max)
}


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

int main(){
    int N, L;
    cin >> N >> L;
    vector<int> apple(N);
    for (int i = 0; i < N; i++){
        apple.at(i) = L + i;
    }
    int sum = 0;
    int eat = 0;
    for (int i = 0; i < N; i++){
        sum += apple.at(i);
        if (abs(apple.at(i)) < abs(apple.at(eat))){
            eat = i;
        }
    }
    cout << sum - apple.at(eat) << endl;
}

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



char st[10010];

int main()
{
    int n;scanf("%d",&n);
    scanf("%s",st);
    for (int i=0;st[i];++i){
        st[i]+=n;
        st[i]-='A';
        st[i]%=26;
        st[i]+='A';
        printf("%c",st[i]);
    }


}



Measured memory_bytes: 128
#include <iostream>
using namespace std;
const long long int mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    long long int ans=1;
    for(int i=1; i<=n; i++){
        ans = (ans*i)%mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}
ll N=1e5+5;
vector <vector <ll> >vec(N);
vector <ll> ans(N,-1);
ll dfs(ll e){
    if(ans[e]!=-1) return ans[e];
    ll a=1;
    ll maxi=0;
    for(auto x : vec[e]){
        maxi=max(maxi,dfs(x));
    }
    a+=maxi;
    ans[e]=a;
    return a;
}


int main(){
    IOS;
    make2(ll,n,m);
    fr(i,m){
        make2(ll,x,y);
        vec[--x].push_back(--y);
    }
    fr(i,n){
        if(ans[i]==-1) dfs(i);
    }
    ll maxi=1;
  //  fr(i,n) cout<<ans[i]<<" ";
    fr(i,n) maxi=max(maxi,ans[i]);
    cout<<maxi-1<<endl;


    return 0;
}


Measured memory_bytes: 11532
#include <stdio.h>

int n, A[50];

int solve(int i, int m) {
    if (m == 0) return 1;
    if (i >= n) return 0;
    int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
    return res;
}

int main() {
    int q, M, i;

    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &A[i]);
    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d", &M);
        if (solve(0, M))
            printf("yes\n");
        else
            printf("no\n");
    }
    return 0;
}


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

/*
i学期の評点をLi, i-1学期の評点をLi-1とする。
Li = Ai-k+1 * Ai-k+2 * ... * Ai
Li-1 = Ai-k * Ai-k+1 * ... * Ai-1
(Li / Li-1) > 1のとき、i学期の評点がi-1学期よりも高い。
Lをそれぞれの右辺に置き換えると、打ち消しの結果(Ai / Ai-k) > 1
つまりAi > Ai-kが得られる。
すなわち、Ai > Ai-kのときi学期の評点がi-1学期より良いと言える。
*/

int main() {
  long long n, k, a[1 << 18];
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  
  for (int i = k + 1; i <= n; i++) {
    if (a[i-k] < a[i]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#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 n;
cin>>n;
vector<P>list(n);
rep(i,n)
{int x,l;
scanf("%d",&x);
scanf("%d",&l);
P p;
  //firstに、アームを一番右側に伸ばしたときの数字
  p.first=x+l;
  //secondに、アームを一番左側に伸ばした時の数字(かぶってはいけないので)
  p.second=x-l;
  list.at(i)=p;
}
sort(list.begin(),list.end());

int nowx=-1e9;
int ans=0;
rep(i,n)
{P p=list.at(i);
  if(nowx<=p.second)
  {ans++; nowx=p.first;}
}

cout << ans << endl;



}
/*vector <int> a(3);
for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }*/

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
using namespace std;
typedef long long ll;
#define inf 2123456789
//#define scanf scanf_s	//vs2019
#define maxn 100005
int a[112345] = { 0 };
int b[112345] = { 0 };//0好 1不好
int main() {
	int n, k, i, d, j, t, ans = 0, x, y;
	cin >> n >> k;
	for (i = 1; i <= n; i++)cin >> a[i];
	while (k--) {
		cin >> x >> y;
		if (a[x] <= a[y])b[x] = 1;
		if (a[y] <= a[x])b[y] = 1;
	}
	for (i = 1; i <= n; i++) {
		if (b[i] == 0)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4420
#include<iostream>
using namespace std;
int main()
{
  int n,p,pp;
  int N[50];
  while(1){
    cin>>n;
    cin>>p;
    if(n==0 && p==0)break;
    pp=p;
    for(int i=0;i<50;++i)N[i]=0;
    for(int i=0;;i++){
      if(pp > 0){
	++N[i%n];
	--pp;
      }
      else{
	pp += N[i%n];
	N[i%n] = 0;
      }
      if(N[i%n] == p){
	cout << i%n << endl;
	break;
      }
    }
  }
  return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  int n;
  cin >> n;
  cout << (3.1415926535)*n*2.0 << endl;
  


  

  return 0;
}


Measured memory_bytes: 3792
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

H,W = I()
maze = [list(s()) for _ in range(H)]
for i in range(H):
    for j in range(W):
        if maze[i][j] == '#':
            F = 0
            if i != 0 :
                if maze[i-1][j] == '#':
                    F = 1
            if i != H-1:
                if maze[i+1][j] == '#':
                    F = 1
            if j != 0:
                if maze[i][j-1] == '#':
                    F = 1
            if j != W-1:
                if maze[i][j+1] == '#':
                    F = 1
            if not F:
                print('No')
                exit()
print('Yes')

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

int main(){
  ll n,k;
  cin >> n >> k;
  ll dp[100005];
  ll h[100005];
  for(int i = 0;i < n;i++)
  {
      cin >> h[i];
  }
  for (int i = 0; i < n; i++)
  {
    dp[i]=-1;
  }
  
  dp[0] = 0;
  if(k==1){
    ll ans=0;
    for (int i = 0; i < n-1; i++)
    {
      ans+=abs(h[i]-h[i+1]);
    }
    cout << ans;
    return 0;
    
  }
  for (int i = 1; i < k; i++)
  {
    dp[i]=abs(h[i]-h[0]);
  }
  if(k>=n){
    cout << abs(h[n-1]-h[0]);
    return 0;
  }
  
  for(int i = k;i < n;i++)
  {
    for (int x = 1; x <= k; x++)
    {
      ll temp = dp[i-x]+abs(h[i-x]-h[i]); 
      if(dp[i]!=-1){
        dp[i] = min(dp[i],temp); 
      }
      else{
        dp[i] = temp;
      }
    }
  }
  cout << dp[n-1];
}


Measured memory_bytes: 1792
/* ****Ragnar7 _Lawliet_**** */
/* First, solve the problem.Then write the code. */
#include<bits/stdc++.h>
#define ll          long long
#define ld             long double
#define hell        1000000007
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen ("input.txt","r",stdin);
    // freopen ("output.txt","w",stdout);
    #endif
    ll t = 1;
    // cin>>t;
    while(t--)
    {
        ll h,w,n;
        cin>>h>>w>>n;
        vector<ll> r(h+1,0),c(w+1,0);
        vector<pair<ll,ll> > v;
        ll x,y;
        map<pair<ll,ll>,ll> mp;
        ll ans = 0;
        ll rr = 0,cc=0;
        for(ll i=0;i<n;i++)
        {
            cin>>x>>y;
            r[x]++;
            c[y]++;
            if(r[rr]<r[x])
                rr = x;
            if(c[cc]<c[y])
                cc = y;
            mp[{x,y}] = 1;
            v.push_back({x,y});
        }
        ll temp = 0;
        for(auto i:v)
        {
            //row fix
            temp = 0;
            temp += r[i.first];
            temp += c[cc];
            if(mp.find({i.first,cc})!=mp.end())
                temp--;
            ans = max(ans,temp);

            //col fix
            temp = 0;
            temp += c[i.second];
            temp += r[rr];
            if(mp.find({rr,i.second})!=mp.end())
                temp--;
            ans = max(ans,temp);
        }
        cout<<ans;

        
    }

    
    time
    return 0;
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
bool dp[1000006];
int main()
{
    int n;cin >> n;
    vector<int> a(n);rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    int before = -1;
    rep(i,1000006)dp[i] = true;
    for (auto &&i : a)
    {
        if(i == before)
        {
            before = i;
            dp[i] = false;
            continue;
        }
        
        if(dp[i])
        {
            int counter = 2;
            while(i*counter < 1000006)
            {
                dp[i*counter] = false;
                counter++;
            }
        }
        before = i;
    }
    int ans = 0;
    before = -1;
    for (auto &&i : a)
    {
        if(i == before)
        {
            before = i;
            continue;
        }
        before = i;
        if(dp[i])ans++;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 5096
from itertools import accumulate
n,k = map(int,input().split())
p = list(map(int, input().split()))
a = [0] + p
a = list(accumulate(a))
num = 0
summ = 0
for i in range(len(a)-k):
    if(a[i+k]-a[i]>summ):
        num = i
        summ = a[i+k]-a[i]
ans = 0
for i in range(k):
    ans += p[num+i]*(p[num+i]+1)/(2*p[num+i])
print(ans)

Measured memory_bytes: 25148
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		//????????£????????????????????°?????????????????£?¨?
		Scanner sc = new Scanner(System.in);
		while(true){
			//???
			int H = sc.nextInt();
			//?¨?
			int W = sc.nextInt();
			//??\?????????0????????????
			if(H ==0 && W ==0){
				break;
			}
			//?¨?????????¶???
			for(int i =1; i <=H; i++){
				//???????????¶???
				for(int j =1; j<=W; j++){
						System.out.print('#');
					}
					System.out.println();
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 37156
def rec(x1,q):
    return x1-((x1**3-q)/(3*(x1**2)))

q = []
while True:
    try:
        tmp = int(input())
        if tmp == -1:
            break
        q.append(tmp)
    except EOFError:
        break
for i in range(len(q)):
    x1 = float(q[i]/2)
    while True:
        x1 = rec(x1,q[i])
        if abs(x1**3 - q[i]) < 0.00001*q[i]:
            break
    print(x1)

Measured memory_bytes: 7668
N = int(input())
n = [int(i)//400 for i in input().split()]
c = 0
for i in n:
    if i >= 8:
        c += 1
n_kind = [i for i in n if i<8]
a = len(set(n_kind))
if a == 0:
    print(1,c)
else:print(a,a+c)

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


int main() {
    string S;
    cin >> S;
    long long n = S.size();
    long long res = 0;
    long long num = 0;
    for (long long i = 0; i < n; ++i) {
        if (S[i] == 'W') {
            res += num;
        }
        else {
            ++num;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3728
#include<iostream>
#include <vector>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;




int main()
{
  long n, l;
  string s;
  cin  >> s;

  reverse(s.begin(), s.end());
  vector <string> word = {"maerd", "remaerd", "esare", "resare"};

  // int num = s.size();
  for (int i = 0; i < s.size();) {
    bool isfind = false;
    if (s.substr(i, word[0].size()) == word[0] ) {i += word[0].size(); isfind = true;}
    if (s.substr(i, word[1].size()) == word[1] ) {i += word[1].size(); isfind = true;}
    if (s.substr(i, word[2].size()) == word[2] ) {i += word[2].size(); isfind = true;}
    if (s.substr(i, word[3].size()) == word[3] ) {i += word[3].size(); isfind = true;}
    if (!isfind) {
      cout << "NO" <<endl;
      return 0;
    }
  }

  cout << "YES"<<endl;;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  ll N,A,B,C,D,E;
  cin >> N >> A >> B >> C >> D >> E;

  ll x = min(A,min(B,min(C,min(D,E))));

  ll y;
  if(N%x==0){
    y=N/x;
  }else{
    y=N/x+1;
  }

  cout << y-1+5 << endl;
}

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

vector<int> get_bin(int num){
  vector<int> res(3);
  int num_cp = num;
  for(int i = 0; i < 3; ++i){
    res[i] = num_cp % 2;
    num_cp /= 2;
  }
  return res;
}

int main(){
  string s;
  cin >> s;
  for(int num = 0; num < 8; ++num){
    vector<int> binary = get_bin(num);
    int sum = s[0] - '0';
    for(int i = 0; i < 3; ++i){
      int add_val = (binary[i] == 1) ? s[i + 1] - '0' : -(s[i + 1] - '0');
      sum += add_val;
    }
    
    if(sum == 7){
      cout << s[0];
      for(int i = 0; i < 3; ++i){
        char op = (binary[i] == 1) ? '+' : '-';
        cout << op << s[i + 1];
      }
      cout << "=7" << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int D = sc.nextInt();
        int N = sc.nextInt();


        int pow = (int)Math.pow(100, D);
        int res = pow * N;
        if (N == 100){
            res = res + (int)Math.pow(100, D) ;
        }
        System.out.println(res);

    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

class UnionFind {
  public:
    vi Parent;
    UnionFind(int N) {
      Parent = vi(N,-1);
    }
  
    int root(int A) {
      if(Parent[A] < 0) return A;
      return Parent[A] = root(Parent[A]);
    }
  
    int size(int A) {
      return -Parent[root(A)];
    }
  
    bool connect(int A,int B) {
      A = root(A);
      B = root(B);
      if(A == B) return false;
      if(size(A) < size(B)) swap(A,B);
      Parent[A] += Parent[B];
      Parent[B] = A;
      return true;
    }
};
  
int main() {
  int H,W;
  cin >> H >> W;
  v(string) G(H);
  rep(i,H) {
    cin >> G[i];
  }
  UnionFind t = UnionFind(H*W);
  rep(i,H) {
    rep(j,W) {
      if(i-1>=0 && G[i][j] != G[i-1][j]) {
        t.connect(i*W+j,(i-1)*W+j);
      }
      if(j-1>=0 && G[i][j] != G[i][j-1]) {
        t.connect(i*W+j,i*W+j-1);
      }
    }
  }
  vi b(H*W,0),w(H*W,0);

  rep(i,H) {
    rep(j,W) {
      if(G[i][j] == '#') {
        b[t.root(i*W+j)]++;
      } else {
        w[t.root(i*W+j)]++;
      }
    }
  }
  ll ans = 0;
  rep(i,H*W) {
    if(b[i] <= 0 || w[i] <= 0) continue;
    ans += 1ll * b[i] * w[i];
  }
  cout << ans << endl;
  return 0;
}

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

const int N=1e5+10;
int a[N],b[N];

int main(){
    int n,h,maxn=0,cnt=0;
    cin>>n>>h;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        maxn=max(maxn,a[i]);
    }
    sort(b,b+n);
    for(int i=n-1;i>=0;i--){
       if(b[i]<maxn) break;
       h-=b[i];
       cnt++;
       if(h<=0) break;
    }
    if(h>0){
        if(h%maxn==0) cout<<cnt+h/maxn<<endl;
        else cout<<cnt+1+h/maxn<<endl;
    }
    else cout<<cnt<<endl;
    return 0;
}


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


int main() {

    int D;
    cin>>D;

    if(D==25)
      cout<<"Christmas"<<endl;
    else if(D==24)
      cout<<"Christmas Eve"<<endl;
    else if(D==23)
      cout<<"Christmas Eve Eve"<<endl;
    else if(D==22)
      cout<<"Christmas Eve Eve Eve"<<endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
aaa = list(map(int, input().split()))
bbb = list(map(int, input().split()))
ccc = list(map(int, input().split()))

aaa.sort()
ccc.sort()

def is_ok_a(mid, b):
    if mid < 0:
        return True
    elif mid >= n:
        return False
    else:
        return aaa[mid] < b

def m_bisect_a(ng, ok, b):
    while abs(ng - ok) > 1:
        mid = (ng + ok) // 2
        if is_ok_a(mid, b):
            ok = mid
        else:
            ng = mid
    return ok

def is_ok_c(mid, b):
    if mid < 0:
        return False
    elif mid >= n:
        return True
    else:
        return ccc[mid] > b

def m_bisect_c(ng, ok, b):
    while abs(ng - ok) > 1:
        mid = (ng + ok) // 2
        if is_ok_c(mid, b):
            ok = mid
        else:
            ng = mid
    return ok

ans = 0
for i in range(n):
    b = bbb[i]
    ng, ok = n, -1
    cnt_a = m_bisect_a(ng, ok, b) + 1
    ng, ok = -1, n
    cnt_c = n - m_bisect_c(ng, ok, b)
    ans += (cnt_a * cnt_c)

print(ans)

Measured memory_bytes: 24180