akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<math.h>

#define DIV 1000000007
using namespace std;
using ll = long long;

int main(void) {
	int N, M, S;
	cin >> N >> M >> S;

	vector < vector<pair<int, pair<ll, ll>>>> city(N + 1);
	for (int i = 0; i < M; i++) {
		int u, v;
		ll a, b;
		cin >> u >> v >> a >> b;
		city[u].push_back(make_pair(v, make_pair(-a, b)));
		city[v].push_back(make_pair(u, make_pair(-a, b)));
	}

	for (int i = 1; i <= N; i++) {
		ll c, d;
		cin >> c >> d;
		city[i].push_back(make_pair(i, make_pair(c, d)));
	}

	S = min(S, 2500);
	priority_queue<pair<ll, pair<int, int>>, vector<pair<ll, pair<int, int>>>, greater<pair<ll, pair<int, int>>>> pq;
	vector<vector<ll>> cost(N + 1, vector<ll>(2501, 1e15));
	vector<vector<bool>> visit(N + 1, vector<bool>(2501));
	pq.emplace(0, make_pair(1, S));
	cost[1][S] = 0;

	while (!pq.empty()) {
		pair<ll, pair<int, int>> x = pq.top();
		pq.pop();
		visit[x.second.first][x.second.second] = true;

		for (auto edge : city[x.second.first]) {
			int to = edge.first, silver = min((ll)2500, x.second.second + edge.second.first);
			if (silver < 0) continue;
			if (visit[to][silver]) continue;
			if (cost[to][silver] >cost[x.second.first][x.second.second] + edge.second.second) {
				cost[to][silver] = cost[x.second.first][x.second.second] + edge.second.second;

				pq.emplace(cost[to][silver], make_pair(to,silver));
			}

		}
	}

	for (int i = 2; i <= N; i++) {
		ll ans = 1e15;
		for (int j = 0; j <= 2500; j++) {
			ans = min(ans, cost[i][j]);
		}

		cout << ans << endl;
	}
}


Measured memory_bytes: 6228
#include <bits/stdc++.h>
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) v.begin(), v.end()

using namespace std;

ll mod = 1e9+7;
inline ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

inline ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}

inline ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

inline ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return (dividend / divisor);
}

inline vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

inline bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
ll facctorialMethod(ll k){
    ll sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main(){
    ll m1,d1,m2,d2;
    cin >> m1 >> d1 >> m2 >> d2;
    
    if(m1 != m2){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int main(){
  int n,m,i,j,k,d[710][710],c[710]={};
  int q[710],t,r,e[710][2]={};
  int dp[710][710]={1}; 
  scanf("%d %d",&n,&m);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(i==j)continue;
      d[i][j]=1;
    }
  }
  while(m--){
    scanf("%d %d",&i,&j);
    d[i][j]=d[j][i]=0;
  }
  m=0;
  for(i=1;i<=n;i++){
    if(c[i])continue;
    q[t=0]=i;
    c[q[t]]=1;
    for(r=1;r-t;t++){//printf("!!%d %d\n",q[t],c[q[t]]);
      e[m][c[q[t]]-1]++;
      for(j=1;j<=n;j++){
	if(d[q[t]][j]==0)continue;//printf("j:%d %d\n",j,c[j]);
	if(c[j]&&c[j]==c[q[t]])goto END;
	if(c[j])continue;
	c[j]=3-c[q[t]];
	q[r++]=j;
      }
    }
    m++;
  }
  //for(i=0;i<n;i++)printf("%d\n",c[i+1]);printf("%d\n",m);
  for(i=0;i<m;i++){//printf("%d %d\n",e[i][0],e[i][1]);
    for(j=n;j>=0;j--){
      for(k=n;k>=0;k--){
	if(dp[j][k]==0)continue;//printf("!!!%d %d\n",j,k);
	if(j+e[i][0]<=n&&k+e[i][1]<=n)dp[j+e[i][0]][k+e[i][1]]=1;
	if(j+e[i][1]<=n&&k+e[i][0]<=n)dp[j+e[i][1]][k+e[i][0]]=1;
      }
    }
  }
  /*for(i=0;i<=n;i++){
    for(j=0;j<=n;j++)printf("%d ",dp[i][j]);printf("\n");
    }//*/
  j=1e9;
  for(i=0;i<=n;i++){
    if(dp[i][n-i]==0)continue;
    j=MIN(j,(i*(i-1))/2+((n-i)*(n-i-1)/2));
  }
  if(j>1e8)goto END;
  printf("%d\n",j);
  return 0;
 END:;
  printf("-1\n");
  return 0;
}


Measured memory_bytes: 4096
#include<stdio.h>

int main(void)
{
  int r = 0;
  int a = 0;
  
  do{
    	scanf("%d", &r);
  }while(r < 1 || r > 100);
  
  a = 3 * r * r;
  printf("%d", a);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll k,x; cin >> k>> x;
  if(500*k>=x) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
   int N;
   cin>>N;
   vector<int> A(N);
   int B;
   vector<int> C(N);
   
   rep(i,N){
       cin>>A[i];
   }
   int sum=0;
   rep(i,N){
       cin>>B;
       sum+=B;
   }
   rep(i,N-1){
       cin>>C[i];
   }
   
   rep(i,N-1){
       if(A[i]==A[i+1]-1){
           sum+=C[A[i]-1];
       }
   }
   cout<<sum<<endl;
   
}


Measured memory_bytes: 3636
#!/usr/bin/env python3
import sys


def solve(S: str):
    if S == "Sunny":
        print("Cloudy")
    if S == "Cloudy":
        print("Rainy")
    if S == "Rainy":
        print("Sunny")
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
using System;

namespace ITP1_3_C
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int j = 1; j < 3001; j++)
            {
                string[] strAry = Console.ReadLine().Split(' ');

                if (strAry[0] == "0" && strAry[1] == "0")
                    break;

                int v0 = int.Parse(strAry[0]);
                int v1 = int.Parse(strAry[1]);

                if (v0 <= v1)
                {
                    Console.WriteLine("{0} {1}", v0, v1);
                }
                else
                {
                    Console.WriteLine("{0} {1}", v1, v0);
                }
            }
        }
    }
}

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

int main(){
    double w,h;
    cin >> w >> h;
    int x,y;
    cin >> x >> y;

    cout << (double)w*h/2 << " ";
    if(x*2 == w && y*2 == h) cout << 1 << endl;
    else cout << 0 << endl;   
}

Measured memory_bytes: 256
import java.util.Scanner

import scala.annotation.tailrec

object Util {
  @tailrec
  def loop(start: Int, end: Int)(f: Int => Unit) {
    if (start < end) {
      f(start)
      loop(start + 1, end)(f)
    }
  }
}

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val n, k = sc.nextInt()
    val hs = Array.fill(n)(sc.nextInt()).sorted
    var ans = Long.MaxValue
    for (i <- 0 to (n - k)) {
      ans = math.min(ans, hs(i + k - 1) - hs(i))
    }

    println(ans)
  }
}


Measured memory_bytes: 55648
a, b, c, x, y = [int(w) for w in input().split()]

if 2 * c >= a + b:
    ans = a * x + b * y
else:
    cnum = min(x, y) * 2

    less = abs(x - y)
    p = a if x > y else b
    if 2 * c < p:
        cnum += 2 * less
        less = 0

    ans = c * cnum + less * p

print(ans)


Measured memory_bytes: 9164
#include <bits/stdc++.h>
#include <vector>
#include <string>

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

bool array_equal(vector<int> a1, vector<int>a2) {
  if (a1.size() != a2.size()) {
    return false;
  }
  for (int i=0; i<a1.size(); i++) {
    if (a1.at(i) != a2.at(i)) {
      return false;
    }
  }
  return true;
}

int gcd(int a, int b) {
  if (a == b) {
    return a;
  }
  else if (a > b) {
    return gcd(a - b, b);
  }
  else {
    return gcd(a, b - a);
  }
}

char int_to_char(int a) {
  if (a == -1) {
    return 'z';
  }
  else {
    return 'a' + a;
  }
}

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int divide_count(int a, int divider) {
  int r = 0;
  while(a % divider == 0) {
    a /= divider;
    r++;
  }
  return r;
}

int main() {
  std::cout << std::setprecision(9);
  int n;
  cin >> n;

  vector<vector<int>> comments(n, vector<int>(n, -1));
  for(int i=0; i<n; i++) {
    int a;
    cin >> a;
    for(int j=0; j<a; j++) {
      int x, y;
      cin >> x >> y;
      comments[i][x - 1] = y;
    }
  }

  int ans = 0;
  for(int bit=0; bit<(1<<n); bit++) {
    bool correct = true;
    bitset<15> bs(bit);
    for(int i=0; i<n; i++) {
      if(bs.test(i) == 1) {
        for(int j=0; j<n; j++) {
          if(comments[i][j] >= 0 && bs.test(j) != comments[i][j]) {
            correct = false;
            break;
          }
        }
        if(!correct) {
          break;
        }
      }
    }
    if(correct && bs.count() > ans) {
      ans = bs.count();
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,sum=0;
  cin >> N;
  vector<int> l(N),r(N);
  for(int i=0;i<N;i++){
    cin >> l.at(i) >> r.at(i);
    sum+= (r.at(i)-l.at(i) +1);
  }
  
  cout << sum << endl;

}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (int)n;i++)
#define repb(i,n) for(int i = (int)n;i >= 0;i--)
#define reps(i,m,n) for(int i = (int)m;i < (int)n;i++)
#define repsb(i,m,n) for(int i = (int)m;i >= (int)n;i--)
#define SORT(v,n) sort(v,v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
#define ll long long int
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
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;}
//vector<vector<int>> v(n_rows->, vector<int>(n_cols, value));
using namespace std;
int main(int argc, char const *argv[]) {
    int m, n, c,ans;
    ans = 0;
    vector<int> b(m, 0);
    cin >> n >> m >> c;
    rep(i, m) cin >> b[i];
    int acc = 0;
    rep(i, n)
    {
        acc = c;
        rep(j, m)
        {
            int t;
            cin >> t;
            acc += t *b[j];
        }
        if(acc>0){
            ans += 1;
        }
    }
    cout << ans<< endl;
    return 0;
}


Measured memory_bytes: 24832
#include<bits/stdc++.h>
#define lli long long int
#define ulli unsigned long long int
#pragma GCC target ("sse4.2")
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define time cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
lli maxSubArraySum(lli a[], lli size)
{
    lli max_so_far = INT_MIN, max_ending_here = 0;

    for (lli i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;

        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}
int main()
{


    fast;
    lli n;
    cin>>n;
    lli a[n][2];
    double x=0,y=0;
    for(lli i=0;i<n;i++)
    {
        cin>>a[i][0]>>a[i][1];
        x+=a[i][0],y+=a[i][1];
    }
    double X=x/n,Y=y/n;
    //cout<<X<<" "<<Y<<"\n";
    double m=0.999;
    double p=0.01;
    lli f;
    double dist=0;
    for(lli i=1;i<=18000;i++)
    {
        f=0;
        dist=((X-a[0][0])*(X-a[0][0])+(Y-a[0][1])*(Y-a[0][1]));
        for(lli j=1;j<n;j++)
        {
            if(((X-a[j][0])*(X-a[j][0])+(Y-a[j][1])*(Y-a[j][1]))>dist)
            {
                dist=((X-a[j][0])*(X-a[j][0])+(Y-a[j][1])*(Y-a[j][1]));
                f=j;
            }
        }
        X+=(a[f][0]-X)*p;
        Y+=(a[f][1]-Y)*p;
        p*=m;
    }

    cout<<fixed<<setprecision(9)<<sqrt((X-a[f][0])*(X-a[f][0])+(Y-a[f][1])*(Y-a[f][1]));


    return 0;

}


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

int main(){
  int n;
  cin >> n;
  vector<long> a(n);
  for(long i = 0;i < n;i++){
    cin >> a.at(i);
    a.at(i) -= i+1;
  }
  
  sort(a.begin(),a.end());
  
  long b = a.at(n/2);
  long kekka = 0;
  for(int i = 0;i < n;i++){
    kekka += abs(a.at(i) - b);
  }
  cout << kekka << endl;
}

Measured memory_bytes: 1792
#![allow(dead_code, unused_imports, deprecated)]
use std::cmp::{max, min, Reverse};
use std::collections::HashMap;

use itertools::Itertools;

use maplit::*;

use proconio::{input, fastout};
use proconio::marker::*;

const INF: usize = 1_000_000_007;

//#[fastout]
fn solve() {
  input!{
    x: i64,
  };

  let mut a = 0i64;
  let mut b = 0i64;
  'la: for i in -118..=119 {
    for j in -119..=118 {
      if i * i * i * i * i - j * j * j * j * j == x {
        a = i as i64;
        b = j as i64;
        break 'la;
      }
    }
  }
  println!("{} {}", a, b);
}

fn main() {
  std::thread::Builder::new()
    .name("big stack size".into())
    .stack_size(32 * 1024 * 1024)
    .spawn(|| {
      solve();
    })
    .unwrap()
    .join()
    .unwrap();
}


Measured memory_bytes: 2288
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
typedef pair<int, int> P;

// 一番上の桁の値を求める
int upperNum(int _num){
    while(_num / 10 != 0){
        _num /= 10;
    }

    return _num;
}

P func(int n){
    int a = n % 10;
    int b = upperNum(n);

    return P(a, b);
}

map<P, int> mp;

int main() {
    int n;
    cin >> n;
    for(int i = 1; i <= n; ++i){
        P p = func(i);
        mp[p]++;
    }
    long long ans = 0;

    for(int i = 1; i <= n; ++i){
        P p = func(i);
        P q(p.second, p.first);
        ans += mp[q];
    }

    cout << ans << endl;
}

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

using namespace std;

//#define FILE_IO

int N, K, lowerThanK;
int v[5005];
bitset <5005> dp;

bool unnecessary(int pos)
{
    if(v[pos] >= K) return false;

    dp.reset();
    dp[0] = 1;
    for(int i = 1; i <= N; i++)
    {
        if(i == pos)    continue;
        for(int j = K; j >= v[i]; j--)
            if(dp[j - v[i]])
                dp[j] = 1;
    }

    for(int i = K - 1; i >= K - v[pos]; i--)
        if(dp[i])
            return false;
    return true;
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d%d", &N, &K);
    for(int i = 1; i <= N; i++)
        scanf("%d", &v[i]);
    sort(v + 1, v + N + 1);

    int p = 1;
    int u = N;
    int ans = 0;
    while(p <= u)
    {
        int mij = p + (u - p) / 2;

        if( unnecessary(mij) )
        {
            ans = mij;
            p = mij + 1;
        }
        else
            u = mij - 1;
    }

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

    return 0;
}


Measured memory_bytes: 256
#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, M = getlist()
	A = getlist()
	S = sum(A)
	cnt = 0
	for i in range(N):
		if 4 * M * A[i] >= S:
			cnt += 1

	if cnt >= M:
		print("Yes")
	else:
		print("No")




if __name__ == '__main__':
	main()

Measured memory_bytes: 38256
;; #!/usr/bin/env sbcl --script

(define-alien-routine getchar_unlocked char)

(declaim (optimize (speed 3) (safety 0) (debug 0)))

(deftype uint8 () '(unsigned-byte 8))
(deftype int32 () '(signed-byte 32))

;; (declaim (type fixnum *ptr* *len*)
;;          (type (vector uint8 4096) *buf*))

;; (defvar *buf* (make-array 4096 :element-type 'uint8 :initial-element 0))
;; (defvar *ptr* (the fixnum 0))
;; (defvar *len* (the fixnum -1))
;; 
;; (defun refresh-buf ()
;;   (setf *len* (the fixnum (read-sequence *buf* *standard-input*)))
;;   (setf *ptr* (the fixnum 0)))
;; 
;; (declaim (ftype (function () uint8) my-read-char))
;; (defun my-read-char ()
;;   (when (>= *ptr* *len*) (refresh-buf))
;;   (if (>= *ptr* *len*)
;;       0
;;       (progn (incf *ptr*)
;;              (aref *buf* (1- *ptr*))))

(declaim (ftype (function () int32) my-read-int))
(defun my-read-int ()
  (let ((is-negative nil)
        (result 0))
    (declare (type int32 result))
    (loop for cur-char = (getchar_unlocked) then (getchar_unlocked)
       while (and (/= cur-char (char-code #\-))
                  (/= 0)
                  (or (< cur-char 48)
                      (> cur-char 57)))
       finally (if (<= 48 cur-char 57)
                   (setf result (- cur-char 48))
                   (setf is-negative t)))
    (loop for cur-char = (getchar_unlocked) then (getchar_unlocked)
       while (<= 48 cur-char 57)
       do (setf result (+ (* result 10) (- cur-char 48))))
    (when is-negative (setf result (- result)))
    result))

(defun main ()
  (let* ((n (my-read-int))
         (k (my-read-int))
         (a (make-array n :element-type 'int32))
         (dp (make-array n :element-type 'int32 :initial-element (+ (expt 10 9) 100))))
    (dotimes (i n)
      (setf (aref a i) (my-read-int)))
    (setf (aref dp 0) 0)
    (loop for i of-type int32 from 0 below n do
      (loop with from-val of-type int32 = (aref dp i)
         for j of-type int32 from (1+ i) to (+ i k)
         while (< j n)
         for nval of-type int32 = (+ from-val (abs (- (aref a i) (aref a j))))
         if (< nval (aref dp j))
         do
           (setf (aref dp j) nval)))
    (format t "~a~%" (aref dp (- n 1)))))

(main)

;; (defun main2 ()
;;   (let* ((n (the int32 (read)))
;;          (k (the int32 (read)))
;;          (a (make-array n :element-type 'int32))
;;          (dp (make-array n :element-type 'int32 :initial-element (+ (expt 10 9) 100))))
;;     (let ((stream (make-string-input-stream (read-line))))
;;       (loop for i from 0
;;          for j = (read stream nil) until (null j)
;;          do (setf (aref a i) (the int32 j)))
;;     (setf (aref dp 0) 0)
;;     (loop for i of-type int32 from 0 below n do
;;       (loop with from-val of-type int32 = (aref dp i)
;;          for j of-type int32 from (1+ i) to (+ i k)
;;          while (< j n)
;;          do
;;            (let ((nval (the int32 (+ from-val (abs (- (aref a i) (aref a j)))))))
;;              (setf (aref dp j) (min (aref dp j) nval)))
;;     (format t "~a~%" (aref dp (- n 1)))))



Measured memory_bytes: 20836
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
typedef long long llong;
typedef pair<int, int> pii;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
int main() {
	string S;
	cin >> S;
	if (S == "AAA" || S == "BBB") {
		cout << "No";
	}
	else {
		cout << "Yes";
	}
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
n = int(input())
S = input()

d1 = defaultdict(int)
d2 = defaultdict(int)
d3 = defaultdict(int)

for s in S:
    for x in d2:
        d3[x+s]+=1
    for y in d1:
        d2[y+s]+=1
    d1[s]+=1

print(len(d3))

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

int main(){
	int X, Y;
	cin >> X >> Y;
	string board[101];
	vector<bool> goodx(101, false), goody(101, false);
	for(int i = 0; i < X; i++)
	{
		cin >> board[i];
		
	}
	
	for(int i = 0; i < X; i++)
	{
		for(int j = 0; j < Y; j++)
		{
			if(board[i][j] == '#'){
				goodx[i] = true;
				goody[j] = true;
			}
		}
		
	}

	for(int i = 0; i < X; i++)
	{
		if (goodx[i]) {
			for(int j = 0; j < Y; j++)
			{
				if (goody[j]) {
					cout << board[i][j];
				}
				
			}
			cout << endl;
		}
		
	}
	return 0;
	
	
}

Measured memory_bytes: 764
N, K = map(int, input().split())
dp = [0] * N
dp[0] = 1
dp_sum = [0] * N
dp_sum[0] = 1
L = [0] * K
R = [0] * K
mod = 998244353

for i in range(K):
    l, r = map(int, input().split())
    L[i] = l
    R[i] = r

for i in range(1, N):
    # マスiにたどり着くためのパターン数を数える
    cnt = 0
    for j in range(K):
        start = max(0, i - R[j])
        end = i - L[j]
        cnt += (dp_sum[end] - dp_sum[start - 1]) % mod
        cnt %= mod
    dp[i] = cnt
    dp_sum[i] = dp_sum[i - 1] + cnt

print(dp[N - 1])


Measured memory_bytes: 27896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define y_n(ans) cout<<(ans?"Yes":"No")<<endl;

int main() {
    long long n; cin >> n;
    string ans = "";
    while (n > 0) {
        if (n%26) {
            ans = (char)('a' + n%26 - 1) + ans;
        }
        else {
            ans = "z" + ans;
            n--;
        }
        n /= 26;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define cl CLOCKS_PER_SEC
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
    int n;
    cin>>n;
    map<string,int>mp;
    mp["WA"]=0;
    mp["AC"]=0;
    mp["TLE"]=0;
    mp["RE"]=0;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<< "AC x "<<mp["AC"]<<"\nWA x "<<mp["WA"]<<"\nTLE x "<<mp["TLE"]<<"\nRE x "<<mp["RE"]<<"\n";
    return 0;
}


Measured memory_bytes: 3632
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=(ll)1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll R;
    cin >> R;
    if(R<1200)prt("ABC");
    else if(R<2800)prt("ARC");
    else prt("AGC");
    return 0;
}



Measured memory_bytes: 3616
#! /usr/bin/env python3

a, b, c = map(int, input().split())

value_max = max(a, b, c)

diff = 0
for z in [a, b, c]:
    diff += value_max - z

res = 0
if diff % 2 == 0:
    res = diff // 2
else:
    res = diff // 2 + 2

print(res)

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

using namespace std;

const int N = 405;
int h, w, x, y;
bool a[N][N], vis[N][N];
long long ans = 0;

void dfs(int i, int j)
{
    if (vis[i][j]) 
        return;
    vis[i][j] = 1;
    
    if (a[i][j] == 0)
    {
        x++;
    }
    else
    {
        y++;
    }
    
    if (i > 0 && a[i - 1][j] == !a[i][j])
    {
        dfs(i - 1, j);
    }
    if (i < h - 1 && a[i + 1][j] == !a[i][j])
    {
        dfs(i + 1, j);
    }
    if (j > 0 && a[i][j - 1] == !a[i][j])
    {
        dfs(i, j - 1);
    }
    if (j < w - 1 && a[i][j + 1] == !a[i][j])
    {
        dfs(i, j + 1);
    }
}

int main() 
{
    cin >> h >> w;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            char c;
            cin >> c;
            if (c == '.')
            {
                a[i][j] = 0;
            }
            else
            {
                a[i][j] = 1;
            }
        }
    }
    
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
             dfs(i, j);
             ans += 1LL * x * y;
             x = y = 0;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 10496
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
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;
}
const int INF=1e18;
const int MOD=998244353;
const int MAX=200001;
int fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;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 COM(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;
}

int powMOD(int n,int r){
    if(r==0)return 1;
    if(r%2==0)return powMOD(n,r/2)*powMOD(n,r/2)%MOD;
    if(r%2==1)return powMOD(n,r-1)*n%MOD;
}

signed main(){
    int n;cin>>n;
    int d[n];
    REP(i,n)d[i]=0;
    int MA=0;
    REP(i,n){
        int a;cin>>a;
        chmax(MA,a);
        if(i==0&&a!=0){
            cout<<0<<endl;
            return 0;
        }
        if(i!=0&&a==0){
            cout<<0<<endl;
            return 0;
        }
        d[a]++;
    }
    int ans=1;
    REPS(i,MA){
        ans*=powMOD(d[i-1],d[i]);
        ans%=MOD;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
import java.lang.reflect.Array;
import java.util.*;
public class Main
{  


public static void main(String[] args)
	{
Scanner in=new Scanner(System.in);
 
 int n=in.nextInt();
 int a[]=new int[n];
 int p[]=new int [2000000];
int ans=0;
  for(int i=0;i<n;i++) {
	  a[i]=in.nextInt();
	  p[a[i]]=p[a[i]-1]+1;
	  ans=Math.max(ans, p[a[i]]);
  }
	
System.out.println(n-ans);
	
	}
}

Measured memory_bytes: 98356
f,*L=open(0).readlines()
n,m=map(int,f.split())
t=[(int(a.split()[0]),list(map(int,b.split()))) for a,b in zip(*[iter(L)]*2)]
K=[]
for a,C in t:
  r=0
  for c in C:
    r|=2**(c-1)
  K.append((a,r))
INF=float('inf')
dp=[INF]*(2**n)
dp[0]=0
for g in range(2**n):
  for a,c in K:
    if dp[g|c]>dp[g]+a:
      dp[g|c]=dp[g]+a
print(-1 if dp[-1]==INF else dp[-1])

Measured memory_bytes: 3572
N, M, K = map(int, input().split())
*A, = map(int, input().split())
*B, = map(int, input().split())
a = [0] * (N+1)
b = [0] * (M+1)
for i in range(N):
    a[i+1] = a[i] + A[i]
for i in range(M):
    b[i+1] = b[i] + B[i]
ans = 0
j = M
for i in range(N+1):
    tmp = K - a[i]
    if tmp < 0:
        break
    while b[j] > tmp:
        j -= 1
    ans = max(ans, i + j)
print(ans)

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

int main(){
    string s;cin>>s;
    sort(s.begin(),s.end());
    if(s=="abc"){
        std::cout << "Yes" << std::endl;
    }
    else{
        std::cout << "No" << std::endl;
    }
    return 0;
}

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

int card[255][14]={{0}};

int main(void){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        char c;
        int num;
        cin >> c >> num;
        card[(int)c][num]=1;
    }
    for(int i = 1; i <= 13; i++){
        if(card[(int)'S'][i]==0){
            cout << "S " << i << endl;
        }
    }
    for(int i = 1; i <= 13; i++){
        if(card[(int)'H'][i]==0){
            cout << "H " << i << endl;
        }
    }
    for(int i = 1; i <= 13; i++){
        if(card[(int)'C'][i]==0){
            cout << "C " << i << endl;
        }
    }
    for(int i = 1; i <= 13; i++){
        if(card[(int)'D'][i]==0){
            cout << "D " << i << endl;
        }
    }
}



Measured memory_bytes: 3092
/*input
3
apple
orange
apple
*/

#include <bits/stdc++.h>

using namespace std;

set <string> S;
int n;

int main() {
	cin >> n;
	while (n--) {
		string s;
		cin >> s;
		S.insert(s);
	}
	cout << S.size() << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define x first
#define y second

#ifdef LOCAL
#include "/Users/swad/Desktop/CP/debug.h"
#endif

const int N = int(2e5) + 10;
const int MOD = int(1e9) + 7;

int n;
vector<int> adj[N];
int fact[N], inv[N], ifact[N];
int sub_sz[N];
int sub_ways[N];
int tot_ways[N];

void dfs1(int at, int p) {
	sub_sz[at] = 1;
	sub_ways[at] = 1;
	int sum = 0LL;
	for (int to : adj[at]) if (to != p) {
		dfs1(to, at);
		sub_sz[at] += sub_sz[to];
		sum += sub_sz[to];
		sub_ways[at] = sub_ways[at] * 1LL * ifact[sub_sz[to]] % MOD * sub_ways[to] % MOD;
	}
	sub_ways[at] = sub_ways[at] * 1LL * fact[sum] % MOD;
}

int bigmod(int a, int e, int m) {
	ll ret = 1LL;
	ll aa = (ll)a;
	while (e) {
		if (e&1) {
			ret *= aa;
			if (ret > m)
				ret %= m;
			e--;
		}
		aa *= aa;
		e /= 2;
		if (aa > m)
			aa %= m;
	}
	return (int)ret;
}

void dfs2(int at, int p, int pways, int psz) {
	// debug() << name(at) name(p) name(pways) name(psz);
	int mul = ifact[psz] * 1LL * pways % MOD;
	int sum = psz;

	for (int to : adj[at]) if (to != p) {
		mul = mul * 1LL * ifact[sub_sz[to]] % MOD * sub_ways[to] % MOD;
		sum += sub_sz[to];
	}
	tot_ways[at] = fact[sum] * 1LL * mul % MOD;
	for (int to : adj[at]) if (to != p) {
		dfs2(to, at, mul * 1LL * fact[sub_sz[to]] % MOD * fact[sum - sub_sz[to]] % MOD * bigmod(sub_ways[to], MOD - 2, MOD) % MOD, sum + 1 - sub_sz[to]);
	}
}

int main() {
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif

	scanf("%d", &n);
	for (int i = 1; i <= n - 1; i++) {
		int u, v;
		scanf("%d %d", &u, &v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	fact[0] = inv[1] = ifact[0] = 1;
	for (int i = 1; i < N; i++) fact[i] = fact[i - 1] * 1LL * i % MOD;
	for (int i = 2; i < N; i++) inv[i] = inv[MOD % i] * 1LL * (MOD - MOD / i) % MOD;
	for (int i = 1; i < N; i++) ifact[i] = ifact[i - 1] * 1LL * inv[i] % MOD;

	dfs1(1, 0);
	// for (int i = 1; i <= n; i++) debug() << name(i) name(sub_sz[i]) name(sub_ways[i]);
	dfs2(1, 0, 1, 0);

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

	return 0;
}

Measured memory_bytes: 18548
package main

import (
	"fmt"
)

func main() {

	var N string

	fmt.Scan(&N)

	if len(N) == 4 {
		if N[0] == N[1] && N[1] == N[2] {
			fmt.Println("Yes")
		} else if N[1] == N[2] && N[2] == N[3] {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}

}


Measured memory_bytes: 1768
from sys import exit

A,B,C = map(int,input().split())
K = int(input())

for i in range(K):
    if B <= A:
        B = 2*B
    elif C <= B:
        C = 2*C
    else:
        None
    
    if C > B and B > A:
        print("Yes")
        exit(0)

print("No")

Measured memory_bytes: 61688
<?php
	
$nx = explode(' ',trim(fgets(STDIN)));
$n = $nx[0];
$x = $nx[1];
$a = explode(' ',trim(fgets(STDIN)));  

$c = 0;

if ($a[0] > $x) {
  $c = $a[0]-$x;
  $a[0] = $x;
}

for($i=0; $i<count($a)-1; $i++){
  $sum = 0;
  $sum = $a[$i]+$a[$i+1];
  if ($sum > $x) {
    $c += $sum - $x;
    $a[$i+1] = $x - $a[$i];
  }
}

echo $c;

?>

Measured memory_bytes: 14840
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define ll long long
#define endl "\n"
#define ar array
#define deb(x) cout << #x << " = " << x << endl
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll N = 2e5 + 1;

template <class T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
inline ll add(ll a, ll b) { return ((a % mod) + (b % mod)) % mod; }
inline ll sub(ll a, ll b) { return ((a % mod) - (b % mod) + mod) % mod; }
inline ll mul(ll a, ll b) { return ((a % mod) * (b % mod)) % mod; }
struct comp
{
    bool operator()(const pair<ll, ll> &x, const pair<ll, ll> &y) const
    {
        return x.first < y.first;
    }
};
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll pwr(ll x, ll n)
{
    if (n == 0)
        return 1;
    if (n & 1)
        return mul(x, pwr(mul(x, x), (n - 1) / 2));
    else
        return pwr(mul(x, x), n / 2);
}
ll modInv(ll n)
{
    return pwr(n, mod - 2);
}
ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}
ll modex(ll a, ll n)
{
    if (n == 0)
        return 1;
    ll ans = modex(a, n / 2);
    ans = mul(ans, ans);
    if (n % 2)
        ans = mul(ans, a);
    return ans;
}
int main()
{
    IOS;
    int t = 1;
    //  cin >> t;
    while (t--)
    {
        ll n;
        cin >> n;
        ll ans = (modex(10, n) - 2 * modex(9, n) + modex(8, n) + 2 * mod) % mod;
        cout << ans << endl;
    }
}

Measured memory_bytes: 3660
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
  int N, l[100001];
  int index=1;
  int a;
  cin >> N;
  cin >> a;
  l[0] = a;
  for (int i=1; i<N ;i++) {
    scanf("%d", &a);

    for(int j=index/2, min=0, max=index-1;;j = (max + min)/2) {
      if (l[j] >= a) {
        min = (max + min + 1) / 2;
        if (j+1 == index) {
          l[index] = a;
          index++;
          break;
        }
      } else if (l[j] < a) {
        if (j - 1 < 0 || l[j-1] >= a){
          l[j] = a;
          break;
        }
        else {
          max = (max + min) / 2;
        }
      }
    }
  }
  cout << index << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll f(vector<ll> v,ll x, ll k){
	ll cnt=k;
	for(ll ele : v)cnt-=(ele-1)/x;
	return cnt>=0;
	
}
int main() {
	ll n,k;
	cin>>n>>k;
	vector<ll> v(n);
	for(ll i=0;i<n;i++)cin>>v[i];
	ll ans;
	ll lo=1,hi=1e9;
	while(lo<=hi){
		ll mid = (lo+hi)>>1;
		if(f(v,mid,k))ans=mid,hi=mid-1;
		else lo=mid+1;
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 6388
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(' ').map { it.toInt() }
    val ans = a.all {
        if (it % 2 == 0) {
            it % 3 == 0 || it % 5 == 0
        } else {
            true
        }
    }
    println(if (ans) "APPROVED" else "DENIED")
}


Measured memory_bytes: 38292
arr = []
gets.to_i.times do
  s, n = gets.split
  case s
  when "insert"
    arr.unshift n.to_i
  when "delete"
    (i = arr.find_index(n.to_i)) && arr.delete_at(i)
  when "deleteFirst"
    arr.shift
  when "deleteLast"
    arr.pop
  end
end
puts arr.join(' ')



Measured memory_bytes: 21276
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
using namespace std;

int main(){
    int N;
    cin >> N;
    cout.precision(10);
    cout << (double)(N - N/2) / (double)N;
}


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

int main() {
  int h,m,s,S;
  cin >> S;
  
    h=S/60/60;
    m=S/60-h*60;
   s=S%60;   
 cout << h << ":"<< m <<":"<< s  << endl;   
      
  return 0;
}

Measured memory_bytes: 1168
#92c
N = int(input()) #<=10**5
A_list = [0] + [int(e) for e in input().split()] + [0]

fare = [abs(A_list[i]-A_list[i-1]) for i in range(1,N+2)]
sum_fare = sum(fare)

#print(A_list)
#print(fare)

for i in range(1,N+1):
    print(sum_fare - (fare[i-1]+fare[i]) + abs(A_list[i+1] - A_list[i-1]))

Measured memory_bytes: 14048
#include<bits/stdc++.h>
using namespace std;
int main() {
int K ;
cin >> K ;
int q = K / 2 , w = K / 2;
if(K % 2 == 1){
int q = K / 2 , w = K / 2 + 1 ;
cout << q * w << endl; 
}
else{
  cout << q * w << endl;
}
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;

typedef long long ll;
// const int mod = 1000000007;
const int mod = 998244353;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

void Main(){
    ll N, K, l, r;
    cin >> N >> K;
    vector<mint> dp1(N, 0);
    vector<mint> dp_sum(N, 0);
    vector<pll> lrs(K);
    rep(i, K){
        cin >> l >> r;
        // --l; -- r;
        lrs[i] = make_pair(l, r);
    }

    dp_sum[0] = 1;
    dp1[0] = 1;
    for(ll i=1;i<N;i++){
        dp_sum[i] += dp_sum[i-1];
        for(auto lr:lrs){
            l = lr.first;
            r = lr.second;
            mint add_v = 0;
            if(i>=l){
                add_v = dp_sum[i-l];
                // cout << "dp_sum[i-l]=" << dp_sum[i-l] << endl;
            }
            if(i>r){
                add_v -= dp_sum[i-r-1];
                // cout << "dp_sum[i-r-1]=" << dp_sum[i-r-1] << endl;
            }
            // cout << "i=" << i << " lr="<< lr << " add_v=" << add_v <<endl;
            dp1[i] += add_v;
            // cout << "dp_sum[" << i <<"]=" << dp_sum[i] <<endl;
        }
        dp_sum[i] += dp1[i];
    }

    cout << dp1[N-1] <<endl;


}

int main(){
    Main();
}

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

constexpr ll INF = ll(1e+18) + 1;

int main() {
    int A, B;

    cin >> A >> B;

    cout << A*B << endl;
}


Measured memory_bytes: 3632
require 'prime'
def isPrime(n)
    f = n.prime_division
    f.length == 1 && f[0][1] == 1
end
N = gets.to_i
if N == 1 then
    puts 0
    exit
end
if isPrime(N) then
    puts 1
    exit
end
factors = N.prime_division
res = 0
factors.each do |f|
    a = []
    s = 1
    b = f[1]
    loop do
        if !a.include?(s) then
            a.push s
            s += 1
            b = b - s
            break if b <= 0
            next
        else
            break
        end
    end
    res += a.length
end
puts res

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

typedef long long int ll;

int main() {
  ll n, capa[5];
  std::cin >> n;
  for(int i = 0; i < 5; ++i) {
    std::cin >> capa[i];
  }
  std::sort(capa, capa + 5);

  ll ans = n / capa[0] + 4;
  if(n % capa[0] > 0) ++ans;

  std::cout << ans << std::endl;
}


Measured memory_bytes: 256
def conv(S,index,c):
	lstS = list(S)
	lstS[index] = c
	S = ''.join(lstS)

	return S


def DFS(stack,MAP,size,count,goal):
	ret = -1
	newstack = []
	for p in stack:
		if p == goal:
			ret = count
		elif ret == -1:
			y = p[0]
			x = p[1]
			Y = size[0]-1
			X = size[1]-1
			if y != 0:
				if MAP[y-1][x] == '.':
					MAP[y-1] = conv(MAP[y-1],x,'*')
					newstack.append([y-1,x])
			if y != Y:
				if MAP[y+1][x] == '.':
					MAP[y+1] = conv(MAP[y+1],x,'*')
					newstack.append([y+1,x])
			if x != 0:
				if MAP[y][x-1] == '.':
					MAP[y] = conv(MAP[y],x-1,'*')
					newstack.append([y,x-1])
			if x != X:
				if MAP[y][x+1] == '.':
					MAP[y] = conv(MAP[y],x+1,'*')
					newstack.append([y,x+1])
	
	if ret == -1:
		if len(newstack) == 0:
			ret = -1
		else:
			ret = DFS(newstack,MAP,size,count+1,goal)

	return ret


if __name__ == '__main__':
	H, W = map(int, input().split())

	MAP = []
	black = 0

	for y in range(H):
		IN = input() 
		MAP.append(IN)
		black += IN.count('#')

	step = DFS([[0,0]],MAP,[H,W],0,[H-1,W-1])

	if step == -1:
		ans = -1
	else:
		ans = H*W - step - 1 - black

	print(ans)

Measured memory_bytes: 68164
#include <stdio.h>
int solve(int i,int m);
int A[20];
int n;
int main(){
  int i,q,m,ans;
  
  while(1){
    scanf("%d",&n);
    if(n>0 && n<=20) break;
    printf("Error\n");
    }
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(A[i]<0 || A[i] >2001) {
      printf("Error\n");
      }
  }
  while(1){
    scanf("%d",&q);
    if(q>0 && q<=200) break;
    printf("Error\n");
  }
  for(i=0;i<q;i++){
    scanf("%d",&m);
    ans = solve(0,m);
    if(ans == 1) printf("yes\n");
    else printf("no\n");
  }
  
  return 0;
}

int solve(int i,int m){
  int res;
  if(m == 0) return 1;
  if(i >= n) return -1;
  res = solve(i + 1,m) == 1|| solve(i+1,m-A[i]) == 1;
  return res;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S;
    cin >> S;
    if(S.size()%2 == 1){
        cout << "No" << endl;
    }
    else{
        for(int i = 0; i < S.size(); i+=2){
            if(S[i] != 'h' || S[i+1] != 'i'){
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3604
def main():
    n = int(input())
    num_list = list(map(int,input().split()))

    count = 0

    for i in range(0,n):
        if num_list[i] != i + 1:
            count += 1

    if count == 2 or count == 0:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n;
vector<P> a;

int32_t main(){_

   cin>>n;
   a.resize(n);

   for (int i = 0; i < n; ++i)
   {
      cin>>a[i].F;a[i].S = i;
   }

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

   for (int i = 0; i < n; ++i)
   {
      cout<<a[i].S+1<<' ';
   }
   
   

   return 0;
}

Measured memory_bytes: 2432
#include<stdio.h>
int main(void)
{
	int n;
	int x,y,b,p;
	int s,kari;
	int i,j;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d %d",&x,&y,&b,&p);
		if(b<=5 && p<=2){
			kari=(x*5+y*2)*0.8;
		}
		else if(b>5 && p>2){
			kari=(x*b+y*p)*0.8;
		}	
		else if(b>5){
			kari=(x*b+y*2)*0.8;
		}
		else if(p>2){
			kari=(x*5+y*p)*0.8;
		}
		
		if(b>=5 && p>=2){
			s=(x*b+y*p)*0.8;
		}
		else {
			s=x*b+y*p;
		}
		if(kari<s){
			s=kari;
		}
		printf("%d\n",s);
	}
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<string>

using namespace std;

int main(){

	int m;
	string map[5];

	cin>>m;

	for(int i=0;i<5;i++) map[i]="*****";

	for(int i=0;i<m;i++){

		for(int j=0;j<5;j++){
			for(int k=0;k<5;k++){
				cin>>map[j][k];
			}
		}

		int ans=0;

		for(int y=0;y<5;y++){
			for(int x=0;x<5;x++){
				for(int sy=1;y+sy-1<5;sy++){
					for(int sx=1;x+sx-1<5;sx++){
						bool f=true;
						for(int j=0;j<sy;j++){
							for(int k=0;k<sx;k++){
								if(map[y+j][x+k]=='0') f=false;
							}
						}
						if(f&&ans<sy*sx) ans=sx*sy;
					}
				}
			}
		}

		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1200