akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
   int n;cin>>n;
   vector<int> l(2*n);
   for(int i=0;i<2*n;i++)cin>>l[i];
   sort(l.begin(),l.end());
   int ans=0;
   for(int i=0;i<2*n;i+=2){
      ans += min(l[i],l[i+1]);
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
n=int(input())
A=[int(i) for i in input().split()]
S=[0]
s=0
for i in range(n):
  s+=A[i]
  S.append(s)
import collections
c=collections.Counter(S)
ans=0
for a in set(S):
  k=c[a]
  ans+=k*(k-1)//2
print(ans)

Measured memory_bytes: 47216
import java.util.*;

public class Main{

	public static int contains(int[] array,int a){
		int c=0;
		for(int i=0;i<array.length;i++){
			if(array[i]==a){
				c=1;
				break;
			}else{
				c=2;
			}
		}return c;
	}

	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		if(n>=1 && n<=999){
			System.out.println("ABC");
		}else{
			System.out.println("ABD");
		}
	}
}


Measured memory_bytes: 21844
A = [list(map(int, input().split())),
     list(map(int, input().split())),
     list(map(int, input().split()))]

N = int(input())
B = [int(input()) for _ in range(N)]

for a in A:
    if a[0] in B and a[1] in B and a[2] in B:
        print('Yes')
        exit()

for i in range(3):
    if A[0][i] in B and A[1][i] in B and A[2][i] in B:
        print('Yes')
        exit()

if A[0][0] in B and A[1][1] in B and A[2][2] in B:
    print('Yes')
    exit()

if A[0][2] in B and A[1][1] in B and A[2][0] in B:
    print('Yes')
    exit()

print('No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n, a[52] = {}, b = 0, c = 0;
    cin >> n;
    fr1(n) cin >> a[i], b = max(b, a[i]), c = min(c, a[i]);
    if (!b) {
        cout << n - 1 << '\n';
        for (int i = n - 1; i; i--) cout << i + 1 << ' ' << i << '\n';
    } else if (!c) {
        cout << n - 1 << '\n';
        fr1(n - 1) cout << i << ' ' << i + 1 << '\n';
    } else if (b > -c) {
        int d = 0, e = 0;
        fr1(n) if (a[i] < 0) d++;
        fr1(n) if (a[i] == b) e = i;
        cout << d + n - 1 << '\n';
        fr1(n) if (a[i] < 0) cout << e << ' ' << i << '\n';
        fr1(n - 1) cout << i << ' ' << i + 1 << '\n';
    } else {
        int d = 0, e = 0;
        fr1(n) if (a[i] > 0) d++;
        fr1(n) if (a[i] == c) e = i;
        cout << d + n - 1 << '\n';
        fr1(n) if (a[i] > 0) cout << e << ' ' << i << '\n';
        for (int i = n - 1; i; i--) cout << i + 1 << ' ' << i << '\n';
    }
}


Measured memory_bytes: 256
<?php

$main = new Main;
$main->execute();

class Main {

    public function execute()
    {
        while (true) {
            fscanf(STDIN, '%d %d', $height, $width);

            if (! $this->canExecute($width, $height)) return;

            $rect = new Rectangle($width, $height);
            $rect->draw();
        }
    }

    public function canExecute($width, $height)
    {
        return ($width != 0) && ($height != 0);
    }

}


/**
 * ????????¢???????????????
 */
class Rectangle {
    private $width;
    private $height;
    private $char = '#';

    public function __construct($width, $height)
    {
        $this->width  = $width;
        $this->height = $height;
    }

    public function draw()
    {
        for ($line = 0; $line < $this->height; $line++) {
             $this->drawLine($this->width, $this->char);
        }
        $this->drawEmptyLine();
    }

    public function drawLine()
    {
        echo str_repeat($this->char, $this->width), PHP_EOL;
    }

    public function drawEmptyLine()
    {
        echo PHP_EOL;
    }

}

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

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ll long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define INF INT_MAX
#define cases(t) ll t; cin>>t; while(t--)
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }

#define pb push_back
#define mp make_pair
#define ii pair<int,int>
#define msi map<string,int>

int main(){
	IOS
	int n;
	cin>>n;
	if(n%1000)
		cout<<1000 - n%1000;
	else
		cout<<0;
		
return 0;
}

Measured memory_bytes: 3648
//
// Created by watemus on 03.05.2020.
//

#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

using namespace std;

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ff first
#define ss second

using ll = long long;
using ld = long double;
#define int ll

constexpr ll INFL = 1'000'000'000'000'000'228;
constexpr int INFI = 1'000'000'228;

#ifdef LOCAL
#else
#endif


void run() {
    int x;
    cin >> x;
    for (int i = -1000; i < 1000; i++) {
        for (int j = -1000;j < 1000; j++) {
            int aa = i * i * i * i * i;
            int bb = j * j * j * j * j;
            if (aa - bb == x) {
                cout << i << " " << j << endl;
                return;
            }
        }
    }
}

signed main() {
#ifdef LOCAL
    std::freopen("input.txt", "r", stdin);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif
    int t = 1;
//    cin >> t;
    while (t--) {
        run();
    }
    return 0;
}

Measured memory_bytes: 3668
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<stdio.h>
#include<vector>
#include<utility>
#include<queue>
#include<stdbool.h>
#include<math.h>
typedef long long ll;
#define N (1000000000+7)
using namespace std;
typedef pair<int, int> P;

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

ll prime[100010];
ll kaijo[200010];
void init() {
	kaijo[0] = 1;
	for (ll i = 1;i <= 200000;i++)kaijo[i] = (kaijo[i - 1] * i) % N;
}

ll inv(ll x) {
	ll res = 1;
	ll k = N - 2;
	ll y = x;
	while (k) {
		if (k & 1)res = (res*y) % N;
		y = (y%N*y%N) % N;
		k /= 2;
	}
	return res;
}

ll Comb(ll n, ll k) {
	ll b = kaijo[n];
	ll c = kaijo[n - k];
	ll d = kaijo[k];
	ll cd = (c*d) % N;
	return ((b%N)*(inv(cd)%N) + N) % N;
}


int main(void) {
	int n;
	cin >> n;
	vector<int>h(n);
	for (int i = 0;i < n;i++)cin >> h[i];
	int now = 0, activate = 0, ans = 0;
	for (int i = 0;i < n;i++) {
		now = h[i];
		if (now > activate) {
			ans += now - activate;
			activate = now;
		}
		else activate = now;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rf = lambda: map(float, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a = max(ri(), ri())
print(math.ceil(ri()/a))












Measured memory_bytes: 27228
//*******Abhijit Burman***********//
//Jalpaiguri Government Engineering College//

// Taken From Striver_79
// Never open a ranklist untill and unless you are done with solving problems, wastes 3/4 minuts 
// Donot treat CP as a placement thing, love it and enjoy it, you will succeed for sure. 


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define MAXX (1000000000000000000+7)
#define mod 1000000007
#define endl "\n"
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
void input(ll a[], ll sz) {for(ll i=0;i<sz;i++) cin >> a[i];}
void print(ll a[], ll sz) {for(ll i=0;i<sz;i++) {if (i == sz - 1) cout << a[i] << "\n"; else cout << a[i] << " ";}}
ll dx1[] = {1, 1, 0, -1, -1, -1, 0, 1};
ll dy1[] = {0, 1, 1, 1, 0, -1, -1, -1};

ll dx2[] = {1, 0, -1, 0};
ll dy2[] = {0, 1, 0, -1};

ll mul(ll a, ll b, ll p = mod) {return ((a % p) * (b % p)) % p;}
ll add(ll a, ll b, ll p = mod) {return (a % p + b % p) % p;}
ll power(ll x,ll y,ll p = mod) 
{ 
    ll res = 1;
    x = x % p;
    while (y > 0) 
    {
        if (y & 1) 
            res = (res*x) % p;
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll n, ll p = mod)
{
    return power(n, p - 2, p);
}
ll ncrMod(ll n, ll r, ll p = mod)
{
    if (r == 0)
        return 1;
    ll fac[n + 1];
    fac[0] = 1;
    for (ll i = 1 ; i <= n; i++)
        fac[i] = fac[i - 1] * i % p;
    return (fac[n] * modInverse(fac[r], p) % p *
            modInverse(fac[n - r], p) % p) % p;
}
// a+b=xor(a,b)+2*(a&b)//

bool isPrime(ll n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
vector<ll> vect[2*(100000)+100];
ll visited[2*(100000)+100];
ll ans;
void dfs(ll node){
    // cout<<"node: "<<node<<endl;
    visited[node]=1;
    ans++;
    for(int child:vect[node]){
        if(visited[child]==0){
            dfs(child);
        }
    }
}
void solve()
{
    ll n,m;
    cin>>n>>m;
    
    ll maxi=0;
    if(m==0){
        cout<<1<<endl;
        return ;
    }
    while(m--){
        ll x,y;
        cin>>x>>y;
        
        vect[x].pb(y);
        vect[y].pb(x);
    }
    
    for(int i=1;i<=n;i++){
        if(visited[i]==0){
            ans=0;
            dfs(i);
            maxi=max(maxi,ans);
        }
    }
    cout<<maxi<<endl;
}


int main()
{
	fio;
// 	#ifndef ONLINE_JUDGE
//     // for getting input from input.txt
//     freopen("input.txt", "r", stdin);
//     // for writing output to output.txt
//     freopen("output.txt", "w", stdout);
// 	#endif
 

	ll t=1;
// 	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 22356
<?php
  $s = trim(fgets(STDIN));
  for($i=0; $i<strlen($s); $i++){
      if(!isset($a)){
        if($s[$i] == "A") $a = $i;
      }
      if($s[$i] == "Z") $z = $i+1;
  }
  echo $z-$a;

Measured memory_bytes: 4732
#include<bits/stdc++.h>
using namespace std;
const int mn = 100005;
char s[mn];
int main()
{
    int n;
    scanf("%d%s", &n, s + 1);
    int ans = 1;
    for(int i = 2; i <= n; i++)
        ans += (s[i] != s[i - 1]);
    printf("%d\n", ans);
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k; cin >> n >> k;
  vector<int>p(n);
  for(int i = 0; i < n; i++)
    cin >> p.at(i);
  sort(p.begin(), p.end());
  int ans = 0;
  for(int i = 0; i < k; i++)
    ans += p.at(i);
  
  cout << ans;
}


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

using namespace std;

int main(){
	int a, L;

	// ループ
	cin >> a >> L;
	while((a > 0) || (L > 0)){
		vector <int> an;
		int *p;
		bool flag = false;

		// メモリ領域の確保
		p = new int[L];

		// 正しく確保できたかチェック
		if(p == NULL){
			cerr << "メモリ領域の確保に失敗しました" << endl;
			return -1;
		}

		// 入力を数列に追加
		an.push_back(a);

		// 数列を帰納的に求める
		while(!flag){
			int sum = 0, j = 10, max = 0, min = 0;
			int i;
			bool isEnd;

			// 分割処理
			for(i=0;i<L;i++){
				p[i] = (a % j) - sum;
				sum += p[i];
				p[i] /= (j / 10);
				j *= 10;
			}

			// ソート
			do{
				isEnd = true;
				for(i=0;i<L-1;i++){
					if(p[i] < p[i+1]){
						p[i] -= p[i+1];
						p[i+1] += p[i];
						p[i] = p[i+1] - p[i];
						isEnd = false;
					}
				}
			}while(!isEnd);

			// 最大値を求める
			for(i=0;i<L;i++){
				max *= 10;
				max += p[i];
			}

			// 最小値を求める
			for(i=0;i<L;i++){
				min *= 10;
				min += p[L-i-1];
			}

			// 差を計算し、数列を検索
			for(i=0;i<(int)an.size();i++){
				if(an[i] == (max - min)){
					flag = true;
					cout << i << " " << an[i] << " " << ((int)an.size() - i) << endl;
				}
			}
			// まだ続けるなら
			if(!flag){
				// 数列に追加
				an.push_back(max - min);
				a = max - min;
			}
		}

		// メモリ領域の解放
		delete [] p;

		// 入力
		cin >> a >> L;
	}

	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("a.in","r",stdin);
#endif
    int A,B,M;
    cin>>A>>B>>M;
    vector <ll> a(A),b(B);
    vector <pair <pll,ll > > x(M);
    rep(i,A)
    cin>>a[i];
    rep(i,B)
    cin>>b[i];
    rep(i,M)
    cin>>x[i].fi.fi>>x[i].fi.se>>x[i].se;
    ll mx=INFLL,mx1=INFLL,ans=INFLL;
    rep(i,A)
    mx=min(mx,a[i]);
    rep(i,B)
    mx1=min(mx1,b[i]);
    ans=mx+mx1;
    rep(i,M)
    {
        ans=min(ans,a[x[i].fi.fi-1]+b[x[i].fi.se-1]-x[i].se);
    }
    cout<<ans;




}

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

using namespace std;

vector<vector<int>> G;

void warshall_floyd(int n) {
    for (int k = 0; k < n; k++){       // 経由する頂点
        for (int i = 0; i < n; i++) {    // 始点
            for (int j = 0; j < n; j++) {  // 終点
                if(G[i][k]!=10&&G[k][j]!=10)G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }
}

bool solve(){
    int n;
    cin>>n;
    if(n==0)return false;

    G.assign(26,vector<int>(26,10));
    for (int i = 0; i < 26; ++i) {
        G[i][i]=0;
    }
    vector<string> vs(n);
    for (int i = 0; i < n; ++i) {
        cin>>vs[i];
    }
    for (int i = 1; i < n; ++i) {
        int ind=0;
        if(vs[i]==vs[i-1])continue;
        while(vs[i].size()>=ind+1&&vs[i-1].size()>=ind+1&&vs[i][ind]==vs[i-1][ind]){
            ++ind;
        }
        if(vs[i].size()>=ind+1&&vs[i-1].size()>=ind+1){
            G[vs[i-1][ind]-'a'][vs[i][ind]-'a']=-1;
            //G[vs[i][ind]-'a'][vs[i-1][ind]-'a']=-1;
        }
        else{
            if(vs[i-1].size()>vs[i].size()&&vs[i].front()==vs[i-1].front()){
                cout<<"no"<<endl;
                return true;
            }
        }
    }
    warshall_floyd(26);
/*
    for (int i = 0; i < 26; ++i) {
        for (int j = 0; j < 26; ++j) {
            cout<<G[i][j]<<" ";
        }
        cout<<endl;
    }
*/
    for (int i = 0; i < 26; ++i) {
        if(G[i][i]<0){
            cout<<"no"<<endl;
            return true;
        }
    }
    cout<<"yes"<<endl;
    return true;
}

int main(){
    while(solve());
    return 0;
}


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

int main(){

 string N;
 cin >> N;
 
  if(N.at(0) == N.at(1) && N.at(1) == N.at(2)){
   cout << "Yes" << endl;
  }
   
  else if(N.at(1) == N.at(2) && N.at(2) == N.at(3)){
   cout << "Yes" << endl;
  }
  else{
   cout << "No" << endl;
  }

}

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

int main(void) {
	int A,B,C;

	scanf("%d %d %d", &A,&B,&C);
	if (B + C > A) {
		printf("%d", B + C-A);
	}else {
		puts("0");
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
int p[111111];
int main() {
	int n;
	cin >> n;
	long r = 0;
	for (int i = 0; i < n; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		p[i] = -a - b;
		r -= b;
	}
	sort(p, p + n);
	for (int i = 0; i < n; i += 2)
		r -= p[i];
	cout << r << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
 
int main() {
  int sum, A, B, C, D;
  cin >> sum;
 
  A = sum / 1000;
  B = (sum / 100) % 10;
  C = (sum / 10) % 10;
  D = sum % 10;
 
  // + + +
  if (A + B + C + D == 7){
    cout << A << "+" << B << "+" << C << "+" << D << "=7" << endl;
    return 0;
  }
  // + + -
  if (A + B + C - D == 7){
    cout << A << "+" << B << "+" << C << "-" << D <<  "=7" << endl;
    return 0;
  }
  // + - +
  if (A + B - C + D == 7){
    cout << A << "+" << B << "-" << C << "+" << D <<  "=7" << endl;
    return 0;
  }
  // - + +
  if (A - B + C + D == 7){
    cout << A << "-" << B << "+" << C << "+" << D <<  "=7" << endl;
    return 0;
  }
  // + - -
  if (A + B - C - D == 7){
    cout << A << "+" << B << "-" << C << "-" << D <<  "=7" << endl;
    return 0;
  }
  // - + -
  if (A - B + C - D == 7){
    cout << A << "-" << B << "+" << C << "-" << D <<  "=7" << endl;
    return 0;
  }
  // - - +
  if (A - B - C + D == 7){
    cout << A << "-" << B << "-" << C << "+" << D <<  "=7" << endl;
    return 0;
  }
  // - - -
  if (A - B - C - D == 7){
    cout << A << "-" << B << "-" << C << "-" << D <<  "=7" << endl;
    return 0;
  }
 
}


Measured memory_bytes: 256
//  main.cpp
//  solve
//
//  Created by Ahmed on 11/16/16.
//  Copyright © 2016 Abdellah. All rights reserved.
//


#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>



#define f first
#define s second
#define pb push_back
#define sz(a) (int)a.size()
#define lp(i,a,n) for(int (i)=(a);(i)<=(int)(n);(i)++)
#define lpd(i,n,a) for(ll (i)=(n);(i)>=(a);--(i))
#define mp make_pair
#define clr(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define eps 1e-6
#define infi 1000000002
#define infll 1000000000000000000ll
#define MX 1000000
#define X real()
#define Y imag()
#define polar(r,t) ((r)* exp(point(0,(t))))
#define length(a) hypot( (a).X , (a).Y )
#define angle(a) atan2( (a).Y , (a).X )
#define vec(a,b) ( (b) - (a) )
#define dot(a,b) (conj(a)*(b)).X
#define cross(a,b) (conj(a)*(b)).Y
#define lengthsqr(a) dot(a,a)
#define reflect(V,M) (conj((V)/(M)) * (M))
#define normalize(a)   ((a)/length(a))
#define ccw(a,b,c)   cross(vec(a,b) , vec(a,c)) > -eps
#define cosRule(a,b,c) (acos(((a)*(a)+(b)*(b)-(c)*(c))/(2*(a)*(b))))
#define cosDot(a,b) (acos(dot(a,b)/length(a)/length(b)))
#define EQ(a,b) (fabs((a) - (b)) <= eps) /* equal to */
#define NE(a,b) (fabs((a) - (b)) > eps)  /* not equal to */
#define LT(a,b) ((a) < (b) - eps)        /* less than */
#define GT(a,b) ((a) > (b) + eps)        /* greater than */
#define LE(a,b) ((a) <= (b) + eps)       /* less than or equal to */
#define GE(a,b) ((a) >= (b) - eps)       /* greater than or equal to */
#define mod1 100050001
#define mod2 100030001
#define base1 37
#define base2 31
#define que priority_queue<pair<int,int>, vector<pair<int,int>> , greater<pair<int,int> > >
#define rotate(v,t) ((v)*exp(point(0,t)))
#define rotateabout(v,t,a) (rotate(vec(a,v),t)+(a))
#define PI atan(1)*4

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
typedef complex<long double> point;
typedef pair<point, point> line;
typedef pair<double , point> Circle;

const int N = 200005;
int n,p[N],d[N];
vi adjL[N];

void dfs(int node,int dep) {
    
    vi vec;
    for(int ch:adjL[node])
        dfs(ch, dep+1) , vec.pb(d[ch]);


    sort(all(vec));
    for(int x:vec) d[node] = max(d[node]+1, x+1);
    
    
    
}


int main()
{
    scanf("%d",&n);
    lp(i, 2, n) scanf("%d",&p[i]) , adjL[p[i]].pb(i);
    dfs(1, 0);
    printf("%d\n",d[1]);
    return 0;
}
/*
 
 */
//freopen("output.txt","w",stdout);
//freopen("input.txt","r",stdin);
//ios::sync_with_stdio(0);cin.tie(0);



Measured memory_bytes: 17280
package main

import (
	"fmt"
	"os"
)

func main() {
	var input string
	fmt.Scanf("%s", &input)

	dict := make(map[string]int)

	for i := 0; i < len(input); i++ {
		if val, ok := dict[string(input[i])]; ok {
			dict[string(input[i])] = val + 1
		} else {
			dict[string(input[i])] = 1
		}
	}

	for _, v := range dict {
		if v%2 != 0 {
			fmt.Println("No")
			os.Exit(0)
		}
	}
	fmt.Println("Yes")
}


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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long long n, k;
    cin >> n >> k;
    long long total = 1, c = 0;
    while(c < n && (total * 2 - total) < k){
        c++;
        total = total * 2;
    }
    while(c < n){
        total += k;
        c++;
    }
    cout << total;
    return 0;
}


Measured memory_bytes: 256
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>
#include <cmath>
#include <iomanip>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////
const int MOD = 1000000007;  

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

    int H, W;
    cin >> H >> W;

    vector<string> grid(H);
    for (auto & row : grid) {
        cin >> row;
    }

    vector<vector<int>> dp(H, vector<int>(W));

    dp[0][0] = 1;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (!i && !j)
                continue;
            if (grid[i][j] == '#')
                continue;
            if (i)
                dp[i][j] = (dp[i-1][j] + dp[i][j]) % MOD;
            if (j)
                dp[i][j] = (dp[i][j-1] + dp[i][j]) % MOD;  
            //cerr << i << " : " << j << " = " << dp[i][j] << "\n"; 
        }
    }

    cout << dp[H-1][W-1] << "\n";

    return 0;
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt(),m=nxt();
    vector <vector <int> > edges;
    vector <int> row(3);
    edges.resize(m,row);
    vector <vector <int> > dist;
    vector <int> r2;
    r2.resize(n+1,1e8);
    dist.resize(n+1,r2);
    for(int i=1;i<=n;i++)
        dist[i][i]=0;
    for(int i=0;i<m;i++)
    {
        int u=nxt(),v=nxt(),c=nxt();
        edges[i][0]=u;
        edges[i][1]=v;
        edges[i][2]=c;
        dist[u][v]=c;
        dist[v][u]=c;
    }

    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            for(int k=1;k<=n;k++)
                if(dist[j][k]>dist[j][i]+dist[i][k])
                    dist[j][k]=dist[j][i]+dist[i][k];
    int test=0;
    for(int i=0;i<m;i++)
    {
        if(edges[i][2]>dist[edges[i][0]][edges[i][1]])
            test++;
    }
    cout<<test<<endl;

    
    return 0;   
}




 
 


Measured memory_bytes: 384
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int K = sc.nextInt();
		
		boolean ok = false;
		for(int i=0; i<=N; i++)
			for(int j=0; j<=M; j++)
				ok |= i*(M-j)+j*(N-i)==K;
		
		System.out.println(ok ? "Yes" : "No");
		
		sc.close();
	}
}


Measured memory_bytes: 23636
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<list>
#include<math.h>
using namespace std;

#define ll long long
#define vecint vector<int>
#define listint list<int>

#define REP(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define print(a) cout << a << endl

#define INF 1000000007;

int main(){
  int n,m;
  int a[1000],b[1000],c[1000],dist[100][100];

  cin >> n >>m;

  rep(i,m){
    cin >> a[i]>>b[i]>>c[i];
    a[i]--;b[i]--;
  }

  rep(i,n){
    rep(j,n){
      if(i==j) dist[i][j]=0;
      else dist[i][j]=INF;
    }
  }

  rep(i,m){
    dist[a[i]][b[i]]=c[i];
    dist[b[i]][a[i]]=c[i];
  }
  rep(k,n){
    rep(j,n){
      rep(i,n){
        dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
      }
    }
  }

  int ans=m;
  rep(i,m){
    bool shortest=false;
    rep(j,n){
      if(dist[j][a[i]]+c[i]==dist[j][b[i]]) shortest=true;
    }
    if(shortest) ans--;
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
vector<vector<char>> grid;
vector<vector<long long int>> dp;
long long int h,w;
int main(void){
  cin>>h>>w;
  grid=vector<vector<char>>(h,vector<char>(w));
  for(long long int i=0; i<h; i++){
    for(long long int j=0; j<w; j++){
      cin>>grid.at(i).at(j);
    }
  }
  dp=vector<vector<long long int>>(h,vector<long long int>(w,10000000));
  dp.at(0).at(0)=0;
  long long int pre=0;
  if(grid.at(0).at(0)=='#'){
    dp.at(0).at(0)=1;
  }
  for(long long int i=0; i<h; i++){
    for(long long int j=0; j<w; j++){
      if(i==0&&j==0){
        continue;
      }
      if(i==0){
        long long int pre=dp.at(i).at(j-1);
        if(grid.at(i).at(j-1)=='.'&&grid.at(i).at(j)=='#'){
          pre++;
        }
        dp.at(i).at(j)=pre;
      }else if(j==0){
        long long int pre=dp.at(i-1).at(j);
        if(grid.at(i-1).at(j)=='.'&&grid.at(i).at(j)=='#'){
          pre++;
        }
        dp.at(i).at(j)=pre;
      }else{
        long long int pre1=dp.at(i).at(j-1);
        if(grid.at(i).at(j-1)=='.'&&grid.at(i).at(j)=='#'){
          pre1++;
        }
        long long int pre2=dp.at(i-1).at(j);
        if(grid.at(i-1).at(j)=='.'&&grid.at(i).at(j)=='#'){
          pre2++;
        }
        dp.at(i).at(j)=min(pre1,pre2);
      }
    }
  }
  cout<<dp.at(h-1).at(w-1)<<endl;
}

Measured memory_bytes: 3724
import numpy as np

D=int(input())
*c,=map(int,input().split())
c=np.array(c)
s=[]
for i in range(D):
    *x,=map(int,input().split())
    s.append(x)

s=np.array(s).reshape((D,26))
tmps=s*1
dt=[]
cnt=np.array([0]*26)

for d in range(D):
    x=tmps[d]-c*(d-cnt)
    y=np.argmax(x)
    cnt[y]=d+1
    dt.append(y+1)

for i in range(D):
    print(dt[i])

Measured memory_bytes: 27556
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        int K = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
 
        for (int i = A; i <= B; i++) {
            if (i % K == 0) {
                System.out.println("OK");
                return;
            }
        }
 
        System.out.println("NG");
    }
}

Measured memory_bytes: 35928
#include <stdio.h>
int main(){
  long long n,i,a,b,min=1000000,max=-1000000,sum,tem,t;
  scanf("%lld",&n);
  sum = 0;
  for(i=0;i<n;i++){
    scanf("%lld",&a);
    sum = sum + a;
    if(a<min){
      min=a;
    }
    if(a>max){
      max=a;
  }
  }
  printf("%lld ",min);
  printf("%lld ",max);
  printf("%lld\n",sum);
  return 0;
}



Measured memory_bytes: 2100
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main() {
  string str;
  long long k;
  cin >> str;
  cin >> k;
  int count = 0;
  int minn = 0;
  while (minn < str.length()) {
    if (str[minn] != 'a' && 'z' - str[minn] < k - count) {
      count += 'z' - str[minn] + 1;
      str[minn] = 'a';
    }
    minn++;
    
  }
  
  str[str.length() - 1] += (k - count) % 26;
  cout << str << endl;

  return 0;
}

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

int main(){
    int n;
    cin >> n;
    long long Ans = 0;
    for(int i=1;i<=n;i++){
        if(i%3 != 0 && i%5 !=0){
            Ans += i;
        }
    }
    cout << Ans << endl;
    return 0;
}

Measured memory_bytes: 3636
// abc170_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int X, N;
    cin >> X >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    sort(ALL(A));

    int mv = INF;
    int mn = INF;
    REPN(i, -2, 105){

        if (find(ALL(A), i) != A.end()){
            continue;
        }

        if (abs(i - X) < mv){
            mn = i;
            mv = abs(i - X);
        }
    }
    print(mn);

    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>

#include <sstream>

using namespace std;

bool DaC(int m, vector<int> &a, int i, int n){

  if(m==0){
    return true;
  }

  if(i>=n){
    return false;
  }
    
  
  return (DaC(m-a[i], a, i+1, n) || DaC(m, a, i+1, n));
}
		   
		   
int main(){
  int n;
  vector<int> a;
  int q;
  vector<int> m;

  cin >> n;
  
  for(int i=0;i<n;i++){
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }

  cin >> q;

  for(int i=0;i<q;i++){
    int tmp;
    cin >> tmp;
    m.push_back(tmp);
  }

  for(int i=0;i<m.size();i++){
    if(DaC(m[i], a, 0, n)){
      cout << "yes" << endl;
    }else{
      cout << "no" << endl;
    }
  }
  
}

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

vector<int> num;
int n,k;
int ans=1e9;

int main()
{
	scanf("%d%d",&n,&k);
	int a;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a);
		num.push_back(a);
	}
	
	for(register int i=0;i+k-1<n;i++)
	{
		int x=num[i],y=num[i+k-1];
		if(y<=0)
		{
			ans=min(ans,abs(x));
		}
		if(y>0)
		{
			if(x<0) ans=min(ans,abs(x)+abs(y)+min(abs(x),abs(y)));
			else ans=min(ans,y);
		}
	}
	
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int N, A, x[50];
long long dp[52][3001];
int main()
{
    scanf("%d%d", &N, &A);
    for(int i=0; i<N; ++i) scanf("%d", x+i);
    dp[0][0] = 1;
    for(int k=0; k<N; ++k)
        for(int i=k; i>=0; --i)
            for(int j=0; j<=50*i; ++j)
                dp[i+1][j+x[k]] += dp[i][j];
    long long ans = 0;
    for(int i=1; i<=N; ++i)
        ans += dp[i][A*i];
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin>>n;
    int a[n+1];
    for (int i=1;i<=n;i++) {
        a[i] = 1;
    }
    for (int i=1;i<=n;i++) {
        for (int j=i+i;j<=n;j+=i) {
            a[j]++;
        }
    }
    int ans = 0;
    for (int i=1;i<=n;i++) {
        if (i&1) {
            if (a[i]==8) {
                ans++;
            }
        }
    }
    cout<<ans;
}


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

int main() {
  int a, b; cin >> a >> b;
  if(a==1) a+=13;
  if(b==1) b+=13;
  if(a>b) cout << "Alice";
  else if(a<b) cout << "Bob";
  else cout << "Draw";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>

int main() {
	int n;
	std::cin >> n;
	std::vector<int> matSize(n + 1);
	std::cin >> matSize[0] >> matSize[1];
	for (int i = 2; i < n + 1; i++) {
		int dammy;
		std::cin >> dammy >> matSize[i];
	}

	std::vector<std::vector<long>> costMat(n, std::vector<long>(n, 0));
	// 動的計画法により解く
	for (int i = 0; i < n - 1; i++) {
		costMat[i][i + 1] = matSize[i] * matSize[i + 1] * matSize[i + 2];
	}
	for (int i = 2; i < n; i++) {
		for (int j = 0; j < n - i; j++) {
			long min = LONG_MAX;
			for (int k = 0; k < i; k++) {
				long cost = costMat[j][j + k] + costMat[j + k + 1][i + j];
				cost += matSize[j] * matSize[j + k + 1] * matSize[i + j + 1];
				if (cost < min) {
					min = cost;
					costMat[j][i + j] = min;
				}
			}
		}
	}
	std::cout << costMat[0][n - 1] << std::endl;
}


Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace D_ABC158
{
    class MainClass
    {

        static int[] n;

        public static void Main(string[] args)
        {
            string s = ReadLine();

            n = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);

            int nowdir = 1;

            var ll = new LinkedList<string>();
            foreach (Char c in s)
            {
                ll.AddLast(c.ToString());
            }

            for (int i = 0; i < n[0]; i++)
            {
                string[] q = ReadLine().Split().ToArray();
                if (q[0] == "1")
                {
                    nowdir = nowdir * -1;
                }
                else
                {
                    if (nowdir == 1 ^ q[1] == "1")
                    {
                        ll.AddLast(q[2]);
                    }
                    else
                    {
                        ll.AddFirst(q[2]);
                    }
                }

            }

            if (nowdir == 1)
            {
                ll.ToList().ForEach(Write);
                WriteLine();
            }
            else
            {
                var lll = ll.ToList();
                lll.Reverse();
                lll.ForEach(Write);
                WriteLine();
            }
        }
        static string Reverse(string s)
        {
            char[] charArray = s.ToCharArray();
            Array.Reverse(charArray);
            return new string(charArray);
        }
    }


}


Measured memory_bytes: 43672
#include <iostream>
#include <string>

int main() {
    int n, taro_point = 0, hanako_point = 0;
    std::cin >> n;
    for (int i=0;i<n;++i) {
        std::string taro, hanako;
        std::cin >> taro >> hanako;
        if (taro > hanako) taro_point += 3;
        if (taro < hanako) hanako_point += 3;
        if (taro == hanako) {
            taro_point += 1;
            hanako_point += 1;
        }
    }
    std::cout << taro_point << " " << hanako_point << std::endl;
    return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using in6 = int64_t;
using ind = double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n,k;
  cin >> n >> k;
  int ans = 0;
  while(n) {
    n /= k;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

int main() {
	lli N, K;
	cin >> N >> K;
	vector<lli>v;
	vector<double>c;
	for (int i = 0; i <= 20; i++) {
		v.push_back(pow(2, i));
		c.push_back(pow(0.5, i));
	}
	double ans = 0.0;
	for (int i = 1; i <= N; i++) {
		int now = i;
		for (int j = 0; j < 20; j++) {
			if (now * v[j] >= K) {
				ans += c[j];
				//cerr << i << ";" << c[j] << endl;
				break;
			}
		}
	}
	ans /= (double)N;
	printf("%.10f\n", ans);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n,a,b,c;
ll l[8];
ll dfs(ll now,ll x,ll y,ll z){//x,y,zはnowを選ぶ時点でのa,b,c用の竹の長さ
  if(now==n) {
    if(x==0||y==0||z==0) return 1e11;//必ず1本ずつ使う
    return abs(a-x)+abs(b-y)+abs(c-z)-30;
    //ここで足し引きの計算(最初の一本ならコストがかからないから
    //その分計算してしまった30は引く)
  }
  //以下併合の動き
  ll res=dfs(now+1,x,y,z);//今の竹を採用しない
  ll re=dfs(now+1,x+l[now],y,z)+10;//aを作るのにnowの竹を使う
  ll re1=dfs(now+1,x,y+l[now],z)+10;//aを作るのにnowの竹を使う
  ll re2=dfs(now+1,x,y,z+l[now])+10;//aを作るのにnowの竹を使う
  return min({res,re,re1,re2});
}
int main(){
  cin >>n>>a>>b>>c;
  for(ll i=0;i<n;i++) cin >>l[i];
  cout <<dfs(0,0,0,0)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x);
#define rl(x) scanf("%lld",&x);
#define pi(x) printf("%d",x);
#define pl(x) printf("%lld",x);
#define lfd() printf("\n");
#define sp() printf(" ");
int n;
int f[120][12];
int p[120][12];
int exist[12];
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=10;j++){
            cin>>f[i][j];
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=0;j<=10;j++){
            cin>>p[i][j];
        }
    }
    int res=-2147483647;
    for(int i=1;i<1024;i++){
        for(int j=1;j<=10;j++)
            exist[j]=(i>>(j-1))&1;
        int cand=0;
        for(int j=1;j<=n;j++){
            int c=0;
            for(int k=1;k<=10;k++)
                c+=(exist[k]&&f[j][k]);
            cand+=p[j][c];
        }
        res=max(res,cand);
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
n = int(sys.stdin.readline().rstrip())
for i in range(n):
    out = score = 0
    runner = [0] * 3
    while out < 3:
        st = sys.stdin.readline().rstrip()
        if st == 'HIT':
            score += runner[2]
            runner = [1] + runner[:-1]
        elif st == 'HOMERUN':
            score += sum(runner) + 1
            runner = [0] * 3
        else:
            out += 1
    print(score)

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

 using namespace std;

 int main() {
   int A, B, pali;

   cin >> A >> B;

   pali = 0;
   for (int i = A; i <= B; i++) {
     string s = to_string(i);
     if (s.at(0) == s.at(4) && s.at(1) == s.at(3)) pali++;
   }

   cout << pali << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    int n,h[200001];
    cin>>n;
    rep(i,n) cin>>h[i];
    int dp[200001]={0};
    rep(i,n) dp[i+1]=min(dp[i]+abs(h[i+1]-h[i]),dp[i-1]+abs(h[i+1]-h[i-1])+int(1e9*(i==0)));
    cout<<dp[n-1]<<"\n";
}

Measured memory_bytes: 1408
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main() {
    int N,T,c[1000],t[1000],ans=1000000,r=0,m=10000;
    cin>>N>>T;
    for(int i=0;i<N;i++){
        cin>>c[i]>>t[i];
        if(t[i]<=T){
            if(c[i]<ans){
                ans=c[i];
                m=min(m,t[i]);
            }
        }
        else r++;
    }
    if(r==N)cout<<"TLE"<<endl;
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

int h(std::vector<short> p, int g) {
    int ret = g;
    for (int i=0; i<16; i++) {
        if (p[i]>0) {
            ret += (std::abs((p[i]-1)/4 - i/4) + std::abs((p[i]-1)%4 - i%4)); 
        }
    }
    return ret-2;
}

bool dfs(std::vector<short> p, int d, int limit, int pre_dir) {
    int z;
    int depth = d+1;
    if (d > limit) {
        return false;
    }
    bool ok = true;
    for (int i=0; i<16; i++) {
        if (p[i] == 0) {
            z = i;
        }
        if (p[i] != (i+1)%16) {
            ok = false;
        }
    }
    if (ok) {
        return true;
    }

    if (z>3) {
        auto pp = p;
        pp[z] = pp[z-4];
        pp[z-4] = 0;
        if (pre_dir != 2 and h(pp, depth) < limit and dfs(pp, depth, limit, 0)) {
            return true;
        }
    }
    if (z%4 != 3) {
        auto pp = p;
        pp[z] = pp[z+1];
        pp[z+1] = 0;
        if (pre_dir != 3 and h(pp, depth) < limit and dfs(pp, depth, limit, 1)) {
            return true;
        }
    }
    if (z<12) {
        auto pp = p;
        pp[z] = pp[z+4];
        pp[z+4] = 0;
        if (pre_dir != 0 and h(pp, depth) < limit and dfs(pp, depth, limit, 2)) {
            return true;
        }
    }
    if (z%4 != 0) {
        auto pp = p;
        pp[z] = pp[z-1];
        pp[z-1] = 0;
        if (pre_dir != 1 and h(pp, depth) < limit and dfs(pp, depth, limit, 3)) {
            return true;
        }
    }
    return false;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    bool ini = true;

    std::vector<short> p(16);
    for (int i=0; i<16; i++) {
        std::cin >> p[i];
        if (p[i] != (i+1)%16) {
            ini = false;
        }
    }
    if (ini) {
        std::cout << 0 << "\n";
        return 0;
    }

    for (int limit=1; limit<45; limit++) {
        if (dfs(p, 0, limit, 4)) {
            std::cout << limit << "\n";
            return 0;
        }
    }

    std::cout << 45 << "\n";
    return 0;
}


Measured memory_bytes: 3240
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#define INF INT_MAX
using namespace std;

int a, b, c;
int MAX, MIN;
int ans;

int main(){
	cin >> a >> b >> c;
	MAX = max({a, b, c});
	MIN = min({ a, b, c });
	ans = (MAX - MIN);
	cout << ans << endl;

	return 0;
}

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

int main(){
  string S,T;
  int A,B;
  string U;
  
  cin >> S >> T >> A >> B >> U;
  
  if(U == S) cout << A-1 << " " << B << endl;
  if(U == T) cout << A << " " << B-1 << endl;
}

Measured memory_bytes: 256
/* 
    @author : srinathbalaji_99
*/


#include<bits/stdc++.h>

#define PB push_back
#define MP make_pair
#define endl '\n'
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define rep(i, a, b, inc) for(long long i = a; i < b; i += inc)
#define REP(i, n) rep(i, 0, n, 1)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define PLL pair<long long, long long>
#define VL vector<long long>
#define VS vector<string>
#define VLL vector<PLL>
#define VVL vector<VL>
#define MPLL map<long long, long long>
#define UMPLL unordered_map<long long, long long>
#define SETL set<long long>
#define MSETL multiset<long long>
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) (a * b)/GCD(a, b)
#define ff first
#define ss second
#define pall(a) REP(i, sizeof(a)/sizeof(a[0]))cout << a[i] << " ";cout << endl;
#define pvall(v) REP(i, v.size())cout << v[i] << " ";cout << endl;
#define gall(a, n) REP(i, n)cin >> a[i];
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef unsigned long long ULL;
typedef long long LL;
typedef long double LD;


using namespace std;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main()
{
    fast();


    LL t,n,i,j,k,x,y,c,m;
    cin >> k >> x;
    LL left = 1000000;
    LL right = 1000000;
    for(LL i = max(x - left, x - k + 1); i <= min(x + k - 1, right); ++i){
        cout << i << " ";
    }
    
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int a[101];
int main(){

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

int x,n;
  cin>>x>>n;
  
  for(int i=0;i<n;i++)
  {
  	int y;
    cin>>y;
    a[y]=1;
  }

  
  int l=x,r=x;
  while(1)
  {
  	if(!a[l])
  	{
  		cout<<l<<endl;
  		break;
  	}
  	if(!a[r])
  	{
  		cout<<r<<endl;
  		break;
  	}
  	l--;
  	r++;
  	//cout<<l<<' '<<r<<endl;
  }
  return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        String[][] month_and_day = {
            {"1", "31"},
            {"2", "28"},
            {"3", "31"},
            {"4", "30"},
            {"5", "31"},
            {"6", "30"},
            {"7", "31"},
            {"8", "31"},
            {"9", "30"},
            {"10", "31"},
            {"11", "30"},
            {"12", "31"}
        };

        String[] m1d1;
        String[] m2d2;
        int ret = 0;

        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        m1d1 = str.split(" ");

        str = scan.nextLine();
        m2d2 = str.split(" ");

        for (int i = 0; i < month_and_day.length; i++) {
            if (m1d1[0].equals(month_and_day[i][0]) && m1d1[1].equals(month_and_day[i][1])) {
                if (m2d2[0].equals(month_and_day[i + 1][0]) && m2d2[1].equals("1")) {
                    ret = 1;
                    break;
                }
            }
        }

        System.out.println(ret);
        scan.close();

    }
}

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

int main(){
  string s;
  int n, ans;
  cin >> ans;
  while(cin >> s){
    if(s == "=") break;
    cin >> n;
    if(s == "+") ans += n;
    else if(s == "-") ans -= n;
    else if(s == "*") ans *= n;
    else if(s == "/") ans /= n;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s; cin >> s;
  int cnt = 0;
  for(int i = 0; i < s.size()/2; i++){
    if(s.at(i) != s.at(s.size() - i - 1)) cnt++;
  }
  cout << cnt;

}

Measured memory_bytes: 3608