akhauriyash/Code-Regression huggingface dataset:
#pragma region

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;
using vvb = vector<vector<bool>>;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &pair) {
  cin >> pair.first >> pair.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

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

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16);
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  init();

  int N, M;
  cin >> N >> M;

  out(N * (N - 1) / 2 + M * (M - 1) / 2);
}


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

int main() {
  int k;
  string s;
  cin >> k >> s;
  
  if(s.size() <= k) {
    cout << s << endl;
  } else {
    string ans = s.substr(0, k);
    ans += "...";
    cout << ans << endl;
  }
}  

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

int main() {
  vector<int> time(5);
  for (int i = 0; i < 5; i++) {
    cin >> time.at(i);
  }
  vector<int> next(5);
  for (int i = 0; i < 5; i++) {
    next.at(i) = (time.at(i) + 9) / 10 * 10;
  }

  int min_time = 9999;
  for (int i = 0; i < 5; i++) {
    int sum_time = 0;
    for (int j = 0; j < 5; j++) {
      if (i == j) {
        sum_time += time.at(j);
      }
      else {
        sum_time += next.at(j);
      }
    }
    min_time = min(min_time, sum_time);
  }

  cout << min_time << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k;
int a[100100];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	int res=0;
	for(int i=1;i<=n;i+=(k-1)){
		res++;
		if(i+(k-1)>=n)
			break;
	}
	cout<<res<<endl;
	return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

int main () {
	int argK, argS;
	cin >> argK >> argS;

	argK++;
	int counter = 0;
	for (int x = 0; x < argK; ++x) {
		for (int y = 0; y < argK; ++y) {
			if (argS - x - y < argK && argS - x - y >= 0) {
				counter++;
			}
		}
	}

	cout << counter;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static int[] ans;
    static HashMap<Integer, ArrayList<Edge>> map;
    static int max = -1;
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ans = new int[n-1];
        map = new HashMap<>();
        for (int i = 0; i < n - 1; i++) {
            int from = sc.nextInt();
            int to = sc.nextInt();
            if (map.containsKey(from)) {
                map.get(from).add(new Edge(to, i));
            } else {
                ArrayList<Edge> list = new ArrayList<>();
                list.add(new Edge(to, i));
                map.put(from, list);
            }
        }
        dfs(1, -1);
        System.out.println(max);
        for(int i = 0; i < n-1; i++) {
            System.out.println(ans[i]);
        }
    }

    static void dfs(int currNode, int prevColor) {
        int color = 1;
        if (!map.containsKey(currNode)) return;
        for (Edge edge: map.get(currNode)) {
            if (color == prevColor) color++;
            dfs(edge.to, color);
            ans[edge.id] = color;
            max = Math.max(max, color);
            color++;
        }
    }

    static class Edge {
        int to;
        int id;
        Edge(int to, int id) {
            this.to = to;
            this.id = id;
        }
    }
}


Measured memory_bytes: 99080
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

int main() {
  int a, b;
  cin >> a >> b;
  int anser = 0;
  FOR(i, a, b + 1) {
    string ii = to_string(i);
    if (ii[0] == ii[4] && ii[1] == ii[3]) {
      anser++;
    }
  }
  cout << anser << endl;
  return 0;
}

Measured memory_bytes: 384
#include<cstdio>
int cnt[10];

int main(){
    for(int i = 0; i < 4; i++){
        int u;
        scanf("%d",&u);
        cnt[u]++;
    }
    if(cnt[1]==1 && cnt[7]==1 && cnt[9]==1 && cnt[4]==1) printf("YES\n");
    else printf("NO\n");
    return 0;
}


Measured memory_bytes: 1608
#include <stdio.h>
#include <math.h>
typedef long long ll;

int main(void) {
  ll i, j, k, b;
  while( 1 ) {
    scanf("%lld", &b);
    if(!b) break;
    b *= 2;
    bool t = false;
    for(i = sqrt(b); i > 0; --i)  if(!(b % i) && (b / i - i) % 2) {
      printf("%lld %lld\n", (b / i - i + 1) / 2, i);
      break;
    }
  }
  return 0;
}


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

const int INF = 1e9;

int main() {
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  int i = 0;
  int cnt0seq = 0;
  while (i < n) {
    if (s[i] == '1') {
      ++i;
    } else {
      if (cnt0seq == k) {
        break;
      }
      while (i < n && s[i] == '0') {
        ++i;
      }
      ++cnt0seq;
    }
  }
  if (i == n) {
    cout<<i<<endl;
    return 0;
  }
  int j = 0;
  int ans = i;
  while (i < n) {
    while (j < n - 1 && !(s[j] == '0' && s[j+1] == '1')) {
      ++j;
    }
    ++j;
    while (i < n && s[i] == '0') {
      ++i;
    }
    while (i < n && s[i] == '1') {
      ++i;
    }
    ans = max(i - j, ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = Long.parseLong(sc.next());
        double b = Double.parseDouble(sc.next());
        long c = Math.round(b * 100);
        System.out.println(a * c / 100);
    }
}

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

int main() {
	// freopen("input.in", "r", stdin);
	// freopen("output.o", "w", stdout);
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	int x = a + b;
	int y = b + c;
	int z = a + c;
	int ans = min(min(x, y), z);
	printf("%d", ans);
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

typedef long long ll;
typedef unsigned long long ull;
typedef complex<double> P;

// ?¨±?????????????????
#define EPS (1e-10)
// 2??????????????????????????????????????????
#define EQ(a,b) (abs((a)-(b)) < EPS)

// ?????? (cross product) : a??b = |a||b|sin??
double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}

// 2??´?????????????????? : a//b <=> cross(a, b) = 0
int is_parallel(P a1, P a2, P b1, P b2) {
  return EQ( cross(a1-a2, b1-b2), 0.0 );
}

int main() {
	int N;
	scanf("%d", &N);
	rep(i, N) {
		double x1, y1, x2, y2, x3, y3, x4, y4;
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
		P a(x1, y1), b(x2, y2), c(x3, y3), d(x4, y4);
		printf("%s\n", (is_parallel(a, b ,c ,d)) ? "YES" : "NO");
	}
	return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int main() {
	string s;cin>>s;
	int l,r; char c;
	if(s.size()%2==0) {
		r=s.size()/2;
		c=s[s.size()/2-1];
	}
	else {
		r=s.size()/2+1;
		c=s[s.size()/2];
	}
	l=s.size()/2-1;
	while(c==s[l]&&c==s[r]&&l>=0&&r<=s.size()-1) {l--;r++;}
	cout<<r<<endl;
}


Measured memory_bytes: 1020
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define gpf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

char st[110000];
int len;

int main(){
	scanf("%s", st + 1);
	len = strlen(st + 1);
	int ans = 0;
	rep(i, 2, len) if (st[i] != st[i - 1]) ans++;
	printf("%d\n", ans);
	return 0;
}

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

// chmax, chmin
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

int main() {
  cout << setprecision(10);

  int N;
  cin >> N;
  map<string, int> cnt;
  int maxim = 0;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    cnt[s]++;
    chmax(maxim, cnt[s]);
  }
  for (auto data : cnt) {
    if (data.second == maxim) cout << data.first << endl;
  }

  return 0;
}


Measured memory_bytes: 25216
//AC
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
ll N = 2000001;
ll MIN = -1000000;
ll MAX = 1000000;


int main(){
    ll K,X;
    cin >> K >> X;
    if(X-K>=MIN){
        for(ll i=X-K+1;i<=X;i++){
            cout << i << ' ';
        }
    }else{
        for(ll i=MIN;i<=X;i++){
            cout << i << ' ';
        }
    }

    if(X+K<=MAX){
        for(ll i=X+1;i<=X+K-1;i++){
            cout << i << ' ';
        }
    }else{
        for(ll i=X+1;i<=MAX;i++){
            cout << i << ' ';
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}
//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

int main(){
    ll a,b,c,k,ans(0);
    cin >> a >> b >> c >> k;

    if(a>k){
        ans += k;
    }else{
        ans += a;
    }
    if((a+b)<=k){
        ans -= k-(a+b);
    }

    put(ans);
    return 0;
}

Measured memory_bytes: 3636
from operator import itemgetter
n = int(input())
rng = []
for i in range(n):
  x,l = map(int,input().split())
  rng.append([x-l,x+l])
rng.sort(key=itemgetter(1))
M = -10**9+1
ans = 0
for lst in rng:
  if lst[0] >= M:
    ans += 1
    M = lst[1]
print(ans)

Measured memory_bytes: 21308
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>
#include <fstream>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i, a, n) for(LL i = (a), i##_max = (n); i < i##_max; ++i)
#define REM(i, a, n) for(LL i = (LL)(n) - 1, i##min = (a); i >= i##min; --i)
#define ALL(arr) (arr).begin(), (arr).end()
#define FLOAT fixed << setprecision(16)
#define SPEEDUP {cin.tie(NULL); ios::sync_with_stdio(false);}
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const string INFSTR = "\x7f";
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template<class T>
T Compare(T left, T right) { return left > right ? 1 : (left < right ? -1 : 0); }
istream& Ignore(istream& ist) { string s; ist >> s; return ist; }
bool Inside(int i, int j, int h, int w) { return i >= 0 && i < h && j >= 0 && j < w; }
template <class T>
T Next() { T buf; cin >> buf; return buf; }

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "UnionFind.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "FlowSolver.h"
#include "Tree.h"
#include "SuffixArray.h"
#include "Matrix.h"
#include "SegmentTree.h"
#include "SegmentTree2D.h"
#include "BIT.h"
#include "Rational.h"
#include "Position.h"
#include "Factorization.h"
#include "Math.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

#if 1234567891
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;
// template <class T>
// auto Is(const T& value) { return [value](const auto& comparand) -> bool { return comparand == value; }; }
#endif
int main() {
	int n, k;
	cin >> n >> k;
	YESNO(n + 1 >= k * 2);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dp[300005];
int main()
{
    string s;
    int n;
    cin>>n;
    cin>>s;

    for(int i = 1; i<n; i++)
    {
        if(s[i]=='E')
            dp[0]++;
    }

    for ( int i = 1; i < n; i++)
    {
        if( s[i-1] != 'E' )
            dp[i]++;
        if( s[i] == 'E')
            dp[i]--;
        dp[i] += dp[i-1];
    }

    int ans = INT_MAX;
    for( int i = 0; i< n; i++)
    {
        ans =  min (dp[i],ans);
    }
    cout<<ans;
    return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define MAX_N 40001

using namespace std;

int N,a[MAX_N],b[MAX_N];

int main(){
  while(scanf("%d",&N),N){
    rep(i,N)scanf("%d",a+i);
    rep(i,N)scanf("%d",b+i);
    sort(a,a+N,greater<int>());
    sort(b,b+N,greater<int>());
    bool won = false;
    int cnt = 0,cur = 0;
    rep(i,N-1){
      if( a[i] <= b[cur] ) cnt++, cur++;
      if( (i+1)/2.0 < (i+1)-cnt ){
	won = true;
	cout << i+1 << endl;
	break;
      }
    }
    if(!won)cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 1540
# D
import math
X = int(input())

B = -math.floor(math.pow(X, 0.2))
for b in range(B, 100000):
    tmp = math.pow(X + b ** 5, 0.2)
    if math.floor(math.floor(tmp+1.0e-6) - tmp + 1.0e-6) == 0:
        break
        
tmp = math.floor(tmp + 1.0e-6)
print(tmp, b)

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

int main() {
  int n;
  cin >> n;
  int m;
  int s = 0;
  for (int i = 1; i <= n; ++i) {
    s += i;
    if (s >= n) {
      m = i;
      break;
    }
  }
  vector<int> solve;
  for (int i = m; i >= 1; --i) {
    if (i <= n) {
      n -= i;
      solve.push_back(i);
    }
  }
  rep(i, solve.size()) cout << solve[i] << endl;
  return 0;
}

Measured memory_bytes: 3688
import java.util.Scanner;

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

		long x = sc.nextLong();

		int ansa = 0;
		int ansb = 0;

		for (int i = -200; i < 201; i++) {
			for (int j = -200; j < 201; j++) {
				if (x == pow(i) - pow(j)) {
					ansa = i;
					ansb = j;
					break;
				}
			}
		}

		System.out.println(ansa + " " + ansb);
	}

	static long pow(int l) {
		long result = 1;
		for (int i = 0; i < 5; i++)
			result *= l;

		return result;
	}

}


Measured memory_bytes: 27296
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	int N;
	int A[10];
	cin>>N;
	rep(i,N)cin>>A[i];
	int ans=1,odd=1;
	rep(i,N){
		ans*=3;
		if(A[i]%2==0)odd*=2;
	}
	cout<<ans-odd<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#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 int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

const int INF = 1e18;
const int mod = 1e9 + 7;
const int N = 1e6 + 5;

int i, n, fact[N], ifact[N];

int pwr(int x, int y)
{
    int res = 1;
    x %= mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % mod;
        y >>= 1;
        x = (x * x) % mod;
    }
    return res;
}

int modinv(int n)
{
    return pwr(n, mod - 2);
}

int add(int a, int b)
{
    a %= mod, b %= mod;
    return a + b >= mod ? a + b - mod : a + b;
}

int mul(int a, int b)
{
    a %= mod, b %= mod;
    return (a * b) % mod;
}

int C(int n, int r)
{
    if (n < r || r < 0)
        return 0;
    return mul(fact[n], mul(ifact[r], ifact[n - r]));
}

int P(int n, int r)
{
    if (n < r || r < 0)
        return 0;
    return mul(fact[n], ifact[n - r]);
}

void precompute()
{
    fact[0] = 1;
    ifact[0] = 1;
    for (int i = 1; i < N; ++i)
    {
        fact[i] = mul(fact[i - 1], i);
        ifact[i] = mul(ifact[i - 1], modinv(i));
    }
}

void solve()
{
    precompute();
    cin >> n;
    int ans = pwr(10, n);
    ans -= pwr(9, n);
    ans += mod;
    ans %= mod;
    ans -= pwr(9, n);
    ans += mod;
    ans %= mod;
    ans += pwr(8, n);
    ans %= mod;
    cout << ans;
}

signed main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fastio;
    int t;
    //cin >> t;
    t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 19264
def main():
    N = int(input())
    nums_list = [list(map(int, input().split())) for _ in range(N)]
    nums_list.reverse()
    cnt = 0
    for a, b in nums_list:
        cnt += (b - (a + cnt)) % b
    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 27136
#include<iostream>
using namespace std;
int main(){
	int n;cin>>n;
	if(n<105)cout<<0<<endl;
	else if(n<135)cout<<1<<endl;
	else if(n<165)cout<<2<<endl;
	else if(n<189)cout<<3<<endl;
	else if(n<195)cout<<4<<endl;
	else cout<<5<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    static long pow(long a,int n) {
        long res=1;
        while (n>0) {
            if ((n-n/2*2)==1) {
                res=res*a;
            }
            a=a*a;
            n>>=1;
        }
        return res;
    }

    static long gcd(long a,long b) {
        long temp;
        while ((temp=a%b)!=0) {
            a=b;
            b=temp;
        }
        return b;
    }

    static long lcm(long a, long b) {
        return a*b/gcd(a, b);
    }

    static int f(int x) {
        int res = 0;
        while (x%2==0) {
            x/=2;
            res++;
        }
        return res;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[N];
        for (int i=0;i<N;i++) {
            a[i] = sc.nextInt();
            a[i]/=2;
        }

        int t = f(a[0]);
        for (int i=0;i<N;i++) {
            if (f(a[i]) != t) {
                System.out.println(0);
                return;
            }
            a[i]>>=t;
        }
        M>>=t;

        long l = 1;
        for (int i=0;i<N;i++) {
            l = lcm(l, a[i]);
            if (l>M) {
                System.out.println(0);
                return;
            }
        }

        M/=l;
        int ans = (M+1)/2;
        System.out.println(ans);
    }
}


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

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

res = []

for i in range(k):
    v = a + i
    if v <= b:
        res.append(v)

for i in range(k):
    v = b - i
    if v >= a and v not in res:
        res.append(v)

res.sort()

for row in res:
    print(row)


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

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
    #include "lib/dump.hpp"
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

signed main() {
    string s;cin>>s;
    if (s[0]=='7' || s[1]=='7' || s[2]=='7'){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>


int main(void) {
	int b, f, r, v;
	int i, j, k;
	int n;
	
	int a[4][3][10];
	
	for(i = 0; i < 4; i++) {
		for(j = 0; j < 3; j++) {
			for(k = 0; k < 10; k++) {
				a[i][j][k] = 0;
			}
		}
	}
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++) {
		scanf("%d %d %d %d", &b, &f, &r, &v);
		a[b-1][f-1][r-1] += v;
	}
	
	for(i = 0; i < 4; i++) {
		for(j = 0; j < 3; j++) {
			for(k = 0; k < 10; k++) {
				printf(" %d", a[i][j][k]);
			}
			printf("\n");
		}
		if(i != 3) {
			printf("####################\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){
  int n;
  vector<int> buttons;
  
  cin >> n;
  rep(i,n) {
	int a;
    cin >> a;
    buttons.push_back(--a);
  }
  
  int current = 0;
  int next = -1;
  rep(i,n) {
    next = buttons[current];
    if (next == 1) {
		cout << i+1 << endl;
      return 0;
    }
    current = next;
  }
  cout << "-1" << endl;
  return 0;
}

Measured memory_bytes: 3904
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] ss = new int[k];

        for (int i = 1; i <= n; i++)
            ss[i % k]++;
        long res = 0;
        for (int a = 0; a < k; ++a) {
            int b = (k - a) % k;
            int c = (k - a) % k;
            if ((b + c) % k != 0)
                continue;
            res += (long) ss[a] * ss[b] * ss[c];
        }
        System.out.println(res);
    }

}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b;
    cin >> a >> b;
    int dig = 1;
    int sum = b;
    while( dig <= b ) dig *= 10;

    while( a > 0 ) {
        sum += (a % 10) * dig;
        a /= 10;
        dig *= 10;
    }

    bool flg = false;
    int i = 1;
    while( i * i < sum ) {
        ++i;
    }

    if( i * i == sum ) flg = true;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int N;
int x[10], y[10];
 
double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}
 
void solve() {
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> x[i] >> y[i];
    double sum = 0.0;
    vector<int> v(N);
    for(int i = 0; i < N; i++) v[i] = i + 1;
    do {
        for(int i = 0; i < N - 1; i++) sum += dist(v[i], v[i+1]);
    } while(next_permutation(v.begin(), v.end()));
    int Factorial = 1;
    for(int i = 2; i <= N; i++) Factorial *= i;
    cout << fixed << setprecision(10) << sum / Factorial << endl;
    return;
}
 
int main() {
    solve();
    return 0;
}


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

int main(){
  string a, b;
  cin >> a >> b;
  int ans=0;
  if(a.at(0)==b.at(0)) ans++;
  if(a.at(1)==b.at(1)) ans++;
  if(a.at(2)==b.at(2)) ans++;
  cout<< ans << endl;
  //cout << (c - (a-b))<0 ? 0 : b+c-a << endl;
  //else cout << b << endl;

  return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  string s;
  for(int i = 0; i < 3; ++i){
    char c; cin >> c;
    s.push_back(c);
  }
  cout << (stoi(s)%4==0 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int a;
  cin >> a;
  if(a == 3 ||a == 5|| a==7){
    puts("YES");
  }else{
    puts("NO");
  }

}


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

int main() {
	ll a;
	long double b;
	cin >> a >> b;
	ll ans = a * b;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
int n,m;
vector<int> E[maxn],ans;
int vis[maxn];
int ind[maxn];

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n>>m;
    rep(i,1,m){
        int x,y;
        cin>>x>>y;
        E[x].push_back(y);
        ind[y]++;
    }
    queue<int> Q;
    rep(i,0,n-1)if(!ind[i])Q.push(i);
    while(!Q.empty()){
        int now=Q.front();Q.pop();
        vis[now]=1;
        ans.push_back(now);
        for(auto t:E[now]){
            if(vis[t])continue;
            ind[t]--;
            if(ind[t]==0)Q.push(t);
        }
    }
    for(auto t:ans)cout<<t<<endl;
    //cout<<endl;
}
/* 
6 6
0 1
1 2
3 1
3 4
4 5
5 2
 */


Measured memory_bytes: 27212
#include<iostream>
#include<string>
using namespace std;
int main(){
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    int dx=tx-sx,dy=ty-sy;
    cout << string(dy,'U') << string(dx,'R');
    cout << string(dy,'D') << string(dx,'L');
    cout << 'L' << string(dy+1,'U') << string(dx+1,'R') << 'D';
    cout << 'R' << string(dy+1,'D') << string(dx+1,'L') << 'U';
    cout << endl;
    return 0;
}

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

static const int INF = 1001001001;

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

    int sum = a + b;
    int gap = a - b;
    int product = a * b;

    int max = -1 * INF;
    if(max < sum)       max = sum;
    if(max < gap)       max = gap;
    if(max < product)   max = product;

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) {
        cin >> A.at(i);
    }

        int B = 0;
        for (int i = 0; i < N; i++) {
            B ^= A[i];
        }
        rep(i, N) {
            cout << (B ^ A[i]) << " ";
        }
    cout << endl;
}


Measured memory_bytes: 3980
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=155;
int read(){
    int f=1,g=0;char ch=getchar();
    for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
    for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
    return f*g;
}
int K,n,p;
void check(int &x,int y){if ((x+=y)>=p) x-=p;}
void solve1(){
	static int f[N][N];
	f[0][0]=1;K/=2;
	for (int i=1;i<=n;i++)
	for (int j=0;j<=K;j++){
		check(f[i][0],f[i-1][j]);
		if (j!=K) check(f[i][j+1],f[i-1][j]);
	}
	int x=0,y=0;
	for (int i=0;i<=K;i++)
	check(x,f[n/2][i]),check(y,f[n-n/2][i]);
	printf("%lld\n",(ll)x*y%p);
}
void solve2(){
	static int f[N][N][N];
	int i;f[0][0][0]=1;
	for (i=1;i*2-K<=n;i++){
		for (int j=0;j<=K+1;j++)
		for (int k=0;k<=i;k++)
		check(f[i][0][0],f[i-1][j][k]);
		if (i*2<=n)
			for (int j=0;j<=K+1;j++)
			for (int k=0;k<=i;k++)
			check(f[i][0][k+1],f[i-1][j][k]);
		if (i*2-K>0){
			for (int j=1;j<=K;j++)
			for (int k=0;k<=i;k++)
			check(f[i][j+1][0],f[i-1][j][k]);
			for (int k=0;k<=i;k++) check(f[i][0][0],f[i-1][0][k]);
		}
		if ((i*2<=n)&&(i*2-K>0)){
			for (int j=0;j<=K;j++)
			for (int k=0;k+1<=K;k++)
			check(f[i][max(j+1,k+2)][k+1],f[i-1][j][k]);
		}
	}
	i--;
	int ans=0;
	for (int j=0;j<=K+1;j++)
	for (int k=0;k<=i;k++)
	check(ans,f[i][j][k]);
	printf("%d\n",ans);
}
int main(){
	n=read();K=read();p=read();
	if (K&1) solve2();
	else solve1();
	return 0;
}


Measured memory_bytes: 12672
N,K=map(int,input().split())
#A=list(map(int,input().split()))
S=list(input())


from itertools import groupby

#ans=0

gs=[len(list(group)) for key,group in groupby(S)]
now_ans = N-len(gs)
add_ans = now_ans + 2*K

ans=min(add_ans,N-1)




print(str(ans))

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

using namespace std;

int main(){
  long long int N,j;
  cin >> N;
  long long int ans = N;
  for(long long int i = 1; i <= pow((double)N,0.5); i++){
    if(N % i == 0){
      j = N / i;
      if(ans > i + j - 2){
        ans = i + j - 2;
      }
    } 
  }

  cout << ans << endl;

  return 0;
}





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

#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

string m;

char rev(char x){
  if(x==m[0])return m[1];
  else return m[0];
}

int main(){
  m={"HD"};
  char c[2];
  cin>>c[0]>>c[1];
  if(c[0]=='D')cout<<rev(c[1]);
  else{cout<<c[1];}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
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;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int n;
    cin >> n;
    cout << (n - 1) * n / 2 << 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 N, ans;
  ans = 0;
  cin >> N;
  int A[N];
  rep (i, N) cin >> A[i];
  sort(A, A + N);	
  for (int i = 0; i < N-1; ++i) {
    if (A[i] == A[i+1]) {
      ++ans;
      break;
    }
  }
  if (ans == 0) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 1024
N = int(input())
T,A = map(int,input().split())
T2 = 10**9
H = list(map(int,input().split()))
for i in range(N):
    tmp = abs(A - (T - (H[i] * 0.006)))
    if(T2 >= tmp):
        ans = i + 1
        T2 = tmp
print(str(ans))

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=(n)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1e9+7

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main(){
   
    int n,k;cin>>n>>k;
    vi h(n);rep(i,n)cin>>h[i]; 
    
    vi dp(n,INT32_MAX);
    dp[0]=0;

    rep(i,n-1){
        repa(j,1,min(k+1,n-i)){
            dp[i+j] = min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
        }
    }

    cout << dp[n-1] << endl;
    
    return 0;
}

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

int main() {
    string s, t; cin >> s>> t;
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());

    bool is_true = false;
    for (int i = 0; i < min(s.size(), t.size()); i++) {
        if (s.at(i) < t.at(i)) {
            puts("Yes");
            return 0;
        }
        if (s.at(i) > t.at(i)) {
            puts("No");
            return 0;
        }
    }

    if (s.size() < t.size())
        puts("Yes");
    else
        puts("No");
}

Measured memory_bytes: 256
s = input()
ans = 0
tmpans = 0
for i in range(len(s)):
    if s[i] == "A" or s[i] == "T" or s[i] == "C" or s[i] == "G":
        tmpans += 1
    else:
        ans = max(ans,tmpans)
        tmpans = 0
ans = max(ans,tmpans)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <numeric>
using namespace std;
 
#define LOCAL  1
#define UPLOAD 2
 
#define ll long long
const long long INF = 1LL << 60;
 
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';
#define REP(i,M) for(int i=0;i<M;i++)
 
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

  auto isKaibun = [](string s){
    for(int i=0;i<s.size();i++){
      if(s[i] != s[s.size()-i - 1]){
        return false;
      }
    }
    return true;
  };

  string s = input<string>();
  string s2 = s.substr(0,(s.size()-1)/2);
  string s3 = s.substr((s.size()+3)/2-1, s.size());
  if(isKaibun(s) && isKaibun(s2) && isKaibun(s3)){
    output("Yes");
  }
  else{
    output("No");
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[3];
		int max = 0;
		int sum = 0;
		for (int i = 0; i < 3; i++) {
			a[i] = sc.nextInt();
			sum += a[i];
			max = Math.max(max, a[i]);
		}
		int money = sum + max * 9;
		System.out.println(money);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
const int INF = 100000000;
int dx[] = {0,1,-1,0,1,-1,1,-1};
int dy[] = {1,0,0,-1,1,-1,-1,1};

int main(){
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << (H - h) * (W - w) << endl;
}


Measured memory_bytes: 256
n = int(input())
a = [int(input()) for _ in range(n)]
pos = 1
cnt = 0
passed = [0]*(n+1)
TF = True
while TF:
  pos -= 1
  temp = a[pos]
  if passed[temp] == 1:
    TF = False
    print(-1)
  elif temp == 2:
    print(cnt+1)
    TF = False
  else:
    passed[temp] = 1
    pos = temp
    cnt += 1

Measured memory_bytes: 7852
import sys
readline=sys.stdin.readline

import numpy as np

N,K=map(int,readline().split())
A=np.array(readline().split(),dtype=int)

nega_list=A[A<0]
posi_list=A[A>0]
zero_num=A[A==0].size

nega_list=np.sort(nega_list)
posi_list=np.sort(posi_list)

nega_cnt=nega_list.size * posi_list.size
posi_cnt=((posi_list.size * posi_list.size-1) // 2) + ((nega_list.size * nega_list.size-1) // 2)

zero_cnt=(zero_num * (zero_num-1)) // 2 + zero_num * (nega_list.size + posi_list.size)

# Kがどこに属するかを判断
if K <= nega_cnt:
  # 負の数が答え
  # かけてX以下になる組み合わせをK個以上作れればOK
  
  def isOkNega(x):
    return np.searchsorted(nega_list,x//posi_list,side="right").sum() >= K
    
  ok=0
  ng=-10**18-1
  while (ok-ng)>1:
    mid=(ok+ng)//2
    if isOkNega(mid):
      ok=mid
    else:
      ng=mid
  print(ok)
  
elif K <= nega_cnt+zero_cnt:
  # 0が答え
  print(0)
  
else:  
  # 正の数が答え
  K-=(nega_cnt+zero_cnt)
  # 正のグループ内の積、負のグループ内の積、それぞれを合わせてX以下の数をK個以上作れる
  
  # 負の数リストは、掛け合わせた絶対値が小さいものを求める必要があるため、正のリストに変更
  nega_list = np.flipud(nega_list * (-1))
  
  # 自分自身との積は除外する必要があるため、自分同士の積リストを作成
  self_nega=nega_list * nega_list
  self_posi=posi_list * posi_list
  
  def isOkPosi(x):
    # 重複を考えずに、負の数同士の積で条件を満たすものをカウント
    nega_all = np.searchsorted(nega_list, x // nega_list, side = "right")
    
    # 自分自身を掛け合わせたもので、条件を満たすものの個数はカウントから除外する必要がある
    nega_cnt = nega_all.sum() - self_nega[self_nega <= x].size
    
    # 同じペアを二回数えているため1/2する
    nega_cnt //= 2
    
    # 正の数リストで同じことをする
    posi_all = np.searchsorted(posi_list, x // posi_list, side = "right")
    posi_cnt = posi_all.sum() - self_posi[self_posi <= x].size
    posi_cnt //= 2
        
    return nega_cnt + posi_cnt >= K
  
  ok=10**18+1
  ng=0
  while abs(ok-ng)>1:
    mid=abs(ok+ng)//2
    if isOkPosi(mid):
      ok=mid
    else:
      ng=mid
  print(ok)


Measured memory_bytes: 34628
// https://atcoder.jp/contests/abc066/tasks/abc066_a

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  int p[3];

  cin >> p[0] >> p[1] >> p[2];

  sort(p, p + 3);

  cout << p[0] + p[1] << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define md %998244353
#define INF 2e9
#define EPS 1e-9
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define endl "\n"
#define FOR(i,a,b) for (long long i = a; i < b; i++)
#define REV(i,a,b) for (long long i = a; i > b; i--)
#define mset(a, v) memset(a, v, sizeof(a))
#define fd(n) fixed<<setprecision(n)
typedef std::pair<int, int> pii;
typedef std::vector<long long> vi;
typedef std::vector<vi> vvi;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

ll solve(ll x,ull y,ll p) {
    ll res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
   
   ll i,j,n,k=0,x,y;
   cin>>n>>x>>y;
    
    ll v[n+1]={0};
    
    for(i=1;i<=n;i++)
    {	  
    for(j=1+i;j<=n;j++)
     {
     	k=  min((j-i),abs(x-i)+abs(y-j) + 1);
     	v[k]++;
	 }  
    }
    
    
    for(i=1;i<n;i++)
      cout<<v[i]<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
int gcd(int x,int y){
    if(x<y){
        swap(x,y);
    }
    while(y>0){
        int r=x%y;
        x=y;
        y=r;
    }
    return x;
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y;
    cin>>x>>y;
    int ans=gcd(x,y);
    cout<<ans<<'\n';
    return(0);
}


Measured memory_bytes: 3204
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextInt()){
            int d=sc.nextInt();
            int ans=0;
            for(int i=1;i*d<600;i++){
                ans+=i*i*d*d*d;
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 17184