akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}
void solve()
{	
	ll n;
	cin >> n;
	if(n % 2){
		cout << 0 << endl;
		return;
	}
	ll res = 0;
	ll cur = 10;
	while(cur <= n){
		res += n / cur;
		cur *= 5;
	}
	cout << res;
}	


 
 
int main()
{
    Red;
  	solve();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{

	int a,b,n,i;

	n=0;

	scanf("%d%d",&a,&b);

	for(i=0; i<=1; i++)
	{
		if(a>b)
		{
			n=n+a;
			a=a-1;
		}
		else
		{
			n=n+b;
			b=b-1;
		}
	}

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

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (ll)c.size()
#define fr first
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for(ll i=a ; i<n ; i++)
#define ld long double
const ll INF = __LONG_LONG_MAX__;
#define rall(a) (a).rbegin(),(a).rend()
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

ll power(ll b,ll e,ll m)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
}

void solve()
{
 ll a,b,c;
 cin>>a>>b>>c;
 if(a+b+c>=22) cout<<"bust";
 else cout<<"win";
}

int main()
{
  fastio
  ll tt=1;
  // cin>>tt;
  while(tt--)
  {
      solve();
      cout<<"\n";
  }
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>

#define min(x, y) ( (x<y) ? (x) : (y) )

int main(){

    long long int tim[5], tim2[5], N=0, ans;
    int i;

    scanf("%lld", &N);
    for (i=0; i<5; i++){
        scanf("%lld", &tim[i]);
    }

    long long int min_num = tim[0];
    for (i=0; i<5; i++){
        if (i>=1) min_num = min(tim[i], min_num);
        tim2[i] = N/min_num;
        if (N%min_num != 0) tim2[i]++;
    }

    ans = tim2[0]+4ll;
    for (i=1; i<5; i++){
        ans += tim2[i] - tim2[i-1];
    }

    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,k,r,s,p,ans=0,a[1000000]={};
  string t;
  cin>>n>>k>>r>>s>>p>>t;
  for(int i=0;i<k;i++){
    if(a[i]==0){
      if(t[i]=='r')
        ans+=p;
      if(t[i]=='s')
        ans+=r;
      if(t[i]=='p')
        ans+=s;
    }
  }
  for(int i=k;i<n;i++){
    if(t[i]==t[i-k]){
      if(t[i]=='r'  && a[i-k]!=1)
        a[i]=1;
      if(t[i]=='s' && a[i-k]!=2)
 		a[i]=2;
      if(t[i]=='p'  && a[i-k]!=3)
  		a[i]=3;
    }
    if(a[i]==0){
      if(t[i]=='r')
        ans+=p;
      if(t[i]=='s')
        ans+=r;
      if(t[i]=='p')
        ans+=s;
    }
  }
  cout<<ans<<endl;
  return(0);
}
  

Measured memory_bytes: 8448
{
  const main = (input: string) => {
    const r = reader(input)

    const M = r.n()
    const { lines } = r

    let sum = 0
    let dsum = 0
    for (let i = 0; i < M; i++) {
      const [d, c] = lines[i].split(' ').map(Number)
      sum += d * c
      dsum += c
    }
    const res = dsum - 1 + Math.floor((sum - 1) / 9)

    console.log(res)
  }

  const reader = (str: string) => {
    const lines = str.trim().split('\n')
    const s = () => lines.shift() || ''
    const line = s
    const n = () => Number(s())

    const ss = () => s().split(' ')
    const ns = () => ss().map(Number)
    return { lines, line, s, n, ss, ns }
  }

  main(require('fs').readFileSync('/dev/stdin', 'utf8'))
}


Measured memory_bytes: 39728
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long h, w; cin >> h >> w; char test[101][101];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> test[i][j];
		}
	}
	for (int i = 1; i <= w + 2; i++) {
		cout << '#';
	}
	cout << endl;
	for (int i = 0; i < h; i++) {
		cout << '#';
		for (int j = 0; j < w; j++) {
			cout << test[i][j];
		}
		cout << '#' << endl;
	}
	for (int i = 1; i <= w + 2; i++) {
		cout << '#';
	}
	cout << endl;
	cin >> h;
}

Measured memory_bytes: 764
import java.util.Scanner;

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



		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int[] p = new int[n];
		int smallest = 200001;
		int counter = 0;
		for(int i =0;i<n;i++) {
			p[i] = sc.nextInt();
			if(p[i]<=smallest) {
				counter++;
				smallest  =p[i];
			}
		}
		System.out.println(counter);

	}

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 82952
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")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize
    }
    println!("{}", (n + 1) / 2);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  vector<vector<ll>> dp(n+1, vector<ll>(n+1, 0));

  for (int len = 1; len <= n; len++) {  // 区間の短い順に決めていく
    for (int l = 0; l + len <= n; l++) {
      int r = l + len;
      if ((n - len) % 2 == 0) {  // 先手
        dp[l][r] = max(dp[l + 1][r] + a[l], dp[l][r - 1] + a[r - 1]);
        cerr << dp[l][r] << endl;
      } else {  // 後手
        dp[l][r] = min(dp[l + 1][r] - a[l], dp[l][r - 1] - a[r - 1]);
      }
    }
  }

  cout << dp[0][n] << endl;

  return 0;
}


Measured memory_bytes: 72832
#ifdef _MSC_VER
#  define _CRT_SECURE_NO_WARNINGS
#  define _USE_MATH_DEFINES
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double;
using u32 = unsigned int; using u64 = unsigned long long int; using str = string;
template <typename T> using vec = vector<T>; void in() { }
template <typename T, typename...TS> void in(T &&x, TS &&...xs) { cin >> x; in(move(xs)...); }
template <typename T> void out(T &&x) { cout << x << "\n"; }
template <typename T, typename...TS> void out(T &&x, TS &&...xs) { cout << x << " "; out(move(xs)...); }
#define indef(t, ...) t __VA_ARGS__; in(__VA_ARGS__)
#define get(t) []{ t x; cin >> x; return x; }()
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define even(x) ((abs(x) & 1) == 0)
#define odd(x) ((abs(x) & 1) == 1)
#define bit(x, i) (((x) >> i) & 1)
#define append emplace_back
#define bisect_left lower_bound
#define bisect_right upper_bound
#define bound(a, x, b) (a <= x && x <= b)
const i64 MOD = 1000000007ll;
const f64 EPS = 1e-10;

pair<i32, i32> p[201];
i32 dp[201][201][100];

void solve() {
    indef(str, s);
    str ans = "";
    ans += s[0];
    ans += to_string(s.size() -2);
    ans += s[s.size()-1];
    out(ans);
}

i32 main()
{
    ios::sync_with_stdio(false);

#ifdef _MSC_VER
    /**
    ifstream fin("input.txt"); cin.rdbuf(fin.rdbuf()); assert(fin);
    ofstream fout("output.txt"); cout.rdbuf(fout.rdbuf()); assert(fout);
    /**/
#endif

    //cout << fixed << setprecision(9);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
using namespace std;

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  int D = A + B;
  int E = B + C;
  int F = C + A;
cout << min({D,E,F}) << endl;
}

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

int n, m, dp[4096], keys[1000][2];
vector<int> bit[13];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		int a, b, c, st = 0;
		cin >> a >> b;
		for(int j = 0; j < b; j++){
			cin >> c;
			st |= (1 << (c - 1));
		}
		keys[i][0] = a, keys[i][1] = st;
	}
	for(int i = 0; i < (1 << n); i++){
		int cnt = 0;
		for(int j = 0; j < n; j++) cnt += ((i & (1 << j)) > 0);
		bit[cnt].push_back(i);
	}
	for(int i = 0; i < (1 << n); i++) dp[i] = INT_MAX;
	dp[0] = 0;
	for(int i = 0; i <= n; i++)
		for(auto j : bit[i]){
			if(dp[j] == INT_MAX) continue;
			for(int k = 0; k < m; k++) dp[j | keys[k][1]] = min(dp[j | keys[k][1]], dp[j] + keys[k][0]);
		}
	cout << ((dp[(1 << n) - 1] == INT_MAX) ? -1 : dp[(1 << n) - 1]) << "\n";
	return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix

import numpy as np

N,M,L = map(int,readline().split())
ABCPST = np.array(read().split(),np.int64)
ABC = ABCPST[:M+M+M]
A = ABC[::3]; B = ABC[1::3]; C = ABC[2::3]
ST = ABCPST[M+M+M+1:]
S = ST[::2]; T = ST[1::2]

# とりあえず、補給抜きにして最短距離を求める
graph = csr_matrix((C,(A,B)),(N+1,N+1))
dist_mat = floyd_warshall(graph,directed=False)

# 補給なしに行ける移動を1手とする

graph2 = np.full((N+1,N+1),np.inf)
np.fill_diagonal(graph2,0)
graph2[dist_mat<=L] = 1

dist_mat2 = floyd_warshall(graph2,directed=False)

dist_mat2[dist_mat2 == np.inf] = 0
dist_mat2 = (dist_mat2).astype(int)

x = dist_mat2[S,T] - 1

print('\n'.join(x.astype(str)))


Measured memory_bytes: 37960
# include<iostream>
# include<cstring>
# include<cstdio>
# include<algorithm>
# define LL long long
using namespace std;
const int MAX=1e5+1;
int n;
LL A;
LL s[MAX<<1],a[MAX],b[MAX],c[MAX];
int lowbit(int x)
{
	return x&-x;
}
void change(int x,int dis)
{
	for(int i=x;i<=200000;i+=lowbit(i))
	  s[i]+=dis;
}
LL ask(int x)
{
	LL ans=0;
	for(int i=x;i;i-=lowbit(i))
	  ans+=s[i];
	return ans;
}
bool look(int mid)
{
	memset(s,0,sizeof(s));
	LL x=a[mid];
	LL ans=0;
	for(int i=1;i<=n;++i)
	  {
	  	if(b[i]>=x) c[i]=1;
		else if(b[i]<x) c[i]=-1;
	  }
	LL sum=0;
	change(100000,1);
	for(int i=1;i<=n;++i)
	  sum+=c[i],ans+=ask(100000+sum),change(100000+sum,1);
	return ans>=A/2+(A%2);
}
int main()
{
	scanf("%d",&n);
	A=1ll*n*(n+1)/2;
	for(int i=1;i<=n;++i)
	  scanf("%lld",&a[i]),b[i]=a[i];
	sort(a+1,a+1+n);
	int l=1,r=n,ans=0;
	while(l<=r)
	{
		int mid(l+r>>1);
		if(look(mid)) l=mid+1,ans=mid;
		else r=mid-1;
	}
	return printf("%d",a[ans]),0;
}

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

/*
uint64_t lucas(int num) {
  if (num == 0) { 
    return 2;
  } else if (num == 1) {
    return 1;
  }  
  return lucas(num-2) + lucas(num-1);
}
*/

uint64_t lucas(int num) {
  uint64_t ans = 0;
  uint64_t n_1 = 0;
  uint64_t n_2 = 0;
  for (int i=0; i<=num; i++) { 
    if (i == 0) {
      n_2 = 2;
      if (num == 0) {
        return 2;
      }
    } else if (i == 1) {
      n_1 = 1;
      if (num == 1) {
        return 1;
      }
    } else { 
      ans = n_1 + n_2;
      n_2 = n_1;
      n_1 = ans;
    }
  }
  return ans;
}
      
int main() {
  int num;
  cin >> num;
  cout << lucas(num) << endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  int n;
  cin>>n;
  while(n--){
    double xa,ya,xb,yb;
    double ra,rb;
    cin>>xa>>ya>>ra;
    cin>>xb>>yb>>rb;
    double dist = sqrt((xb-xa)*(xb-xa)+(yb-ya)*(yb-ya));
    if(dist > ra+rb){
      cout<<0<<endl;
    }else if(dist+rb < ra){
      cout<<2<<endl;
    }else if(dist+ra < rb){
      cout<<-2<<endl;
    }else{
      cout<<1<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
int kaibun(int x);

int main() {
  int a, b;
  cin >> a >> b;
  int sum = 0;
  for(int i = a; i < b+1; i++) {
    if(kaibun(i) == 1) sum++;
  }
  
  cout << sum << endl;
}

int kaibun(int x) {
 int s = x % 10, t = x / 10000 % 10;
 int u = x / 10 % 10, v = x / 1000 % 10; 
 if (s == t &&u == v) return 1;
 return 0;
}

Measured memory_bytes: 256
import bisect
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
a.sort()
b.sort()
c.sort()

ans=0
for i in range(n):
    ida=bisect.bisect_left(a,b[i])
    idc=bisect.bisect_right(c,b[i])
    ans+=(ida*(n-idc))
print(ans)

            

Measured memory_bytes: 23232
#include<stdio.h>
int main(void) {
  char s[3];
  scanf("%c%c%c", &s[0], &s[1], &s[2]);
  int c = 0;
  if(s[0] == '1') {
    c++;
  }
  if(s[1] == '1') {
    c++;
  }
  if(s[2] == '1') {
    c++;
  }
  printf("%d\n", c);
  return 0;
}

Measured memory_bytes: 2052
#include <iostream>
#include <deque>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#define llint long long
#define mod 998244353
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;
typedef pair<llint, P> E;

struct SegTree{
	int size;
	vector<P> seg;
	
	SegTree(){}
	SegTree(int size){
		this->size = size;
		seg.resize(1<<(size+1));
	}
	
	void init()
	{
		for(int i = 0; i < (1<<(size+1)); i++) seg[i] = P(inf, inf);
	}
	
	void update(int i, P val)
	{
		i += (1 << size);
		seg[i] = val;
		while(i > 1){
			i /= 2;
			seg[i] = min(seg[i*2], seg[i*2+1]);
		}
	}

	P query(int a, int b, int k, int l, int r)
	{
		if(b < l || r < a) return P(inf, inf);
		if(a <= l && r <= b) return seg[k];
		P lval = query(a, b, k*2, l, (l+r)/2);
		P rval = query(a, b, k*2+1, (l+r)/2+1, r);
		return min(lval, rval);
	}
	P query(int a, int b)
	{
		if(a > b) return P(inf, inf);
		return query(a, b, 1, 0, (1<<size)-1);
	}
};

struct UnionFind{
	int size;
	vector<int> parent;
	
	UnionFind(){}
	UnionFind(int size){
		this->size = size;
		parent.resize(size+1);
		init();
	}
	void init(){
		for(int i = 0; i <= size; i++) parent[i] = i;
	}
	int root(int i){
		if(parent[i] == i) return i;
		return parent[i] = root(parent[i]);
	}
	bool same(int i, int j){
		return root(i) == root(j);
	}
	void unite(int i, int j){
		int root_i = root(i), root_j = root(j);
		if(root_i == root_j) return;
		parent[root_i] = root_j;
	}
};

llint n, d;
llint a[200005];
SegTree lseg(18), rseg(18);
vector<P> vec;
vector<E> evec;
UnionFind uf(200005);

int main(void)
{
	cin >> n >> d;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) vec.push_back(P(a[i], i));
	sort(vec.begin(), vec.end());
	
	lseg.init(), rseg.init();
	for(int i = 0; i < vec.size(); i++){
		int p = vec[i].second;
		P res = lseg.query(1, p-1);
		if(res.first < inf/2) evec.push_back(E(res.first+p*d+a[p], P(p, res.second)));
		res = rseg.query(p+1, n);
		if(res.first < inf/2) evec.push_back(E(res.first-p*d+a[p], P(p, res.second)));
		lseg.update(p, P(a[p]-p*d, p));
		rseg.update(p, P(a[p]+p*d, p));
	}
	sort(evec.begin(), evec.end());
	
	llint ans = 0;
	for(int i = 0; i < evec.size(); i++){
		llint u = evec[i].second.first, v = evec[i].second.second, w = evec[i].first;
		if(uf.same(u, v)) continue;
		ans += w;
		uf.unite(u, v);
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 40168
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>

int main() {
  int K, X;
  scanf("%d %d", &K, &X);

  for (int i = -(K-1); i < K; ++i)
    printf("%d%c", X+i, i+1<K? ' ': '\n');
}


Measured memory_bytes: 128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
H = LIST()

if K >= N:
	print(0)
else:
	print(sum(sorted(H, reverse=True)[K:]))


Measured memory_bytes: 27232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define gc getchar
#define pc putchar
inline ll rd(){
    ll x=0,f=1;char c=gc();
    for(;!isdigit(c);c=gc())if(c=='-')f=-1;
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return x*f;
}
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void writeln(ll x){write(x);puts("");}
const int N=100005;
int fl[N],pri[N],n,ans;
ll a[N],b[N];
map<ll,int> s,vis;
int main(){
	Rep(i,2,N-1){	
		if (!fl[i]) pri[++*pri]=i;
		Rep(j,1,*pri){
			if (i*pri[j]>=N) break;
			fl[i*pri[j]]=1;
			if (i%pri[j]==0) break;
		}
	}
	scanf("%d",&n);
	Rep(i,1,n){
		scanf("%lld",&a[i]);
		ll k=a[i]; a[i]=b[i]=1;
		Rep(j,2,2200){
			if (k==1) break;
			if (fl[j]) continue;
			ll t=1ll*j*j*j;
			for (;k%t==0;k/=t);
			if (k%(j*j)==0) a[i]*=j*j,b[i]*=j;
			else if (k%j==0) a[i]*=j,b[i]*=j*j;
			for (;k%j==0;k/=j);
		}
		if (k>1){
			ll t=(ll)(sqrt(k));
			if (1ll*t*t==k) a[i]*=k,b[i]*=t;
			else a[i]*=k,b[i]*=k*k;
		}
	}
	Rep(i,1,n) s[a[i]]++;
	Rep(i,1,n) if (!vis[a[i]]){
		vis[a[i]]=1;
		if (a[i]==b[i]) ans++;
		else ans+=max(s[a[i]],s[b[i]]),vis[b[i]]=1;
	}
	printf("%d",ans);
}


Measured memory_bytes: 27264
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=200005;
int n,a[max_n];
int main(){
    scanf("%d",&n);
    ll sum=0;
    for(int i=1;i<=n;i++){
        scanf("%d",a+i);
        sum+=a[i];
    }
    ll x=0;
    ll ans=1e18;
    for(int i=1;i<n;i++){
        x+=a[i];
        ans=min(ans,abs(sum-2*x));
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1024
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: usize,
        h_vec: [usize; n],
    }

    let mut ans = 0;
    let mut current = 0;
    let mut prev = h_vec[0];
    for i in 1..h_vec.len() {
        if prev >= h_vec[i] {
            current += 1;
        } else {
            current = 0;
        }
        ans = std::cmp::max(ans, current);
        prev = h_vec[i];
    }
    println!("{}", ans);
}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";

string vow = "aeiou";

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

void solve ( int test_case )
{
    int n , m ;
    cin >> n >> m ;

    vvb v ( m , vb ( n ) ) ;
    for ( int i=0 ; i < m ; i++ )
    {
        int t ; cin >> t ;

        while ( t-- )
        {
            int temp ; cin >> temp ;
            temp -- ;

            v[i][temp] = true ;
        }
    }

    vi req ( m ) ;
    for ( int i=0 ; i < m ; i++ ) cin >> req[i] ;

    int maxx = 1 << n ;
    int ans = 0 ;
    for ( int k = 0 ; k < maxx ; k++ )
    {
        int b ;
        for ( b = 0 ; b < m ; b++ ) // bulb
        {
            int mask = k ;
            int indx = 0 ;
            int cnt = 0 ;

            for ( ; mask > 0 ; mask >>= 1 , indx ++ )
            {
                int bit = (mask&1) ;

                if ( bit == 1 && v[b][indx] == true )
                    cnt ++ ;
            }

            if ( cnt % 2 != req[b] )
                break ;
        }

        if ( b == m ) ans ++ ;
    }

    cout << ans ; line
}

int main()
{fast
    int t = 1;
    //cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

ll modpow(ll a, int n) {
    ll res = 1;
    while (n) {
        if (n & 1)
            (res *= a) %= MOD;
        (a *= a) %= MOD;
        n >>= 1;
    }
    return res;
}

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

    string L;
    cin >> L;

    int N = L.length();
    ll pow2 = 1, pow3 = modpow(3, N);
    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        (pow3 *= 333333336) %= MOD;
        if (L[i] == '0')
            continue;
        ans += pow2 * pow3 % MOD;
        ans %= MOD;
        (pow2 *= 2) %= MOD;
    }
    ans += pow2;

    cout << ans % MOD << endl;

    return 0;
}


Measured memory_bytes: 3768
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

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

int main() {
  int n;
  cin >> n;
  vector<int> ans(n + 1);
  rep(i, n + 1) {
    int num = i;
    while (1) {
      if (num == 0) break;
      if (num % 2 == 0)
        ans[i]++;
      else
        break;
      num /= 2;
    }
  }
  cout << distance(ans.begin(), max_element(ans.begin() + 1, ans.end()))
       << endl;
  return 0;
}


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

struct Node {
	ll k;
	Node* r, * l, * p;
};
Node* root, * NIL;
Node* treeMinimum(Node* x) {
	while (x->l != NIL) x = x->l;
	return x;
}
Node* find(Node* u, ll k) {
	while (u != NIL && k != u->k) {
		if (k < u->k)u = u->l;
		else u = u->r;
	}
	return u;
}
void treeDelete(Node* z) {
	Node* y, * x;
	if (z->l == NIL || z->r == NIL)y = z;
	else y = treeMinimum(z->r);
	if (y->l != NIL) {
		x = y->l;
	}
	else {
		x = y->r;
	}
	if (x != NIL) {
		x->p = y->p;
	}
	if (y->p == NIL) {
		root = x;
	}
	else {
		if (y == y->p->l) {
			y->p->l = x;
		}
		else {
			y->p->r = x;
		}
	}
	if (y != z) {
		z->k = y->k;
	}
	free(y);
}
void insert(ll k) {
	Node* y = NIL;
	Node* x = root;
	Node* z;
	z = (Node*)malloc(sizeof(Node));
	z->k = k;
	z->l = NIL;
	z->r = NIL;
	while (x != NIL) {
		y = x;
		if (x->k > k) x = x->l;
		else x = x->r;
	}
	z->p = y;
	if (y == NIL) {
		root = z;
	}
	else {
		if (z->k < y->k) {
			y->l = z;
		}
		else {
			y->r = z;
		}
	}
}
void inorder(Node* u) {
	if (u == NIL)return;
	inorder(u->l);
	cout << " " << u->k;
	inorder(u->r);
}
void preorder(Node* u) {
	if (u == NIL)return;
	cout << " " << u->k;
	preorder(u->l);
	preorder(u->r);
}

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

	ll n, x; cin >> n;
	string com;
	for (int i = 0; i < n; i++) {
		cin >> com;
		if (com[0] == 'f') {
			cin >> x;
			Node* t = find(root, x);
			if (t != NIL)cout << "yes" << endl;
			else cout << "no" << endl;
		}
		else if (com[0] == 'i') {
			cin >> x;
			insert(x);
		}
		else if (com[0] == 'p') {
			inorder(root);
			cout << endl;
			preorder(root);
			cout << endl;
		}
		else if (com[0] == 'd') {
			cin >> x;
			treeDelete(find(root, x));
		}
	}
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; exit(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<ull> vul;
typedef vector<vector<ull>> vvul;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ull x;
    cin >> x;
    ll num = x / 11;
    x -= num * 11;
    
    if (x == 0) {
        END(num * 2)
    }
    if (x <= 6) {
        END(num * 2 + 1)
    }
    if (x <= 11) {
        END(num * 2 + 2)
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000

int main(){
  ll n;
  cin >> n;
  vll A(n);
  vll count(n);
  vll kake(n);
  rep(i,n){
    cin >> A[i];
    A[i]--;
    count[A[i]]++;
  }
  rep(i,n){
    kake[i] = count[i]*(count[i] - 1)/2;
  }
  //rep(i,n) cout << kake[i] << endl;
  ll sum = 0;
  rep(i,n){
    sum += kake[i];
  }
  rep(i,n){
    if(count[A[i]] > 0){
    	cout << sum - (count[A[i]]-1) << endl;
    }
    else
      cout << sum - count[A[i]] << endl;
  }
}

Measured memory_bytes: 7296
#include <stdio.h>

int main(void){
  char moji1, moji2;

  scanf("%c %c", &moji1, &moji2);

  if(moji1 > moji2){
    printf(">\n");
  }else if(moji1 < moji2){
    printf("<\n");
  }else{
    printf("=\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
	string a,b;
	cin>>a>>b;
	int c=stoi(a+b);
	bool root=false;
	for(int i=0;i<500;i++){
		if(i*i==c) root=true; 
	}
	cout<<(root? "Yes": "No")<<endl;

}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
x = (sum([A[i] for i in range(N) if i % 2 == 0]) - sum([A[i] for i in range(N) if i % 2 == 1]))
print(x)
for  i in range(N-1):
    x = 2*A[i]-x
    print(x)

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

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

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


int main()
{
	int K, T;
	cin >> K >> T;
	vector<int> a(T);
	int sum = 0;
	int max = -1;
	int maxindex = -1;
	REP(i, T) {
		cin >> a[i];
		sum += a[i];
		if (a[i] > max) {
			max = a[i];
			maxindex = i;
		}
	}
	sum -= max;
	if (sum >= max - 1) {
		cout << "0" << endl;
	}
	else {
		cout << max - sum - 1 << endl;
	}
}

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

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define all(a) (a).begin(), (a).end()

int main() {
	int n;
	cin >> n;
	for (int i = 3; i <= n; ++i) {
		string s = to_string(i);
		if (i % 3 == 0 || s.find('3') != string::npos)
			cout << " " << i;
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 3240
n = int(input())
N = n
print(n, end = ":")
i = 2
ans_list = []
while i <= n:

    if i * i > N and len(ans_list) == 0:
        ans_list.append(N)
        break

    while n % i == 0:
        ans_list.append(i)
        n //= i
    i += 1
for i in ans_list:
    print(" ", end = "")
    print(i, end = "")
print()


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Placing Marbles
            var s = Console.ReadLine();

            Console.WriteLine(s.Count(x => x == '1'));
        }
    }
}

Measured memory_bytes: 11220
#include<stdio.h>

bool used[900000];
int main() {
	int n, x; scanf("%d%d", &n, &x);
	int j = 2 * n - 1;
	if (x != 1 && x != j) {
		puts("Yes");
		if (x + j / 2 <= j) {
			for (int i = x + j / 2; i >= x; i--) { printf("%d\n", i); used[i] = 1; }
			for (int i = 1; i <= j; i++) { if (!used[i])printf("%d\n", i); }
		}
		else {
			for (int i = x - j / 2; i <= x; i++) { printf("%d\n", i); used[i] = 1; }
			for (int i = j; i >= 1; i--) { if (!used[i])printf("%d\n", i); }
		}
	}
	else puts("No");
}

Measured memory_bytes: 1536
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}

	return d;
}

lli num[200000] = {};
lli a[200000] = {};


lli n, k;

void dfs(lli i, lli count, lli left) {

	if (left == 0) {
		cout << i + 1 << endl;
		return;
	}

	//cerr << i << " " << count << " " << left << endl;

	if (num[i] == -1) {
		num[i] = count;
	}
	else {
		if (count - num[i] == 0) {
			left = 0;
		}
		else {
			//cerr << "count - num[i]" << (count - num[i]) << endl;
			left %= (count - num[i]);
		}
		if (left == 0) {
			cout << i + 1 << endl;
			return;
		}
	}
	dfs(a[i], count + 1, left - 1);

	return;
}


int main(void) {

	cin >> n >> k;
	for (lli i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
		num[i] = -1;
	}

	dfs(0, 0, k);

	return 0;
}

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

int re(int x) {
	if (x<0) return -x;
	else return x;
}

int main(void) {
	int a, b, c, d;

	cin >> a >> b >> c >> d;

	if (re(a - c) <= d) cout << "Yes";
	else if (re(a - b) <= d && re(b - c) <= d) cout << "Yes";
	else cout << "No";

	return 0;
}



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

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

    bool flag = false;
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            int mult = i*j;
            if(mult == N)
                flag = true;
        }
    }

    if(flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}

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

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		double[] x = new double[20];
		double[] y = new double[20];
		int i = 0;
		String string;
		
		while((string = reader.readLine()) != null){
			x[i] = Double.valueOf(string.split(",")[0]);
			y[i] = Double.valueOf(string.split(",")[1]);
			i++;
		}
		
		double a = Math.hypot(x[1] - x[0], y[1] - y[0]);
		double b = Math.hypot(x[2] - x[0], y[2] - y[0]);
		double c = Math.hypot(x[2] - x[1], y[2] - y[1]);
		double z = (a + b + c) / 2;
		double S = Math.sqrt(z * (z - a) * (z - b) * (z - c));
		for(int j = 2; j < i - 1; j++){
			a = Math.hypot(x[j] - x[0], y[j] - y[0]);
			b = Math.hypot(x[j + 1] - x[0], y[j + 1] - y[0]);
			c = Math.hypot(x[j + 1] - x[j], y[j + 1] - y[j]);
			z = (a + b + c) / 2;
			S += Math.sqrt(z * (z - a) * (z - b) * (z - c));
		}
		System.out.println(S);
	}
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  ll ans = 1;
  for(int i=1;i<=n;++i) {
    ans *= i;
    ans %= MOD;
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pii pair<int,int>
#define pb push_back
#define INF INT_MAX
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)
#define iso ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
int main()
{
    iso;
    int n,k;
    cin>>n>>k;
    int ar[n+1];
    f(i,1,n+1)cin>>ar[i];
    ll dp[n+1];

    dp[1]=0;
    dp[2]=abs(ar[1]-ar[2]);
    for(int i=3;i<=n;i++)
    {
       ll m=INT_MAX;
        for(int j=i-1;j>=1&&j>=i-k;j--)
        m=min(dp[j]+abs(ar[i]-ar[j]),m);
     dp[i]=m;
    }
    //for(int i=1;i<=n;i++)cout<<dp[i]<<" ";
    //cout<<"\n";
    cout<<dp[n];
}


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

//AC by deitorial
int main(){
  int h, n;
  cin>>h>>n;
  int INF = 1<<29;

  vector<int> dp(h+10010, INF);
  dp[0] = 0;

  int a, b;
  for(int rp=0; rp<n; rp++){
    cin>>a>>b;
    for(int i=0; i<=h; i++){
      dp[i+a] = min(dp[i+a], dp[i]+b);
    }
  }

  //int ans = *min_element(dp.begin()+h, dp.end());
  int ans = INF;
  for(int i=h; i<h+10010; i++){
    ans = min(ans, dp[i]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#define LOCAL
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char c) {return to_string((string) &c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll N; cin >> N;
    ll n = 1LL << N;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<Pll> dp(n, {0,0});
    rep(i,n){
        dp[i] = {a[i], 0};
    }
    auto merge = [&](Pll &a, Pll &b) -> Pll{
        Pll ret;
        if(a.first > b.first){
            ret.first = a.first;
            if(a.second > b.first)ret.second = a.second;
            else ret.second = b.first;
        }
        else{
            ret.first = b.first;
            if(a.first > b.second)ret.second = a.first;
            else ret.second = b.second;
        }
        return ret;
    };

    rep(j, N){
        rep(i, n){
            if((i >> j) & 1){
                dp[i] = merge(dp[i], dp[i & ~(1LL << j)]);
            }
        }
    }

    vector<ll> ans(n);
    reps(i,n-1){
        chmax(ans[i], ans[i-1]);
        chmax(ans[i], dp[i].first + dp[i].second);
    }

    reps(i,n-1){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 11264
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n; cin >> n;
    cout << (n-1)/2 << endl;
    
}

Measured memory_bytes: 256
N,M=map(int,input().split())
from1=set()
toN=set()
for i in range(M):
  a,b=map(int,input().split())
  if a==1:
    from1.add(b)
  elif b==N:
    toN.add(a)
print(("","IM")[len(from1&toN)==0]+"POSSIBLE")
  

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

using namespace std;

bool check(int x){
  if(x == 1) return true;
  for(int i=2; i<x; i++){
    int tmp = i;
    while(tmp < x){
      tmp *= i;
      if(tmp == x) return true;
    }
  }
  return false;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x;
  cin >> x;
  for(int i=x; i>=1; i--){
    if(check(i)){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256