akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

struct T3 {
        int t0;
        int t1;
        int t2;
};

int sortfunc(struct T3 &lhs, struct T3 &rhs)
{
        if (lhs.t0 != rhs.t0) {
                return lhs.t0 < rhs.t0;
        }
        return lhs.t1 < rhs.t1;
}

void intinl3(auto *v, int count)
{
        for (int i = 0; i < count ; ++i) {
                int a, b, c;
                cin >> a >> b >> c;
                v->push_back({a, b, c});
        }
}

int main()
{
        int n, q;
        vector<T3> stxlist, events;
        set<int> xset;

        cin >> n >> q;

        intinl3(&stxlist, n);

        for (auto stx : stxlist) {
                events.push_back({stx.t0 - stx.t2, 1, stx.t2});
                events.push_back({stx.t1 - stx.t2, -1, stx.t2});
        }

        for (int i = 0; i < q; ++i) {
                int d;
                cin >> d;
                events.push_back({d, 2, 0});
        }

        sort(events.begin(), events.end(), sortfunc);

        for (auto event : events) {

                if (event.t1 == 1) {
                        xset.insert(event.t2);
                }
                if (event.t1 == -1) {
                        xset.erase(event.t2);
                }
                if (event.t1 == 2) {
                        if (xset.empty()) {
                                cout << -1 << endl;
                        }
                        else {
                                cout << *(xset.begin()) << endl;
                        }
                }
        }

        return 0;
}


Measured memory_bytes: 21864
using System;
using System.Collections.Generic;

namespace AOJ.intro
{
    namespace ITP_1_6_A
    {
        static public class ReversingNumbers
        {
            static public void Main()
            {
                //// コンパイルエラーに付き封印
                //string[] temp;
                //int n = int.Parse(Console.ReadLine());
                //int[] result = Array.ConvertAll(temp = Console.ReadLine().Trim().Split(), int.Parse);

                //if (n != result.Length) // 例外処理
                //{
                //    Console.WriteLine("The value is invalid");
                //    return;
                //}
                //for (int i = result.Length - 1; i >= 0; --i)
                //{
                //    Console.Write(result[i]);
                //    if(i != 0){
                //        Console.Write(" ");
                //    }
                //}
                //Console.WriteLine();

                int n = int.Parse(Console.ReadLine().Trim());
                string[] inputData = Console.ReadLine().Trim().Split(' ');
                for (int i = n - 1; i >= 0; i--)
                {
                    int data = int.Parse(inputData[i]);
                    if (i == 0)
                    {
                        Console.WriteLine(data);
                    }
                    else Console.Write("{0} ", data);
                }
            }
        }
    }
}


Measured memory_bytes: 9224
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
    	Scanner input = new Scanner(System.in);
      	String S = input.next();
      	int A = countOf(S, '0');
      	int B = countOf(S, '1');
      
      	if (A > B) {
        	int tmp = B;
          	A = B;
          	B = A;
        }
      	
      System.out.print(A * 2);

    }
  static int countOf(String str, char target){
	int count = 0;

	for(char x: str.toCharArray()){
		if(x == target){
			count++;
		}
	}

	return count;
}
}


Measured memory_bytes: 27080
import java.util.*;

public class Main {
	
	static final private String DATE_FORMAT = "yyyy/MM/dd";

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double result = 0;
		for(int tmp = 0; tmp < n ; tmp++) {
			double x = sc.nextDouble();
			String y = sc.nextLine();
			if(y.equals(" BTC")) {
				result += x*380000;
			}else {
				result += x;
			}
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 24660
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    ll N,M; cin >> N >> M;
    if(abs(N-M) > 1){
        cout << 0 << endl;
        return 0;
    }

    ll inu = 1 , saru = 1;
    for(ll i=1;i<=N;i++) inu = inu * i % mod;
    for(ll i=1;i<=M;i++) saru = saru * i % mod;

    ll ans = inu * saru % mod;

    if(N==M) ans = ans * 2 % mod;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main(){
    int N, T; cin >> N >> T;
    vector<int> A(N);
    for(int &a:A){
        cin >> a;
    }
    
    ll ans = 0;
    ll end = T;

    for(int i=0; i<N-1; i++){
        if(end > A[i+1]) ans += A[i+1] - A[i];
        else ans += T;
        end = A[i+1] + T;
    }
    
    cout << ans + T << endl;
    return 0;
}





Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int>vi;
#define pb push_back
#define f first
#define s second


int main()
{
	
	int x,y,z;
	cin>>x>>y>>z;
	swap(x,y);
	swap(x,z);
	cout<<x<<" "<<y<<" "<<z;
	return 0;	
}



Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int expr(string& s, int& i);
int term(string& s, int& i);
int factor(string& s, int& i);
int number(string& s, int& i);

int expr(string& s,int& i) {
	int a = term(s, i);
	while (s[i] == '+' || s[i] == '-') {
		char op = s[i];
		i++;
		int b = term(s, i);
		if (op == '+') {
			a = a+b;
		}
		else {
			a = a - b;
		}
	}
	return a;
}

int term(string& s, int& i) {
	int a = factor(s, i);
	while (s[i] == '*' || s[i] == '/') {
		char op = s[i];
		i++;
		int b = factor(s, i);
		if (op == '*') {
			a = a*b;
		}
		else {
			a = a / b;
		}
	}
	return a;
}

int factor(string& s, int& i) {
	if (isdigit(s[i])) {
		int a = number(s, i);
		return a;
	}
	else {
		i++;//(
		int a = expr(s, i);
		i++;//)
		return a;
	}
}

int number(string& s, int& i) {
	int a = s[i]-'0';
	i++;
	while (isdigit(s[i])) {
		a = a * 10 + (s[i] - '0');
		i++;
	}
	return a;
}

int main()
{
	int n;
	cin >> n;
	REP(j, n) {
		string ss;
		cin >> ss;
		int k = 0;
		cout << expr(ss, k) << endl;
	}

}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
#define set_null(a,n) memset(a,0,sizeof(a))
#define pi acos(-1)
#define ll long long int
#define fr(a,b) for(int i=a;i<b;i++)

int main()
{
    char ch[105];
    cin>>ch;
    int x=strlen(ch);
    bool flag1=true,flag2=true,flag3=true;
    for(int i=0;i<x/2;i++)
    {
        if(ch[i]!=ch[x-1-i])
        {
            flag1=false;
        }
    }
    int n=(x-1)/2;

    for(int i=0;i<n;i++)
    {
        if(ch[i]!=ch[n-1-i])
        {
            flag2=false;
        }
    }
    int m=(x+3)/2;
    for(int i=m;i<x;i++)
    {
        if(ch[i]!=ch[x-1-i])
        {
            flag3=false;
        }
    }
    if(flag1&&flag2&&flag3)
    {
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }

    return 0;
}



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

int main(void) {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string S;
	cin >> S;
	for (int i = 0; i < S.length(); i++) {
		cout<<'x';
	}
	return 0;
}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int dp[1<<12];

int main(){
    int n, m, ans = 0;
    cin >> n >> m;
    for(int i = 0; i < 1<<n; i++){
        dp[i] = INF;
    }
    dp[0] = 0;
    vector<pair<int, int>> k(m);
    for(int i = 0; i < m; i++){
        int a, b, c = 0;
        cin >> a >> b;
        int x;
        for(int j = 0; j < b; j++){
            cin >> x;
            x--;
            c += 1<<x;
        }
        k[i] = make_pair(a, c);
    }
    for(int i = 0; i < m; i++){
       for(int j = (1<<n) - 1; j >= 0; j--){
           if(dp[j] == INF) {continue;}
           int o = j | k[i].second;
           dp[o] = min(dp[o], dp[j] + k[i].first);
       } 
    }
    cout << (dp[(1<<n) - 1] != INF? dp[(1<<n) - 1] : -1) << endl;
    return 0;
}


Measured memory_bytes: 256
my Int $max-days = $*IN.get.Int;
my Int $former-days = $*IN.get.Int;
my Int $former-price = $*IN.get.Int;
my Int $latter-price = $*IN.get.Int;

say $former-price * ($former-days,$max-days).min + $latter-price * (($max-days - $former-days <= 0) ?? 0 !! ($max-days - $former-days))

Measured memory_bytes: 64284
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
using namespace std;

int main(){
	string a,b;
	double c;
	int count = 0;
	cin >> a >> b;
	c = stoi(a+b);
	for(int i;i <= abs(c);i++){
		if(pow(i,2) == c){
			count += 1;
			cout << "Yes" << endl;
				break;
		}
	}

	if(count == 0){
	cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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; }

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const int MAX_N = 110;
const int MAX_W = 1e5+10;

int N,W;
LL w[MAX_N],v[MAX_N];
LL dp[MAX_N][MAX_W];

LL dfs(int cur, LL rem){
    if(dp[cur][rem] != -1) return dp[cur][rem];
    if(cur == N) return 0;

    if(rem >= w[cur]){
        return dp[cur][rem] = max(dfs(cur+1,rem),dfs(cur+1,rem-w[cur])+v[cur]);
    }else{
        return dp[cur][rem] = dfs(cur+1,rem);
    }

}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    cin >> N >> W;
    REP(i,N){
        cin >> w[i] >> v[i];
    }
    memset(dp,-1,sizeof(dp));
    cout << dfs(0,W) << endl;

}


Measured memory_bytes: 86272
import java.util.*;

public class Main
{
    public static void main (String[] args)
    {
        Scanner scanner = new Scanner(System.in);

        int a = scanner.nextInt();
        int b = scanner.nextInt();

        if (a < b){
            System.out.println("a < b");
        } else if(a > b) {
            System.out.println("a > b");
        } else if(a == b) {
            System.out.println("a == b");
        }
    }
}

Measured memory_bytes: 26064
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string S;
    cin >> S;
    if(S[0] != S[1] || S[1] != S[2] || S[0] != S[2]){
        cout << "Yes" << endl; 
    }else{
        cout << "No" << endl;
    }
}

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

int minjumps(vector<int>v)
{
  int n=v.size();
  vector<int>dp(n+1,0);
  for(int i=1;i<n;i++)
  {
    if(i==1)
    {
      dp[i+1]=dp[i]+abs(v[i]-v[i-1]);
      continue;
    }
    dp[i+1]=min((dp[i]+abs(v[i]-v[i-1])),(dp[i-1]+abs(v[i]-v[i-2])));
  }
  return dp[n];
}

int main()
{
  int n;
  cin>>n;
  vector<int>v(n);
  for(int i=0;i<n;i++)
  {
    cin>>v[i];
  }
  cout<<minjumps(v)<<endl;  
  return 0;
}

Measured memory_bytes: 1408
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
using namespace std;

int main(void){
	int a[100000];
	int n;
	int l;
	int max;
	int mid;
	int x;
	max = 0;
	scanf("%d %d", &n, &l);
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
		if (i > 0){
			x = a[i - 1] + a[i];
			if (max < x){
				max = x;
				mid = i;
			}
		}
	}
	if (max < l)printf("Impossible\n");
	else{
		printf("Possible\n");
		for (int i = 1; i < mid; i++)printf("%d\n", i);
		for (int i = n - 1; i > mid; i--)printf("%d\n", i);
		printf("%d\n", mid);
	}
	return 0;
}



Measured memory_bytes: 1152
import java.util.Scanner;

//Card Game
public class Main {

	int[] a, b;
	boolean[] u;
	int res;

	void dfs(int k, int pa, int pb) {
		int p, q;
		if (k == 9) {
			res += pb < pa ? 1 : 0;
			return;
		}
		for (int i = 0; i < 9; i++) {
			if (u[i])
				continue;
			u[i] = true;
			if (b[k] < a[i]) {
				p = a[i] + b[k];
			} else {
				p = 0;
			}
			if (b[k] < a[i]) {
				q = 0;
			} else {
				q = a[i] + b[k];
			}
			dfs(k + 1, pa + p, pb + q);
			u[i] = false;
		}
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		while (T-- != 0) {
			a = new int[9];
			b = new int[9];
			u = new boolean[9];
			for (int i = 0; i < 9; i++)
				a[i] = sc.nextInt();
			for (int i = 0; i < 9; i++)
				b[i] = sc.nextInt();
			res = 0;
			dfs(0, 0, 0);
			double x = res * 1.0 / 362880;
			System.out.printf("%.5f %.5f\n", x, 1 - x);
		}
	}

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

Measured memory_bytes: 20788
#include <iostream>
#include <vector> 
#include <algorithm>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> a;
  for(int i=0; i< N;i++){
    int A;
    cin >> A;
    a.push_back(A);
  }
  sort(a.begin(),a.end(),std::greater<int>());
  int A=0,B=0;
  for(int i=0;i<N;i++){
    if(i%2==0){ 
      A+=a[i];
    }else{
      B+=a[i];
    }
  }
  cout << A-B << endl;
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Applicative
import Control.Monad.Fix
import Control.Monad.ST
import Data.Int
import Data.Foldable
import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

solve :: Int -> VU.Vector Int -> Int
solve !n !an = minimum $ map cost $ median bn
 where
  bn = VU.imap (\(!i) (!a) -> a - i - 1) an

  cost k = VU.foldl' (\(!acc) (!b) -> acc + abs (b - k)) 0 bn

  median vs =
    let vs' = sort $ VU.toList vs
    in  if even n
          then [vs' !! (n `div` 2 - 1), vs' !! (n `div` 2)]
          else [vs' !! (n `div` 2)]

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  n  <- (\vec -> (vec VU.! 0)) . VU.unfoldrN 1 readInt <$> B.getLine
  an <- VU.unfoldrN n readInt <$> B.getLine
  print $ solve n an


Measured memory_bytes: 36220
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); 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; }

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	char t = s[0];
	int ans = 1;
	for(int i=1; i<n; i++) {
		if(s[i-1] != s[i]) ans++;
		t = s[i];
	}
	cout << ans << endl;


  return 0;
}


Measured memory_bytes: 512
n, x = map(int, input().split())
M = []
for _ in range(n):
    M.append(int(input()))

M.sort()
cnt = 0
for m in M:
  x -= m
  cnt += 1

while x > 0:
    x -= M[0]
    if x >= 0:
        cnt += 1


print(cnt)


Measured memory_bytes: 3060
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()
if A + B >= 10:
    print("error")
else:
    print(A + B)

Measured memory_bytes: 26984
h,w=map(int,input().split())
if h==1:
    print(1)
    exit()
elif w==1:
    print(1)
    exit()
if h%2==1 and w%2==1:
    ans=int((h*w+1)/2)
elif h%2==0:
    ans=int(h/2*w)
else:
    ans=int(w/2*h)
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int

const llong MOD = 1e9 + 7;

map<llong, llong> M;

template<typename T> void factorization(T p) {
    llong i = 2;
    while (i * i <= p) {
        if (p % i == 0) {
            ++M[i];
            p /= i;
        } else {
            ++i;
        }
    }

    if (p != 1) ++M[p];
}

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    for (llong i = 2; i <= n; ++i) {
        factorization(i);
    }

    llong ans = 1;
    for (auto itr = M.begin(); itr != M.end(); ++itr) {
        ans = ((ans % MOD) * (itr->second + 1) % MOD) % MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
void selectionSort(int [],int);
void printArray(int [],int);
int count;
int main(){
  int i,n,A[N];
  count = 0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  selectionSort(A,n);
  printArray(A,n);
  return 0;
}
void selectionSort(int A[],int n){
  int i,j,tmp,key;
  for(i=0;i<n-1;i++){
    key = i;
    for(j=i+1;j<n;j++){
      if( A[j] < A[key] ){
	key = j;
      }
    }
    tmp = A[key];
    A[key] = A[i];
    A[i] = tmp;
    if( key != i ) {
      count++;
    }
  }
  return ;
}
void printArray(int A[],int n){
  int i;
  for(i=0;i<n;i++){
    if( i!=0 ){
      printf(" ");
    }
    printf("%d",A[i]);
  }
  printf("\n%d\n",count);
} 

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


int main()
{
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  if(a >= k)
  {
    cout << k << endl;
  }
  else if(a + b >= k)
  {
    cout << a << endl;
  }
  else
  {
    cout << a + a + b - k << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 3596
using System;
namespace csharptest
{
    class Program
    {
        static void Main(string[] args)
        {
            double a = double.Parse(Console.ReadLine());
            Console.WriteLine(string.Format("{0:0.000000}", (a * a * Math.PI)) + " " + string.Format("{0:0.000000}", (a * 2 * Math.PI)));
        }
    }
}

Measured memory_bytes: 5804
#include<stdio.h>
//#include<stdlib>
int main(){
    int s=0;
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);
    if(x>=y && x<=z || x<=y && x>=z) s=abs(x-y)+abs(x-z);
    else if(y>=x && y<=z || y<=x && y>=z) s=abs(x-y)+abs(y-z);
    else if (z>=y && z<=x || z>=x && z<=y) s=abs(z-y)+abs(z-x);
    printf("%d\n",s);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

template<typename T>
class BIT {
private:
  vector<T> bit;
  int n;
public:
  BIT(int _n) : n(_n) {
    bit = vector<T>(n+1, 0); //0初期化
  }
  void add(int v, T a){ //vは0-indexed
    for(int x=v+1; x<=n; x += x&(-x)) bit[x] += a;
  }
  T sum(int v){ //vは0-indexed
    T ret=0;
    for(int x=v+1; x>0; x -= x&(-x)) ret += bit[x];
    return ret;
  }
};

int main(){
  int n;
  cin>>n;
  vector<int> a(n),b(n),c(n);
  rep(i,n) cin>>a[i]>>b[i]>>c[i];

  auto arrange = [&](double m){
    vector<pair<double,int>> v;
    rep(i,n) v.pb(mp((double)(c[i]-m*a[i])/b[i], i));
    sort(all(v));
    return v;
  };

  auto sol = [&](){
    auto vl = arrange(-INF);
    vector<int> perm(n);
    rep(i,n) perm[vl[i].se] = i;

    auto calc = [&](double m){
      auto v = arrange(m);

      BIT<int> bit(n);
      int ret = 0;
      rep(i,n){
        int x = perm[v[i].se];
        ret += i - bit.sum(x);
        bit.add(x,1);
      }
      //dbg(m,ret);
      return ret;
    };

    double l = -INF, r = INF;
    rep(_,200){
      double m = (r+l)/2.0;
      if( calc(m)>=(n*(n-1)/2+1)/2 ) r = m;
      else l = m;
    }
    return r;
  };

  double x = sol();
  swap(a,b);
  double y = sol();

  printf("%.10f %.10f\n", x, y);

  return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        //入力
        var input = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToList();
        var input2 = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToList();
        var input3 = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToList();
        long n = long.Parse(Console.ReadLine());
        var list = new List<long>();
        for (var i = 0; i < n; i++)
        {
            list.Add(long.Parse(Console.ReadLine()));
        }
        //
        input.AddRange(input2);
        input.AddRange(input3);

        for (var i = 0; i < n; i++)
        {
			if(input.Any(x => list[i] == x)){
				input[input.IndexOf(list[i])] = 0;
			}
        }
         if ((input[0] == 0 && input[1] == 0 && input[2] == 0) ||
            (input[3] == 0 && input[4] == 0 && input[5] == 0) ||
            (input[6] == 0 && input[7] == 0 && input[8] == 0) ||
            (input[0] == 0 && input[3] == 0 && input[6] == 0) ||
            (input[1] == 0 && input[4] == 0 && input[7] == 0) ||
            (input[2] == 0 && input[5] == 0 && input[8] == 0) ||
			(input[0] == 0 && input[4] == 0 && input[8] == 0) ||
			(input[2] == 0 && input[4] == 0 && input[6] == 0)
            )
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
        // 文字列の入力
        //string s = Console.ReadLine();

        // 整数の入力
        //long n = long.Parse(Console.ReadLine());
        /*
        // 文字列配列の入力
        string[] inputStrArray = Console.ReadLine().Split(' ');

        // 整数配列の入力
        long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
		*/
        //処理
        //syori

        //出力


        Console.Out.Flush();
    }
}

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

def isprime(n):
    if n == 2:
        return True
    if (n < 2) or (n % 2 == 0):
        return False
    
    i = 3
    while i <= n**0.5:
        if n % i == 0:
            return False
        i += 2
    
    return True

c = 0

for _ in range(N):
    if isprime(int(input())):
        c += 1

print(c)
        
        


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

int main(){
  
  	long long n, k;
    cin >> n >> k;
    
    double res = 0.0;
    for (long long i = 1; i <= n; ++i) {
        double tmp = 1.0;
        long long d = i;
        while (d < k) d *= 2, tmp /= 2.0;
        res += tmp;
    }
    res /= n;
    cout << fixed << setprecision(10) << res << endl;
  
    /*long long n, k; cin >> n >> k;
    double res = 0.0;
    for(long long i=1; i<n+1; ++i){
        double tmp = 1.0;
        long long d = i;
        while(i<k){i *= 2; tmp /= 2.0;}
        res += tmp;
    }
    res /= n;
    cout << fixed << setprecision(15) << res << endl;*/
    return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;

const int maxn = 1e5 + 5;

signed main(void){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int n;
	string s;
	cin >> n >> s;
	if (n % 2){
		cout << "No";
		return 0;
	}
	if (s.substr(0, n/2) == s.substr(n/2, n/2)){
		cout << "Yes";
	}
	else cout << "No";
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int ui;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
#define All(v) (v).begin(),(v).end()
#define Rep(i,n) for(int i = 0; i < (int)n; i++)
#define Reps(i,n) for(int i = 1; i <= (int)n; i++)
#define For(i,m,n) for(int i = m; i < n; i++)
#define Fors(i,m,n) for(int i = m; i <= n; i++)
#define inf 2e9
#define f first
#define s second
#define pb push_back
#define mp make_pair
struct speed{speed(){cin.tie(); ios::sync_with_stdio(false); cout << fixed << setprecision(18);}}speed;

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

ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

ll lcm(ll a, ll b){
    return a*b/gcd(a,b);
}


int main (){
    int n;
    cin >> n;
    vector<int> v(n),c(n);
    Rep(i,n) cin >> v[i];
    Rep(i,n) cin >> c[i];
    int ans = 0;
    for(int bit = 0; bit < (1<<n); bit++){
        int tmpv = 0;
        int tmpc = 0;
        for(int i = 0; i < n; i++){
            if(bit & (1 << i)){
                tmpv += v[i];
                tmpc += c[i];
            }
        }
        if(ans < tmpv - tmpc) ans = tmpv - tmpc;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import *
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    print(max(a + b, a - b, a * b))
    return

#B
def B():
    k, x = LI()
    ans = []
    for i in range(x - k + 1, x + k):
        ans.append(i)
    print(*ans)
    return

#C
def C():
    n = II()
    d = defaultdict(int)
    for _ in range(n):
        s = S()
        s.sort()
        d[tuple(s)] += 1
    ans = 0
    for i in d.values():
        ans += i * (i - 1) // 2
    print(ans)
    return

# D
# 解説AC
# 後方から見ていくのはわかったけど。。。
# i日前に選べるバイトの中から一番報酬が大きいを選んでいく
def D():
    n, m = LI()
    q = []
    d = defaultdict(list)
    ans = 0
    for _ in range(n):
        a, b = LI()
        d[a].append(b)
    for i in range(m):
        for di in d[i+1]:
            heappush(q, -di)
        if q:
            ans -= heappop(q)
    print(ans)
    return

#E
def E():
    return

#F
def F():
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 74076
#include <bits/stdc++.h>
    using namespace std;
    const long double PI=3.14159265358979323846;
     
    int main() {
    	int x1,y1,x2,y2;
    	scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    	if (x1>x2) {
    		swap(x1,x2);
    		swap(y1,y2);
    	}
    	int n;
    	scanf("%d", &n);
    	vector<pair<long double, long double> > v;
    	bool FLAG=false;
    	for (int i=0; i<n; i++) {
    		long double x, y;
    		scanf("%Lf%Lf", &x, &y);
    		if (x1<=x && x<=x2) {
    			if (y1<=y2 && y1<=y && y<=y2) {
    				if (y1==y2) FLAG=true;
    			}
    			if (y2<=y1 && y2<=y && y<=y1) {
    				if (y1==y2) FLAG=true;
    			}
    			
    			if (y1<=y2 && y1<=y && y<=y2) {
    				FLAG|=(x1==x2);
    				v.push_back({x,y});
    			}
    			if (y2<=y1 && y2<=y && y<=y1) {
    				FLAG|=(x1==x2);
    				v.push_back({x,y});
    			}
    		}
    	}
    	sort(v.begin(), v.end());
    	vector<pair<long double, long double> > vl;
    	if (y1<=y2) {
    		for (int i=0; i<v.size(); i++) {
    		if (vl.empty()||v[i].second>vl.back().first) vl.push_back({v[i].second,v[i].first});
    		else {
    			int loc=lower_bound(vl.begin(),vl.end(),make_pair(v[i].second,(long double)0))-vl.begin();
    			vl[loc].first=v[i].second;
    			vl[loc].second=v[i].first;
    		}
    	}
    }
    else {
    	for (int i=0; i<v.size(); i++) {
    		if (vl.empty()||-v[i].second>vl.back().first) vl.push_back({-v[i].second,v[i].first});
    		else {
    			int loc=lower_bound(vl.begin(),vl.end(),make_pair(-v[i].second,(long double)-1000000000))-vl.begin();
    			vl[loc].first=-v[i].second;
    			vl[loc].second=v[i].first;
    		}
    	}
    }
    	bool FLAG2=false;
    	if ((int)vl.size()==min(abs(x2-x1),abs(y2-y1))+1) FLAG2=true;
    	//printf("%d\n", vl.size());
    	long double ans=(long double)(abs(x2-x1)+abs(y2-y1))*(long double)100;
    	if (!FLAG) {
    		ans+=(long double)(PI*5.0-20.0)*(long double)vl.size();
    		if (FLAG2) ans-=(PI*5.0-20.0);
    	}
    	if (FLAG||FLAG2) ans+=(PI*10.0-20.0);
    	printf("%.12Lf\n", ans);
    }

Measured memory_bytes: 21480
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
    int n;cin>>n;
    map<int,int> m;
    rep(i,n){
        int a;cin>>a;
        FOR(j,-1,1){
        if(m.count(a+j)){
            m[a+j]++;
        }else{
            m[a+j]=1;
        }
        }
    }
    int ma=0;
    for (auto i : m) {
        ma=max(ma,i.second);
    }
    cout<<ma<<endl;
    return 0;
}

Measured memory_bytes: 4736
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
const int MINF=-2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll kind(vi SYURUI) {//vector<int>型の配列の要素の種類数
    int size = SYURUI.size();
    sort(all(SYURUI));
    int cnt = 1;
    rep(i, size-1) {
        if (SYURUI[i] != SYURUI[i + 1])cnt++;
    }
    return cnt;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int N; cin >> N;
    int BIG = 1000000000000000000;
    vi A(N); rep(i, N)cin >> A[i];
    int sum = 1;
    bool b = true;
    rep(i, N)if (A[i] == 0) {
        puts("0");
        b = false;
        break;
    }
    if (b) {
        rep(i, N) {
            if (A[i] <= BIG / sum) {
                sum *= A[i];
            }
            else {
                puts("-1");
                b = false;
                break;
            }
        }
    }
    if (b)cout << sum << endl;
}




Measured memory_bytes: 4076
char W[9],V[9];Z[7*24*60],S,N,T,P,M;main(){
	int i,j,k,l,r,d;
	for(;scanf("%d%d%d%s%s%d%d",&S,&N,&T,W,V,&P,&M),S;printf("%.9f\n",1-pow(1-1.0/P,N*r))){
		memset(Z,0,sizeof(Z));
		l=*W=='A'?7:1;
		d=24*60*(*W=='A'?1:7);
		//i=0,l=1;
		if(*V=='A')for(i=0;i<l;i++)for(j=0;j<24*60;j++)Z[i*24*60+j]=1;
		if(*V=='D')for(i=0;i<l;i++)for(j=0;j<12*60;j++)Z[(i*24+6)*60+j]=1;
		if(*V=='N')for(i=0;i<l;i++)for(j=0;j<6*60;j++)Z[i*24*60+j]=Z[(i*24+18)*60+j]=1;
		for(r=j=0;j<24*60;r=r>l?r:l,j++)for(k=j,l=i=0;i<M;i++){
			if(k<24*60)l+=Z[(k+S)%(7*24*60)]&Z[k];
			k=(k+T)%(d);
		}
}exit(0);}

Measured memory_bytes: 736
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
  public static void main(String args[]) throws IOException{

   int n,m,l;
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


   while(true){

	   String line = br.readLine();
	   String[] token = line.split("");
	   if(line.equals("0")) break;
	   int sum = 0;
	   for(int i = 0; i < token.length;i++){
		   sum += Integer.parseInt( token[i] );
	   }

	   System.out.println(sum);

   }


  }
}

Measured memory_bytes: 25416
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			int s[] = new int[n];
			double m = 0;
			for (int i = 0; i < n; ++i) {
				s[i] = sc.nextInt();
				m += s[i];
			}
			m /= n;
			double al = 0;
			for (int i = 0; i < n; ++i) {
				al += (s[i] - m) * (s[i] - m);
			}
			al /= n;
			al = Math.sqrt(al);
			System.out.println(al);
		}
	}
}


Measured memory_bytes: 31196
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
          

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a , b , c;
    cin >> a >> b >> c;
    cout << (a + b) * c / 2;
}


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

const unsigned long mod = 1000000007;

// exponentiation by squaring: n^k
long long mod_pow(long long n, long long k) {
  if (k == 1) {
    return n % mod;
  } else if (k % 2 == 1) {
    return (n * mod_pow(n, k - 1)) % mod;
  } else {
    long long half_pow = mod_pow(n, k / 2);
    return (half_pow * half_pow) % mod;
  }
}

int main() {
  unsigned int N, K;
  std::cin >> N >> K;

  std::vector<long long> dp(K + 1, 0);

  for (unsigned int i = K; i >= 1; --i) {
    const unsigned long candidate_num = K / i;
    dp.at(i) = mod_pow(K / i, N);
    unsigned long subtract = 0;
    for (unsigned int j = 2; j <= candidate_num; ++j) {
      subtract = (subtract + dp.at(j * i)) % mod;
    }
    dp.at(i) = (dp.at(i) - subtract + mod) % mod;
  }

  unsigned long sum = 0;
  for (unsigned int i = 1; i <= K; ++i) {
    sum = (sum + (i * dp.at(i)) % mod) % mod;
  }

  std::cout << sum << std::endl;
  return 0;
}


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

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

    string s;
    cin >> s;

    if(s.size() >= 4 && s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I'){
        puts("Yes");
    }else{
        puts("No");
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define Int int64_t
using namespace std;
const Int M=(Int)(1e9+7);

inline Int mmul(Int a,Int b){if(a>=M)a=a%M;if(b>=M)b=b%M;if(a*b>=M)return(a*b)%M;return(a*b);}
inline Int madd(Int a, Int b){if(a>=M)a=a%M;if(b>=M)b=b%M;if(a+b>=M)return(a+b)%M;return(a+b);}



int main()
{
    int N;cin>>N;
    string s=to_string(N);
    
    int mp[10][10]={0};
    int ans=0;
    
    for(int i=1;i<=N;++i){
        int last=i%10;
        int t=i;
        while(t>=10){
            t/=10;
        }
        int first=t;
        mp[first][last]++;
    }
    
    for(int i=1;i<=9;++i){
        for(int j=1;j<=9;++j){
            ans+=mp[i][j]*mp[j][i];
        }
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
typedef long long int lli;
typedef pair<lli, lli> Pii;
const int INF = 193499;
int main(){
    int n;
    cin >> n;
    lli a[n],b[n],c[n];
    rep(i,n) cin >> a[i] ;
    rep(i,n) cin >> b[i] ;
    rep(i,n) cin >> c[i] ;

    sort(a,a+n);
    sort(c,c+n);
    lli ans = 0;

    rep(i,n){
        auto ue = lower_bound(a,a+n,b[i]) -a;
        auto sita = upper_bound(c,c+n,b[i]) -c;
        ans += ue * (n - sita);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const double pi = acos(-1.0);
const ll mod =  1e9+7;
#define ios std::ios::sync_with_stdio(false);cin.tie(0), cout.tie(0);
const int maxn = 1e5 + 5;

int main() {
  ios;
  int repeat;
  cin >> repeat;
  if(repeat==0)cout<<1<<endl;
  else if(repeat==1)cout<<0<<endl;

  return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <utility>
#include <algorithm>

using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)

ll solve(ll *layer,ll *D,ll N,ll X){
    if(N==0) return 1;
    if(X==1) return 0;
    else if( X<=layer[N-1]+1) return solve(layer,D,N-1,X-1);
    else if (X==layer[N-1]+2) return D[N-1]+1;
    else return D[N-1]+1+solve(layer,D,N-1,min(X-layer[N-1]-2,layer[N-1]));
}

int main(){
    ll N,X;
    cin>>N>>X;
    ll layer[50];
    layer[0]=1;
    rep(i,49) layer[i+1]=2*layer[i]+3;
    ll D[50];
    D[0]=1;
    rep(i,49) D[i+1]=2*D[i]+1;
    cout<<solve(layer,D,N,X)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int N, Y, sumMin, sumMax, cnt;
int coin[3];
int ansA[100000000];


int main(void) {
	scanf("%d %d", &N, &Y);
	cnt = 0;
	coin[0] = Y / 10000;
	coin[1] = (Y - coin[0]*10000) / 5000;
	coin[2] = (Y - coin[0]*10000 - coin[1]*5000) / 1000;
	sumMax = 10*coin[0] + 5*coin[1] + 1*coin[2];
	sumMin = coin[0] + coin[1] + coin[2];
	const man = coin[0];
	const gsn = coin[1];
	const sen = coin[2];
	if(N < sumMin || N > sumMax){
		printf("%d %d %d", -1, -1, -1);
		cnt++;
	}

	for(int a = 0; a <= man; a++){
		for(int b = 0; b <= man - a; b++){
			coin[0] = man - (a + b);
			coin[1] = gsn + (a * 2);
			coin[2] = sen + (b * 10);
			if(coin[0]+coin[1]+coin[2] == N){
				printf("%d %d %d", coin[0], coin[1], coin[2]);
				cnt++;
				exit(0);
			}
			for(int c = 1; c <= coin[1]; c++){
				coin[1] -= c;
				coin[2] += c * 5;
				if(coin[0]+coin[1]+coin[2] == N){
					printf("%d %d %d", coin[0], coin[1], coin[2]);
					cnt++;
					exit(0);
				}
			}

		}
	}

	if(cnt <= 0){
		printf("%d %d %d", -1, -1, -1);
	}

	return 0;
}

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

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)


template<typename T> T gcd(T a, T b) {
  if(a < b) swap(a, b);
  if(b == 0) return a;
  return gcd(b, a % b);
}

int main(int argc, char *argv[]) {
  i64 N, i;
  cin >> N;
  vi A(N);
  REP(0, N, i) {
    cin >> A[i];
  }

  i64 g = A[0];
  REP(1, N, i) {
    g = gcd(g, A[i]);
  }

  if(g != 1) {
    cout << "not coprime" << endl;
  }
  else {
    unordered_set<i64> factors;
    bool pairwise = true;
    
    auto test = [&](i64 &A, i64 p) {
      if(A % p == 0) {
	while(A % p == 0) {
	  A /= p;
	}
	if(factors.find(p) != factors.end()) {
	  pairwise = false;
	}
	else {
	  factors.insert(p);
	}
	return true;
      }
      return false;
    };
    
    REP(0, N, i) {
      i64 a = A[i];
      test(a, 2);
      i64 p = 3;
      while(p * p <= a) {
	test(a, p);
	p += 2;
      }
      if(a != 1) {
	test(a, a);
      }
    }

    if(pairwise) {
      cout << "pairwise coprime" << endl;
    }
    else {
      cout << "setwise coprime" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 14316
s = gets.rstrip
n = s.size

dp = Array.new(n) { Array.new(3, -1) }

dp[0][1] = 1
dp[1][2] = 1

if s[0] != s[1]
  dp[1][1] = 2
end

2.upto(n-1) do |i|
  kouho = [-1]
  if dp[i-1][1] != -1 && s[i-1] != s[i]
    kouho << dp[i-1][1] + 1
  end

  if dp[i-1][2] != -1
    kouho << dp[i-1][2] + 1
  end

  dp[i][1] = kouho.max

  kouho = [-1]
  last2 = i >= 3 ? s[i-3..i-2] : ''
  if dp[i-2][2] != -1 && last2 != s[i-1..i]
    kouho << dp[i-2][2] + 1
  end

  if dp[i-2][1] != -1
    kouho << dp[i-2][1] + 1
  end

  dp[i][2] = kouho.max
end

# dp.each do |a|
#   p a
# end

p dp[n-1].max


Measured memory_bytes: 16764
using System;
using System.Linq;

namespace Ex160425_1{
    public class Program{
        public static void Main(string[] args){
            var input = Console.ReadLine().Split(' ').ToList();
            input.Sort();

            Console.WriteLine("{0} {1} {2}", input[0], input[1], input[2]);
        }
    }
}

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

int main(){
    int N,T,A;
    cin >> N >> T >> A;
    double s = 100000.0;
    int ans = 0;
    rep(i,N){
        int x;
        cin >> x;
        if(fabs((T-x*0.006)-A) < s){
            ans = i+1;
            s = fabs((T-x*0.006)-A);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256