akhauriyash/Code-Regression huggingface dataset:
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'

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

  int n, y; cin >> n >> y;
  for (int i = 0; i <= y / 10000; ++i){
    if (i > n) break;
    if (i * 10000 > y) break;
    for (int j = 0; j <= y / 5000; ++j){
      if (i + j > n) break;
      if (i * 10000 + j * 5000 > y) break;
      for (int k = 0; k <= y / 1000; ++k){
        if (i + j + k > n) break;
        if (i + j + k == n && 10000 * i + 5000 * j + 1000 * k == y){
          cout << i << " " << j << " " << k << '\n'; return 0;
        }
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << '\n';

  return 0;
}

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

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

    int flag = 0;
    int atai;
    long data = N;

    string res;

    while(flag == 0){
        atai = (data-1) % 26;
        data = (data-1) / 26;
        if(data == 0){
            flag = 1;
        }
        res += (char)('a'+atai);
    }
    reverse(res.begin(),res.end());
    cout << res << endl;

}

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

using vi = vector<int>;

using vd = vector<double>;
using vvd = vector<vd>;

int main()
{
    ios_base::sync_with_stdio(0);

    int n; cin >> n;

    vi in_t(n);
    vi in_v(n);

    for(auto& x : in_t) cin >> x;
    for(auto& x : in_v) cin >> x;

    vi limitv = {0};

    for(int i = 0; i < n; i++)
    for(int j = 0; j < in_t[i]; j++)
        limitv.push_back(in_v[i]);

    int num_t = limitv.size();
    int num_v = 102;

    vvd dp(num_t, vd(num_v, -1));

    dp[0][0] = 0;

    for(int t = 1; t < num_t; t++)
    for(int v = 0; v <= limitv[t]; v++)
    {
        if(v && dp[t - 1][v - 1] >= 0)
            dp[t][v] = max(dp[t][v], dp[t - 1][v - 1] + double(v - 1) + 0.5);

        if(dp[t - 1][v + 1] >= 0 && v + 1 <= limitv[t])
            dp[t][v] = max(dp[t][v], dp[t - 1][v + 1] + double(v) + 0.5);

        if(dp[t - 1][v] >= 0)
        {
            if(v < limitv[t])
                dp[t][v] = max(dp[t][v], dp[t - 1][v] + double(v) + 0.25);
            else
                dp[t][v] = max(dp[t][v], dp[t - 1][v] + double(v));
        }
    }

    cout << fixed << setprecision(3) << dp[num_t - 1][0] << endl;
    return 0;
}

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

using namespace std;

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

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

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
void roll(int dice[], int a, int b, int c, int d){
  int tmp = dice[a];
  dice[a] = dice[b];
  dice[b] = dice[c];
  dice[c] = dice[d];
  dice[d] = tmp;
}
void roll_x(int dice[]){
  roll(dice, 0, 1, 5, 4);
}
void roll_y(int dice[]){
  roll(dice, 0, 2, 5, 3);
}
void roll_z(int dice[]){
  roll(dice, 1, 2, 4, 3);
}
void get_dice(int dice[], int top, int front){
  REP(i, 6) dice[i] = i + 1;
  for(int i = 0; i < 6; i++){
    if(i % 2) roll_x(dice);
    else roll_y(dice);
    for(int j = 0; j < 4; j++){
      roll_z(dice);
      if(dice[0] == top && dice[1] == front) return;
    }
  }
}

int main(){
  int N;
  int tr[4] = {2, 1, 3, 4};
  while(cin>>N && N){
    int h[200][200] = {};
    int d[200][200] = {};
    REP(i, N){
      int t, f;
      cin>>t>>f;
      int dice[6];
      get_dice(dice, t, f);
      int x = 100, y = 100;
      while(true){
        int nr = -1;
        REP(r, 4){
          if(h[y + dy[r]][x + dx[r]] < h[y][x] && dice[tr[r]] >= 4 && (nr == -1 || dice[tr[nr]] < dice[tr[r]])){
            nr = r;
          }
        }
        if(nr == -1) break;
        x += dx[nr];
        y += dy[nr];
        if(nr == 3) roll_x(dice);
        if(nr == 2) roll_y(dice);
        if(nr == 0) REP(i, 3) roll_y(dice);
        if(nr == 1) REP(i, 3) roll_x(dice);
      }
      h[y][x]++;
      d[y][x] = dice[0];
    }
    int ans[6] = {};
    REP(y, 200)REP(x, 200) if(d[y][x] > 0) ans[d[y][x] - 1]++;
    REP(i, 6){
      cout<<ans[i];
      if(i == 5) cout<<endl;
      else cout<<" ";
    }
  }
  return 0;
}

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

using namespace std;

const long long INF = 1e18;
const int N = 1e5;
const int MOD = 1e9 + 7;

const double PI = acos(-1);


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n;
    string s;
    cin >> n >> s;
    if (n & 1)
        cout << "No";
    else {
        int f = 1;
        for (int i = 0; i < n / 2; i++)
            if (s[i] != s[n / 2 + i])
                f = 0;
        if (f)
            cout << "Yes";
        else
            cout << "No";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
vector<int> calc(int n){
    vi res(1001,0);
    if(n==0||n==1)return res;
    for(int i = 2;i<=n;i++){
        while(n%i==0){
            n/=i;
            res[i]++;
        }
    }
    return res;
}
int main(){
    int n;cin>>n;
    vi res(1001,0);
    rep2(i,2,n+1){
        vi su = calc(i);
        rep2(j,1,su.size()){
            res[j]+=su[j];
            //cout<<j<<su[j]<<endl;
        }
    }
    ll ans =1;
    rep2(i,2,n+1){
        //if(res[i]==0)continue;
        //cout<<res[i]<<endl;
        ans*=(res[i]+1);
        ans%=mod;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
input = gets.chomp.split(' ').map(&:to_i)

if (input[0] - input[2]).abs <= input[3]
  puts "Yes"
elsif (input[0] - input[1]).abs <= input[3] && (input[1] - input[2]).abs <= input[3]
  puts "Yes"
else
  puts "No"
end


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

using namespace std;
int a[5],k;
int main()
{
	cin>>a[1]>>a[2]>>a[3]>>k;
	sort(a+1,a+4);
	int ans=a[3]*(1<<k)+a[1]+a[2];
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
 
struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;
 
template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is,pair<T1,T2>&p){
    is>>p.first>>p.second;
    return is;
}

template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}


signed main(){
    int h,w,n;cin>>h>>w>>n;swap(h,w);
    using P=pair<int,int>;
    set<P> st;
    vector<P>v(n);
    rep(i,n){
        cin>>v[i];
        st.insert(v[i]);
    }
    // 番pain
    for(int i=1;i<=h;i++)st.insert(P(w+1,i));
    for(int i=1;i<=w;i++)st.insert(P(i,h+1));

    int ans=w;
    vector<int> yp(200010,-1);
    yp[1]=1;
    {
        for(int x=1,y=1;;){
            if(st.count(P(x+1,y))) break;
            x++;
            if(st.count(P(x,y+1))) continue;
            y++;
            yp[y]=x;
        }
    }
    for(auto [x,y]:v){
        if(yp[y]<0) continue;
        if(x>yp[y]){
            chmin(ans,x-1);         
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 33804
{-#LANGUAGE FlexibleContexts#-}
import Control.Monad
import Control.Monad.State
import Control.Monad.Reader
import Control.Arrow
-- import Control.Comonad
import Data.Maybe
import Data.List
import Data.Bool
import Data.Fixed
import Data.Tuple
import Data.Ratio
import qualified Data.Map.Strict as M
import qualified Data.Array.IO as IA
import qualified Data.Vector as V

getI = read <$> getLine :: IO Int
getIs = map read . words <$> getLine :: IO [Int]
getD = read <$> getLine :: IO Double
getDs = map read . words <$> getLine :: IO [Double]
getInt = read <$> getLine :: IO Integer
getInts = map read . words <$> getLine :: IO [Integer]

type Row = Integer
type Col = Integer
type PointI = (Integer, Integer)
type Point = (Int, Int)

mmm = 1000000007
fact n
    | n < 1 = 1
    | True = foldr1 (*) [1..n]
ti = toInteger
fi = fromInteger
fig = fromIntegral
rf = realToFrac

(.<.) :: Integer -> Integer -> Integer
(.<.) f g -- combination
    | g < 1 || f < 1 || f < g = 1
    | True = foldr1 (*) (take (fi g) [f,f-1..]) `div` fact g
(.>.) f g --combination with repetition
    | g < 1 || f < 1 = 1
    | True = fact (f + g - 1) `div` (fact (f - 1) * fact g)
comb = (.<.)
combWp = (.>.)

unique a = unique_ (reverse . sort $ a) [] Nothing
    where
        unique_ [] arr _ = arr
        unique_ (x:xs) arr n
            | n == Just x = unique_ xs arr n
            | otherwise = unique_ xs (x:arr) $ Just x
 
zeroume keta num
    | (length . show $ num) > keta = show num
    | otherwise = do 
        let zeros = take keta $ repeat '0'
        reverse . take keta $ (reverse . show $ num) ++ zeros
 
i2b num
    | num < 2 = show num
    | otherwise = i2b_ num []
        where
            i2b_ num str
                | num == 0 = str
                | num == 1 = '1':str
                | otherwise = do
                    let next = num `div` 2
                    let this = if odd num then '1' else '0'
                    i2b_ next (this:str)

mapIncr = mapPlus 1
mapPlus n Nothing = Just n
mapPlus n a = (+) n <$> a

countIf f = length . filter f

enumDivisor :: Int -> [Int]
enumDivisor n = do
    let sqrted = floor $ sqrt (fromIntegral n)
        smaller = filter (\x -> mod n x == 0) [1..sqrted]
        bigger = reverse $ map (div n) smaller
    if head bigger == sqrted then smaller ++ (init bigger)
    else smaller ++ bigger

safeHead [] = Nothing
safeHead (x:_) = Just x

-- 
--
--

main = map head . words <$> getLine >>= putStrLn


Measured memory_bytes: 508
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
using namespace std;

int main() {
    string s,a;
    cin >> s >> a;
    if(s[0]==a[2] && s[1]==a[1] && s[2]==a[0]){
        cout << "YES" << endl;
    }else{
        cout << "NO" <<endl;
    }
 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<double,double> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const LL INF=1<<17;




int main(){
    int N,C;
    cin >> N >> C;
    int D[C][C];
    int c[N][N];
    for(int i=0;i<C;i++){
        for(int j=0;j<C;j++){
            cin >> D[i][j];
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            cin >> c[i][j];
            c[i][j]--;
        }
    }
    LL X[3][C];
    for(int k=0;k<C;k++){
        X[0][k]=0;
        X[1][k]=0;
        X[2][k]=0;
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                X[(i+j)%3][k]+=D[c[i][j]][k];
            }
        }
    }
    LL ans=LINF;
    for(int i=0;i<C;i++){
        for(int j=0;j<C;j++){
            for(int k=0;k<C;k++){
                if(i==j||j==k||k==i) continue;
                ans=min(ans,X[0][i]+X[1][j]+X[2][k]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1280
# A - Grouping 2
# ある学校に N 人の生徒がいる
# なるべく多く 3人 以上のグループにしたい！
# 3人以上のグループを 最大で x 個 作れるときの x の値を出力する

# 生徒数 N （整数） を入力
N = int(input())
# print(N)

# N を 3 で割った余りで 計算する

if N % 3 == 0:
    # print('amari0')
    answer = int(N / 3)
elif N % 3 == 1:
    # print('amari1')
    answer = int((N - 1) / 3)
else:
    # print('amari2')
    answer = int((N - 2) / 3)

# 結果の表示
print(answer)


Measured memory_bytes: 9004
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// using namespace std;

void Main() {
  int N, A, B;
  std::cin >> N >> A >> B;

  int res;

  if (A * N >= B) {
    std::cout << B << std::endl;
    return;
  } else {
    std::cout << A * N << std::endl;
    return;
  }
}

int main() {
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<cstdio>
#include<climits>
using namespace std;

int m[105][105];
int plen;
//function matrix chain order
void matrixco(int p[]){
  int n,j,q;
  n=plen-1;
  for(int i=1;i<=n;i++){
    m[i][i]=0;
  }

  for(int l=2;l<=n;l++){
    for(int i=0;i<=n-l+1;i++){
      j=i+l-1; 
      m[i][j]=INT_MAX;   
      for(int k=i;k<=j-1;k++){
	q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	if(q<m[i][j]){
	  m[i][j]=q;
	}
      }
    }
  }
}

int main(){
  int n;
  int p[105];
  int r,c;
  //load n
  cin >>n;

  plen=n+1;

  for(int i=0;i<n;i++){
    //load r,c
    scanf("%d %d",&r,&c);

    if(i!=n-1) p[i]=r;
    else{
      p[i]=r;
      p[i+1]=c;
    }
  }

  matrixco(p);

  cout <<m[1][n]<<endl;
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define iFOR(i, a, b) for(int i=(a); i>=(b); --i)
#define make_unique(a) sort(all((a))), (a).resize(unique(all((a)))-(a).begin())

using namespace std;

typedef pair<int,int> PII;
typedef long long LL;
typedef double DD;
typedef long double LD;
typedef pair<LL,LL> PLL;
typedef pair<DD,DD> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;
const LL mod = 1000000007;
char s[104];
int main(){
    int n;
    scanf("%d %s",&n,s+1);
    int l = strlen(s+1);
    s[n+1] = 0;
    printf("%s",s+1);
    if(l > n) printf("...");
	return 0;
}
/*
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */

Measured memory_bytes: 3824
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cassert>
#include <utility>

using namespace std;
using ll = long long;

int main (){
    ll W,H,x,y;
    cin >> W >> H >> x >> y;
    double area = H*W;
    double max_area = area /2;
    int ans=0;
    cout << std::fixed;
    cout << setprecision(9)<<max_area;
    double a = H / W;
    if(2*x==W && 2*y==H){
        ans = 1;
    }
    cout <<' ' <<ans ;   
}

Measured memory_bytes: 256
def main():
	N= int(input())
	dp = [0]*(N+1)
	dp[1]=1

	for i in range(2, N+1):
		ans = dp[i-1]+1
		tmp6 = 6
		while tmp6 <= i:
			ans = min(ans, dp[i-tmp6]+1)
			tmp6 *= 6

		tmp9 = 9
		while tmp9 <= i:
			ans = min(ans, dp[i-tmp9]+1)
			tmp9 *= 9

		dp[i] = ans

	print(dp[N])

if __name__ == '__main__':
    main()

Measured memory_bytes: 3828
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> A(N+1);
  REP(i, N+1) cin >> A[i];

  vector<int> B(N);
  REP(i, N) cin >> B[i];

  int ans = 0;
  REP(i, N){
    int MIN = min(A[i], B[i]);
    B[i] -= MIN; A[i] -= MIN; ans += MIN;
    MIN = min(A[i+1], B[i]);
    B[i] -= MIN; A[i+1] -= MIN; ans += MIN;
  }

  cout << ans << "\n";

  return 0;
}

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

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=a;i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(a>b)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

struct A{
	int sz;
	map<int,int> v;
	void set(int i,int x){
		if(i<sz){
			v[i]=x;
			return;
		}
		throw int(0);
	}
	int get(int i){
		if(v.count(i))return v[i];
		throw int(0);
	}
};

struct B{
	map<char,A> buf;
};

struct S{
	string s;
	int i;
	char nx(){
		if(i==int(s.size()))return '.';
		return s[i];
	}
	void inc(){
		i++;
	}
	bool dig(){
		return isdigit(nx());
	}
};

void decass(B&cur,S&s);
int expr(B&cur,S&s);
int num(S&s);

void decass(B&cur,S&s){
	char n=s.nx();
	s.inc();
	if(!cur.buf.count(n)){
		//declare
		s.inc();
		int i=num(s);
		s.inc();
		cur.buf[n]=A{i,{}};
	}else{
		dmp(n);
		//assignment
		s.inc();
		int i=expr(cur,s);
		dmp(i);
		s.inc();
		s.inc();
		int v=expr(cur,s);
		dmp(v);
		cur.buf[n].set(i,v);
	}
}

int expr(B&cur,S&s){
	if(s.dig()){
		return num(s);
	}else{
		char n=s.nx();
		dmp(n);
		s.inc();
		s.inc();
		int i=expr(cur,s);
		s.inc();
		return cur.buf[n].get(i);
	}
}

int num(S&s){
	int res=0;
	while(s.dig()){
		res=res*10+s.nx()-'0';
		s.inc();
	}
	return res;
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	while(1){
		vc<string> ss;
		while(1){
			string s;cin>>s;
			if(s==".")break;
			ss.pb(s);
		}
		if(ss.empty())break;
		B cur;
		int ans=-1;
		rep(i,ss.size()){
			S s{ss[i],0};
			try{
				decass(cur,s);
			}catch(int dummy){
				ans=i;
				break;
			}
		}
		cout<<ans+1<<endl;
	}
}



Measured memory_bytes: 3348
import math
while 1:
    n = int(input())
    if n == 0 :
        break
    a = list(map(int,input().split()))
    ave = sum(a)/n
    s = 0
    for i in range(n):
        s += (a[i] - ave)**2
    s2 = math.sqrt(s / n)
    print("%.9f"%s2)



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

int main() {
  int N;
  ll K;
  cin >> N >> K;
  int A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  
  ll b[N]{};
  ll d = pow(10, 9) + 7;
  ll ans = 0;
  ll sum1 = 0;

  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (A[i] > A[j]) sum1++;
    }
  }

  int a[2 * N];
  for (int i = 0; i < N; i++) {
    a[i] = A[i];
    a[N + i] = A[i];
  }

  ll sum2 = 0;
  for (int i = 0; i < N; i++) {
    for (int j = N; j < 2 * N; j++) {
      if (a[i] > a[j]) {
        sum2++;
      }
    }
  }
  
  ans += K * sum1 % d;
  ans += (K * (K - 1) / 2) % d * (sum2);
  ans %= d;
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>
using namespace std;
#include <string>
#include <cstdio>
#define ll long long
#define TLE std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef pair<int,int> pii;
const ll mod = 1000000007 ;
const int INF=0x3f3f3f3f;
#define test(n) cout<<"Test "<<n<<endl;
#define pb push_back
#define rp(n) for(int i=1;i<=n;i++)
#define rep(n,m) for(int i=1;i<=n;i++) for(int j=1;j<=m;j++)
ll ksm(ll x,ll n){ll ans=1;while (n){if (n&1)ans=(ans*x)%mod;x=x*x%mod;n>>=1;}return ans;}
using namespace std;
double pi = atan(1.0)*4 ;
const int mxn = 1e3+7 ;
int n,t,m,k,l,r;
/// ll mat[mxn][mxn], prime[mxn], isprime[mxn];
ll phi[mxn];
int a[11];
ll exgcd(ll a,ll b, ll &x ,ll &y)
{
    if(!a&&!b) return -1;/// 无最大公约数
    if(!b) {x=1,y=0;return a;}
    ll d=exgcd(b,a%b,y,x);
    y-=a/b*x ;
    return d;
}
string str ;
int vis[mxn][mxn];
struct node{string str;int k;}no[mxn];
int main()
{
    cin>>n>>m;
    if(n==1&&!m)
    {
        cout<<0<<endl;return 0;
    }
    rp(10) a[i] = -1;
    bool f1 = 0 ;
    for(int i=1;i<=m;i++)
    {
        cin>>l>>r;/// 1 3 1 0 2 1 3 2
        if(l==1 && !r && n!=1) f1 = 1 ;
        else if(a[l]==-1) a[l] = r ;
        else
        {
            if(a[l]==r) f1 = 0 ;
            else f1 = 1 ;
        }
    }
    if(f1) { cout<<-1<<endl;return 0;}
    for(int i=1;i<=n;i++)
    {
        if(a[i]==-1)
        {
            if(i==1) a[i]=1;
            else  a[i]=0;
        }
        cout<<a[i];
    }
    cout<<endl;
}


Measured memory_bytes: 888
#include<stdio.h>
int main(void){
   int dan,i,j,k,ans[31]={0},year;
    for(;;){
    scanf("%d",&dan);
    if(dan==0)break;
    year=0;
    ans[0]=1;
    for(i=1;i<=dan;i++){
        if(i==1){
            ans[1]=ans[0];
        }
        else if(i==2){
            ans[2]=ans[0]+ans[1];
        }
        else ans[i]=ans[i-1]+ans[i-2]+ans[i-3];
    }
    if(ans[dan]%3650==0){
        year=ans[dan]/3650;
    }
    else{
        year=ans[dan]/3650+1;
    }
    printf("%d\n",year);
    }
return 0;
}

Measured memory_bytes: 1028
x, k, d = map(int, input().split())
x = abs(x)

MIN = x-k*d


if 0 <= MIN:
    print(MIN)
else:
    a, R = divmod(x, d)
    L = d-R
    cnt = k-a
    if cnt % 2 == 0:
        print(R)
    else:
        print(L)


Measured memory_bytes: 8852
using System;

namespace ConsoleApp8
{
	class Program
	{
		static void Main(string[] args)
		{
			int c500 = int.Parse(Console.ReadLine());
			int c100 = int.Parse(Console.ReadLine());
			int c50 = int.Parse(Console.ReadLine());
			int total = int.Parse(Console.ReadLine());
			int count = 0;
			// べたい
			for (int i = 0; i <= c500; i++)
			{
				for (int j = 0; j <= c100; j++)
				{
					for (int k = 0; k <= c50; k++)
					{
						if (500 * i + 100 * j + 50 * k == total)
							count++;
					}
				}
			}
			Console.WriteLine(count);
		}
	}
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>

using namespace std;

const int N = 100 + 5, NO_OF_LETTERS = 4, MOD = 1e9 + 7, T_INDEX = 3;
long long no_of_strings[N][NO_OF_LETTERS][NO_OF_LETTERS][NO_OF_LETTERS];
char letter[NO_OF_LETTERS] = {'A', 'C', 'G', 'T'};

int ok(int last_1, int last_2, int last_3, int last_4)
{
    char l1 = letter[last_1], l2 = letter[last_2], l3 = letter[last_3], l4 = letter[last_4];

    if(l1 == 'A' && l2 == 'G' && l4 == 'C')
        return false;
    if(l1 == 'A' && l3 == 'G' && l4 == 'C')
        return false;
    if(l1 == 'A' && l2 == 'G' && l3 == 'C')
        return false;
    if(l2 == 'A' && l3 == 'G' && l4 == 'C')
        return false;
    if(l1 == 'G' && l2 == 'A' && l3 == 'C')
        return false;
    if(l2 == 'G' && l3 == 'A' && l4 == 'C')
        return false;
    if(l1 == 'A' && l2 == 'C' && l3 == 'G')
        return false;
    if(l2 == 'A' && l3 == 'C' && l4 == 'G')
        return false;

    return true;
}

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

    vector <long long> total(length + 1, 0);

    for(int i = 1; i <= length; i++)
    {
        for(int last_1 = 0; last_1 < NO_OF_LETTERS; last_1++)
        {
            for(int last_2 = 0; last_2 < NO_OF_LETTERS; last_2++)
            {
                for(int last_3 = 0; last_3 < NO_OF_LETTERS; last_3++)
                {
                    no_of_strings[i][last_1][last_2][last_3] = 0;

                    for(int last_4 = 0; last_4 < NO_OF_LETTERS; last_4++)
                    {
                        if(i == 1)
                        {
                            no_of_strings[i][last_1][T_INDEX][T_INDEX] = 1;
                        }
                        else if(i == 2)
                        {
                            no_of_strings[i][last_1][last_2][T_INDEX] = 4;
                            //   cout << "f(" << i << "," << letter[T_INDEX] << letter[last_2] << letter[last_1] <<  "= " << no_of_strings[i][last_1][last_2][T_INDEX] << endl;
                        }
                        else if(i == 3)
                        {
                            if(ok(T_INDEX, last_3, last_2, last_1))
                            {
                                no_of_strings[i][last_1][last_2][last_3] = 1;//no_of_strings[i - 1][last_2][last_3][T_INDEX];
                            }
                        }
                        else if(ok(last_4, last_3, last_2, last_1))
                        {
                            no_of_strings[i][last_1][last_2][last_3] += no_of_strings[i - 1][last_2][last_3][last_4];
                        }
                    }

                    no_of_strings[i][last_1][last_2][last_3] %= MOD;

                    //cout << "f(" << i << "," << letter[last_3] << letter[last_2] << letter[last_1] <<  "= " << no_of_strings[i][last_1][last_2][last_3] << endl;
                    total[i] = (total[i] + no_of_strings[i][last_1][last_2][last_3])%MOD;
                }
            }
        }
    }

    cout << total[length];
    return 0;
}


Measured memory_bytes: 256
h,n=map(int,input().split())
AB=[]
maA=0
inf=float("inf")
for i in range(n):
   a,b=map(int,input().split())
   maA=max(maA,a)
   AB.append((a,b))

dp=[inf]*(h+maA+1)
dp[0]=0
for i in range(h+1):
   for aj,bj in AB:
      dp[i+aj]=min(dp[i+aj],dp[i]+bj)
print(min(dp[h:]))

Measured memory_bytes: 42332
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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 S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll x;

int main() {
  std::cin >> x;

  std::cout << (!x ? 1 : 0) << endl;

  return 0;
}

Measured memory_bytes: 3620
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <string>
#include <deque>
#include <stack>
#include <cmath>

using namespace std;

#define PB push_back
#define MP make_pair
#define f first
#define s second
#define FOR(i,a,b) for (LL i = a; i < b; ++i)
#define RFOR(i, b, a) for (int i = b-1; i>=a; --i)
#define FILL(a, b) memset(a, b, sizeof a)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)a.size()

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<LL> VI;
typedef pair<LL, LL> PLL;

const int INF = 1000 * 1000 * 1000;
const LL LINF = 1LL * INF*INF;
const int MAX = 400007;
const long double PI = acos(-1.);
const double EPS = 1e-6;
LL mod = 1000LL * 1000 * 1000 + 7;

int n,k;
int arr[MAX/4];
int dpT[MAX/4];
int dp(int pos)
{
	if(pos>n-1)
		return INF;
	if(pos==n-1)
		return 0;
	if(dpT[pos]!=-1)
		return dpT[pos];
	int ans=INF;
	FOR(i,0,k)
		ans=min(ans,dp(pos+i+1)+abs(arr[pos]-arr[pos+i+1]));
	return dpT[pos]=ans;
}



int main()
{
	//freopen("input.tXXt", "r", stdin);
	ios_base::sync_with_stdio(0);
	FILL(dpT,-1);
	cin >> n >> k;
	FOR(i,0,n)
		cin >> arr[i];
	cout<<dp(0);




	return 0;
}


Measured memory_bytes: 5760
#include <stdio.h>
#include <iostream>
#include <string>
#include <sstream>
#include <math.h>
using namespace std;


int count(long n){
	int c=0;
	while(n!=0){
		if(n%10==4 || n%10==7){
			c++;
			n=n/10;
		}else{
			n=n/10;
		}
	}
	return c;
}

int main(){
	double a;
	double b;
	cin >> a;
	cin >> b;
	cout << a/b << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
int main()
{
  int a,b;
  cin >> a >> b;
  if(a<=8&&b<=8)printf("Yay!");
  else printf(":(");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define N 1000000
using namespace std;

int main(void){
	int n;
	int i,j;
	int count;
	vector<int> prime(N);

	for(i=0;i<N;i++){
		if(i%2==0||i==1) prime.at(i)=0;
		else prime.at(i)=1;
	}
	prime.at(2)=1;
	for(i=3;i<(N/2);i+=2){
		if(prime.at(i)==1){
			for(j=2;i*j<N;j++){
				prime.at(i*j)=0;
			}
		}
	}
	while(cin >> n){
		count=0;
		for(i=2;i<=n;i++){
			if(prime.at(i)==1) count++;
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 4896
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

int h, w;
string s[2010];
int lft[2010][2010];
int rt[2010][2010];
int up[2010][2010];
int down[2010][2010];

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> h >> w;
    rep(i, 0, h){
        cin >> s[i];
    }
    rep(i, 0, h){
        int now = -1;
        rep(j, 0, w){
            if(s[i][j] == '#') now = j;
            lft[i][j] = now;
        }
        now = w;
        for(int j = w - 1; j >= 0; j--){
            if(s[i][j] == '#') now = j;
            rt[i][j] = now;
        }
    }
    rep(j, 0, w){
        int now = -1;
        rep(i, 0, h){
            if(s[i][j] == '#') now = i;
            up[i][j] = now;
        }
        now = h;
        for(int i = h - 1; i >= 0; i--){
            if(s[i][j] == '#') now = i;
            down[i][j] = now;
        }
    }
    int ans = 0;
    rep(i, 0, h){
        rep(j, 0, w){
            if(s[i][j] == '#') continue;
            int tmp = 1;
            tmp += j - lft[i][j] - 1;
            tmp += rt[i][j] - j - 1;
            tmp += i - up[i][j] - 1;
            tmp += down[i][j] - i - 1;
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 130688
// Add compile option "-std=c++11" for C++11 compile.

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

// Macro
#define rep(i, N) for(int i=0; i<(int)N; i++)

// Type
template <typename T> using P = pair<T, T>;
using ll = long long;
using ull = unsigned long long;

// Constants
const ll INF = 1e18;
const ll MOD = 1000000007;

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

  ll abs_sum = 0;   // 絶対値の総和
  ll abs_min = INF; // 絶対値の最小値
  int minus_n = 0;  // マイナス値の数
  bool zero_flag = false; // 0があるか
  rep(i, N) {
    ll A;
    cin >> A;

    if(A == 0) {
      zero_flag = true;
      continue;
    }

    if(A < 0) {
      minus_n++;
    }

    ll abs_A = abs(A);
    abs_sum += abs_A;
    abs_min = min(abs_min, abs_A);
  }

  if(zero_flag || minus_n % 2 == 0) {
    cout << abs_sum << endl;
  } else {
    cout << abs_sum - (2 * abs_min) << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
struct node{
    int x1,y1,x2,y2;
};
vector<node> ans;
int a[600][600],h,w;
int main()
{
    scanf("%d%d",&h,&w);
    int i,j;
    for (i=1;i<=h;i++)
        for (j=1;j<=w;j++) scanf("%d",&a[i][j]);
    
    for (i=1;i<=h;i++)
    {
        for (j=1;j<w;j++)
            if (a[i][j]%2) {ans.push_back((node){i,j,i,j+1});a[i][j]--;a[i][j+1]++;}
    }

    for (i=1;i<h;i++)
        if (a[i][w]%2) {ans.push_back((node){i,w,i+1,w});a[i][w]--;a[i+1][w]++;}

    int len=ans.size();
    printf("%d\n",len);
    for (i=0;i<len;i++)
        printf("%d %d %d %d\n",ans[i].x1,ans[i].y1,ans[i].x2,ans[i].y2);
    return 0;
}

Measured memory_bytes: 5360
/*
    Author:  raghav.blacklist1
*/

#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define	ln(a,b)		((a==(b-1))?'\n':' ')
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define trace(x) 	cerr<<#x<<": "<<x<<" "<<endl;

using namespace std;

ll spf[1000005];

void sieve(){

	rep(i,0,1000005)	spf[i]=i;

	rep(i,2,1005)	if(spf[i]==i)	for(ll j = i*i; j<1000005;j+=i)	spf[j]=i;
}

int main(void){

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

	sieve();
	ll n;
	cin>>n;
	ll ar[n];
	rep(i,0,n)	cin>>ar[i];
	ll cnt[1000005] = {0};

	rep(i,0,n){

		ll tmp = ar[i];
		set<ll> fact;
		while(tmp!=1){

			fact.insert(spf[tmp]);
			tmp/=spf[tmp];
		}

		for(auto it:fact)	cnt[it]++;
	}

	ll flag1 = 1, flag2 = 1;
	rep(i,1,1000001){

		if(cnt[i]>1)	flag1=0;
		if(cnt[i]==n)	flag2=0;
	}	

	if(flag1){

		cout<<"pairwise coprime"<<endl;
		return 0;
	}

	if(flag2){

		cout<<"setwise coprime"<<endl;
		return 0;
	}

	cout<<"not coprime"<<endl;

	return 0;
}

Measured memory_bytes: 27028
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        x: usize,
        y: usize,
        z: usize
    }
    println!("{}", x * y / 2);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
#define maxx 100010
#define NIL -1

struct node{
	int num;
	int parent,left,right;//left is son, right is brother
};
node tree[maxx];

int get_depth(int x){
	int depth=0;
	while(tree[x].parent!=NIL){
		//cout<<"  "<<x<<"  ";
		x=tree[x].parent;
		depth++;
	}
	return depth;
}

int main (){
	for(int i=0;i<maxx;i++) {
		tree[i].parent=NIL;
		tree[i].left=NIL;
		tree[i].right=NIL;
	}
	int n;
	cin>>n;
	int a,b,c,d;
	for(int i =0;i<n;i++){
		cin>>a>>b;
		tree[i].num=a;
		for(int j=0;j<b;j++){
			if(j==0) {
				cin>>c;
				tree[tree[i].num].left=c;
				tree[c].parent=tree[i].num;
			}
			else{
				cin>>d;
				tree[c].right=d;
				tree[d].parent=tree[i].num;
				c=d;
			}
		}
	}

	for(int i=0;i<n;i++){
		printf("node %d: parent = %d, depth = %d, ",i,tree[i].parent,get_depth(i));
		if(tree[i].parent==NIL) printf("root, [");
		else if(tree[i].left==NIL) printf("leaf, [");
		else printf("internal node, [");
		if(tree[i].left!=NIL) {
			printf("%d",tree[i].left);
			int xx=tree[i].left;
			while(tree[xx].right!=NIL){
				printf(", %d",tree[xx].right);
				xx=tree[xx].right;
			}
		}
		printf("]\n");
	}
	return 0;
}


Measured memory_bytes: 4768
/*#include <iostream>
using namespace std;
int main() {
	char X,Y;
	cin >> X;
	cin >> Y;
	if (X > Y) {
		cout << ">";
		return 0;
	}
	if (X < Y) cout << "<";
	else cout << "=";

	return 0;
}	*/
/*
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int>p;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		p.push_back(a);
	}
	sort(p.begin(), p.end());
	int suma= 0;
	bool b =true;
	for (int i = N-1; i >=0; i--) {
		if (b) {
			suma += p[i];
			b = false;
		}
		else {
			suma -= p[i];
			b = true;
		}
	}

	cout << suma;

	return 0;
*/

	#include <iostream>
	#include <algorithm>
	#include <vector>
	using namespace std;

	int main() {
		int N;
		cin >> N;
		vector<int>p;
		vector < int>t;
		for (int i = 0; i < N; i++) {
			int a;
			cin >> a;
			p.push_back(a);
			if (a % 10 != 0) {
				t.push_back(a);
			}
		}
		int suma = 0;
		for (int i =0; i <N; i++) 
		{
			suma += p[i];
		}
		sort(t.begin(), t.end());
		
		if (suma % 10 == 0 && !t.empty()) {
			suma -= t[0];
			cout << suma << endl;

		}
		else if (t.empty()) {
			cout << 0 << endl;
	
		}
		else cout << suma << endl;
		
		return 0;
	}	

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main()
{
    int N;
    cin >> N;
    ll ans = 0;
    for(int i=1; i<1000000; i++){
        ans += (N-1)/i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
import sys
from collections import defaultdict

N,M=map(int, sys.stdin.readline().split())

ac=set()
wa=defaultdict(lambda: 0) 

wa_cnt=0

for _ in range(M):
    p,s=sys.stdin.readline().split()
    if s=="AC":
        ac.add(p)
        if wa[p] != "Done":
            wa_cnt+=wa[p]
        wa[p]="Done"
    elif s=="WA":
        if wa[p] != "Done":
            wa[p]+=1

print len(ac),wa_cnt


Measured memory_bytes: 47516
using System;
public class Aprob {
    public static void Main() {
        string[] readSome = new string[2];
        readSome = Console.ReadLine().Split(' ');
        int N = int.Parse(readSome[0]);
        int L = int.Parse(readSome[1]);
        string[] S = new string[N];
        for (int i = 0; i < N; i++) {
            S[i] = Console.ReadLine();
        }
        Array.Sort(S);
        string outp = "";
        foreach (string str in S) {
            outp += str;
        }
        Console.WriteLine(outp);
    }
}

Measured memory_bytes: 13408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  if (a <=8 && b <= 8) {
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using ll=long long; 
using ld=long double; 
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int mod1=1e9+7; 
#define MAX 1000002
ll fact[MAX+7];
ll powerm1(ll a,ll b){ ll res=1; while(b) { if(b&1) res=(res*a)%mod1; a=(a*a)%mod1; b>>=1; } return res; }
void fac(){ fact[0]=1; fact[1]=1; rep(i,2,MAX-1) fact[i]=(fact[i-1]*i)%mod1; }
ll modInv(int n){ return powerm1(n,mod1-2); }
int ncr(int n,int r){ if (r==0) return 1; return (fact[n]*modInv(fact[r])%mod1*modInv(fact[n-r])%mod1)%mod1; }
int main()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout); 
  #endif
  int n; cin>>n; if(n<2){ cout<<0; return 0; } if(n==2){ cout<<2<<"\n"; return 0; }
  ll ans=powerm1(10,n); ans=(ans-2*powerm1(9,n)); while(ans<0) ans+=mod1; ans=(ans+powerm1(8,n))%mod1; cout<<ans; 
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;
	const int maxn=1e5+9;
	int d[maxn];
	for(int i=1;i<=n;++i)cin>>d[i];
	sort(d+1,d+n+1);
	int p=n/2;
	cout<<d[p+1]-d[p];
    return 0;
}

Measured memory_bytes: 640
N, M, C = map(int, input().split())
Blis = [int(x) for x in input().split()]
Alis = []
k = 0
for i in range(N):
  Alis.append([int(x) for x in input().split()])
for i in range(N):
  total = 0
  for j in range(M):
    total = total + (Alis[i][j])*(Blis[j])
  total = total + C
  if total > 0:
    k = k + 1
print(k)

Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))

new_A = []
prev_a = -1
for a in A:
    if prev_a == a:
        continue
    new_A.append(a)
    prev_a = a

stock = 0
wallet = 1000
for i in range(len(new_A)):
    prev_price = 201 if i == 0 else new_A[i - 1]
    next_price = 0 if i == len(new_A) - 1 else new_A[i + 1]
    #print(prev_price, new_A[i], next_price)
    # 極大
    if prev_price < new_A[i] and next_price < new_A[i]:
        # 売る
        #print('sell: ' + str(new_A[i]) + ' * ' + str(stock))
        wallet += stock * new_A[i]
        stock = 0
    if new_A[i] < prev_price and new_A[i] < next_price:
        # 買う
        #print('buy: ' + str(new_A[i]) + ' * ' + str(wallet // new_A[i]))
        stock = wallet // new_A[i]
        wallet = wallet % new_A[i]
print(wallet)

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

Measured memory_bytes: 256
A = [1, 3, 5, 7, 8, 10, 12]
B = [4, 6, 9, 11]
C = [2]
x, y = map( int, input().split())
if (x in A and y in A) or (x in B and y in B):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::cmp::{min,max};
use std::collections::HashMap;
fn main() {
    input!{
        a:usize,
        b:usize,
    }
    let ans = if a % b ==0 {
        0
    } else {
         a % b
    };
    println!("{}",ans);
}

Measured memory_bytes: 4352