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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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; }

void Main(){
    int D,T,S; cin >> D >> T >> S;
    cout << (T*S>=D ? "Yes" : "No") << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    FOR(i,1, 100000000){
        if(a*i % b ==c){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << "\n";
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_mut)]
#![allow(non_snake_case)]

//　高速 EOF要
//macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();input_inner!{iter, $($r)*}};($($r:tt)*) => {let mut s = {use std::io::Read;let mut s = String::new();std::io::stdin().read_to_string(&mut s).unwrap();s};let mut iter = s.split_whitespace();input_inner!{iter, $($r)*}};}
//macro_rules! input_inner {($iter:expr) => {};($iter:expr, ) => {};($iter:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($iter, $t);input_inner!{$iter $($r)*}};}
//macro_rules! read_value {($iter:expr, ( $($t:tt),* )) => {( $(read_value!($iter, $t)),* )};($iter:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()};($iter:expr, chars) => {read_value!($iter, String).chars().collect::<Vec<char>>()};($iter:expr, usize1) => {read_value!($iter, usize) - 1};($iter:expr, $t:ty) => {$iter.next().unwrap().parse::<$t>().expect("Parse error")};}
// 低速 EOF不要
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")};}

// https://beta.atcoder.jp/contests/arc101/tasks/arc101_a

fn main(){
    input!{N:i64,K:i64,x:[i64;N]};
//    let N:i64 = N;
//    let K:i64 = K;
//    let x:Vec<i64> = x;
    let windows = x.windows(K as usize);
    let mut ans = i64::max_value();
    for window in windows{
        let L = window.first().unwrap();
        let R = window.last().unwrap();
        if L*R < 0 {
            ans = std::cmp::min(ans,std::cmp::min(L.abs(),R.abs()) + L.abs() + R.abs());
        }else{
            ans = std::cmp::min(ans,std::cmp::max(L.abs(),R.abs()));
        }
    }
    println!("{}",ans);
}

Measured memory_bytes: 4476
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long int LL;
const LL MAX=1e9+7;
vector<LL> x;
int go[35][100005];
LL s[100005];
int main(){
	LL n,l,q;
	int i,j,k;
	LL a,b,c;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a;
		x.push_back(a);
	}
	cin>>l>>q;
	for(j=0;j<n;j++){
		auto itr=upper_bound(x.begin(),x.end(),x[j]+l);
		go[0][j]=(int)distance(x.begin(),itr-1);
	}
	for(i=1;i<=30;i++){
		for(j=0;j<n;j++){
			go[i][j]=go[i-1][go[i-1][j]];
		}
	}
	for(i=0;i<q;i++){
		cin>>a>>b;
		a--,b--;
		if(a>b)swap(a,b);
		for(j=30;j>=0;j--){
			if(go[j][a]>=b)continue;
			s[i]+=(1<<j);
			a=go[j][a];
		}
		s[i]++;
	}
	for(i=0;i<q;i++){
		cout<<s[i]<<endl;
	}
	return 0;
}
		
		


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

int main() {
  
  int64_t N; cin >> N;
  int64_t ans = 0;
  
  int64_t M = N-1;
  for(int64_t K=2; K*K<=M; K++){
    if(M%K == 0){
      if(K*K != M) ans += 2;
      else ans++;
    }
  }
  if(M != 1){
    ans++;
  }

  vector<int64_t> N_yakusuu;
  for(int64_t K=2; K*K<=N; K++){
    if(N%K == 0){
      if(K*K != N){
        N_yakusuu.push_back(K);
        N_yakusuu.push_back(N/K);
      }
      else{
        N_yakusuu.push_back(K);
      }
    }
  }
  N_yakusuu.push_back(N);
  
  int64_t n = N;
  for(int64_t K: N_yakusuu){
    while(n%K == 0){
      n = n/K;
    }
    if(n%K == 1){
      ans++;
    }
    n = N;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 26+26+10;
char enc(int t)
{
	if(t<10)return '0'+t;
	t-=10;
	if(t<26)return 'a'+t;
	t-=26;
	return 'A'+t;
}
string s[N];
int sum=N;
int ttm=0;
int query(string s)
{
	if (s.length() > 128)
		return 0x3f3f3f3f;
	++ttm;
	if (ttm >= 850)
		while (1);
			cout << "?" << " " << s << endl;
	fflush(stdout);
	int ans = 0;
	cin >> ans;
	return ans;
}
int len = 0x3f3f3f3f;
int q[N];
string merge(string a,string b){
	int i=0,j=0;
	int la=a.length(),lb=b.length();
	string fir=string();
	while(i<la&&j<lb){
		string qr=fir;
		qr+=a[i];
		for(int k=j;k<lb;k++){
			qr+=b[k];
		}
		if(query(qr)+qr.length()==len){
			fir+=a[i++];
		}else {
			fir+=b[j++];
		}
	}
	while(i<la)fir+=a[i++];
	while(j<lb)fir+=b[j++];
	return fir;
}
int main()
{
	for(int i=0;i<N;i++){
		s[i]+=enc(i);
		q[i]=query(s[i])+1;
		len=min(len,q[i]);
	}
	for(int i=0;i<N;i++){
		if(q[i]==len){
			while(query(s[i]+enc(i))+s[i].length()+1==len)s[i]+=enc(i);
		}else s[i]=string();
	}
	while(1){
		for(int i=0;i<N;i++)for(int j=i+1;j<N;j++)if(s[i].length()>s[j].length())swap(s[i],s[j]);
		int t=0;
		while(!s[t].length())++t;
		if(t+1==N)break ;
		string nw=merge(s[t],s[t+1]);
		s[t+1]=nw;
		s[t]=string();
	}
	cout << "! "<< s[N-1] << endl;
	fflush(stdout);
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
set<int> S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>x;
		S.insert(x);
	}
	if(S.size()==N) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 9600
//============================================================================
// Name        : aoj2406.cpp
// Author      : afterCmidday
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int n, t, e, x, ans = -1;
	cin >> n >> t >> e;
	for(int i = 0;i < n;i++){
		cin >> x;
		int sum = x;
		while(sum + x <= t + e){
			sum += x;
		}
		if(t - e <= sum && sum <= t + e){
			ans = i + 1;
			break;
		}
	}
cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef std::pair<int, int> ipair;
#define int long long
#define pb push_back
#define ff first
#define INF INT_MAX
#define ss second
#define rep(i, a) for (int i = 0; i < a; i++)
#define fr(i, j, a) for (int i = j; i < a; i++)
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define mp make_pair
#define IOS                                                                 \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
int mod = 2019;
void init() {
string s;cin>>s;
int suff=0;
vi cnt(mod);
cnt[suff]++;
int pot=1;
int ans=0;
int n=s.size();
for(int i=n-1;i>=0;i--){
    int dig=s[i]-'0';
    suff= (suff + pot* dig)%mod;
    pot = 10*pot%mod;
    ans+=cnt[suff];
    cnt[suff]++;
}
cout<<ans<<endl;
}
int32_t main() {
  IOS;
  init();
  return 0;
}


Measured memory_bytes: 3744
N=int(input())
A=list(map(int,input().split()))
ans=[0]

cnt=0
hit=0
while cnt<N:
  if ans[hit]+1==A[cnt]:
    hit+=1
    ans.append(hit)
  cnt+=1
print(N-len(ans[1:]) if len(ans)>1 else -1)

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

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

  int V[N], C[N];
  for (int i = 0; i < N; i++) cin >> V[i];
  for (int i = 0; i < N; i++) cin >> C[i];

  int X = 0, Y = 0;
  for (int i = 0; i < N; i++) {
    if (C[i] < V[i]) {
      X += V[i];
      Y += C[i];
    }
  }

  int ans = X - Y;
  cout << ans << endl;

  return 0;
}


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

int main() {
  ll count=0;
  vector<ll> n(3);
  cin >> n[0] >> n[1] >> n[2];
  sort(n.begin(), n.end());

  //最小二数の偶奇が等しい場合
  if(n[0]%2 == n[1]%2) {
    count += (n[1]-n[0])/2;
    count += (n[2]-n[1]);
  }//最小二数の偶奇が異なる
  else {
    count++, n[1]++, n[2]++;
    count += (n[1]-n[0])/2;
    count += (n[2]-n[1]);
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b=0,c=10000000000;cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    b=max(a,b);
    c=min(a,c);
  }
  cout<<b-c<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
//貪欲アルゴリズム
string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

    // 後ろから解くかわりにすべての文字列を「左右反転」する
    //逆順にすることでdreamとdreamerなどが区別できる
    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

    // 端から切っていく
    bool can = true;//全体でdivedeできるか
    for (int i = 0; i < S.size();) {
        bool can2 = false; //先頭から見ていきSの一部が 4 個の文字列たちどれかで divide できるか
        for (int j = 0; j < 4; ++j) {
            string d = divide[j];
            //substr…部分文字列取り出し
            if (S.substr(i, d.size()) == d) { // d で divide できるか
                can2 = true;
                i += d.size(); // divide できたら i を進める
            }
        }
        if (!can2) { // divide できなかったら
            can = false;
            break;
        }
    }

    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3740
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    List<Integer> list = new ArrayList<>();
    list.add(Integer.parseInt(sc.nextLine()));
    
    for(int i = 1; i < N; i++){
      int a = Integer.parseInt(sc.nextLine());
      int lb = 0;
      int ub = list.size()-1;
      if(a <= list.get(ub)){
        list.add(a);
      }else if(a > list.get(lb)){
        list.set(0, a);
      }else{
        int mid = 0;
        while(ub-lb > 1){
          mid = (ub+lb)/2;
          if(a > list.get(mid)){
            ub = mid;
          }else{
            lb = mid;
          }
        }
        list.set(ub, a);
      }
    }
    System.out.println(list.size());
  }
}

Measured memory_bytes: 96908
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
s,f=0,-1
for x in a:
  s+=b[x-1]
  if x-f==1:
    s+=c[f-1]
  f=x
print(s)

Measured memory_bytes: 3060
#include <algorithm>
#include <cstdio>
using namespace std;
long long f[100005],g[100005];
int main(){
	int n,m,a,b;
	long long sum=0,ans;
	scanf("%d%d%d",&n,&m,&a);
	for (int i=1;i<n;i++){
		scanf("%d",&b);
		sum+=b-a;
		f[a+1]+=a+1;
		f[b+1]-=a+1;
		g[a+1]++;
		g[b+1]--;
		if (a>b){
			sum+=m;
			f[1]+=a+1-m;
			f[b+1]+=m;
			g[1]++;
		}
		a=b;
	}
	ans=sum;
	for (int i=1;i<=m;i++){
		f[i]+=f[i-1];
		g[i]+=g[i-1];
		ans=std::min(ans,sum+f[i]-g[i]*i);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 1664
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=0;i<b;i++)
#define REP(i,a,b) for(int i=0;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout <<(f?"Yes":"No")<<endl//fが真の場合Yesを出力、偽の場合Noを出力
#define yes(f) cout <<(f?"yes":"no")<<endl
#define YES(f) cout <<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())

using namespace std;

const int mod=1e9+7;



signed main(){
    int m,f,b;
    cin >> m >> f >> b;
    if(m+f<b)
    {
        cout << "NA" << endl;
        return 0;
    }
    if(m>b)
    {
        cout << 0 << endl;
        return 0;
    }
    
    cout << b-m << endl;
}


Measured memory_bytes: 3096
// finish date: 2018/01/15
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int i=a;i<b;i++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000

vector<vector<int>> b, c, field;


int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}

int factorial(int n) {
    int ans = 1;
    FOR(i, 1, n + 1) {
        ans = ans * i;
    }
    return ans;
}


int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> d(N, vector<int>(N, INF));
    vector<int> a(M), b(M), c(M);
    rep(i, M) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
        d[a[i]][b[i]] = c[i];
        d[b[i]][a[i]] = c[i];
    }
    rep(i, N) d[i][i] = 0;
    rep(k, N) {
        rep(i, N) {
            rep(j, N) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    vector<int> isMinD(M, false);
    rep(i, M) {
        if(c[i] == d[a[i]][b[i]]) isMinD[i]= true;
    }
    int count = 0;
    rep(i, M) if (!isMinD[i]) count++;
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; i++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	ll N; cin >> N;
	for (int n = N; n >= 1; n--) {
		ll x = sqrt(n);
		if (n % x == 0 && n / x == x) {
			cout << n << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int n;
  cin >> n;
  
  vector<int> ps(n);
  vector<int> ps2(n);
  for (int i = 0; i < n; i++) {
    cin >> ps[i];
    ps2[i] = ps[i];
  }
  
  sort(ps.begin(), ps.end());
  
  int wrong = 0;
  for (int i = 0; i < n; i++) {
    if (ps2[i] != ps[i]) {
      wrong++;
    }
  }
  
  if (wrong <= 2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
    
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace whatever{
	int readu(){
		char ch=getchar();
		while(!isdigit(ch))
			ch=getchar();
		int value=ch-'0';
		ch=getchar();
		while(isdigit(ch)){
			value=value*10+ch-'0';
			ch=getchar();
		}
		return value;
	}
	void writeu(int n){
		if(n<10)
			putchar(n+'0');
		else{
			writeu(n/10);
			putchar(n%10+'0');
		}
	}
	void run(){
		int n=readu();
		static int value[200002];
		static int index[200002];
		for(int i=1; i<=n; ++i){
			int p=readu();
			value[i]=p;
			index[p]=i;
		}
		index[n+1]=0;
		int result=0;
		for(int first=1, last=-1; first<=n; ++first){
			last=max(first, last);
			while(index[last+1]>index[last])
				++last;
			result=max(result, last-first+1);
		}
		writeu(n-result);
		putchar('\n');
	}
}
int main(){
	whatever::run();
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    repi(i,1,10){
        if(n/i<10&&n%i==0){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
}

Measured memory_bytes: 3596
#include <cstdio>
#include <string>

int main()
{
    int N, K;
    scanf("%d", &N);
    char S[N+1];
    scanf("%s", S);
    scanf("%d", &K);
    for(int i=0; i<N; i++){
        if(S[i] != S[K-1])
            S[i] = '*';
    }
    printf("%s\n", S);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    int a[n];
    int dp[n]; for (int i = 0; i < n; i++) dp[i] = 2000000000;
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d",&a[i]);
        for (int j = 1; j <= min(i,k); j++){
            dp[i] = min(dp[i],dp[i-j]+abs(a[i-j]-a[i]));
        }
    }
    printf("%d",dp[n-1]);

}


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

int main() {
	int N; cin >> N;
	long x[210000];
	long z[210000];
	for (int i = 1; i <= N; i++) {
		cin >> x[i];
		z[i] = x[i];
	}
	sort(x+1, x + N+1);
	for (int i = 1; i <= N; i++){
		if (z[i] < x[N / 2+1]) {
			cout << x[N / 2+1] << endl;
		}
		else cout << x[N / 2] << endl;
	}
}

Measured memory_bytes: 5376
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int[] a = new int[n];
		for(int i = 0;i < n;i++){
			a[i] = saori.saori_hayami();
		}
		int ans = 0;
		for(int i = 0;i < n-2;i++){
			if((a[i] < a[i+1] && a[i+1] < a[i+2]) || (a[i] > a[i+1] && a[i+1] > a[i+2])){
				ans++;
			}
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21204
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr int MOD = 1e9 + 7;

// update, query O(logn)
struct BIT {
    vector<int> data;
    int n;
    BIT(int n) : data(n+1), n(n+1) {}

    void update(int i,int x){
        for(; i <= n; i += i & -i) data[i] += x;
    }

    int query(int i){
        int ret = 0;
        for(; i > 0; i -= i & -i) ret += data[i];
        return ret;
    }
};

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N,M;cin>>N>>M;
    BIT bit(N);
    for(int i=0;i<M;++i){
        int c,x,y;
        cin>>c>>x>>y;
        if(c==0){
            bit.update(x,y);
        } else {
            cout << bit.query(y) - bit.query(x-1) << '\n';
        }
    }
    return 0;
}


Measured memory_bytes: 3352
def MI(): return map(int, input().split())
def II(): return int(input())
def IS(): return input()
def LI(): return list(map(int, input().split()))


n = II()
d, x = MI()
a = [II() for _ in range(n)]
ans = 0
for i in range(n):
    ans += len([i for i in range(1,d+1,a[i])])
print(ans + x)



Measured memory_bytes: 3060
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
typedef pair<P,long double> Pi;
typedef pair <long double,int> Pd;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[9]={-1,0,1,-1,0,1,-1,0,1},dy[9]={-1,-1,-1,0,0,1,1,1};
map<P,int> mp;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll h,w,n;
    cin>>h>>w>>n;
    for(int i=0;i<n;i++){
         int a,b;
         cin>>a>>b;
         for(int j=0;j<9;j++){
             if(a+dy[j]<=1||a+dy[j]>=h||b+dx[j]<=1||b+dx[j]>=w)continue;
             mp[P(a+dy[j],b+dx[j])]++;
         }
    }
    ll cnt=0;
    vector<ll> ans(11,0);
    for(auto p: mp){
        cnt++;
       // if(p.fi.fi<=1||p.fi.fi>=h||p.fi.se<=1||p.fi.se>=w)continue;
        ans[p.se]++;
    }
    cout<<(h-2)*(w-2)-cnt<<endl;
    for(int i=1;i<=9;i++){
        cout<<ans[i]<<endl;
    }
}


Measured memory_bytes: 56576
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int x; cin >> x;
  vector<int> item = {100,101,102,103,104,105};
  vector<int> dp(100005); // x円の買い物ができるかどうか
  dp[0] = 1;

  REP(i,x+1) {
    REP(j,item.size()) {
      int t = i-item[j];
      if (0 <= t) dp[i] = max(dp[i], dp[t]);
    }
  }

  COUT(dp[x]);
  return 0;
}


Measured memory_bytes: 3692
#include <stdio.h>

int main(){
	
	int n,k,i,sum=1;
	
	scanf("%d %d",&n,&k);
	
	for(i=0;i<n-1;i++){
		sum=sum*(k-1);
	}
	
	sum=sum*k;
	
	printf("%d\n",sum);
	
	return 0;
}


Measured memory_bytes: 128
import sys
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
t = s[::-1]
N = len(s)

dp = [[MAX_INT]*2 for i in range(N+1)]
dp[0][0] = 0
for i in range(N):
  num = int(t[i])
  dp[i+1][0] = min(dp[i][0] + num, dp[i][1] + num +1)
  dp[i+1][1] = min(dp[i][0] + 10-num, dp[i][1] + 10-num-1)
print(min(dp[-1][0], dp[-1][1]+1))

Measured memory_bytes: 144372
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}

ll gcd(ll a,ll b){
	if(a<b){ll c=a;a=b;b=c;}
	while(a%b!=0){ll c=b;b=a%b;a=c;}
	return b;
}
ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}


int main(){
	
	int n;
	cin>>n;
	vector<ll> t(n);
	rep(i,n){
		cin>>t[i];
	}
	ll ans=1;
	rep(i,n){
		ans=lcm(t[i],ans);
	}
	cout<<ans<<endl;

}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int n,a,s,x,i;
    while(1)    {
        scanf("%d",&a);
        if(a==0)    break;
        s=0;
        for(i=0;i<9;i++){
            scanf("%d",&n);
            s+=n;
        }
        x=a-s;
        printf("%d\n",x);
    }
    return 0;
}


Measured memory_bytes: 1980
import java.util.*;
public class Main {

	    public static void main(String[] args) throws java.io.IOException{
	        Scanner scan = new Scanner(System.in);
	        while(scan.hasNext()){
	        	
	        	Double a=scan.nextDouble();
	        	System.out.printf("%.8f\n",ss(a,1));
	        	
	        	
	        }
	    }
	    public static double ss(double a,int c){
	    	if(c==11)return 0;
	    	if(c%2==0){
	    		return a+ss(a/3,c+1);
	    	}
	    	else {
	    		return a+ss(a*2,c+1);
	    	}
	    }
}
	    

Measured memory_bytes: 12000
#include<iostream>
#include<string>
#include <vector>
#include<algorithm>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(), v.end())
#define ll long long
const ll MOD = 1e9 + 7;

int main() {
	int n, x;
	int sum = 0;
	cin >> n >> x;
	vi m(n);
	rep(i, n) {
		cin >> m[i];
		sum += m[i];
	}
	vsort(m);
	x -= sum;
	int ans = x / m[0] + n;
	cout << ans << endl;
}

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


using namespace std;

using ll = long long;


int main(void) {
    ll N, M;
    cin >> N >> M;
    ll even_max_len = M % 2 == 0 ? M : M - 1;
    ll odd_max_len = M % 2 == 1 ? M : M - 1;
    for (ll i = M; i > 0; i--) {
        if (i % 2 == 0) {
            ll j = (even_max_len - i) / 2;
            printf("%lld %lld\n", 1 + j, 1 + j + i);
        } else {
            ll base = even_max_len + 2;
            ll j = (odd_max_len - i) / 2;
            printf("%lld %lld\n", base + j, base + j + i);
        }
    }
}


Measured memory_bytes: 3648
import heapq
import math

n, m = map(int, input().split())
li_a = list(map(lambda x: x * -1, (map(int, input().split()))))
heapq.heapify(li_a)


for i in range(m):
    w = heapq.heappop(li_a)
    heapq.heappush(li_a, math.ceil(w / 2))

print(sum(li_a) * -1)


Measured memory_bytes: 14536
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe

int main(void){ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////////////////
int i=0;
string s;
cin >> s;
sort(s.begin(),s.end());
   while(s[i]!=s[i+1]){
       i++;
       if(i==s.size()-1){
          cout << "yes" << endl;
          return 0;
       }
   }

   cout << "no" << endl;

////////////////////////////////////////////////////////
return 0;}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
constexpr ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }

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

    auto m = (n + 2 - 1) / 2;
    cout << (double)m / n << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


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

string a, b;

int main() {
    cin >> a >> b;

    if (a == "H") {
        cout << b << endl;
        return 0;
    } else {
        if (b == "D") {
            b = "H"; 
        } else {
            b = "D";
        }
        cout << b << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main() {
  int r, c;
  std::cin >> r >> c;
  std::vector<std::vector<int>> table(r + 1, std::vector<int>(c + 1, 0));
  std::vector<int> last_row(c + 1, 0);

  int x;
  for (int i = 0; i < r; i++) {
    int rsum = 0;
    for (int j = 0; j < c; j++) {
      std::cin >> x;
      table[i][j] = x;
      rsum += x;
    }
    table[i][c] = rsum;
  }
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c + 1; j++) {
      last_row[j] += table[i][j];
    }
  }
  table[r] = last_row;

  for (int i = 0; i < r + 1; i++) {
    for (int j = 0; j < c + 1; j++) {
      std::cout << table[i][j];
      if (j < c)
        std::cout << " ";
    }
    std::cout << std::endl;
  }
}



Measured memory_bytes: 3152
import java.util.*;


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

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt() - 1;
        String S = sc.next();
        String[] SH = S.split("");
        
        if(SH[K].equals("A")){
            SH[K] = "a";
        }else if(SH[K].equals("B")){
            SH[K] = "b";
        }else{
            SH[K] = "c";
        }
        
        for(String sh : SH){
            System.out.print(sh);
        }
    
    }
}

Measured memory_bytes: 21972
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	vector<int>A(N); rep(i, 0, N) { cin >> A[i]; }
	auto B = A;

	sort(all(A));

	int ans = 0;
	rep(i, 0, N) {
		int idx = lower_bound(all(A), B[i]) - A.begin();
		ans += (i % 2 != idx % 2);
	}
	cout << ans / 2 << endl;

	return 0;
}


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

int main() {
  int N, H, W;
  cin >> N >> H >> W;
  int h, w;
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    cin >> h >> w;
    if (h>=H && w>=W) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
k = input()
s = input()
s1 = [i for i in s]
s2 = len(s1)
s3 = []
if int(s2) <= int(k):
  print(s)
else:
  for i in range(int(k)):
    s3.append(s1[i])
  s3.insert(int(k),"...")
  StrA = "".join(s3)
  print(StrA)

Measured memory_bytes: 9148
import java.util.Scanner;

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

	int[] A = new int[N];

	for(int i = 0 ; i < N ; i++){
		A[i] = sc.nextInt();
	}
	sc.close();

	int four = 0;
	int two = 0;
	int nn = 0;
	for(int i = 0 ; i < N ; i++){
		if(A[i]%4 == 0){
			four++;
		}
		else if(A[i]%2 == 0 && A[i]%4 !=0){
			two++;
		}
		else{
			nn++;
		}
	}
	if(four >= nn ||(nn-1 == four && two ==0)){
		System.out.println("Yes");
	}
	else{
		System.out.println("No");
	}

	}
}


Measured memory_bytes: 50096
from fractions import gcd
n, m = map(int, input().split())
s = input()
t = input()
gcm = gcd(n, m)
lcm = n * m // gcm
for i in range(gcm):
    if s[(n // gcm) * i] != t[(m // gcm) * i]:
        print(-1)
        exit()
print(lcm)

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

int main(void)
{
  ll n; cin >> n;
  ll x, y;
  x = n * 800;
  y = (n/15) * 200;
  cout << (x - y) << endl;
}


Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	
	Scanner sc = new Scanner(System.in);
	LinkedList<Integer> array = new LinkedList<Integer>();
	public void run() {
			int n = sc.nextInt();
		calc(n);
	}
	
	public void calc(int n){
		int[][] gyouretsu = new int[n][n];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				gyouretsu[i][j] = 0;
			}
		}
		for(int i = 0; i < n; i++){
			int u = sc.nextInt();
			int k = sc.nextInt();
			for(int j = 0; j < k; j++){
				int v = sc.nextInt();
				gyouretsu[u-1][v-1] = 1;
			}
		}
		int[] ans = new int[n];
		int[] kita = new int[n];
		for(int i = 0; i < n; i++){
			ans[i] = -1;
			kita[i] = -1;
		}
		array.push(0);
		kita[0] = 0;
		rec(gyouretsu, 0, ans, kita);
	
		for(int i = 0; i < n; i++){
			System.out.println(i+1 + " " + ans[i]);
		}
	}
	public void rec(int[][] gyouretsu, int t, int[] ans, int[] kita){
		int s = array.size();
		for(int i = 0; i < s; i++){
			int now = array.get(0);
			ans[now] = t;
			array.remove(0);
			for(int j =0; j <  gyouretsu[now].length; j++){
				if(gyouretsu[now][j] == 1 && kita[j] == -1){
					array.add(j);
					kita[j] = 0;
				}
			}
		}
		if(array.size() != 0){
		rec(gyouretsu, t+1, ans, kita);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 20796
#include <cstdio>

int count[3][101];
int data[200][3];

int main() {
	int N;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 3; j++) {
			int k;
			scanf("%d", &k);
			data[i][j] = k;
			count[j][k]++;
		}
	}
	for (int i = 0; i < N; i++) {
		int sum = 0;
		for (int j = 0; j < 3; j++) {
			if (count[j][data[i][j]] == 1) sum += data[i][j];
		}
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 1028
n=0
Answer=0
N=int(input())
h=list(map(int,input().split()))
h.insert(0,0)

for i in range(N):
    if h[n]<=h[n+1]:
        m=h[n+1]-h[n]
        Answer=Answer+m
    else :
        pass
    n=n+1
print(Answer)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
/* const int MOD = 1000000007; */
const int MOD = 998244353;
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


int powMod(int n, int p) {
  int res = 1;
  while (p) {
    if (p & 1) (res *= n) %= MOD;
    (n *= n) %= MOD;
    p >>= 1;
  }
  return res;
}
int invMod(int n) {
  return powMod(n, MOD - 2);
}

vector<int> fac, finv, inv;

void comb_init(int n) {
  fac  = vector<int>(n);
  finv = vector<int>(n);
  inv  = vector<int>(n);
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < n; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
 
int comb(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main() {
  int N, M, K; 
  cin >> N >> M >> K;

  comb_init(400000);

  int ans = 0;
  REP(i, K+1){
    (ans += (M*powMod(M-1, N-1-i))%MOD*comb(N-1, i)) %= MOD;
  }

  cout << ans << "\n";

  return 0;
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                int n = int.Parse(input);

                int ans = (n * n + n + 2) / 2;
                sb.AppendLine(ans.ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9192
import java.util.*;
import java.io.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		HashMap hs = new HashMap();
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());
		int[] c = new int[n];
		int[][] a = new int[n][m];
		for(int i = 0 ; i < n ; i++){
			c[i] = Integer.parseInt(sc.next());
			for(int j = 0 ; j < m ; j++){
				a[i][j] = Integer.parseInt(sc.next());
			}
		}
		sc.close();
		int yono = (int)Math.pow(10 , 9);
		int[] mo = new int[m];
		for(int i = 0 ; i < 1 << n ; i++){
			Arrays.fill(mo , 0);
			int y = 0;
			for(int j = 0 ; j < n ; j++){
				if((1 & i >> j) == 1){
					for(int k = 0 ; k < m ; k++){
						mo[k] += a[j][k];
					}
					y += c[j];
				}
			}
			boolean ebishu = true;
			for(int ii = 0 ; ii < m && ebishu ; ii++){
				if(mo[ii] < x) ebishu = false;
			}
			if(ebishu) yono = Math.min(yono , y);
		}
		if(yono == (int)Math.pow(10 , 9)) ou.print(-1);
		else ou.print(yono);
		ou.print("\n");
		ou.flush();
	}
}

Measured memory_bytes: 36912
#include <stdio.h>
int main (void)
{
        int  a,b,c,d;
        int  k[100]={0};
        int  i,j=0;

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

        d=a;
        if (a>b) d=b;

        for(i=1;i<=d;i++){
        if ((a%i==0)&&(b%i==0)){k[j]=i;
        j++;}
        }

      printf("%d\n", k[j-c]);

        return 0;
        }

Measured memory_bytes: 128
n=int(input())
li=[list(map(int,input().split())) for i in range(n)]
li.sort()
li.insert(0,[0,0,0])

for i in range(n):
  sa=li[i+1][0]-li[i][0]
  kyori=abs(li[i+1][1]-li[i][1])+abs(li[i][2]-li[i+1][2])
  if kyori==0 or sa<kyori or sa%2!=kyori%2:
    print("No")
    exit()
  else:
    continue
print("Yes")

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

int main(){
    int N, K;
    cin >> N >> K;
    vector<ll> X(N), Y(N);
    vector<ll> P(N), Q(N);
    for(int i=0;i<N;i++) cin >> X[i] >> Y[i], P[i] = X[i], Q[i] = Y[i];
    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());
    ll ans = 1ll<<62;
    
    for (int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            for(int a=i+1;a<N;a++){
                for (int b=j+1;b<N;b++){
                    ll x1 = X[i], x2 = X[a], y1 = Y[j], y2 = Y[b];
                    int cnt = 0;
                    for(int k=0;k<N;k++){
                        if (x1 <= P[k] && P[k] <= x2 && y1 <= Q[k] && Q[k] <= y2) cnt += 1;
                    }
                    if (cnt == K) ans = min(ans, (x2-x1)*(y2-y1));
                }
            }
        }
    }
    cout << ans << endl;
}

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

int main(){
    int n;
    cin>>n;
    int p[30];
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    int ans=0;
    for(int i=0;i<n-2;i++){
        if((p[i]<p[i+1]&&p[i+1]<p[i+2]||p[i]>p[i+1]&&p[i+1]>p[i+2])){
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int a[100001];
int main(){
    ll n,sum=0;
    cin>>n;
    rep(i,n){
        cin>>a[i];
    }
    ll s=0;
    rep(i,n){
        if(a[i]!=0) s+=a[i];
        else{
            sum+=s/2;
            s=0;
        }
    }
    sum+=s/2;
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,r,b;char ch[10000];
int main()
{
	n=read();scanf("%s",ch+1);
	int l=strlen(ch+1);
	for(int i=1;i<=n;++i)
		if(ch[i]=='R')++r;
		else ++b;
	if(r>b)puts("Yes");
	else puts("No");
}


Measured memory_bytes: 256