akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
void solve(long long N, long long K, std::vector<long long> p)
{
    
    int val = 0;
    rep(i, K) {
        val += p[i];
    }
    int max_idx = 0;
    int max_val = val;
    for(int i=1;i<N-K+1;i++) {
        val -= p[i-1];
        val += p[i+K-1];
        
        // cout << val << endl;
        if (val > max_val) {
            max_val = val;
            max_idx = i;
        }
    }
    double exp = 0;
    rep (i, K) {
        exp += (p[max_idx + i] * (p[max_idx + i] + 1)) / (2.0 * p[max_idx + i]);
    }
    printf("%f\n", exp);
}
 
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> p(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &p[i]);
    }
    solve(N, K, std::move(p));
    return 0;
}

Measured memory_bytes: 1792
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
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)*}
  };
}
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, 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")
  };
}

fn main() {
  input!{
    N: i64,
  }

  let ans = (1 + N) * N / 2
    - 3 * (1..(N/3+1)).sum::<i64>()
    - 5 * (1..(N/5+1)).sum::<i64>()
    + 15 * (1..(N/15+1)).sum::<i64>()
    ;
  println!("{}", ans);

}


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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(lo i=1;i<=n;i++)
#define mid (bas+son)/2

const lo MAX = -1000000000000000000; 
const lo MIN = 1000000000000000000; 
const lo inf = 1000000000; 
const lo KOK = 100000; 
const lo LOG = 30; 
const lo li = 1000005; 
const lo mod = 1000000007; 

lo n,m,cev,b,a[li],dp[li];
string s;
vector<int> v;

lo f(lo sira){
	lo cevap=MIN;
	if(sira>n) return MIN;
	if(sira==n) return 0;
	if(~dp[sira]) return dp[sira];
	cevap=min(cevap,(f(sira+1)+abs(a[sira+1]-a[sira])));
	cevap=min(cevap,(f(sira+2)+abs(a[sira+2]-a[sira])));
	//~ cout<<sira<<" "<<cevap<<endl;
	return dp[sira]=cevap;
}

int main(){
	memset(dp,-1,sizeof(dp));
	scanf("%lld",&n);
	FOR{
		scanf("%lld",&a[i]);
	}
	printf("%lld\n",f(1));
	return 0;
}


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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var odd = 0;
            var even = 0;

            for(int i = 1; i <= N; i++)
            {
                if (i % 2 == 0)
                {
                    even++;
                }
                else
                {
                    odd++;
                }
            }
            Console.WriteLine(((double)odd / (even + odd)).ToString());
        }
    }
}


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

int main(){
    long long n,sum=0;
    cin >> n;
    for(long long i = 1 ; i <= n ; i += 1){
        if(i % 3 == 0 || i % 5 == 0){
            continue;
        }
        sum += i;
    }
    cout << sum << endl;
}

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


Measured memory_bytes: 3064
/*
  ___    ___             ___    __                   _     _   _
 |   \  /   |           |   \  |  |                 | |   (_) | |
 |    \/    |  _ __     |    \ |  |   __ _   _____  | |_   _  | | __
 |  |\  /|  | | '__|    |  |\ \|  |  / _' | |  ___) | __| | | | |/ /
 |  | \/ |  | | |    _  |  | \    | | (_| | |___  | | \_  | | |   /
 |__|    |__| |_|   (_) |__|  \___|  \__,_| (_____|  \__| |_| |_|\_\

 */

 #include<bits/stdc++.h>
 using namespace std;
 #define ll long long
 #define M 1000000007

 int main()
 {
    ll i,j,n,k,ans=0;
    cin>>n>>k;
    ll a[n+1];
    ll first[2002];
    ll second[2002];

    memset(first,0,sizeof first);
    memset(second ,0,sizeof second);
    cin>>a[0];
    for(i=1;i<n;i++)
    {
        cin>>a[i];
        for(j=0;j<i;j++)
        {
            if(a[j]>a[i])
                first[a[i]]++;
        }
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            if(a[j]>a[i])
                second[a[i]]++;
        }
    }
    for(i=0;i<2002;i++)
        ans=(ans+ (((((k*(k-1))/2)%M)*second[i])%M)%M + (k*first[i])%M+M)%M;
    cout<<ans;
 }


Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.readline

N, K = map(int, input().split())
V = deque(list(map(int, input().split())))
score = deque()

for i in range(K+1): #左から
    for j in range(K-i+1): #右から
        hand = deque()
        if i + j <= N:
            for n in range(i): #左から
                hand.append(V[n]) 
            for m in range(j): #右から
                hand.append(V[N-m-1])
            for k in range(K-i-j):
                if len(hand) > 0 and min(hand) < 0:
                    hand.remove(min(hand)) 
            score.append(sum(hand))

print(max(score))

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

public class Main {
    PrintWriter out = new PrintWriter(System.out);
    // no self-loop or multiple edges
    public static void main(String[] args) throws Exception {
        Main main = new Main();
//        main.solve();
        System.out.println(main.solve());
    }
    long solve(){
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt(), n = sc.nextInt();
        int[] cur = new int[H+1], next = new int[H+1];
        Arrays.fill(cur,Integer.MAX_VALUE/2);
        cur[H] = 0;
        for(int i=0;i<n;i++){
            Arrays.fill(next,Integer.MAX_VALUE/2);
            int a = sc.nextInt(), b = sc.nextInt();
            if(a>H){
                System.arraycopy(cur, 0, next, 0, H+1);
                next[0] = Math.min(next[0], b);
            } else{
                for(int j=H; j>H-a; j--) next[j] = cur[j];
                for(int j=H-a;j>0;j--){
                    next[j] = Math.min(next[j+a]+b,Math.min(cur[j],cur[j+a]+b));
                }
                next[0] = cur[0];
                for(int j=a;j>=0;j--){
                    next[0] = Math.min(next[0],Math.min(cur[j]+b,next[j]+b));
                }
            }
            System.arraycopy(next, 0, cur, 0, H+1);
        }
        long ans = cur[0];
        sc.close();
        return ans;
    }
}



Measured memory_bytes: 28096
#include <cstdint>
#include <iostream>
#include <vector>
#include <algorithm>

uint32_t add(uint32_t num)
{
    uint32_t sum = 0;
    for (uint32_t i=1; i <= num; ++i) {
        sum += i;
    }
    return sum;
}

int main(void)
{
    uint32_t a, b;

    std::cin >> a >> b;

    uint32_t sum = add(b-a);

    std::cout << sum - b << std::endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=1000000007;
	const long o=1;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		long[] a=new long[s[0]],b=new long[s[1]],q=new long[s[2]],ans=new long[s[2]];
		int[] bb=new int[s[1]];
		for(int i=0;i<s[0];i++) {a[i]=sc.L;}
		for(int i=0,j=0;i<s[1];i++) {
			b[i]=sc.L;
			while(j<s[0]&&a[j]<b[i]){j++;}
			bb[i]=j;
		}
		for(int i=0;i<s[2];i++) {
			q[i]=sc.L;
			ans[i]=long.MaxValue;
			int lb=-1,ub=s[1]-1,mid=0;
			while(ub-lb>1){
				mid=(ub+lb)/2;
				if(b[mid]>=q[i]){ub=mid;}
				else{lb=mid;}
			}
			if(bb[ub]!=s[0]){
				ans[i]=Math.Min(Math.Abs(q[i]-b[ub]),Math.Abs(q[i]-a[bb[ub]]))+Math.Abs(b[ub]-a[bb[ub]]);
			}
			if(bb[ub]!=0){
				ans[i]=Math.Min(ans[i],Math.Min(Math.Abs(q[i]-b[ub]),Math.Abs(q[i]-a[bb[ub]-1]))+Math.Abs(b[ub]-a[bb[ub]-1]));
			}
			if(ub!=0){
				ub--;
				if(bb[ub]!=s[0]){
					ans[i]=Math.Min(ans[i],Math.Min(Math.Abs(q[i]-b[ub]),Math.Abs(q[i]-a[bb[ub]]))+Math.Abs(b[ub]-a[bb[ub]]));
				}
				if(bb[ub]!=0){
					ans[i]=Math.Min(ans[i],Math.Min(Math.Abs(q[i]-b[ub]),Math.Abs(q[i]-a[bb[ub]-1]))+Math.Abs(b[ub]-a[bb[ub]-1]));
				}
			}
		}
		Console.WriteLine(String.Join("\n",ans));
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

Measured memory_bytes: 26320
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		
		for(int i = 0; i < n; i++) {
			String s = sc.nextLine();
			System.out.println(s.replaceAll("Hoshino", "Hoshina"));
		}
	}
}

Measured memory_bytes: 17260
#include <stdio.h>
#include <string.h>
int main(void){
    // Your code here!
    char c[102][102],N;
    scanf("%d",&N);
    
    for(int i = 0;i < N;i++){
        scanf("%s",c[i]);
    }
    
    for(int i = 0;i < N;i++){
        for(int j = i + 1;j < N;j++){
            if(strcmp(c[i],c[j]) == 0){
                printf("No\n");
                return 0;
            }
        }
    }
    
    for(int i = 1;i< N;i++){
        if(c[i][0] != c[i-1][strlen(c[i-1])-1]){
            printf("No\n");
            return 0;
        }
    }
    
    printf("Yes\n");
    return 0;
    
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

int inf = std::numeric_limits<int>().max();

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define ll long long
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

int main() {
	int k, x;
	cin >> k >> x;
	for(int i=(x-k+1); i<=(x+k-1); i++) {
		cout << i << endl; 
	}
}


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

long long const MOD = 1000000007LL;

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

    vector<pair<long, long> > vec;
    for (long i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        vec.push_back(make_pair(b, a));
    }

    sort(vec.begin(), vec.end());
    long sum = 0;
    bool res = true;
    for (long i = 0; i < n; i++) {
        sum += vec[i].second;
        if (sum > vec[i].first) res = false;
    }

    if (res) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 6128
#include <cstdio>
#include <algorithm>
using namespace std;
using ll = long long;

const int MAX = 200005;

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

	int p1[MAX], p2[MAX];
	for (int x, i = 1; i <= N; i++) {
		scanf("%d", &x);
		p1[i] = x;
		p2[N + 1 - i] = L - x;
	}

	ll dp1[MAX] = { L - p1[N] }, dp2[MAX] = { L - p2[N] };
	ll ans = max(L - dp1[0], L - dp2[0]);

	for (int i = 1; i < N; i++) {
		dp1[i] = dp1[i - 1] + p1[N - (i - 1) / 2] + p1[N - i / 2] - 2 * p1[N - i];
		dp2[i] = dp2[i - 1] + p2[N - (i - 1) / 2] + p2[N - i / 2] - 2 * p2[N - i];
		ans = max({ ans, (i + 1ll) * L - dp1[i], (i + 1ll) * L - dp2[i] });
	}

	printf("%lld", ans);

	return 0;
}

Measured memory_bytes: 4864
#include<stdio.h>
#include<stdlib.h>
  
int main(){
  int n,m;
  scanf("%d%d",&n,&m);
  int input[m], flag[n+1];
  int i;
  for(i=0;i<m;i++){
    scanf("%d",&input[i]);
  }
  
  for(i=0;i<n+1;i++){
    flag[i]=0;
  }

  for(i=m-1;i>=0;i--){
    if(flag[input[i]]==0){
      printf("%d\n",input[i]);
      flag[input[i]]=m-i;
    }
  }
  for(i=1;i<=n;i++){
    if(flag[i]==0){
      printf("%d\n",i);
    }
  }
  return 0;
}

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


using namespace std;

#define MAXN 110

int v[MAXN];

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    int i, j;
    for (i=1; i<=n; i++) {
        scanf("%d", &v[i]);
    }
    int ans = 0;
    int x, y;
    for (x=0; x<=n; x++) {
        for (y=0; y<=n; y++) {
            if (x+y<=n && x+y<=k) {
                vector<int> aux;
                for (i=1; i<=x; i++) {
                    aux.push_back(v[i]);
                }
                for (i=n; i>=n-y+1; i--) {
                    aux.push_back(v[i]);
                }
                sort(aux.begin(), aux.end());
                int res = k-x-y;
               // printf("Testando %d %d\n", x, y);
                for (i=0; i<=min(res, ((int) aux.size())); i++) {

                    int soma = 0;
                    for (j=i; j<aux.size(); j++) {
                        soma+=aux[j];
                    }
                   // printf("Tirando %d: %d\n", i, soma);
                    ans = max(ans, soma);
                }
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}








Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 505;

int H, W, h, w;

int main() {
  scanf("%d%d%d%d", &H, &W, &h, &w);
  if (H % h == 0 && W % w == 0) {
    puts("No");
  } else if (H % h != 0) {
    puts("Yes");
    for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j)
	if (i % h == 0)
	  printf("%d ", 1000 * (h - 1) - 1);
	else
	  printf("%d ", -1000);
      puts("");
    }
  } else {
    puts("Yes");
    for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j)
	if (j % w == 0)
	  printf("%d ", 1000 * (w - 1) - 1);
	else
	  printf("%d ", -1000);
      puts("");
    }
  }
  
  return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const int Inf = 1e9;
const ll INF= 1e18;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N;
    cin >> N;
    vector<ll> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    sort(vec.begin(),vec.end());
    vector<ll> d(N);
    d.at(0) = vec.at(0);
    for(int i = 1;i < N;i++) {
        d.at(i) = d.at(i - 1) + vec.at(i);
    }
    int ret = 1;
    for(int i = N - 1;i >= 1;i--) {
        if(vec.at(i) > d.at(i - 1) * 2) {
            break;
        }
        ret++;
    }
    cout << ret << endl;
}

Measured memory_bytes: 1792
//https://atcoder.jp/contests/dp/tasks/dp_h

#include <bits/stdc++.h>
#include <limits.h>
#include <algorithm>  


#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;


using namespace std;

typedef long long int ll;

const int precision = 16;
const int modulo =  1000000007; // 10^9 + 7
using ll = long long;
const double EPS = 1e-9;
//const ll INF = 1e18L + 5;
const int nax = 1e5 + 5;


int solveGrid() {
	int h, w; cin >> h >> w;
	vector<vector<char>> grid(h, vector<char>(w, '.'));
	for(auto i = 0; i < h; ++i) {
		for(auto & cell : grid[i]) {
			cin >> cell;
		}
	}

	vector<vector<ll>> dp(h, vector<ll>(w, 0));
	
	for(auto c = 0; c < w; ++c) {
		if(grid[0][c] == '#') break;
		dp[0][c] = 1;
	}

	for(auto r = 1; r < h; ++r) {
		for(auto c = 0; c < w; ++c) {
			if(grid[r][c] == '#') continue;

			if(r - 1 >= 0 and grid[r - 1][c] != '#') {
				dp[r][c] = dp[r - 1][c];	
			}
			
			if(c - 1 >= 0 and grid[r][c - 1] != '#') {
				dp[r][c] += dp[r][c - 1];	
			}
			
			if(dp[r][c] > modulo) {
				dp[r][c] -= modulo;
			}
		}
	}

	// for(auto r = 0; r < h; ++r) {
	// 	for(auto c = 0; c < w; ++c) {
	// 		cout << dp[r][c] << "  ";
	// 	}
	// 	cout <<endl;
	// }

	return dp[h - 1][w - 1];
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(precision);
	cout.setf(ios_base::fixed);

	auto ret = solveGrid();
	cout << ret << endl;
	return 0;
}




Measured memory_bytes: 9088
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
int bit [1000000] = {},n;

//[1,n]
//get sum from [i,n]
int sum(int i){
    int s = 0;
    while (i > 0) {
        s += bit[i];
        i -= i & -i;
    }
    return s;
}
// add a_i += x
void add (int i,int x){
    while (i <= n) {
        bit[i] += x;
        i += i & -i;
    }
}

signed main(){
    int n,k; cin >> n >> k;
    vector<int>v(n);
    erep(e,v) cin >> e;
    vector<int>dp;
    rep(i,v.size()-1)
    dp.push_back(abs(v[i] - v[i+1]));
    if(k == 1){
        int ans = INF;
        rep(i,v.size()){
            cmin(ans,abs(v[i]));
        }
        cout << ans << endl;
        return 0;
    }
    rep(i,dp.size()){
        if(i)dp[i] += dp[i-1];
    }
    int ans = INF;
    rep(i,dp.size() - k + 2){
        if(i == 0) cmin(ans,min(abs(v[0]),abs(v[i+k-1])) + dp[k-2]);
        else cmin(ans,min(abs(v[i]),abs(v[i + k - 1]))+ dp[i + k -2] - dp[i - 1]);
    }
    cout << ans << endl;
}



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

int main(void){
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i=0;i<n;i++) cin >> vec.at(i);

    vector<int> vote(100002);
    for(int i=0;i<n;i++){
        vote.at(vec.at(i))++;
        vote.at(vec.at(i)+1)++;
        if(vec.at(i)!=0) vote.at(vec.at(i)-1)++;
    }
    sort(vote.begin(),vote.end());
    reverse(vote.begin(),vote.end());
    cout << vote.at(0) << endl;
}

Measured memory_bytes: 1024
import std.algorithm;
import std.array;
import std.bigint;
import std.bitmanip;
import std.conv;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; }

T[] readToArray(T)() {
    return readln.split.to!(T[]);
}

void readInto(T...)(ref T ts) {
    auto ss = readln.split;
    foreach(ref t; ts) {
        t = ss.front.to!(typeof(t));
        ss.popFront;
    }
}

// 冪乗をmod取りつつ計算
@nogc @safe pure ulong modPow(ulong a, ulong n, ulong m) {
    ulong r = 1;
    while (n > 0) {
        if(n % 2 != 0) r = r * a % m;
        a = a * a % m;
        n /= 2;
    }
    return r;
}

// フェルマーの小定理から乗法逆元を計算
// 定理の要請により法は素数
@nogc @safe pure ulong modInv(ulong a, ulong m) {
    return modPow(a, m-2, m);
}

// mod取りつつ順列を計算
@nogc @safe pure ulong modPerm(ulong n, ulong k, ulong m) {
    if (n < k) return 0;

    ulong r = 1;
    for (ulong i = n-k+1; i <= n; i++) {
        r *= i;
        r %= m;
    }
    return r;
}

// mod取りつつ順列を計算
@nogc @safe pure ulong modFact(ulong n, ulong m) {
    return modPerm(n, n, m);
}

// mod取りつつ組み合わせを計算
// modInvを使っているので法は素数
@nogc @safe pure ulong modComb(ulong n, ulong r, ulong m) {
    return modPerm(n, r, m)*modInv(modFact(r, m), m) % m;
}

immutable ulong MOD = 1000000007;

void main() {
    ulong r;
    readInto(r);
    writeln(3*r*r);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back

using namespace std;

const int N=25;

int n,m,dis[N][N][N][N],mx=-1;

char ch[N][N];

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

bool inside(int x,int y)
{
    return x>-1&&y>-1&&x<n&&y<m;
}

void BFS(int x,int y)
{
    dis[x][y][x][y]=0;
    queue<pair<int,int> >q;
    q.push({x,y});
    while(!q.empty())
    {
        pair<int,int>p=q.front();
        q.pop();
        for (int i=0;i<4;i++)
        {
            int nx=p.F+dx[i];
            int ny=p.S+dy[i];
            if (inside(nx,ny)&&ch[nx][ny]=='.'&&dis[x][y][nx][ny]==-1)
            {
                dis[x][y][nx][ny]=1+dis[x][y][p.F][p.S];
                mx=max(mx,dis[x][y][nx][ny]);
                q.push({nx,ny});
            }
        }
    }
}

int main()
{
    memset(dis,-1,sizeof dis);
    cin >> n >> m;
    for (int i=0;i<n;i++)
    {
        for (int j=0;j<m;j++)
        {
            cin >> ch[i][j];
        }
    }
    for (int i=0;i<n;i++)
    {
        for (int j=0;j<n;j++)
        {
            if (ch[i][j]=='.')
            {
                BFS(i,j);
            }
        }
    }
    cout << mx << endl;
}



Measured memory_bytes: 1792
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), c
  cout << fixed << setprecision(15);

  ll h, w, k;
  cin >> h >> w >> k;

  ll xs, ys, xg, yg;
  cin >> xs >> ys >> xg >> yg;
  xs--, ys--, xg--, yg--;

  vector<string> mp(h);
  rep(i, h) cin >> mp[i];

  using Q = tuple<ll, ll, ll, ll>;
  priority_queue<Q, vector<Q>, greater<Q>> pque;
  vector<vvll> dist(h, vvll(w, vll(5, INF)));

  pque.emplace(0, xs, ys, 4);
  dist[xs][ys][4] = 0;
  while (!pque.empty()) {
    ll du, x, y, d;
    tie(du, x, y, d) = pque.top();
    pque.pop();
    if (dist[x][y][d] < du) continue;
    rep(i, 4) {
      ll nx = x + dx[i], ny = y + dy[i];
      bool ok = 0 <= nx && nx < h && 0 <= ny && ny < w && mp[nx][ny] != '@';
      if(!ok) continue;
      ll dv;
      if(d == i){
        dv = du + 1;
      } else {
        dv = k*(du/k) + k;
      }
      if (dist[nx][ny][i] > dv) {
        dist[nx][ny][i] = dv;
        pque.emplace(dv, nx, ny, i);
      }
    }
  }

  ll ans = INF;
  rep(i, 4) chmin(ans, dist[xg][yg][i]/k);

  if(ans == INF/k) ans = -1;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 144860
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

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

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)

struct plis {
	vector<int> lis;
	vector<pair<int,int>> ops;
	void add(int x) {
		auto it=lower_bound(all(lis), x);
		if(it==lis.end()) {
			lis.pb(x);
			ops.push_back({-1,0});
		}else {
			ops.push_back({it-lis.begin(),*it});
			*it=x;
		}
	}
	void rollback() {
		if(ops.back().xx==-1) {
			lis.pop_back();
			ops.pop_back();
		}else {
			lis[ops.back().xx]=ops.back().yy;
			ops.pop_back();
		}
	}
};

int n;
int a[200001];
vector<int> adj[200001];
int ans[200001];

plis curr;
void dfs(int x) {
	curr.add(a[x]);
	ans[x]=curr.lis.size();
	
	for(auto i:adj[x]) {
		if(ans[i]==0) {
			dfs(i);
		}
	}
	
	curr.rollback();
}


int main() {
	IO;
	cin>>n;
	for(int i=1;i<=n;++i) cin>>a[i];
	for(int i=1;i<n;++i) {
		int a,b;
		cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	
	dfs(1);
	for(int i=1;i<=n;++i) cout<<ans[i]<<"\n";
	
	return 0;
	
}


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

using namespace std;

int main()
{
  int N, M, K;
  int D[16], idx[101], v[101][101];
  memset(idx, -1, sizeof(idx));
  cin >> N >> M >> K;
  for(int i = 0; i < M; i++) cin >> D[i], D[i]--, idx[D[i]] = i;
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < K; j++) cin >> v[i][j], v[i][j]--; 
  }
  int d[1<<16]; memset(d, -1, sizeof(d));
  queue<int> que;
  que.push((1<<M)-1);
  d[(1<<M)-1] = 0;
  while(!que.empty()) {
    int bit = que.front(); que.pop();
    if(!bit) break;
    for(int i = 0; i < K; i++) {
      int nbit = 0;
      for(int j = 0; j < M; j++) {
	if((bit >> j) & 1 && ~idx[v[D[j]][i]]) nbit |= (1<<idx[v[D[j]][i]]);
      }
      if(!~d[nbit]) {
	d[nbit] = d[bit] + 1;
	que.push(nbit);
      }
    }
  }
  cout << d[0] <<endl;
  return 0;
}

Measured memory_bytes: 3548
#include <iostream>
#include <vector>
#include <limits>
#include <algorithm>
#include <iomanip>

using namespace std;

template<class T>
class StarrySkyTree {
    private:
        int N;
        const T MAX;
        const T ZERO;
        std::vector<T> dat, lazy;
    public:
        StarrySkyTree(int n) : MAX(std::numeric_limits<T>::max()), ZERO(static_cast<T>(0)) {
            N = 1;
            while (N < n) N *= 2;
            dat.assign(2*N, MAX);
            lazy.assign(2*N, ZERO);
        }
        // a is 0-indexed
        void set(int a, const T v) {
            dat.at(a+N) = v;
        }
        void build() {
            for (int i=N-1; i>0; --i) dat.at(i) = std::min(dat.at(2*i), dat.at(2*i+1));
        }
        void eval(int k, int l, int r) {
            if (lazy.at(k) == ZERO) return;

            dat.at(k) += lazy.at(k);
            if (r - l > 1) {
                lazy.at(2*k) += lazy.at(k);
                lazy.at(2*k+1) += lazy.at(k);
            }
            lazy.at(k) = ZERO;
        }
        // add v to [a, b)
        // a and b are 0-indexed
        void add(int a, int b, const T v) {
            return add (a, b, v, 1, 0, N);
        }
        void add(int a, int b, const T v, int k, int l, int r) {
            eval(k, l, r);

            if (b <= l || r <= a) return;
            if (a <= l && r <= b) {
                lazy.at(k) += v;
                eval(k, l, r);
            } else {
                add(a, b, v, 2*k, l, (l+r)/2);
                add(a, b, v, 2*k+1, (l+r)/2, r);
                dat.at(k) = std::min(dat.at(2*k), dat.at(2*k+1));
            }
        }
        // get min of [a, b)
        // a and b are 0-indexed
        T get(int a, int b) {
            return get(a, b, 1, 0, N);
        }
        T get(int a, int b, int k, int l, int r) {
            eval(k, l, r);

            if (b <= l || r <= a) return MAX;
            if (a <= l && r <= b) return dat.at(k);
            T vleft = get(a, b, 2*k, l, (l+r)/2);
            T vright = get(a, b, 2*k+1, (l+r)/2, r);
            return std::min(vleft, vright);
        }
};

void solve() {
    int n, q;
    cin >> n >> q;

    StarrySkyTree<int> sst(n);
    for (int i=0; i<n; ++i) sst.set(i, 0);
    sst.build();

    for (int i=0; i<q; ++i) {
        int a;
        cin >> a;
        if (a == 0) {
            int s, t, x;
            cin >> s >> t >> x;
            sst.add(s, t+1, x);
        } else {
            int s, t;
            cin >> s >> t;
            cout << sst.get(s, t+1) << '\n';
        }
    }
}

int main() {

    solve();

    return 0;
}



Measured memory_bytes: 4944
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int n, m, k, ans;
char s[9][9];
int main(){
    scanf("%d %d %d",&n,&m,&k);
    for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
    for(int b=0;b<(1<<(n+m));b++){
        int cnt = 0;
        for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) if(!(b & (1<<(i-1))) && !(b & (1<<(j+n-1))) && s[i][j] == '#') cnt++;
        if(cnt == k) ans++;
    }
    printf("%d",ans);
}

Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}

int main(){
    int x;
    cin >> x;
    ll ans = x/500*1000;
    x%=500;
    ans+=x/5*5;
    cout << ans<<endl;
}



Measured memory_bytes: 384
S = input()
N = len(S)
cnt1, cnt2 = 0, 0
for i in range(N):
    if i % 2 == 0:
        if S[i] == "0":
            cnt1 += 1
        else:
            cnt2 += 1
    else:
        if S[i] == "0":
            cnt2 += 1
        else:
            cnt1 += 1

print(min(cnt1, cnt2))

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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

#define int long long


signed main()
{
    int n;
    while(cin >> n, n) {
        vector<int> v(n);
        for(int i=0; i<n; ++i) cin >> v[i];
        sort(v);
        int sum = 0;
        for(int i=1; i<v.size()-1; ++i) sum += v[i];
        cout << sum / (v.size()-2) << endl;
    }
    return 0;
}

Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<(n); i++)
long long facctorialMethod(long long k){
    long long sum = 0;
    for (long long i = 1; i <= k; i++)
    {
        sum += i;
    }
    return sum;
}

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

    long long ans = 0;
    long long n = s.length();
    char str[n] = {'\0'};
    long long v[n] = {0};
    long long idx_str = 0;
    long long idx_v = 0;
    char tmp = s[0];
    str[idx_str++] = s[0];
    long long count = 1;
    for(long long i=1; i<n; i++){
        if(tmp == s[i]){
            count++;
        }
        else{
            str[idx_str++] = s[i];
            v[idx_v++] = count;
            count = 1;
            tmp = s[i];
        }
    }
    v[idx_v] = count;

    long long i =0;
    while(v[i] != 0){
        if(v[i-1]==0 && v[i]==1 && str[i-1]=='<' && str[i]=='>'){
            ans++;
        }

        if(v[i] == 1){
            v[i] = 0;
        }
        else if(str[i-1] == '<' && str[i] == '>' && v[i-1] >= v[i]){
            v[i]--;
        }
        else if(str[i-1] == '<' && str[i] == '>' && v[i-1] < v[i]){
            ans -= v[i-1];
        }
        

        if(v[i]!=0)
            ans += facctorialMethod(v[i]);
        
        i++;
    }

    if(s[0]=='>' && s[1]=='<'){
        ans++;
    }
    if(s[n-1]=='<' && s[n-2]=='>'){
        ans++;
    }
    
    if((s[0]=='<' && n == 1) || (s[0]=='>' && n == 1)){
        ans++;
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 5252
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define int long long
#define sz(x) (int)x.size()
#define mp make_pair
#define fi first
#define se second
#define io ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
#define INF 1e7

signed main()
{
	io;
	int x;
	cin >> x;
	if(x) cout << 0;
	else cout << 1;
}
 
	
		



Measured memory_bytes: 3684
#include<bits/stdc++.h>
#include<string.h>
#include<string>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int n=s.size();int c=0;
  for(int j=0;j<n/2;j++)
  {
    if(s[j]!=s[n-1-j])
    {
      c++;
    }
  }
  cout<<c;
  return 0;
}

Measured memory_bytes: 256
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#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 n, x;
	cin >> n >> x;
	int a[n + 1];
	a[0] = 0;
	for1(i, n){
		int x;
		cin >> x;
		a[i] = a[i - 1] + x;
	}
	cout << upper_bound(a, a + n + 1, x) - a<< '\n';
	return 0;
}


Measured memory_bytes: 256
# input
N, K = map(int, input().split())

# process/output
if K == 1:
    print(0)
else:
    n = N
    if n > K:
        n = n%K

    p = n
    while True:
        t = abs(p-K)
        if t > p:
            break
        p = t
    print(p)


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

int main(void) {

char inp[100];
int i;
int year;
double nm;
int c,j,count;
char str[100]={'\0'};
char *ln;

fgets(str, 100, stdin); // 入力："123456\n"
ln = strchr(str, '\n'); /* 改行文字を検索 */
if (ln != NULL) { /* 改行が読み取られていたかどうか */
   *ln = '\0';    /* 改行文字を終端文字に置き換える */
}
else {            /* 入力ストリーム上に文字が残ってる場合 */
   while (1) {    /* 改行文字が読み取られるまで空読みする */
       c = getchar();
      if (c == '\n' || c == EOF) break;
   }
}

//printf("%s\n",str);



double sum=0;

sscanf(str, "%d", &year);
//printf("%d\n",year);

for(i=1;i<=year;i++){


fgets(str, 100, stdin); // 入力："123456\n"
ln = strchr(str, '\n'); /* 改行文字を検索 */
if (ln != NULL) { /* 改行が読み取られていたかどうか */
   *ln = '\0';    /* 改行文字を終端文字に置き換える */
}
else {            /* 入力ストリーム上に文字が残ってる場合 */
   while (1) {    /* 改行文字が読み取られるまで空読みする */
       c = getchar();
      if (c == '\n' || c == EOF) break;
   }
}

//printf("%s\n",str);

 sscanf(str, "%lf %s", &nm, inp);

//printf("%lf\n",nm);
//printf("%s\n",inp);

if(strcmp(inp,"JPY")==0)
	sum=sum+nm;
else
	sum=sum+nm*380000.0;


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

    return 0;
}


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

using namespace std;

constexpr int MAXN=105;
char s[MAXN];

int main(){
	int K;
	scanf("%d%s",&K,s+1);
	int n=strlen(s+1);
	if(n<=K) printf("%s",s+1);
	else{
		for(int i=1;i<=K;++i)
			putchar(s[i]);
		printf("...");
	}
}


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

int main() {
  ll n;cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a.at(i);
	sort(a.begin(),a.end(),greater<ll>() );
	ll mid = a.front()/2;
	ll r;
	ll m = 99999999999;
	for(ll i=1;i<n;++i){
		ll num = abs(a.at(i)-mid);
		if( m > num ){
			m = num;
			r = a.at(i);
		}
	}
	cout << a.front() << " " << r << endl;
	return 0;
}

Measured memory_bytes: 4016
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define pr pair<int,int>
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
  ios_base::sync_with_stdio(false);
    // #ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //   freopen("output.txt", "w", stdout);
    // #endif
  int n,m; cin>>n>>m;
  vector<int> a(n);
  ll sum=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }

  sort(all(a));
  int c=0;
  for(int i=0;i<n;i++){
    if(sum>(4*m*a[i]))
      continue;
    c++;
  }
  if(c>=m)
    cout<<"Yes\n";
  else
    cout<<"No\n";
  return 0;
}

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

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
	int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

int n, k, ans;

int main() {
	read(n), read(k);
	for (int x, i = 1; i <= n; ++i) {
		read(x);
		ans += x >= k;
	}
	write(ans);
	putchar('\n'); 
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
const int N=12;
int mask,f[(1<<N)+10],n,T,c,m,k;
int mi(int a,int b){return a<b?a:b;}
int main()
{
	memset(f,0x3f,sizeof(f));
	f[0]=0;
	scanf("%d%d",&n,&T);
	while(T--)
	{
		scanf("%d%d",&c,&m);
		mask=0;
		while(m--)
		{
			scanf("%d",&k);
			mask|=1<<(k-1);
		}
		for(int i=0;i<(1<<n);i++)
			f[i|mask]=mi(f[i|mask],f[i]+c);
	}
	if(f[(1<<n)-1]==0x3f3f3f3f)f[(1<<n)-1]=-1;
	printf("%d",f[(1<<n)-1]);
	return 0;
}

Measured memory_bytes: 128
ary1 = [1, 3, 5, 7, 8, 10, 12]
ary2 = [4, 6, 9, 11]
ary3 = [2]
x = gets.chomp.split(" ").map(&:to_i)

a1 = 0
a2 = 0
a3 = 0
x.each do |v|
  a1 += 1 if ary1.include?(v)
  a2 += 1 if ary2.include?(v)
  a3 += 1 if ary3.include?(v)
end

puts a1 == 2 || a2 == 2 || a3 == 2 ? "Yes" : "No"

Measured memory_bytes: 1788
#include<stdio.h>
#define max 100000
int parent(int i){
return i/2;
}
int leftnode(int i){return 2*i;}
int rightnode(int i){return 2*i+1;}

int main(){
int n,i,H[max+1];
scanf("%d",&n);
for(i=1;i<=n;i++){
  scanf("%d",&H[i]);
}
for(i=1;i<=n;i++){
  printf("node %d: key = %d, ",i,H[i]);
  if(parent(i)>=1)printf("parent key = %d, ",H[parent(i)]);
  if(leftnode(i)<=n)printf("left key = %d, ",H[leftnode(i)]);
  if(rightnode(i)<=n)printf("right key = %d, ",H[rightnode(i)]);
  printf("\n");
}
return 0;
}



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

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		int x = Integer.parseInt(str);
		int[] prime = new int[200000];
		for (int n = 2;; n++) {
			if (prime[n] != 0)
				continue;
			if (n >= x) {
				System.out.println(n);
				break;
			}
			for (int np = n + n; np < 200000; np += n)
				prime[np] = 1;
		}
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 21844
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

const int MAXN = 100100;

int n, m, a, b;

set <int> s[MAXN];
vector <int> v[MAXN];
deque <int> sol;

int main() {
	scanf("%d %d",&n,&m);
	REP(i, m) {
		scanf("%d %d",&a,&b);
		s[a].insert(b);
		s[b].insert(a);
    v[a].push_back(b);
    v[b].push_back(a);
	}

  sol.push_back(1);
  sol.push_back(v[1][0]);

  REP(i, (int)v[1].size()) s[v[1][i]].erase(1);
  REP(i, (int)v[sol.back()].size()) s[v[sol.back()][i]].erase(sol.back());

  while (!s[sol.front()].empty()) {
    int A = *s[sol.front()].begin();
    sol.push_front(A);
    REP(i, (int)v[A].size()) s[v[A][i]].erase(A);
  }
  while (!s[sol.back()].empty()) {
    int A = *s[sol.back()].begin();
    sol.push_back(A);
    REP(i, (int)v[A].size()) s[v[A][i]].erase(A);
  }

  printf("%d\n",(int)sol.size());
  REP(i, (int)sol.size()) printf("%d ",sol[i]);
  puts("");

	return 0;
}


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

int main(){
    int N,M;
    cin >> N >> M;
    int all = 0;
    vector<int>vec(N);
    for(int i=0;i<N;i++){
        cin >> vec[i];
        all += vec[i];
    }
    sort(vec.rbegin(),vec.rend());
    if(vec[M-1]*4*M >= all){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" <<endl;
    }
}


Measured memory_bytes: 256
a, b, x = list(map(int, input().split()))
import math

if a * a * b / 2 <= x:
  t = (2 * (a * a * b - x)) / (a * a * a)
else:
  t = a * b * b / x / 2

x = math.degrees(math.atan(t))
print(x)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
string s,t;
int dp[3001][3001];
int lcs(int i,int j)
{
    if(dp[i][j]!=-1)
    return dp[i][j];
    if(i==0||j==0)
    return dp[i][j]=0;
    if(s[i-1]==t[j-1])
    return dp[i][j]=lcs(i-1,j-1)+1;
    return dp[i][j]=max(lcs(i,j-1),lcs(i-1,j));
    
}
int main()
{ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);

    
    cin>>s>>t;
    int i,j;

   memset(dp,-1,sizeof(dp));
   
    int l=lcs(s.size(),t.size());
    
     dp[0][0]=0;
    int k=l;
     char ans[l+1];
     ans[l]=' ';
     l--;
    i=s.size();
    j=t.size();

   while(i>0&&j>0)
    {
        if(s[i-1]==t[j-1])
           {
               ans[l]=s[i-1];
              
             l--;
             
               
               i--;
               j--;
               
               
                
           }
           
           
           
              else if(dp[i-1][j]>dp[i][j-1])
               i--;
               else
               j--;
           
           
    }
    for(i=0;i<k;i++)
    cout<<ans[i];
    

return 0;

    
}

Measured memory_bytes: 35968