akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<string> A(N);
  map<string,int> B;
  for(string &S:A){
    cin>>S;
    B[S]++;
  }
  int ma=0;
  for(pair<string,int> p:B)
    ma=max(p.second,ma);
  for(pair<string,int> p:B)
    if(p.second==ma)
      cout<<p.first<<endl;
}

Measured memory_bytes: 25152
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
ll ans[1005][1005],prime[10005],num;
bool flag[10005];
int n;
int main()
{
	scanf("%d",&n);
	if(n==2)
	{
		printf("4 7\n23 10\n");
		return 0;
	}
	flag[1]=1;
	for(int i=2;i<=10000;i++)
	{
		if(!flag[i])prime[++num]=i;
		for(int j=1;j<=num&&prime[j]*i<=10000;j++)
		{
			flag[i*prime[j]]=1;
			if(i%prime[j]==0)break;
		}
	}
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	{
		if(!((i+j)&1))
		{
			int p1=(i+j+1)/2;
			int p2=(i-j+n+1)/2+n;
			ans[i][j]=prime[p1]*prime[p2];
		}
	}
	ll v=0;
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	{
		if((i+j)&1)
		{
			ans[i][j]=1;
			if(i!=1)ans[i][j]*=ans[i-1][j]/__gcd(ans[i][j],ans[i-1][j]);
			if(j!=1)ans[i][j]*=ans[i][j-1]/__gcd(ans[i][j],ans[i][j-1]);
			if(i!=n)ans[i][j]*=ans[i+1][j]/__gcd(ans[i][j],ans[i+1][j]);
			if(j!=n)ans[i][j]*=ans[i][j+1]/__gcd(ans[i][j],ans[i][j+1]);
			ans[i][j]++;
		}
		v=max(v,ans[i][j]);
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		  printf("%lld ",ans[i][j]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 7040
#include <stdio.h>
#include <math.h>
int main(void){
  long long x,a=-118,b=-119;
  scanf("%lld",&x);
  for(a=-118;a<=119;a++){
    for(b=-119;b<=118;b++){
      if(pow(a,5)-pow(b,5)==x){
        printf("%lld %lld\n",a,b);
        return 0;
      }
    }
  }
}

Measured memory_bytes: 2596
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int w,h;
    while (cin>>w>>h) {
        if (w==0&&h==0) {
            break;
        }
        char c;
        std::vector<vector<char>> vec(h,vector<char>(w));
        bool seen[h][w];
        for (int i=0;i<h;i++) {
            for (int j=0;j<w;j++) {
                cin>>c;
                vec[i][j]=c;
                seen[i][j]=false;
            }
        }
        int count=0;
        for (int i=0;i<h;i++) {
            for (int j=0;j<w;j++) {
                if (vec[i][j]=='1'&&seen[i][j]==false) {
                    seen[i][j]=true;
                    std::stack<pair<int,int>> stk;
                    stk.push(make_pair(i,j));
                    while (stk.size()!=0) {
                        int x=stk.top().first;
                        int y=stk.top().second;
                        if (x+1<h&&seen[x+1][y]==false&&vec[x+1][y]=='1') { //下
                            stk.push(make_pair(x+1,y));
                            seen[x+1][y]=true;
                        } else if (y+1<w&&seen[x][y+1]==false&&vec[x][y+1]=='1') { //右
                            stk.push(make_pair(x,y+1));
                            seen[x][y+1]=true;
                        } else if (x+1<h&&y-1>=0&&seen[x+1][y-1]==false&&vec[x+1][y-1]=='1') { //左下
                            stk.push(make_pair(x+1,y-1));
                            seen[x+1][y-1]=true;
                        } else if (x+1<h&&y+1<w&&seen[x+1][y+1]==false&&vec[x+1][y+1]=='1') { //右下
                            stk.push(make_pair(x+1,y+1));
                            seen[x+1][y+1]=true;
                        } else if (x-1>=0&&y-1>=0&&seen[x-1][y-1]==false&&vec[x-1][y-1]=='1') { //左上
                            stk.push(make_pair(x-1,y-1));
                            seen[x-1][y-1]=true;
                        } else if (x-1>=0&&y+1<w&&seen[x-1][y+1]==false&&vec[x-1][y+1]=='1') { //右上
                            stk.push(make_pair(x-1,y+1));
                            seen[x-1][y+1]=true;
                        } else if (x-1>=0&&seen[x-1][y]==false&&vec[x-1][y]=='1') { //上
                            stk.push(make_pair(x-1,y));
                            seen[x-1][y]=true;
                        } else if (y-1>=0&&seen[x][y-1]==false&&vec[x][y-1]=='1') { //左
                            stk.push(make_pair(x,y-1));
                            seen[x][y-1]=true;
                        } else {
                            stk.pop();
                        }
                    }
                    count++;
                }
            }
        }
        cout<<count<<endl;
    }
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vst = vector<st>;
using vch = vector<char>;
using vbl = vector<bl>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
#define mkp(a, b) make_pair(a, b) 
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;} return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;} return false;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;
const db pi = acos(-1.0L);


int main(){
  ll n;
  cin >> n;
  vll a(n);
  vin(a);
  ll q;
  cin >> q;
  vll b(q), c(q);
  rep(i, 0, q) cin >> b.at(i) >> c.at(i);

  ll sumall = accumulate(all(a), (ll)0);
  map<ll, ll> stock;
  rep(i, 0, 100001){
    stock[i] = 0;
  }
  rep(i, 0, n){
    stock[a.at(i)]++;
  }
  rep(i, 0, q){
    ll number = stock[b.at(i)];
    stock[b.at(i)] = 0;
    stock[c.at(i)] += number;
    sumall += number * (c.at(i) - b.at(i));
    cout << sumall << endl;
  }
}

Measured memory_bytes: 11968
#include<stdio.h>
int main()
{
  int n;
  scanf("%d",&n);
  int store=n%10;
  if(store==2 || store==4 || store==5 || store==7 || store==9)
  {
    printf("hon\n");
  }
  else if(store==0 || store==1 || store==6 || store==8)
  {
    printf("pon\n");
  }
  else
  {
    printf("bon\n");
  }
}
    

Measured memory_bytes: 2092
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

N,A=ilint()
n=max(A)
r=0
tmp=INF
for a in A:
    if a!=n and abs(n//2-a)<tmp:
        r=a
        tmp=abs(n//2-a)
print(n,r)

Measured memory_bytes: 89568
N, Y = gets.split.map(&:to_i)

max_N = [10000, 5000, 1000].map { |m| Y / m }

ans = []
0.upto(max_N[0]) do |m0|
  0.upto(max_N[1]) do |m1|
  	sen = N - m0 - m1
    if sen >= 0
		if Y == m0 * 10000 + m1 * 5000 + sen * 1000
	      ans << [m0, m1, sen]
	    end
    end
  end
end

puts ans.empty? ? '-1 -1 -1' : ans[0].join(' ')

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

struct Edge { int to, cost; };

template<class T, class Edge> V<T> dijkstra(const VV<Edge>& g, int s = 0) {
  V<T> dist(g.size(), numeric_limits<T>::max());
  using P = pair<T, int>;
  priority_queue< P, V<P>, greater<P> > pque;
  pque.emplace(dist[s] = 0, s);
  while (!pque.empty()) {
    T d; int v;
    tie(d, v) = pque.top(); pque.pop();
    if (d > dist[v]) continue;
    for (const auto& e : g[v]) if (dist[v] + e.cost < dist[e.to]) {
      pque.emplace(dist[e.to] = dist[v] + e.cost, e.to);
    } 
  }
  return dist;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int sx, sy, gx, gy; cin >> sx >> sy >> gx >> gy;
  set< pair<int, int> > se;
  int n; cin >> n;
  while (n--) {
    int x, y; cin >> x >> y;
    se.emplace(x, y);
  }
  int lx, ly; cin >> lx >> ly;
  V<> dx{0, 1, 1, 0, -1, -1};
  VV<> dy{{1, 0, -1, -1, -1, 0}, {1, 1, 0, -1, 0, 1}};
  auto _ = [&](int x, int y, int t) -> int { return 6 * ((lx + x) * (2 * ly + 1) + (ly + y)) + t % 6; };
  VV<Edge> g(6 * (2 * lx + 1) * (2 * ly + 1));
  for (int x = -lx; x <= lx; ++x) for (int y = -ly; y <= ly; ++y) {
    if (se.count({x, y})) continue;
    for (int t = 0; t < 6; ++t) {
      g[_(x, y, t)].emplace_back(Edge{_(x, y, t + 1), 1});
    }
    for (int d = 0; d < 6; ++d) {
      int nx = x + dx[d], ny = y + dy[x & 1][d];
      if (nx < -lx or nx > lx or ny < -ly or ny > ly) continue;
      if (se.count({nx, ny})) continue;
      for (int t = 0; t < 6; ++t) {
        g[_(x, y, t)].emplace_back(Edge{_(nx, ny, t + 1), abs(x * y * t) % 6 != d});
      }
    }
  }
  auto d = dijkstra<int>(g, _(sx, sy, 0));
  int res = 1e9;
  for (int t = 0; t < 6; ++t) res = min(res, d[_(gx, gy, t)]);
  cout << (res != 1e9 ? res : -1) << '\n';
}


Measured memory_bytes: 28240
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

const int M = 1e9+7;

using namespace std;

main()
{
    fast;
    int n,i;
    ll a,b;
    cin>>n>>a>>b;
    ll x[n],ans=0;
    for (i=0;i<n;i++)
        cin>>x[i];
    for (i=0;i<n-1;i++)
        ans+=min((x[i+1]-x[i])*a,b);
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	ab := make([][3]int, n)
	for i := 0; i < n; i++ {
		a, b := intScanner(), intScanner()
		ab[i] = [3]int{a, b, a + b}
	}
	sort.Sort(SliceSort(ab))
	t, k := 0, 0
	for i, v := range ab {
		if i%2 == 0 {
			t += v[0]
		} else {
			k += v[1]
		}
	}
	fmt.Println(t - k)
}

type SliceSort [][3]int

func (x SliceSort) Len() int           { return len(x) }
func (x SliceSort) Less(i, j int) bool { return x[i][2] > x[j][2] }
func (x SliceSort) Swap(i, j int)      { x[i], x[j] = x[j], x[i] }


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define ll long long
#define agar else if
using namespace std;
ll a,b,c,d,n,e,f,g,m;
vector<ll>vc;
string s,t;
set<ll>st;
char a1,b1,c1,d1;
int main()
{
    cin>>a;
    for(ll i=0;i<a;i++)
    {
        cout<<"ACL";
    }
}


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

const int maxn = 1e5+10, MOD = 1e9+7;;

int n;
long long ans = 1;
char s[maxn<<1];
stack<char> st;

int main() {
	cin >> n >> s;
	for (int i = 0; i < 2*n; ++i) {
//		cout << i << ' ' << st.size() << endl;
		if (!st.empty() && st.top() == s[i]) {
			ans = (ans*st.size())%MOD;
			st.pop();
		}
		else {
			if (s[i] == 'W' && st.empty()) ans = 0;
			st.push(s[i]);
		}
	}
//	cout << ans << endl;
	ans *= st.empty();
	for (int i = 1; i <= n; ++i) {
		ans = (ans*i)%MOD;
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
    int N, K;
    cin >> N >> K;
    vector<bool> sunuke(N, false);
    int ans = 0;
    rep(i, N) {
        int d;
        cin >> d;
        rep(j, d) {
            int A;
            cin >> A;
            A--;
            sunuke[A] = true;
        }
    }
    rep(i, N) {
        if (!sunuke[i]) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#!/bin/python

import os
import sys

#
# Complete the gradingStudents function below.
#
def solution(x,y,z,k):
    #
    # Write your code here.
    #
    if k % 2 == 0:
        return x-y
    else:
        return y-x

if __name__ == '__main__':
    inp = raw_input().split()


    result = solution(int(inp[0]),int(inp[1]),int(inp[2]),int(inp[3]))
    if result > 1000000000000000000:
        print ("Unfair")
    else:
        print (str(result))


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

using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


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

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

  auto solve = [n](vector<int> &a) {
    const int LOG = 31;
    vector< vector<long long> > dp(n + 1, vector<long long>(LOG));
    iota(dp[1].begin(), dp[1].end(), 0);

    auto cnt = [](long long from, long long to) {
      int res = 0;
      while (from > to) {
        to *= 4;
        res++;
      }
      return 2 * res;
    };

    for (int i = 1; i < n; i++) {
      for (int j = 0; j < LOG; j += 2) {
        int need = cnt(a[n - i - 1] * (1LL << j), a[n - i]);
        need += need & 1;
        if (need < LOG) {
          dp[i + 1][j] = j + dp[i][need];
        } else {
          dp[i + 1][j] = j + dp[i][LOG - 1] + i * (need - LOG + 1);
        }
      }
    }

    vector<long long> res(n + 1);
    for (int i = 0; i <= n; i++) {
      res[i] = dp[i][0];
    }
    return res;
  };

  auto dp_pos = solve(a);
  auto dp_neg = solve(b);
  debug(dp_pos);
  debug(dp_neg);
  
  long long ans = 1e18;
  for (int i = 0; i <= n; i++) {
    ans = min(ans, dp_pos[n - i] + dp_neg[i] + i);
  }
  cout << ans << '\n'; 
  return 0;
}

Measured memory_bytes: 61664
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])
sum = 0

#累積和、二乗和の両方で1項ずつ求めてmodをとる
for x in A:
  sum += x
  sum %= (10**9+7)
#sum = A.sum() % (10**9+7)

sum2 = 0
for x in A:
  sum2 += x*x
  sum2 %= (10**9+7)
#sum2 = (A**2).sum() % (10**9+7)

ans = (sum**2 - sum2) % (10**9+7)
if ans < 0:
  ans += (10**9+7)
ans *= int((10**9+7+1)/2) 
ans %= (10**9+7)
print(int(ans))


Measured memory_bytes: 49800
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  string s, t;
  cin >> s >> t;

  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());

  cout << (s < t ? "Yes" : "No") << endl;




  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
//#include <cstring>
//#include <sstream>
#include <fstream>
#include <vector>
#include <algorithm>
//#include <stack>
//#include <queue>
//#include <chrono>
//#include <numeric>
//#include <set>
//#define _USE_MATH_DEFINES
//#include <cmath>
//#include <math.h>
//#include <iomanip>
//#include <list>
//#include <limits>

using namespace std;
const int infty = static_cast <int> (pow(256, sizeof(int)) / 2 - 1);

class cRMQ
{
	vector<int> va;
public:
	cRMQ(int n);
	void update(int i, int x);
	int find(int s, int t);
};

cRMQ::cRMQ(int n)
{
	va.resize(n);
	for(int i = 0; i < n; ++i)
	{
		va[i] = infty;
	}
}

void cRMQ::update(int i, int x)
{
	va[i] = x;
}
int cRMQ::find(int s, int t)
{
	int m = infty;
	for(int i = s; i <= t; ++i)
	{
		m = min(m, va[i]);
	}
	return m;
}

int main()
{
	////ifstream fin("DPL_1_C-in40.txt");
	//ifstream fin("test.txt");
	//if (!fin.is_open())
	//{
	//	cout << "File not found." << endl;
	//	return 0;
	//}

	//fin.tie(0);
	//ios::sync_with_stdio(false);

	//int n,q;
	//fin >> n >> q;
	//fin.ignore();

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

	int n, q;
	cin >> n >> q;
	cin.ignore();

	int com, x, y;
	cRMQ cr(n);

	for (int i = 0; i < q; ++i)
	{
		cin >> com >> x >> y;
		//fin >> com >> x >> y;
		switch (com)
		{
		case 0:
			cr.update(x, y);
			break;
		case 1:
			cout << cr.find(x, y) << endl;
		}
	}
	return 0;
}

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

int main()
{
	int n, s;

	vector< vector< long long int > > memo( 10, vector< long long int >( 1001, 0 ) );
	int lim = 0;
	for( int i = 0; i <= 100; ++i ){
		for( int j = 9; j > 1; --j ){
			for( int k = 1000 - i; k >= 0; --k ){
				memo[ j ][ i + k ] += memo[ j - 1 ][ k ];
			}
		}
		memo[ 1 ][ i ] = 1;
	}

	while( cin >> n >> s ){
		if( !n && !s ) break;
		cout << memo[ n ][ s ] << endl;
	}


	return 0;
}

Measured memory_bytes: 3140
def main():

    # X = int(input())
    N, D = map(int, input().split())
    # A = [int(i) for i in input().split()]

    ans = 0
    for i in range(N):
        x, y = map(int, input().split())
        if D >= (x ** 2 + y ** 2) ** 0.5:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9632
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a, b;
    cin >> a >> b;
    vector<int> v(12);
    v[4] = 1;
    v[6] = 1;
    v[9] = 1;
    v[11] = 1;
    v[2] = 2;
    if(v[a] == v[b]) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
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)*}
    };
}
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!{
        a: usize,
        b: usize,
        c: usize,
    };

    let mut ret = true;
    if a < b {
        if a < c && c < b {
            ret = true;
        } else {
            ret = false;
        }
    } else {
        if a > c && c > b {
            ret = true;
        } else {
            ret = false;
        }
    }
    println!("{}", if ret {"Yes"} else {"No"});

}

Measured memory_bytes: 4352
N,Y = gets.split.map(&:to_i)
(0..N).each{ |a|
  (a..N).each{ |b|
    n10,n5,n1 = [a,b-a,N-b]
    if n10*10000 + n5*5000 + n1*1000 == Y
      puts [n10,n5,n1].join(" ")
      exit
    end
  }
}
puts "-1 -1 -1"

Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define int long long
using namespace std;
using Graph = vector<vector<int>>;
const int MOD = 1000000007;

signed main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> S(M);
  vector<int> C(M);
  for( int i = 0; i < M; i++ ) cin >> S.at(i) >> C.at(i);
  
  int op, ed;
  if( N == 1 ){
    op = 0;
    ed = 9;
  }else if( N == 2 ){
    op = 10;
    ed = 99;
  }else{
    op = 100;
    ed = 999;
  }
  
  for( int i = op; i <= ed; i++ ){
    string num = to_string(i);
    bool fg = true;
    for( int j = 0; j < M; j++ ){
      char suzi = '0' + C.at(j);
      if( num.at(S.at(j)-1) != suzi ){
        fg = false;
      }
    }
    if( fg ){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

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

  int n;
  cin >> n;
  vector<int> b(n);
  rep(i, n) cin >> b[i];

  vector<int> ans;
  rep(i, n) {
    bool f = 0;
    for (int j = n-i-1; j >= 0; j--) {
      if (b[j] == j+1) {
        ans.push_back(j+1);
        b.erase(b.begin() + j);
        f = 1;
        break;
      }
    }
    if (f == 0) {
      cout << -1 << endl;
      return 0;
    }
  }

  reverse(ans.begin(), ans.end());

  rep(i, n) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderMake.ABC166
{
    class ABC166C
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split().Select((x) => int.Parse(x)).ToArray();
            var h = Console.ReadLine().Split().Select((x) => int.Parse(x)).ToArray();
            int[] peaks = new int[nm[0]];
            for (int i = 0; i < nm[1]; i++)
            {
                var p = Console.ReadLine().Split().Select((x) => int.Parse(x)-1).ToArray();
                if (h[p[0]] > h[p[1]])
                {
                    peaks[p[1]]++;
                }
                else if(h[p[0]] < h[p[1]])
                {
                    peaks[p[0]]++;
                }
                else
                {
                    peaks[p[0]]++;
                    peaks[p[1]]++;
                }
            }
            Console.WriteLine(peaks.Count((x) => x == 0));
        }
    }
}


Measured memory_bytes: 49424
import java.util.*;

public class Main {
	public Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		try{
			while(true){
				new aoj0034().doIt();
			}
		}catch(Exception g){
			System.exit(0);
		}
	}
	class aoj0034{
		int a[] = new int [10];
		void doIt(){
			String str[] = sc.next().split(",");
			int sum = 0;
			for(int i = 0;i < 10;i++){
				a[i] = Integer.parseInt(str[i]);
				sum = sum + a[i];
			}
			int v1 = Integer.parseInt(str[10]);
			int v2 = Integer.parseInt(str[11]);
			double time = sum /(double)(v1 + v2); 
			time = time * v1;
			sum = 0;
			for(int i = 0;i < 10;i++){
				sum = sum + a[i];
				if(sum >= time){
					System.out.println(i+1);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 17160
#include <stdio.h>

int main(void) {
	char S[1020];
	int N;
	scanf("%s", S);
	for (int i = 0; S[i] != '\0'; i++) {
		N = i;
	}
	if (S[N] == 's')
		printf("%ses", S);
	else
		printf("%ss", S);
	return 0;
}

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

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

        var ans = 1L;
        for (int i = 1; i < s.Length; i++)
        {
            if (s[i - 1] != s[i]) ans++;
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13116
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        ab: [(usize, usize); m],
    }
    let mut unionfind = petgraph::unionfind::UnionFind::new(n);
    for (a, b) in ab {
        unionfind.union(a - 1, b - 1);
    }
    let mut table = std::collections::HashMap::new();
    for i in 0..n {
        *table.entry(unionfind.find(i)).or_insert(0) += 1;
    }
    println!("{}", table.values().max().unwrap_or(&0));
}


Measured memory_bytes: 10516
#include <stdio.h>
#include <string.h>

int win(char*,char*);

int win(char* x,char* y){
  int i,j;
  
  //printf("cmp %d\n",strcmp(x,y));
  
  j=strcmp(x,y);
  if( j==0 ){
    return 0;
  }else{
      if( j>0 ) return -1;
      else if( j<0 ) return 1;
  }
  return 0;
}

int main(){
  int i,n,judge,ts=0,hs=0;
  char ta[101],ha[101];
    
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",ta,ha);
    judge = win(ta,ha);
    if(judge==1) hs+=3;
    else if(judge==-1) ts+=3;
    else{
      ts++;
      hs++;
    }
  }
  printf("%d %d\n",ts,hs);
  
  return 0;
}

Measured memory_bytes: 604
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

struct Combination {
    static ll mpow(ll x, ll n) { ll y = 1; for (; n > 0; n /= 2) { y = n % 2 ? y * x % MOD : y; x = x * x % MOD; } return y; }
    vector<ll> fact, ifact;
    Combination(int n) : fact(n + 1), ifact(n + 1) {
        fact[0] = 1; for (int i = 0; i < n; ++i) fact[i + 1] = fact[i] * (i + 1) % MOD;
        ifact[n] = mpow(fact[n], MOD - 2); for (int i = n; i > 0; --i) ifact[i - 1] = ifact[i] * i % MOD;
    }
    ll operator ()(int n, int k) { return k < 0 || k > n ? 0 : fact[n] * ifact[n - k] % MOD * ifact[k] % MOD; }
} Combi(2047);

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

    vv<ll> dp = vvec(B - A + 2, N + 1, 0LL);
    dp[0][0] = 1;
    rep(i, B - A + 1) {
        rep(j, N + 1) {
            if (dp[i][j] == 0) continue;
            dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;

            ll rest = N - j;
            ll ifp = 1;
            rep(k, C) ifp = ifp * Combi.ifact[A + i] % MOD;
            rep(k, C, D + 1) {
                ll add = (A + i) * k;
                if (add > rest) break;

                ll a = Combi(rest, add) * Combi.fact[add] % MOD * ifp % MOD * Combi.ifact[k] % MOD;
                dp[i + 1][j + add] = (dp[i + 1][j + add] + a * dp[i][j]) % MOD;

                ifp = ifp * Combi.ifact[A + i] % MOD;
            }
        }
    }

    write(dp[B - A + 1][N]);
}

Measured memory_bytes: 8192
#!/usr/bin/env python
# -*- coding: utf-8 -*-

M = 1000000007


def inv(x, m):
  y, u, v = m, 1, 0

  while y != 0:
    t = x // y
    x -= t * y
    u -= t * v
    x, y = y, x
    u, v = v, u

  return u % m


def main():
  x, y = map(int, input().split())
  r = 2 * x - y
  l = 2 * y - x

  if r < 0 or l < 0 or r % 3 != 0 or l % 3 != 0:
    print(0)
    return

  r //= 3
  l //= 3
  value = 1

  for i in range(l):
    value = (value * (r + l - i)) % M
    value = (value * inv(i + 1, M)) % M

  print(value)


if __name__ == '__main__':
  main()


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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

int main() {
    int N, K;
    cin >> K >> N;
    vector<int> A;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    vector<int> ds;
    for (int i = 1; i < N; ++i) {
        ds.push_back(A[i] - A[i - 1]);
    }
    ds.push_back(K - A.back() + A.front());
    sort(ds.begin(), ds.end());
    cout << K - ds.back() << endl;
}

Measured memory_bytes: 2548
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,b;
vector<ll>v;
int32_t main(){
CODE_START;
cin>>n>>b;
ll ans=0;
while(n>0){
    ans++;
    n=n/b;
}
cout<<ans<<endl;
}


Measured memory_bytes: 256
N = int(input())
X = [[] for _ in range(N)]
P = [-1] * N
for i in range(N-1):
    a, b = map(int, input().split())
    X[a-1].append((i, b-1))
    P[b-1] = a-1

Q = [(0, -1)]
ANS = [-1] * (N-1)
while Q:
    x, c0 = Q.pop()
    
    c = 1
    for i, y in X[x]:
        if c == c0: c += 1
        ANS[i] = c
        Q.append((y, c))
        c += 1

print(max(ANS))
for ans in ANS:
    print(ans)

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

int main()
{
    int n;
    cin >> n;
    int tmp;
    int ans = 0;
    vector<int> h;
    int maxh = 0;
    h.push_back(0);
    for(int i=0; i < n; i++){
        cin >> tmp;
        h.push_back(tmp);
    }
    
    for(int i=0; i < n+1; i++){
        if(h[i] <= h[i+1] && maxh <= h[i+1]){
            maxh = max(maxh, h[i+1]);
            ans++;
        }else{
            maxh = max(maxh, h[i]);
        }
    }
    cout << ans << endl;
    return 0; 
}

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

typedef long long ll;
typedef unsigned long long ull;

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

    ll res=0;
    for(ll i=1;i*i<N;i++){
        if(N%i != 0) continue;
        if(N/i <= i+1) continue;
        res += N/i - 1;
    }
    cout<<res<<endl;

    return 0;
}

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

int n,d,a[100009],b[100009];
int idx=1,sum,tim=0,ans=0;
signed main(){
  cin>>n>>d;

  r(i,n){
    cin>>a[i]>>b[i];
  }

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

    if(abs(idx-b[i])>a[i]-tim){
      cout<<-1<<endl;
     return 0;
    }

    if(sum==d &&  !((idx-1)+abs(1-b[i]) <= a[i]-tim )){
      cout<<-1<<endl;
     return 0;
    }

    if( (idx-1)+abs(1-b[i]) <= a[i]-tim ){
      ans+=sum*(idx-1);
      sum=0;
    }
    else{
      ans+=sum*abs(a[i]-tim);
    }
    idx=b[i];
    tim=a[i];
    sum++;
  }



  cout<<ans+sum*(idx-1)<<endl;
}


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

int main(){
  float N,x; string y;
  cin >> N;
  float ans;
  for (int i;i<N;i++){
    cin >> x >> y;
    if (y == "JPY"){
      ans += x;
    }else{
      ans += (x * 380000);
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n, v) rep(i, n) cin >> v[i]

using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1, 0, -1, 0}, y_pos[4] = {0, 1, 0, -1};
int ctoi(char c)
{
	if (c >= '0' && c <= '9')
	{
		return c - '0';
	}
	return 0;
}

char upper(char c)
{
	return c - 0x20;
}

char lower(char c)
{
	return c + 0x20;
}

void unique_vector(vector<int> &v)
{
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
	std::fill((T *)array, (T *)(array + N), val);
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y)
{
	if (y == 0)
		return x;
	return gcd(y, x % y);
}

//最小公倍数
ll lcm(ll x, ll y)
{
	ll g = gcd(x, y);
	return x / g * y;
}

ll myPow(ll x, ll n, ll m)
{
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

//k!
ll facctorialMethod(ll k)
{
	ll sum = 1;
	for (ll i = 1; i <= k; ++i)
	{
		sum *= i;
		sum %= MOD;
	}
	return sum;
}

//nCr
ll permutationMethod(ll n, ll r)
{
	ll n_sum, r_sum;
	ll i;
	r = n - r;
	n_sum = facctorialMethod(n);
	r_sum = facctorialMethod(r);
	return n_sum / r_sum;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main()
{
	int n;
	cin >> n;
	ll ans = 0;
	rep(i,n+1){
		if (i % 3 != 0 && i % 5 != 0)
		{
			ans += i;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3636
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
#include<numeric>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define M 998244353
#define all(x) x.begin(),x.end()
#define mkp(a,b) make_pair(a,b)
using namespace std;

inline int mex(unordered_set<int> st)
{
	int m = 0;
	while (st.find(m) != st.end())
	{
		m += 1;
	}
	return m;
}
inline int calculateGrundy(int n)
{
	if (n == 1)
		return 0;
	unordered_set<int> mexi;
	for (int i = 1; i <= sqrt(n); i += 1)
	{
		if (n % i == 0)
		{
			if (n / i != n)
				mexi.insert(calculateGrundy(n / i));
			mexi.insert(calculateGrundy(i));
		}
	}
	return mex(mexi);
}
inline ll gcd(ll a, ll b)
{
	// This is code taken from geeksforgeek
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
/*ll power(ll x, ll y)
{
	// This is code taken from geeksforgeek
	ll res = 1;

	x = x % N;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % N;
		y = y >> 1;
		x = (x * x) % N;
	}
	return res;
}*/
ll power(ll x, ll y, ll p)
{
	ll res = 1;

	x = x % p;

	while (y > 0)
	{

		if (y & 1)
			res = (res * x) % p;

		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}


ll modInverse(ll n, ll p)
{
	return power(n, p - 2, p);
}

ll nCrModPFermat(ll n, ll r, ll p)
{
	if (r == 0)
		return 1;

	vector<ll> fac(n + 1, 0);
	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;
}

bool check(ll a)
{
	ll count = 0;
	while (a % 2 == 0)
	{
		a /= 2;
		count += 1;
	}
	if (count > 1)
		return false;
	bool flag = true;
	for (ll i = 3; i <= sqrt(a); i += 2)
	{
		if (a % i == 0)
		{
			flag = false;
			break;
		}
	}
	return flag;
}
ll sum(ll n)
{
	return (n * (n + 1)) / 2;
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s;
	string t;
	cin>>s>>t;
	ll ans=0;
	f(i,0,s.length())
	{
		if(s[i]!=t[i])
			ans+=1;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif

vector<int> G[N];
int dfs(int v){
  if(G[v].size()==0) return 0;
  vector<int> ak; 
  REP(i,G[v].size()) ak.pb(dfs(G[v][i]));
  sort(all(ak));
  reverse(all(ak));
  int mx=0;
  REP(i,ak.size()) mx=max(mx,ak[i]+i+1); 
  return mx;
}
int main(){
  int n; scanf("%d",&n);
  REP(i,n-1){
    int x; scanf("%d",&x); G[x-1].pb(i+1);
  }
  printf("%d\n",dfs(0));
  return 0;
}

Measured memory_bytes: 34560
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define for(i,a,b) for(int i=a;i<b;i++)
#define sort(a,b) sort(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
 
int main() {
  ll n,t;
  ci(n>>t);
  vec c(n),d(n);
  for(i,0,n)
    ci(c[i]>>d[i]);
  ll b=pow(10,5);
  for(i,0,n)
    if(t>=d[i])
      if(b>=c[i])
        b=c[i];
  if(b==pow(10,5))
    co("TLE");
  else
    co(b);
  }

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

#define pb push_back
#define FOR(i, s, e) for (int (i) = (s); (i) < (e); (i)++)

int N, Q;
char s[200100], t[200100], d[200100];

int C(int x) {
    FOR(i, 0, Q) {
        if(s[x] == t[i]) {
            if(x == 0) return 1;
            if(x == N + 1) return 3;
            if(d[i] == 'L') {
                x--;
            }
            else {
                x++;
            }
            
        }
    }
    if(x == 0) return 1;
    if(x == N + 1) return 3;
    return 2;
}



int main() {
    cin >> N >> Q;
    FOR(i, 1, N + 1) cin >> s[i];
    FOR(i, 0, Q) cin >> t[i] >> d[i];

    int L1 = 0, R3 = N + 1;
    while(R3 - L1 > 1) {
        int mid = (L1 + R3) / 2;
        if(C(mid) == 1) L1 = mid;
        else R3 = mid;
    }
    int L2 = R3;

    L1 = 0; R3 = N + 1;
    while(R3 - L1 > 1) {
        int mid = (L1 + R3) / 2;
        if(C(mid) == 3) R3 = mid;
        else L1 = mid;
    }
    int R2 = L1;

    cout << R2 - L2 + 1 << endl;

}


Measured memory_bytes: 896
input_str = input()
input_list = input_str.split(' ')
a = int(input_list[0])
b = int(input_list[1])
x = int(input_list[2])
if a <= x:
    if x <= a + b:
        print('YES')
    else:
        print('NO')
else:
    print('NO')


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

int main(){
    char row[4];
    int number = 0;
    scanf("%s", row);
    for(int i = 0; i < 5; i++){
        if(row[i] == '+'){
            number++;
        }else if(row[i] == '-'){
            number--;
        }
    }
    printf("%d\n", number);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<queue>
#include<utility>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define MP make_pair
typedef long long ll;


ll dp[52][52];
bool flag[52][52];
int w,d,n;
bool ok(int i,int j){
    if(i>=w||i<0)return 0;
    if(j>=d||j<0)return 0;
    return 1;
}

int main(){
    cin >> w >> d >> n;
    priority_queue<pair<ll,pair<int,int> > > pq;
    rep(i,n){
        int x,y,z;
        cin >> x >> y >> z;
        x--;y--;
        dp[x][y] = z;
        flag[x][y] = 1;
        pq.push(MP(z,MP(x,y)));
    }
    while(!pq.empty()){
        auto x = pq.top();
        pq.pop();
        int a = x.second.first;
        int b = x.second.second;
        ll c = x.first;
        for(int i=-1;i<=1;i++){
            if(i==0)continue;
            if(ok(a+i,b)){
                if(flag[a+i][b]){
                    if(abs(dp[a+i][b]-dp[a][b])>1){
                        cout << "No" << endl;
                        return 0;
                    }
                }else{
                    flag[a+i][b] = true;
                    dp[a+i][b] = c-1;
                    pq.push(MP(c-1,MP(a+i,b)));
                }
            }
            if(ok(a,b+i)){
                if(flag[a][b+i]){
                    if(abs(dp[a][b+i]-dp[a][b])>1){
                        cout << "No" << endl;
                        return 0;
                    }
                }else{
                    flag[a][b+i] = true;
                    dp[a][b+i] = c-1;
                    pq.push(MP(c-1,MP(a,b+i)));
                }
            }
        }
    }
    ll sm = 0;
    rep(i,w){
        rep(j,d){
            sm += dp[i][j];
        }
    }
    cout << sm << endl;
    return 0;
}


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

namespace ABC043A
{
    class Program
    {
        static void Main(string[] args)
        {
            int N;
            int s;
            int i;

            
            N = int.Parse(Console.ReadLine());

            s = 0;

            for (i = 1; i <= N; i++)
           {
                s = s + i;
           }
                Console.WriteLine(s);

                Console.ReadKey();
            
        }
    }
}

Measured memory_bytes: 11092
N = int(input())

evidences = [[] for _ in range(N)]
for i in range(N):
    A = int(input())
    for _ in range(A):
        x, y = map(int, input().split())
        evidences[i].append((x - 1, y))

result = 0
for i in range(1, 2 ** N):
    consistent = True
    for j in range(N):
        if (i >> j) & 1 == 0:
            continue
        for x, y in evidences[j]:
            if (i >> x) & 1 != y:
                consistent = False
                break
        if not consistent:
            break
    if consistent:
        result = max(result, bin(i)[2:].count('1'))
print(result)

Measured memory_bytes: 3064
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    let n:String=read!();
    let mut n=n.chars().map(|a| a.to_digit(10).unwrap() as isize).collect_vec();
    let mut min=10000;
    for i in 0..n.len()-2 {
        if (753-(n[i]*100+n[i+1]*10+n[i+2])).abs()<min {min=(753-(n[i]*100+n[i+1]*10+n[i+2])).abs()}
    }
    println!("{}",min);
}

Measured memory_bytes: 2056
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

using ll = long long int;
using namespace std;

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

  cerr << "Answer:" << endl;
  if((B-A)%2 == 0){
    cout << (B-A)/2 << endl;
  }else{
    cout << min((A+B-1)/2, (2*N-A-B+1)/2) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
list = ['3','5','7']
cnt = 0
ok = []

X = int(input())


for a in list:
    for b in list:
        for c in list:
            ok.append(a+b+c)
            for d in list:
                ok.append(a+b+c+d)
                for e in list:
                    ok.append(a+b+c+d+e)
                    for f in list:
                        ok.append(a+b+c+d+e+f)
                        for g in list:
                            ok.append(a+b+c+d+e+f+g)
                            for h in list:
                                ok.append(a+b+c+d+e+f+g+h)
                                for i in list:
                                    ok.append(a+b+c+d+e+f+g+h+i)

all = []
for i in ok:
    if i.count("3") >= 1 and i.count("5") >= 1 and i.count("7") >= 1:
        if int(i) <= X:
            cnt += 1

print(cnt)

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

using namespace std;

const int INF = (int)1e9;

int main() {
		string S;
		cin >> S;

		int ans = INF;
		for ( int j = 0; j < 2; j++ ) {
				int cnt = 0;
				for ( int i = 0; i < S.length(); i++ ) {
						if ( (i % 2 == 0) && (S[i] != (j + '0')) ) cnt++;
						else if ( (i % 2 == 1) && (S[i] == (j + '0')) ) cnt++;
				}
				if ( ans > cnt ) ans = cnt;
		}

		cout << ans << endl;

		return 0;
}


Measured memory_bytes: 512