akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 


int main() {

  int R;
  cin>>R;

  if(R<1200)
    cout<<"ABC"<<endl;
  else if(R<2800)
    cout<<"ARC"<<endl;
  else
    cout<<"AGC"<<endl;

  return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
    
  public static void main(String[] args) {
    int N, A, B, apass = 0, bpass = 0;
    String S;
    Scanner scanner = new Scanner(System.in);
    N = scanner.nextInt();
    A = scanner.nextInt();
    B = scanner.nextInt();
    scanner.nextLine();
    S = scanner.nextLine();
    for (int i = 0; i < S.length(); i++) {
        if (S.charAt(i) == 'c' || apass + bpass == A + B) {
            System.out.println("No");
        } else if (S.charAt(i) == 'a') {
            apass++;
            System.out.println("Yes");
        } else if (S.charAt(i) == 'b' && bpass < B) {
            bpass++;
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
    scanner.close();
  }
}

Measured memory_bytes: 24168
n=[int(i) for i in input().split()]
N=n[0]
A=n[1]
B=n[2]

S=0
for i in range(1,N+1):
  s=0
  C=str(i)  #N文字化
  c=list(C)
  
  w=[int(i) for i in c]
  s=sum(w)
  if s>=A and s<=B:
    S +=i
print(S)

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

int main(void)
{
  int n,m;
  scanf("%d",&n);
  char a[n][11];
  for(int i=0; i<n; i++){
      scanf("%s",a[i]);
  }

  scanf("%d",&m);
  char b[m][11];
  for(int i=0; i<m; i++){
      scanf("%s",b[i]);
  }

  qsort(a,n,11,strcmp);
  qsort(b,m,11,strcmp);

  int count = 0;
  int max = 0;

  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      if(strcmp(a[i],a[j])==0) count++;
    }
    
    for(int k=0; k<m; k++){
      if(strcmp(a[i],b[k])==0) count--;
    }
    if(max<count) max=count;
    count = 0;
  }

  printf("%d",max);

    return 0;

}



Measured memory_bytes: 128
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;

int main() {



  int N;
  cin >> N;
  map<string,int> m;
  for(int i = 0;i<N;++i){
    string s;
    cin >> s;
    sort(begin(s), end(s));
    ++m[s];
  }
  
  int64_t ans = 0;
  for (auto& v : m)
    ans += (int64_t)v.second * (v.second - 1) / 2;
  cout << ans << endl;
}


Measured memory_bytes: 11136
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = "";
			while ((s = Console.ReadLine()) != "0")
			{
				int A = 0, B = 0;
				A = s.Skip(1).Count(c => c == 'A');
				B = s.Skip(1).Count(c => c == 'B');
				if (A > B) A++;
				else B++;
				Console.WriteLine("{0} {1}", A, B);
			}
		}
	}
}

Measured memory_bytes: 5804
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    int A,B;
    A = a*b;
    B = c*d;
    if(A>B)
        printf("%d\n",A);
    else
        printf("%d\n",B);
    return 0;
}

Measured memory_bytes: 256
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "PP.hpp"
#define deb(x...) cerr << "[" << #x << "] = " << x << "\n";
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

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

int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(b / a, c) << '\n';
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int k,n,a[100000],i,sum,max;
    while (1) {
        scanf("%d %d",&n,&k);
        if (n==0&&k==0) {
            return 0;
        }
        for (i=0; i<n; i++) {
            scanf("%d",&a[i]);
        }
        sum=0;
        for (i=0; i<k; i++) {
            sum+=a[i];
        }
        max=sum;
        for (i=0; i+k<n; i++) {
            sum=sum-a[i]+a[i+k];
            if (max<sum) {
                max=sum;
            }
        }
        printf("%d\n",max);
    }
}

Measured memory_bytes: 988
D,G = map(int,input().split())
p = [0]*D
c = [0]*D
for i in range(D):
    p[i], c[i] = map(int,input().split())

ans = float('inf')

for bit in range(1 << D):
    temp_score = 0
    solved_num = 0
    uncompleted_idx = -1
    for i in range(D):
        if (bit & (1<<i)):
            temp_score += p[i]*100*(i+1) + c[i] #コンプリートする得点帯
            solved_num += p[i]
        else:
            uncompleted_idx = max(uncompleted_idx,i)


    if G <= temp_score:
        ans = min(ans,solved_num)
        continue
    # 半端に解く問題（未コンプのうち最も配点の高い問題）をシミュレーション
    if uncompleted_idx == -1:
        continue

    for j in range(p[uncompleted_idx]):
        temp_score += 100*(uncompleted_idx+1)
        solved_num += 1
        if G <= temp_score:
            ans = min(ans,solved_num)
            break
print(ans)

Measured memory_bytes: 3064
void main() {
	if(rs.count('7')) writeln("Yes");
	else writeln("No");
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 2708
#include<stdio.h>
int main(void)
{
    int n,m,i,cnt[300000]={0};
    scanf("%d",&n);
    for(i=0;i<n-1;i++){
        scanf("%d",&m);
        cnt[m]++;
    }
    for(i=1;i<n+1;i++){
        printf("%d\n",cnt[i]);
    }
    return 0;
}

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

constexpr long long mod = 1e9+7;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S1, S2;
    cin >> N;
    cin >> S1 >> S2;
    long long ans;
    int pos;
    bool same;
    if (S1[0] == S2[0]){
        ans = 3;
        pos = 1;
        same = true;
    }else{
        ans = 6;
        pos = 2;
        same = false;
    }
    for (; pos < N; ++pos){
        if (S1[pos] == S2[pos]){
            if (same){
                ans = (ans * 2) % mod;
            }else{
                same = true;
            }
        }else{
            ++pos;
            if (same){
                ans = (ans * 2) % mod;
                same = false;
            }else{
                ans = (ans * 3) % mod;

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

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	long long int N, A, B, sec, times, count;
	scanf("%lld %lld %lld", &N, &A, &B);
	sec = A + B;
	times = N / sec;

	if (A == 0){puts("0"); return 0;}

	count = A * times;
	if((N - sec * times) < A) count += N - sec * times;
	else count += A;
	printf("%lld\n", count);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int f(int n){
    if(n%2==1)return 0;
    return f(n/2)+1;
}
int n,a,ans=1000000000;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        ans=min(ans,f(a));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Part(vec, b, e) vec.begin() + b, vec.begin() + e
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(vec, s) vec.find(s) != vec.end()
#define Set_union(A, B, res) set_union(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_intersection(A, B, res) set_intersection(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_difference(A, B, res) set_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_symmetric_difference(A, B, res) set_symmetric_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));

int main() {
	string S;
	cin >> S;
	if (S == "SSS") cout << 0 << endl;
	else if (S == "RRR") cout << 3 << endl;
	else if (S == "SRR" || S == "RRS") cout << 2 << endl;
	else cout << 1 << endl;
	return 0;
}

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

int main() {
	double w;
    while(EOF != scanf("%lf",&w)){
        if(w<=48.00)cout<<"light fly"<<endl;
        else if(w<=51.00)cout<<"fly"<<endl;
        else if(w<=54.00)cout<<"bantam"<<endl;
        else if(w<=57.00)cout<<"feather"<<endl;
        else if(w<=60.00)cout<<"light"<<endl;
        else if(w<=64.00)cout<<"light welter"<<endl;
        else if(w<=69.00)cout<<"welter"<<endl;
        else if(w<=75.00)cout<<"light middle"<<endl;
        else if(w<=81.00)cout<<"middle"<<endl;
        else if(w<=91.00)cout<<"light heavy"<<endl;
        else cout<<"heavy"<<endl;
    }
	return 0;
}

Measured memory_bytes: 3204
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
 
#define int long long
#define ll long long 
#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define per(i, a, b) for(int i = a; i >= b; --i)
#define F first
#define sqr(x) ((x) * (x))
#define S second
#define make make_pair
#define pb push_back
#define sz(x) (ll)(x.size()) 
#define all(x) x.begin (), x.end ()

using namespace std;
                        
typedef unsigned long long ull;
typedef long double ld;

const int MOD = (int)1e9 + 7;
const int N = (int)2e6+ 222;
const ll INF = (ll)1e18;
const double eps = (double)1e-6;
            
int n, k, a[N], ans, pref[N], cnt[N];
vector <int> t[N], v;
int block = 400;
pair <int, int> p[N];


bool cmp (pair <int, int> a, pair <int, int> b) {
	return (a.F / block < b.F / block) || (a.F / block == b.F / block && a.S < b.S);
}
void add (int x) {
	cnt[pref[x]] ++;
}
void del (int x) {
	cnt[pref[x]] --;
}
                         

void get () {
	for (int i = 0; i <= n; ++i) v.pb(pref[i]);
	sort(all(v));
	for (int i = 1; i <= n; ++i) pref[i] = lower_bound(all(v), pref[i]) - v.begin();
	for (int i = 1; i <= n; ++i) {
		int zero = 0;    	
		p[i] = {max(i - k + 1, zero), i - 1};
	}                                                                     
	sort(p + 1, p + 1 + n, cmp);                                         
	int l = p[1].F, r = p[1].S;
	for (int i = l; i <= r; ++i) {
		add(i);
	}
	ans = cnt[pref[p[1].S + 1]];
	for (int i = 2; i <= n; ++i) {
		while (l > p[i].F) {
			l--;
			add(l);
		}
		while (l < p[i].F) {
			del(l);
			l++;
		}	
		while (r > p[i].S) {
			del(r);
			r--;
		}
		while (r < p[i].S) {
			r ++;
			add(r);
		}
		ans += cnt[pref[p[i].S + 1]];
    }     
}

void solve () {
	cin >> n >> k;
	if (k == 1) {
		cout << 0;
		return;
	}
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];		
 		a[i] --;	
 	} 
 	for (int i = 1; i <= n; ++i) {
 		pref[i] = pref[i - 1] + a[i];
 		pref[i] %= k;
 	}
 	get();  
 	cout << ans;
}

signed main () {
    #ifdef Maga                                                                                                            	
        freopen("input", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);                                              
    int t = 1;
    while (t --) {
    	solve ();
    }
    return 0;                                                 
}

Measured memory_bytes: 63856
#include <bits/stdc++.h>
using namespace std;
int n;
void solve(string s, int a, int b){
    if(a == n) cout << s << endl;
    else for(int i=0; i<=b; i++){
        string t = s; t.push_back((char)('a'+i));
        solve(t,a+1,max(b,i+1));
    }
}
int main(){ cin >> n; solve("a",1,1); }

Measured memory_bytes: 3568
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define vd vector<double>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define reverse_v(a) reverse(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    (c) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}

void Print(bool c)
{
    (c) ? (cout << "YES" << endl) : (cout << "NO" << endl);
}

//最小公倍数
template <typename T>
T gcd(T a, T b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

//最大公約数
template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}
//セカンドキー->ファーストキーの順ソート
bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

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

int eve(int x)
{
    if (x % 400 == 0)
        return 1;
    if (x % 100 == 0)
        return 0;
    if (x % 4 == 0)
        return 1;
    return 0;
}

int main(void)
{
    ll k, sp = 0;
    cin >> k;
    vs num;

    if (k < 10)
        return cout << k << endl, 0;
    rep(i, 1, 10) num.push_back(to_string(i));
    while (1)
    {
        string s = num[sp];
        int n = s.back() - '0';
        rep(i, -1, 2)
        {
            if (n + i < 0 || 9 < n + i)
                continue;
            num.push_back(s + to_string(n + i));
            if (num.size() == k)
                return cout << num.back() << endl, 0;
        }
        sp++;
    }
}

Measured memory_bytes: 5748
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<math.h>

using namespace std;

typedef long long ll;

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



signed main() {
	
	ll n;

	cin >> n;

	vector<pair<int, int> > pairs(n);

	rep(i, n) {
		cin >> pairs[i].first;
		pairs[i].second = i + 1;
	}

	sort(pairs.begin(), pairs.end());

	rep(i, n)cout << pairs[i].second << endl;

	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
const int MX = 1e5 + 100;
vector<int> ans[MX];
main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n; cin >> n;
    int ss = sqrt(n * 2);
    if(ss * (ss + 1) == n * 2) {
        cout << "Yes\n";
        cout << ss + 1 << endl;
        int ptr = 0;
        vector<int> last;
        for(int i = 1; i <= ss + 1; i ++) {
            for(int j = i; j <= ss; j ++) {
                ans[i].push_back(++ ptr);
            }
        }
        for(int i = 1; i <= ss + 1; i ++) {
            cout << ss << ' ';
            for(int j = 1; j < i; j ++) {
                cout << ans[j][i - j - 1] << ' ';
            }
            for(auto it: ans[i]) cout << it << ' ';
            cout << endl;
        }
    }
    else {
        cout << "No";
    }
}

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

int main(){
  int table[55000]={};
  for(int i=2; i*i<55000; ++i){
    if(!table[i]){
      for(int j=i*2; j<=55000; j+=i){
        table[j]=1;
      }
    }
  }

  int n;
  while(~scanf("%d",&n)){
    int i;
    for(i=n-1; table[i]; --i);
    cout << i << " ";
    for(i=n+1; table[i]; ++i);
    cout << i << endl;
  }
  return 0;
}



Measured memory_bytes: 3352
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}
	b := make([]int, n)

	for i := n; i >= 1; i-- {
		// iの倍数の箱に入ってるボールの数の合計
		sum := 0
		for j := i + i; j <= n; j += i {
			sum ^= b[j-1]
		}
		b[i-1] = sum ^ a[i-1]

	}

	ans := make([]int, 0, len(a))
	for i, e := range b {
		if e == 1 {
			ans = append(ans, i+1)
		}
	}

	fmt.Println(len(ans))
	if len(ans) != 0 {
		for _, a := range ans {
			fmt.Printf("%d ", a)
		}
		fmt.Println()

	}

}

// func main() {
// 	sc.Split(bufio.ScanWords)

// 	n := nextInt()
// 	a := make([]int, n)
// 	b := make([]int, n+1)
// 	for i := 0; i < n; i++ {
// 		a[i] = nextInt()
// 	}

// 	m := map[int]int{}
// 	for i := 1; i <= n; i++ {
// 		m[i] = n / i
// 	}

// 	for i := n; i >= 1; i-- {
// 		if m[i] == 1 {
// 			b[i] = 1
// 			continue
// 		} else {
// 			b[i] = 0
// 			continue
// 		}

// 	}

// }


Measured memory_bytes: 6144
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")

#include <cstdio>
#include <stdint.h>
#include <algorithm>
#include <functional>

#ifdef _MSC_VER
//#include <__msvc_all_public_headers.hpp>
#define getchar_unlocked getchar
#define putchar_unlocked putchar
#endif // VS

#define long long long
using namespace std;

void read(uint32_t& x)
{
	x = 0;
	int k;
	while (true)
	{
		k = getchar_unlocked();
		if (k < '0')	break;
		x = x * 10 + k - '0';
	}
}

void sread(int32_t& x)
{
	bool flag;
	x = 0;
	int k = getchar_unlocked();
	if (flag = (k == '-')) k = getchar_unlocked();

	while (true)
	{
		if (k < '0')	break;
		x = x * 10 + k - '0';
		k = getchar_unlocked();
	}
	if (flag) x *= -1;
}

void sprint(int64_t x) {
	if (x == 0) {
		putchar_unlocked('0');
		return;
	}
	if (x < 0) {
		putchar_unlocked('-');
		x *= -1;
	}
	int s = 0;
	char f[15];
	while (x) {
		f[s++] = x % 10;
		x /= 10;
	}
	while (s--)
		putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}

int32_t a[200000];
int main() {
	uint32_t n;
	read(n);
	for (size_t i = 0; i < n; i++) sread(a[i]);
	int64_t res;
	if (n & 1) {
		//Odd
		int64_t sum = 0;
		for (size_t i = 0; i < n - 1; i += 2) sum += a[i];
		res = sum;
		int64_t tailDiff = 0, tailDiffMax = 0;
		for (int i = n - 3; i >= 0; i -= 2)
		{
			sum -= a[i]; sum += a[i + 1];
			tailDiff += a[i + 2]; tailDiff -= a[i + 1];
			tailDiffMax = max(tailDiffMax, tailDiff);
			res = max(res, sum + tailDiffMax);
		}
	}
	else {
		//Even
		int64_t sum = 0;
		for (size_t i = 0; i < n; i += 2) sum += a[i];
		res = sum;
		for (int i = n - 1; i >= 0; i -= 2)
		{
			sum += a[i]; sum -= a[i - 1];
			res = max(res, sum);
		}
	}
	sprint(res);
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll need[10] = {0,2,5,5,4,5,6,3,7,6};
	ll n, m; cin >> n >> m;
	vll a(m);
	rep(i, m) cin >> a[i];
	vector<string> dp(n+10, "");
	rep(i, n){
		if (i!=0 && dp[i]=="") continue;
		rep(j, m){
			ll suf = i+need[a[j]];
			string s = dp[i]+(char)('0'+a[j]);
			if (dp[suf].size() < s.size()){
				dp[suf] = s;
			}else if(dp[suf].size() == s.size()){
				dp[suf] = max(dp[suf], s);
			}
		}
	}
	cout << dp[n] << "\n";
	return 0;
}

Measured memory_bytes: 43776
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


n = I()
p = LI()
inds = [i for i, j in enumerate(p) if i + 1 == j]
if len(inds) == 0:
    print(0)
else:
    ans = len(inds)
    counts = [1]
    cnt = 1
    for i in range(len(inds) - 1):
        if inds[i] + 1 == inds[i + 1]:
            counts[-1] += 1
        else:
            counts.append(1)
    for cnt in counts:
        ans -= cnt // 2
    print(ans)


Measured memory_bytes: 14008
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001;
const int NMAX=8;
const int mod = 1000000007;

int main()
{
  int n,m;
  cin>>n>>m;
  int ans=0;
  if(n>=2)ans+=n*(n-1)/2;
  if(m>=2)ans+=m*(m-1)/2;
  cout<<ans;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  for_each(begin(A), end(A), [](auto& x) { cin >> x; });

  ll ans = count_if(cbegin(A), cend(A), [&](auto x) { return x >= K; });

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


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

using namespace std;
const int N = 1e6 + 10;
int a[N];

int main()
{
    int n, L; cin >> n >> L;
    for (int i = 1; i <= n; i++) cin >> a[i];
    int tmp = 0;
    for (int i = 1; i < n; i++) if (a[i] + a[i + 1] >= L) tmp = i;
    if (tmp == 0) return cout << "Impossible\n", 0;
    cout << "Possible\n";
    for (int i = 1; i < tmp; i++) cout << i << " ";
    for (int j = n - 1; j > tmp; j--) cout << j << " ";
    cout << tmp << "\n";

    return 0;
}


Measured memory_bytes: 1152
//#include <map>
//#include <ctime>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
//#define scanf scanf_s
using namespace std;

int ans = 0, N;
vector<int> its;
vector<int> edgs[12000];
int pts[12000];

void apt(int th)
{
	pts[th] = its.back();
	its.pop_back();
}

void npt(int fr, int th)
{
	ans += min(pts[fr], pts[th]);
	for (int i = 0; i < edgs[th].size(); i++)
	{
		if (edgs[th].at(i) == fr)
			continue;
		apt(edgs[th].at(i));
	}
	for (int i = 0; i < edgs[th].size(); i++)
	{
		if (edgs[th].at(i) == fr)
			continue;
		npt(th, edgs[th].at(i));
	}
}

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N - 1; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		edgs[a].push_back(b);
		edgs[b].push_back(a);
	}
	for (int i = 0; i < N; i++)
	{
		int a;
		scanf("%d", &a);
		its.push_back(a);
		sort(edgs[i].begin(), edgs[i].end());
	}
	sort(its.begin(), its.end());

	apt(1);
	npt(0, 1);

	printf("%d\n", ans);
	for (int i = 1; i <= N; i++)
		printf("%d ", pts[i]);

	//system("pause");
	return 0;
}

Measured memory_bytes: 1536
import java.util.*;

public class Main {

    static final int MOD=1000000007;


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double x = sc.nextDouble();
        if(a*a*b/2<=x) {
            double h = 2 * (b - x / (a * a));
            double ans = Math.toDegrees(Math.atan(h / a));
            System.out.println(ans);
        }else{
            double h = 2*x/(a*b);
            double ans = 90-Math.toDegrees(Math.atan(h/b));
            System.out.println(ans);
        }
    }
}




Measured memory_bytes: 25172
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

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

int N;
int ans;

int main() {
	cin >> N;

	ans = 2147483647;
	for (int i = 1;i < N;i++) {
		int A = i;
		int B = N - A;

		int tmp = 0;
		for (int j = 100000;j > 0; j /= 10) {
			tmp += A / j;
			tmp += B / j;
			A %= j;
			B %= j;
		}

		ans = min(ans, tmp);
	}

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

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

//Code Short
#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define DSORT(n) sort(n.begin(),n.end())
#define QECHO(n) cout << n
#define QECHOS(n) cout << n << " "

//Define Math
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
    int a,b,c;
    cin >> a >> b >> c;
    QECHO(a+b+c-max({a,b,c}));QECHO("\n");
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}

vector < int > SOE(int min, int max) {
  if (min < 2) min = 2;
  vector < int > int_array;
  for (int i = min; i <= max; i++) int_array.push_back(i);
  vector < int > sosu;
  double stop = sqrt(max);
  while (true) {
    sosu.push_back(int_array.front());
    int_array.erase(int_array.begin());
    if (stop < (double)(sosu.back())) break;
    for (int i = 0; i < (int) int_array.size(); i++) {
      if (int_array[i] % sosu.back() == 0)
        int_array.erase(int_array.begin() + i);
    }
  }
  sosu.insert(sosu.end(), int_array.begin(), int_array.end());
  return sosu;
}

int MinCM(int a, int b) {
  int c = a * b;
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return c / b;
}

int MaxCD(int a, int b) {
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
vector < int > igets(int N) {
  vector < int > A;
  int temp;
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    A.push_back(temp);
  }
  return A;
}

ll nPr(ll n, ll r) {
  ll ans = 1;
  r = n - r;
  while (n != r) {
    ans *= n;
    --n;
  }
  return ans;
}

ll nE(ll n) {
  return nPr(n, n);
}

ll nCr(ll n, ll r) {
  if (r == 0) return -1;
  else {
    if (0 != n - r && n - r < r) r = n - r;
    return nPr(n, r) / nE(r);
  }
}

Measured memory_bytes: 256
import scala.util.control.Breaks

object Main{
  def main(args: Array[String]) {
    val sc = new java.util.Scanner(System.in)
    var s = sc.next

    s = s.reverse

    val words = Seq("dream", "dreamer", "erase", "eraser").map{_.reverse}

    var flag = true
    val b = new Breaks
    b.breakable { while (flag) {
      flag = false
      words.foreach{ w =>
        if (s.take(w.size) == w) {
          s = s.drop(w.size)
          flag = true
        }
      }
    } }
    if (s.size == 0)
      println("YES")
    else
      println("NO")
  }
}

Measured memory_bytes: 116192
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
long long n,a[3030],dp[3030][3030];
long long dfs(long long x,long long y)
{
	if(x==y)
	{
		dp[x][y]=a[x];
		return dp[x][y];
	}
	if(dp[x][y]!=1e15)
	{
		return dp[x][y];
	}
	dp[x][y]=max(a[x]-dfs(x+1,y),a[y]-dfs(x,y-1));
	return dp[x][y];
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<3010;i++)
	{
		for(int j=0;j<3010;j++)
		{
			dp[i][j]=1e15;
		}
	}
	cout<<dfs(0,n-1)<<endl;
	return 0;
}

Measured memory_bytes: 72064
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
int a[100];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  vector<bool> check(8, false);
  int ans = 0;
  int sum = 0;
  REP(i, n) {
    int b;
    cin >> b;
    a[i] = b / 400;
    if(a[i] >= 8) sum++;
    else if(!check[a[i]]) {
      ans++;
      check[a[i]] = true;
    } 
  }

  cout << ((sum >= 1 && ans == 0) ? 1 : ans) << " ";
  cout << ans + sum << endl;
}


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

 int main(){
  
  int a,b,c ;
  cin>>a>>b>>c;
  if( a > b) swap(a, b);
  if( b > c) swap(b, c);
  if( a > b) swap(a, b);

  cout<<a<<" "<<b<<" "<<c<<endl;
  return 0;
}




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



int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
    }
    
    map<int,int> m;
    
    long int ans = 0;
    rep(i,n) {
        ans += m[i-a[i]];
        m[i+a[i]]++;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 20960
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main()
{
    while (true) {
        int n, m, p;
        cin >> n >> m >> p;
        if (n == 0 && m == 0 && p == 0) {
            return 0;
        }

        vector<int> v;
        for (int i = 0; i < n; ++i) {
            int x;
            cin >> x;
            v.push_back(x);
        }

        auto bet = accumulate(begin(v), end(v), 0) * 100;
        auto remain = bet * (100 - p);
        cout << (v[m - 1] == 0 ? 0 : remain / v[m - 1] / 100) << endl;
    }
}

Measured memory_bytes: 3012
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  long double N, K; cin >> N >> K;
  long double p = 0;
  for (int i = 1; i <= N; ++i) {
    if (i >= K) {
      p += 1.0;
    } else {
      LL cnt = ceil(log2(K / i));
      p += 1.0 / (pow(2, cnt));
    }
  }
  double p2 = p / N;
  printf("%.12f\n", p2);
}


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

int main(){
	int m, h;
    string str, s1;
    while (1){
        cin >> str;
        if (str == "-") break;
        else {
            cin >>m;
            for (int i = 0; i < m; i++){
                cin >> h;
                s1 = str.substr(h);
                str = str.erase(h);
                str = s1 + str;

            }
        }
        cout << str << endl;
    }
    


}



Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<set> 
#include<math.h>
using ll = long long;
int main(){
  int n;
  cin>>n;
  if(n%10==3)cout<<"bon"<<endl;
  else if(n%10==0||n%10==1||n%10==6||n%10==8)cout<<"pon"<<endl;
  else cout<<"hon"<<endl;
  
  
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    vi v(3);
    rep(i, 3) cin >> v[i];
    sort(rall(v));
    cout << v[0] * 10 + v[1] + v[2] << endl;
    return 0;
}

Measured memory_bytes: 256
main(){
    int w,h,x,y,r;
    scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
    if( x-r<0 || y-r<0 || w<x+r || h<y+r ){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
}


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

void test_case(){

}

int main(){

	for(int i=1;i<=5;i++){
		int x;
		cin >> x;
		if(x==0){
			cout << i << endl;
			return 0;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3592
#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>;

int main(){
	int x,a;
	cin >> x >> a;
	if(x < a) cout << 0 << endl;
	else cout << 10 << endl;
}

// cout << fixed << setprecision(15) <<  << endl;

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))

int main(){
    int d[17]; int n[100]={0}; int cnt=0,t=0;
    queue<int> q; rep(i,17)d[i]=0;
    for(;cnt<100;t++){
        if(t%5==0 && t<500)q.push(t/5);
        while(!q.empty()){
            int v=q.front();
            int num=v%5==1?5:2;
            int g=0;
            rep(j,18-num){
            	if(d[j]<1 && !g){g=1;reps(k,1,num-1){
                    	if(d[j+k]>0)g=0;
                    }
                    if(g){rep(k,num)d[j+k]=17*(v%2)+3*(v%3)+19;}
                }
            }
            if(!g)break;
            q.pop();
            n[v]=t-v*5;
            cnt++;
        }
        rep(i,17)if(d[i]>0)d[i]--;
    }
    while(~scanf("%d",&t))printf("%d\n",n[t]);
    return 0;
}

Measured memory_bytes: 3172
n,m=map(int,input().split())
s=[]
for i in range(m):
    a,b=map(int,input().split())
    if a==1 or a==n:s.append(b)
    elif b==1 or b==n:s.append(a)
ls=len(s)
s=list(set(s))
if ls==len(s):print("IMPOSSIBLE")
else:print("POSSIBLE")

Measured memory_bytes: 23288
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}


int main(void) {
    int i,j;
    int n, k;
    cin >> n >> k;
    vi h(n);
    rep(i,n) cin >> h[i];
    sort(all(h));
    int ans = INF;
    rep(i,n-k+1) ans = min(ans,h[i+k-1]-h[i]);
    cout << ans << endl;

}


Measured memory_bytes: 640
#include <stdio.h>

int main( void ) {
	int i, n, p, have[ 50 ], r;

	for ( ; scanf( "%d %d", &n, &p ), r = p; printf( "%d\n", i ) ) {
		for ( i = 0; i < 50; i++ )
			have[ i ] = 0;

		for ( i = 0; ; i = ( i + 1 ) % n ) {
			if ( r ) {
				r--;
				have[ i ]++;
			} else {
				r = have[ i ];
				have[ i ] = 0;				
			}

			if ( r == p )
				break;
		}
	}

	return 0;
}

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

int n;
double p[3002], dp[3002][3002], ans=0;

int main(){
	memset(dp,0,sizeof dp);
	cin >> n;
	for (int i=0;i<n;i++) cin >> p[i];
	dp[0][0]=1-p[0];
	dp[0][1]=p[0];
	for (int i=1;i<n;i++){
		for (int j=0;j<=i+1;j++){
			if (j==0) dp[i][j]=dp[i-1][j]*(1-p[i]);
			else dp[i][j]=(dp[i-1][j]*(1-p[i]))+(dp[i-1][j-1]*p[i]);
		}
	}
	for (int i=0;i<=n;i++){
		if (i>n/2) ans+=dp[n-1][i];
	}
	cout << fixed << setprecision(9) << ans << "\n";
}

Measured memory_bytes: 70656
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define watch(x) cout<<"->"<<#x<<" : "<<x<<endl;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c)) 
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef unsigned long long llu;

const int INF = 1e9;
const int MOD = 1e9+7;
const double PI = 2*acos(0.0);
#define int long long
signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin>>n;
	--n;
	int res = n * (n+1) / 2; 	
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
int main() {
	int n; cin >> n;
	int a = (n + 1) / 2;
	cout << (double) a/n << endl;
	return 0;
}


Measured memory_bytes: 3744
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <array>
#include <cmath>
#include <queue>
#include <stack>
#include <numeric>
using namespace std;
int main() {
	string n;
	cin >> n;
	if (n[0] == '7' || n[1] == '7' || n[2] == '7') cout << "Yes" << endl;
	else  cout << "No" << endl; 	
}

Measured memory_bytes: 3624
import std.stdio, std.conv, std.string, std.algorithm.searching, std.algorithm.iteration, std.algorithm.sorting, std.algorithm.comparison;

void main()
{
    auto input = readln().strip.split.to!(int[]);
    auto N = input[0];
    auto K = input[1];

    int[] hList = [];

    foreach(i; 0..N)
    {
        hList ~= readln.strip.to!int;
    }
    hList.sort();
    int minH=int.max;
    for(int i = 0;i < N-K+1;i++)
    {
        minH = min(hList[K-1+i] - hList[i], minH);
    }
    writeln(minH);
}


Measured memory_bytes: 1660
#include <iostream>
#include <set>
#include <algorithm>

int main()
{
    int n{}, m{};
    std::set<int> evens;

    std::cin >> n >> m;;
    int x{};
    for (int i = 0; i < n; i++) {
        std::cin >> x;
        evens.insert(x);
    }
    const auto itr = std::max_element(evens.begin(), evens.end());
    const auto maxeven = *itr;
    evens.erase(itr);

    int result{};
    for (int i = 0; i < 1000000000; i++) {
        const auto x = maxeven / 2 + maxeven * i;
        if (x > m) {
            break;
        }
        const auto found = std::all_of(evens.begin(), evens.end(), [x](auto val) {
            const auto tmp = x - val / 2;
            return (tmp >= 0 && tmp % val == 0);
        });
        if (found) result++;
    }
    std::cout << result << std::endl;
    return 0;
}


Measured memory_bytes: 4992
function main(input) {
  input=input.trim();
  var arr = input.split("").map((n) => (n));
  var ans = 0

  if(arr[0]=="A"){
    ans++
  }

  var temp=0;
  var memo=0;
  for(var i=2; i<arr.length-1; i++){
    if(arr[i]=="C"){
      temp++;
      memo=i
    }
  }
  if(temp==1){
    ans++
  }

  if(ans==2){
    arr.splice(0,1);
    arr.splice(memo-1,1);
    if(/[A-Z]/.test(arr)==false){
      ans++
    }
    if(ans==3){
      console.log("AC");
    }else{
      console.log("WA");
    }
  }else{
    console.log("WA");
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 7372
#include<stdio.h>
int dp[50];

int fib(int n)
{
  if(n == 0 || n == 1) return dp[n] = 1;
  if( dp[n] != -1 ) return dp[n];
  return dp[n] = fib( n - 1 ) + fib( n - 2);

}

int main()
{
  int i, n;
  for( i = 0; i< 50 ; i++)
  {
    dp[i] = -1;
  }
  scanf("%d", &n);
  printf("%d\n",fib(n));
  return 0;
}


Measured memory_bytes: 2112
use std::collections::BTreeMap;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let mut map = BTreeMap::new();
    for _ in 0..n {
        let mut s = sc.read::<String>().bytes().collect::<Vec<_>>();
        s.sort();
        let s = String::from_utf8(s).unwrap();
        *map.entry(s).or_insert(0) += 1;
    }

    let mut ans: u64 = 0;
    for (_, c) in map.into_iter() {
        ans += c * (c - 1) / 2;
    }
    println!("{}", ans);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 10492
/*
 *  Author :: Kattu37
 */

#include<bits/stdc++.h>
using namespace std;

#define mod 1000000007
#define PI 3.14159265358979

typedef long long ll;


int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll a;
	double b;

	cin >> a >> b;
	int c = b * 100;
	cout.precision(8); cout << fixed;
	cout << (ll)floor( (a * c ) / 100.0) << "\n";

	return 0;
}

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

int main(void){
	char str1[5001]={0},str2[5001]={0};
	str1[0]='0';
	str2[0]='0';
	
	while(scanf("%s",&str1[1])!=EOF){
		int dp[2][5002]={0};
		int i,j,st1,st2,max=0,f=0;
		
		scanf("%s",&str2[1]);
		
		st1=strlen(str1);
		st2=strlen(str2);
		
		for(i=1;i<st1;i++){
			for(j=1;j<st2;j++){
				if(str1[i]==str2[j]){
					dp[f][j]=dp[1-f][j-1]+1;
				}
				else dp[f][j]=0;
				
				if(dp[f][j]>max)max=dp[f][j];
			}
			if(f)f=0;
			else f=1;
		}
		printf("%d\n",max);
	}
	
	return 0;
}

Measured memory_bytes: 816
N = int(input())
num = list(map(int, input().split()))
answer = 1
if 0 in num:
  print(0)
else:
  for i in range(N):
    if answer*num[i] <= 10**18:
      answer = answer*num[i]
      if i == N-1:
        print(answer)
    else:
      print(-1)
      break

Measured memory_bytes: 21480
#include <cmath>
#include <iostream>

using namespace std;

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

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

  long costs[n];
  costs[0] = 0;
  for (int i = 1; i < n; i++) {
    costs[i] = costs[i - 1] + abs(hs[i] - hs[i - 1]);
    for (int j = 2; j <= k; j++) {
      if (i - j < 0) break;
      costs[i] = min(costs[i], costs[i - j] + abs(hs[i] - hs[i - j]));
    }
  }

  cout << costs[n - 1] << endl;
  return 0;
}



Measured memory_bytes: 1408
N,A,B = map(int, input().split())
S = list(input())
cnt_all = 0
cnt_over = 0
for i in range(N):
    if S[i] == 'a':
        if cnt_all < A+B:
            print("Yes")
            cnt_all += 1
        else:
            print("No")
    elif S[i] == 'b':
        if cnt_all < A+B and cnt_over < B:
            print("Yes")
            cnt_all += 1
            cnt_over += 1
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 56824
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  ll a, b, c; cin >> a >> b >> c;
  bool ok;
  if (a+b>=c) ok = false;
  else {
    if (4*a*b<(c-a-b)*(c-a-b)) ok = true;
    else ok = false;
  }
  cout << (ok? "Yes" : "No") << endl;




  
  
  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 3592
from collections import deque
from heapq import heappush, heappop
N, M, K, S = map(int, input().split())
P, Q = map(int, input().split())
C = [int(input())-1 for i in range(K)]
G = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split()); a -= 1; b -= 1
    G[a].append(b)
    G[b].append(a)

D = [N]*N
que = deque()
for c in C:
    D[c] = 0
    que.append(c)
while que:
    v = que.popleft()
    d = D[v]
    for w in G[v]:
        if D[w] != N:
            continue
        D[w] = d+1
        que.append(w)

INF = 10**18
dist = [INF]*N
dist[0] = 0
que = [(0, 0)]
while que:
    cost, v = heappop(que)
    if dist[v] < cost:
        continue
    c += 1
    for w in G[v]:
        if D[w] == 0:
            continue
        if D[w] <= S:
            if cost + Q < dist[w]:
                dist[w] = cost + Q
                heappush(que, (cost + Q, w))
        else:
            if cost + P < dist[w]:
                dist[w] = cost + P
                heappush(que, (cost + P, w))
print(dist[N-1] - (Q if D[N-1] <= S else P))



Measured memory_bytes: 34856
#include<stdio.h>

int main() {
  int n, i, j, num[7] = {};
  double height[41] = {};
  while(scanf("%d", &n) != EOF) {
    for (i = 1; i < n + 1; i += 1) {
      scanf("%lf", &height[i]);
    };

    for (i = 1; i < n + 1; i += 1) {
      if (height[i] < 165.0) {
        num[1] += 1;
      } else if (height[i] >= 165.0 && height[i] < 170.0) {
        num[2] += 1;
      } else if (height[i] >= 170.0 && height[i] < 175.0) {
        num[3] += 1;
      } else if (height[i] >= 175.0 && height[i] < 180.0) {
        num[4] += 1;
      } else if (height[i] >= 180.0 && height[i] < 185.0) {
        num[5] += 1;
      } else if (height[i] >= 185.0) {
        num[6] += 1;
      };
    };

    if (n == 0) {
      for (i = 1; i < 7; i += 1) {
        printf("%d:\n", i); 
      };
    } else {
      for (i = 1; i < 7; i += 1) {
        printf("%d:", i); 
        for (j = 0; j < num[i]; j += 1) {
          printf("*");
        };
        printf("\n");
        num[i] = 0;
      };
    };
  };

  return 0;
}

Measured memory_bytes: 640