akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define re return
#define ll long long
#define ull unsigned ll
#define ld long double
#define f first
#define s second
#define pi acos(-1)
#define oo (ll)1e9
#define OO 1e18
#define EPS 1e-6
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn=5205;

int main()
{
    IO;
    int n;
    cin >> n;
    vector<ll> x(n),y(n);
    priority_queue<pair<ll,int> >pq;
    for(int i=0;i<n;++i){
        cin >> x[i] >> y[i];
        pq.push({y[i]+x[i],i});
    }
    ll ans=0;
    for(int i=0;i<n;++i){
        if(i%2)ans-=y[pq.top().s];
        else ans+=x[pq.top().s];
        pq.pop();
    }
    cout<<ans<<endl;
    re 0;
}

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

using namespace std;

typedef unsigned long long ull;

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

    int a,b,c;
    cin >> a >> b >> c;
    
    string res = to_string(a) + to_string(b) + to_string(c);
    sort(res.begin(), res.end());
    if (res == "557")
        cout << "YES";
    else
        cout << "NO";


    return 0;
}

Measured memory_bytes: 256
def sumDigits(i):
    s = 0
    while i > 0:
        s += (i % 10)
        i = int(i / 10)
    return s

N = int(input())

m = N
for i in range(1, N):
    k = N - i
    m = min(m, sumDigits(i) + sumDigits(k))

print(m)

Measured memory_bytes: 2940
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;

int main() {

	int n, k;
 	cin >> n >> k;
	vector<bool> ans(n);


	for (int i = 0; i < k;i++)		//k種類のお菓子 
	{
		int have_amount;
		cin >> have_amount;
		for (int j = 0; j < have_amount; j++)
		{
			int buf;
			cin >> buf;
			ans[buf-1] = true;
		}
	}
	int ans_amount = 0;
	for (int i = 0; i < n;i++)
		if (!ans[i])
			ans_amount++;

	cout << ans_amount;

	return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
 
struct card {
    char num1;
    int num2;
};
 
void def1(struct card *, struct card *);

void def2(int, struct card *);
 
#define N 36 
int main(void)
{
  int i, j; 
int minj, n, flag;

    struct card array1[N], array2[N];
     
    scanf("%d",&n);
    
for (i = 0; i < n; i++) {

        scanf(" %c%d", &array1[i].num1, &array1[i].num2);

        array2[i] = array1[i];
    }
     
    for (i = 0; i < n; i++) {
        for (j = n - 1; j > i; j--) {
            if ( array1[j].num2 < array1[j-1].num2 ) 
	      def1( &array1[j] , &array1[j-1] );
        }
    }
     
    for (i = 0; i < n; i++) {
        minj = i;
        for (j = i; j < n; j++) {
            if( array2[j].num2 < array2[minj].num2 )
	      minj = j;
        }
        if(i != minj) def1( &array2[i], &array2[minj]);
    }
    flag = 1;
    for (i = 0; i < n; i++) {
        if( array1[i].num1 != array2[i].num1 ) {
            flag = 0;
            break;
        }
    }
     
    def2(n, array1);

    printf("Stable\n");

    def2(n, array2);

    if(flag){ 
      printf("Stable\n");
    }else{
      printf("Not stable\n");
    }     
    return 0;
}
 
void def1(struct card *card1, struct card *card2)
{
  struct card temp;
  temp = *card1;
  *card1 = *card2;
    *card2 = temp;
}
 
void def2(int n, struct card *C)
{
    int i;
    for (i = 0; i < n - 1; i++) {
        printf("%c%d ", C[i].num1, C[i].num2);
    }
    printf("%c%d\n", C[n-1].num1, C[n-1].num2);
}

Measured memory_bytes: 608
#![allow(non_snake_case)]

use std::io;

// h > 3, w > 3
fn print_frame(h: u32, w: u32) {
    assert!(h >= 3 && w >= 3, "h & w: error");
    
    for y in 0..h {
        for x in 0..w {
            if x == 0 || x == w-1 || y == 0 || y == h-1 {
                print!("#");
            } else {
                print!(".");
            }
        }
        println!("");
    }

}

fn main() {
    let sin = io::stdin();
    loop {
        let mut buf = String::new();
        sin.read_line(&mut buf).ok();
        let mut ws = buf.split_whitespace();
        let h: u32 = ws.next().unwrap().parse().unwrap();
        let w: u32 = ws.next().unwrap().parse().unwrap();
        if h == 0 && w == 0 {
            break;
        } else {
            print_frame(h, w);
            println!("");
        }
    }
}



Measured memory_bytes: 5020
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 100005;
const int MMAX = 50005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(int)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = (_begin + _end) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


ll N,M,K,A[NMAX],B[MMAX],C,D,E;
int dp[NMAX] = {};

string S;
vec v;

ll ans = 0;

void solve(){
  // main algorithm
  for (int i = 0; i < M; ++i)
  {
    int x = B[i];
    int lb = -1, ub = N-1;
    while(ub - lb > 1) {
        int mid = (lb + ub) / 2;
        if (A[mid] >= x)
        {
          ub = mid;
        }else{
          lb = mid;
        }
    }
    if (A[ub] == x)
    {
      ++ans;
    }
  }
}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  cout << ans << endl;
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  cin >> N;
  for (int i = 0; i < N; ++i)
  {
    scanf("%lld", &A[i]);
  }
  cin >> M;
  for (int i = 0; i < M; ++i)
  {
    scanf("%lld", &B[i]);
  }
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

Measured memory_bytes: 4248
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned long;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

    void Solve() {
        UL N, M, L; cin >> N >> M >> L;
        ULL arr1[100][100]; rep(y, N) rep(x, M) cin >> arr1[x][y];
        ULL arr2[100][100]; rep(y, M) rep(x, L) cin >> arr2[x][y];
        rep(y, N) {
            rep(x, L) {
                ULL ans = 0;
                rep(i, M) ans += arr1[i][y] * arr2[x][i];
                if (x) cout << " ";
                cout << ans;
            } cout << endl;
        }
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    cout << fixed << setprecision(10);
    p->Solve();
    return 0;
}



Measured memory_bytes: 3228
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define WRAP(y,x,h,w) (0<=y && y<h && 0<=x && x<w)

typedef long long ll;
typedef unsigned long long ull;
typedef string str;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int n;
	cin >> n;
	set<int> si;
	int cnt = 0;
	REP(i, n) {
		int a;
		cin >> a;
		if(a<3200)
		si.insert(a / 400);
		else
			cnt++;
	}
	int mi;

	mi= max(1, (int)si.size());
	int ma = (int)si.size() + cnt;
	cout << mi << " " << ma << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

arr = sorted(make_divisors(N))

if len(arr)%2==0:
  if arr[len(arr)//2-1]>=10 or arr[len(arr)//2]>=10:
    print('No')
  else:
    print('Yes')
else:
  if arr[len(arr)//2]>=10:
    print('No')
  else:
    print('Yes')


Measured memory_bytes: 3188
#include <iostream>
#include <stdio.h>
#include <algorithm>
#define eps 1e-9

using namespace std;

int n, k, t, u, v, l;
int d[205];

int main(void)
{
	cin >> n >> k >> t >> u >> v >> l;
	for(int i = 0; i < n; i++) cin >> d[i];
	d[n] = l;
	
	double ans = 0, rem = 0, pos = 0; int nx = 0, stk = 0;
	while(1){
		if(stk > 0 && rem < eps){
			rem = t;
			stk--;
		}
		if(rem < eps){
			double tm = (d[nx] - pos) / u;
			ans += tm;
			pos = d[nx];
			nx++;
			if(stk < k) stk++;
			else rem = t;
		}
		else{
			if(pos + rem * v < d[nx]){
				ans += rem;
				pos += rem * v;
				rem = 0;
			}
			else{
				double tm = (d[nx] - pos) / v;
				ans += tm;
				pos = d[nx];
				nx++;
				rem -= tm;
				if(stk < k) stk++;
				else rem = t;
			}
		}
		if(pos >= l - eps) break;
	}
	printf("%.11f\n", ans);
	
	return 0;
}


Measured memory_bytes: 3228
from collections import defaultdict

N = int(input())
S = input()
mod1 = 10 ** 9 + 7
mod2 = 10 ** 9 + 9
base1 = 1007
base2 = 2009

ok = 0
ng = N // 2 + 1
mid = (ok + ng) // 2
while ng - ok > 1:
    seen1 = defaultdict(lambda: 10 ** 5)
    seen2 = defaultdict(lambda: 10 ** 5)
    rh1 = 0
    rh2 = 0
    for i in range(mid):
        rh1 += ord(S[i]) * pow(base1, mid - i - 1, mod1)
        rh2 += ord(S[i]) * pow(base2, mid - i - 1, mod2)
        rh1 %= mod1
        rh2 %= mod2
    seen1[rh1] = 0
    seen2[rh2] = 0
    flag = 0
    for i in range(1, N - mid + 1):
        if flag == 1:
            break
        rh1 = (rh1 * base1 + ord(S[i + mid - 1]) - ord(S[i - 1]) * pow(base1, mid, mod1)) % mod1
        rh2 = (rh2 * base2 + ord(S[i + mid - 1]) - ord(S[i - 1]) * pow(base2, mid, mod2)) % mod2
        if i - seen1[rh1] >= mid and i - seen2[rh2] >= mid:
            ok = mid
            mid = (ok + ng) // 2
            flag = 1
        else:
            if seen1[rh1] == 10 ** 5:
                seen1[rh1] = i
            if seen2[rh2] == 10 ** 5:
                seen2[rh2] = i
    if flag == 0:
        ng = mid
        mid = (ok + ng) // 2

print(ok)


Measured memory_bytes: 48108
import scala.io.StdIn.readLine

object Main{
  def main(args: Array[String]): Unit = {
    val a = readLine.split(" ").map(_.toInt)
    var f = "=="
    if(a(0) < a(1)) {
      f = "<"
    }
    if(a(0) > a(1)) {
      f = ">"
    }
    printf("a %s b\n", f)
  }
}

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

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

    long double ans = 0.0;
    long double x;
    std::string u;
    for (int i = 0; i < N; i++) {
        std::cin >> x;
        std::cin >> u;
        if (u == "BTC") {
            x *= 380000.0;
        }
        ans += x;
    }

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

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define fi first
#define se second
#define MP make_pair

int read()
{
    int v = 0, f = 1;
    char c = getchar();
    while (c < 48 || 57 < c) {if (c == '-') f = -1; c = getchar();}
    while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar();
    return v * f;
}

const ll MOD = 1e9 + 7;

int p[1000000], n, m;

struct M
{
    ll a[4][4];
    M()
    {
        for (int i = 0; i < 4; i++)
            for (int j = 0; j < 4; j++)
                a[i][j] = 0;
    }
};

M operator * (const M &a, const M &b)
{
    M re;
    for (int i = 0; i < 4; i++)
        for (int j = 0; j < 4; j++)
            for (int k = 0; k < 4; k++)
                (re.a[i][j] += a.a[i][k] * b.a[k][j]) %= MOD;
    return re;
}

M pw(M a, ll b)
{
    M re;
    for (int i = 0; i < 4; i++) re.a[i][i] = 1;
    while (b)
    {
        if (b & 1)
            re = re * a;
        a = a * a;
        b >>= 1;
    }
    return re;
}

int main()
{
    n = read(), m = read();
    for (int i = 1; i <= m; i++) p[i] = read();
    p[0] = -1;
    M a;
    a.a[0][0] = 1, a.a[0][1] = 1, a.a[0][2] = 1, a.a[0][3] = 1;
    a.a[1][1] = 1, a.a[1][3] = 1;
    a.a[2][2] = 1, a.a[2][3] = 1;
    a.a[3][0] = 1, a.a[3][1] = 1, a.a[3][2] = 1, a.a[3][3] = 2;
    M b;
    b.a[0][0] = 1, b.a[0][1] = 1, b.a[0][2] = 1, b.a[0][3] = 1;
    b.a[1][1] = 1, b.a[1][3] = 1;
    b.a[2][2] = 1, b.a[2][3] = 1;
    b.a[3][3] = 1;
    M ans;
    for (int i = 0; i < 4; i++) ans.a[i][i] = 1;
    for (int i = 1; i <= m; i++)
    {
        ans = ans * pw(a, p[i] - p[i - 1] - 1);
        ans = ans * b;
    }
    ans = ans * pw(a, n - p[m] - 1);
    printf("%lld\n", ans.a[0][3]);
}


Measured memory_bytes: 640
n,m=gets.split.map &:to_i;
$p=(0..n).map{Array.new(11,0)};
$g=(0..n).map{[]};
m.times{a,b=gets.split.map &:to_i;$g[a].push(b);$g[b].push(a)}
def f(u,d,l)if d>=0&&$p[u][d]<1
$p[u][d]=l;$g[u].map{|v|f v,d-1,l}end end
q=gets.to_i;
d=$<.map &:split;
1.upto(q){|i|0.upto(d[-i][1].to_i){|a|f d[-i][0].to_i,a,d[-i][2].to_i}};
1.upto(n){|i|p$p[i][0]}

Measured memory_bytes: 95816
def gcd(x, y):
    if x > y:
        x, y = y, x
    while x > 0:
        x, y = y%x, x
    return y

def lcm(x, y):
    z = gcd(x, y)
    return x*y//z

if __name__ == "__main__":
    while True:
        try:
            a, b = map(int, input().split())
            g = gcd(a, b)
            l = lcm(a, b)
            print("{} {}".format(g, l))
        except:
            break



Measured memory_bytes: 5596
#![allow(unused_imports)]
#![allow(non_snake_case)]
use proconio::{input, fastout};
use proconio::marker::{Chars, Bytes, Usize1};

use std::cmp::Ordering;
use std::collections::BinaryHeap;

#[derive(Copy, Clone, Eq, PartialEq)]
struct State {
    cost: usize,
    y: usize,
    x: usize
}

impl Ord for State {
    fn cmp(&self, other: &State) -> Ordering {
        other.cost.cmp(&self.cost)
            .then_with(|| self.y.cmp(&other.y))
            .then_with(|| self.x.cmp(&other.x))
    }
}

impl PartialOrd for State {
    fn partial_cmp(&self, other: &State) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}


#[fastout]
fn main() {
    input!{
        H:usize, W:usize,
        ch:Usize1, cw:Usize1,
        dh:Usize1, dw:Usize1,
        g: [String; H]
    }
    let mut G: Vec<Vec<char>> = Vec::new();
    for x in g {
        G.push(x.chars().collect());
    }
    let arr: Vec<(i32, i32)> = vec![(0, 1), (1, 0), (0, -1), (-1, 0)];
    let mut dist = vec![vec![H*W; W]; H];
    dist[ch][cw] = 0;
    let mut q = BinaryHeap::new();
    q.push(State{cost:0, y:ch, x:cw});
    while let Some(State{cost, y, x}) = q.pop() {
        if cost > dist[y][x] { continue; };
        for &(du, dv) in &arr {
            let nu = y.wrapping_add(du as usize);
            let nv = x.wrapping_add(dv as usize);
            if nu < H && nv < W && G[nu][nv] == '.' && dist[nu][nv] > cost {
                dist[nu][nv] = cost;
                q.push(State{cost, y:nu, x:nv});
            }
        }
        for du in -2i32..3 {
            for dv in -2i32..3 {
                let nu = y.wrapping_add(du as usize);
                let nv = x.wrapping_add(dv as usize);
                if nu < H && nv < W && G[nu][nv] == '.' && dist[nu][nv] > cost + 1 {
                    dist[nu][nv] = cost + 1;
                    q.push(State{cost:cost + 1, y:nu, x:nv});
                }
            }
        }
    }
    let ans = dist[dh][dw];
    println!("{}", if ans == H * W {-1} else {ans as i32});
}


Measured memory_bytes: 15192
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){
   
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    
    string s;
    cin>>s;
    if(s=="ABC"){
        cout<<"ARC";
    }
    else{
        cout<<"ABC";
    }
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
typedef long long ll;
const int INF = 1e+9+7;

int main(){
    int N,A,B,C;
    cin >> N >> A >> B >> C;
    vector<int> l(N);
    rep(i,N) cin >> l[i];
    int d_l=INF;
    int l_a=0;
    int l_b=0;
    int l_c=0;

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

    do{
        rep2(num,3,N+1){
            rep2(i,1,num-1){
                rep2(j,i+1,num){
                    l_a=0;
                    l_b=0;
                    l_c=0;
                    rep(k,i){
                        l_a+=l[k];
                    }

                    rep2(k,i,j){
                        l_b+=l[k];
                    }

                    rep2(k,j,num){
                        l_c+=l[k];
                    }
                    d_l=min(d_l,10*(num-3)+abs(l_a-A)+abs(l_b-B)+abs(l_c-C));
                    d_l=min(d_l,10*(num-3)+abs(l_a-B)+abs(l_b-C)+abs(l_c-A));
                    d_l=min(d_l,10*(num-3)+abs(l_a-C)+abs(l_b-A)+abs(l_c-B));
                    d_l=min(d_l,10*(num-3)+abs(l_a-A)+abs(l_b-C)+abs(l_c-B));
                    d_l=min(d_l,10*(num-3)+abs(l_a-B)+abs(l_b-A)+abs(l_c-C));
                    d_l=min(d_l,10*(num-3)+abs(l_a-C)+abs(l_b-B)+abs(l_c-A));

                }
            }
        }
        
    }while(next_permutation(l.begin(),l.end()));

    
    cout << d_l << endl;
}

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

#define ll long long
#define endl "\n"

ll a[100005],n,k,dp[100006];

ll solve(ll i){
    if(i==n-1)  return 0;
    if(i>=n)    return INT_MAX;
    if(dp[i]!=-1)   return dp[i];
    ll ans=INT_MAX;
    for(ll j=i+1;j<=min(n,i+k);j++){
        ans=min(ans,abs(a[i]-a[j])+solve(j));
    }
    return dp[i]=ans;
}

int main(){
    memset(dp, -1, sizeof dp);
    cin >> n >> k;
    for(ll i=0;i<n;i++)
        cin >> a[i];
    cout << solve(0) << endl;
    return 0;
}

Measured memory_bytes: 11364
import math as m
N,K = map(int,input().split())
A = list(map(int,input().split()))
order_1 = A.index(1) + 1
l = []
if order_1 <= K or order_1 >= N-K+1:
  print(m.ceil((N - K)/(K - 1)) + 1)
else:
  for i in range(K):
    count_r = m.ceil((N - order_1 - i)/(K - 1))
    count_l = m.ceil((order_1 + i - K)/(K - 1))
    count_total = count_r + count_l + 1
    l.append(count_total)
  print(min(l))

Measured memory_bytes: 13812
#include <iostream>

int main(){
    
    int a, b;
    
    std::cin >> a >> b;
    if(a * b % 2 == 0){
        std::cout << "Even" << std::endl;
    }
    else{
        std::cout << "Odd" << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#include<assert.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")
#define charsize 100005 //10^5+5

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a= c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    // char ;
    // ll n,ans=0;
    // scanf("%lld",&n);
    ll c[3][3],a[3],b[3];
    rep(i,0,3){
        rep(j,0,3) scanf("%lld",&c[i][j]);
    }
    a[0]=0;
    rep(i,0,3){
        b[i]=c[0][i]-a[0];
    }
    rep(i,1,3){
        a[i]=c[i][0]-b[0];
    }
    if(c[1][1]==a[1]+b[1] && c[1][2]==a[1]+b[2] && c[2][1]==a[2]+b[1] && c[2][2]==a[2]+b[2]){
        YES;
    }else{
        NO;
    }

    
    // printf("%lld\n");
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cctype>
using namespace std;

namespace zyt
{
	template<typename T>
	inline bool read(T &x)
	{
		char c;
		bool f = false;
		x = 0;
		do
			c = getchar();
		while (c != EOF && c != '-' && !isdigit(c));
		if (c == EOF)
			return false;
		if (c == '-')
			f = true, c = getchar();
		do
			x = x * 10 + c - '0', c = getchar();
		while (isdigit(c));
		if (f)
			x = -x;
		return true;
	}
	template<typename T>
	inline void write(T x)
	{
		static char buf[20];
		char *pos = buf;
		if (x < 0)
			putchar('-'), x = -x;
		do
			*pos++ = x % 10 + '0';
		while (x /= 10);
		while (pos > buf)
			putchar(*--pos);
	}
	typedef long long ll;
	typedef pair<int, int> pii;
	const int N = 1e5 + 10;
	const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
	int n, A[N], B[N];
	pii buf[N << 1];
	ll ans;
	ll solve()
	{
		ll sum = 0;
		bool flag = false;
		static bool vis[N];
		memset(vis, 0, sizeof(bool[n + 1]));
		for (int i = 1; i <= n; i++)
		{
			sum += buf[i].first;
			if (vis[buf[i].second])
				flag = true;
			else
				vis[buf[i].second] = true;
		}
		if (!flag)
			return LINF;
		else
			return sum;
	}
	int work()
	{
		read(n);
		for (int i = 1; i <= n; i++)
			read(A[i]), read(B[i]), buf[i] = pii(A[i], i), ans += A[i];
		ll sum = 0;
		for (int i = 1; i <= n; i++)
			buf[i + n] = pii(B[i], i), sum += B[i];
		ans = min(ans, sum);
		sort(buf + 1, buf + (n << 1) + 1);
		ans = min(ans, solve());
		swap(buf[n], buf[n + 1]);
		ans = min(ans, solve());
		swap(buf[n], buf[n + 2]);
		ans = min(ans, solve());
		swap(buf[n], buf[n + 2]);
		swap(buf[n - 1], buf[n + 1]);
		ans = min(ans, solve());
		write(ans);
		return 0;
	}
}
int main()
{
	return zyt::work();
}

Measured memory_bytes: 3980
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let S: String = sc.get();
    if S.ends_with("s") {
        println!("{}{}", S, "es");
    } else {
        println!("{}{}", S, "s")
    }
}


Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);
    vi p(N);
    Rep(i,N) Scd(p[i]), p[i]--;

    vi a(N);
    vi b(N);
    Rep(i,N) a[i] = N*i+1;
    Rep(i,N) b[i] = N*N-N*i;

    Rep(i,N) a[p[i]] += i;
    // Rep(i,N) printf ("%d\n", a[p[i]] + b[p[i]] );
    Rep(i,N) printf ("%d%s", a[i], i==N-1?"\n":" " );
    Rep(i,N) printf ("%d%s", b[i], i==N-1?"\n":" " );

    return 0;
}



Measured memory_bytes: 896
A, B = [int(A) for A in input().split()] 
socket = 0
count = 0
if B==1 :
    count=0
elif B != 0 :
    while socket < B :
        if socket + A < B :
            socket = socket + A - 1
            count += 1
        elif socket+A >= B :
            socket = socket + A
            count += 1
print(count)


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<iomanip>

#define EPS (1e-10)
using namespace std;
#define PI (3.1415926535)

int main(){
	string a, b;
	vector<int> m, n, s;
	int set;

	m.resize(81, 0);
	n.resize(81, 0);
	s.resize(81, 0);

	cin >> set;
	while(set-- > 0){
		cin >> a >> b;
		for(int i = 0; i < 81; i++){
			m[i] = n[i] = s[i] = 0;
		}		
		if(a.size() > 80 || b.size() > 80){
			cout << "overflow" << endl;
		}else{
			reverse(a.begin(), a.end());
			reverse(b.begin(), b.end());
			for(int i = 0; i < a.size(); i++){
				m[i] = a[i] - '0';
			}
			for(int i = 0; i < b.size(); i++){
				n[i] = b[i] - '0';
			}
			for(int i = 0; i < 80; i++){
				s[i] += m[i] + n[i];
				if(s[i] >= 10){
					s[i+1]++;
					s[i]-=10;
				}
			}
			int digit = 81;
			while(--digit > 0){
				if(s[digit] != 0){
					break;
				}
			}
			if(digit >= 80){
				cout << "overflow" << endl;
			}else{
				for(int i = digit; i >= 0; i--){
					cout << s[i];
				}
				cout << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define ssort(a) sort(a.begin(), a.end())
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n){
    cin >> a[i];
  }
  int r=1, sum=a[0], xxor=a[0];
  ll ans=0;
  rep(i, n){
    int l=i;
    if(i!=0){
      sum-=a[i-1];
      xxor^=a[i-1];
    }
    while(r<n && sum+a[r]==(xxor^a[r])){
      sum+=a[r];
      xxor^=a[r];
      r++;
      //cout << sum << " " << xxor << " " << r << endl;
    }

    //cout << l <<  " " << r << endl;
    if(sum!=xxor)continue;
    ans+=r-l;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4064
// 2020-07-24 09:19:21
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

const int INF = 1e9+5;
int dist[300][300];
void answer() {
  int n, m, l;
  cin >> n >> m >> l;
  rep(i, n) rep(j, n) {
    if(i == j) dist[i][j] = 0;
    else dist[i][j] = INF;
  }
  rep(i, m) {
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    dist[a][b] = dist[b][a] = c;
  }
  rep(k, n) rep(i, n) rep(j, n) {
    chmin(dist[i][j], dist[i][k] + dist[k][j]);
  }
  rep(i, n) rep(j, n) {
    if(i == j) dist[i][j] = 0;
    else if(dist[i][j] <= l) dist[i][j] = 1;
    else dist[i][j] = INF;
  }
  rep(k, n) rep(i, n) rep(j, n) {
    chmin(dist[i][j], dist[i][k] + dist[k][j]);
  }
  int q;
  cin >> q;
  rep(qi, q) {
    int s, t;
    cin >> s >> t;
    s--; t--;
    if(dist[s][t] == INF) cout << -1 << '\n';
    else cout << dist[s][t] - 1 << '\n';
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3948
def e_roaming(MOD=10**9 + 7):
    N, K = [int(i) for i in input().split()]

    class Combination(object):
        """参考: https://harigami.net/contents?id=5f169f85-5707-4137-87a5-f0068749d9bb"""
        __slots__ = ['mod', 'factorial', 'inverse']

        def __init__(self, max_val_arg: int = 10**6, mod: int = 10**9 + 7):
            fac, inv = [1], []
            fac_append, inv_append = fac.append, inv.append

            for i in range(1, max_val_arg + 1):
                fac_append(fac[-1] * i % mod)

            # inv_append(pow(fac[-1], -1, mod)) (after Python 3.8)
            inv_append(pow(fac[-1], mod - 2, mod))

            for i in range(max_val_arg, 0, -1):
                inv_append((inv[-1] * i) % mod)

            self.mod, self.factorial, self.inverse = mod, fac, inv[::-1]

        def combination(self, n, r):
            r = min(r, n - r)
            if n < 0 or r < 0 or n < r:
                return 0
            return self.factorial[n] * self.inverse[r] * self.inverse[n - r] % self.mod

    comb = Combination(N).combination
    if K >= N:
        K = N - 1  # N 回以上移動することは、N-1 回移動することと同じ結果を生む
    return sum(comb(N, k) * comb(N - 1, k) % MOD for k in range(K + 1)) % MOD

print(e_roaming())

Measured memory_bytes: 20524
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long   ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<ll, ii>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9;
const double PI = acos(-1);
#define offset 
const ll MOD= 998244353;
#define initseg ll new_nodo=(nodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 300000
int dp[tam][3],v[tam];
int n;
int f(int pos,int ant)
{
    if (pos==n)
        return 0;
    if (dp[pos][ant]!=-1)
        return dp[pos][ant];

    return dp[pos][ant]=max(f(pos+1,v[pos]-min(ant,v[pos]))+min(ant,v[pos]),
                            f(pos+1,0)+(ant+v[pos])/2);
}
int  main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    memset(dp,-1,sizeof dp);
    cin>>n;
    ll tot=0,valor,ant=0;
    forr(i,0,n)
    {
        cin>>valor;
        if (valor%2==1)
            v[i]=1,tot+=valor/2;
        else
            v[i]=min(valor,2ll),tot+=(valor-v[i])/2;
        //cout<<v[i]<<" ";
    }
    //cout<<endl<<tot<<endl;
    cout<<tot+f(0,0)<<endl;
}
// PLUS ULTRA!!

Measured memory_bytes: 8832
#include <iostream>
#include <utility>
#include <queue>
#include <memory>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)

using namespace std;
using ll = long long;
const int mod = 1e9+7;

int main(){
    ll n;
    ll ans = 0;
    cin >> n;
    ans = n*(n-1)/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import math
N = int(input())
CSF = [list(map(int,input().split())) for _ in range(N-1)]

ans = [0] * N

for i in range(N-1):
    tmp = CSF[i][1] + CSF[i][0]
    for j in range(i+1,N-1):
        if tmp <= CSF[j][1]:
            tmp = CSF[j][1] + CSF[j][0]
        else:               
            tmp = CSF[j][0] + math.ceil((tmp - CSF[j][1])/CSF[j][2]) * CSF[j][2] + CSF[j][1]       

    ans[i] = tmp
    print(ans[i])
        
print(ans[N-1])
        


Measured memory_bytes: 3188
#include <stdio.h>

long long int N, X;

long long int gcd(long long int m, long long int n)
{
	while (n != 0)
	{
		long long int temp = m % n;
		m = n;
		n = temp;
	}
	return m;
}

int main(void)
{
	scanf("%lld%lld", &N, &X);
	printf("%lld\n", 3 * (N - gcd(N, X)));
	return 0;
}

Measured memory_bytes: 128
/**
 *   @FileName	f.cpp
 *   @Author	kanpurin
 *   @Created	2020.09.13 22:14:43
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int n;cin >> n;
    vector<int> a(n),b(n);
    vector<pair<int,int>> cnt_a(n),cnt_b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        cnt_a[a[i]-1].first++;
        cnt_a[a[i]-1].second = i;
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        cnt_b[b[i]-1].first++;
        cnt_b[b[i]-1].second = i;
    }
    int max_idx = -1;
    int max_cnt = -1;
    for (int i = 0; i < n; i++) {
        if (!(cnt_a[i].first > 0 && cnt_b[i].first > 0)) continue;
        if (max_cnt < cnt_b[i].first) {
            max_cnt = cnt_b[i].first;
            max_idx = i;
        }
        if (cnt_a[i].first + cnt_b[i].first > n) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    
    
    
    
    
    
    
    vector<int> end_a(n,-1);
    int t = 0;
    for (int i = 0; i < n; i++) {
        while (t < n && a[t] == i + 1) t++;
        if (t > 0 && a[t-1] == i+1) end_a[i] = t;
    }
    vector<int> start_b(n,-1);
    t = 0;
    for (int i = 0; i < n; i++) {
        while (t < n && b[t] < i + 1) t++;
        if (t < n && b[t] == i+1) start_b[i] = t;
    }
    int zurasi = 0;
    for (int i = 0; i < n; i++) {
        if (end_a[i] == -1 || start_b[i] == -1) continue;
        zurasi = max(zurasi,max(end_a[i] - start_b[i],0));
    }
    for (int i = 0; i < n; i++) {
        cout << b[(i-zurasi+n)%n] << " ";
    }
    
    
    
    cout << endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    int cnt[100002] = {};
    rep(i, N){
        int a; cin >> a;
        cnt[a]++; cnt[a+1]++;
        if(a > 0) cnt[a-1]++;
    }
    int ans = 0;
    rep(i, 100002) if(cnt[ans] < cnt[i]) ans = i;
    cout << cnt[ans] << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
   int n;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++)
   {
      cin>>a[i];
   }
   sort(a,a+n);
   for(int i=0;i<n;i++)
   {
      if(i>0)
         cout<<" ";
      cout<<a[i];
   }
   cout<<endl;
   return 0;
}

Measured memory_bytes: 10896
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll gcd(int a,int b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(int a,int b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll INFS=1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);

int main() {
  int n;
  cin>>n;
  string s,t;
  cin>>s>>t;
  int cnt=0;
  rep(i,n){
    bool ja=true;
    int k=n-i-1;
    for(int j=0;j<=i;j++){
      if(s[k]!=t[j]) ja=false;
      k++;
    }
    if(ja) cnt=i+1;
  }
  cout<<len(s)*2-cnt<<endl;
}

Measured memory_bytes: 3644
from math import fabs


def main():
  S = list(input())
  result = 1000
  target = 753
  for i in range(len(S) - 2):
    s = int(S[i] + S[i+1] + S[i+2])
    s = int(fabs(target - s))
    result = min(s, result)
  print(result)

main()

Measured memory_bytes: 3060
/***********************************************************
 *This code By @1353055672(Ligen)                          *
 *[Warning]You're not excepted to understand this code!    *
 *NOIP 2019 RP++                                           *
 ***********************************************************/
//#pragma GCC optimize(3)
#define ADD_STACK int size = 512 << 20;\
    char *pp = (char*)malloc(size) + size;  \
    __asm__("movl %0, %%esp\n" :: "r"(pp))
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<bitset>
#include<ctime>
#include<vector>
#define ll long long
#define ull unsigned long long
#define mn 200020
#define Max(x,y) ((x>y)?x:y)
#define Min(x,y) ((x<y)?x:y)
#define Abs(x) (((x)<(0))?(-(x)):(x))
#define infll (ll)(1e18)
#define infint (1<<30)
#define mod (int)(1e9+7)
#define FOR(a,b,c) for (register int a=b;a<=c;++a)
#define FORD(a,b,c) for (register int a=b;a>=c;--a)
using namespace std;
//char buf[1<<20],*p1=buf,*p2=buf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
inline ll read(){
    ll x=0,f=1;char c;
    for(c=getchar();c<'0'||c>'9';f=((c=='-')?-1:f),c=getchar());
    for(;c>='0'&&c<='9';x=x*10+c-'0',c=getchar());return x*f;
}
template<typename T>
inline void write(T a){
    if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
    while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
}
inline void write_(){return;}
template<typename T,typename... Args>
inline void write_(T a,Args... b){write(a);putchar(' ');write_(b...);}
inline void writeln(){putchar('\n');return;}
template<typename T,typename... Args>
inline void writeln(T a,Args... b){write(a);putchar(' ');writeln(b...);}
//need c++11

//inline void write(ll a){
//    if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
//    while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
//}
//inline void write_(ll a){write(a);putchar(' ');}
//inline void writeln(ll a){write(a);putchar('\n');}
inline ll gcd(ll a,ll b){return a==0?b:gcd(b%a,a);}
inline ll lcm(ll a,ll b){return 1ll*a/gcd(a,b)*b;}
inline ll Pow(ll n,ll a){ll b=1;while(a){if(a&1)b=1ll*b*n%mod;n=1ll*n*n%mod;a>>=1;}return b;}
//---------------------Head Files--------------------------//
ll n,m,a[mn],b[mn],f[2020][2020];
signed main(){
	#ifdef _WIN32
        freopen("0.in","r",stdin);
//        freopen("0.out","w",stdout);
//        ADD_STACK;
        long double be=clock();
    #endif
	n=read(),m=read();
	FOR(i,1,n)a[i]=read();
	FOR(i,1,m)b[i]=read();
	FOR(i,1,n)
		FOR(j,1,m)if(a[i]==b[j])
			f[i][j]=(f[i-1][j]+f[i][j-1]+1)%mod;
		else f[i][j]=(f[i-1][j]+f[i][j-1]-f[i-1][j-1]+mod)%mod;
	writeln((f[n][m]+1)%mod);
	#ifdef _WIN32
        long double en=clock();
        printf("Time: %.0Lfms\n",en-be);
        fclose(stdin);fclose(stdout);
    #endif
    return 0;
}


Measured memory_bytes: 35072
package main

import "fmt"

func main() {
	var n, m uint
	fmt.Scan(&n, &m)

	lightBulbs := make([][]int, m)
	for i := range lightBulbs {
		var k int
		fmt.Scan(&k)
		lightBulbs[i] = make([]int, k)
		for j := range lightBulbs[i] {
			fmt.Scan(&lightBulbs[i][j])
		}
	}

	ps := make([]int, m)
	for i := range ps {
		fmt.Scan(&ps[i])
	}

	var ans int
	for i := 0; i < (1 << n); i++ {
		flag := true
		onOff := fmt.Sprintf("%010b", i)
		for j, l := range lightBulbs {
			match := 0
			for k := range l {
				if onOff[len(onOff)-l[k]] == '1' {
					match++
				}
			}
			if match%2 != ps[j] {
				flag = false
				break
			}
		}
		if flag == true {
			ans++
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
import java.util.Scanner;
class Main{
    public static void main(String arg[]){
        Scanner scn=new Scanner(System.in);
        int n = scn.nextInt();
        int answer=1;
        if(n<105){
            System.out.println(0);
        }else{
            for(int i= 107;i<=n;i+=2){
                int cnt=0;
                for(int j=1;j<=i;j+=2){
                    if(i%j==0){
                        cnt++;
                    }
                }
                if(cnt==8) answer++;
            }
            System.out.println(answer);
        }
    }
}

Measured memory_bytes: 22100
h,w = map(int,input().split())
a = []
for i in range(h):
    s=list(input())
    a.append(s)

x = 0
y = 0

c = 0
a[0][0] = '.'
while x != w-1 or y != h-1:
    r = 0
    if x <= w-2:
        if a[y][x+1] == '#':
            r = 1
            a[y][x+1] = '.'
    if y <= h-2:
        if a[y+1][x] == '#':
            r += 2
            a[y+1][x] = '.'
    if x >= 1:
        if a[y][x-1] == '#':
            r = 0
    if y >= 1:
        if a[y-1][x] == '#':
            r = 0
    if r == 2:
        y += 1
    if r == 1:
        x += 1
    if x == w-1 and y == h-1:
        if a[y-1][x] == '.' and a[y][x-1] == '.':
            c = 1
    if r == 0 or r == 3:
        c = -1
        x = w-1
        y = h-1

    

    
if c == 1:
    print('Possible')
else:
    print('Impossible')

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <set>
#define int long long
using namespace std;

int arr[100010],dp[100010];

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n,i;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>arr[i];
		if(i>1)
			dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i]-arr[i-2]));
		else if(i)
			dp[i]=abs(arr[i]-arr[i-1]);
	}
	cout<<dp[n-1]<<'\n';
	
	return 0;
}


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

using namespace std;

typedef long long ll;

// AtCoder Beginner Contest 133 D - Rain Flows into Dams - ねむーの日記~AtCoderな日々~ https://nemurin-blog.hatenablog.com/entry/2019/07/07/232302
int main() {
    int N; cin>>N;
    vector<ll> A(N);
    for (int i=0;i<N;i++) cin>>A[i];

    ll sum=0, halfSum=0;
    for (int i=0;i<N;i++) {
        sum += A[i];
        if (i%2==1) halfSum += 2*A[i];
    }

    vector<ll> ans(N);
    ans[0] = sum - halfSum;
    for (int i=0;i<N-1;i++) {
        ans[i+1] = 2*A[i] - ans[i];
    }
    
    for (int i=0;i<N;i++) cout << ans[i] << " ";
    cout << endl;
}

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

int main() {
  long long A, B;
  cin >> A >> B;
  
  long long common = 1;
  long long a = 1;
  
  long long i = 2;
  while (A != 1) {
    if (A % i == 0 && B % i == 0) {
      common *= i;
      A /= i;
      B /= i;
      continue;
    } else if (A % i == 0 && B % i != 0) {
      a *= i;
      A /= i;
      continue;
    }
    i++;
  }

  long long ans = common * a * B;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256