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

using namespace std;

typedef long long ll;

bool query(ll x) {
  cout << "? " << x << endl;
  char c;
  cin >> c;
  return c == 'Y';
}

int main(int argc, char *argv[]) {
  vector<bool> a(10, true);
  int len = -1;
  for (ll i = 1, j = 10; i <= 9; i++, j *= 10) {
    if (!query(j)) {
      len = i;
      break;
    }
  }
  if (len == -1) {
    for (ll i = 1, j = 9; i <= 10; i++, j = j * 10 + 9) {
      if (query(j)) {
        len = i;
        break;
      }
    }
  }
  ll low = 1;
  for (int i = 2; i < len; i++) {
    low = low * 10;
  }
  ll high = low * 10 - 1;
  while (low <= high) {
    ll mid = (low + high) / 2;
    if (query(mid)) {
      low = mid + 1;
    } else {
      high = mid - 1;
    }
  }
  if (len == 1) high = 0;
  for (int i = (high == 0 ? 1 : 0); i <= 9; i++) {
    if (query(high * 100 + i * 10)) {
      cout << "! " << high * 10 + i << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 596
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t N;
	std::cin >> N;
	std::vector<int64_t> L(N);
	for (int64_t i = 0; i < N; i++)
	{
		std::cin >> L[i];
	}
	std::sort(L.begin(), L.end());

	int64_t ans = 0;

	for (int64_t i = 0; i < N; i++)
	{
		for (int64_t j = i + 1; j < N; j++)
		{
			int64_t k = std::lower_bound(L.begin(), L.end(), L[i] + L[j]) - L.begin();
			ans += std::max(k - (j + 1), (int64_t)0);
		}
	}

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

}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int func(long long n, std::vector<long long> a) {
    vll left(n + 1), right(n + 1);
    rep(i, n) {
        left[i + 1]  = gcd(a[i], left[i]);
        right[i + 1] = gcd(a[n - 1 - i], right[i]);
    }

    ll ans = left[n];
    rep(i, n) {
        ll res;
        if (i == 0) {
            res = right[n - 1];
        } else if (i == n - 1) {
            res = left[n - 1];
        } else {
            res = gcd(left[i], right[n - 1 - i]);
        }
        ans = max(ans, res);
    }
    cout << ans << endl;

    return 0;
}

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

    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    func(N, std::move(A));
    return 0;
}


Measured memory_bytes: 2560
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: h,w,i,j
    character(1),allocatable:: a(:,:)
    logical,allocatable:: pass(:,:)
    
    read*, h,w
    allocate(a(w,h),pass(w,h))
    block
        character(w):: inpt_a
        do i=1,h
            read*, inpt_a
            do j=1,w
                a(j,i) = inpt_a(j:j)
            end do
        end do
    end block
    pass(:,:) = .false.
    if (dfs(1,1,pass))then
        print'(a)', 'Possible'
    else
        print'(a)', 'Impossible'
    end if

contains
recursive function dfs(x,y, pass) result(ret)
    integer(int32):: x,y
    integer(int32):: i,j
    logical:: ret, pass(:,:), npass(w,h)
    npass(:,:) = pass(:,:)
    npass(x,y) = .true.
    ret = .false.
    if (x==w .and. y==h) then
        ret = .true.
        do i=1,h
            do j=1,w
                if (a(j,i) == '#' .and. (.not.npass(j,i))) ret=.false.
            end do
        end do
        return
    end if

    if (x+1 <= w)then
        if(a(x+1,y) == '#') ret=ret .or. dfs(x+1,y,npass)
    end if
    if (y+1 <= h) then
        if(a(x,y+1) == '#') ret=ret .or. dfs(x,y+1,npass)
    end if

        
end function
end program name

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const ll INF = 1061109567;
const ll DOG = 1000000000000001;
const double EPS = 1e-10;
int main(){
    ll N;
    string name;
    cin>>N;
    N--;
    while(N>=0){
        name+=(96+N%26+1);
        N/=26;
        N--;
    }
    for(auto i=name.end()-1;i!=name.begin()-1;i--){
        cout<<*i;
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3588
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		
		int l = 1;
		int r = N;
		
		for(int i=0;i<M;i++) {
			l = Math.max(l,  sc.nextInt());
			r = Math.min(r, sc.nextInt());
		}
		
		if(r<l) {
			out.println(0);
		}else {
			out.println(r-l+1);
		}
		
		sc.close();

	}

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

}


Measured memory_bytes: 62504
N, Q = map(int, input().split())

rtree = {}
for _ in range(N -1 ):
    a, b = map(int, input().split())
    rtree[b] = a

points = [0 for _ in range(N + 1)]
for _ in range(Q):
    p, x = map(int, input().split())
    points[p] += x


dp = [-1 for _ in range(N + 1)]


dp[1] = points[1]

def search(target):
    if dp[target] != -1:
        return dp[target]

    parent = rtree[target]
    ppoint = search(parent)
    dp[target] = ppoint + points[target]
    return dp[target]

ans = []
for target in range(1, N+1):
    ans.append(search(target))

print(" ".join(map(str,ans)))



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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int N;
  cin >> N;
  vi64 A(N);
  cin >> A;
  vi64 ans(N);
  rep(i, N) {
    ans[0] += i % 2 == 0 ? A[i] : -A[i];
  }
  rep(i, N - 1) {
    ans[i + 1] = A[i] * 2 - ans[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<set>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  10000007
#define md 998244353ll
///////////////////////////
///////////////////////////
///


bool vis[MX + 2];
int ar[MX + 2];
int main(){


  for(int i = 2; i<= MX; i++){
      if(vis[i] == 0) {
          ar[i] = i;
          for(int j = i * 2; j<= MX; j += i){
              ar[j] = i;
              vis[j] = 1;
          }
      }
  }


  int n;
  I(n);

ll res = 1;
  for(int i = 2;i<= n;i++){
      int x = i;
      ll an = i;
      while( x > 1){
          int k = ar[x];
          ll cnt = 0;
          while(x % k == 0){
              x/= k;
              cnt++;
          }
          an *= (cnt + 1);
      }
      res += an;
  }

  cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 52620
import math

def solve(x):
    cnt = 0
    for i in li:
        k_i = math.ceil(i/x) - 1
        cnt += k_i
    if cnt > k:
        return False
    else:
        return True


n=0
k=0
li=[]

if __name__ == "__main__":
    n,k = map(int, input().split())
    li = list(map(int,input().split()))
    left = 1
    right = 10**9
    ans = 0
    while right >= left:
        mid = left + (right - left)//2
        flag = solve(mid)
        if flag:
            ans = mid
            right = mid - 1
        else:
            left = mid + 1
    print(ans)


Measured memory_bytes: 30972
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let N = scan.word::<usize>();
    let K = scan.word::<usize>();
    let C = scan.word::<usize>();
    let S = scan.word::<String>().chars().collect::<Vec<_>>();

    // 前から貪欲
    let mut work1 = vec![];
    let mut k = 0;
    let mut next = 0;
    for i in 0..N {
        if k < K && next <= i && S[i] == 'o' {
            work1.push(i);
            k += 1;
            next = i + 1 + C;
        }
    }

    // 後ろから貪欲
    let mut work2 = vec![];
    let mut k = 0;
    let mut next = N;
    for i in (0..N).rev() {
        if k < K && i <= next && S[i] == 'o' {
            work2.push(i);
            k += 1;
            next = i.saturating_sub(1 + C);
        }
    }
    work2.reverse();

    for i in 0..K {
        if work1[i] == work2[i] {
            println!("{}", work1[i] + 1);
        }
    }
}


Measured memory_bytes: 6428
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;
typedef vector<pii> vpii;

#define pb(x) push_back(x)
#define ppb() pop_back()
#define mp(x,y) make_pair(x,y)
#define mod 1000000007
#define FOR0(i,n) for(int i=0;i<n;i++)
#define For(v) for(auto it = v.begin();it!=v.end();it++)
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define FORD(i,a,b) for(int i=(a);i>=(int)(b);i--)
#define sf(n) scanf("%d", &n)
#define sfc(x) scanf("%c", &x)
#define pf(x) printf("%d", x)
#define pff(x) printf("%lf", x)
#define pfc(x) printf("%c", x)
#define pfs(x) printf("%s", x)
#define sf2(a,b) scanf("%d %d", &a, &b)
#define sf3(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
//#define pfs(n) printf("%d ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define sz size()
#define ll long long
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
bool prime[500010];
void SieveOfEratosthenes(ll n)
{
    memset(prime,true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    else if (y%2 == 0)
        return power(x, y/2)*power(x, y/2);
    else
        return x*power(x, y/2)*power(x, y/2);
}

ll power1(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1){
			res*=a;
		}
		a=a*a;
		b>>=1;
	}
	return res;
}



ll mod_power(ll a,ll b,ll m){
	ll res=1;
	a%=m;
	while(b){
		if(b&1){
			res=res*a%m;
		}
		a=a*a%m;
		b>>=1;
	}
	return res;
}
ll printDivisors(ll n) 
{ 
	ll count=0;
    for (ll i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            if (n/i == i) 
                count++; 
  
            else // Otherwise print both 
                printf("%d %d ", i, n/i); 
        } 
    } 
} 
bool isPrime(int n)
{
    if (n <= 1)  return false;
    if (n <= 3)  return true;

    if (n%2 == 0 || n%3 == 0) return false;

    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;

    return true;
}
int main(){
  fast
  ll a,b;
  cin>>a>>b;
  if(b%a==0)cout<<a+b;
  else cout<<b-a;
}

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

#define ll long long
#define loop(i,x,n) for(lli i=x; i<=n; i++)
#define rloop(i,n,x) for(lli i=n; i>=x; i--)

typedef vector<ll> v64;
typedef vector<pair<ll,ll>> vp64;
typedef vector<bool> vbo;
typedef set<ll> s64;
typedef set<bool> sbo;
typedef unordered_set<ll> us64;
typedef map<ll,ll> m64;
typedef unordered_map<ll,ll> um64;

int main(){
    string s,t;
    cin>>s>>t;
    int n = s.length(), m = t.length();
    int dp[n][m];
    if(s[0]==t[0]) dp[0][0] = 1;
    else dp[0][0] = 0;
    for(int j=1; j<m; j++){
        if(s[0]==t[j]) dp[0][j] = 1;
        else dp[0][j] = dp[0][j-1];
    }
    for(int i=1; i<n; i++){
        if(s[i]==t[0]) dp[i][0] = 1;
        else dp[i][0] = dp[i-1][0];
    }
    for(int i=1; i<n; i++){
        for(int j=1; j<m; j++){
            if(s[i]==t[j]) dp[i][j] = dp[i-1][j-1]+1;
            else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }
    int i = n-1, j = m-1;
    string ans = "";
    while(i>=0 && j>=0){
        if(s[i]==t[j]) ans+=s[i], i--, j--;
        else if(dp[i][j] == dp[i-1][j]) i--;
        else j--;
    }
    reverse(ans.begin(),ans.end());
    // cout<<dp[n-1][m-1]<<"\n";
    cout<<ans<<"\n";
    return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

vector<ll> v;
int n;
ll dp[222222][22];
ll four[22];

ll comp(ll a,ll b){
	ll ret = 0;
	ll mul = (a + b - 1) / b;
	ll tmp = 1;
	while(tmp < mul){
		tmp *= 4;
		ret++;
	}
	return ret;
}

ll dfs(int a, int b){
	if(dp[a][b] != -1)return dp[a][b];
	if(a == n-1)return dp[a][b] = 0;
	ll tmp = comp(four[b]*v[a],v[a+1]);
	if(tmp > 15){
		return dp[a][b] = tmp + (tmp - 15) * (n - a - 2) + dfs(a+1, 15);
	}
	else{
		return dp[a][b] = tmp + dfs(a+1,tmp);
	}
}

vector<ll> seica(){
	REP(i,222222)REP(j,22)dp[i][j] = -1;
	vector<ll> ret(n);
	for(int i = n-1;i >= 0;i--) {
	//	cout << i << endl;
		ret[i] = dfs(i, 0);
	}
	return ret;
}

int main(){
	
	cin >> n;
	four[0] = 1;
	REP(i,20)four[i+1] = four[i] * 4;
	REP(i,n){
		int tmp;cin >> tmp;
		v.EB(tmp);
	}
	
	auto A = seica();
	reverse(ALL(v));
	auto B = seica();reverse(ALL(B));
	
	ll ans = min(2 * A[0], 2 * B[n-1] + n);
	REP(i,n-1){
		ans = min(ans, 2*(A[i+1]+B[i])+(i+1));
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 44144
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  int n,m;
  cin >> n >> m;
  cout << n*(n-1)/2 + m*(m-1)/2 << endl;
  return 0;
}

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

struct Point {
  double x, y;
};

void koch(int n, Point a, Point b) {
  if(n == 0) return;
  Point s, t, u;
  double th = M_PI * 60.0 / 180.0;  // 度 >> Radian

  s.x = (2.0*a.x + 1.0*b.x)/3.0;
  s.y = (2.0*a.y + 1.0*b.y)/3.0;
  t.x = (1.0*a.x + 2.0*b.x)/3.0;
  t.y = (1.0*a.y + 2.0*b.y)/3.0;
  u.x = (t.x-s.x)*cos(th) - (t.y-s.y)*sin(th) + s.x;
  u.y = (t.x-s.x)*sin(th) + (t.y-s.y)*cos(th) + s.y;

  koch(n-1, a, s);  cout << s.x << " " << s.y << endl;
  koch(n-1, s, u);  cout << u.x << " " << u.y << endl;
  koch(n-1, u, t);  cout << t.x << " " << t.y << endl;
  koch(n-1, t, b);
}

signed main() {
  Point a, b;
  int n; cin >> n;
  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  cout << a.x << " " << a.y << endl;
  koch(n, a, b);
  cout << b.x << " " << b.y << endl;

  return 0;
}



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

int main() {
    int x,y,a,b,c; cin >>x>>y>>a>>b>>c;
    vector <int>v1;
    vector <int>v2;
    vector <int>v3;
    for (int i =0;i < a; i++) {int d; cin >> d; v1.push_back(d);}
    for (int i =0;i < b; i++) {int d; cin >> d; v2.push_back(d);}
    for (int i =0;i < c; i++) {int d; cin >> d; v3.push_back(d);}
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    sort(v3.begin(), v3.end());
    a--; b--; c--;
    int m = x+y;
    long long ans = 0;
    for (int i = 0; i < m; i++){
        if (a >=0 && b>=0 && c>=0){
            if(v1[a]>=v2[b] && v1[a]>= v3[c] && x>0){ x--;  ans += v1[a]; a--;if(!x) a= -1;}
            else if(v2[b]>=v1[a] && v2[b]>= v3[c] && y>0){ y--; ans += v2[b]; b--;if(!y) b= -1;}
            else { ans += v3[c]; c--;}
        }
        else if( a>= 0 && b>= 0){
            if(v1[a]>=v2[b]  && x>0){x--;  ans += v1[a]; a--; if(!x) a= -1;}
            else if(v2[b]>=v1[a] &&  y>0){y--;ans += v2[b]; b--;if(!y) b= -1;}
        }
        else if( a>= 0 && c>= 0){
            if(v1[a]>=v3[c]  && x>0){ x--;  ans += v1[a];a--;if(!x) a= -1;}
            else {ans += v3[c]; c--;}
        }
         else if( b>= 0 && c>= 0){
            if(v2[b]>=v3[c]  && y>0){ y--;  ans += v2[b];b--;}
            else {ans += v3[c]; c--;}
         }
        else if (a>=0){ans+= v1[a]; a--;}
        else if (b>=0){ ans += v2[b];b--;}
        else if (c>=0){ans+= v3[c]; c--;}
    }
    cout << ans<<endl;
    //cout << a<<  b << c; 
}

Measured memory_bytes: 1784
import numpy as np
n = int(input())
res = [0]*(n+1)
for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            x = i*i + j*j + k*k + i*j + j*k + k*i
            if x <= n:
                res[x] += 1
for i in range(1,n+1):
    print(res[i])


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

int main() {

    int n;

    cin >> n;

    vector<int> a(n);

    int tmp;
    int flag = 0;

    for (int i =0;i<n;i++){
        cin >> a.at(i);
    }
  	
 	sort(a.begin(), a.end());
  	a.erase(unique(a.begin(), a.end()), a.end());
  
  	if (a.size() == n) cout << "YES" << endl;
  	else cout << "NO" << endl;
  
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#define BUG puts("no bug")
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define REP(a,b,c) for(ll a=b;a<=c;a++)
#define PER(a,b,c) for(ll a=b;a>=c;a--)
#define lb(a) (a&(-a))
#define pp (p<<1)
#define ppp (p<<1|1)
#define pi pair<ll,ll>
#define pii pair<pair<ll,ll>,ll>
using namespace std;
const ll MAXN=1e6+5;
ll n,m,t;
ll qian[MAXN];
int main(){
    REP(i,1,1e6){
        qian[i]+=qian[i-1];
        if(i%3&&i%5)qian[i]+=i;
    }
    cin>>n;
    cout<<qian[n];
}

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

int main(){
    int H[25565] = {0};
    int W[25565] = {0};
    int i;
    do{
        cin >> H[i] >> W[i];
        i++;
    }while(H[i-1] != 0 && W[i-1] != 0);
    for(int j=0;j<i-1;j++){
        for(int k=H[j];k>0;k--){
            for(int l=W[j];l>0;l--){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}

Measured memory_bytes: 1356
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int cost[n];

    for(int i=0;i<n;i++)cin>>cost[i];

    int dp[n];
    for(int i=0;i<n;i++)dp[i] = INT_MAX;

    dp[0] = 0;

    for(int i=1;i<n;i++)
    {
       for(int j=1;j<=k;j++)
       {
           if(i-j>=0)
            dp[i] = min( dp[i],dp[i-j] + abs(cost[i]-cost[i-j]) );
       }
    }

    cout<<dp[n-1];

}


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

int main(){
    int ans = 0,mm = -1;

    int a,b,c,n;
    cin >> a >> b >> c >> n;
    ans += a+b+c;

    mm = max(max(a,b),c);

    ans += mm * pow(2,n) - mm;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;

#define abs(N) ((N>0)?N:-1*N)
#define min(A,B) ((A>B)?B:A)
#define max(A,B) ((A<B)?B:A)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

int main(){

	int n;
	cin >> n;
	int t=0,h=0;
	for (int i = 0; i < n; ++i) {
		string ts,hs;
		cin >> ts >> hs;
		if(ts>hs){
			t+=3;
		}else if(ts<hs){
			h+=3;
		}else{
			t++;
			h++;
		}
	}

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

	return 0;
}



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

int main(void)
{
  int i;
  char S[101];
  
  scanf("%s", S);
  for (i = 0; i < 101; i++)
  {
    if (S[i] == '\0')
    {
      break;
    }
    S[i] = 'x';
  }
  
  printf("%s\n", S);
  return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n + 1];
		for (int i = 1; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		arr[0] = arr[1];
		arr[n] = arr[n - 1];
		int total = 0;
		for (int i = 0; i < n; i++) {
			total += Math.min(arr[i], arr[i + 1]);
		}
		System.out.println(total);
	}
}


Measured memory_bytes: 23124
#include <stdio.h>
#include <string.h>

typedef struct {
    int tx;
    int ty;
    char now[101][101];
    int ice;
} MAP;

MAP queue[1000];
int head, tail;
char map[101][101], check[101][101];

int max(int a, int b)
{
    if (a > b){
        return (a);
    }
    return (b);
}

void enq(MAP t)
{
    queue[tail % 1000] = t;
    tail++;
}

void deq(MAP *t)
{
    *t = queue[head % 1000];
    head++;
}

int bfs(int y, int x)
{
    MAP first, temp;
    int i, j;
    int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
    int ans;
    
    memcpy(first.now, map, sizeof(map));
    first.tx = x;
    first.ty = y;
    first.ice = 0;
    
    ans = 0;
    head = tail = 0;
    enq(first);
    
    while (head != tail){
        deq(&temp);
        
        temp.ice++;
        ans = max(ans, temp.ice);
        
        for (i = 0; i < 4; i++){
            if (temp.tx + dx[i] >= 0 && map[temp.ty + dy[i]][temp.tx + dx[i]] != -1 && temp.ty + dy[i] >= 0 && temp.now[temp.ty + dy[i]][temp.tx + dx[i]] == 1){
                first = temp;
                first.now[first.ty][first.tx] = 0;
                first.tx += dx[i];
                first.ty += dy[i];
                enq(first);
            }
        }
    }
    return (ans);
}

int dfs(int y, int x, int num)
{
    int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
    int i, j;
    
    check[y][x] = 0;
    num++;
    
    for (i = 0; i < 4; i++){
        if (x + dx[i] >= 0 && y + dy[i] >= 0 && check[y + dy[i]][x + dx[i]] == 1){
            num = dfs(y + dy[i], x + dx[i], num);
        }
    }
    
    return (num);
}

int main(void)
{
    int x, y;
    int i, j;
    int ans;
    
    while (1){
        scanf("%d", &x);
        scanf("%d", &y);
        
        if (x + y == 0){
            break;
        }
        
        memset(map, -1, sizeof(map));
        
        for (i = 0; i < y; i++){
            for (j = 0; j < x; j++){
                scanf("%d", &map[i][j]);
            }
        }
        
        ans = 0;
        
        for (i = 0; i < y; i++){
            for (j = 0; j < x; j++){
                memcpy(check, map, sizeof(map));
                if (map[i][j] == 1 && dfs(i, j, 0) > ans){
                    ans = max(ans, bfs(i, j));
                }
            }
        }
        
        printf("%d\n", ans);
    }
    
    return (0);
}

Measured memory_bytes: 10000
n, m, x = [int(x) for x in input().split()]
c = [[int(x) for x in input().split()] for _ in range(n)]
ans = float('inf')
for s in range(1 << n):
    if all(sum(c[i][j] for i in range(n) if s & (1 << i)) >= x for j in range(1, m + 1)):
        ans = min(ans, sum(c[i][0] for i in range(n) if s & (1 << i)))
print(ans if ans != float('inf') else -1)


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

using namespace std;

#define ALL(x) begin(x), end(x)

int gcd(int A, int B) {
  int d;
  if (!A) return B;
  if (!B) return A;
  while ((d = A % B)) {
    A = B;
    B = d;
  }
  return B;
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N), L(N + 1), R(N + 1);
  for (auto &a : A) {
    cin >> a;
  }

  L[0] = R[N] = 0;
  for (auto i = 0; i != N; ++i) {
    L[i + 1] = gcd(L[i], A[i]);
    R[N - i - 1] = gcd(R[N - i], A[N - i - 1]);
  }

  int ans{};
  for (auto i = 0; i != N; ++i) {
    ans = max(ans, gcd(L[i], R[i + 1]));
  }

  cout << ans << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> lP;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG
int main(){
    string s,t;
    cin>>s>>t;

    int slong=s.size();
    int tlong=t.size();

    int ans=1010;
    rep(i,slong-tlong+1){
        int count=0;
        rep(j,tlong){
            if(s[i+j]!=t[j]) count++;
        }
    ans=min(ans,count);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3576
def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [N, K] = list(map(lambda x: int(x), inputs[0].split()))
    pattern = K
    for i in range(1, N):
        pattern *= K - 1
    return pattern


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin >> n;
	int a[n];
	int i;
	for (i = 0; i < n; i++)
		cin >> a[i];
	int mx = a[0];
	long long int ans = 0;
	for (i = 1; i < n; i++)
	{
		if (a[i] < mx)
		{
			ans +=  mx - a[i];
		}
		mx = max(mx, a[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4396
#include <stdio.h>

int main(void){
	int N = 3000;
	int a;
	int b;
	int c;
	int counter;

	scanf("%d %d %d",&a,&b,&c);
	for(int i=a; i <= b; i++){
		if(c%i==0)
		counter++;
}
	printf("%d\n", counter);

	return 0;
}


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

using namespace std;

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    int x;
    cin>>x;
    if(x==0)
        cout<<1;
    else
        cout<<0;
    return 0;
}


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

int main (void)
{
  int a, b = 0;
  cin>>a;
  cin>>b;
  if(a == 0 || b == 0)
  {
      cout<<"Zero";
      return 0;
  }
  else if(a > 0 && b > 0)
  {
      cout << "Positive";
      return 0;
  }
  else if(a < 0 && b > 0)
  {
      cout<<"Zero";
      return 0;
  }
  else if(a < 0 && b < 0)
  {
      if((a-b)%2 == 0)
      {
          cout<<"Negative";
          return 0;
      }
      else
      {
          cout<<"Positive";
          return 0;
      }
  }
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline

def main():
    mod=1000000007
    inv=lambda x: pow(x,mod-2,mod)    
    n=int(input())
    Fact=[1] #階乗
    for i in range(1,n+1):
        Fact.append(Fact[i-1]*i%mod)
    Finv=[0]*(n+1) #階乗の逆元
    Finv[-1]=inv(Fact[-1])
    for i in range(n-1,-1,-1):
        Finv[i]=Finv[i+1]*(i+1)%mod
    Edges=[[] for _ in range(n)]
    for _ in range(n-1):
        a,b=map(int,input().split())
        a-=1; b-=1
        Edges[a].append(b)
        Edges[b].append(a)
    Stack=[0]
    Par=[-1]*n
    Order=[]
    while Stack:
        v=Stack.pop()
        Order.append(v)
        for c in Edges[v]:
            if c!=Par[v]:
                Stack.append(c)
                Par[c]=v
    DP=[1]*n
    Size=[1]*n
    for v in Order[::-1]:
        DP[v]*=Fact[Size[v]-1]
        DP[v]%=mod
        p=Par[v]
        if p==-1:
            continue
        Size[p]+=Size[v]
        DP[p]*=DP[v]*Finv[Size[v]]
        DP[p]%=mod
    Ans=[0]*n
    Ans[0]=DP[0]
    for v in Order[1:]:
        p=Par[v]
        Ans[v]=Ans[p]*Size[v]*inv(n-Size[v])%mod
    print(*Ans,sep='\n')
    
if __name__=='__main__':
    main()

Measured memory_bytes: 117816
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int main(){
    ll n;
    map<ll,int> m;
    cin >> n;
    ll tmp = n;
    for (ll i = 2; i*i <= n;i++){
        while(n%i == 0){
            n/= i;
            m[i]++;
        }
    }
    if (n != 1) m[n]++;
    int ans = 0;
    for (auto q:m){
        //cout << q.first << q.second << endl;
        int tmp = q.second;
        int cnt = 1;
        while(tmp > 0){
            tmp -=cnt;
            cnt++;
            if (tmp >= 0) ans++;
        }
    }
    cout << ans << endl;
    

    return 0;

}

Measured memory_bytes: 3644
#include<iostream>
using namespace std;
typedef unsigned long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
int main() {
    ll a, k;
    double b;
    cin >> a >> b;
    if (a != 0 && b != 0) {
        k = b * 1000;
        a *= k;
        a /= 1000;
        cout << a << endl;
    } else {
        cout << 0 << endl;
    }
}


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

const int N = 1e5 + 5;

int n, m, dis[N], pre[N], s, t;
vector<int> G[N];
deque<int> Q;
bool bo[N];

void dfs(int x) {
	bo[x] = 1;
	for (int i = 0; i < G[x].size(); i++) {
		int u = G[x][i];
		if (bo[u]) continue;
		Q.push_back(u);
		dfs(u);
		return;
	}
}

void dfs1(int x) {
	bo[x] = 1;
	for (int i = 0; i < G[x].size(); i++) {
		int u = G[x][i];
		if (bo[u]) continue;
		Q.push_front(u);
		dfs1(u);
		return;
	}
}

int main() {
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	Q.push_back(1);
	dfs(1); 
	dfs1(1);
	cout << Q.size() << endl;
	while (!Q.empty()) {
		int x = Q.back();
		Q.pop_back();
		printf("%d ", x);
	}
}

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

using namespace std;

using ull = unsigned long long;

int main() {
    int A, B;
    cin >> A >> B;
    if((A+B)%2){
        cout << "IMPOSSIBLE" << endl;
    } else{
        cout << ((A+B)>>1) << endl;
    }
    return 0;
}


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

bool check_753(int i)
{
  string S = to_string(i);
  bool has_7=false, has_5=false, has_3=false;
  for(char c:S)
  {
    if(c=='7')
      has_7 = true;
    else if(c=='5')
      has_5 = true;
    else if(c=='3')
      has_3 = true;
  }
  if(has_7 && has_5 && has_3)
    return true;
  else
    return false;
}

int count_753(long long int i, long long int N, int cnt)
{
  if(i > N)
    return cnt;

  if(check_753(i))
    ++cnt;

  cnt = count_753(10*i+3, N, cnt);
  cnt = count_753(10*i+5, N, cnt);
  cnt = count_753(10*i+7, N, cnt);
}

int main()
{
  long long int N;
  cin >> N;
  long long int i=0;
  int ans;
  ans = count_753(i, N, 0);
  cout << ans << endl;
  return 0;
}

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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		long H = nextLong();
		long W = nextLong();
		long h = nextLong();
		long w = nextLong();


		System.out.println((H-h)*(W-w));

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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



using namespace std;



#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repf(i, f, l) for(int i = f; i < (int)l; ++i)
#define repit(it, t) for(__typeof((t).begin()) it = (t).begin(); it != (t).end(); it++)
#define endl "\n"
#define pb emplace_back
#define lb lower_bound
#define int long long
#define ul unsigned long
#define ull unsigned long long
#define ll long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second
#define DBG0(x) { cout << #x << ": " << x << "\t"; }
#define DBG(x) {DBG0(x); cout << endl;}
#define DBG2(x, y) {DBG0(x); DBG(y);}
#define DBG3(x, y, z) {DBG0(x); DBG2(y, z);}
#define DBG4(w, x, y, z) {DBG0(w); DBG3(x, y, z);}

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef vector<bool> vbl;
typedef pair<int, int> pii;

signed main(void){
    ios::sync_with_stdio(false);
    string s;
    int w;
    cin >> s >> w;
    int ind = 0;
    string ret = "";
    while (ind < s.size()) {
        ret += s[ind];
        ind += w;
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a;
    int ans = 0;

    scanf("%d", &a);
    
    while (a > 0) {
        if (a%10 == 2) {
            ans++;
        }
        a /= 10;
    }

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

    return 0;
}

Measured memory_bytes: 128
N = int(input())
h = list(map(int, input().split()))
DP = [0]*N
DP[1] = abs(h[0]-h[1])
for i in range(2, N):
    DP[i] = min(DP[i-1]+abs(h[i-1]-h[i]), DP[i-2]+abs(h[i-2]-h[i]))
print(DP[N-1])


Measured memory_bytes: 20480
#coding: utf-8
N,T=map(int,input().split())
ans_t=1001
i=0
for i in range(N):
    c,t=map(int,input().split())
    if(t<=T):
        if(c<ans_t):
            ans_t=c
if(ans_t!=1001):
    print(ans_t)
else:
    print("TLE")


Measured memory_bytes: 2940
#include <stdio.h>

int main()
{

int a[10000], min, max, n, i;
long long sum = 0;
scanf("%d", &n);
for(i = 0; i < n; i++)
{
scanf("%d", &a[i]);
sum += a[i];
}
max = min = a[0];
for(i = 1; i < n; i++)
{
if(a[i] > max)max = a[i];
if(a[i] < min)min = a[i];
}
printf("%d %d %lld\n", min, max, sum);

return 0;
}


Measured memory_bytes: 2048
import java.util.Scanner;

// A - BuyingSweets

public class Main {
	
	int X = 0;
	int A = 0;
	int B = 0;
	int ans = 0;
	int sum = 0;
	
	public static void main(String[] args) {
		new Main().run();
	}
	void run() {
		Scanner sc = new Scanner(System.in);
		X = sc.nextInt();
		A = sc.nextInt();
		B = sc.nextInt();
		ans = X - A;
		
		while(ans >= 0) {
			ans -= B;
		}
		System.out.println(ans + B);
	}
}

Measured memory_bytes: 23764
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<climits>
using namespace std;


int main(){

    int h,w;
    cin >> h >> w;
    int count = 0;
    char str[h+2][w+2];
    int num[h+2][w+2] = {0};
    for(int i = 1;i < h+1;i++){
        for(int j = 1;j < w+1;j++){
            cin >> str[i][j];
        }
    }

    /*for(int i = 1;i < h+1;i++){
        for(int j = 1;j < w+1;j++){
           cout << str[i][j];
        }
        cout << endl;
    }*/


    for(int i = 1;i < h+1;i++){
        for(int j = 1;j < w+1;j++){
            if(str[i][j] == '#'){
                num[i][j] = 0;
                if(num[i+1][j-1] != '#'){
                    num[i+1][j-1]++;
                }
                if(num[i+1][j] != '#'){
                    num[i+1][j]++;
                }
                if(num[i+1][j+1] != '#'){
                    num[i+1][j+1]++;
                }
                if(num[i][j-1] != '#'){
                    num[i][j-1]++;
                }
                if(num[i][j+1] != '#'){
                    num[i][j+1]++;
                }
                if(num[i-1][j-1] != '#'){
                    num[i-1][j-1]++;
                }
                if(num[i-1][j] != '#'){
                    num[i-1][j]++;
                }
                if(num[i-1][j+1] != '#'){
                    num[i-1][j+1]++;
                }
            }
        }
    }

    for(int i = 1;i < h+1;i++){
        for(int j = 1;j < w+1;j++){
            if(str[i][j] == '#'){
                cout << '#';
            }else{
                cout << num[i][j];
            }
        }
        cout << 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;

int main(){
    int k,A,B;
    cin >> k >> A >> B;
    for(int i = A; i <=B  ; i++){
        if(i%k==0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3620
import java.io.PrintWriter;
import java.util.Scanner;
import static java.lang.Math.*;

public class Main {

	static int[][] d;
	static final int INF = 1 << 24;

	static Scanner scan = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		while(true){
			int n = si(),m = si(),s = si()-1,g1 = si()-1,g2 = si()-1;
			if(n==0) break;
			d = new int[n][n];
			for (int i = 0; i < n ; i++) for (int j = 0; j < n ; j++) d[i][j] = i==j ? 0 : INF;
			for (int i = 0; i < m; i++) d[si()-1][si()-1]=si();
			warshallFloyd(n);
			int mincost = INF;
			for (int i = 0; i < n; i++) mincost = min(d[s][i]+d[i][g1]+d[i][g2],mincost);
			out.println(mincost);
		}
		out.flush();
	}

	static void warshallFloyd(int n){
		for (int i = 0; i < n ; i++) {
			for (int j = 0; j < n ; j++) {
				for (int j2 = 0; j2 < n; j2++) {
					d[j][j2] = min(d[j][j2],d[j][i]+d[i][j2]);
				}
			}
		}
	}

	static int si() {
		return Integer.parseInt(scan.next());
	}
}

Measured memory_bytes: 66068
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
using namespace std;
using ll = unsigned long long;

int main() {
    int n = 5;
    int x;
    int out;
    for(int i = 0 ; i < n ; i++){
        cin >> x;
        if(x==0){
            out = i+1;
        }
    }
    cout << out;
    return 0;
}


Measured memory_bytes: 3588
X, K, D = map(int, input().split())

value = abs(X)

if (value / D) >= K:
  print(value - D * K)
else:
  min_count = value // D
  mod_value = K - min_count
  if mod_value % 2 == 0:
    print(value % D)
  else:
    print(abs(value % D - D))

Measured memory_bytes: 9180
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  string S;
  cin >> N >> S;
  const int64_t L = static_cast<int64_t>(S.length());
  int64_t count = 0;
  string result = "";
  for (int64_t i = 0; i < L; ++i) {
    const char ch = S.c_str()[i];
    if (ch == '(') {
      result += "(";
      ++count;
    } else {
      if (count > 0) {
        result += ")";
        --count;
      } else {
        result = "(" + result + ")";
      }
    }
  }
  while (count > 0) {
    result += ")";
    --count;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stdlib.h>

using namespace std;

unsigned long long int power(unsigned long long int x, unsigned long long int n) {
	if(n == 0) return 1;
	if(n == 1) return x;
	if(x == 0) return 0;
	if(n % 2 == 1) {
		unsigned long long int y;
		y = power(x, (n - 1) / 2);
		return x*y*y;
	} else {
		unsigned long long int y;
		y = power(x, n / 2) ;
		return y*y;
	}
	return -1;
}

int main(void){
//	FILE* fp_in = freopen("data.txt", "r", stdin);

	int Q;
	cin >> Q;
	vector<int> N;
	vector<int> ans;
	for(int i = 0; i < Q; i++) {
		unsigned long long int n_i;
		unsigned long long int p;
		int ans = 0;
		cin >> n_i;
		p = n_i;

		while( p > 9 ) {

			stringstream ss;
			ss << p;
			int max = 0;

			for(int i = 1; i < ss.str().length() ; i++) {
				unsigned long long int tmp;
				unsigned long long int div1, div2;
				tmp = power(10, i);
				div1 = p / tmp;
				div2 = p % tmp;
//				cout << div1 << ":" << div2 << "@" << div1*div2 << endl;
				if(div1 * div2 >= max) {
					max = div1 * div2;
				}
			}
			ans ++;
			p = max;
			if( p > n_i ) {
				ans = -1;
				p = -1;
			}

		}
		cout << ans << endl;
	}


	
//	while(1){}
	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1ll << 60

using namespace std;
typedef long long ll;
typedef pair<ll, int> pp;

typedef struct {
	int to;
	ll cost;
} edge;

void Dijk(int s, vector<vector<edge>> &d, vector<ll> &ans) {
	int i;
	priority_queue<pp, vector<pp>, greater<pp>> que;
	que.push(pp(0, s));
	while (!que.empty()) {
		int n = que.top().second;
		ll c = que.top().first;
		que.pop();
		if (ans[n] == INF) {
			ans[n] = c;
			vector<edge>& e = d[n];
			rep(i, e.size()) {
				if (ans[e[i].to] == INF) {
					que.push(pp(e[i].cost + c, e[i].to));
				}
			}
		}
	}
}

int main(void) {
	int num, i, m, s, g, x, y, c, d;
	ll sum = 1e15;
	cin >> num >> m >> s >> g;
	vector<vector<edge>> a(num + 1), b(num + 1);
	vector<ll> fir(num + 1, INF), lat(num + 1, INF), ans(num + 1);
	priority_queue<ll> que;
	rep(i, m) {
		scanf("%d%d%d%d", &x, &y, &c, &d);
		a[x].push_back({ y, c });
		a[y].push_back({ x, c });
		b[x].push_back({ y, d });
		b[y].push_back({ x, d });
	}
	Dijk(s, a, fir);
	Dijk(g, b, lat);
	for (i = num; i > 0; i--) {
		que.push(sum - fir[i] - lat[i]);
		ans[i] = que.top();
	}
	for (i = 1; i <= num; i++)
		cout << ans[i] << "\n";
	return 0;
}

Measured memory_bytes: 22236
#include<stdio.h>
int main()
{
    int a,b,x;
    scanf("%d %d %d",&x,&a,&b);
    if((b-a)<=0)
    {
        printf("delicious");
    }
    else if((b-a)>x)
    {
        printf("dangerous");
    }
    else
    {
        printf("safe");
    }
    return 0;

}


Measured memory_bytes: 128