akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 998244353;
const int MAXN =(int) 5e5+10;
const int MAXM = (int) 3e6+10;

///--------------------START-------------------------
char a[MAXN];
int b[MAXN];
int N;
LL sum;

void work(){
    scanf("%s",a+1);
    N = strlen(a+1);
    sum = 0LL;
    if(a[1]=='<'){
        b[0]=0;
        for(int i=1;i<=N;i++){
            if(a[i]=='<'){
                b[i]=b[i-1]+1;
            }
            else{
                break;
            }
        }
    }
    if(a[N]=='>'){
        b[N]=0;
        for(int i=N;i>=1;i--){
            if(a[i]=='>'){
                b[i-1]=b[i]+1;
            }
            else{
                break;
            }
        }
    }
    for(int i=1;i<N;i++){
        if(a[i]=='>'&&a[i+1]=='<'){
            b[i]=0;
            for(int j=i-1;j>=0;j--){
                if(a[j+1]=='>'){
                    b[j]=max(b[j],b[j+1]+1);
                }
                else{
                    break;
                }
            }
            for(int j=i+1;j<=N;j++){
                if(a[j]=='<'){
                    b[j]=max(b[j],b[j-1]+1);
                }
                else{
                    break;
                }
            }
        }
    }
//    printf("%d",b[0]);
//    for(int i=1;i<=N;i++){
//        printf("%c%d",a[i],b[i]);
//    }
//    printf("\n");
    for(int i=0;i<=N;i++){
        sum += (LL)b[i];
    }
    printf("%lld\n",sum);
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}





Measured memory_bytes: 2688
#include <iostream>

using namespace std;
typedef long long ll;
ll N, b = 0, a = 0, ans = 0;

int main() {
	cin >> N;
	for(int i=0;i<N;i++) {
		cin >> a;
		ans += (b + a) >> 1;
		if(b == 1) a = a ? (b + a) % 2 : 0;
		else a %= 2;
		// cout << " " << a << " " << ans << endl;
		b = a;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
b = -2
a = []
def d(n):
    if n > 0:
        return -(-n//b)
    elif n < 0:
        return (n-1)//b
def r(n):
    if n%b < 0:
        return -(n%b)
    else:
        return n%b

while N != 0 and N != 1:
    a.append(r(N))
    N = d(N)
if N == 1:
    a.append(N)
else:
    a.append(0)

a.reverse()
ans = "".join(map(str,a))
print(ans)

Measured memory_bytes: 38384
while True:
    try:
        lst = list(map(float, input().split(',')))
        xa, ya = lst[0], lst[1]
        xb, yb = lst[2], lst[3]
        xc, yc = lst[4], lst[5]
        xd, yd = lst[6], lst[7]

        ans1 = ((yc - ya)*xb - (xc - xa)*yb + (xc * ya - xa * yc))
        ans2 = ((yc - ya)*xd - (xc - xa)*yd + (xc * ya - xa * yc))
        ans3 = ((yb - yd)*xa - (xb - xd)*ya + (xb * yd - xd * yb))
        ans4 = ((yb - yd)*xc - (xb - xd)*yc + (xb * yd - xd * yb))

        if ans1*ans2 > 0 or ans3*ans4 > 0:
            print("NO")

        else:
            print("YES")

    except EOFError:
        break


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

int main(){
    int n;
    cin >> n;
    int ans = 0;
    int maxh = 0;
    for(int i=0;i<n;i++){
        int h;
        cin >> h;
        maxh = max(maxh,h);
        if(maxh == h){
            ans ++;
        } 
    }
    cout << ans << endl;
}

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

namespace kakomon
{
    class Program
    {
        static void Main(string[] args)
        {
            abc082_b();
        }

        static void abc082_b()
        {
            // B - Two Anagrams
            string s = Console.ReadLine().Trim();
            string t = Console.ReadLine().Trim();
            // 1文字ずつバラしてソートする、tは逆順(最も遅くなるように)
            char[] s_arr = s.ToCharArray();
            char[] t_arr = t.ToCharArray();
            Array.Sort(s_arr);
            Array.Sort(t_arr);
            Array.Reverse(t_arr);
            // 1つの単語に合体する
            string s_asc = String.Join("", s_arr);
            string t_desc = String.Join("", t_arr);
            //Console.WriteLine(String.Format("{0} {1}", s_asc, t_desc));
            // CompareTo の戻り値 < 0 なら、比較対象よりも前方(早い)
            string ans;
            if (s_asc.CompareTo(t_desc) < 0) ans = "Yes";
            else ans = "No";
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13408
#include<bits/stdc++.h>
using namespace std;
 
int main () {
  int a,b,m;
  cin >>a>>b>>m;
  vector<int>an(a);
  vector<int>bn(b);
  int amin =1010010;
  int bmin =1010010;
  int ansA =0;
  int ansB =0;
  for (int i=0;i<a;i++){
    cin >>an[i];
    amin =min(amin,an[i]);
  }
  for (int i=0;i<b;i++){
    cin>>bn[i];
    bmin =min(bmin,bn[i]);
  }
  ansA =amin+bmin;
 
  int cnt =0;
  int pmax =0;
 
  vector<vector<int>> mn(m, vector<int>(3));
 
  for(int i=0;i<m;i++){
    for(int j=0;j<3;j++){
      cin>>mn.at(i).at(j);
    }
  }
  for (int i=0;i<m;i++){
    ansA =min(ansA,an[mn[i][0]-1]+bn[mn[i][1]-1]-mn[i][2]);
  }
  cout <<ansA<<endl;
return 0;
}

Measured memory_bytes: 7680
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var n = IO.RInt;
            var list = new List<int[]>();
            for (int i = 0; i < n; i++)
            {
                var txy = IO.RSInt;
                list.Add(txy);
            }

            var pre_t = 0;
            var pre_x = 0;
            var pre_y = 0;
            for (int i = 0; i < n; i++)
            {
                var t = list[i][0];
                var x = list[i][1];
                var y = list[i][2];

                var span_t = t - pre_t;
                pre_t = t;
                var span_x = Abs(x - pre_x);
                pre_x = x;
                var span_y = Abs(y - pre_y);
                pre_y = y;

                var dis = span_x + span_y;

                if (dis > span_t)
                {
                    WriteLine("No");
                    return;
                }

                if ((span_t - dis) % 2 != 0)
                {
                    WriteLine("No");
                    return;
                }
            }
            WriteLine("Yes");
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

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

int main()
{

  string S;
  cin >> S;

  int cnt = 0;

  if (S[0] == 'A')
  {
    cnt++;
  }
  else
  {
    cout << "WA" << endl;
    exit(0);
  }

  int first_idx = 2, second_idx = S.size() - 2;
  int idx;
  for (int p = 0; p < S.size(); p++)
  {
    idx = S.find('C');
    if (idx <= first_idx & second_idx <= idx)
    {
      cnt++;
    }
    else if (idx <= second_idx & first_idx <= idx)
    {
      cnt++;
    } else {
      break;
    }
    S.erase(idx, 1);
  }

  if (cnt > 2 || cnt == 1)
  {
    cout << "WA" << endl;
    exit(0);
  }

  S.erase(0, 1);

  for (int i = 0; i < S.size(); i++) {
    if (islower(S[i])){
      cnt++;
    } else {
      cout << "WA"<< endl;
      exit(0);
    }
  }

  cout << "AC" << endl;

  return 0;
}

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

int main() {
	int N, L;
	cin >> N >> L;
	vector<string> S(N);
	for (int i = 0; i < N; ++i) {
		cin >> S[i];
	}
	sort(S.begin(), S.end());
	string ansS;
	for (int i = 0; i < N; ++i) {
		ansS += S[i];
	}
	cout << ansS << endl;
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N; cin >> N;

    map<string,int> mp;

    int max_cnt = 0;
    for(int i=0; i<N; i++){
        string S; cin >> S;
        mp[S] = mp[S]+1;
        if(mp[S] > max_cnt){
            max_cnt = mp[S];
        }
    }
    
    for(auto it = mp.begin(); it != mp.end(); it++){
        if(it->second == max_cnt){
            cout << it->first << endl;
        }
    }
}

Measured memory_bytes: 25216
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;


signed main(){

    int s;
    int hour, min, second;

    std::cin >> s;

    hour = s / 3600;
    min = (s - 3600 * hour) / 60;
    second = (s - 3600 * hour - min * 60); 

    std::cout << hour << ":" << min << ":" << second << std::endl;

    return 0;

}


Measured memory_bytes: 3080
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S):
    W = ['Sunny', 'Cloudy','Rainy']
    for i, w in enumerate(W):
        if w == S:
            return W[(i+1)%len(W)]


def main():
    S = read_str()
    print(slv(S))


if __name__ == '__main__':
    main()


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

const int INF=123456789;

int n,m;
int R;
int z[1001];

int ld[200][200],sd[200][200];

vector<int> island[200];
int island_idx;
int island_id[200];

ll dp[1001][200];

void init()
{
    fill(ld[0],ld[200],INF);
    fill(sd[0],sd[200],INF);
    rep(i,200) island[i].clear();
    island_idx=0;
    fill(island_id,island_id+200,-1);
    fill(dp[0],dp[1001],10000LL*INF);
}


int main()
{
    while(scanf(" %d %d",&n,&m),n)
    {
        init();

        // input
        rep(i,m)
        {
            int x,y,t;
            char sl;
            scanf(" %d %d %d %c",&x,&y,&t,&sl);
            --x;
            --y;
            if(sl=='L') ld[x][y]=ld[y][x]=min(ld[x][y],t);
            else sd[x][y]=sd[y][x]=min(sd[x][y],t);
        }
        scanf(" %d",&R);
        rep(i,R)
        {
            scanf(" %d",&z[i]);
            --z[i];
        }

        // Warshall-Floyd
        rep(i,n)
        {
            ld[i][i]=0;
            sd[i][i]=0;
        }
        rep(k,n)rep(i,n)rep(j,n)
        {
            ld[i][j]=min(ld[i][j],ld[i][k]+ld[k][j]);
            sd[i][j]=min(sd[i][j],sd[i][k]+sd[k][j]);
        }

        // determine the island i-th town belongs
        rep(i,n)
        {
            if(island_id[i]!=-1) continue;

            island_id[i]=island_idx;
            rep(j,n) if(ld[i][j]<INF) island_id[j]=island_idx;

            ++island_idx;
        }
        rep(i,n) island[island_id[i]].pb(i);

        // calc ans
        dp[0][z[0]]=0;
        for(int i=1; i<R; ++i)
        {
            int p_id=island_id[z[i-1]], c_id=island_id[z[i]];
            if(p_id==c_id)
            {
                rep(j,island[p_id].size())
                {
                    int boat=island[p_id][j];
                    dp[i][boat] = min(dp[i][boat], dp[i-1][boat]+ld[z[i-1]][z[i]]);
                }
            }
            rep(j,island[p_id].size())rep(k,island[c_id].size())
            {
                int now_b=island[p_id][j], nx_b=island[c_id][k];
                dp[i][nx_b] = min(dp[i][nx_b], dp[i-1][now_b]+ld[z[i-1]][now_b]+sd[now_b][nx_b]+ld[nx_b][z[i]]);
            }
        }

        ll ans=10000LL*INF;
        rep(i,n) ans=min(ans,dp[R-1][i]);
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 5104
import java.util.*;

class Main {
    final Scanner sc = new Scanner(System.in);

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

    private void run() {
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n];

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt() - 1;
        }

        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
        }

        for (int i = 0; i < n - 1; i++) {
            c[i] = sc.nextInt();
        }

        int ans = 0;
        for (int i = 0; i < n; i++) {
            ans += b[a[i]];

            if (i > 0 && a[i] - a[i - 1] == 1) {
                ans += c[a[i - 1]];
            }
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 22228
R, C, K = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(K)]

items = [[0] * (C + 1) for _ in range(R + 1)]
for r, c, v in X:
    items[r][c] = v

dp = [[0] * 4 for _ in range(C + 1)]
for i in range(1, R + 1):
    # Vertical transition
    for j in range(1, C + 1):
        dp[j][0] = max(dp[j])
        for k in range(1, 4):
            dp[j][k] = 0

    # Horizontal or picking-up transition
    for j in range(1, C + 1):
        for k in reversed(range(4)):
            dp[j][k] = max(dp[j][k], dp[j - 1][k])
            if items[i][j] and k < 3:
                dp[j][k + 1] = max(dp[j][k + 1], dp[j][k] + items[i][j])

print(max(dp[-1]))


Measured memory_bytes: 179140
#include<iostream>
using namespace std;
int main(void) {
	char a[4],x;
	bool r = true;
	for (int i = 0; i < 4; i++)
		cin >> a[i];
	x = a[0];
	for (int i = 1; i < 4; i++) {
		if (x == a[i]) {
			r = false;
			break;
		}
		else {
			x = a[i];
			continue;
		}
	}
	cout << (r ? "Good" : "Bad") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    priority_queue<ll> q;
    vector<ll> f(n);




    vector<ll> fa(n);
    rep(i,n){cin>>a[i];}
    rep(i,n){cin>>f[i];}

    sort(a.rbegin(),a.rend());
    sort(f.begin(),f.end());
    rep(i,n){fa[i]=a[i]*f[i];}

    ll up = 1000000000001;
    ll down = 0;
    int nibu = 0;


    while(nibu<100){
        ll kk =0;
       // cout<<up<<" "<<down<<endl;
        nibu++;
        ll med = (up+down)/2;
        bool flag= true;


       for(int j=0;j<n;j++){
            ll kai = f[j]*a[j];
            if(med<kai){
                //ll hiku = a[j]-(med/f[j]);
                ll hiku = (a[j]*f[j]-med-1)/f[j]+1;
               kk+=hiku;
               if(kk>k){
                   flag = false;
                   break;
               }
            }

        }


        if(flag){
            up = med;
        }else{

            down = med;
        }
    }
cout<<up<<endl;








    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>                                                                                                                  
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
                 
#define pb push_back
#define PII pair<int,int>
                 
#define VS vector<string>
#define VI vector<int> 
#define ll long long int
#define debug(x) cout << x << " :" <<#x << endl  
int main(void) { 
    string s;cin >> s;
    int i = s.size()-1; 
    string s1 = "dream", s2 = "dreamer", s3 = "erase", s4 = "eraser";
    bool p = true; 
    while(i > 0) {
        if(s[i] == 'm') {
            RREP(j,5) {
                if (s[i] != s1[j]) p = false;
                i--;
            }    
            if(!p) break;
        } else if(s[i] == 'e') {
            RREP(j,5) {
                if(s[i] != s3[j]) p = false;
                i--;
            }    
            if(!p) break;
        } else if(s[i] == 'r') {
            if(s[i-2] == 'm') {
                RREP(j,7) {
                    if(s[i] != s2[j]) p = false;
                    i--;
                }
            } else if(s[i-2] == 's') {
                RREP(j,6) {
                    if(s[i] != s4[j]) p = false;
                    i--;
                }
            } else {
                p = false;
            }    
            if(!p) break;
} else {
            p = false;
            break;
        }
      
    }           
    if(p) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);

int32_t main(){
	fast;
	int n;
	cin >> n;
	
	int ans = n*800 - 200*(n/15);
	cout << ans;
}



Measured memory_bytes: 256
import numpy as np
a,b,V = map(int, input().split())
x = V/(a*a)
"""
算数の解
"""
# if b >= 2*x:
#     tan = b**2/(2*a*x)
# else:
#     tan = 2*(b-x)/a
# ans = np.arctan(tan)
# print(ans*180/np.pi)


"""
二部探索
"""
def f(theta):
    if np.tan(theta) < (2*x)/a:
        l = x + a*np.tan(theta)/2
    else:
        l = (2*a*x*np.tan(theta))**0.5
    return l >= b


eps = 10**-12
def  binarySearch(l,r):
    while r - l > eps:
        mid = (l+r)/2
        if f(mid):
            r = mid
        else:
            l = mid
    return r

print(binarySearch(-1*np.pi/180,(np.pi/2-eps))*180/np.pi)


Measured memory_bytes: 12484
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vvi vector<vector<int>>
using namespace std;

class miniUnionFind {
private:
	vector <vector<int>> Graph; // {Value,ParentID, isMarked}
public:
	void push(int x) {
		Graph.push_back({ x,x,false });
	}
	int search(int x) {
		int nextnode =x;
		while (Graph[nextnode][1] != nextnode) {
			if (Graph[nextnode][2] == true) break;
			nextnode = Graph[nextnode][1];
		}

		return nextnode;
	}
	void setparent(int u, int parent) {
		Graph[u][1] = parent;
	}

	void mark(int u) {
		Graph[u][2] = true;
	}
};
void subfunc(int N,int Q) {
	miniUnionFind muf;
	for (int i = 0; i < N; i++) {
		muf.push(i);
	}
	for (int i = 1; i < N; i++) {
		int m; cin >> m; m--;
		muf.setparent(i, m);
	}
	ll ans = 0;

	for (int times = 0; times < Q; times++) {
		char c; cin >> c;
		int q; cin >> q;
		if (c == '0' and q == 0) break;
		q--;
		if (c == 'Q') {
			ans += muf.search(q) + 1;
		}
		else {
			muf.mark(q);
		}
	}

	cout << ans << endl;
}
int main() {
	int N,Q; cin >> N >> Q;
	while (N != 0 or Q != 0) {
		subfunc(N, Q);
		cin >> N >> Q;
	}
}


Measured memory_bytes: 9824
// B.

#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int w, a, b;
	cin >> w >> a >> b;
	int p = min(a, b), q = max(a, b);
	int ans = max(0, q - (p + w));
	cout << ans << endl;
	return 0;
}


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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] AB = Console.ReadLine().Split(' ');
            ulong A = ulong.Parse(AB[0]);
            decimal B = decimal.Parse(AB[1]);
            ulong ans = (ulong)((decimal)(A * B));
            Console.WriteLine(ans);
            Console.ReadLine();
        }
    }
}


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

int main()
{
	int n;
	cin >> n;
	vector<vector<int>> a(n, vector<int>(3));
	for (int q = 0; q < n; q++)
	{
		for (int w = 0; w < 3; w++)
		{
			cin >> a[q][w];
		}
	}
	vector<vector<int>> dp(n, vector<int>(3));
	for (int q = 0; q < 3; q++)
	{
		dp[0][q] = a[0][q];
	}
	for (int q = 1; q < n; q++)
	{
		for (int w = 0; w < 3; w++)
		{
			dp[q][w] = 0;
			for (int e = 0; e < 3; e++)
			{
				if (w != e)
				{
					dp[q][w] = max(dp[q][w], dp[q-1][e]);
				}
			}
			dp[q][w] += a[q][w];
		}
	}
	cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << "\n";
	return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string disp(bool x){
    return x ? "Yes" : "No";
}

int main(){
    int n;
    cin >> n;
    
    for(int i = 0; 4*i <= n ; i++){
        for(int j=0; (4*i)+(j*7)<= n;j++){
            if((4*i)+(7*j) == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}
    
    






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

namespace ConsoleApp44 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            Array.Sort(st);

            int A = st[0];
            int B = st[1];
            int C = st[2];

            if (A == 5 && B == 5 && C == 7) {
                Console.WriteLine("YES");
            } else {
                Console.WriteLine("NO");
            }

        }
    }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
#include <string>
#include <cmath>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<ll> vll;
 
#define all(v) v.begin(),v.end()
#define test() int t;cin>>t;while(t--) 
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int mod = 1e9+7;

vpii prime_fact;
vi store;

ll power(ll x, ll a)
{
    if(a==0)return(1);
    ll z = power(x, a/2);
    z=(z*z)%mod;
    if(a%2)z=(z*x)%mod;
    return(z);
}
 
int main()
{   
    fastio
    int n;
    cin>>n;
    vll arr(n+1);
    ll sq_sum=0, total_sq=0;
    for (int i = 1; i <= n; i++)
    {
        cin>>arr[i];
        sq_sum+=(arr[i]*arr[i]);
        sq_sum%=mod;
        total_sq+=arr[i];
        total_sq%=mod;
    }
    total_sq*=total_sq;
    total_sq%=mod;
    if(total_sq<sq_sum)total_sq+=mod;
    cout<<((total_sq-sq_sum)*power(2, (ll) mod-2))%mod<<endl;
}

Measured memory_bytes: 4784
N = int(input())
A = sorted(list(map(int,input().split())))
lim = max(A)
B = [0] * (lim+1)
for i in range(N):
    B[A[i]] += 1
ans = N
for i in range(1,lim+1):
    if B[i] == 0:
        continue
    if B[i] >= 2:
        ans -= B[i]
        B[i] = 0
    for j in range(i*2,lim+1,i):
        ans -= B[j]
        B[j] = 0

print(ans)


Measured memory_bytes: 32280
#include <bits/stdc++.h>
#include <vector>
#include <string>
using namespace std;
#define FL(i,a,b) for(int i = a;i<b;i++)
typedef vector<int> vi;

int inf = numeric_limits<int>::max();

int main(){
    string s,t;
    cin>>s>>t;
    int a = s.size();
    int b = t.size();

    int arr[a+1][b+1] = { };
    int keep[a+1][b+1] = { };

    for(int i = 1;i<a+1;i++){
        for(int j = 1;j<=b;j++){
            int cost = 0;
            if(s[i-1]==t[j-1]){
                cost = 1;
            }
            if(arr[i-1][j]>arr[i][j-1]){
                arr[i][j] = arr[i-1][j];
                keep[i][j] = 1;
            }
            else{
                arr[i][j] = arr[i][j-1];
                keep[i][j] = 2;
            }
            if(arr[i][j]<(arr[i-1][j-1]+cost)){
                arr[i][j] = arr[i-1][j-1] + cost;
                keep[i][j] = 3;
            }
        }
    }

    /*FL(i,0,a+1){
        FL(j,0,b+1){
            cout<<arr[i][j]<<" ";
        }
        cout<<"\n";
    }
    cout<<endl;
    FL(i,0,a+1){
        FL(j,0,b+1){
            cout<<keep[i][j]<<" ";
        }
        cout<<"\n";
    }*/
    string m = "";
    int i = a;
    int j = b;
    while(i!=0 && j!=0){
        if(keep[i][j]==1){
            i--;
        }
        else if(keep[i][j]==2){
            j--;
        }
        else{
            m = s[i-1] + m;
            i--;j--;
        }
    }
    cout<<m;

}


















Measured memory_bytes: 70656
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll N;
  cin >> N;
  vector<ll> abc(5);
  ll abc_min;
  for (int i = 0; i < 5; ++i) {
    cin >> abc[i];
    if (i == 0) {
      abc_min = abc[0];
    } else {
      abc_min = min(abc_min, abc[i]);
    }
  }
  if (abc_min >= N) {
    cout << 5 << endl;
    return 0;
  }
  if (N % abc_min == 0) {
    cout << N / abc_min + 4 << endl;
  } else {
    cout << N / abc_min + 5 << endl;
  }
  return 0;
}


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

using namespace std;

int main()
{
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector <int >p(a);
    for(int i=0;i<a;i++){
        cin >> p[i];
    }
    vector< int > q(b);
    for(int i=0;i<b;i++){
        cin >> q[i];
    }
    vector<int > r(c);
    for(int i=0;i<c;i++){
        cin >> r[i];
    }
    sort(p.rbegin(),p.rend());
    sort(q.rbegin(),q.rend());
    for(int i=x;i<a;i++){
        p.pop_back();
    }
    for(int i=y;i<b;i++){
        q.pop_back();
    }
    for(int x:p){
        r.push_back(x);
    }
    for(int x:q){
        r.push_back(x);
    }
    sort(r.rbegin(),r.rend());
    long long ans =0;
    for(int i=0;i<x+y;i++){
        ans+=r[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2552
import math

N , K = map(int,input().split())

count = 0
now = K

while now > N :
    count += 1
    now = now / 2.

prob = 0

for i in range(1,N+1) :
    if i < now :
        for k in range(N) :
            if i * 2**k >= now :
                break
        prob += 2**(-(count + k )) / N
    else :
        prob += 2**(-count) / N

print(prob)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main(void)
{
	int N, A, B, charge;

	cin >> N >> A >> B;
	charge = N * A;
	if (charge < B)
    {
      cout << charge << endl;
    }
	else
    {
      cout << B << endl;
    }
  return (0);
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstdlib>

int main()
{
  int n;
  char lf;
  std::cin >> n;
  int rcnt = 0;
  int bcnt = 0;
  for (int i = 0; i < n; i++) {
    char ch;
    std::cin >> ch;
    switch (ch) {
      case 'R':
        rcnt++;
        break;
      case 'B':
        bcnt++;
        break;
      default:
        std::cerr << "Unknown char found '" << ch << "'\n";
        exit(1);
    }
  }
  if (rcnt > bcnt) {
    std::cout << "Yes\n";
  } else {
    std::cout << "No\n";
  }
  return 0;
}


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

void solve()
{
    int n,k;
    cin>>n>>k;
    int w[n],v[n];
    for(int i=0; i<n; i++){
        cin>>w[i]>>v[i];
    }
    int dp[100001][n+1];//min weight to get v using n item
    for(int i=0; i<=(1000*n); i++){
        for(int j=0; j<=n; j++){
            if(i==0){
                dp[i][j]=0;
                continue;
            }
            if(j==0){
                dp[i][j]=1e9+1;
                continue;
            }
            int in=1e9+1,ex=1e9+1;
            if(i-v[j-1]>=0){
                in=w[j-1]+dp[i-v[j-1]][j-1];
            }
            ex=dp[i][j-1];
            dp[i][j]=min(in,ex);
        }
    }
    int ans=INT_MIN;
    for(int i=0; i<=(1000*n); i++){
        for(int j=0; j<=n; j++){
            if(dp[i][j]<=k){
                ans=max(ans,i);
            }
        }cout<<endl;
    }
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    while(t--){
        solve();
        cout<<endl;
    }
}


Measured memory_bytes: 43088
import java.util.*;

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

        if (a > k) {
            System.out.println(a-k+" "+b);
        } else {
            // a 終わりc
            long c = k-a;
            if (c > b) {
                System.out.println("0 0");
            } else {
                System.out.println("0 " + (b - c));
            }
        }


    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <stdio.h>

using namespace std;

void solve()
{
	int price, num;
	int sum = 0, count = 0, items = 0;
	while(scanf("%d,%d", &price, &num) != EOF)
	{
		++count;
		items += num;
		sum += price * num;
	}
	cout << sum << endl;
	cout << (int)(items / (double)count + 0.5) << endl;
}

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

Measured memory_bytes: 1204
H,W,D=map(int,input().split())
L=["*"]*(H*W)

for y in range(H):
    B=list(map(int,input().split()))
    for x in range(W):
        L[B[x]-1]=(x,y)

G=[[0]*((H*W+D-1)//D) for _ in range(D)]

for i in range(H*W-D):
    (X1,Y1)=L[i]
    (X2,Y2)=L[i+D]

    p,q=i//D,i%D
    G[q][p+1]=G[q][p]+abs(X1-X2)+abs(Y1-Y2)

Q=int(input())
X=[0]*Q

for k in range(Q):
    L,R=map(int,input().split())
    L,R=L-1,R-1

    p,r=L//D,L%D
    q=R//D
    X[k]=G[r][q]-G[r][p]

print("\n".join(map(str,X)))


Measured memory_bytes: 99412
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=1e9+7;
const llint big=1e15+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
int main(void){
	int n,a,b,i,ans=0;cin>>n>>a>>b;
	for(int i=1;i<=n;i++){
		int gen=0,ke=i;
		while(ke>0){gen+=ke%10;ke/=10;}
		if(a<=gen&&gen<=b){ans+=i;}
	}
	cout<<ans<<endl;
	RE;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define erep(i, a, b) for (int i = a; i <= (int)(b); ++i)
#define per(i, a, b) for (int i = (b); i > (a); --i)
#define eper(i, a, b) for (int i = ((int)(a)); i >= b; --i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

static const int MAX_PRIME = 1000005;
bool is_prime[MAX_PRIME];
int primes[MAX_PRIME], prime_cnt;
void make_prime()
{
    rep(i, 0, MAX_PRIME) is_prime[i] = true;
    is_prime[0] = false;
    is_prime[1] = false;
    rep(i, 2, MAX_PRIME)
    {
        if (is_prime[i])
            primes[prime_cnt++] = i;
        rep(j, 2 * i, j += i) is_prime[j] = false;
    }
}

bool isPrime(int x)
{
    if (x < 2)
        return false;
    else if (x == 2)
        return true;
    else if (x % 2 == 0)
        return false;

    double sq = sqrt(x);
    for (int i = 3; i <= sq; i += 2)
    {
        if (x % i == 0)
        {
            return false;
        }
    }
    return true;
};

const int N_MAX = 100005;
int q, sum[N_MAX];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    make_prime();
    rep(i, 3, N_MAX) {
        if (isPrime(i) && isPrime((i+2)/2)) {
            sum[i]++;
        }
    }
    int cnt = 0;
    rep(i, 3, N_MAX) {
        sum[i] += sum[i-1];
    }
    cin >> q;
    rep(i, 0, q) {
        int l, r, ans = 0;
        cin >> l >> r;
        ans = sum[r] - sum[l-1];
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 5888
import sys,queue,math,copy,itertools
from fractions import gcd
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in input().split()]
N,A = LI()
_LI = lambda : [int(x)-A for x in input().split()]
X = _LI()

m = [0 for _ in range(50*N)]
Base = 25 * N

for i in range(N):
    m2 = copy.copy(m)
    for j in range(len(m)):
        if m[j]:
            if 0<= j + X[i] < len(m2):
                m2[j+X[i]] += m[j]
    m = m2
    m[X[i] + Base] += 1
print (m[Base])

Measured memory_bytes: 62828
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
#define MOD2 (998244353)
#define MOD3 (1000000009)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("in.txt");ofstream coutt("out.txt");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a-1)/b+1;}
//Read:
//Use __builtin_popcountll for ll

int n,s,p2;
int v[3005],two[3005],dp[3005][3005];
int f(int i,int sum){
    if(sum==s){
        return two[n];
    }
    if(sum>s || i>n)return 0;
    int &ans=dp[i][sum];
    if(ans!=-INF)return ans;
    
    ans=f(i+1,sum+v[i])*p2%MOD2;
    ans=(ans+f(i+1,sum))%MOD2;
    return ans;
}

signed main(){
    two[0]=1;
    p2=poww(2,MOD2-2,MOD2);
    for(int i=1;i<=3004;i++)two[i]=two[i-1]*2%MOD2;
    for(int i=0;i<3005;i++)for(int j=0;j<3005;j++)dp[i][j]=-INF;
    cin>>n>>s;
    for(int i=1;i<=n;i++)cin>>v[i];
    cout<<f(1,0);
}


Measured memory_bytes: 74424
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef unsigned long long ull;

const int MOD = 1000000007 ; //  , 1000000009 , 1000000023 ,998244353
const ll INF = ll(1e18);
const ld PI = 4*atan((ld)1);

ll power(ll x,ll n) {
  ll result=1;
  while(n>0){
    if(n&1)result = ((result%MOD) * (x%MOD))%MOD;
    result %= MOD;
    x=((x%MOD)*(x%MOD))%MOD;
    x %= MOD;
    n >>= 1;
  }
  return result;
}
ll gcd(ll a,ll b){
  if(a==0)return b;
  return gcd(b%a,a);
}


int main() {
  #ifdef AVI  
    freopen("input.txt" , "r" , stdin);
  #endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  
  ll n;
  cin >> n;
  vector<ll>div;
  for(ll i=1 ; i*i<=n ; i++){
    if(n%i==0){
      div.push_back(i);
      if(n/i!=i)div.push_back(n/i);
    }
  }
  ll res = INF;
  for(ll i=0 ; i<div.size() ; i++){
    for(ll j=0 ; j<div.size() ; j++){
      if(div[i]*div[j]==n)res = min(res , div[i]+div[j]-2);
    }
  }
  cout << res;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll mod = 1e9 + 7;

int main()
{
    ll S;
    cin>>S;
    
    ll dp[S+1];
    dp[1] = 0; dp[2] = 0;
    dp[3] = 1;
    for (int i=4; i<=S; i++) {
        dp[i] = 1;
        for (int j = 3; j<i; j++) {
            dp[i] += dp[i-j];
            dp[i] %= mod;
        }
    }
    cout << dp[S] << '\n';
    return 0;
}

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

int main() {
	int loop = 0;
	cin >> loop;

	int customers = 0;

	for (int i = 0; i < loop; i++){
		int start, end;
		cin >> start >> end;

		customers += (end - start) + 1;
	}

	cout << customers << endl;
}

Measured memory_bytes: 256
/*
      author : nishi5451
      created: 11.08.2020 23:11:47
*/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;


int main(){
    int r;
    cin >> r;
    printf("%.12lf\n",2.0*r*M_PI);
    return 0;
}

Measured memory_bytes: 3720
n, m = map(int, input().split())
d = [[] for _ in range(n)]
for i in range(m):
    p, y = map(int, input().split())
    d[p-1].append((y, i))
d = list(map(sorted, d))
ans = [0] * m
for p in range(n):
    for x, (y, i) in enumerate(d[p], 1):
        ans[i] = (p + 1) * 10 ** 6 + x
for a in ans:
    print(str(a + 10 ** 12)[1:])


Measured memory_bytes: 39144
#n=int(input())
a,b=map(str,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

a=int(a)
b=int(b[0]+b[2]+b[3])

ans=(a*b)//100

print(ans)


Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,k;
  cin >> a >> b >> c;
  cin >> k;
  int cnt=0;
  const int row1[3] = {a,b,c};
  for(int i=0;i<k;i++){
    int row2[3]={};
    row2[0] = row1[0];
    row2[1] = row1[1];
    row2[2] = row1[2];

    for(int j=0;j<k-i;j++){
      row2[2] *= 2;
    }
    for(int j=0;j<i;j++){
      row2[1] *= 2;
    }
    if(row2[2] > row2[1] && row2[1] > row2[0]){
      cnt+=1;
      break;
    }
  }
  if(cnt>0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3624
import itertools
op = ["+", "-"]
s = input()
for i in itertools.product(op, repeat=3):
    t = 0
    t += int(s[0])
    t += int(s[1]) * (1 if i[0] == "+" else -1)
    t += int(s[2]) * (1 if i[1] == "+" else -1)
    t += int(s[3]) * (1 if i[2] == "+" else -1)
    if t == 7:
        print(s[0] + i[0] + s[1] + i[1] + s[2] + i[2] + s[3] + "=7")
        exit()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int ma=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    ma=max(ma,a[i]);
  }
  int c,mi=1000000001;
  for(int i=0;i<n;i++){
    if(ma!=a[i]&&mi>abs(a[i]-(ma+1)/2)){
      mi=abs(a[i]-(ma+1)/2);
      c=a[i];
    }
  }
  cout << ma << " " << c << endl;
}

Measured memory_bytes: 768
def main():
    A = int(input())
    B = int(input())
    C = int(input())
    D = int(input())
    E = int(input())

    time_list = [A, B, C, D, E]

    min_one = 10
    min_in = -1
    for i, val in enumerate(time_list):
        # 1桁目をミル
        un_one = val % 10
        if min_one > un_one and un_one != 0:
            min_one = un_one
            min_in = i

    res_list = []
    for i, val in enumerate(time_list):
        if i == min_in:
            res_list.append(val)
        else:
            dif = val % 10
            if dif == 0:
                res_list.append(val)
            else:
                res_list.append(val - dif + 10)
    res_sum = 0
    for v in res_list:
        res_sum += v

    print(res_sum)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int s[] = new int[n+1];

		int cnt = 0;
		for(int i = 0; i < n; i++) {
			int val = Integer.parseInt(sc.next());
			if(val > n) {
				cnt++;
				continue;
			}

			s[val]++;
		}
		int sum = cnt;
		for(int i = 0; i < 100000; i++) {
			if(s[i] < i) {
				cnt += s[i];
			} else if(s[i] > i) {
				cnt += s[i] - i;
			}
			sum += s[i];

			if(n - sum < i) {
				cnt += n - sum;
				break;
			}
		}
		System.out.println(cnt);
		sc.close();
	}

}


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

int a[100005];
int main()
{
    int n,x;
    while(cin >> n >> x)
    {
        ll sum = 0;
        int tmp;
        for(int i = 0;i < n;i++)
        cin >> a[i];
        for(int i = 0;i < n;i++)
        {
            if(i == 0 && a[i] > x)
            {
                tmp = a[i];
                a[i] = x;
                sum += (tmp - x);
            }
            if(a[i] + a[i - 1] > x)
            {
                tmp = a[i];
                a[i] = x - a[i - 1];
                sum += (tmp - a[i]);
            }
        }
        cout << sum << endl;
    }

	return 0;
}


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

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

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;
//#define DEBUG(x) ;

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

ll N;
vector<vector<ll>> G;
ll seen[1000*1000];
ll dist[1000*1000];

ll dfs(ll n)
{
	if (seen[n] == 2) return dist[n];
	seen[n] = 1;
	for (auto nv : G[n])
	{
		if (seen[nv] == 1)
		{
			std::cout << -1 << std::endl;
			exit(0);
		}

		dist[n] = max(dist[n], dfs(nv) + 1);
	}

	seen[n] = 2;
	return dist[n];
}

int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll N; cin >> N;
	G.resize(N*N);

	auto f = [](ll i, ll j) -> ll
			 {
				 if (i < j) swap(i, j);
				 return i*(i-1)/2 + j + 1;
			 };

	REP(i, N)
	{
		ll pre{0};
		REP(j, N-1)
		{
			ll a; cin >> a;
			--a;
			ll now = f(i, a);
			G[pre].push_back(now);
			pre = now;
		}
	}

	std::cout << dfs(0) << std::endl;
	
	return 0;
}


Measured memory_bytes: 50164
#include <bits/stdc++.h>
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nuintptr)
	
using namespace std;


typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

 
const ll MAX = 2e5+10;
const ll inf = 1e9+10;



int main(){
	fastio;
	ll a,b,v,w,t;
	cin>>a>>v>>b>>w>>t;
	if( t*(v-w) >= abs(a-b) ) cout<<"YES\n";
	else cout<<"NO\n";

}	

Measured memory_bytes: 3652
k = int(input())

l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(l[k-1])

Measured memory_bytes: 3060