akhauriyash/Code-Regression huggingface dataset:
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int num = sc.nextInt();
			Set<Integer> set = new HashSet<>();
			for (int i = 0; i < num; i++) {
				set.add(sc.nextInt());
			}
			if (num == set.size()) {
				System.out.print("YES");
			} else {
				System.out.print("NO");
			}
		}
	}
}

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

using namespace std;

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

  string s;
  cin >> s;
  int upper = stoi(s.substr(0, 2));
  int lower = stoi(s.substr(2, 2));
  if ((upper == 0 || upper >= 13) && 1 <= lower && lower <= 12) {
    cout << "YYMM" << endl;
  } else if (1 <= upper && upper <= 12 && (lower == 0 || lower >= 13)) {
    cout << "MMYY" << endl;
  } else if (1 <= upper && upper <= 12 && 1 <= lower && lower <= 12) {
    cout << "AMBIGUOUS" << endl;
  } else {
    cout << "NA" << endl;
  }
  return 0;
}


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

#define F first 
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 2010, M = 2 * N;

int n;
int a[N];

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i ++ ) cin >> a[i];
	sort(a + 1, a + 1 + n);
	
	LL res = 0;
	for (int i = 1; i <= n; i ++ )
		for (int j = i + 1; j <= n - 1; j ++ )
		{
			int l = j + 1, r = n;
			if (a[l] >= a[i] + a[j]) continue;
			
			while (l < r)
			{
				int mid = l + r + 1 >> 1;
				if (a[mid] < a[i] + a[j]) l = mid;
				else r = mid - 1;
			}
			res += r - j;
		}
		
	cout << res << endl;
    return 0;
}

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

#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) for(int i=int(n-1);i>=0;i--)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define D(a) cerr << #a << " = " << a << endl
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
typedef pair<int,int> pii;
typedef long long int ll;
typedef vector<int> vi;
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    
    const int INF = 1e9;
    int n,k; cin >> n >> k;
    k = min(k,n-1);
    vi a(n),dp(n,INF);
    forn(i,n) cin >> a[i];
    dp[n-1] = 0;
    dforn(i,n-1) forsn(j,1,k+1) if(i+j < n)
        dp[i] = min(dp[i], abs(a[i]-a[i+j]) + dp[i+j]);
    cout << dp[0] << endl;
    return 0;
}


Measured memory_bytes: 1024
'use strict'

function main(s) {
  s = s.split('\n')[0].split(' ').map(n => Number(n));

  const start = s[0];
  const last  = s[1];
  let count = 0;

  for (let i = start; i <= last; i++) {
    const str = String(i);
    const reverse_str = str.split('').reverse().join('');
    if (str === reverse_str) {
      count += 1;
    }
  }

  console.log(count);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 13468
N,A,B,K=map(int,input().split())
mod=998244353

INV=[None]*(N+1)
for i in range(1,N+1):
    INV[i]=pow(i,mod-2,mod)

Combi=[None]*(N+1)
Combi[0]=1
Combi[1]=N
for i in range(2,N//2+2):
    Combi[i]=Combi[i-1]*(N-i+1)*INV[i] %mod
for i in range(N//2+2,N+1):
    Combi[i]=Combi[N-i]


ANS=0

if B>A:
    (A,B)=(B,A)

ran=K//A

for i in range(min(ran,N)+1):
    q, r = divmod(K-(A*i), B)
    if r==0 and q<=N:
        ANS = (ANS+(Combi[i]*Combi[q])%mod)%mod

print(ANS)



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

int main(void) {
  long long N;
  cin >> N;

  string S;
  cin >> S;

  long long r = 0;
  long long g = 0;
  long long b = 0;

  for (long long i=0; i<N; i++) {
    switch (S.at(i)){
      case 'R':
        r++;
        break;
      case 'G':
        g++;
        break;
      case 'B':
        b++;
        break;
    }
  }

  long long all = r * g * b;

  // k - j == j - i の場合を除去

  long long extra = 0;

  for (long long i=0; i<N-2; i++) {
    for (long long j=i+1; j<N-1; j++) {
      
      long long k = 2 * j - i; // この場合 k は 2*j-i に確定する
      if( k >= N || k < 0 ) continue; // オーバーフロー防止
      if( ( S.at(i)!=S.at(j) ) && ( S.at(j)!=S.at(k) ) && ( S.at(k)!=S.at(i) ) ){
        extra++;
      }
    }
  }

  cout << all - extra << endl; // 余分な場合を差し引いた分を出力
  
}


Measured memory_bytes: 3656
#include <iostream>

using namespace std;

int main() {
    string str;
    cin >> str;
    int a, z;
    for(int i=0; i<str.size(); i++) {
        if(str[i]=='A') {
            a = i;
            break;
        }
    }
    for(int i=str.size()-1; i>=0; i--) {
        if(str[i]=='Z') {
            z = i;
            break;
        }
    }
    cout << z-a+1 << endl;


    return 0;
    
}

Measured memory_bytes: 640
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000;
const double PI = acos(-1);
struct Edge { int nxt, to; }edge[100000];
LL n,m;
int f[100000] = {}, w[1000000][2] = {};
int F = 0;
int main() {
	std::cin >> n >> m;
	for (int i = 0; i < m; i++) {
		LL a, b;
		std::cin >> a >> b;
		w[i][0] = std::min(a, b), w[i][1] = std::max(a, b);
	}
	using item = std::pair<int, int>;
	std::sort((item*)w[0], (item*)w[m], [](item x, item y) { return x.first < y.first; });
	//for (int i = 0; i < m; i++)
		//std::cout << w[i][0] << " " << w[i][1] << std::endl;
	f[1] = 1;
	bool ff = true;
	while (ff) {
		ff = false;
		for (int i = 0; i < m; i++) {
			if (f[w[i][0]] == f[w[i][1]] && f[w[i][0]] != 0) {
				F = 1; break;
			}
			else if (f[w[i][0]] == f[w[i][1]]) ff = true;
			else {
				if (f[w[i][0]] == 1)f[w[i][1]] = 2;
				else if (f[w[i][0]] == 2)	f[w[i][1]] = 1;
				else if (f[w[i][1]] == 1)f[w[i][0]] = 2;
				else if (f[w[i][1]] == 2)	f[w[i][0]] = 1;
			}
		}
		if (F == 1)break;
	}
	int sum = 0, ssum = 0;
	for (int i = 1; i <= n; i++) {
		//std::cout << f[i] << std::endl;
		if (f[i] == 1)
			sum++;
		else if (f[i] == 2)
			ssum++;
	}
	std::cout << (F == 1 ? n*(n - 1) / 2 : sum*(n-sum)) - m << std::endl;
	return 0;
}

Measured memory_bytes: 3072
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const int INF = INT_MAX / 6;

typedef struct Area {
    int left; // left 1
    int mid; // mid 0
    int right; // right 1
} Area;

vector<Area> areas;

int main(void) {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    int slen = (int) S.size();

    vector<pair<char, int>> compress;
    if (S[0] == '0') {
        compress.push_back({'1', 0});
    }
    {
        char c = S[0];
        int count = 1;
        for (int i = 1; i < slen; i++) {
            if (S[i] == c) {
                count++;
            } else {
                compress.push_back({c, count});
                c = S[i];
                count = 1;
            }
        }
        compress.push_back({c, count});
    }
    if (compress[(int) compress.size() - 1].first == '0') {
        compress.push_back({'1', 0});
    }

    // for (auto &p : compress) {
    //     printf("%c: %d\n", p.first, p.second);
    // }
    // printf("\n");

    int ans = 0;
    int acc = 0;
    int cnt = 0;
    queue<pair<char, int>> q;

    acc += compress[0].second;
    q.push(compress[0]);
    for (int i = 1; i < (int) compress.size(); i++) {
        if (cnt >= 2 * K) {
            chmax(ans, acc);
            acc -= q.front().second;
            q.pop();
            acc -= q.front().second;
            q.pop();
            cnt -= 2;
        }
        acc += compress[i].second;
        q.push(compress[i]);
        cnt++;
    }
    chmax(ans, acc);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1528
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
signed main() {
	string s; cin >> s;
	for (int i = 0; i < s.size(); i++) {
		for (int j = i; j < s.size(); j++) {
			if (s.substr(0, i) + s.substr(j, s.size() - j) == "keyence") {
				cout << "YES\n";
				return 0;
			}
		}
	}
	cout << "NO\n";
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<map>
#include<iomanip>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define ll long long
#define pb(a) push_back(a)
using namespace std;
const vector<VE> DIR{ {-1,0},{1,0},{0,-1},{0,1} };
const ll MOD = 1000000007;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
int rgb2num(char c) {
	if (c == 'R') {
		return 0;
	}
	else if (c == 'G') {
		return 1;
	}
	else if (c == 'B') {
		return 2;
	}
	else {
		return -1;
	}
}
int main() {
	int n;
	string str;
	cin >> n;
	cin >> str;
	if (n < 4) {
		cout << 0 << endl;
		return 0;
	}
	vector<VE> vec(3,VE(n,0));
	vec[rgb2num(str[n - 1])][n-1] = 1;
	REP(i, n-1) {
		int rgbnum = rgb2num(str[n - 2-i]);
		REP(k, 3) {
			if (rgbnum == k) {
				vec[k][n - 2 - i] = vec[k][n - 1 - i] + 1;
			}
			else {
				vec[k][n - 2 - i] = vec[k][n - 1 - i];
			}
		}
	}
	ll ans = 0;
	REP(i, n-2) {
		for (int j = i + 1; j < n - 1; ++j) {
			if (str[j] == str[i]) {
				continue;
			}
			ans += vec[3 - rgb2num(str[i]) - rgb2num(str[j])][j+1];
			if (2 * j - i < n) {
				if (str[2 * j - i] != str[i] && str[2 * j - i] != str[j]) {
					ans--;
				}
			}
		}

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


Measured memory_bytes: 3648
n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(m)]
p=list(map(int,input().split()))
res=0
for i in range(2**n):
    b=list(str(bin(i))[2:].zfill(n))
    #print(b)
    my=True
    for j in range(m):
        pre=0
        for k in range(a[j][0]):
            #print(pre,a[j][k+1],b,b,b[a[j][k+1]-1])
            pre+=int(b[a[j][k+1]-1])
        if p[j]==0:
            if pre%2!=0:
                my=False
        else:
            if pre%2!=1:
                my=False
        #print(b,pre,my,j)
    #print(b,pre,my)
    if my:
        #print(b)
        res+=1
print(res)


Measured memory_bytes: 44912
N,K=map(int,input().split())
A=[]

for k in range(K):
  d=int(input())
  A.append(list(map(int,input().split())))
  
counts=[0]*N

for n in range(K):
  for a in A[n]:
    counts[a-1] +=1

print(counts.count(0))
  

Measured memory_bytes: 9180
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/

//var min, min2, count: Int!
//for i in 1...10 {
//    let x = Int(readLine()!)!
//    if i == 1 {
//        min = x
//        count = 1
//    } else if x < min {
//        min2 = min
//        min = x
//        count = 1
//    } else if x == min && count == 1 {
//        min2 = x
//        count = 2
//    }
//}
//print(min2)

/*************** メインプログラム ***************/

let N = readInt()!
var mochi = [Int]()
for _ in 0..<N {
    let d = readInt()!
    if !mochi.contains(d) {
        mochi += [d]
    }
}
print(mochi.count)


Measured memory_bytes: 1280
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n, k; string s;
    cin >> n >> k >> s;
    if (s[k-1] == 'A') s[k-1] = 'a';
    else if (s[k-1] == 'B') s[k-1] = 'b';
    else s[k-1] = 'c';
    cout << s << endl;
    return 0;
}

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int a[n];
	map<int,int> m;
	for(int i=0;i<n;i++){
		cin>>a[i];
		m[a[i]]++;
	}
	for(auto i:m){
		if(i.second > 1){
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES";
	return 0;
}

Measured memory_bytes: 10368
#include <stdio.h>
#include <math.h>

int main(void)
{
	double a;				//辺a
	double b;				//辺b
	double C;				//aとbの間の角度
	double h;				//aを底辺とした高さ
	double L;				//三角形の周の長さ
	double S;				//三角形の面積
	double PI = acos(-1);	//円周率

	scanf("%lf%lf%lf", &a, &b, &C);

	C = C * PI / 180;

	//高さhを求める
	h = b * sin(C);

	//周の長さを求める
	L = a + b + sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(C));

	//面積を求める
	S = ((a * b) / 2) * sin(C);

	//結果を出力する
	printf("%lf\n%lf\n%lf\n", S, L, h);

	return 0;
}

/*
テストケース
No.2 100 80 54
	
	A.3236.06796649979
	  263.6387228699747
	  64.7213595499958

No.3 25 76 45
	
	A.671.7514421272201
	  161.94254861335486
	  53.740115370177605

No4. 86 77 120
	
	A.2867.4101119302763
	  304.23384863410047
	  66.68395609140178
*/


Measured memory_bytes: 2116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res%mod;
}

int main(){
    ll N; cin >> N;
    vector<pair<ll, ll>> P(N);
    map<pair<ll, ll>, ll> M;
    ll lz = 0;
    ll rz = 0;
    ll z = 0;
    for(int i = 0; i < N; i++){
        ll a, b; cin >> a >> b;
        if(a == 0 && b == 0) z++;
        else if(a == 0) lz++;
        else if(b == 0) rz++;
        else{
            ll aa = abs(a), ab = abs(b);
            ll GCD = gcd(aa, ab);
            a/=GCD, b/= GCD;
            if(a < 0) P[i] = {-a, -b};
            else P[i] = {a, b};
            M[P[i]]++;
        }
    }

    

    ll ans = 1;
    if(lz != 0 || rz != 0) ans *= (modpow(2, lz, MOD) + modpow(2, rz, MOD) -1 +MOD) %MOD; 
    //ans *= modpow(2, lz, MOD) + modpow(2, rz, MOD) -1; 
    ans %= MOD;
    for(auto m : M){
        auto p = m.first;
        ll n = M[p];
        if(n == 0) continue;
        ll n_ = 0;

        auto p_ = p;
        ll temp; temp = p_.first, p_.first = p_.second, p_.second = temp;
        if(p_.first < 0) p_.first *= -1;
        else p_.second *= -1;
        
        n_ = M[p_]; M[p_] = 0;
        if(n_ != 0){
            ans *= ((modpow(2, n, MOD) + modpow(2, n_, MOD))%MOD -1 +MOD)%MOD;
            ans %= MOD;
        }
        else {
            ans *= modpow(2, n, MOD);
            ans %= MOD;
        }
    }
    ans += z; ans -= 1;
    ans += MOD;
    ans%=MOD;
    cout << ans << endl;


}


Measured memory_bytes: 31424
for(r={I:1,V:5,X:10,L:50,C:100,D:500,M:1000},j=require("fs").readFileSync("/dev/stdin","utf8"),k=n=s=0;p=n,i=j[k++];)(n=r[i])?n>p?s+=n-2*p:s+=n:(console.log(s),s=0)

Measured memory_bytes: 7912
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) ((int)(x).size())
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1e9;
// const ll INF = 1e15;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------


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

  int H, W, N;
  cin >> H >> W >> N;
  VVI paint(H, VI(W));

  int sum = 0;

  NREP(i, N) {
    int a;
    cin >> a;
    while (a > 0) {
      if (sum / W % 2 == 0) {
        paint[sum / W][sum % W] = i;
      } else {
        paint[sum / W][W - sum % W - 1] = i;
      }
      a--;
      sum++;
    }
  }

  REP(i, H) {
    REP(j, W) {
      cout << paint[i][j] << " ";
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N, K;
        N = sc.nextInt(); K = sc.nextInt();
        int h, cont = 0;
        for (int i=0; i<N; i++){
            h = sc.nextInt();
            if (h >= K) cont++;
        }
        System.out.println(cont);
    }
}

Measured memory_bytes: 49356
N = int(input())
a = [0]*(N+1)
for i in range(N+1):
    if i % 15 == 0 or i % 3 == 0 or i % 5 == 0:
        a[i] = 0
    else:
        a[i] = i
#print(a)
print(sum(a))

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

const int UNCALCULATED = -1;
const int MAXN = 100 + 10, MAXW = 100000 + 10;
long dp[MAXN][MAXW];
long v[MAXN], w[MAXN];

long calc(int i, int j) {
    if(j < 0)return -1e9;
    if(i == 0)return 0;
    if(dp[i][j] != UNCALCULATED)return dp[i][j];
    return dp[i][j] = max(v[i] + calc(i - 1, j - w[i]), calc(i - 1, j));
}

int main() {
    for(int i = 0; i < MAXN; i++) {
        for(int j = 0; j < MAXW; j++) {
            dp[i][j] = UNCALCULATED;
        }
    }
    int n, total;
    cin >> n >> total;
    for(int i = 1; i <= n; i++)cin >> w[i] >> v[i];
    cout << calc(n, total) << endl;
    return 0;
}

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

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

	std::vector<int> h(n);
	for (auto&& e : h)
		std::cin >> e;

	int ans = 0;

	h.insert(h.begin(), 0);
	for (int i = 0; i < n; ++i)
		if (h[i] < h[i + 1])
			ans += h[i + 1] - h[i];

	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if(a==0) cout<<1<<endl;
    else if(b==0) cout<<2<<endl;
    else if(c==0) cout<<3<<endl;
    else if(d==0) cout<<4<<endl;
    else if(e==0) cout<<5<<endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    long long int n, ans = 0, cnt = 0;
    cin >> n;
    vector<string> s(n);
    for(int i = 0;i < n;i++){
        cin >> s[i];
        sort(s[i].begin(),s[i].end());
    }

    sort(s.begin(),s.end());
    for(int i = 0;i < n - 1;i++){
        long long int a = 0, b = 0;
        if(s[i] == s[i + 1]){
            cnt++;

            if(i == n - 2){
                cnt++;
                a = cnt * (cnt - 1);
                b = 2;
                ans += a / b;
            }
        }
        else{
            cnt++;
            a = cnt * (cnt - 1);
            b = 2;
            ans += a / b;
            cnt = 0;
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 7296
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <time.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define mod 1000000009
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)


using ll = long long;
using pil = pair<int, ll>;

const ll INF = (ll)1e15;
int r,c;
vector<pil> Graph[200000];
bool used[200000];
ll min1,min2;
ll val[200000];

void dfs(int v){
    used[v] = 1;
    for(pil e : Graph[v]){
        int u = e.first;
        ll w = e.second - val[v];
        if(used[u]){
            if(w != val[u]){
                min2 = -INF;
                return;
            }
            continue;
        }
        val[u] = w;
        if(u < r){
            min1 = min(min1,w);
        }else{
            min2 = min(min2,w);
        }
        dfs(u);
    }
    return;
}

int main()
{
    int n;
    cin >> r >> c >> n;
    while(n--){
        int v,u;
        ll x;
        cin >> v >> u >> x;
        v--;
        u--;
        u += r;
        Graph[v].push_back(make_pair(u,x));
        Graph[u].push_back(make_pair(v,x));
    }
    rep(i,r){
        if(used[i]) continue;
        min1 = 0;
        min2 = INF;
        val[i] = 0;
        dfs(i);
        if(min1 + min2 < 0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 15104
# -*- coding: utf-8 -*-
N = int(input())
h_list = list(map(int, input().split()))
h_list = h_list
dp = {}
dp[0] = 0
dp[1] = abs(h_list[0] - h_list[1])
for i in range(2, N):
    dp[i] = min(dp[i - 2] + abs(h_list[i - 2] - h_list[i]), dp[i - 1] + abs(h_list[i - 1] - h_list[i]))
print(dp[N - 1])

Measured memory_bytes: 23200
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF = 99999999999999;
const ll MOD = 998244353;
ll a, b, c, d, e, f, p, t, x, y,z, q, m, n, r, h, k, ans = 0, w;

string S;
void input() {
	cin >> n >> S;
}

void solve() {
	ans = 1;
	rep(i, n - 1) {
		if (S[i] != S[i + 1])ans++;
	}

	cout << ans << endl;
}

int main() {
	input();
	solve();
}

Measured memory_bytes: 512
n,m,c = map(int,input().split())
b = [int(i) for i in input().split()]
ans = 0
for i in range(n):
    a = [int(j) for j in input().split()]
    x = c
    for k in range(m):
        x += a[k] * b[k]
    if x > 0:
        ans += 1
print(ans)



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


#define	SIZE	64


void Init(int *box)
{
	int i;

	for(i = 0; i < SIZE; i++)
		box[i]  = 0;
}


void Test(int *box, int i)
{
	if(box[i])
		printf("1\n");
	else
		printf("0\n");
}


void Set(int *box, int **mask_box)
{
	int x;
	int i = 0;

	while( (x = mask_box[0][i]) != -1){
		box[x] = 1;
		i++;
	}
}


void Clear(int *box, int **mask_box)
{
	int x;
	int i = 0;

	while( (x = mask_box[0][i]) != -1){
		box[x] = 0;
		i++;
	}
}


void Flip(int *box, int **mask_box)
{
	int x;
	int i = 0;

	while( (x = mask_box[0][i]) != -1){
		if(box[x])
			box[x] = 0;
		else
			box[x] = 1;
		i++;
	}
}


void All(int *box, int **mask_box)
{
	int x;
	int i = 0;

	while( (x = mask_box[0][i]) != -1){
		if(box[x] == 0){
			printf("0\n");
			return;
		}
		i++;
	}

	printf("1\n");
}


void Any(int *box, int **mask_box)
{
	int x;
	int i = 0;

	while( (x = mask_box[0][i]) != -1){
		if(box[x]){
			printf("1\n");
			return;
		}
		i++;
	}

	printf("0\n");
}


void None(int *box, int **mask_box)
{
	int x;
	int i = 0;

	while( (x = mask_box[0][i]) != -1){
		if(box[x]){
			printf("0\n");
			return;
		}
		i++;
	}

	printf("1\n");
}


void Count(int *box, int **mask_box)
{
	int count = 0;
	int x;
	int i = 0;

	while( (x = mask_box[0][i]) != -1){
		if(box[x])
			count++;
		i++;
	}

	printf("%d\n", count);
}


void Val(int *box, int **mask_box)
{
	unsigned long long int sum = 0;
	int x;
	int i = 0;

	while( (x = mask_box[0][i]) != -1){
		sum += (unsigned long long int)(pow(2, x) * box[x]);
		i++;
	}

	printf("%llu\n", sum);
}


int main()
{
	int n, size;
	int q, command, m;
	int **mask_box, *_mask_box;
	int bit_box[SIZE];
	int i, j;

	scanf("%d", &n);

	_mask_box = (int *)malloc(sizeof(int) *  n * (SIZE + 1));
	mask_box = (int **)malloc(sizeof(int *) * n);
	for(i = 0; i < n; i++)
		mask_box[i] = _mask_box + (i * (SIZE + 1));

	for(i = 0; i < n; i++){
		scanf("%d", &size);
		for(j = 0; j < size; j++)
			scanf("%d", &mask_box[i][j]);
		mask_box[i][size] = -1;
	}

	scanf("%d", &q);

	Init(bit_box);

	for(i = 0; i < q; i++){
		scanf("%d", &command);

		switch(command){
			case 0:
			// test
				scanf("%d", &m);
				Test(bit_box, m);
				break;
			case 1:
			//set
				scanf("%d", &m);
				Set(bit_box, mask_box + m);
				break;
			case 2:
			// clear
				scanf("%d", &m);
				Clear(bit_box, mask_box + m);
				break;
			case 3:
			// flip
				scanf("%d", &m);
				Flip(bit_box, mask_box + m);
				break;
			case 4:
			// all
				scanf("%d", &m);
				All(bit_box, mask_box + m);
				break;
			case 5:
			// any
				scanf("%d", &m);
				Any(bit_box, mask_box + m);
				break;
			case 6:
			// none
				scanf("%d", &m);
				None(bit_box, mask_box + m);
				break;
			case 7:
			// count
				scanf("%d", &m);
				Count(bit_box, mask_box + m);
				break;
			case 8:
			// val
				scanf("%d", &m);
				Val(bit_box, mask_box + m);
				break;

		}
	}

	return 0;
}


Measured memory_bytes: 2036
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int N = 1e6+5;

int n;

int main(){
    cin >> n;
    if(n < 1200){
        cout << "ABC" << endl;
    } else if(n < 2800){
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
int main() {
	int k;
	cin >> k;
	int val = 7;
	int len = 1e7;
	int ans = 1;
	while(len--) {
        val %= k;
        if(val == 0) {
        	cout << ans << endl;
        	break;
        }
        val *= 10;
        val += 7;
        ++ans;
	}
	if(len == -1)
		cout << -1 << endl;
}

Measured memory_bytes: 3524
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(x, max(y, z))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll N;
  cin >> N;
  vll A(N);
  rep(i, N) cin >> A[i];
  SORT(A);
  ll ans = A[N - 1] - A[0];
  ANS;
  return 0;
}

Measured memory_bytes: 3468
N=int(input())
L=sorted(list(map(int,input().split())))
ans=0
if N%2 == 1 :
    print(ans)
elif L[int(N/2)] == L[int(N/2-1)] :
    print(ans)
else:
    ans = L[int(N/2)]-L[int(N/2-1)]
    print(ans)

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

int main(){
    char c;
    cin >> c;

    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
        cout << "vowel" << endl;
    }
    else
    {
        cout << "consonant" << endl;
    }
    
}

Measured memory_bytes: 3632
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// #define ll long long 
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=2*1e5+2;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	string s,t;
	cin>>s>>t;
	cout<<t<<s;	
}  
// I never lose. I either win or I learn

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,i,j;
    scanf("%d",&n);
    int a[n],b[n];
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(i=i-1;i>=0;i=i-2)
        printf("%d ",a[i]);
    for(i=(i%2+1)%2;i<n;i=i+2)
        printf("%d ",a[i]);
    return 0;
}


Measured memory_bytes: 2816
n,m=map(int,input().split())
x=[]
y=[]
z=[]
for i in range(n):
    xi,yi,zi=map(int,input().split())
    x.append(xi)
    y.append(yi)
    z.append(zi)

def minus(x):
    return -1 * x

ans=0
for i in range(2):
    temp_x = x
    if(i==1):
        temp_x = list(map(minus,x))
    for j in range(2):
        temp_y = y
        if(j==1):
            temp_y = list(map(minus,y))
        for k in range(2):
            temp_z = z
            if(k==1):
                temp_z = list(map(minus,z))

            xyz = [temp_x[l] + temp_y[l] + temp_z[l] for l in range(n)]
            xyz.sort()
            temp_sum=0
            for h in range(n-m,n):
                temp_sum+=xyz[h]
            if(ans < temp_sum):
                ans = temp_sum
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 1000000007
typedef long long ll;

int main(){
    int n;
    cin >> n;
    int div[n+1];
    for(int i=0;i<=n;i++)
        div[i] = 1;
    for(int i=2;i<=n;i++){
        for(int j=i;j<=n;j+=i)
            div[j]++;
    }
    int count = 0;
    for(int i=1;i<=n;i++){
        if(i%2!=0 && div[i]==8)
            count++;
    }
    cout << count;
}

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

#define int long long
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(0);

int32_t main(){
//	fast;
	int n;
	cin >> n;
	
	double ans ;
	if(n%2) ans = n/2 + 1;
	else    ans = n/2;
	
	ans = ans/(double)n;
	printf("%0.7f",ans);
}







Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip> 
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(j, a, b) for (int j = a; j >= b; j--)
using namespace std;
const int MOD = 1e9 + 7;
const int MAX = 1e9 + 7;
void add(int& a, int b){
    a=(long long)a+b;
    if(a>=MOD)a-=MOD;
}
int abs_diff(int a, int b){
    return abs(a-b);
}
void get_max(int& a, int b){
    a = max(a, b);
}
void get_min(int& a, int b){
    a = min(a, b);
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    vector <int> v(n+2), dp(n+2, MAX);
    rep(i,1,n+1)cin>> v[i];
    dp[1]= 0;
    v[0]=MAX;
    rep(i,2,n+1){
        dp[i] = min(dp[i-1]+ abs_diff(v[i],v[i-1]), dp[i-2]+ abs_diff(v[i],v[i-2]));
        //cout <<i << " "<< dp[i] << " " << dp[i-1] << " " << dp[i-2]<< " " << v[i] << " " << v[i-1]<< " " << abs_diff(v[i],v[i-2])<<  "\n";
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<ll> v;
  rep(i,N){
    ll a;
    cin >> a;
    v.push_back(a);
  }

  bool all_minus = true;
  bool all_plus = true;
  rep(i,N){
    if(v[i] > 0) all_minus = false;
    if(v[i] < 0) all_plus = false;
  }

  vector<pair<int,int>> ret;
  
  if(!(all_minus || all_plus)){
    ll min_value = 100000000000LL;
    int min_value_i = -1;
    ll max_value = -100000000000LL;
    int max_value_i = -1;
    rep(i,v.size()){
      if(min_value > v[i]){
        min_value = v[i];
        min_value_i = i;
      }
      if(max_value < v[i]){
        max_value = v[i];
        max_value_i = i;
      }
    }

    if(abs(min_value) < abs(max_value)){
      all_plus = true;
      rep(i,N){
        if(max_value_i == i) continue;
        ret.emplace_back(max_value_i+1,i+1);
        v[i] += max_value;
      }
    }else{
      all_minus = true;
      rep(i,N){
        if(min_value_i == i) continue;
        ret.emplace_back(min_value_i+1,i+1);
        v[i] += min_value;
      }
    }
  }
  if(all_plus){
    rep(i,N-1){
      ret.emplace_back(i+1,i+2);
    }
  }
  else if(all_minus){
    rep(i,N-1){
      ret.emplace_back(N-i,N-1-i);
    }
  }

  cout << ret.size() << endl;
  rep(i,ret.size()){
    cout << ret[i].first << " " << ret[i].second << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let n = get!(usize);
    let mut v = get!([usize]);
    v.sort();
    let big = v[n / 2];
    let small = v[n / 2 - 1];
    //println!("{}, {}", small, big);
    println!("{}", big - small);
}


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

/* constant */

const int MAX_N = 1000;
const int MAX_Q = 1000;

/* typedef */

struct Era {
  string name;
  int sy, ey;

  Era() {}
  Era(int _y): sy(_y) {}

  bool operator<(const Era& e) const { return sy < e.sy; }
};

/* global variables */

int n, q;
Era eras[MAX_N];

/* subroutines */

/* main */

int main() {
  for (;;) {
    cin >> n >> q;
    if (n == 0) break;

    for (int i = 0; i < n; i++) {
      int ey, gy;
      cin >> eras[i].name >> ey >> gy;
      eras[i].sy = gy - ey + 1;
      eras[i].ey = gy;
    }
    sort(eras, eras + n);
    //for (int i = 0; i < n; i++)
    //cout << eras[i].name << ' ' << eras[i].sy << '-' << eras[i].ey << endl;
    
    while (q--) {
      int ey, gy;
      cin >> gy;

      int eid = upper_bound(eras, eras + n, Era(gy)) - eras - 1;
      //printf("%d -> %d\n", gy, eid);

      if (eid < 0 || eras[eid].ey < gy)
	cout << "Unknown" << endl;
      else {
	int ey = gy - eras[eid].sy + 1;
	cout << eras[eid].name << ' ' << ey << endl;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 1312
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

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

    N = N % 10;

    string ans = "hon";
    if (N == 3) {
        ans = "bon";
    } else if (N == 0 || N == 1 || N == 6 || N == 8) {
        ans = "pon";
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3612
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    sort(all(A));
    int ans = 0;
    set<int> S;

    if(A[0] == 1){
        if(N != 1 && A[1] == 1) cout << 0 << endl;
        else cout << 1 << endl;
        return 0;
    } 

    rep(i, N){
        if(i + 1 != N && A[i] == A[i + 1]){
            S.insert(A[i]);
            continue;
        }
        if(S.count(A[i])) continue;

        bool flag = true;
        for(int j = 2; j * j <= A[i]; j++){
            if(A[i] % j == 0){
                if(S.count(j) || S.count(A[i] / j)){
                    flag = false;
                    break;
                }
            }
        }

        if(flag){
            ans++;
            S.insert(A[i]);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 13552
s=input()
n=int(s[:2])
m=int(s[2:])
if 1<=n<=12:
  if 1<=m<=12:
    print("ambiguous".upper())
    exit()
  else:
    print("MMYY")
    exit()
if 1<=m<13:
  print("YYMM")
  exit()
print("NA")


Measured memory_bytes: 2940
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(N)]
AB.sort()
ans=0
count=0
for i in range(N):
    count=M-AB[i][1]
    if count>=0:
        ans+=AB[i][0]*AB[i][1]
        M=count
    else:
        ans+=AB[i][0]*M
        break
print(ans)

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

int main(){
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  const double PI = 3.14159265358979323846264338;
  double deg_a, deg_b;
  deg_a = PI*h/6+PI*m/360;
  deg_b = PI*m/30;
  double ans;
  ans = sqrt(a*a+b*b-2*a*b*cos(deg_a-deg_b));
  cout << fixed << setprecision(20) << ans << endl;
}

Measured memory_bytes: 4200
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    private static BufferedReader br;
    private static StringTokenizer tokenizer;

    private static void solve() throws IOException {
        String str = next();
        char[] arr = str.toCharArray();
        int len = arr.length;
        if ((len & 1) == 1) {
            System.out.println("No");
            return;
        }

        for (int i = 0; i < arr.length; i+=2) {
            if (!(arr[i] == 'h' && arr[i + 1] == 'i')) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }




    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        solve();
    }

    public static String next() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            String line = br.readLine();
            if (line == null)
                throw new IOException();
            tokenizer = new StringTokenizer(line);
        }
        return tokenizer.nextToken();
    }

    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

}

Measured memory_bytes: 22868
import functools


def solve(vs):
    ws = sorted(vs)
    res = functools.reduce(lambda x, y: (x + y) / 2, ws)
    return res


def main():
    _ = int(input())
    vs = [int(v) for v in input().split()]
    res = solve(vs)
    print("{:.12f}".format(res))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3700
#include <iostream>
using namespace std;
int main(){
  string str;
  while(  cin >> str){
    for(int i = 0 ; i < str.size(); i++){
      if( str[i] == '@'){
	for(int j = 0 ; j < str[i+1]-'0'; j++ ){
	  cout << str[i+2];
	}
	i+=2;
      }else cout << str[i];
    } 
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1172
import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		String s=" ";
		StringTokenizer st;
		int a,b,gcd,lcm,t,m,n;
		try {
			for(;s!=null;){
				s = r.readLine();
				st = new StringTokenizer(s," ");
				a = Integer.parseInt(st.nextToken().toString());
				b = Integer.parseInt(st.nextToken().toString());
				if(b>a){
					t=b; b=a; a=t;
				}
				m=a;n=b;
				while(true){
					if(n==0){
						gcd=m;
						break;
					}
					t=n;
					n=m%n;
					m=t;
				}
				lcm=(a/gcd)*b;
				System.out.println(gcd+" "+lcm);
			}
		} catch (Exception err) {
			System.exit(0);
		}
	}
}

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

int main(void) {
	int n;
	int ans = 0;
	scanf("%d", &n);
	if (n >= 100)
		ans = n % 10;
	if (n >= 10)
		ans = n % 10;
	else
		ans = n;
	if (ans == 3)
		printf("bon");
	else if (ans == 0)
		printf("pon");
	else if (ans == 1)
		printf("pon");
	else if (ans == 6)
		printf("pon");
	else if (ans == 8)
		printf("pon");
	else
		printf("hon");
	return 0;
}

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

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

Measured memory_bytes: 256
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(a:i64 b:i64 c:i64));
    let max = std::cmp::max(a, std::cmp::max(b, c));
    (a + b + c + max * 10 - max).to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "1 5 2" => "53",
    test2: "9 9 9" => "108",
    test3: "6 6 7" => "82",
}


Measured memory_bytes: 4352