akhauriyash/Code-Regression huggingface dataset:
/* #region template */
use std::io::{stdin, stdout, Bytes, Read, Stdin, StdinLock, Stdout, StdoutLock, Write};
use std::str::FromStr;
#[allow(dead_code)]
struct Io<'a> {
    reader: Bytes<StdinLock<'a>>,
    writer: StdoutLock<'a>,
    in_buf: [u8; BUF_SIZE],
}
#[allow(dead_code)]
impl<'a> Io<'a> {
    fn new(stdin: &'a Stdin, stdout: &'a Stdout) -> Io<'a> {
        Io {
            reader: stdin.lock().bytes(),
            writer: stdout.lock(),
            in_buf: [0; BUF_SIZE],
        }
    }
    fn r<T: FromStr>(&mut self) -> T {
        let mut count = 0;
        loop {
            match self.reader.next() {
                Some(Ok(b' ')) | Some(Ok(b'\n')) => break,
                Some(Ok(c)) => self.in_buf[count] = c,
                _ => panic!(),
            }
            count += 1;
        }

        let s = unsafe { std::str::from_utf8_unchecked(&self.in_buf[0..count]) };
        s.parse().unwrap_or_else(|_| panic!())
    }
    fn ru(&mut self) -> usize {
        self.r()
    }
    fn iter<'b, T>(&'b mut self) -> IoIter<'a, 'b, T> {
        IoIter::new(self)
    }
    fn c<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        self.iter().take(n).collect()
    }
    fn cu(&mut self, n: usize) -> Vec<usize> {
        self.c(n)
    }
    fn w<T: std::fmt::Display>(&mut self, v: T) {
        writeln!(self.writer, "{}", v).unwrap();
    }
    fn wn<T: std::fmt::Display>(&mut self, v: T) {
        write!(self.writer, "{}", v).unwrap();
    }
}
#[allow(dead_code)]
struct IoIter<'a: 'b, 'b, T> {
    io: &'b mut Io<'a>,
    m: std::marker::PhantomData<T>,
}
#[allow(dead_code)]
impl<'a: 'b, 'b, T> IoIter<'a, 'b, T> {
    fn new(io: &'b mut Io<'a>) -> IoIter<'a, 'b, T> {
        IoIter {
            io,
            m: std::marker::PhantomData,
        }
    }
}
impl<'a, 'b, T: FromStr> Iterator for IoIter<'a, 'b, T> {
    type Item = T;
    fn next(&mut self) -> Option<Self::Item> {
        Some(self.io.r())
    }
}
fn main() {
    let stdin = stdin();
    let stdout = stdout();
    let mut io = Io::new(&stdin, &stdout);
    unsafe {
        solve(&mut io);
    }
}
/* #endregion */

const BUF_SIZE: usize = 1024;

unsafe fn solve(io: &mut Io) {
    io.w("0 0");
    re(io.r(), (0.0, 0.0), (100.0, 0.0), io);
}
fn re(n: usize, p1: (f64, f64), p2: (f64, f64), io: &mut Io) {
    let sqrt3 = 3.0f64.sqrt();
    if n > 0 {
        let s = ((p1.0 * 2.0 + p2.0) / 3.0, (p1.1 * 2.0 + p2.1) / 3.0);
        let t = ((p1.0 + p2.0 * 2.0) / 3.0, (p1.1 + p2.1 * 2.0) / 3.0);
        let u = (
            (t.0 - s.0) / 2.0 - (t.1 - s.1) * sqrt3 / 2.0 + s.0,
            (t.0 - s.0) * sqrt3 / 2.0 + (t.1 - s.1) / 2.0 + s.1,
        );
        re(n - 1, p1, s, io);
        re(n - 1, s, u, io);
        re(n - 1, u, t, io);
        re(n - 1, t, p2, io);
    } else {
        io.wn(p2.0);
        io.wn(' ');
        io.w(p2.1);
    }
}



Measured memory_bytes: 5068
#include<bits/stdc++.h>
using namespace std;
int main(){
  cout << fixed << setprecision(15);
  
  int N,K;
  cin>>N>>K;
  double sum=0.0;
  for(int i=1;i<=N;i++){
    int pt=i;
    double p=1.0/N;
    while(pt<K){
      p/=2;
      pt*=2;
    }
   sum+=p;
  }
  cout<<sum<<endl;
}


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

ll N;

int main(){

    cin >> N;

    ll ans = 0, mid;
    if (N%2 == 0){
        mid = N/2;
        ans = N*((N-1)/2) + mid;
    }
    else{
        ans  = N*((N-1)/2);
    }

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

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];

  int64_t total = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] == 0) continue;

    if (A[i] >= 2) {
      total += A[i] / 2;
      A[i] &= 1;
    }
    if (A[i] == 1 and i + 1 < N and A[i + 1] > 0) {
      A[i]--;
      A[i + 1]--;
      total++;
    }
    if (A[i] == 1 and 0 < i and A[i - 1] > 0) {
      A[i]--;
      A[i - 1]--;
      total++;
    }
  }
  printf("%ld\n", total);

  return 0;
}


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

#define check cnt=0;for(j=0;j<6;j++)if(d1[j]==d2[j])cnt++;
#define r tmp=d2[1];d2[1]=d2[3];d2[3]=d2[4];d2[4]=d2[2];d2[2]=tmp;
#define y tmp=d2[0];d2[0]=d2[3];d2[3]=d2[5];d2[5]=d2[2];d2[2]=tmp;

int main(){
 int d1[6],d2[6],tmp,cnt,j,a=1,i,k;

 for(int i=0;i<6;i++){
  cin >> d1[i] ;
 }
 for(int i=0;i<6;i++){
  cin >> d2[i] ;
 }

 check
   if(cnt==6)a=0;

 while(a){
  for(i=0;i<5;i++){
   for(k=0;k<4;k++){
    check
    if(cnt==6)break;
    r
   }
   check
   if(cnt==6)break;
   tmp=d2[0];
   d2[0]=d2[1];
   d2[1]=d2[5];
   d2[5]=d2[4];
   d2[4]=tmp;
  }
  if(cnt==6)break;
  y
  for(k=0;k<4;k++){
   check
   if(cnt==6)break;
   r
  }
  if(cnt==6)break;
  y
  y
  for(k=0;k<4;k++){
   check
   if(cnt==6)break;
   r
  }
  a=0;
 }

 if(cnt==6)cout << "Yes" << endl ;
 else cout << "No" << endl ;

 return 0;
}

Measured memory_bytes: 3088
N = int(input())
A = list(map(int, input().split()))
rain = [0]
r0 = 0
for i in range(N):
    r0 += A[i] * (-1)**i
rain[0] = r0
for i in range(1, N):
    rain.append(2 * A[i-1] - rain[i-1])
print(" ".join([str(n) for n in rain]))

Measured memory_bytes: 19092
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    string s;
    cin>>s;
    
    string t="";
    rep(i,s.size()){
        if(s[i]!='x')t+=s[i];
    }
    
    string tr = t;
    reverse(all(tr));
    if(t!=tr){
        cout<<-1<<endl;
        return 0;
    }
    
    int n = 2*s.size();
    
    string sr = s;
    reverse(all(sr));
    
    s+='*';
    sr+='*';
    
    int a=0, b=0;
    
    int c = 0;
    while(n){
        if( s[a]==sr[b] ){
            if( s[a]=='*' )break;
            a++, b++;
            n-=2;
        }else if( s[a]=='x' ){
            c++;
            a++;
            n--;
        }else if( sr[b]=='x' ){
            c++;
            b++;
            n--;
        }else{
            abort();
        }
    }
    cout<<c/2<<endl;
}


Measured memory_bytes: 768
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem0512 : Caesar Cipher **/
int main()
{
	string s;
	cin>>s;
	
	string ans;
	rep(i, s.size()) {
		int t = s[i]-'A';
		t -= 3;
		if (t<0)
			t = 26 + t;
		ans += 'A'+t;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fi first
#define se second
#define pb push_back
#define mk make_pair
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 998244353;
 
ll fastpowMOD(ll a, ll p,ll MOD);
ll fastpowMOD(ll a, ll p,ll MOD){ if(p==0) return 1; a %= MOD; ll z = fastpowMOD(a,p/2,MOD); z = (z*z)%MOD; if(p%2) z = (z*a)%MOD; return z; }
 
 
ll combo(ll n, ll k){
 	if(k==0) return 1;
 	ll N=1,D=1;
 	for(ll i = 1;i<=k;i++){
 		N = (((n-i+1)%MOD)*N)%MOD;
 		D = (D*i)%MOD;
	 }
	 
	 return (N*fastpowMOD(D,MOD-2,MOD))%MOD;
 }
 
ll lcm(ll a,ll b){
	return (a*b)/__gcd(a,b);
}

int main(){
	fastio;
	int n,k;
	cin>>n>>k;
	vector<int> a(n,0);
	int mini = 0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]==1){
			mini = i;
		}
	}
	int ans = n;
	
	for(int i=mini;i>=0 && i>mini-k;i--){
		int t = 0;
		t += ((n-1-i)%(k-1))?(n-1-i)/(k-1)+1:(n-1-i)/(k-1);
		t += ((i-0)%(k-1))?(i-0)/(k-1)+1:(i-0)/(k-1);
		ans = min(ans,t);
	}
	
	
	
	cout<<ans<<"\n";
	
	
}
 
 
 
 

Measured memory_bytes: 640
#include<iostream>

using namespace std;

int main(){
  int w,h;

  while(true){
    cin >> w >> h;

    if((w==0) && (h==0))
      break;

    for(int i=0;i<w;i++){
      for(int j=0;j<h;j++){
	cout << '#';
      }
      cout << endl;
    }
    cout << endl;
  }
}

Measured memory_bytes: 3076
H,W = list(map(int,input().split()))

M=[]

w_count=0

for i in range(H):
    s=input()
    m=[]
    for j in range(W):
        if s[j]=='.':
            m.append(0)
            w_count+=1
        else:
            m.append(1)
    M.append(m)

path = [[[] for j in range(W)] for i in range(H)]

for i in range(H):
    for j in range(W):
        if M[i][j]==0:
            if i!=H-1:
                if M[i+1][j]==0:
                    path[i][j].append([i+1,j])
                    path[i+1][j].append([i,j])
            if j!=W-1:
                if M[i][j+1]==0:
                    path[i][j].append([i,j+1])
                    path[i][j+1].append([i,j])

M_path = [[10**27 for j in range(W)] for i in range(H)]
M_checked = [[False for j in range(W)] for i in range(H)]
M_path[0][0]=0

from collections import deque

Q=deque([[0,0]])
M_checked[0][0]=True
while len(Q)>0:
    i,j=Q.pop()
    mp = M_path[i][j]
    for p in path[i][j]:
        if not M_checked[p[0]][p[1]]:
            M_checked[p[0]][p[1]]=True
            Q.appendleft(p)
            if mp+1 < M_path[p[0]][p[1]]:
                M_path[p[0]][p[1]] = mp+1

if M_path[H-1][W-1]<10**27:
    print(w_count-(M_path[H-1][W-1]+1))
else:
    print(-1)

Measured memory_bytes: 4596
# ABC 143 D - Triangles
# https://atcoder.jp/contests/abc143/tasks/abc143_d

n = gets.chomp.to_i
l = gets.chomp.split(/ /).map(&:to_i).sort

count = 0
0.upto(n - 3) do |i|
  a = l[i]
  (i + 1).upto(n - 2) do |j|
    b = l[j]
    c_candidates = l[(j + 1)..(n - 1)]
    t = a + b
    c_over_index = c_candidates.bsearch_index { |c| c >= t }
    if c_over_index.nil?
      count += (n - 1) - j
    else
      count += c_over_index
    end
  end
end

puts count


Measured memory_bytes: 1912
H, W = map(int,input().split())
s = [list(input()) for i in range(H)]
sl = [[0]*(W) for _ in range(H)]
sr = [[0]*(W) for _ in range(H)]
su = [[0]*(W) for _ in range(H)]
sd = [[0]*(W) for _ in range(H)]

for i in range(H):
    for j in range(W):
        if s[i][j]=='.':
            if i==0:
                sl[i][j] = 1
            else:
                sl[i][j] = sl[i-1][j]+1
            if j==0:
                su[i][j]=1
            else:
                su[i][j] = su[i][j-1]+1
for i in list(range(H))[::-1]:
    for j in list(range(W))[::-1]:
        if s[i][j]=='.':
            if i==H-1:
                sr[i][j] = 1
            else:
                sr[i][j] = sr[i+1][j]+1
            if j==W-1:
                sd[i][j]=1
            else:
                sd[i][j] = sd[i][j+1]+1
ans = 0
for i in range(H):
    for j in range(W):
        if s[i][j]=='.':
            ans = max(ans, sl[i][j]+sr[i][j]+su[i][j]+sd[i][j]-3)
print(ans)

Measured memory_bytes: 308744
while 1:
    t, p, r = map(int, input().split())
    if t == 0:
        break

    data = [[0 for i in range(3)] for j in range(t)]  # [ID, Solved, Penalty]
    wrong = [[0 for i in range(p)] for j in range(t)]
    for i in range(t):
        data[i][0] = i + 1

    for _ in range(r):
        log = list(input().split())
        team = int(log[0]) - 1
        quiz = int(log[1]) - 1
        time = int(log[2])
        flag = log[3]

        if flag == "CORRECT":
            data[team][1] += 1
            data[team][2] += (wrong[team][quiz] * 1200 + time)
        else:
            wrong[team][quiz] += 1

    data = sorted(data, key=lambda x: (-x[1], x[2], x[0]))
    for D in data:
        print(' '.join(str(d) for d in D))


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

int main(void)
{
    long long N;
    cin >> N;
    vector<long long> A(N);
    for (long long i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    vector<long long> x(N);
    vector<long long> y(N);
    for (long long i = 0; i < N; i++)
    {
        x[i] = i+A[i];
        y[i] = i-A[i];
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    long long countx = 0;
    long long county = 0;
    long long count = 0;
    while(1)
    {
        if (countx == N || county == N)
        {
            break;
        }
        if (x[countx] < y[county])
        {
            countx++;
        }
        else if (x[countx] > y[county])
        {
            county++;
        }
        else
        {
            long long prex = 0;
            long long prey = 0;
            while(1)
            {
                if (x[countx+prex] != x[countx])
                {
                    break;
                }
                prex++;
            }
            while(1)
            {
                if (y[county+prey] != y[county])
                {
                    break;
                }
                prey++;
            }
            count += prex * prey;
            countx += prex;
            county += prey;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 8020
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


int main(){
    ll a,b,n;
    cin >> a >> b >> n;

    ll x = 0;
    if(b > n){
        x = n;
    } else {
        x = b-1;
    }
    cout << floor(a*x/b)-a*floor(x/b) << endl;

    return 0;
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
	int k;
  vector<int> v(5);
  for (int i=0; i<5; i++) cin>>v[i];
  cin>>k;
  for (int i=0; i<5; i++) {
    for (int j=0; j<5; j++) {
      if (i==j) continue;
      if (abs(v[i]-v[j])>k) out(":(");
    }
  }
  
  cout<<"Yay!"<<endl;
  

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

int n, q, d[200000];
string s, t[200000];

bool g(int p) {
	inc(i, q) {
		if(t[i][0] == s[p]) { p += d[i]; }
		if(p == -1) { return true; }
		if(p == n) { break; }
	}
	return false;
}

int f() {
	int L = -1, H = n;
	while(H - L > 1) {
		int M = (L + H) / 2;
		(g(M) ? L : H) = M;
	}
	return H;
}

int main() {
	cin >> n >> q >> s;
	inc(i, q) { string D; cin >> t[i] >> D; d[i] = (D == "L" ? -1 : +1); }
	
	int x = f();
	reverse(ALL(s));
	inc(i, q) { d[i] *= -1; }
	int y = f();
	y = n - y;
	
	cout << y - x << endl;
	
	return 0;
}


Measured memory_bytes: 12164
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>

using namespace std;


int main() {
	string s;
	string t = "";
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0')t.push_back('0');
		if (s[i] == '1')t.push_back('1');
		if (s[i] == 'B'&&t.size()!=0)t.pop_back();
	}
	cout << t;
}

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


Measured memory_bytes: 2144
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
	int N;
	cin >> N;
	vector<int> P(N);
	rep(i, N) cin >> P[i];

	int mini = P[0];
	int cnt = 1;
	for(int i = 1; i<N; i++) {
		if(P[i]<mini) {
			mini = P[i];
			cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}



Measured memory_bytes: 1024
<?php

fscanf(STDIN, '%d %d', $N, $K);
fscanf(STDIN, '%s', $S);

$count = 1;
$index = 0;
$counts = array_fill(0, $N, 0);

for ($i=1; $i < $N ; $i++) { 
    if ( $S[$i] !== $S[$i-1] ) {
        $counts[$index] = $count;
        $index++;
        $count = 1;
    } else {
        $count++;
    }
}
$counts[$index] = $count;
$lastIndex = $index;

$i = 0;
if ( $S[0] == 0 ) {
    $start = max(0, 2 * $i - 1);
    $end = 2 * $i - 1 + 2 * $K;
} else {
    $start = 2 * $i;
    $end = 2 * $i + 2 * $K;
}
$tempMax = array_sum(array_slice($counts, $start, $end-$start+1));
$temp = $tempMax;


for ($i=0; $i <$lastIndex+1 ; $i++) {
    if ( $i == 0 && $S[0] == 0 ) {
        $temp = $temp - $counts[$start + 2 * $i];
    } else if ( $S[0] == 0 ) {
        $temp = $temp - $counts[$start + 2 * $i] - $counts[$start + 2 * $i - 1];
    } else {
        $temp = $temp - $counts[$start + 2 * $i] - $counts[$start + 2 * $i + 1];
    }
    $temp = $temp + $counts[$end + 2 * $i + 1] + $counts[$end + 2 * $i + 2];

    if ($tempMax < $temp) {
        $tempMax = $temp;
    }

    if ( $end + 2 * $i + 2 >= $lastIndex ) {
        break;
    }
}

echo $tempMax;

?>

Measured memory_bytes: 12792
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N;
    cin >> N;
    vector<long> H(N);
    for(size_t i=0;i<N; i++)
    {
        cin >> H[i];
    }
    long max_count=0;
    long count=0;
    for(size_t i=0;i<N-1; i++)
    {
        if(H[i]>=H[i+1]) count++;
        else
        {
            max_count=max(max_count, count);
            count=0;
        }
        cerr << H[i] << ":" << H[i+1] << ":" << count << endl;
    }
    max_count=max(max_count, count);
    cout << max_count << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3996
si = list(input())
s = []
for i in range(len(si)):
    if si[i] == 'A':
        s.append('A')
    elif si[i] == 'B':
        if i < len(si) - 1 and si[i+1] == 'C':
            s.append('B')
        else:
            s.append('X')
    elif si[i] == 'C':
        if i > 0 and si[i-1] == 'B':
            pass
        else:
            s.append('X')

result = 0
ac = 0
for i in range(len(s)):
    if s[i] == 'A':
        if i < len(s) - 1 and s[i+1] == 'B':
            result += ac + 1
            s[i+1] = 'A'
        else:
            ac += 1
    else:
        ac = 0

print(result)


Measured memory_bytes: 61808
#include<bits/stdc++.h>
#include <iostream>
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long ll;
ll fight(ll h)
{
	if(h==0)
		return 0;
	int cnt=0;
	while(h!=0){
		h/=2;
		cnt++;
	}
	return cnt;
}
int main(int argc, char const *argv[])
{
	ll h;
	cin>>h;
	ll ans = pow(2,fight(h))-1;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;


pair<vector<int>, vector<int> > solve(int n, int m) {
    assert (2 * m + 1 <= n);
    unordered_set<int> used;
    vector<int> a(n), b(n);
    REP (i, m) {
        a[i] = i;
        if (n % 2 == 0) {
            b[i] = 2 * m - i - (i >= m / 2);
        } else {
            b[i] = 2 * m - i;
        }

        assert (m <= b[i] and b[i] < n);
        int delta = min(b[i] - a[i], a[i] + n - b[i]);
        assert (not used.count(delta));
        used.insert(delta);
    }
    return make_pair(a, b);
}

// generated by online-judge-template-generator v4.1.0 (https://github.com/kmyk/online-judge-template-generator)
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    constexpr char endl = '\n';
    int N, M;
    cin >> N >> M;
    auto [a, b] = solve(N, M);
    REP (i, M) {
        cout << (a[i] + 1) << ' ' << (b[i] + 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 9660
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        new Main().solveA();
    }

    private void solveA() {
        try (Scanner sc = new Scanner(System.in);) {
            List<Integer> list = new ArrayList<>();
            int N = sc.nextInt();
            for (int i = 0; i < N; i++) {
                list.add(sc.nextInt());
            }

            List<Integer> sortedList = new ArrayList<>(list);

            Collections.sort(sortedList);

            int median = sortedList.get(N / 2);
            int medianMinus = sortedList.get(N / 2 - 1);

            for (int i : list) {
                if (i >= median) {
                    System.out.println(medianMinus);
                } else {
                    System.out.println(median);
                }
            }
        }
    }

}


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

int main() {
  int n,m,x,s1 = 0,s2 = 0;
  cin >> n >> m >> x;
  vector<int>a(m);
  for(int i = 0;i < m;i++){
    cin >> a.at(i);
    if(a.at(i) < x){
      s1++;
    }
    else{
      s2++;
    }
  }
  if(s1 < s2){
    cout << s1 << endl;
  }
  else{
    cout << s2 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed << setprecision(15);
    int W, H, N;
    cin >> W >> H >> N;
    vector<int> X(N);
    vector<int> Y(N);
    vector<int> A(N);
    ll ans = 0;
    vector<vector<char>> B(H, vector<char>(W, '-'));
    for (int i = 0; i < N; i++)
    {
        cin >> X[i] >> Y[i] >> A[i];
        if(A[i] == 1){
            for (int j = 0; j < H;j++)
            {
                for (int k = 0; k < X[i];k++)
                {
                    B[j][k] = '*';
                }
            }
        }
        else if(A[i] == 2){
            for (int j = 0; j < H;j++)
            {
                for (int k = X[i]; k < W;k++)
                {
                    B[j][k] = '*';
                }
            }
        }
        else if(A[i] == 4){
            for (int j = Y[i]; j < H;j++)
            {
                for (int k = 0; k < W;k++)
                {
                    B[j][k] = '*';
                }
            }
        }
        else{
            for (int j = 0; j < Y[i];j++)
            {
                for (int k = 0; k < W;k++)
                {
                    B[j][k] = '*';
                }
            }
        }
    }
    for (int i = 0; i < H;i++)
    {
        for (int j = 0; j < W;j++)
        {
            if(B[i][j] == '-'){
                ans++;
            }
            //cout << B[i][j];
        }
        //cout << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <map>
#include <utility>
using namespace std;

int main()
{
    int N, K, S, T;
    cin>>N>>K>>S>>T;
    vector<int> A(N);
    for (int &a: A)
        cin>>a;

    vector<map<pair<int, int>, long long>> X(K+1);
    X[0][make_pair(0x3ffff, 0)] = 1;
    for (int &a: A)
    {
        if ((a&S)==S && (a|T)==T)
            for (int k=K-1; k>=0; k--)
                for (auto x: X[k])
                    X[k+1][make_pair(x.first.first&a, x.first.second|a)] += x.second;
    }
    long long ans = 0;
    for (int k=1; k<=K; k++)
        ans += X[k][make_pair(S, T)];
    cout<<ans<<endl;
}


Measured memory_bytes: 153536
N,Q = map(int,input().split())
S = list(input())
cum_sum = [0]*N
for i in range(1,N):
    if S[i-1] == "A" and S[i] == "C":
        cum_sum[i] = cum_sum[i-1] + 1
    else:
        cum_sum[i] = cum_sum[i-1]

for _ in range(Q):
    l,r = map(int,input().split())
    print(cum_sum[r-1] - cum_sum[l-1])


Measured memory_bytes: 6872
import javax.print.DocFlavor;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.function.BiConsumer;

public class Main {

    //グローバル変数を定義

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

    void run() {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();

        int max = -1;

        int one = Integer.parseInt(a) + Integer.parseInt(b+c);
        int two = Integer.parseInt(a) + Integer.parseInt(c+b);
        int three = Integer.parseInt(b) + Integer.parseInt(a+c);
        int four = Integer.parseInt(b) + Integer.parseInt(c+a);
        int five = Integer.parseInt(c) + Integer.parseInt(a+b);
        int six = Integer.parseInt(c) + Integer.parseInt(b+a);

        max = Math.max(one, two);
        max = Math.max(max, three);
        max = Math.max(max, four);
        max = Math.max(max, five);
        max = Math.max(max, six);
        System.out.println(max);
    }
}


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

typedef long long ll;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

bool TEST=false;

void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}

ll N,ans;
v_ll W;
int main(){
  ans = 1000000000;
  cin >> N;
  W.assign(N+10,0);
  ll x=0,y=0;
  for (ll i=0;i<N;i++){
    cin >> W[i];
    y+=W[i];
  }
  for (ll i=0;i<N;i++){
    x+=W[i];y-=W[i];
    ll z=y-x;
    if (z<0)z=-z;
    if (z<ans)ans=z;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

int main()
{
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll x, y;
    cin >> x >> y;

    ll t = abs(abs(x) - abs(y));

    if (x * y == 0) {
        cout << abs(x - y) + (x < y ? 0 : 1) << endl;
    } else if (x * y < 0) {
        cout << t + 1 << endl;
    } else {
        if ((x < 0 && x > y) || (x > 0 && x > y)) {
            cout << t + 2 << endl;
        } else {
            cout << t << endl;
        }
    }
}


Measured memory_bytes: 256
while True:
  n = int(input())
  if n == 0:
    break
  lst = []
  for _ in range(n):
    p, d1, d2 = map(int, input().split())
    lst.append((d1 + d2, p))
  lst.sort()
  print(lst[-1][1], lst[-1][0])


Measured memory_bytes: 7012
import java.util.*;

class Main{
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		String s = sc.nextLine();

		if(s.equals("Sunny")) System.out.println("Cloudy");
		if(s.equals("Cloudy")) System.out.println("Rainy");
		if(s.equals("Rainy")) System.out.println("Sunny");
	}
}



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

int used[101][2][2][101];
int mem[101][2][2][101];

Int dfs(Int idx, Int allZero, Int same, Int cnt, string s){
  if(idx >= Int(N.size())) return cnt == K;
  if(cnt > K) return 0;
  if(used[idx][allZero][same][cnt]++) return mem[idx][allZero][same][cnt];

  int res = 0;
  for(Int i=0;i<10;i++){
    Int nidx = idx + 1;
    Int nallZero = allZero && (i == 0);
    Int nsame = same && (N[idx] == i + '0');
    Int ncnt = cnt + (i != 0);
    if(same && N[idx] < i + '0') continue;
    res += dfs(nidx, nallZero, nsame, ncnt, "");
  }
  return mem[idx][allZero][same][cnt] = res;

}

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

  cin>>N>>K;

  Int ans = dfs(0, 1, 1, 0, "");
  cout<<ans<<endl;

  return 0;
}


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

int main(){
    int N;
    cin >> N;
    if(N >= 100){
        N %= 100;
    }
    if(N >= 10){
        N %= 10;
    }

    if(N == 3){
        cout << "bon" << endl;
    }else if(N == 0 || N == 1 || N == 6 || N == 8){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }
}

Measured memory_bytes: 3572
n , k = map(int, input().split())
a = list(int(i) for i in input().split())
 
temp = sum(a[0:k])
max_  = temp
for i in range(n-k):
  f = a[i]
  s = a[i+k]
  temp -= f
  temp += s
  max_ = max(max_, temp)
    
print((max_+k)/2)

Measured memory_bytes: 24804
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
using str=string;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

ll lcm(ll a,ll b){
    return (a*b/gcd(a,b));
}

str S;
int n;

int main(){
    int n;
    string s;
    cin >> n >> s;
    rep(i,s.size()){
        s[i]=(s[i]-'A'+n)%26+'A';
    }
    cout << s << endl;
    return 0;
}

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

int main(){
    double a, b, C, S, L, h, rad;
    double PI = acos(-1);
    cin >> a >> b >> C;
    rad = C * PI / 180;
    S = 0.5*a*b*sin(rad);
    L = a + b + sqrt(a*a + b*b -2*a*b*cos(rad));
    h = b*sin(rad);
    printf("%lf %lf %lf", S, L , h);
    return 0;
}


Measured memory_bytes: 3440
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll a,b;
    cin>>a>>b;
    ll k2=abs(a-b);
    if(k2%2==1){
        cout<<"IMPOSSIBLE"<<endl;
    }
    else{
        cout<<max(a,b)-(k2/2)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>

using namespace std;

#ifdef DEBUG
#define dprintf      printf
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(int i=0){}else
#define drep(i,n)    if(int i=0){}else
#define dstop()      scanf("")
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__);
#define array(T,id,n) T id[n]; rep(i,n)cin>>id[i];

//#define int long long;
#ifndef int
#define INF (0x7fffffff)
#else
#define INF (0x7fffffffffffffff)
#endif

typedef  long long           ll;
typedef  unsigned            ui;
typedef  unsigned long long  ull;
typedef  pair<int,int>       i_i;
typedef  pair<ll,int>        ll_i;
typedef  pair<ll,ll>         ll_ll;
typedef  pair<double,int>    d_i;
typedef  pair<double,double> d_d;

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

signed main(void)
{
  ll ans=0;
  in(int,n);
  char s[2][112]={};
  scanf("%s %s",s[0],s[1]);

  int stay=0;
  int i=0;
  if(s[0][i]==s[1][i])
    {
      // たて向き
      stay=0;
      ans=3;
      i+=1;
    }
  else
    {
      // よこ向き
      stay=1;
      ans=6;
      i+=2;
    }

  while(i<n)
    {
      if(s[0][i]==s[1][i])
	{
	  if(stay) // よこたて
	    ans*=1;
	  else	   // たてたて
	    ans*=2;
	  stay=0;
	  i+=1;
	}
      else
	{
	  if(stay) // よこよこ
	    ans*=3;
	  else     // たてよこ
	    ans*=2;
	  stay=1;
	  i+=2;
	}
      ans%=1000000007;
    }
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
using namespace std;

int main(void){
    int n,temp;
    long long ans=0;
    cin >>n;
    for(int i=0; i<n; i++){
        cin >> temp;
        ans+=temp-1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	static class Node {		
		int id, parentId, depth;
		int[] children;
		public Node(int id, int parentId) {
			this.id = id;
			this.parentId = parentId;
			this.depth = 0;
			this.children = null;
		}
		private String getType() {
			if (depth == 0) {
				return "root";
			}
			if (children == null || children.length == 0) {
				return "leaf";
			}
			return "internal node";
		}
		public String toString() {
			StringBuilder sb = new StringBuilder();
			sb.append("node " + id + ": ");
			sb.append("parent = " + parentId + ", ");
			sb.append("depth = " + depth + ", ");
			sb.append(getType() + ", ");
			sb.append(Arrays.toString(children));
			return sb.toString();
		}
	}

	public static void main(String[] args) throws IOException {
		
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		Node[] nodes = new Node[n];

		for (int i = 0; i < n; i++) {		
			StringTokenizer st = new StringTokenizer(reader.readLine());			
			int id = Integer.parseInt(st.nextToken());
			if (nodes[id] == null) {
				nodes[id] = new Node(id, -1);
			}
			if (nodes[id].parentId != -1) {
				nodes[id].depth = nodes[nodes[id].parentId].depth + 1;
			}

			int m = Integer.parseInt(st.nextToken());
			int[] children = new int[m];
			for (int j = 0; j < m; j++) {
				int childId = Integer.parseInt(st.nextToken());
				children[j] = childId;
				if (nodes[childId] == null) {
					nodes[childId] = new Node(childId, id);
				} else {
					nodes[childId].parentId = id;
				}
				nodes[childId].depth = nodes[id].depth + 1;
			}
			nodes[id].children = children;
		}

		for (Node node : nodes) {
			System.out.println(node);
		}
	}
}


Measured memory_bytes: 110520
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
struct edge{int to,cost;};
typedef pair<int,int>P;
typedef pair<int,P>P2;
int c,n,m,s,d,a1,a2,a3,dis[102][11];
vector<edge>v[102];
int main(){
  while(cin>>c>>n>>m>>s>>d,c){
    r(i,102)r(j,11)dis[i][j]=1e8;
    r(i,102)v[i].clear();
    r(i,m){
      cin>>a1>>a2>>a3;
      v[a1].push_back(edge{a2,a3});
      v[a2].push_back(edge{a1,a3});
    }
    priority_queue<P2,vector<P2>,greater<P2> >q;
    q.push(P2(0,P(s,c)));
    dis[s][c]=0;
    while(!q.empty()){
      P2 p=q.top();q.pop();
      int now=p.second.first;
      int card=p.second.second;
      int len=p.first;
      if(dis[now][card]<len)continue;
      r(i,v[now].size()){
        int next=v[now][i].to;
        int cost2=v[now][i].cost;
        if(dis[next][card]>cost2+len){
          dis[next][card]=cost2+len;
          q.push(P2(cost2+len,P(next,card)));
        }
        if(card&&dis[next][card-1]>cost2/2+len){
          dis[next][card-1]=cost2/2+len;
          q.push(P2(cost2/2+len,P(next,card-1)));
        }
      }
    }
    int ans=1e9;
    r(i,11)ans=min(ans,dis[d][i]);
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3092
#include <iostream>
#define mod 1000000007
using namespace std;
long long jc[5005],jcinv[5005],inv[5005];
inline long long C(long long x,long long y)
{
	return jc[x]*jcinv[y]%mod*jcinv[x-y]%mod;
}
int main(int argc, char** argv) {
	jc[0]=jc[1]=jcinv[0]=jcinv[1]=inv[1]=1;
	for(long long i=2;i<=5000;i++)
	{
		jc[i]=jc[i-1]*i%mod;
		inv[i]=(mod-mod/i)*inv[mod%i]%mod;
		jcinv[i]=jcinv[i-1]*inv[i]%mod;
	}
	long long n,ans=0;
	cin >> n;
	for(long long i=1;i<=n/3;i++)
	{
		ans+=C(i+n-i*3-1,i-1);
		ans%=mod;
	//	cout << ans << "\n";
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3312
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

  map<string, int> dict;
  rep(i, N) {
    string s;
    cin >> s;
    dict[s]++;
  }

  int m = 0;
  for (auto& p : dict) {
    m = max(m, p.second);
  }

  priority_queue<string, vector<string>, greater<string>> q;

  for (auto& p : dict) {
    if (p.second == m) {
      q.push(p.first);
    }
  }

  while (!q.empty()) {
    cout << q.top() << endl;
    q.pop();
  }

  return 0;
}

Measured memory_bytes: 26868
import java.awt.Point;
import java.util.ArrayDeque;
import java.util.Scanner;
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Collection;


 
public class Main{
	
        static final Scanner sc=new Scanner(System.in);
        
        
        
        
        
        
        public static void main(String[]args){
                int N=sc.nextInt();
                int i=sc.nextInt();
                System.out.println(N-i+1);
                


                
        }
        
        
        

		
	
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	int c[n];
	for(int i = 0; i < n; i++) cin >> c[i];
	sort(c, c+n);
	cout << c[n - 1] - c[0]  << endl;
}

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

int main()
{
    int n, ans = 0;
    string s;
    cin >> n >> s;
    for(int i = 1; i < s.size(); i++)
    {
        string tmp1, tmp2;
        set<char>s1, s2;
        for(int j = 0; j < i; j++)
        {
            tmp1 += s[j];
            s1.insert(s[j]);
        }
        for(int j = i; j < s.size(); j++)
        {
            tmp2 += s[j];
            s2.insert(s[j]);
        }
        //cout<<tmp1<<" "<<tmp2<<endl;
        int tot = 0;
        for(set<char>::iterator it = s1.begin(); it != s1.end(); it++)
        {
            if(s2.count(*it))tot++;
        }
        ans = max(ans, tot);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int A,B,C,X,Y;
	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&C);
	scanf("%d",&X);
	scanf("%d",&Y);
	
	int maxxy,minxy,c;
	if(X>=Y){
		maxxy=X;minxy=Y,c=0;
	}else{
		maxxy=Y;minxy=X,c=1;
	}
	int total=0;
	int kari=0;
	if(A+B>=2*C){
		total=minxy*C*2;
		kari=maxxy*C*2;
		if(c==0){
			total+=A*(X-Y);
		}else{
			total+=B*(Y-X);
		}
		
		if(total>=kari){total=kari;}
	}else{
		total=A*X+B*Y;
	}
	printf("%d",total);
	return 0;}

Measured memory_bytes: 128
S = gets.chomp.split("")
alp = "abcdefghijklmnopqrstuvwxyz".split("")
ans = [0] * 26
S.each do |s|
    ans[alp.index(s)] = 1
end

26.times do |t|
    if ans[t] == 0
        puts alp[t]
        exit
    end
end
puts "None"

Measured memory_bytes: 19244
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define ld long double
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define FTEST int testcase;fin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
#define plii pair<ll,pii>
#define no {cout<<"no"<<endl;return;}
#define yes {cout<<"yes"<<endl;}
#define rep(i,N) for(int i=0;i<N;i++)
const int maxn=3e5;
const int mod=998244353;
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ull power(ull a,ll b){
    ull ans=1;
    while(b){
        if(b&1) ans=ans*a;
        b/=2;
        a=a*a;
    }
    return(ans);
}
ll arr[maxn+1];
ll dp[maxn+1];
vector<int> v;
void solve(){
    int n,a;cin>>n;
    dp[0]=0;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
        dp[i]=(dp[i-1]+arr[i])%MAX;
    }
    ll sum=0;
    for(int i=2;i<=n;i++){
        sum=(sum+arr[i]*dp[i-1])%MAX;
    }
    cout<<sum;
    return;
}
int main(){
    IO
    //TEST
    solve();
    return(0);
}
/*
2
3 3
2500 2500 2520
10 -5 -20
10 15 20
-15 17 13
2 3
2125 2098
-20 10 -10
10 10 -20
*/
/*
1
3 3
2500 2500 2520
10 -5 -20
10 15 20
-15 17 13

*/


Measured memory_bytes: 6660