akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const ll P = 1e9+7;

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

	vector<string> u;
	u.push_back("");
	for(int i=0; i<3; i++){
		vector<string> v;
		for(string s: u){
			for(char a: "ACGT"){
				if(a) v.push_back(s+a);
			}
		}
		u = vector<string>(v);
	}

	vector<vector<ll> > dp(2, vector<ll>(u.size()));
	for(int j=0; j<u.size(); j++){
		if(u[j]=="AGC"||u[j]=="GAC"||u[j]=="ACG") continue;
		dp[0][j] = 1;
	}
	for(int i=0; i<N-3; i++){
		dp[(i+1)%2] = vector<ll>(u.size());
		for(int j=0; j<u.size(); j++){
			for(char c: "ACGT"){
				if(!c) continue;
				string x = u[j]+c;
				string y = x.substr(1);
				if(y=="AGC"||y=="GAC"||y=="ACG"||
					(x[0]=='A'&&x[2]=='G'&&x[3]=='C')||
					(x[0]=='A'&&x[1]=='G'&&x[3]=='C')){
					continue;
				}
				int n = find(u.begin(), u.end(), y)-u.begin();
				dp[(i+1)%2][n] += dp[i%2][j];
				dp[(i+1)%2][n] %= P;
			}
		}
	}

	ll ans = 0;
	for(int j=0; j<u.size(); j++){
		//cout << u[j] << endl;
		ans += dp[(N-3)%2][j];
	}
	cout << ans%P << endl;

	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int n;
const int inf = 0x3f3f3f3f;
long long int dp[100001][15];
vector<int> c;

long long solve(int n, int pos){
	if(n==0) return 0;
	if(n<0) return inf;
	if(pos==c.size()) return inf;
	if(dp[n][pos]) return dp[n][pos];
	return dp[n][pos] = min(1+solve(n-c[pos], pos), solve(n, pos+1));
}


int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	c.push_back(1);
	c.push_back(6);
	c.push_back(36);
	c.push_back(216);
	c.push_back(1296);
	c.push_back(7776);
	c.push_back(46656);
	c.push_back(279936);
	c.push_back(9);
	c.push_back(81);
	c.push_back(729);
	c.push_back(6561);
	c.push_back(59049);
	c.push_back(531441);
	cout << solve(n, 0);
	return 0;
}



Measured memory_bytes: 16640
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <vector>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

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

int main()
{
  int n;
  cin >> n;
  vs w(n);
  for (string &s : w)
  {
    cin >> s;
  }
  bool ok = true;
  rep(i, n - 1)
  {
    if (w.at(i).at(w.at(i).size() - 1) != w.at(i + 1).at(0))
    {
      ok = false;
      break;
    }
  }
  sort(w.begin(), w.end());
  rep(i, n - 1)
  {
    if (w.at(i) == w.at(i + 1))
    {
      ok = false;
      break;
    }
  }
  if (ok)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}

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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m = M) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

int exp(int n, int k) {
  if (k == 0) return 1;
  if (k == 1) return n;
  int ax = exp(n, k / 2);
  ax = mod(ax * ax);
  if (k % 2) ax = mod(ax * n);
  return ax;
}

int gcd(int a, int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
//#define MULTIPLE_TEST_CASE
void solution() {
  int x;
  cin >> x;
  cout << 1 - x << endl;
}

int32_t main() {
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  while (t--) solution();
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define N 200005
using namespace std;
int n,x,y;
int xx[N],yy[N];
int head[N],ver[N*2],nxt[N*2],tot;
void add(int a,int b)
{
	tot++;nxt[tot]=head[a];head[a]=tot;ver[tot]=b;return ;
}
int dis[N];
int f[N][20];
void dfs(int x,int fa)
{
	for(int i=head[x];i;i=nxt[i])
	{
		if(ver[i]==fa)continue;
		dis[ver[i]]=dis[x]+1;
		f[ver[i]][0]=x;
		dfs(ver[i],x);
	}
	return ;
}
int ans;
bool v[N];
int lca(int a,int b)
{
	if(dis[a]<dis[b])swap(a,b);
	for(int i=19;i>=0;i--)
	{
		if(dis[f[a][i]]>=dis[b])a=f[a][i];
	}
	if(a==b)return a;
	for(int i=19;i>=0;i--)
	{
		if(f[a][i]!=f[b][i])
		{
			a=f[a][i];b=f[b][i];
		}
	}
	return f[a][0];
}
int calc(int a,int b)
{
	return dis[a]+dis[b]-2*dis[lca(a,b)];
}
void dffs(int x,int fa,int now)
{
	if(ans!=-1)ans=max(ans,(dis[x]-1)*2);
	for(int i=head[x];i;i=nxt[i])
	{
		if(ver[i]==fa)continue;
		if(calc(x,ver[i])>=3)
		{
			ans=-1;
			continue;
		}
		if(dis[ver[i]]<=now+1)continue;
		dffs(ver[i],x,now+1);
	}
	return ;
}

int main()
{
	scanf("%d%d%d",&n,&x,&y);
	int t1,t2;
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&xx[i],&yy[i]);
	}
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&t1,&t2);
		add(t1,t2);add(t2,t1);
	}
	dis[y]=1;dfs(y,-1);
	for(int i=1;i<=19;i++)
	{
		for(int j=1;j<=n;j++)
		{
			f[j][i]=f[f[j][i-1]][i-1];
		}
	}
	tot=0;memset(head,0,sizeof(head));
	for(int i=1;i<n;i++)
	{
		add(xx[i],yy[i]);add(yy[i],xx[i]);
	}
	dffs(x,-1,1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 30592
import java.util.*;

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

		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] P = new int[N];
		for(int i=0; i<N; i++)
			P[i] = sc.nextInt();
		
		int ans = 1;
		TreeSet<Integer> ts = new TreeSet<>();
		for(int i=0; i<N; i++) {
			ts.add(P[i]);
			if(i>=K) {
				if(ts.last()!=P[i] || ts.first()!=P[i-K]) {
					ans++;
				}
				ts.remove(P[i-K]);
			}
		}
		
		int notChange=0;
		int cnt=1;
		for(int i=1; i<N; i++) {
			if(P[i-1]<P[i]) {
				cnt++;
				if(cnt==K)
					notChange++;
			} else {
				cnt=1;
			}
		}
		
		System.out.println(ans - (notChange>=2 ? notChange-1 : 0));
		sc.close();
	}
}


Measured memory_bytes: 69664
// A - RGB Cards

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	int r, g, b;
	cin >> r >> g >> b;

	string ans;

	if ((100*r + 10*g + b) % 4 == 0) ans = "YES";
	else ans = "NO";

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
from math import atan2, hypot
from itertools import accumulate
N = int(readline())
XY = [tuple(map(int, readline().split())) for _ in range(N)]
XY.sort(key = lambda x: atan2(*x))
X, Y = list(map(list, zip(*XY)))
X, Y = list(accumulate(X*2)), list(accumulate(Y*2))
ans = 0
for i in range(N):
    for j in range(1, N+1):
        ans = max(ans, hypot(X[i+j]-X[i], Y[i+j]-Y[i]))
print(ans)

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

int main() {
	int n, m, points, penals;
	points = penals = 0;
	cin >> n >> m;
	vector<int> acp(n), pin(n);
	while (m--) {
		int p; string c;
		cin >> p >> c;
		if (c == "AC") {
			if (!acp[p-1]) {
				acp[p-1] = 1;
				++points;
				penals += pin[p-1];
			}
		} else if (c == "WA") {
			++pin[p-1];
		}
	}
	
	cout << points << ' ' << penals << endl;
	return 0;
}


Measured memory_bytes: 1024
N = int(input())
if (N&1)==0: ans = 0
if   N<3*5* 7: ans = 0
elif N<3*5* 9: ans = 1
elif N<3*5*11: ans = 2
elif N<3*7* 9: ans = 3
elif N<3*5*13: ans = 4
else:          ans = 5
print(ans)


Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main() {
  long long h;
  scanf("%lld", &h);

  long long m = log2(h);

  long long result = pow(2, m+1) - 1;
  
  cout << result << endl;
  
  return 0;
}


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

struct Node {
    Node(std::vector<int> &&n): neighbors(n) {}
    std::vector<int> neighbors;
    bool is_searched = false;
};

struct WFSData {
    int node;
    int distance;
};

int main() {
    int n, x, y;
    std::cin >> n >> x >> y;

    auto graph = std::vector<Node>();
    graph.reserve(n);

    graph.emplace_back(Node(std::vector<int>(1, 1)));

    for(int i = 1; i < n - 1; ++i) {
        auto neighbors = std::vector<int>();
        neighbors.reserve(2);
        neighbors.push_back(i - 1);
        neighbors.push_back(i + 1);
        const auto node = Node(std::move(neighbors));
        graph.emplace_back(node);
    }

    graph.emplace_back(Node(std::vector<int>(1, n - 2)));

    graph[x - 1].neighbors.push_back(y - 1);
    graph[y - 1].neighbors.push_back(x - 1);

    auto answer = std::unordered_map<int, int>();

    for(int i = 0; i < n - 1; ++i) {
        auto que = std::queue<WFSData>();
        que.push(WFSData{i, 1});

        graph[i].is_searched = true;

        while(!que.empty()) {
            const auto d = que.front();
            que.pop();

            for(const auto n: graph[d.node].neighbors) {
                if(graph[n].is_searched) {
                    continue;
                }
                graph[n].is_searched = true;
                que.push(WFSData{n, d.distance + 1});
                if(n > i) {
                    ++answer[d.distance];
                }
            }
        }

        for(auto &node: graph) {
            node.is_searched = false;
        }
    }

    for(int k = 1; k < n; ++k) {
        std::cout << answer[k] << std::endl;
    }

    return 0;
}


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

namespace B {
    class Program {
        static void Main(string[] args) {
            var bingoMap = new List<int>();

            foreach (var _ in Enumerable.Range(0, 3))
            {
                bingoMap.AddRange(Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList());
            }

            var completeTimes = int.Parse(Console.ReadLine());
            var indexs = new List<int>();

            foreach (var _ in Enumerable.Range(0, completeTimes))
            { 
                var input = int.Parse(Console.ReadLine());
                indexs.Add(bingoMap.IndexOf(input) + 1);
            }

            if (CheckBingo(indexs))
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }

        static bool CheckBingo(List<int> indexs)
        {
            if (indexs.Contains(1)) 
            {
                if (indexs.Contains(2))
                    if (indexs.Contains(3))
                        return true;
                if (indexs.Contains(4))
                    if (indexs.Contains(7))
                        return true;
                if (indexs.Contains(5))
                    if (indexs.Contains(9))
                        return true;
            }

            if (indexs.Contains(2))
                if (indexs.Contains(5))
                    if (indexs.Contains(8))
                        return true;
            if (indexs.Contains(4))
                if(indexs.Contains(5))
                    if (indexs.Contains(6))
                        return true;

            if (indexs.Contains(3))
            {
                if(indexs.Contains(6))
                    if (indexs.Contains(9))
                        return true;
                if(indexs.Contains(5))
                    if (indexs.Contains(7))
                        return true;
            }

            if (indexs.Contains(4))
                if (indexs.Contains(5))
                    if (indexs.Contains(6))
                        return true;
            if (indexs.Contains(7))
                if (indexs.Contains(8))
                    if (indexs.Contains(9))
                        return true;

            return false;
        }
    }
}


Measured memory_bytes: 13280
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut a = read_vec::<i64>();
    a.sort();
    let mut found = HashSet::new();
    let primes = get_primes(a.iter().max().unwrap() + 1);

    let mut ans = 0;
    'outer: for i in 0..n {
        let num = a[i];
        if i + 1 <= n - 1 && num == a[i + 1] {
            found.insert(num);
            continue 'outer;
        }

        for factor in collect_all_factors(&factorize(num, &primes)) {
            if found.contains(&factor) {
                found.insert(num);
                continue 'outer;
            }
        }

        ans += 1;
        found.insert(num);
    }
    println!("{}", ans);
}

fn get_primes(n: i64) -> Vec<i64> {
    let mut is_prime = vec![true; n as usize + 1];
    let mut primes = Vec::new();
    is_prime[0] = false;
    is_prime[1] = false;

    for i in 2..n + 1 {
        if is_prime[i as usize] {
            primes.push(i);
            let mut j = 2 * i;
            while j < n {
                is_prime[j as usize] = false;
                j += i;
            }
        }
    }
    primes
}

fn factorize(mut num: i64, primes: &Vec<i64>) -> std::collections::HashMap<i64, i64> {
    // max_primes >= (num)^(1/2)
    let mut dict = std::collections::HashMap::new();
    for &p in primes.iter() {
        while num % p == 0 {
            *dict.entry(p).or_insert(0) += 1;
            num /= p;
        }
        if num == 1 {
            break;
        }
        if p * p > num {
            *dict.entry(num).or_insert(0) += 1;
            break;
        }
    }
    if num != 1 {
        dict.insert(num, 1);
    }
    dict
}

fn pow(n: i64, mut p: i64) -> i64 {
    let mut r = n;
    let mut ret = 1;
    while p > 0 {
        if p % 2 == 0 {
            r = r * r;
            p /= 2;
        } else {
            ret = ret * r;
            p -= 1;
        }
    }
    ret
}

fn collect_all_factors(dict: &std::collections::HashMap<i64, i64>) -> Vec<i64> {
    let mut ret = vec![1];
    for &key in dict.keys() {
        let mut new = ret.clone();

        for coef in 1..dict[&key] + 1 {
            let coef_1 = pow(key, coef);
            for &num in ret.iter() {
                new.push(num * coef_1);
            }
        }
        ret = new;
    }
    ret
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 9432
import sys
input = sys.stdin.readline
from collections import *

def era(n): #n以下の素数を列挙
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False
    
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]:
            continue
        
        for j in range(2*i, n+1, i):
            is_prime[j] = False
    
    return [i for i in range(n+1) if is_prime[i]]

N = int(input())
p = era(55555)
ans = []

for pi in p:
    if pi%5==1 and len(ans)<N:
        ans.append(pi)

print(*ans)

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

int main() {
  int x, y;
  cin >> x >> y;

  rep(i, x) {
    int j = x - i;
    if ((i * 2) + (j * 4) == y) {
      cout << "Yes" << '\n';
      return 0;
    }
  }
  cout << "No" << '\n';
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  string S;
  cin>>N>>S;
  int count=0;
  for(int i=2;i<N;i++){
  if(S.at(i-2)=='A'&&S.at(i-1)=='B'&&S.at(i)=='C'){
  count++;
  
  }
  
  }
  cout<<count<<endl;
}


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

public class Main {

    private void solve() {
        int N = sc.nextInt();
        int M = sc.nextInt();
        int X = sc.nextInt();

        int[][] A = new int[N][M];
        int[] C = new int[N];
        for (int i = 0; i < N; i++) {
            C[i] = sc.nextInt();
            for (int j = 0; j < M; j++) {
                A[i][j] = sc.nextInt();
            }
        }

        int min = Integer.MAX_VALUE;
        int bitMax = 1 << N;
        for (int mask = 0; mask < bitMax; ++mask) {
            int[] l = new int[M];
            int c = 0;
            for (int i = 0; i < N; i++) {
                if ((mask & (1 << i)) == 0) {
                    continue;
                }

                c += C[i];
                for (int j = 0; j < M; j++) {
                    l[j] += A[i][j];
                }
            }

            boolean ok = true;
            for (int j = 0; j < M; j++) {
                if (l[j] < X) {
                    ok = false;
                    break;
                }
            }

            if (ok) {
                min = Math.min(c, min);
            }
        }

        if (min == Integer.MAX_VALUE) {
            out.println(-1);
        } else {
            out.println(min);
        }
    }

    private static PrintWriter out;
    private static MyScanner sc;

    private static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        private MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] args) {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        sc = new MyScanner();
        new Main().solve();
        out.close();
    }
}


Measured memory_bytes: 34544
import java.util.*;
import java.lang.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int length = scan.nextInt();
        int[] numbers = new int[length];
        for (int i = 0; i < length; i++){
            numbers[i] = scan.nextInt();
        }
        int[] result = new int[length];
        
        if (length < 3){
            System.out.println( numbers[1] - numbers[0]);
        }
        else{
            result[0] = 0;
            result[1] = (int)Math.abs(numbers[1] - numbers[0]);
            for (int i = 2; i < length; i++){
                result[i] = Math.min(result[i - 1] + (int)Math.abs(numbers[i] - numbers[i -1]),result[i - 2] + (int)Math.abs(numbers[i] - numbers[i - 2]));
            }
            System.out.println(result[length -1]);
        }
        scan.close();
    }
}

Measured memory_bytes: 50636
N = int(input())
b = [int(x) for x in input().split()]

if sum([(x > idx + 1) for (idx, x) in enumerate(b)]) >= 1:
  print(-1)
else:
  list_ = []
  while len(b) > 0:
    for idx, c in enumerate(b):
      if idx+1 == c:
        del_idx = idx
    list_.append(b.pop(del_idx))

  for c in list_[::-1]:
      print(c)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll=int_fast64_t;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n,a;
    in>>n;
    vector<int> b(n+1),c(n+1),s(n+1);
    fr(i,n) in>>a,++b[a];
    Fr(i,n) ++c[b[i]];
    iFr(i,n) s[i-1]=s[i]+c[i];
    fr(i,n) s[i+1]+=s[i];
    Fr(i,n){
        int l=0,r=n/i+1,m;
        while(r-l>1){
            m=(l+r)>>1;
            if(s[m-1]<m*i) r=m;
            else l=m;
        }
        cout<<l<<endl;
    }
}

Measured memory_bytes: 4352
#include<stdio.h>

int main()
{
    int a,b,c,x,y,z;
    scanf("%d%d%d",&a,&b,&c);
    if(1<=a && a<=10000 && 1<=b && b<=10000 && 1<=c && c<=10000)
    {
        if(a>b && a>c || a==c && a>c){
                x=b+c;
                printf("%d",x);
        }
        if(b>a && b>c || a==b && b>c){
            y=a+c;
            printf("%d",y);
        }
        if(c>a && c>b || a==b && c>b || a==b && a==c){
            z=a+b;
            printf("%d",z);
        }
    }

return 0;
}

Measured memory_bytes: 1708
#include <iostream>
#include<iomanip>
using namespace std;
int main(void){
    double r;
    cin >> r;
    cout << fixed << setprecision(5);
    cout << r*r*3.141592653589;
    cout << " ";
    cout << 2*r*3.141592653589;
    cout << endl;
}


Measured memory_bytes: 3208
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;

int dp[3100][3100];

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n,t;
    cin >> n >> t;
    vector<pint> p(n);
    rep(i, n){
        cin >> p[i].fs >> p[i].sc;
    }
    sort(all(p));
    int ans = 0;
    rep(i, n){
        rep(j, t){
            chmax(dp[i + 1][j], dp[i][j]);
            if(j < p[i].fs) continue;
            chmax(dp[i + 1][j], dp[i][j - p[i].fs] + p[i].sc);
        }
        int now = dp[i][t - 1] + p[i].sc;
        chmax(ans, now);
    }
    print(ans);



}


Measured memory_bytes: 39988
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
int main() {
    int n, m; cin >> n >> m;
	int b[15];int p[15]; vector<int>s;
	rep(i, n) {
		cin >> b[i];
		if (b[i])s.push_back(i);
	}
	rep(i, m) {
		cin >> p[i];
	}
	int now = 0; bool f = false;
	vector<int>t,u;
	rep(i, m) {
		rep(j, p[i]) {
			if (f) {
				t.push_back(now);
			}
			else {
				u.push_back(now);
			}
			now++;
		}
		if (f)f = false;
		else f = true;
	}
	int mi = 10000; int len = s.size();
	if (len==(int)t.size()) {
		int sum = 0;
		rep(i, len) {
			sum += abs(s[i] - t[i]);
		}
		mi = min(mi, sum);
	}
	if (len==(int)u.size()) {
		int sum = 0;
		rep(i, len) {
			sum += abs(s[i] - u[i]);
		}
		mi = min(mi, sum);
	}
	cout << mi << endl;
	return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <string>
#include <limits>

int main()
{
    std::string S, T;
    std::cin >> S >> T;
    int min = std::numeric_limits<int>::max();
    for (int i = 0; i < S.size(); i++)
    {
        if (i + T.size() - 1 >= S.size())
            continue;
        int count = 0;
        for (int j = 0; j < T.size(); j++)
        {
            if (S[i + j] != T[j])
                count++;
        }
        min = std::min(min, count);
    }
    std::cout << min << std::endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


#define BOLL_MAX 200050
ll boll_num[BOLL_MAX] = {0};

int main()
{
    int n;
    cin >> n;
    vector<int> a;
    rep(i, n){ 
        int tmp; 
        cin >> tmp; 
        a.push_back(tmp);
        boll_num[tmp]++;
    }

    //rep(i,n) cout << boll_num[i] << endl;

    ll max_score = 0;
    rep1(i,n){
        ll score = (boll_num[i]) * (boll_num[i]-1) / 2;
        max_score += score;
    }
    rep(i, n){
        int num = a[i];
        ll minus = (boll_num[num] - 1);
        if (boll_num[num] <= 1) minus = 0;
        cout << max_score - minus << endl;
    }

}



Measured memory_bytes: 4084
import java.util.Arrays;
import java.util.Scanner;

//Twin Prime
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		boolean[] p = new boolean[10001];
		Arrays.fill(p, true);
		p[0]=p[1]=true;
		for(int i=2;i<10001;i++)if(p[i])for(int j=2*i;j<10001;j+=i)p[j]=false;
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			for(int i=n;i>=5;i--)if(p[i]&&p[i-2]){System.out.println((i-2)+" "+i);break;}
		}
	}
}

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

using namespace std;

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

	vector<int> v(n);
	for(auto& x : v) {
		cin >> x;
	}

	sort(v.begin(), v.end());
	auto boundary = unique(v.begin(), v.end());

	cout << boundary - v.begin() << endl;;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp mak_pair
#define pb push_back
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin>>s;
	int su=0;
	for(int i=0;i<s.length();i++)
		su+=(s[i]-'0');
	if(su%9==0)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,A,B,C,res=inf;
vi a;

void dfs(int I,int x,int y,int z,int S){
	if(I==n){
		if(x>0&&y>0&&z>0) res=min(res,abs(x-A)+abs(y-B)+abs(z-C)+S);
		return;
	}
	int t=a[I++];
	dfs(I,x,y,z,S);
	dfs(I,x+t,y,z,S+10);
	dfs(I,x,y+t,z,S+10);
	dfs(I,x,y,z+t,S+10);
}

int main(){
	cin>>n>>A>>B>>C;
	a=vi(n);
	for(auto &i:a) cin>>i;
	dfs(0,0,0,0,-30);
	cout<<res<<endl;
}

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

using namespace std;

const int N = 1e5 + 5;

long long n;
long long sol = 1e15;

int main()
{
    cin>>n;
    for(long long i = 1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            sol = min(sol , i + n/i -2);
        }
    }
    cout<<sol;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

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

int main()
{
  INT(N);
  ll D;
  cin >> D;
  vector<P> A(N);
  int cnt = 0;
  REP(i,N){
    cin >> A[i].first >> A[i].second;
    if(A[i].fi*A[i].fi+A[i].se*A[i].se<=D*D){
      cnt++;
    }
  }
  cout << cnt << endl;
}

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

int main(){
  string s, ans = "";
  cin >> s;
  rep(i, s.length()){
    if(s[i] == 'B' && ans != ""){
      ans = ans.erase(ans.length() - 1, 1);
    } 
    if(s[i] == '0' || s[i] == '1'){
      ans += s[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

string solve(string sa, int a, string sb, int b, string sc, int c) {
	if (a == 0) {
		return solve(sb, b, sc, c, "", 0);
	}
	if (a <= b + c) {
		vector<string> vv(a, sa);
		int g = c / a;
		for (int i = 0; i < vv.size(); ++i)
			for (int j = 0; j < g; ++j)
				vv[i] += sc;
		g = a - c % a;
		for (int i = g; i < a; ++i)
			vv[i] += sc;
		for (int i = 0; i < b; ++i)
			vv[i % g] += sb;
		sort(vv.begin(), vv.end());
		vector<pair<string, int> > go;
		int cur = 0;
		for (int i = 0; i < vv.size(); ++i) {
			++cur;
			if (i == vv.size() - 1 || vv[i + 1] != vv[i]) {
				go.push_back(make_pair(vv[i], cur));
				cur = 0;
			}
		}
		while (go.size() < 3)
			go.push_back(make_pair("", 0));
		return solve(go[0].first, go[0].second, go[1].first, go[1].second, go[2].first, go[2].second);
	}
	else {
		if (b + c == 0) {
			string ans;
			for (int i = 0; i < a; ++i)
				ans += sa;
			return ans;
		}
		vector<string> vv(b + c);
		for (int i = 0; i < a; ++i)
			vv[i % (b + c)] += sa;
		for (int i = 0; i < c; ++i)
			vv[i] += sc;
		for (int i = 0; i < b; ++i)
			vv[c + i] += sb;
		sort(vv.begin(), vv.end());
		vector<pair<string, int> > go;
		int cur = 0;
		for (int i = 0; i < vv.size(); ++i) {
			++cur;
			if (i == vv.size() - 1 || vv[i + 1] != vv[i]) {
				go.push_back(make_pair(vv[i], cur));
				cur = 0;
			}
		}
		while (go.size() < 3)
			go.push_back(make_pair("", 0));
		return solve(go[0].first, go[0].second, go[1].first, go[1].second, go[2].first, go[2].second);
	}
}

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	int a, b, c;
	cin >> a >> b >> c;
	cout << solve("a", a, "b", b, "c", c) << "\n";
	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

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

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

	if(a[0] > 0){
		cout << -1 << endl;
		return 0;
	}

	rep(i,n - 1){
		if(a[i + 1] - a[i] > 1){
			cout << -1 << endl;
			return 0;
		}
	}

	long long ans = 0;
	vector<long long> s(n, 0);

	int i = n - 1;
	while(i >= 0){
		int t = a[i];
		ans += a[i];

		if(i == 0) break;

		while(a[i] == t){
			t--;
			i--;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
int n,m,i,j,a[262144],p[262144],sum,mod=998244353,i2=(mod+1)/2;;
int qp(int x,int y)
{
	int z=1;
	while(y){
		if(y&1){
			z=1ll*z*x%mod;
		}
		y/=2;
		x=1ll*x*x%mod;
	}
	return z;
}
void fwt(int *a,int len)
{
	int i,j;
	for(i=1;i<len;i*=2){
		fz0k(j,len)if(!(i&j)){
			int x=a[j],y=a[j+i];
			a[j]=x+y;if(a[j]>=mod)a[j]-=mod;
			a[j+i]=x-y;if(a[j+i]<0)a[j+i]+=mod;
		}
	}
}
void ifwt(int *a,int len)
{
	int i,j;
	for(i=1;i<len;i*=2){
		fz0k(j,len)if(!(i&j)){
			int x=a[j],y=a[j+i];
			a[j]=x+y;if(a[j]>=mod)a[j]-=mod;
			a[j+i]=x-y;if(a[j+i]<0)a[j+i]+=mod;
			a[j]=1ll*a[j]*i2%mod;a[j+i]=1ll*a[j+i]*i2%mod;
		}
	}
}
int main()
{
	scanf("%d",&n);m=(1<<n);
	fz0k(i,m){
		scanf("%d",&p[i]);
		sum=(sum+p[i])%mod;
	}
	sum=qp(sum,mod-2);
	fz0k(i,m){
		p[i]=1ll*p[i]*sum%mod;
	}
	dec(p[0],1)
	a[0]=m-1;
	fz1(i,m-1){
		a[i]=mod-1;
	}
	fwt(a,m);fwt(p,m);
	fz0k(i,m){
		a[i]=1ll*a[i]*qp(p[i],mod-2)%mod;
	}
	ifwt(a,m);
	int t=a[0];
	fz0k(i,m){
		dec(a[i],t);
		printf("%d\n",a[i]);
	}
	return 0;
}

Measured memory_bytes: 4864
n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]

count=0
for i in x:
  a = int(i[0]*i[0]+i[1]*i[1])
  b = int(d*d)
  if(a<=b):
    count+=1
    
print(count)

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

int main(){
    string s;
    cin >> s;
    int k;
    cin >> k;
    int n = s.size();
    vector<vector<ll>> dp1(n+1,vector<ll>(k+1)), dp2(n+1,vector<ll>(k+1));
    dp1.at(0).at(0) = 1;

    rep(i,n) {
        int d = s.at(i) - '0';
        if(d==0){
            rep(j,k+1){
                dp1.at(i+1).at(j) = dp1.at(i).at(j);
            }
        } else {
            rep(j,k+1){
                dp2.at(i+1).at(j) += dp1.at(i).at(j);
            }
            rep(j,k){
                dp1.at(i+1).at(j+1) = dp1.at(i).at(j);
                dp2.at(i+1).at(j+1) += dp1.at(i).at(j) * (d-1);
            }
        }
        
        rep(j,k+1){
            dp2.at(i+1).at(j) += dp2.at(i).at(j);
        }
        rep(j,k){
            dp2.at(i+1).at(j+1) += dp2.at(i).at(j) * 9;
        }
        // rep(j,k+1){
        //     cout << dp1.at(i).at(j) << " ";
        // }
        // cout << endl;
    }
    ll ans = dp1.at(n).at(k) + dp2.at(n).at(k);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int sq[16000];
int a[10][10];

int main() {
    memset(sq, -1, sizeof(sq));
    for (int i = 0; i < 127; i++)
        sq[i*i] = 0;

    int n = gi();
    int d = gi();
    for (int i = 0; i < n; i++)
        for (int j = 0; j < d; j++)
            a[i][j] = gi();

    int r = 0;
    for (int i = 0; i < n; i++)
        for (int j = i+1; j < n; j++) {
            int s = 0;
            for (int k = 0; k < d; k++) {
                int x = (a[i][k] - a[j][k]);
                s += x*x;
            }
            if (sq[s] == 0)
                r++;
        }

    printf("%d\n", r);

    return 0;
}


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

const long long MOD = 924844033;

void add(long long& a, long long b){
    a = (a + b) % MOD;
}

int main(){
    long long i, j, k;
    long long N, K;
    cin >> N >> K;

    const int MAX = 2001;
    long long dp1[MAX][MAX][4] = {0};
    long long dp1r1[MAX], dp1r2[MAX];
    dp1[0][0][1] = 1;

    int M = (N+K-1)/K;
    for(i=0; i<M; i++){
        for(j=M-1; j>=0; j--){
            add(dp1[i+1][j][0], (dp1[i][j][0] + dp1[i][j][1]) % MOD);
            add(dp1[i+1][j][1], (dp1[i][j][2] + dp1[i][j][3]) % MOD);
            add(dp1[i+1][j+1][3], (dp1[i][j][3] + dp1[i][j][2]) % MOD);
            add(dp1[i+1][j+1][2], (dp1[i][j][1] + dp1[i][j][0]) % MOD);
            add(dp1[i+1][j+1][1], dp1[i][j][2]);
            add(dp1[i+1][j+1][0], dp1[i][j][0]);
        }
    }
    for(j=0; j<=M; j++){
        dp1r1[j] = (dp1[M][j][0] + dp1[M][j][1]) % MOD;
        dp1r2[j] = (dp1[M-1][j][0] + dp1[M-1][j][1]) % MOD;
    }
    long long dp2[MAX] = {0};
    dp2[0] = 1;
    int sum = 0;
    for(i=1; i<=K; i++){
        int m = (N%K > 0 && i > N%K) ? M-1 : M;
        sum += m;
        for(j=sum; j>=0; j--){
            for(k=1; k<=m; k++){
                if(j>=k){
                    if(m == M){
                        add(dp2[j], dp2[j-k] * dp1r1[k] % MOD);
                    }else{
                        add(dp2[j], dp2[j-k] * dp1r2[k] % MOD);
                    }
                }
            }
        }
    }

    long long fact[MAX];
    fact[0] = 1;
    for(i=1; i<=N; i++) fact[i] = fact[i-1] * i % MOD;

    long long ans = fact[N];
    for(i=1; i<=N; i++){
        long long a = (i%2==0 ? 1 : -1) * dp2[i] % MOD * fact[N-i] % MOD;
        add(ans, (a+MOD)%MOD);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	int n; cin >> n;
	double ans = 0;
	for (int i = 0; i < n; i++) {
		double x; string u; cin >> x >> u;
		if (u == "JPY") ans += x;
		else ans += x * 380000.0;
	}
	printf("%.10lf\n", ans);
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc119/tasks/abc119_b

package main

import "fmt"

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

	var total float64
	for i := 0; i < N; i++ {
		var x float64
		var unit string
		fmt.Scanf("%f %s", &x, &unit)
		if unit == "JPY" {
			total += x
		} else if unit == "BTC" {
			total += x * 380000.0
		}
	}

	fmt.Println(total)
}


Measured memory_bytes: 512
#![allow(unused_imports)]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::{min, max};
use std::collections::{HashMap, HashSet, VecDeque, BinaryHeap};

fn main() {
    input!{
        n: usize,
        v: [usize; n],
        q: usize,
        bc: [(usize, usize); q]
    }
    let mut cs = vec![0; 100001];
    let mut s = v.iter().sum::<usize>();
    for &a in &v {
        cs[a] += 1;
    }
    for &(b, c) in &bc {
        s = s - cs[b] * b + cs[b] * c;
        cs[c] += cs[b];
        cs[b] = 0;
        println!("{}", s);
    }
}


Measured memory_bytes: 5092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    ll n,m;
    cin >> n >> m;
    ll ans = 0;
    if(2*n>=m){
        ans = m/2;
    }else{
        ans = (2*n+m)/4;
    }
    cout << ans << endl;
}

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

#include<cstdio>
#include<cstring>

int main(){
  char s[202], t[202], p[101];

  scanf("%s %s", s, p);
  strcpy(t, s);
  strcat(s, t);
  if (strstr(s, p)==NULL) cout << "No\n";
  else cout << "Yes\n";
  

  return 0;
}

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

int main(){
    int n,i,k,j=0;
    cin >> n >> k;

    int A[n],dp[n];
    
    for(i=0;i<n;i++)
        cin >> A[i];

    if(k>=n)
        cout << abs(A[0]-A[n-1]) << endl;
    else {
        for(i=0;i<=k;i++)
            dp[i] = abs(A[i]-A[0]);

        for(i=k+1;i<n;i++){
            int temp = 1000000009;
            for(j=1;j<=k;j++)
                temp = min(temp, dp[i-j] + abs(A[i]-A[i-j]));
            dp[i]=temp;
        }

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

Measured memory_bytes: 4408
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N;
    int a;
    cin>> N;
    vector<int>  x;
    for(int i=0;i<N;i++) {
        cin>>a;
        x.push_back(a);
    }
    int num=-1;
    bool flag=true;
    while(flag){
        for(auto & var :x){
            if(var %2 !=0){ 
                flag=false;
                break  ;
            }
            var/=2;
        }
        num++;
    }
    cout << num;
    
}


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

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

	int a[N], min, max;
	for (int i=0; i<N; i++)
		cin >> a[i];

	max = INT_MIN;
	min = a[0];

	for (int i=1; i<N; i++) {
		max = (max < a[i]-min)? a[i]-min: max;
		min = (min > a[i])? a[i]: min;
	}

	cout << max << endl;

	return 0;
}


Measured memory_bytes: 3884
#include <bits/stdc++.h>
using namespace std;
string s;
bool v[27];
int n;
int main()
{
	cin>>s;
	bool chk=0;
	int i;
	for(i=0;s[i];i++)
	{
		v[s[i]-'a']=1;
		if(s[i]+i!='z')
			chk=1;
	}
	n=i;
	if(n!=26)
	{
		for(i=0;i<26;i++)
		{
			if(!v[i])
			{
				s+=char(i+'a');
				break;
			}
		}
		cout<<s<<"\n";
		return 0;
	}
	if(!chk)
	{
		cout<<"-1\n";
		return 0;
	}
	for(i=n-1;i>=0;i--)
	{
		for(int j=0;j<26;j++)
			v[j]=0;
		for(int j=0;j<i;j++)
		{
			v[s[j]-'a']=1;
			//cout<<s[i]<<"\n";
		}
		//cout<<v['y'-'a']<<"\n";
		for(int j=s[i]-'a'+1;j<26;j++)
		{
			if(!v[j])
			{
				//cout<<j<<"\n";
				v[j]=1;
				s[i]='a'+j;
				//s[i+1]='\0';
				cout<<s.substr(0,i+1)<<"\n";
				return 0;
			}
		}
	}
 	return 0;
}


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

int main()
{
  int n;
  cin>>n;
  vector<int> v(n); 
  int sum=0;
  for(int &i:v) { cin>>i; sum+=i; }
  int ans=0;
  for(int i:v)
  {
    ans += (sum-i)*i;
    sum-=i;
  }
  cout<<ans<<"\n";
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main () {
    int N,M;
    cin >> N >> M;
    vector<int> A(N);
    for(int i = 0;i<N; i++) cin >> A[i];
    sort(A.begin(), A.end() , greater<int>());
    int cnt = 0;
    for(int i = 0;i<N; i++) cnt += A[i];

    int res = 0;
    for(int i = 0; i<N; i++) {
        if(A[i] * (4 * M) >= cnt ) res++;
    }
    if(res >= M) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
import sys
sys.setrecursionlimit(10**6)
import math
import itertools
from collections import defaultdict
from collections import Counter
import numpy as np

import heapq
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
od=998244353
n,k,x=list(map(int,input().split()))

n_c_i=[1]
pow_k=pow(k-1,n,od)
inv_k=pow(k-1,od-2,od)
each_cal=[]
zenpou=[1]
kouhou=[]
for i in range(1,x+1):
    n_c_i.append((n_c_i[-1]*(n-i)*pow(i,od-2,od))%od)
    zenpou.append(zenpou[-1]*(k-1)%od)
for i in range(x+1):
    pow_k=pow_k*inv_k%od
    kouhou.append(pow_k)
    each_cal.append(pow(k-1,n-i-1,od))
    

ans=0
for i in range(x+1):
    #ans+=comb*k*pow_k%od
    ans+=(n_c_i[i]*k*each_cal[i])%od
    ans%=od

print(ans)



Measured memory_bytes: 58216