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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    int N = input();
    auto a = make_vector(N, N, 0);
    cin >> a;
    
    auto dp = make_vector(1 << N, -1);

    function< int(int, int) > dfs = [&](int p, int bit) {
        if (bit + 1 == (1 << N)) return 1;
        if (p == N) return 0;
        
        int &res = dp[bit];
        if (~res) return res;
        res = 0;
        
        range(i, 0, N) {
            if ((1 << i) & bit || !a[p][i]) continue;
            (res += dfs(p + 1, bit | 1 << i)) %= mod;
        }
        
        return res;
    };
    
    cout << dfs(0, 0) << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 8448
//coded by: pranonrahman-------------------------------------
//-----------------------------------------------------------
//-----------------------------------------------------------
#include<bits/stdc++.h>
using namespace std;
#define O_o ios_base::sync_with_stdio(0)
#define O_O ios_base::sync_with_stdio(0); cin.tie(NULL)
#define o_O ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define fixedprecision(n) cout<<fixed<<setprecision(n)
#define endl '\n'
#define CASE(n) cout << "Case " << n << ": "
#define pi acos(-1.0)
#define _____(n) cout << "Dhukse " << n << endl
int main()
{
    O_o;
    long long t=1;
    //cin >> t;
    long long T=t;
    while(t--)
    {
        long long n,m;
        cin >> n >> m;
        map<long long,long long>mp;
        map<long long,long long>m2;
        long long ac=0,tp=0;
        for(int i=0;i<m;i++)
        {
            string s;
            long long x;
            cin>> x >> s;
            if(s=="AC" and m2[x]==0)
            {
                ac++;
                tp+= mp[x];
                m2[x]=1;
            }
            else
            {
                mp[x]++;
            }
        }
        cout << ac << ' ' << tp << endl;
    }
    return 0;
}



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

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, M: int):
    return YES if N == M else NO


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import lru_cache, reduce
from math import gcd
from operator import add, itemgetter, mul, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

a, b = list(map(int, sys.stdin.buffer.readline().split()))
print( a * b)


Measured memory_bytes: 27228
#include<bits/stdc++.h>
using namespace std;
int b[100000];
int main()
{
    int n;
    cin>>n;
    long long int a[n+5];
    for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
    sort(a,a+n);
    int j=0;
    for(int i=1;i<n;i++)
     {
         if(a[i]==a[i-1])
            {
                b[j]=a[i];
                i++;
                j++;
            }
     }
    if(j>=2)
    {
    long long int x=b[j-1],y=b[j-2];
    cout<<x*y<<endl;
    }
    else
    cout<<0<<endl;
}


Measured memory_bytes: 4580
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

bool match(string S, string T)
{
    vector<bool> b(S.size());
    for (int i = 0; i < S.size(); i++) {
        if (b[i]) continue;
        char c1 = S[i], c2 = T[i];
        for (int j = i + 1; j < S.size(); j++) {
            if (S[j] == c1) {
                b[j] = true;
                if (T[j] != c2) return false;
            }
        }
    }
    return true;
}

int main()
{
    string S, T;
    cin >> S >> T;
    bool answer = match(S, T) && match(T, S);
    cout << (answer ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 1544
#include<iostream>
#include<cstdio>
using namespace std;
int n,k;
long long sum[101000],sum2[101000],a[101000],ans=0;
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++){
		sum[i]=sum[i-1]+a[i];
		sum2[i]=sum2[i-1];
		if(a[i]>0)sum2[i]+=a[i];
	}
	for(int i=1;i<=n-k+1;i++){
		ans=max(ans,sum2[n]-(sum2[i+k-1]-sum2[i-1])+(sum[i+k-1]-sum[i-1]));
		ans=max(ans,sum2[n]-(sum2[i+k-1]-sum2[i-1]));
	}
	printf("%lld",ans);
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define strall(v) (v).cbegin(),(v).cend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
//const long long INF = 1LL << 60;
 int INF = 500000;
 int MAX = 1e5+10;
 ll mod = 1e9+7;


int main(){
  int n,d;
  cin >> n >> d;
  int b = 2*d+1;
  int ans = (n+b-1)/b;
  cout << ans << endl;
}

Measured memory_bytes: 256
module S = Set.Make (struct type t = string let compare = compare end) ;;

Scanf.scanf "%s" (fun s ->
    let n = String.length s in
    let replace s i a b =
        let c = char_of_int (294 - int_of_char a - int_of_char b) in
        String.init n (fun j -> if j = i || j = i + 1 then c else s.[j])
    in
    let rec dfs s set =
        let rec loop i set =
            if i = n - 1 then set else
            if s.[i] = s.[i + 1] then loop (i + 1) set else (
                let s2 = replace s i s.[i] s.[i + 1] in
                let set = if S.mem s2 set then set else dfs s2 (S.add s2 set) in
                loop (i + 1) set
            )
        in
        loop 0 set
    in
    let streak s =
        let rec loop i =
            if i = n - 1 then true else
                if s.[i] = s.[i + 1] then loop (i + 1) else false
        in
        loop 0
    in
    let nondup s =
        let rec loop i =
            if i = n - 1 then 1 else
                if s.[i] = s.[i + 1] then 0 else loop (i + 1)
        in
        loop 0
    in
    let sum s =
        let rec loop i acc =
            if i = n then acc else loop (i + 1) (acc + int_of_char s.[i] - 97)
        in
        loop 0 0
    in

    let m = 998244353 in
    let ( +@) a b = (a + b) mod m in
    let ( -@) a b = (((a - b) mod m) + m) mod m in
    let ( *@) a b = (a * b) mod m in

    let pow a b =
        let rec loop r b acc =
            if b = 0 then acc else
                loop (r *@ r) (b lsr 1) (if b land 1 = 0 then acc else acc *@ r)
        in
        loop a b 1
    in
    let solve s =
        let adjust v =
            if n mod 3 <> 0 then v else (
                if sum s mod 3 = 0 then v -@ pow 2 (n / 3) else v +@ pow 2 (n / 3 - 1)
            )
        in
        let rec loop i dp1 dp2 =
            if i = n then adjust dp1 else
                loop (i + 1) (dp1 *@ 3 +@ dp2) (dp2 *@ 2)
        in
        if streak s then 1 else loop 1 0 1 +@ nondup s
    in
    Printf.printf "%d\n" @@ if n <= 3 then S.cardinal (dfs s (S.singleton s)) else solve s
)

Measured memory_bytes: 3200
/* DSL1_A: Disjoint Set */

#include <iostream>

int *parents;
int *ranks;

int find(int x) {
    if (parents[x] == x)
        return x;
    else
        return parents[x] = find( parents[x] );
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if ( ranks[x] < ranks[y] ) {
        parents[x] = y;
    }
    else if ( ranks[y] < ranks[x] ) {
        parents[y] = x;
    }
    else if (x != y) {
        parents[x] = y;
        ranks[y] += 1;
    }
}

int main() {
    std::ios::sync_with_stdio(false);

    int n, q;
    std::cin >> n >> q;

    parents = new int[n];
    ranks   = new int[n];
    for (int i = 0; i < n; i++) {
        parents[i] = i;
        ranks[i]   = 0;
    }

    int command, x, y;
    for (int i = 0; i < q; i++) {
        std::cin >> command >> x >> y;
        switch (command) {
            case 0:
                unite(x, y);
                break;
            case 1:
                bool same = find(x) == find(y);
                std::cout << ( same ? 1 : 0 ) << "\n";
                break;
        }
    }

    return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;
int main(int argc, char const *argv[]) {
  string s;std::cin >> s;
  re(i, s.size()-1){
    if(s[i]=='A'&&s[i+1]=='C') {
      std::cout << "Yes" << '\n';
      return 0;
    }
  }
  std::cout << "No" << '\n';
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long mod(long long a)
{
    if(a<0)
        return a*-1;
    else
        return a;
}
int main()
{
    long long a,b,c,m1,m2;
    cin>>a>>b;
    c=(a+b)/2;
    m1=mod(a-c);
    m2=mod(b-c);
    if(m1==m2)
        cout<<c;
    else
        cout<<"IMPOSSIBLE";
    return 0;
}



Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<bool> vb;
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;}
int const INF = 1 << 30;

template<int MOD> struct Fp {
long long val;
constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
if (val < 0) val += MOD;
}
constexpr int getmod() { return MOD; }
constexpr Fp operator - () const noexcept {
return val ? MOD - val : 0;
}
constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
constexpr Fp& operator += (const Fp& r) noexcept {
val += r.val;
if (val >= MOD) val -= MOD;
return *this;
}
constexpr Fp& operator -= (const Fp& r) noexcept {
val -= r.val;
if (val < 0) val += MOD;
return *this;
}
constexpr Fp& operator *= (const Fp& r) noexcept {
val = val * r.val % MOD;
return *this;
}
constexpr Fp& operator /= (const Fp& r) noexcept {
long long a = r.val, b = MOD, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b; swap(a, b);
u -= t * v; swap(u, v);
}
val = val * u % MOD;
if (val < 0) val += MOD;
return *this;
}
constexpr bool operator == (const Fp& r) const noexcept {
return this->val == r.val;
}
constexpr bool operator != (const Fp& r) const noexcept {
return this->val != r.val;
}
friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
return os << x.val;
}
friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
if (n == 0) return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1) t = t * a;
return t;
}
};

const int MOD = 1000000007;
using mint = Fp<MOD>;

mint com(long long n, long long r) {
mint res = 1;
for (long long i = 0; i < r; ++i) {
res *= (n-i);
res /= (i+1);
}
return res;
}

void err() {
    cout << 0 << endl;
    exit(0);
}

int main() {
    int n;
    cin >> n;
    vector<int> Tmin(n,1),Tmax(n,INF);
    vector<int> Amin(n,1),Amax(n,INF);
    rep(i,n) cin >> Tmax[i];
    rep(i,n) cin >> Amax[i];

    int cur = -INF;
    rep(i,n) if(chmax(cur,Tmax[i])) Tmin[i] = Tmax[i];

    cur = -INF;
    drep(i,n) if(chmax(cur,Amax[i])) Amin[i] = Amax[i];

    mint res = 1;
    rep(i,n) {
        if(Tmax[i] < Amin[i] || Amax[i] < Tmin[i]) err();
        int s = max(Tmin[i],Amin[i]);
        int t = min(Tmax[i],Amax[i]);
        res *= (t-s+1);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 5156
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int ans = 0;
            int n = in.nextInt();
            int[] a = new int[n];
            int[] c = new int[n - 1];

            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            for (int i = 0; i < n; i++) {
                ans += in.nextInt();
            }

            for (int i = 0; i < n - 1; i++) {
                c[i] = in.nextInt();
            }

            for (int i = 1; i < n; i++) {
                if (a[i] - a[i - 1] == 1) {
                    ans += c[a[i - 1] - 1];
                }
            }

            System.out.println(ans);
        }
    }
}


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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);


int main(void)
{
    ll n,ans=INF; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll mini=*min_element(all(a)),maxi=*max_element(all(a));
    for(int i=mini;i<=maxi;i++){
        ll tmp=0;
        rep(j,n){
            tmp += (a[j]-i)*(a[j]-i);
        }
        ans = min(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3608
n = int(input())
a = list(map(int, input().split()))

q = int(input())

cnt = [0] * 100001

sum = 0
for i in a:
	cnt[i] += 1
	sum += i

while q:
	b, c = map(int, input().split())
	sum += (c - b) * cnt[b]
	cnt[c] += cnt[b]
	cnt[b] = 0
	q -= 1
	print(sum)


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

int main()
{
  int sum = 0;
  string s;
  cin >> s;
  for(int i = 0; i < 4; ++i) {
    if(s[i] == '+') sum++;
    else sum -= 1;
  }
  
  cout << sum;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll (i) = (s); (i) < (x); (i) ++)
#define REP(i, x) PREP(i, 0, x)
#define MREP(i, s, x) for(ll (i) = (s); (i) >= (x); (i) --)
#define IREP(i) for(ll (i) = 0; ; (i) ++)
#define MOD (1000000007LL)
#define INF (1LL<<60)
typedef long long ll;
using namespace std;
using graph = vector<vector<ll>>;
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; }

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N, W;
    cin >> N >> W;
    vector<ll> v(N), w(N);
    REP(i, N){
        cin >> v[i] >> w[i];
    }

    vector<vector<ll>> dp(N+100, vector<ll>(W+100, 0));
    // dp[rows][cols] == value;

    PREP(i, 1, N+1){
        PREP(j, 0, W+1){
            chmax(dp[i][j], dp[i-1][j]);
            if(j - w[i-1] >= 0){
                chmax(dp[i][j], dp[i-1][j - w[i-1]] + v[i-1]);
            }
        }
    }

    cout << dp[N][W] << endl;
    return 0;
}


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

int main()
{
    int k = 0;
    std::cin >> k;

    std::string s;
    std::cin >> s;

    if (s.size() > k)
    {
        std::cout << s.substr(0, k) << "...";
    }
    else
    {
        std::cout << s;
    }
}

Measured memory_bytes: 3620
import java.util.*;
import java.io.*;
 
public class Main{
  public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
String str = br.readLine();
                    String[] strs = str.split("\\s");
                    int r = Integer.parseInt(strs[0]);
                    int c = Integer.parseInt(strs[1]);
                    int[][] graph = new int[r+1][c+1];
                    int lastnum = 0;
 
                    for(int i = 0;i<r;i++){
                        str = br.readLine();
                        String[] temp = str.split("\\s");
                        int total =0;
 
                        for(int j =0;j<c;j++){
                            int tempnum = Integer.parseInt(temp[j]);
                            total += tempnum;
                            graph[i][j] = tempnum;
 
                            if(i == 0){
                                graph[r][j]= tempnum;
                            }else{
                                int tempnum2 = graph[r][j];
                                tempnum2 += tempnum;
                                graph[r][j]=tempnum2;
                            }
                        }
                        graph[i][c] = total;
                        lastnum += total;
                    }
                    br.close();
                    graph[r][c] = lastnum;
                     
                    for(int i =0;i<r+1;i++){
                        StringBuilder sb = new StringBuilder();
                        for(int j=0;j<c+1;j++){
                            String ts = String.valueOf(graph[i][j]);
                            sb.append(ts);
                            
                             if(j != c){
                            sb.append(" ");
                            }
                        }
                        System.out.println(new String(sb));
 
                    }
 
 
}
}

Measured memory_bytes: 29512
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

template <class T> void max_swap(T& a, const T b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int w, h;
	while (scanf("%d%d", &w, &h), w | h)
	{
		const int mod = 100000;
		int north[128][128], east[128][128];
		memset(north, 0, sizeof(north));
		memset(east, 0, sizeof(east));
		north[1][0] = east[0][1] = 1;
		for (int i = 0; i < h; ++i)
		{
			for (int j = 0; j < w; ++j)
			{
				north[i][j] %= mod;
				east[i][j] %= mod;

				if (i == h - 1 && j == w - 1)
					continue;

				north[i + 1][j] += north[i][j];
				east[i][j + 2] += north[i][j];
				east[i][j + 1] += east[i][j];
				north[i + 2][j] += east[i][j];
			}
		}
		int res = north[h - 1][w - 1] + east[h - 1][w - 1]
		 + north[h][w - 1] + east[h - 1][w];
		printf("%d\n", res % mod);
	}
}

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

#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, m, x;
    cin >> n >> m >> x;

    if (n < m)
        swap(n, m);

    cout << (x + n - 1) / n;

    return 0;
}   

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	ll m;

	cin >> m;

	cout << 24 * 2 - m << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

void view(int a[], int n){
	int i;
	for(i=0;i<n-1;i++) printf("%d ",a[i]);
	printf("%d\n",a[n-1]);
}

void bubbleSort(int a[], int n){
	int j,temp,flag=1,count=0;
	while(flag==1){
		flag = 0;
		for(j=n-1;j>0;j--){
			if(a[j]<a[j-1]){
				temp = a[j];
				a[j] = a[j-1];
				a[j-1] = temp;
				flag = 1;
				count++;
			}
		}
	}
	view(a,n);
	printf("%d\n",count);
}

int main(void){
	int i,a[100],n;

	scanf("%d\n",&n);
	for(i=0;i<n;i++) scanf("%d",&a[i]);
	bubbleSort(a,n);

	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
typedef     unsigned long long  ull;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll> >      vpll;
typedef		vector<ll>      vll;
typedef		map<string,ll>      msl;
typedef		map<ll,ll>      mll;
#define yes cout << "YES\n"
#define no cout<<"NO\n"
//#define sort(x) sort(x.begin(), x.end())
//sort(a,a+n,greater<ll>())
//for (auto it = mp.begin(); it != mp.end(); ++it){}
#define MAX 1000005
#define mod 1000000007



int main()
{
 //O_O ;
   ll n;
   cin>>n;ll ans,p=0;
   for(ll i=-2000;i<=2000;i++)
   {
       ans=i*i*i*i*i;
       //cout<<ans<<nn;
       if(p==1)
        break;
       for(ll j=-2000;j<=2000;j++){

       if(ans-j*j*j*j*j==n)
       {
           cout<<i<<ss<<j<<nn;
           p=1;
           break;
        }

    }

}


    return 0;
}


Measured memory_bytes: 3564
def f(a,b,c):
    if a==b or b==c or c==a:
        return False
    if a+b>c and b+c>a and c+a>b:
        return True
    else:
        return False
from itertools import combinations
n=int(input())
l=[int(i) for i in input().split()]
ans=0
for a,b,c in combinations(l,3):
    if f(a,b,c):
        ans+=1
print(ans)

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N, M;
    cin >> N >> M;
    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }
    int mod = 1e9 + 7;
    vector<vector<int>> dp(N, vector<int>(M));
    dp[0][0] = 1;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if (S[i][j] == '#') continue;
            if (i + 1 < N && S[i + 1][j] != '#') {
                dp[i + 1][j] += dp[i][j];
                dp[i + 1][j] %= mod;
            }
            if (j + 1 < M && S[i][j + 1] != '#') {
                dp[i][j + 1] += dp[i][j];
                dp[i][j + 1] %= mod;
            }
        }
    }

    cout << dp[N - 1][M - 1] << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

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

using ll = long long;

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

   map<ll, ll> mp;
   for (int i = 0; i < N; i++) {
      ll a;
      cin >> a;
      mp[a]++;
   }

   vector<ll> v;
   for (auto &x : mp) {
      while (x.second > 0) {
         x.second /= 2;
         if (x.second > 0) v.push_back(x.first);
      }
   }

   sort(v.begin(), v.end(), greater<ll>());

   if (v.size() >= 2) {
      cout << v[0] * v[1] << endl;
   } else {
      cout << 0 << endl;
   }

   return 0;
}

Measured memory_bytes: 6528
#include<stdio.h>

int main(void){
    int N=0;
    int x[201]={0};
    int y[201]={0};
    int maxup=0,maxdown=0,maxright=0,maxleft=0;
    int n=0,d=0;
    int answerx[10000];
    int answery[10000];
    int count=0;
    while(1){
        maxup=0,maxdown=0,maxright=0,maxleft=0;
        scanf("%d",&N);
        if(N==0){
            break;
        }
        for(int i=1;i<N;i++){
            scanf("%d %d",&n,&d);
            if(d==0){
                x[i]=x[n]-1;
                y[i]=y[n];
            }
            else if(d==1){
                x[i]=x[n];
                y[i]=y[n]-1;
            }
            else if(d==2){
                x[i]=x[n]+1;
                y[i]=y[n];
            }
            else if(d==3){
                x[i]=x[n];
                y[i]=y[n]+1;
            }
        }
        for(int i=0;i<N;i++){
            if(x[i]>maxright){
                maxright=x[i];
            }
            if(x[i]<maxleft){
                maxleft=x[i];
            }
            if(y[i]>maxup){
                maxup=y[i];
            }
            if(y[i]<maxdown){
                maxdown=y[i];
            }
        }
        maxdown*=-1;
        maxleft*=-1;
        answerx[count]=maxleft+maxright;
        answery[count]=maxup+maxdown;
        count++;
    }
    for(int i=0;i<count;i++){
        printf("%d %d\n",answerx[i]+1,answery[i]+1);
    }
    return 0;
}


Measured memory_bytes: 2104
package main
 
import (
	"bufio"
	"os"
	"sort"
	"strconv"
	"fmt"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func scanInt() int {
	iv, _ := strconv.Atoi(scanString())
	return iv
}
 
func scanString() string {
	sc.Scan()
	return sc.Text()
}
 
func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 100001), 100001*100)
}

func calcmax(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func main() {
	var N, K, A, ANS int
	N = scanInt()
	K = scanInt()
	l := make([]int, N)
	max := 0
	for i := 0; i < N; i++ {
		A = scanInt()
		l[i] = A
		max = calcmax(max, A)
	}

	sort.Slice(l, func(i, j int) bool { return l[i] > l[j] })
	length := len(l)
	l = l[hissatsu(K, length):length]
	for _, v := range l {
		ANS += v
	}
	fmt.Println(ANS)
}

func hissatsu(n, length int) int {
	if n < length {
		return n
	} else {
		return length
	}
}


Measured memory_bytes: 5988
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define line cout<<"\n"
#define ci std ::cin
#define co std ::cout
#define sf scanf
#define sff(n,m) scanf("%d%d",&n,&m)
#define pf printf
#define p_line printf("\n")
#define cas(n) printf("Case %d: ",n++)
#define task return
#define loop(x,n)  for(int x = 0 ; x < n ; x++)
#define constloop(x,a,n) for(int x = a ; x < n ; x++)
#define revloop(x,a,n)  for(int x = a ; x >= n ; x--)
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pi acos(-1)
#define mx 10000000
/*ll P[mx+5],cnt=1;
bool nP[mx+5];
void sieve(void)
{
    P[0]=2;
    nP[0]=true;
    nP[1]=true;
    for(ll i=3 ; i<=mx ; i+=2)
    {
        if(nP[i]==true)
            continue;
        for(ll j=i+i ; j<=mx ; j+=i)
            nP[j]=true;
        P[cnt++]=i;
    }
}*/
void solve()
{
    //Code here
 	int x;
 	ci>>x;
 	co<<1-x;
 	line;
}
int main()
{
	/*freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);*/
	/*ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);*/
	solve();
	return 0;
}

Measured memory_bytes: 3584
s = input()
n = len(s) - 1
ans = 0
for i in range(2 ** n):
    index = []
    for j in range(n):
        if ((i>>j)&1):
            index.append(j)
    lis = []
    zero = 0
    for k in range(len(index)):
        lis.append(int(s[zero:index[k]+1]))
        zero = index[k] + 1
    lis.append(int(s[zero:]))
    ans += sum(lis)
print(ans)
        
    
    

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

int memo[100];
int fibonacci( int a )
{
    if( a == 0 || a == 1 )
        return memo[0] = memo[1] = 1;
    else
    {
        if( memo[a] != 0 )
            return memo[a];
        else
            return memo[a] = fibonacci( a - 1 ) + fibonacci( a - 2 );
    }
}

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

    cout << fibonacci(n) << endl;

    return 0;
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define  rep(i,n) for(li i=0;i<(n);i++)
#define  red(i,n) for(li i=(n)-1;i>=0;i--)
#define  scn(a)   scanf("%d",&(a))
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a,ul b) { return b?gcd(b,a%b):a; }

int main()
{
    bool a[26]={0};
    char c;
    while(cin>>c) a[c-'a']=1;
    int i=0;
    for(;i<26;i++)if(a[i]==0)cout<<(char)('a'+i)<<endl,exit(0);
    cout<<"None"<<endl;

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Fri Oct  4 10:11:27 2019

@author: Md abdul momin
"""

N = int(input())
ans=[0 for i in range(0,100005)]
Val =[int(x) for x in input().split()]
for i in range(1,N+1):
    ans[Val[i-1]]=i
for i in range(1,N+1):
    print(ans[i])
    
    

Measured memory_bytes: 14708
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type pair struct {
	x, y int
}

func main() {
	a, b := getInt(), getInt()

	g := gcd(a, b)

	ans := len(factorize(g)) + 1
	fmt.Println(ans)
}

func gcd(a, b int) int {
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

func factorize(n int) map[int]int {
	ret := make(map[int]int)
	for n%2 == 0 {
		n /= 2
		ret[2]++
	}

	for i := 3; i*i <= n; i += 2 {
		if n%i != 0 {
			continue
		}

		for n%i == 0 {
			n /= i
			ret[i]++
		}
	}

	if n != 1 {
		ret[n]++
	}

	return ret
}

// -----------------------------------------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << ": " << x << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define int long long
#define print(x) cout << (x) << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = (1LL << 30);
const ll MOD = 1000000007;
//=============================================================
//=============================================================
int N,Y;
void solve()
{
    int xxx,yyy,zzz;
    xxx=yyy=zzz=-1;
    bool f = false;
    rep(i,N+1){
        if (f)break;
        rep(j,N-i+1){
            int z = (N-i-j);
            z = (z>=0)? z : 0;
            if (i*10 + j*5 + z == Y){
                xxx = i; yyy = j; zzz = z;
                f = true;
                break;
            }
        }
    }


    printf("%lld %lld %lld\n", xxx, yyy, zzz);
}
signed main()
{
    cin >> N >> Y;
    Y /= 1000;
    solve();
    return 0;
}

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

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

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

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

vector<int> dijkstra(int i, int n, vector<vector<pair<int, int>>> graph) {
  vector<int> d(n, INF);
  d[i] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
  q.push(make_pair(0, i));
  while (!q.empty()) {
    pair<int, int> p = q.top();
    q.pop();
    int v = p.second;
    if (d[v] < p.first) {
      continue;
    }
    for (auto x : graph[v]) {
      if (d[x.first] > d[v] + x.second) {
        d[x.first] = d[v] + x.second;
        q.push(pair<int, int>(d[x.first], x.first));
      }
    }
  }
  return d;
}

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

  vector<vector<pair<int, int>>> graph(N);
  REP(i, N-1){
    int u, v, d;
    cin >> u >> v >> d;
    u--; v--;
    graph[u].emplace_back(v, d);
    graph[v].emplace_back(u, d);
  }

  auto dist = dijkstra(0, N, graph);

  REP(i, N){
    cout << dist[i]%2 << "\n";
  }

  return 0;
}

Measured memory_bytes: 15616
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, Z, T;
    cin >> N >> Z >> T;
    cout << (N+Z-1) / Z * T << '\n';
}


Measured memory_bytes: 3592
#include<stdio.h>

int main(void)
{
int n,i,j;

scanf("%d",&n);

while(1){
j=0;
for(i=1;i<=n;i++)if(n%i==0)j++;
if(j==2){
printf("%d\n",n);
return 0;
}else{
n++;
}}

return 0;
} 

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

signed main() {
  int N, M;
  cin >> N >> M;
  
  vector<vector<int>> kumi(2000, vector<int>(N));
  for (int bit = 0; bit < (1<<N); ++bit){
   for (int i = 0; i < N; ++i) {
      if (bit & (1<<i)) { // i が bit に入るかどうか
        kumi.at(bit).at(i) = 1;
      }else{
        kumi.at(bit).at(i) = 0;
      }
    }
  }
  
  vector<int> K(M);
  vector<vector<int>> S(M);
  int s;
  for( int i = 0; i < M; i++ ){
    cin >> K.at(i);
    for( int j = 0; j < K.at(i); j++ ){
      cin >> s;
      S.at(i).push_back(s);
    }
  }
  
  vector<int> P(M);
  for( int i = 0; i < M; i++ ) cin >> P.at(i);
  
  int ans = 0;
  for( int i = 0; i < pow(2, N); i++ ){
//K個のスイッチ（s1,s2,…sk）中、オンになっている個数%2がPのとき、j個目の電球が点灯
    int cnt = 0; //何個電球が光ったか
    for( int j = 0; j < M; j++ ){ 
      int oncnt = 0;
      for( int u = 0; u < K.at(j); u++ ){
        if( kumi.at(i).at(S.at(j).at(u)-1) == 1 ) oncnt++;
      }
      if( oncnt % 2 == P.at(j) ) cnt++;
    }
    if( cnt == M ) ans++;
  }
  cout << ans << endl;
      

    
}


Measured memory_bytes: 512
#include <iomanip>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int H, N;
  cin >> H >> N;
  int A = 0;
  rep(i, N) {
    int a;
    cin >> a;
    A += a;
  }
  if (A < H)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int main() {
	long long  n, a, b, i, x, xn, sum = 0;
	scanf("%lld%lld%lld%lld", &n, &a, &b, &x);
	for (i = 1; i < n; i+=2) {
		scanf("%lld", &xn);
		sum += (xn - x)*a > b ? b : (xn - x)*a;
		if (i + 1 < n) {
			scanf("%d", &x);
			sum += (x - xn)*a > b ? b : (x-xn)*a;
		}
	}
	printf("%lld", sum);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	char c=getchar();int t=0,f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int n;
int main(){
	n=read();
	printf("%d\n",n*n*n);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
#include <sstream>
#include <queue>
using namespace std;
typedef long long ll;

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  ll ans_a_1 = a * c;
  ll ans_a_2 = a * d;
  ll ans_b_1 = b * c;
  ll ans_b_2 = b * d;

  cout << max({ans_a_1, ans_a_2, ans_b_1, ans_b_2}) << endl;
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 2000000000
typedef long long ll;
bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力



int main() {
    
    ll n,M;
    cin >>n>>M;
    vector<vector<ll>>  s(M);
    rep(i,M){
        ll k;
        cin >> k;
        rep(j,k){
            ll tmp;
            cin >> tmp;
            s[i].pb(tmp-1);
        }
    }
    vector<ll> p(M); 
    rep(i,M){
        cin >> p[i];
    }
    vector<vector<bool>> S(1<<n);
    rep(bit,1<<n){
        
        rep(i,n){
            if(bit&(1<<i)){
                S[bit].pb(1);
            }else{
                S[bit].pb(0);
            }
        }
    }

    vector<bool> L(n);

    ll cnt =0;
    rep(i,1<<n){
        rep(j,M){
            bool pt = 0;
            rep(k,s[j].size()){
                if(S[i][s[j][k]] == 1){
                    pt ^= 1;
                }
            }
            if(pt !=p[j])  break;
            if(j == M-1){
                cnt++;
            }
        }
    }


    cout << cnt << endl;

    return 0;
    

}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i) 
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define debug1(a) cout<<" a : "<<a<<"\n"
#define debug2(a,b) cout<<" a : "<<a<<" b : "<<b<<"\n"
#define debug3(a,b,c) cout<<" a : "<<a<<" b : "<<b<<" c : "<<c<<"\n"
#define M 1000000007

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
	int n,k;
	cin>>n>>k;
	int a[n],dp[n]={0};
	rep(i,n) cin>>a[i];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	REP(i,2,n-1)
	{
		int temp=LLONG_MAX;
		REP(j,1,k)
		{
			if (i-j<0) break;
			temp=min(temp,abs(a[i]-a[i-j])+dp[i-j]);
		}
		dp[i]=temp;
	}
	cout<<dp[n-1];
	return 0;
}




Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
using namespace std;
long long int k,n,a[200010],i,j;
long long int sum=0,temp=0;
int main()
{
    scanf("%lld%lld",&k,&n);
    for(i=0;i<n;i++)
        scanf("%lld",&a[i]);
    sum=k-(k-a[n-1]+a[0]);
    //printf("%lld",sum);
    for(i=0;i<n-1;i++)
    {
        temp=k-(a[i+1]-a[i]);
        if(temp<sum)
            sum=temp;
    }
    printf("%lld",sum);
    return 0;
}


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

int a, b;
string s;

int main(void){
    // Here your code !
    scanf("%d %d", &a, &b);
    cin >> s;

    if (s[a] != '-') {printf("No\n"); return 0;}

    for (int i = 0; i < s.size(); ++i) {
      if (i == a) continue;
      if (int(s[i]) - 48 > 9 || int(s[i]) - 48 < 0) {printf("No\n"); return 0;}
    }
    printf("Yes\n");
    return 0;
}

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

using namespace std;
 
int main(void){
  char dp[1001][1001];
  int n,M[1001][1001];
   
   
  while(cin >> n,n){
       
      for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
          M[i][j]=1;
      
      for(int i=0;i<n;i++){
	for(int j=0;j<n;j++){
          cin >> dp[i][j];
          if(i==0){
	    if(dp[i][j]!='*')M[i][j]=1;
	    else M[i][j]=-1;
	  }
          else{
	    if(dp[i][j]!='*'){
	      if(j==0)M[i][j]=1;
	      else{
		if(M[i-1][j]==-1 || M[i-1][j-1]==-1 || M[i][j-1]==-1)M[i][j]=1;
		else M[i][j]=min(M[i-1][j],min(M[i-1][j-1],M[i][j-1]))+1;
	      }
	    }
	  }
          if(dp[i][j]=='*')M[i][j]=-1;
        }
      }

      int ans=0;      
      for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	  ans=max(ans,M[i][j]);
  
      cout << ans << endl;
    }
  return 0;
}

Measured memory_bytes: 5756
from itertools import product
N, K = map(int, input().split())
D = list(map(int, input().split()))
canuse = {0,1,2,3,4,5,6,7,8,9} - set(D)
canuse = list(canuse)
ans = float("inf")
for d in range(1, 6):
    for num in product(canuse, repeat=d):
        number = ""
        for m in num:
            number += str(m)
        number = int(number)
        if number >= N:
            ans = min(number, ans)
        
print(ans)

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

int main() {
  int n ,d , x;
  cin >> n >> d >> x ;
  vector<int> a(n) ;
  for ( int i=0 ; i<n ; i++){
    cin >> a.at(i) ; 
  }
  int ans =x ;
    for (int i=0 ; i< n ; i++){
     ans +=( (d-1)/a.at(i) )+1 ;
    }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#真に大切なのは中間点となる要素
N, M = map(int, input().split())
an = set()
nb = set()
for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        an.add(b)
    elif b == N:
        nb.add(a)

print('IMPOSSIBLE' if len(an&nb)==0 else 'POSSIBLE')

Measured memory_bytes: 19024
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
 
public class Main {
	public static void main(String[] args) throws IOException {
		MScanner sc = new MScanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		int a=sc.nextInt();int b=sc.nextInt();int c=sc.nextInt();int d=sc.nextInt();int e=sc.nextInt();
		int k=sc.nextInt();
		if(e-a>k) {
			pw.println(":(");
		}
		else {
			pw.println("Yay!");
		}
		pw.flush();
 
	}
    static class MScanner {
		StringTokenizer st;
		BufferedReader br;
 
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 23124
#include<iostream>
using namespace std;
int y,x,s;

int calc(int p,int x){
  return p*(100+x)/100;
}

int main(){
  while(1){
    cin>>x>>y>>s;
    if(y==0&&x==0&&s==0)break;
    int ans=0;
    for(int i=1;i<s;i++){
      for(int j=1;j<s;j++){
	if(calc(i,x)+calc(j,x)!=s)continue;
	ans=max(ans,calc(i,y)+calc(j,y));
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>

using namespace std;

typedef pair<long long , long long > P;

int main(){
    string s;
    map<int, int> m1, m2;
    cin >> s;
    int ll=0, lr, rl, rr;
    int i=0;
    while(1){
        while(1){
            if(s[i]=='L'){
                lr=i-1;
                rl=i;
                break;
            }
            i++;
        }
        while(1){
            if(s[i]=='R'){
                rr=i-1;
                break;
            }
            i++;
            if(i==s.length()){
                rr=i-1;
                break;
            }
        }
        m1[lr] += (lr-ll+2)/2 + (rr-rl+1)/2;
        m1[rl] += (lr-ll+1)/2 + (rr-rl+2)/2;
        ll=i;
        if(i==s.length()){
            break;
        }
    }
    for(int i=0;i<s.length();i++){
        cout << m1[i] << ' ';
    }
    cout << endl;
}


Measured memory_bytes: 5248