akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)

int main(void){
    int n, i;
    long long int p, q;
    map<int, long long int> emp;
    vector<int> seq;
    while(cin >> n && n) {
        bool isExist = false;
        emp.clear();
        seq.clear();
        rep(l, n) {
            cin >> i >> p >> q;
            if(!emp[i]) seq.push_back(i);
            emp[i]+=p*q;
        }
        rep(i, seq.size()) {
            if(emp[seq[i]] >= 1000000) {
                cout << seq[i] << endl;
                isExist = true;
            }
        }
        if(!isExist) cout << "NA" << endl;
    }
}

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


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

    long ans1 = 0;
    long ans2 = 0;
    long ans;

    // S = 010101010...に直す場合
    for (long i = 0; i < S.size(); i++) {
        if (i % 2 == 0) {
            if (S[i] == '1') {
                ans1++;
            }
        }
        else {
            if (S[i] == '0') {
                ans1++;
            }
        }
    }

    // S = 10101001...に直す場合
    for (long i = 0; i < S.size(); i++) {
        if (i % 2 == 0) {
            if (S[i] == '0') {
                ans2++;
            }
        }
        else {
            if (S[i] == '1') {
                ans2++;
            }
        }
    }

    ans = min(ans1, ans2);

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


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

#ifdef LOCAL
	#define D(a) cerr << #a << " = " << a << endl
#else
	#define D(a)
	#define cerr false && cerr
#endif
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) dforsn(i,0,n)
#define forn(i,n) forsn(i,0,n)
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first
#define endl '\n'
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

int main() {
	fastio;
	
    int n; cin >> n;
    vi a[3];
    forn(i,3) a[i].resize(n);
    forn(i,n) forn(j,3) cin >> a[j][i];  
	
    dforn(i,n-1) forn(j,3){
        int m = a[j][i]; 
        forn(k,3) if(j != k)
            m = max(m,a[j][i]+a[k][i+1]);
        a[j][i] = m; 
    } 
    int res = 0;
    forn(i,3) res = max(res,a[i][0]);
    cout << res << endl;
	return 0;
}


Measured memory_bytes: 1408
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scanf("%d", &N)

	p := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &p[i])
	}

	cnt := 1
	min := p[0]
	for i := 1; i < N; i++ {
		if min > p[i] {
			min = p[i]
			cnt++
		}
	}

	fmt.Println(cnt)
}


Measured memory_bytes: 6400
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using static Scanner;
using static System.Math;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Solve();
        Console.Out.Flush();
    }
    static void Solve() {
        var S = Scan().AsSpan();
        var list = new List<string>();
        while (S.IndexOf("><") != -1) {
            list.Add(S[..(S.IndexOf("><") + 1)].ToString());
            S = S[(S.IndexOf("><") + 1)..];
        }
        list.Add(S.ToString());
        long answer = 0;
        foreach (var str in list) {
            long lt = str.Length - str.Replace("<", "").Length;
            long gt = str.Length - str.Replace(">", "").Length;
            var max = Max(lt, gt);
            answer += max + lt * (lt - 1) / 2 + gt * (gt - 1) / 2;
        }
        Console.WriteLine(answer);
    }
}

public static class Scanner
{
    static readonly Stream stdin = Console.OpenStandardInput();
    static readonly byte[] buffer = new byte[1024];
    static int length, p;
    static bool isEof;
    private static byte StdIn() {
        if (isEof) return 0;
        if (p < length) return buffer[p++];
        p = 0;
        if ((length = stdin.Read(buffer, 0, 1024)) > 0) return buffer[p++];
        isEof = true;
        return 0;
    }
    public static char GetChar() {
        var by = StdIn();
        while ((by < '!' || '~' < by) && !isEof) by = StdIn();
        return (char) by;
    }
    public static string Scan() {
        var sb = new StringBuilder();
        for (var ch = GetChar(); '!' <= ch && ch <= '~'; ch = (char) StdIn()) {
            sb.Append(ch);
        }
        return sb.ToString();
    }
}

Measured memory_bytes: 39004
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>

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

using namespace std;
using ll = long long;
using P = pair<int, int>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9+7;
ll INF = 1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, k;
    cin >> n >> k;
    vector<ll> v(n);
    REP(i,n){
        cin >> v[i];
    }
    
    ll m = 0;
    
    for(int i1 = 0; i1 <= min(n,k); i1++){
        if(i1<min(n,k)-i1){continue;};
        for(int i2 = 0; i2 <= i1; i2++){
            ll sum = 0;
            vector<ll> o;
            int l=0, r=n-1;
            for(int i3 = 0; i3 < i1; i3++){
                if(i2 <= i3){
                    sum += v[l];
                    o.push_back(v[l]);
                    l++;
                }else{
                    sum += v[r];
                    o.push_back(v[r]);
                    r--;
                }
            }
            sort(o.begin(), o.end());
            for(int i3 = 0; i3 < k-i1; i3++){
                if(o[i3] < 0){
                    sum -= o[i3];
                }
            }
//            REP(i, o.size()){
//                cout << o[i] << " ";
//            }
//            cout << " = " << sum << endl;
            m = max(m, sum);
        }
    }
    cout << m << endl;
    
    return 0;
}


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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll inf = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/


const int N = 25;
int a[N], b[N], c[N];

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

    for(int i = 1;i <= n;i++) cin >> a[i];
    for(int i = 1;i <= n;i++) cin >> b[i];
    for(int i = 1;i <= n - 1;i++) cin >> c[i];

    int prev = -1;
    int ans = 0;
    for(int i = 1;i <= n;i++){
        ans += b[a[i]];
        if(prev == a[i] - 1) ans += c[a[i] - 1];
        prev = a[i];
    }
    cout << ans;
}







Measured memory_bytes: 256
n=int(input())
if n<3:print(1)
else:
    a=list(map(int,input().split()))
    ans=1
    x=a[1]
    if a[1]>a[0]:f=1
    elif a[1]<a[0]:f=-1
    elif a[1]==a[0]:f=0
    for i in range(2,n):
        y=a[i]
        if f==1 and y<x:
            ans+=1
            f=0
        elif f==-1 and y>x:
            ans+=1
            f=0
        elif f==0:
            if y>x:
                f=1
            elif y<x:
                f=-1
        x=y
    print(ans)

Measured memory_bytes: 14484
object Main extends App {
	override def main(args: Array[String]) = {
		val sc = new java.util.Scanner(System.in)
		
		var cont: Boolean = true
		while(cont){
			val d = new Datum(sc.nextInt,sc.nextInt)
			cont = d.isContinue
			if(cont){
				println(d.solve)
			}
		}
	}
	
	class Datum(val x:Int , val y:Int){
		val isContinue:Boolean = !(x == 0 && y == 0)
		
		def solve:String = Math.min(x,y) + " " + Math.max(x,y) 
		
	}
}

Measured memory_bytes: 53164
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll n;
vl a;

bool f(ll x){
	ll num=0;
	for(int i=0;i<n;i++){
		if(a[i]<n-x) continue;
		ll tmp=a[i]-n+x+1;
		num+=(tmp+n)/(n+1);
	}
	return num<=x;
}

int main(){
	cin>>n;
	a=vl(n);
	for(int i=0;i<n;i++) cin>>a[i];
	ll l=-1,r=INF;
	while(r-l>1){
		ll m=(l+r)/2;
		bool B=0;
		for(ll j=m;j>=max(m-100,0ll);j--) B|=f(j);
		if(B) r=m;
		else l=m;
	}
	cout<<r<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    string str;
    cin >> str;
    transform(str.begin(),str.end(),str.begin(),::tolower);
      
    int count=0;
    while(1){
        string tmp;
        cin>>tmp;
        if(tmp=="END_OF_TEXT") break;
        transform(tmp.begin(),tmp.end(),tmp.begin(),::tolower);
        if(str==tmp) count++;
    }
    cout <<count<<endl;
     
}


Measured memory_bytes: 3216
import java.util.*;
 
class Main {
      
    public static void main(String[] args) {
         
       Scanner cin=new Scanner(System.in);
       
       while(true) {
    	   int n=cin.nextInt(),m=cin.nextInt(),res=0;
    	   if(n==0)break;
           List<Integer> A=new ArrayList<>();
           
           for(int i=0;i<n;i++)A.add(cin.nextInt());
           
           for(int i=0;i<n-1;i++) {
        	   for(int j=i+1;j<n;j++) {
        		   
        		   int sum=A.get(i)+A.get(j);
        		   //System.out.println(sum);
        		   if(sum>res && sum<=m)res=sum;
        	   }
           }
           
           if(res!=0)System.out.println(res);
           else System.out.println("NONE");
       }
       
    }
     
 
}


Measured memory_bytes: 51908
# 桁DP

n = gets.chomp.split("").map(&:to_i)
length = n.length
# dp[上から i 桁まで][smaller]の最大値
dp = (length + 1).times.map { Array.new(2, - 1) }
# 初期化
# dp[0 桁目まで][桁は不自由]の最大値は 0
dp[0][0] = 0

# 桁数分ループする（i は遷移元の桁）
length.times do |i|
  dp_current = dp[i]
  dp_next = dp[i + 1]
  # smaller == 1 の場合、以下の桁は自由
  2.times do |smaller|
    next if dp_current[smaller] == -1
    # smaller が既に 1 の場合は 10 回ループ、0 の場合は(その桁の数字 + 1）回ループ
    limit = smaller == 1 ? 9 : n[i]
    (limit + 1).times do |d|
      # smaller == 0 且つ d == limit（上限）の時のみ、0 のまま遷移する
      next_smaller = smaller == 0 && d == limit ? 0 : 1
      sum = dp_current[smaller] + d
      dp_next[next_smaller] = sum if dp_next[next_smaller] < sum
    end
  end
end

puts dp.last.flatten.max


Measured memory_bytes: 1788
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D: We Like AGC
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;
const int MOD = 1000000007;

/* typedef */

enum { A, C, G, T };

/* global variables */

int dp[2][4][4][4];

/* subroutines */

inline void addmod(int &a, int b) { a = (a + b) % MOD; }

/* main */

/*
  AGC, GAC, ACG
  A*GC, AG*C
 */

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

  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 4; j++)
      for (int k = 0; k < 4; k++)
	dp[0][i][j][k] = 1;
  dp[0][A][G][C] = dp[0][G][A][C] = dp[0][A][C][G] = 0;

  int cur = 0, nxt = 1;
  for (int h = 3; h < n; h++) {
    memset(dp[nxt], 0, sizeof(dp[nxt]));

    for (int i = 0; i < 4; i++)
      for (int j = 0; j < 4; j++)
	for (int k = 0; k < 4; k++)
	  if (dp[cur][i][j][k] > 0)
	    for (int l = 0; l < 4; l++) {
	      if ((j == A && k == G && l == C) ||
		  (j == G && k == A && l == C) ||
		  (j == A && k == C && l == G) ||
		  (i == A && k == G && l == C) ||
		  (i == A && j == G && l == C))
		continue;
	      else
		addmod(dp[nxt][j][k][l], dp[cur][i][j][k]);
	    }

    cur ^= 1, nxt ^= 1;
  }

  int sum = 0;
  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 4; j++)
      for (int k = 0; k < 4; k++)
	addmod(sum, dp[cur][i][j][k]);
  printf("%d\n", sum);
  return 0;
}


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

typedef long long LL;
const int MAXN=1e6+5;
const int MAXM=1e5+5;
const int mod=1e9+7;
const double pi=acos(-1);

char x[MAXN];

int main(){
	scanf("%s",x+1);
	int n=strlen(x+1);
	int ans=n;
	for(int i=1;i<n;i++){
		if (x[i]==x[i+1]) continue;
		ans=min(ans,max(i,n-i));
	}
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 384
//081 B - Shift only 2017/12/10
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int n; cin >> n;
    uint64 a[n];
    rep(i ,n) cin >> a[i];
    int i=0;bool even=true;int cnt=0;
    while(true){
        while(i!=n-1){
            if(a[i]%2!=0) {even=false; break;}
            a[i]/=2;
            ++i;
        }
        if(!even) break;
        else { ++cnt; i=0; }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(a: int, b: int, c: int, d: int):
    print(max(
        max(a*c,a*d),
        max(b*c,b*d)
    ))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    c = int(next(tokens))  # type: int
    d = int(next(tokens))  # type: int
    solve(a, b, c, d)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61912
n=1<<18;L[1<<18],p;F[1<<18],X[1<<18];i;
long D[1<<20],Z[1<<20],A[1<<18],x,z;
long f(a,b,k,l,r){
	D[k]+=z=Z[k];
	Z[2*k+1]+=z;
	Z[2*k+2]+=z;
	Z[k]=0;
	return a<=l&r<=b?D[k]+(Z[k]=x):l<b&a<r?D[k]=fmax(
		f(a,b,2*k+1,l,(l+r)/2),
		f(a,b,2*k+2,(l+r)/2,r)
	):D[k];
}
main(j){
	for(gets(L);~scanf("%d%d%ld",L+j,&p,A+j);F[p]=j++)X[j]=F[p];
	//for(;i++<n;)for(f(i,i+1,0,0,n),p=F[i];p;p=X[p])x=A[p],x=f(L[p],i+1,0,0,n);
	for(;p?:(p=F[++i],f(i,i+1,0,0,n),n/i);p=X[p])x=A[p],x=f(L[p],i+1,0,0,n);
	printf("%ld",x);
}

/*
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
*/

Measured memory_bytes: 19200
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)

void printv(vector<ll> v) {
  for (ll i : v)
    cout << i << endl;
}

int main() {
	string s,t;
	cin>>s>>t;
	int l=s.length();
	string pt=t.substr(0,l);
	cout<<(s==pt ? "Yes" : "No")<<endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

ll N,M;
ll A[100010];
ll B[100010];
vector < ll > G[100010];

int main ()
{
    cin >> N >> M;
    REP(i,N) cin >> A[i] >> B[i];
    REP(i,N) G[A[i]].push_back(B[i]);

    ll ans = 0;
    priority_queue < ll > que;
    for (int i = 1; i <= M; i++) {
        for (int j = 0; j < G[i].size(); j++) {
            que.push(G[i][j]);
        }
        if (que.empty()) {
            continue;
        }
        ans += que.top();
        que.pop();
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7296
#include <iostream>
#include <sstream>
#include <string>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

ll solve(ll N, ll K) {
    if (K == 0) {
        return (N * N);
    }
    else {
        ll ans = 0;
        FOR(b, K + 1, N + 1) {
            auto start = K;
            auto len = b - K;
            auto vacant = b - len;

            while(start <= N) {
                auto end = start + len - 1;
                if (end <= N) {
                    ans += len;
                    start += len + vacant;
                }
                else {
                    ans += N - start + 1;
                    break;
                }
            }
        }
        return ans;
    }
}

int main(void)
{
    cin.sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    cout << solve(N, K) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define stop char nyaa;cin>>nyaa;

void solve() {
	int n;
	cin >> n;
	vector<pair<double, int>> v(n);
	rep(i, n) {
		cin >> v[i].first;
		v[i].second = i;
	}
	sort(v.begin(), v.end());
	vector<int> ans(n);
	rep(i, n) {
		int low = lower_bound(v.begin(), v.end(), pair<double, int>(v[i].first,-1)) - v.begin();
		int upp = upper_bound(v.begin(), v.end(), pair<double, int>(v[i].first,100000)) - v.begin();
		ans[v[i].second] = low * 3 + upp - low - 1;
	}
	rep(i, n) cout << ans[i] << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
		return 0;
}


Measured memory_bytes: 4712
using System;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {

        string line = Console.ReadLine();
	    int num = line.Length;
        string str = line.Substring(0, num / 2);
      	int num2 = line.IndexOf(str,num / 2 + 1);
      	if(num2 == -1){
        Console.WriteLine("No");
        }else
        {
        Console.WriteLine("Yes");
        }
    }
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    ll ans = 0;
    rep(a, K)rep(b, K)rep(c, K) {
        ans += __gcd(a+1, __gcd(b+1, c+1));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func increment(bits []bool) bool {
	i := 0
	for i < len(bits) && bits[i] {
		bits[i] = false
		i++
	}
	if i < len(bits) {
		bits[i] = true
	} else {
		return false
	}
	return true
}

func main() {
	scanner.Split(bufio.ScanWords)
	n := nextInt()
	bits := make([]bool, n)

	ok := true
	i := 0
	for {
		cache := []string{}
		for j := 0; j < n; j++ {
			if bits[j] {
				cache = append(cache, strconv.Itoa(j))
			}
		}
		if i == 0 {
			fmt.Println("0:")
		} else {
			fmt.Printf("%v: %v\n", i, strings.Join(cache, " "))
		}

		i++
		ok = increment(bits)
		if !ok {
			break
		}
	}
}



Measured memory_bytes: 6388
#include <bits/stdc++.h>
using namespace std;
#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++)
using pii = pair<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using ll = long long;

int main() {
    int n , k;
    cin >> n >> k;
    vi p(n);
    rep (i, n) cin >> p.at(i);

    sort(p.begin(), p.end());
    int ans = 0;
    rep(i, k) {
        ans += p.at(i);
        //cout << p.at(i) << endl;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3628
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#include <random>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,n) for(int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for(int i=(a)-1;i>=b;--i)
#define range(i,a,b,c) for(int i=a;\
                    c>0?i<b:\
                    i>b;\
                    i+=c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define int long long
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 1 << 28;
const ll INFL = (ll)1 << 58;
ll mod = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real& r) { return (r > eps) - (r < -eps); }
int sgn(const Real& a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep) {
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

template<class InputIterator>
int sum(InputIterator begin, InputIterator end) {
	return accumulate(begin, end, 0ll);
}

string reverse_str(string s) {
	reverse(all(s));
	return s;
}

string s;

void solve() {
	cin >> s;
	int first = [=](){
		rep(i, s.size()) {
			if (s[i] == 'A') return i;
		}
	}();

	int last = []() {
		rrep(i, s.size()) {
			if (s[i] == 'Z') return i;
		}
	}();

	cout << last - first + 1 << endl;
}

signed main() {
	srand(time(NULL));
	int T = 100;
	cout << fixed << setprecision(15);
	rep(i, T) {
		char s[MAX];
		if (scanf("%s", s) == EOF) break;
		int n = strlen(s);
		for (int i = n - 1; i > -1; i--) {
			ungetc(s[i], stdin);
		}
		solve();
	}
	return 0;
}

Measured memory_bytes: 1024
/**
    @Author:Monk78
    @Topic:
**/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll>Vl;
typedef pair<ll,ll>PII;
typedef vector<PII>Vll;
typedef vector<pair<ll,pair<ll,ll> > >Vlll;
typedef priority_queue<ll>PQL;
typedef map<ll,ll>MP;
#define S second
#define F first
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end));i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mod 1000000009
#define MAX 100005
#define f(i,a,b) for(int i=(a);i<(b);i++)
#define rf(i,a,b) for(int i=(a);i>=b;i--)
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
#define vpshVar() int main()
bool cmp(const pair<string,ll>&a,const pair<string,ll>&b){
    if(a.F==b.F)return a.S>b.S;
    else return a.F<b.F;
}
vector<pair<string,ll> > V;
vpshVar(){
    ll N,num;
    string str;
    sl(N);
    map<string,ll>M;
    for(ll i=0;i<N;i++){
        cin>>str>>num;
        V.pb(mp(str,num));
        string ss=str+to_string(num);
        M[ss]=i+1;
    }
    sort(V.begin(),V.end(),cmp);
    //reverse(V.begin(),V.end());
    for(auto it:V){
        string ss=it.F;
        ll snum=it.S;
        string jj=ss+to_string(snum);
        pl(M[jj]);
        cout<<endl;
    }
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

const ll MOD = 998244353;

ll A, B, C, D;
ll dp[3][3005][3005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> A >> B >> C >> D;
    if(A == C){
        ll tmp = 1;
        for(int i = B+1; i <= D; i++){
            tmp *= A;
            tmp %= MOD;
        }
        cout << tmp << endl;
        return 0;
    }
    if(B == D){
        ll tmp = 1;
        for(int i = A+1; i <= C; i++){
            tmp *= B;
            tmp %= MOD;
        }
        cout << tmp << endl;
        return 0;
    }
    dp[0][A][B] = 1;
    dp[1][A][B] = 1;
    for(int i = A+1; i <= C; i++) {
        dp[0][i][B] = (dp[0][i-1][B]*B)%MOD;
        dp[0][i][B] %= MOD;
    }
    for(int i = B+1; i <= D; i++) {
        // for(int j = 0; j <= 2; j++){
        //     dp[min(2, j+1)][A][i] = dp[j][A][i-1]*A;
        //     dp[min(2, j+1)][A][i] %= MOD;
        // }
        dp[1][A][i] = (dp[1][A][i-1]*A)%MOD;
        dp[1][A][i] %= MOD;
    }
    for(int i = A+1; i <= C; i++){
        for(int j = B+1; j <= D; j++){
            // cout << i << ' ' << j << endl;
            dp[0][i][j] += dp[0][i-1][j];
            dp[0][i][j] %= MOD;

            dp[1][i][j] += ((dp[0][i][j-1]+dp[1][i][j-1]+dp[2][i][j-1])*i)%MOD;
            dp[1][i][j] %= MOD;
            dp[1][i][j] += dp[0][i-1][j];
            dp[1][i][j] %= MOD;

            dp[2][i][j] += dp[1][i-1][j];
            dp[2][i][j] %= MOD;
            dp[2][i][j] += (dp[2][i-1][j]*j)%MOD;
            dp[2][i][j] %= MOD;
        }
    }
    cout << (dp[0][C][D]+dp[1][C][D]+dp[2][C][D])%MOD << endl;
}

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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n, k;
  cin >> n >> k;
  int ans = 1;
  ans *= k;
  rep(i, 0, n - 1) ans *= k - 1;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=1e5+10;
int a[maxn];
int cmp(const int a,const int b){
    return a>b;
}
int n,m,v,p;
int b[maxn];
bool judge(int mid){
    //printf("hello %lld\n",mid);
    if(mid<=p)return true;
    if(a[mid]+m<a[p])return false;
    if(v<=p-1&&a[mid]+m>=a[p])return true;
    for(int i=1;i<=n;i++)b[i]=a[i];
    int temp=0;
    int inx=n,cnt=v-p+1;
    for (int i=n,j=v-p;i>mid&&j;i--,j--){
        temp+=m;
        b[i]+=m;
    }
    temp+=m*p;
    int now=a[mid]+m;
    int res=m*v-temp;
    for(int i=p;i<mid;i++){
        int add=min(m,max(now-a[i],0ll));
        if(add>res)add=res;
        res-=add;
        b[i]+=add;
    }
    return now>=b[p]&&res<=0;
}
signed main(){
    cin>>n>>m>>v>>p;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+n+1,cmp);
    int low=1,high=n;
    int ans=0;
    while(low<=high){
        int mid=(low+high)>>1;
        if(judge(mid)){
            low=mid+1;
            ans=mid;
        }
        else{
            high=mid-1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
require 'pp'

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

N, K = gets_i_list
a_list = []
K.times do
  gets_i
  a_list.push(gets_i_list)
end
puts N - a_list.flatten.uniq.size

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


int main(){
	int n;
	cin>>n;
	
	int passado=0;
	string ans = "Yes";
	
	for (int i=0; i<n; i++){
		int k;
		cin>>k;
		
		//passado=k;
		
		if (k>passado){
			passado=k-1;
		}
		
		else if (k==passado){
			passado=k;
		}
		
		else ans="No";
	}
	
	
	cout<<ans<<endl;
}


Measured memory_bytes: 256
(let* ((n (read))
       (vec (concatenate 'vector (loop repeat n
                                       collect (read)))))

  (defun f (v &optional (pos 0) (cnt 0))
    (if (> cnt n)
      -1
      (if (= pos 1)
        cnt
        (f v (1- (aref v pos)) (1+ cnt)))))

  (format t "~A~%"
          (f vec)))


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

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

    int n;
    cin >> n;
    double t, a;
    cin >> t >> a;

    vector<double> H(n);
    for(int i = 0; i < n; i++){
        cin >> H[i];
    }

    double mini = 1e9;
    int idx = 1e9;
    for(int i = 0; i < n; i++){
        double ave = t - H[i] * 0.006;
        mini = min(mini, abs(a - ave));
        if(mini == abs(a - ave)){
            idx = i;
        }
    }

    cout << idx + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
	#define debug(A,args...) fprintf(stderr,A,##args)
#else
	#define debug(A,args...) printf("")
#endif
#define deb debug("line %d\n",__LINE__)
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void GG(){puts("-1");exit(0);}

	const db eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=998244353;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int MM=5e6+10;
	ll fac[MM],facinv[MM],Inv[MM];ll Comb(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,MM-1) fac[i]=fac[i-1]*i%MOD;
		facinv[MM-1]=invm(fac[MM-1]);fd(i,MM-1,1) facinv[i-1]=facinv[i]*i%MOD;
		Inv[1]=1;fo(i,2,MM-1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
	}
	const int N=1e6+10;
	//------------------FIXED------------------
	int n,MX;
	ll dec[N];
	struct Graph
	{
		vc<int> to[N];
		bool used[N];int sg[N],cnt[N];
		void input()
		{
			int m=qread();while(m--){ int x=qread(),y=qread();if(x>y)swap(x,y);to[x].PB(y); }
			fd(x,n,1)
			{
				for(auto y:to[x]) used[sg[y]]=1;
				while(used[sg[x]]) sg[x]++;add(cnt[sg[x]],dec[x]),chmax(MX,sg[x]);
				for(auto y:to[x]) used[sg[y]]=0;
			}
			deb;
		}
	}G[3];
	void main()
	{
		dec[0]=1,dec[1]=ll(1e18)%MOD;fo(i,2,N-1) dec[i]=dec[i-1]*dec[1]%MOD;
		n=qread();fo(id,0,2) G[id].input();
		int ans=0;fo(i,0,MX) fo(j,0,MX) add(ans, 1ll*G[2].cnt[i^j]*G[0].cnt[i]%MOD*G[1].cnt[j]%MOD );write(ans);
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	//freopen("a.out","w",stdout);
	#endif
	srand(time(0));
	mine::PRE();
	mine::main();
	debug("\n------------------------------------------\nTime: %.2lf s\n",1.0*clock()/CLOCKS_PER_SEC);
}

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

using namespace std;

int main()
{
    int n;
    string t_cade,h_cade;
    int t_point=0,h_point=0;
    cin >>n;

    for(int i=0;i<n;i++)
    {
        cin>>t_cade>>h_cade;

        if(t_cade==h_cade)
        {
            t_point++;
            h_point++;
        }else
        {
            int index=0;
            while (t_cade[index] == h_cade[index])
            {
                index++;
            }

            if(t_cade[index] > h_cade[index])
            {
                t_point+= 3;
            }else
            {
                h_point += 3;
            }
        }
    }

    cout<<t_point<<" "<< h_point<<endl;

    return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
void conv(string &S, char c){
  if (c == 'J'){
    S = S.back() + S.substr(0, S.size() - 1);
  }
  if (c == 'C'){
    S =  S.substr(1) + S[0];
  }
  if (c == 'E'){
    if (S.size() % 2 == 0){
      S = S.substr(S.size() / 2) + S.substr(0, S.size() / 2);
    } else {
      S = S.substr(S.size() / 2 + 1) + S[S.size() / 2] + S.substr(0, S.size() / 2);
    }
  }
  if (c == 'A'){
    reverse(S.begin(), S.end());
  }
  if (c == 'P'){
    for (int i = 0; i < S.size(); i++){
      if (S[i] == '0'){
        S[i] = '9';
      } else if ('1' <= S[i] && S[i] <= '9'){
        S[i]--;
      }
    }
  }
  if (c == 'M'){
    for (int i = 0; i < S.size(); i++){
      if (S[i] == '9'){
        S[i] = '0';
      } else if ('0' <= S[i] && S[i] <= '8'){
        S[i]++;
      }
    }
  }
}
int main(){
  int n;
  cin >> n;
  for (int i = 0; i < n; i++){
    string S;
    cin >> S;
    string T;
    cin >> T;
    int m = S.size();
    for (int j = m - 1; j >= 0; j--){
      conv(T, S[j]);
    }
    cout << T << endl;
  }
}


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

using namespace std;

#ifdef Lin1043
    #define DEBUG(msg, ...) printf("(%s #%d) " msg, __FUNCTION__, __LINE__, __VA_ARGS__)
    #define massert(...) assert(...)
#else
    #define DEBUG(...)
    #define massert(...)
#endif

#define rep(i , l , r) for(int i = (l) , ___ = (r) ; i <= ___ ; ++i )
#define per(i , r , l) for(int i = (r) , ___ = (l) ; i >= ___ ; --i )

struct iopener
{
    iopener()
    {
#ifdef Lin1043
        freopen("./in" , "r" , stdin);
#endif
    }
} iop;

typedef long long LL;

template<typename T>inline bool chkmin(T &x , const T &y) { return x > y ? (x = y , 1) : 0; }
template<typename T>inline bool chkmax(T &x , const T &y) { return x < y ? (x = y , 1) : 0; }

template<typename T>inline T read(T &f)
{
    f = 0; int x = 1 ; char c = getchar();
    while(!isdigit(c)) x = (c == '-' ? -1 : 1) , c = getchar();
    while(isdigit(c)) (f *= 10) += c & 15 , c = getchar();
    return f = x * f;
}

const int N = 200000 + 5;
const int KCZ = 1e9 + 7 , L = N - 5;

int n , A[N] , B[N];

LL fac[N] , inv[N];

LL mp(LL x , LL y = KCZ - 2)
{
    LL res = 1;
    while(y)
    {
        if(y & 1) res = res * x % KCZ;
        x = x * x % KCZ;
        y >>= 1;
    }
    return res;
}

void init()
{
    fac[0] = 1;
    rep(i , 1 , L)
        fac[i] = fac[i - 1] * i % KCZ;
    inv[0] = 1;
    inv[L] = mp(fac[L]);
    per(i , L - 1 , 1)
        inv[i] = inv[i + 1] * (i + 1) % KCZ;
}

int delta;

const int M = 4000 + 5;

LL f[M][M];

void add(LL &x , const LL &y)
{
    x += y ; if(x >= KCZ) x -= KCZ;
}

void sub(LL &x , const LL &y)
{
    x -= y ; if(x < 0) x += KCZ;
}

LL C(int n , int m)
{
    if(n < m) return 0;
    return fac[n] * inv[m] % KCZ * inv[n - m] % KCZ;
}

int main()
{
    read(n) , init();
    rep(i , 1 , n)
        read(A[i]) , read(B[i]);
    rep(i , 1 , n)
        chkmax(delta , max(A[i] , B[i]));
    rep(i , 1 , n)
        f[delta - A[i]][delta - B[i]]++; 
    rep(i , -delta , delta)
        rep(j , -delta , delta)
        {
            if(i >= -delta + 1)
                add(f[i + delta][j + delta] , f[i - 1 + delta][j + delta]);
            if(j >= -delta + 1)
                add(f[i + delta][j + delta] , f[i + delta][j - 1 + delta]);
        }
    LL Ans = 0;
    rep(i , 1 , n)
    {
        add(Ans , f[delta + A[i]][delta + B[i]]);
        sub(Ans , C(2 * (A[i] + B[i]) , 2 * A[i]));
    }
    Ans = Ans * mp(2) % KCZ;
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 130304
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
signed main() {
	int a, b, c, d, e, f, g, h, i, j, k;
	cin >> a >> b >> c >> d >> e >> f >> g >> h;
	k = c * d + g * h;
	i = max(0, min(a + c, e + g) - max(a, e));
	j = max(0, min(b + d, f + h) - max(b, f));
	cout << k - i * j * 2 << endl;
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = 1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

void solve() {
    string s; cin >> s;
    if (sz(s) >= 4 && s.substr(0, 4) == "YAKI") {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
}

int main() {
    int JUDGE_ONLINE = 1;
    if (fopen("in.txt", "r")) {
        JUDGE_ONLINE = 0;
        assert(freopen("in.txt", "r", stdin));
        //assert(freopen("out.txt", "w", stdout));
    }
    else {
        ios_base::sync_with_stdio(0), cin.tie(0);
    }
    solve();
    if (!JUDGE_ONLINE) {
        //cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    }
    return 0;
}

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

int main() {
    int A;
    cin >> A;
    int B;
    cin >> B;
    int H;
    cin >> H;
    int M;
    cin >> M;

    double hx, hy;
    double angleH = -1 * M_PI / 6 * H + M_PI / 2 + (-1 * M_PI / 360 * M);
    hx = A * cos(angleH);
    hy = A * sin(angleH);

    double mx, my;
    double angleM = -1 * M_PI / 30 * M + M_PI / 2;
    mx = B * cos(angleM);
    my = B * sin(angleM);

    double length = sqrt((hx - mx) * (hx - mx) + (hy - my) * (hy - my));
    // cout << hx << ", " << hy << endl;
    // cout << mx << ", " << my << endl;

    // cout << endl;
    // cout << length << endl;

    printf("%.20lf\n", length);
    return 0;
}

Measured memory_bytes: 4040
#include "bits/stdc++.h"

using namespace std;

void solve()
{
	int N;
	cin >> N;
	vector<double> ps(N);
	for (int i = 0; i < N; i++)
	{
		cin >> ps[i];
	}
	vector<vector<double>> dp(N+1, vector<double>(N+1));

	dp[0][0] = 1;

	for (int i = 0; i < N; i++)
		for (int j = 0; j <= i; j++)
		{
			dp[i+1][j+1] += dp[i][j]*ps[i];
			dp[i+1][j] += dp[i][j]*(1-ps[i]);
		}

	double ans = 0;

	for (int j = N/2+1; j <= N; j++)
	{
		ans += dp[N][j];
	}

	cout << fixed << setprecision(9) << ans << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 70784
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

constexpr int MOD = 1000000007;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

int main() {
    string s;

    cin >> s;
    int N = s.size();

    LL sum = 0;
    for (int j = 0; j < (1 << (N-1)); ++j) {
        LL ret = 0, acc = s[0] - '0';
        for (int k = 1; k < N; ++k) {
            if ((j & (1 << (k-1))) != 0) {
                ret += acc;
                acc = s[k] - '0';
            } else {
                acc = 10 * acc + (s[k] - '0');
            }
        }
        ret += acc;
        sum += ret;
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B;
  cin >> A >> B;
  int sum;
  sum = 0;
  while(A <= B){
    int a, b, c, d, e;
    a = A / 10000, e = A % 10;
    b = (A - a * 10000) / 1000, c = (A - a * 10000 - b * 1000) / 100;
    d = c = (A - a * 10000 - b * 1000 - c * 100) / 10;
    if (a == e && b == d) sum += 1;
    A++;
  
  }
  cout << sum << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int n;
vector<int> l;

int main() {
    cin >> n;
    l.resize(n);
    rep(i, n) cin >> l[i];
    sort(l.begin(), l.end());

    ll ans = 0;
    for (int i = n - 1; i >= 0; i--) {
        for (int j = i - 1; j >= 0; j--) {
            auto itr = lower_bound(l.begin(), l.end(), l[i]+l[j]);
            int d = distance(itr, l.end());
            ans += (n - 1 - i) - d;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if(s == "RRR") {
    cout << 3 << endl;
  } else if(s == "RRS" || s == "SRR") {
    cout << 2 << endl;
  } else if(s == "RSS" || s == "SRS" || s == "SSR" || s == "RSR") {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 3568
#include <iostream>
#include <vector>
using namespace std;
vector<bool> P(1000000, true);
vector<int> Q(1000000, 0);
int main()
{
	P[0] = P[1] = false;
	for (int i = 2; i * i < P.size(); ++i) {
		for (int j = 2 * i; j < P.size(); j += i)
			P[j] = false;
	}

	for (int i = 2; i < P.size(); ++i) {
		Q[i] = Q[i-1];
		if (P[i]) Q[i]++;
	}
	int n;
	while (cin >> n) cout << Q[n] << endl;
	return 0;
}

Measured memory_bytes: 0
<?php

fscanf(STDIN, "%d %d", $n, $q);

$queue = array();
for ($i = 0; $i < $n; $i++) {
    fscanf(STDIN, "%s %d", $name, $time);

    $queue[] = array(
        'name' => $name,
        'time' => $time,
    );
}

$current   = 0;

while (count($queue) > 0) {
    $queue_next = array();

    for ($i = 0; $i < count($queue); $i++) {
        $process = $queue[$i];

        if ($process['time'] - $q <= 0) {
            $current += $process['time'];
            echo $process['name']." $current\n";

            continue;
        }

        $current += $q;
        $process['time'] -= $q;

        $queue_next[] = $process;
    }

    $queue = $queue_next;
}



Measured memory_bytes: 49048
import java.util.*;

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

    public static void main(String[] args) {
        long h = sc.nextLong();
        List<Long> hpList = calcHpRem(h);
        long[] power2 = new long[64];
        for(int i = 0; i < 64; ++i) {
            power2[i] = (i == 0) ? 1 : power2[i - 1] * 2;
        }

        long ans = 0;
        for(int i = 0, f = hpList.size(); i < f; ++i) {
            ans += power2[i];
        }
        System.out.println(ans);
    }

    static List<Long> calcHpRem(long h) {
        List<Long> hpList = new ArrayList<>(65);
        while(h > 0) {
            hpList.add(h);
            h /= 2;
        }
        return hpList;
    }
}

Measured memory_bytes: 23764