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

int main(){
    int N;
    scanf("%d", &N);
    int a[N], b[N], c[N];
    for(int i = 0; i < N; i++)scanf("%d%d%d", &a[i], &b[i], &c[i]);
    int dp[N][3];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for(int i = 1; i < N; i++){
        dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = b[i] + max(dp[i - 1][2], dp[i - 1][0]);
        dp[i][2] = c[i] + max(dp[i - 1][0], dp[i - 1][1]);
    }
    int ans = max({dp[N - 1][0], dp[N - 1][1], dp[N - 1][2]});
    printf("%d\n", ans);
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int a[510][510];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    rep(i, H) {
        rep(j, W) {
            cin >> a[i][j];
        }
    }
    vector<pair<int, int>> A;
    rep(i, H) {
        rep(j, W - 1) {
            if (a[i][j] % 2 == 1) {
                a[i][j]--;
                a[i][j + 1]++;
                A.push_back({i, j});
                A.push_back({i, j + 1});
            }
        }
    }
    rep(i, H - 1) {
        if (a[i][W - 1] % 2 == 1) {
            a[i][W - 1]--;
            a[i + 1][W - 1]++;
            A.push_back({i, W - 1});
            A.push_back({i + 1, W - 1});
        } 
    }
    cout << A.size() / 2 << endl;
    rep(i, A.size()){
        cout << A[i].first + 1 << " " << A[i].second + 1;
        if (i % 2 == 0) cout << " ";
        else cout << endl; 
    }


    return 0;
}


Measured memory_bytes: 5232
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int>A(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
    }
    int all=0;int k=1;
    all=pow(3,N);
    for(int i=0;i<N;i++){
        if(A.at(i)%2==0){k*=2;}
    }
    cout<<all-k<<endl;

    return 0;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

a = 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
K = parse(readline())
println(a[K])

Measured memory_bytes: 118824
#include <cstdio>
#include <vector>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < int(n); ++(i))
#define repeat_reverse(i, n) for (int i = (n)-1; (i) >= 0; --(i))
#define repeat_from_reverse(i, m, n) for (int i = (n)-1; (i) >= int(m); --(i))
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define unittest_name_helper(counter) unittest_ ## counter
#define unittest_name(counter) unittest_name_helper(counter)
#define unittest __attribute__((constructor)) void unittest_name(__COUNTER__) ()
using ll = long long;
using namespace std;
template <class T> inline void setmax(T & a, T const & b) { a = max(a, b); }
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

vector<bool> sieve_of_eratosthenes(int n) { // enumerate primes in [2,n] with O(n log log n)
    vector<bool> is_prime(n+1, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i*i <= n; ++i)
        if (is_prime[i])
            for (int k = i+i; k <= n; k += i)
                is_prime[k] = false;
    return is_prime;
}
vector<int> list_primes(int n) {
    auto is_prime = sieve_of_eratosthenes(n);
    vector<int> primes;
    for (int i = 2; i <= n; ++i)
        if (is_prime[i])
            primes.push_back(i);
    return primes;
}

int main() {
    vector<int> primes = list_primes(1299709);
    while (true) {
        int n; scanf("%d", &n);
        if (n == 0) break;
        auto it = whole(lower_bound, primes, n);
        int q = *it;
        int p = *it == n ? *it : *(-- it);
        printf("%d\n", q - p);
    }
    return 0;
}

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

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define VI vector<int>
#define PII pair<int,int>
#define ALL(x) (x).begin(), (x).end()
#define FI first
#define SE second
#define MODN 1000000007

template<class T>
ostream &operator<<(ostream &os, vector <T> V) {
  os << "[";
  for (auto vv : V) os << vv << ",";
  return os << "]";
}

template<class L, class R>
ostream &operator<<(ostream &os, pair <L, R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

signed main() {
  IOS;
  int n,m,a;
  cin >> n >> m;
  set<int> s;
  FOR(i, 0, m) {
    cin >> a;
    s.insert(a);
  }

  int dp[(int)1e5+5]={0};
  dp[0]=1;
  dp[1]=1;
  for (int i = 2; i <= n; i++) {
    if (s.find(i-1) == s.end()) {
      dp[i] = dp[i-1];
//      cout << i << "-1: " << dp[i] << endl;
    }
    if (s.find(i-2) == s.end()) {
//      cout << dp[i] << " " << dp[i-2] << " " << (dp[i] + dp[i-2]) % MODN << endl;
      dp[i] = (dp[i] + dp[i-2]) % MODN;
//      cout << i << "-2: " << dp[i] << endl;
    }
//    cout << i << ": " << dp[i] << endl;
  }

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

Measured memory_bytes: 5760
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_Training
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(' ');
            var n = int.Parse(nm[0]);
            var m = int.Parse(nm[1]);
            var ans = n * (n - 1) / 2 + m * (m - 1) / 2;
            Console.WriteLine(ans);

        }

    }
}

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

int main(){
    int N;
    cin >> N;
    int a,Imax = 0,Imin = 3000;
    for(int i = 0;i < N;i++){
        cin >> a;
        Imax = max(Imax,a);
        Imin = min(Imin,a);
    }
    int I;
    I = Imax - Imin;
    //cout << Imax << endl;
    //cout << Imin << endl;
    if(I % 2 == 1){
        cout << I/2+1 << endl;
    }else{
        cout << I/2 << endl;
    }
    
}


Measured memory_bytes: 3044
#include <algorithm>
#include <cctype>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

int main() {
    int k, s;
    cin >> k >> s;

    int cnt = 0;
    for (int x = 0; x <= k; x++) {
        for (int y = 0; y <= k; y++) {
            int z = s - x - y;
            if (0 <= z && z <= k) {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll h;
    cin >> h;

    ll p = 0;
    while(1 < h) {
        h /= 2LL;
        p++;
    }

    ll ans = 2LL; 
    while(p--) {
        ans *= 2;
    }
    ans--;

    out(ans);
    re0;
}

Measured memory_bytes: 256
use proconio::input;

fn is_ok(a: &[i64], k: i64, x: i64) -> bool {
    let mut c = 0;
    for &a_i in a.iter() {
        c += (a_i + (x - 1)) / x - 1;
    }
    c <= k
}

fn main() {
    input! {
        n: usize,
        k: i64,
        a: [i64; n],
    };
    let mut ng = 0;
    let mut ok = 1_000_000_001;
    while ok - ng > 1 {
        let x = ng + (ok - ng) / 2;
        if is_ok(&a, k, x) {
            ok = x;
        } else {
            ng = x;
        }
    }
    let ans = ok;
    println!("{}", ans);
}


Measured memory_bytes: 5364
#include <stdio.h>
#define MAX 251

int main(){
  int i,H,A[MAX];

  scanf("%d",&H);
  for(i=1;i<=H;i++) scanf("%d",&A[i]);

  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i/2!=0) printf("parent key = %d, ",A[i/2]);
    if(i*2<=H){
      printf("left key = %d, ",A[i*2]);
      if(i*2+1<=H) printf("right key = %d, ",A[i*2+1]);
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long a[2], b[2], t;
    
    cin >> a[0] >> a[1] >> b[0] >> b[1] >> t;
    
    if(a[1] <= b[1]){
        cout << "NO";
    }
    else{
        if((a[1] - b[1]) * t >= abs(a[0] - b[0])){
            cout << "YES";
        }
        else{
            cout << "NO";
        }
    }
    
    return 0;
}


Measured memory_bytes: 3604
import java.util.*;

public class Main {

    private static Double allSum;

    public static class Point {
        public int x;
        public int y;
        public boolean isUsed;

        public Point(int x, int y, boolean isUsed) {
            this.x = x;
            this.y = y;
            this.isUsed = isUsed;
        }

        public int getX() {
            return this.x;
        }

        public int getY() {
            return this.y;
        }

        public void setUseCondition(boolean cond) {
            this.isUsed = cond;
        }

        public boolean getUsedCondition() {
            return this.isUsed;
        }
    }

    public static void main(String[] args) {
        // 諸々init
        allSum = Double.parseDouble("0");
        double res = 0;

        // 入力読取＆街の座標の配列を作成
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());
        Point[] towns = new Point[N];

        int count = 0;
        while (sc.hasNext()) {
            String[] line = sc.nextLine().split(" ");
            Point point = new Point(Integer.parseInt(line[0]), Integer.parseInt(line[1]), false);
            towns[count] = point;
            count++;
        }
        sc.close();

        // 経路パターン数(N!)の取得
        int patterns = 1;
        for (int i = N; i >= 2; i--) {
            patterns = patterns * i;
        }

        goWithRoute(towns, null, Double.parseDouble("0"));

        res = allSum / patterns;

        System.out.println(res);
    }

    public static void goWithRoute(Point[] towns, Point lastPoints, double sum) {
        boolean isDo = false;
        double originsum = sum;
        for (Point point : towns) {
            if (point.isUsed) {
                continue;
            }
            isDo = true;
            //System.out.println("【P】x: " + point.getX() + ", y: " + point.getY());
            point.setUseCondition(true);
            if (!Objects.isNull(lastPoints)) {
                //System.out.println("before sum = " + sum);
                double xDiff = lastPoints.getX() - point.getX();
                double yDiff = lastPoints.getY() - point.getY();
                double powSum = Math.pow(xDiff, 2) + Math.pow(yDiff, 2);
                double distance = Math.sqrt(powSum);
                sum += distance;
                //System.out.println("after sum = " + sum);
            }

            goWithRoute(towns, point, sum);
            sum = originsum;

            point.setUseCondition(false);
        }
        if (!isDo) {
            //System.out.println("◆◆ finish ! : value = " + sum + " ◆◆");
            allSum += sum;
        }
    }

}

Measured memory_bytes: 24404
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <deque>
#include <queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <iomanip>
#include <utility>
#include <functional>
using namespace std;
//orz jzm
#define ll long long
#define ull unsigned ll
const ll PR=19260817;
int n;
ll a[200005];
ll llabs(ll x) {
	return x>0?x:-x;
}
int main() {
	scanf("%d", &n);
	ll x=0ll, y=0ll;
	for (int i=0; i<n; i++) {
		scanf("%lld", &a[i]);
		y+=a[i];
	}
	ll ans=1000000000000000000ll;
	for (int i=0; i<n-1; i++) {
		x+=a[i];
		y-=a[i];
		ans=min(ans, llabs(x-y));
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <math.h>
#include <map>
using namespace std;

long long a,b,x;

long long f(long long n) {
    if(n==-1) return 0;
    return n/x+1;
}

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

    cout<<f(b)-f(a-1)<<endl;

    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = [i for i in input()]
ans = 0
rsp = {"r": 0, "s": 0, "p": 0}
for i in range(n):
    if t[i] == "r":
        ans += p
    elif t[i] == "s":
        ans += r
    else:
        ans += s
    if i >= k and t[i] == t[i-k]:
        rsp[t[i]] += 1
        t[i] = "o"
mi = int(rsp["r"] * p + rsp["s"] * r + rsp["p"] * s)
print(ans-mi)

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

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(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll H1, M1, H2, M2, K;
  IN(H1,M1,H2,M2,K);

  ll D1 = H1*60 + M1;
  ll D2 = H2*60 + M2;
  ll ans = D2-D1-K;
  if(ans<0) ans=0;
  OUT(ans);

  return 0;
}

Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int main(){
  long tkhs,aok,k;
  cin>>tkhs>>aok>>k;
  if(tkhs>k)
    tkhs-=k;
  else{
    k-=tkhs;
    aok-=k;
    tkhs=0;
    if(aok<0)aok=0;
  }
  cout<<tkhs<<" "<<aok<<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)

int main(void){
    int n;
    while(cin >> n && n) {
        int ans = 0;
        for(int i=1; i<=n; ++i) {
            int tmp = i;
            while(tmp%5 == 0) {
                ans++;
                tmp /= 5;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1160
/* Preprocess */
#include <bits/stdc++.h>

/* Field */
using namespace std;

/* Function */
int main (void) 
{

  string s;   // input
  string ans; // output

  cin >> s;

  cout << s.at(0) << s.size()-2 << s.at(s.size()-1) << endl;

  return 0;

}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.awt.Point;
public class Main {
	static Scanner sc;
	static PrintWriter out;
	static final int uncal = -1;
	static final double pi = 3.14159;
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		sc = new Scanner(System.in); 
		out = new PrintWriter(System.out);
		int r = sc.nextInt();
		out.println(2*pi*r);
		out.close();
	}
	static void shuffle(int[] array) {
		Random rand = new Random();
		for (int i = 0; i < array.length; i++) {
			int randomIndexToSwap = rand.nextInt(array.length);
			int temp = array[randomIndexToSwap];
			array[randomIndexToSwap] = array[i];
			array[i] = temp;
		}
	}
	static boolean isPalindrome(String s) {
		int l = s.length();
		char[] sa = s.toCharArray();
		for(int i=0;i<l/2;i++) {
			if(sa[i] != sa[l-i-1])
				return false;
		}
		return true;
	}
	static class Point extends java.awt.Point implements Comparable<Point>{
		public Point(int x,int y) {
			// TODO Auto-generated constructor stub
			super(x,y);
		}
		public String toString() {
			return x+" "+y;
		}
		@Override
		public int compareTo(Point p) {
			// TODO Auto-generated method stub
			if(x == p.x)
				return y - p.y;
			return x - p.x;
		}
		
	}
	static class Scanner{
		private BufferedReader br;
		private StringTokenizer st;
		public Scanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}
		public Scanner(String filename) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(filename));
		}
		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 long nextLong() throws IOException{
			return Long.parseLong(next());
		}
		public double nextDouble() throws IOException{
			return Double.parseDouble(next());
		}
		public int[] inArr(int n) throws Exception{
			int a [] = new int[n];
			st = new StringTokenizer(br.readLine());
			for(int i=0;i<n;i++) {
				a[i] = Integer.parseInt(next());
			}
			return a;
		}
	}

}

Measured memory_bytes: 33312
//...START BY DOING WHAT IS NECESSARY, THEN WHAT IS POSSIBLE AND SUDDENLY YOU ARE DOING THE IMPOSSIBLE... 
// ................. WORK UNTILL YOUR IDOLS BECOME YOUR RIVALS................................

#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define pb emplace_back
#define f first
#define s second
#define delrep(a)  (a).erase(unique((a).begin(),(a).end()),(a).end());
#define all(a)  (a).begin(),(a).end()
#define sz(x)   (int)x.size()
const int N=4e5+5;
using namespace std;
int get_second( pair<int, int> i ){ return i.second; }  
int trail_zero(int n){while (n % 10 == 0) n /= 10 ; return n;}
typedef long long ll;
map<ll,ll> m11;
set<int> s1;
map<int,pair<int,int>> m1;
vector<pair<int,int>>v1;
vector<int>v9[26];
char s111[N];
ll p2[N],p3[N];
ll hash1[N];
int n,m;
bool check(int a,int b) { if(a>=0 || a<n) return true; if(b>=0 || b<m) return true; else return false;}
int dx[]={0,-1,0,1};
int dy[]={1,0,-1,0};
char s[500][500]; 
 vector<long long int> v[26];
 set<string> st; 
int main()
{
    int n,k; cin>>n>> k;
    if((n-1)%(k-1)==0) cout<<(n-1)/(k-1)<<endl; else cout<<(n-1)/(k-1)+1<<endl;
    return 0;
}








Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int N,K;
    vector<int>x;
    
    cin >> N >> K;
    for(int i=0;i<N;i++){
        int a;cin>>a;x.push_back(a);
    }
    int ans = 1e9;
    for(int i=0;i<=N-K;i++){
        int j=i+K-1;
        int ka=0;
        if(x[j]<0){
            ka=-x[i];
        }else if(x[i]<0&&x[j]>=0){
            ka=min(x[i]*(-2)+x[j],x[j]*2-x[i]);
        }else{
            ka=x[j];
        }
        ans=min(ans,ka);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define bit(k) (1LL<<(k))
#define SUM(v) accumulate(all(v), 0LL)

typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
struct fast_ios{ fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }fast_ios_;

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

#define TOSTRING(x) string(#x)
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os  << "["; for(auto _: v) os << _ << ", "; os << "]"; return os; };
template <typename T> ostream &operator<<(ostream &os, set<T> &st) { os << "("; for(auto _: st) { os << _ << ", "; } os << ")";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair< T, U >& p){os << "{" <<p.first << ", " << p.second << "}";return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &mp){ os << "["; for(auto _: mp){ os << _ << ", "; } os << "]" << endl; return os; }

#define DUMPOUT cerr
void dump_func(){ DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) { DUMPOUT << head; if (sizeof...(Tail) > 0) { DUMPOUT << ", "; } dump_func(std::move(tail)...); }

#ifdef DEBUG
#define dbg(...) dump_func(__VA_ARGS__)
#define dump(...) DUMPOUT << string(#__VA_ARGS__) << ": "; dump_func(__VA_ARGS__)
#else
#define dbg(...)
#define dump(...)
#endif

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const long double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/


int main() {
    int N, M, K;
    cin >> N >> M >> K;
    rep(i,N+1)rep(j,M+1){
        int cnt = abs(i * (M-j) + j * (N - i));
        if(cnt == K){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}



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

using namespace std;

const int MOD = 1e9 + 7;


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

    int n;
    cin >> n;
    unsigned long long sol = 1;

    for(int i = 1; i <= n; ++i) {
        sol = sol * i % MOD;
    }

    cout << sol;

    return 0;
}


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

s = [0] * (n+1)

for i in range(n):
    s[i+1] = s[i] + a[i]
    s[i] = (s[i] - i) % k
s[n] = (s[n] - n) % k

count = dict()
for i in range(min(k-1, n+1)):
    if not s[i] in count:
        count[s[i]] = 0
    count[s[i]] += 1

ans = 0
for i in range(k-1, n+1):
    if not s[i] in count:
        count[s[i]] = 0
    count[s[i]] += 1
    count[s[i-k+1]] -= 1
    ans += count[s[i-k+1]]

for i in count.values():
    ans += i * (i - 1) // 2

print(ans)

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

int main()
{
	string a,b,c;
	cin>>a>>b>>c;
	
	if(a.back()==b.front()&&b.back()==c.front()) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int sn[101];

int main() {
  int n,k;
  cin >> n >> k;
  rep(i,k){
    int d; cin >> d;
    rep(j,d){
      int A; cin >> A; sn[A]++;
    }
  }
  int cnt=0;
  for(int i=1;i<=n;i++){
    if(!sn[i]) cnt++;
  }
  cout << cnt << endl;
}


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

int gcd(int a, int b)
{
     return(b ? gcd(b, a % b):a);
}

int main()
{
    int a, b;
    while(cin >> a >> b)
    {
        cout << gcd(a, b) << " " << 1LL * a * b /gcd(a, b) << endl;
    }
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    ll N, K;
    cin >> N >> K;

    Vl A(N), F(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> F[i];
    }

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

    ll left = -1;
    ll right = 1e12;
    while (right - left > 1) {
        ll mid = (left + right) / 2;
        ll K_need = 0;
        for (int i = 0; i < N; i++) {
            ll tmp = A[i] * F[i];
            if (tmp > mid) {
                K_need += (tmp - mid + F[i] - 1) / F[i];
            }
        }
        if (K_need > K) {
            left = mid;
        }
        else {
            right = mid;
        }
    }

    cout << right << endl;

    return 0;
}

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

struct data {
  int a, b;
  bool operator<(const data &r) const { return a < r.a; }
};

int h, w, n;
vector<data> v;
vector<int> res, pre;

void solve();
int calc(int x, int y);

int main() {
  cin >> h >> w >> n;
  v.resize(n);
  res.resize(w);
  pre.resize(w);
  for(int i = 0; i < w; ++i) pre[i] = i;
  for(int i = 0; i < n; ++i) cin >> v[i].a >> v[i].b;
  sort(v.begin(), v.end());
  solve();
  for(int i = 0; i < w; ++i) cout << res[i] + 1 << endl;
  return 0;
}

void solve() {
  for(int i = 0; i < n; ++i)
    swap(pre[calc(v[i].a - 1, v[i].b - 1)],
         pre[calc(v[i].a - 1, v[i].b)]);
  for(int i = 0; i < w; ++i) res[pre[calc(h, i)]] = i;
}

int calc(int x, int y) {
  x %= 2 * w;
  if((y ^ x) % 2 == 0) {
    int tmp = min(x, y);
    x -= tmp;
    y -= tmp;
    if(x > 0) --x;
    tmp = min(x, w - 1);
    y += tmp;
    x -= tmp;
    if(x > 0) --x;
    y -= min(x, w - 1);
  }
  else {
    int tmp = min(x, w - 1 - y);
    x -= tmp;
    y += tmp;
    if(x > 0) --x;
    tmp = min(x, w - 1);
    y -= tmp;
    x -= tmp;
    if(x > 0) --x;
    y += min(x, w - 1);
  }
  return y;
}


Measured memory_bytes: 5968
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int dy[] = {0, 0, 1, -1};
    int dx[] = {1, -1, 0, 0};
    const int INF = INT_MAX/2;

    for(;;){
        int r;
        cin >> r;
        if(r == 0)
            return 0;

        int w[2], h[2], x0[2], y0[2];
        vector<vector<int> > room[2];
        for(int i=0; i<2; ++i){
            cin >> w[i] >> h[i] >> x0[i] >> y0[i];
            room[i].assign(h[i]+2, vector<int>(w[i]+2, INF));
            for(int j=1; j<=h[i]; ++j){
                for(int k=1; k<=w[i]; ++k){
                    cin >> room[i][j][k];
                }
            }
        }

        vector<int> level[2];
        for(int i=0; i<2; ++i){
            level[i].resize(h[i]*w[i]+1, INF);
            level[i][0] = 0;
            multimap<int, pair<int, int> > mm;
            vector<vector<int> > check(h[i]+2, vector<int>(w[i]+2, INF));
            mm.insert(make_pair(room[i][y0[i]][x0[i]], make_pair(y0[i], x0[i])));
            check[y0[i]][x0[i]] = room[i][y0[i]][x0[i]];
            int a = 1;
            while(!mm.empty()){
                int l = mm.begin()->first;
                int y = mm.begin()->second.first;
                int x = mm.begin()->second.second;
                mm.erase(mm.begin());
                if(l > check[y][x])
                    continue;
                level[i][a] = l;
                ++ a;
                for(int j=0; j<4; ++j){
                    int y1 = y + dy[j];
                    int x1 = x + dx[j];
                    if(max(l, room[i][y1][x1]) < check[y1][x1]){
                        mm.insert(make_pair(max(l, room[i][y1][x1]), make_pair(y1, x1)));
                        check[y1][x1] = max(l, room[i][y1][x1]);
                    }
                }
            }
        }

        int ret = INF;
        for(int i=0; i<=r; ++i){
            if(i >= level[0].size() || r-i >= level[1].size())
                continue;
            ret = min(ret, level[0][i] + level[1][r-i]);
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 0
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=3e5+4;

int main()
{
	int n,k;

	scn(n); scn(k);

	int ans=0;

	int pre[n+1],suf[n+1];

	pre[0]=0; suf[n]=n;

	rep(i,1,n+1)
	pre[i]=(pre[i-1]+i)%mod;

	for(int i=n-1;i>=0;i--)
	suf[i]=(suf[i+1]+i)%mod;

	for(int i=k;i<=n+1;i++)
	{
		int here=(suf[n-i+1]-pre[i-1]+1+mod)%mod;

		//cout<<i<<" "<<suf[n-i+1]<<" "<<pre[i-1]<<" "<<here<<endl;

		ans=(ans+here)%mod;
	}

	pri(ans);

    return 0;
}

Measured memory_bytes: 5288
#include <stdio.h>

int main(void)
{
	int W, H, x, y, r;

	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

	if (r <= x && x <= W - r && r <= y && y <= H - r) {
		puts("Yes");
	} else {
		puts("No");
	}

	return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
#define rep(i,a,n) for(int _tmp=n,i=a;i<=_tmp;++i)
#define dep(i,a,n) for(int _tmp=n,i=a;i>=_tmp;--i)
#define re(i,a,n) for(int _tmp=n,i=a;i<_tmp;++i)
#define fec(i,a) for(__typeof a.begin() i=a.begin();i!=a.end();++i)
#define For(i,u) for(int i=H[u];i;i=nxt[i])
#define si(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
using namespace std;
template<class T> inline void read(T&x){char c;bool fu=0;for(c=getchar();c<=32;c=getchar());if(c=='-')fu=1,c=getchar();for(x=0;c>32;c=getchar())x=x*10+c-'0';if(fu)x*=-1;}
template<class T> inline void read(T&x,T&y){read(x);read(y);}
template<class T> inline void read(T&x,T&y,T&z) {read(x,y);read(z);}
typedef long long ll;
typedef pair<int,int> pii;
const int N=111111;
//head
char s[N];
int cnt,n;
int main() {
	scanf("%s",s+1);n=strlen(s+1);
	rep(i,1,n)if(s[i]!=s[i-1])++cnt;
	if(cnt==1)return puts("0"),0;
	if(cnt&1){
		cout<<cnt-1;
	}else {
		cout<<cnt-1;
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
using namespace std;
using ll = long long;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin >> N;
    ll H;
    ll prev = 0;
    ll ans = 0, ta = 0;
    for(int i = 0; i < N; i++){
        cin >> H;
        if(H <= prev){
            ta++;
        }else{
            ta = 0;
        }
        ans = max(ta, ans);
        prev = H;
    }
    ans = max(ta, ans);

    cout << ans << endl;
    return 0;
}








Measured memory_bytes: 256
// Confessions of a Dangerous Mind

/*
	"We know what we are, but know not what we may be."
*/

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 20, BL = 400;
const double EPS = 3e-16;

/*
	"You never know how strong you are until being strong is the only choice you have."
*/

int main(){
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

/*
	"With self-discipline most anything is possible."
*/	

	double n; cin >> n;
	
	double ans = 0, x = n / 3;
	
	ans = x * x * x;
	cout << fixed << setprecision(10) << ans;
	return 0;
}

/*
	"Reach for it. Push yourself as far as you can."
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
template <bool Directed, typename TEdge, bool Index> struct graph {
    using EType = TEdge;
    vector<TEdge> edges;
    vector<vector<int>> adj;
    graph(int n) : adj(n + Index) {}
    graph(int n, int m) : graph(n) { edges.reserve(m << not Directed); }
    TEdge& operator()(int e) { return edges[e]; }
    vector<int>& operator[](int u) { return adj[u]; }
    int size() { return adj.size() - Index; }
    void append(int u, const TEdge& e) {
        adj[u].push_back(edges.size());
        edges.push_back(e);
    }
    void add_edge(const TEdge& e) {
        append(e.u, e);
        if(not Directed) append(e.v, e.reverse());
    }
};
struct edge {
    int u, v;
    edge reverse() const { return {v, u}; }
    friend ostream& operator<<(ostream& os, const edge& e) {
        return os << "{u: " << e.u << ", v: " << e.v << "}";
    }
};
template <bool Directed, typename TEdge, bool Index>
pair<vector<int>, vector<int>> bfs(graph<Directed, TEdge, Index>& g, const vector<int>& s) {
    vector<int> d(g.adj.size(), -1), p(g.adj.size(), -1);
    queue<int> q;
    for(int u : s) {
        d[u] = 0;
        q.push(u);
    }
    while(not q.empty()) {
        int u = q.front(); q.pop();
        for(int e : g[u]) {
            if(d[g(e).v] == -1) {
                d[g(e).v] = d[g(e).u] + 1, p[g(e).v] = e;
                q.push(g(e).v);
            }
        }
    }
    return {d, p};
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    graph<0, edge, 1> g(n, m);
    for(int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        g.add_edge({u, v});
    }
    auto [d, p] = bfs(g, {1});
    cout << "Yes" << endl;
    for(int i = 2; i <= n; i++) {
        cout << g(p[i]).u << endl;
    }
    return 0;
}

Measured memory_bytes: 14540
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;


int main() {
        ll n;
        cin >> n;
        ll a,b,c;
        ll MX = 3500;
        bool ok = false;
        for(ll h=1;h<=MX;h++){
                for(ll w=1;w<=MX;w++){
                        ll mother = 4*h*w - n*h - n*w;
                        ll kid = n*h*w;
                        if( mother * kid <= 0) continue;
                        if(kid%mother == 0){
                                a = h;
                                b = w;
                                c = kid/mother;
                                ok = true;
                        }
                        if(ok) break;
                }
                if(ok) break;
        }

        cout << a << " " << b << " " << c << endl;

        return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

bool debug=false;
/*---------------------------------------------------*/

int main(){
  double r0,w0,c,r;
  while(cin>>r0>>w0>>c>>r){
    if(r0==0&&w0==0&&c==0&&r==0)break;
    cout<<max(0,int((c*w0-r0)/r+0.99999999))<<endl;
  }
  return 0;
}

Measured memory_bytes: 3208
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[][] d = new int[n+m][2];
    int [] id = new int[n];//距離が最小となるときの地点を格納する配列

    for(int i = 0; i < n+m; i++){
      d[i][0] = sc.nextInt();
      d[i][1] = sc.nextInt();
    }

    for(int i = 0; i < n; i++){
      int min = 4 * (int)Math.pow(10, 8);
      for(int j = n; j < n+m; j++){
        int l = Math.abs(d[i][0] - d[j][0]) + Math.abs(d[i][1] - d[j][1]);
        if(min > l){
          min = l;
          id[i] = j-n+1;
        }else if(min == l && id[i] > j-n+1){
          id[i] = j-n+1;
        }
      }
    }

    for(int i = 0; i < n; i++){
      System.out.println(id[i]);
    }

  }
}


Measured memory_bytes: 21844
n = gets.strip.split.map{|n| n.to_i}.sort
a = n[0]
b = n[1]
c = n[2]

up = 0
if a == b
  up = c - b
else
  up = c - b
  a += up
  if (c-a)%2 == 0
    up += (c-a)/2
  else
    up += ((c-a)/2.0).ceil + 1
  end
end
puts up


Measured memory_bytes: 1788
from collections import deque


H,W = map(int, input().split())
A = [[str(i) for i in list(input())] for _ in range(H)]

q = deque()
for i in range(H):
    for j in range(W):
        if A[i][j] == "#":
            q.append((i,j))


ans = 0
dyx = [(1,0), (0,1), (-1,0), (0,-1)]
while q:
    flag = False
    for _ in range(len(q)):
        y,x = q.popleft()
        for dy, dx in dyx:
            ny, nx = y+dy, x+dx
            if not 0 <= ny <= H-1 or not 0 <= nx <= W-1:
                continue
            if A[ny][nx] == ".":
                q.append((ny, nx))
                A[ny][nx] = "#"
                flag = True
    if flag:
        ans += 1

print(ans)




Measured memory_bytes: 116572
#include <bits/stdc++.h>
using namespace std;
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; }

int main() {
  string s,t;
  cin >> s >> t;
  //int dp[s.length()+1][t.length()+1]={0};
  /*何でか分からないけど、上式だと変な値入って下式だと大丈夫だった*/
  int dp[3010][3010]={0};
  /*for(int i=0; i<s.length(); i++){
    for(int j=0; j<t.length(); j++)
      cout << dp[i][j] << '\t';
    cout << endl;
  }*/
  for(int i=0; i<s.length(); i++){//0~=なし、中身i,i+1の方がいい
    for(int j=0; j<t.length(); j++){//1~=あり、中身i-1,iより
      if(s[i]==t[j])
        chmax(dp[i+1][j+1],dp[i][j]+1);
      chmax(dp[i+1][j+1],dp[i][j+1]);
      chmax(dp[i+1][j+1],dp[i+1][j]);
    }
  }
  string res="";
  int i=s.length(); int j=t.length();
  while(i>0 && j>0){//復元
    if(dp[i-1][j]==dp[i][j])
      i--;
    else if(dp[i][j-1]==dp[i][j]) //排反じゃないからelse必要
      j--;
    else{
      res = s[i-1] + res;
      i--; j--; //２つ減らすの忘れずに
    }
  }
  /*for(int i=0; i<s.length(); i++){
    for(int j=0; j<t.length(); j++)
      cout << dp[i][j] << '\t';
    cout << endl;
  }*/
  cout << res << endl;
}

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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define FORE( i, m, n ) FOR( i, m , n + 1 )
#define REP( i, n )     FOR( i, 0, n )
#define REPE( i, n )	FOR( i, 0, n + 1 )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define P				pair<string, int>
#define fi				first
#define se				second

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

const int INF = 1e9;
const int MOD = 1e9 + 7;
const int MAX_N = 100;

bool G[MAX_N][MAX_N];

signed main() {
	string s; cin >> s;

	cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
}

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

signed main(){
    // Your code here!
   int n;
   string tmp;
   
   map<string,int> mp{};
   
   cin >> n;
   for(int i = 0; i < n; i ++){
        cin >> tmp;
        mp[tmp] = 1;
   }
   cout <<  mp.size();
   
}


Measured memory_bytes: 19120
#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>

using namespace std;

class restaurant{
    public:
    string city;
    int good;
    int num;
    restaurant(){}
    restaurant(string c, int g, int n) : city(c), good(g), num(n){}
};

bool operator<(const restaurant& x, const restaurant& y){
    if (x.city == y.city)
        return x.good > y.good;
    else
        return x.city < y.city;
}

int main(){
    int n;
    cin >> n;
    vector<restaurant> res(n);
    for (int i = 0; i < n; i++){
        string c;
        int g;
        cin >> c >> g;
        res[i] = restaurant(c, g, i + 1);
    }
    sort(res.begin(), res.end());
    for (int i = 0; i < n; i++)
        cout << res[i].num << endl;
}

Measured memory_bytes: 256
import sys

def dump(x):
    print(x, file=sys.stderr)

# dump(-1 % 5)
MOD = 10**9+7
# dump(MOD)

n = int(input())
all = 1
for i in range(n):
    all *= 10
    all %= MOD

a=1
for i in range(n):
    a *= 9
    a %= MOD

b=1
for i in range(n):
    b *= 8
    b %= MOD

ans = all - 2*a + b
ans %= MOD
print(ans)







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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }



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

    ll N;
    cin >> N;

    vector<ll> a(N);
    REP(i,N){
        cin >> a.at(i);
    }

    deque<ll> b;
    if(N%2==0){
        REP(i,N){
            if(i%2==0){
                b.push_back(a.at(i));
            }
            else{
                b.push_front(a.at(i));
            }
        }
    }
    else{
        REP(i, N)
        {
            if (i % 2 == 0)
            {
                b.push_front(a.at(i));
            }
            else
            {
                b.push_back(a.at(i));
            }
        }
    }

    REP(i,N){
        cout << b.at(i) << " ";
    }
    return 0;}


Measured memory_bytes: 6288
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
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;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin>>n;
    vector<ll> c;
    vector<vector<ll>> st(ll(1e+5)*2+5);
    ll prev = -1;
    rep(i,n){
        ll tmp;cin>>tmp;
        if(tmp!=prev){
            c.push_back(tmp);
            prev = tmp;
        }
    }
    ll cs = c.size();
    rep(i, cs) {
        st[c[i]].push_back(i);
    }
    vector<vector<ll>> dp(cs,vector<ll>(2,0));
    dp[0][0] = 1;
    repr(i, 1, cs) {
        auto it = lower_bound(begin(st[c[i]]), end(st[c[i]]), i);
        if(it!=st[c[i]].begin()){
            it--;
            dp[i][1] += dp[*it][0] + dp[*it][1];
            dp[i][1] %= MOD;
        }
        if(i > 0) {
            dp[i][0] += dp[i-1][0];
            dp[i][0] += dp[i-1][1];
            dp[i][0] %= MOD;
        }
        DEBUG{
            printf("i: %d, 0: %lld, 1: %lld\n", i, dp[i][0], dp[i][1]);
        }
    }
    cout << (dp[cs-1][0] + dp[cs-1][1]) % MOD << endl;
    return 0;
}


Measured memory_bytes: 23664
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N, M, X; cin >> N >> M >> X;
    vector<vector<int>> A(N, vector<int>(M));
    vector<int> C(N);
    for (int i = 0; i < N; i++) {
        cin >> C[i];
        for (auto &a : A[i]) cin >> a;
    }
    vector<int> B(M);
    int ans = 1e9;
    for (int bits = 0; bits < (1 << N); bits++) {
        fill(begin(B), end(B), 0);
        int total = 0;
        for (int i = 0; i < N; i++) if (bits & (1 << i)) {
            total += C[i];
            for (int j = 0; j < M; j++) {
                B[j] += A[i][j];
            }
        }
        if (all_of(begin(B), end(B), [&](int b) { return b >= X; })) {
            ans = min(ans, total);
        }
    }
    cout << (ans == 1e9 ? -1 : ans) << endl;
    return 0;
}


Measured memory_bytes: 3660