akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int gcd(ll a, ll b){
    if(a < b) swap(a, b);
    if(a % b == 0){
        return(b);
    }
    else{
        return(gcd(b, a%b));
    }
}

int main(){
    ll A, B; cin >> A >> B;
    ll x = gcd(A, B);
    ll ans = A / x * B;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

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

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

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n, m;
    cin >> n >> m;
    int tmp = m / n;
    vector< int > v = Div( m );

    int res = 0;
    for( int i = 0; i < v.size(); ++i ) {
        if( v[i] <= tmp ) {
            res = v[i];

        }
    }

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



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

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

    ll i,j,k,l,m,n,w,x,y,z,p,q,tmp,sum=0;
    string str;
    cin>>n;
    cout<<n*2*M_PI;

    return 0;
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a;
	vector<int>v(4);
	for(int i=0;i<6;i++){
		cin>>a;
		v[a]++;
	}
	bool f=true;
	for(int i=0;i<=4;i++){
		if(v[i]>=3) f=false;
	}
	if(f){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}


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

int main(){
    using namespace std;
    const unsigned long MOD = 1000000007;
    unsigned long N, K;
    cin >> N >> K;
    unsigned long R{0}, L{N + 1};
    while(R + 1 < L){
        auto m = (L + R) / 2;
        (m * m > N ? L : R) = m;
    }
    auto f = [&MOD](auto i, auto j){return (i + j) % MOD;};
    auto g = [&MOD](auto i, auto j){return i * j % MOD;};

    vector<unsigned long> tapi(L), tape(L), tapi1(L), tape1(L), tapi2(L), tape2(L);
    vector<unsigned long> uku(L);
    for(size_t i = 1; i < L; ++i)uku[i] = N / i - R;
    fill(tapi1.begin() + 1, tapi1.end(), 1);
    copy(uku.begin() + 1, uku.end(), tape1.begin());
    partial_sum(tapi1.begin(), tapi1.end(), tapi1.begin(), f);
    partial_sum(tape1.rbegin(), tape1.rend(), tape1.rbegin(), f);
    fill(tapi2.begin() + 1, tapi2.end(), 1);
    for(unsigned long i = 1; i <= K; ++i){
        fill(tapi.begin() + 1, tapi.end(), tapi1.back());
        for(size_t j = 1; j < L; ++j)tapi[j] += (tapi2[j] * uku[j] + tape2[j]) % MOD;
        transform(uku.begin() + 1, uku.end(), tapi.begin() + 1, tape.begin(), g);
        partial_sum(tapi.begin(), tapi.end(), tapi.begin(), f);
        partial_sum(tape.rbegin(), tape.rend(), tape.rbegin(), f);
        swap(tapi1, tapi2);
        swap(tape1, tape2);
        swap(tapi, tapi1);
        swap(tape, tape1);
        fill(tapi.begin(), tapi.end(), 0);
        fill(tape.begin(), tape.end(), 0);
    }
    cout << tapi1[1] << endl;
    return 0;
}

Measured memory_bytes: 1920
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
int ABS(int a){return max(a,-a);}
int main(){
	int a,b,c;
	while(scanf("%d%d%d",&a,&b,&c),a){
		if(c==0){
			if(a==1&&b<0){
				printf("%d %d %d %d\n",1,0,a,b);
			}else printf("%d %d %d %d\n",a,b,1,0);
			continue;
		}
		vector<int>x1;
		vector<int>x0;
		for(int i=1;i*i<=a;i++){
			if(a%i)continue;
			x1.push_back(i);
			if(i*i!=a)x1.push_back(a/i);
		}	
		for(int j=1;j*j<=ABS(c);j++){
			if(c%j==0){
				x0.push_back(j);
				x0.push_back(-j);
				if(j*j!=ABS(c)){
					x0.push_back(c/j);
					x0.push_back(-(c/j));
				}
			}
		}
		bool ok=false;
		for(int i=0;i<x1.size();i++){
			if(ok)break;
			for(int j=0;j<x0.size();j++){
				int p=x1[i];
				int q=x0[j];
				int r=a/p;
				int s=c/q;
				if(p*s+q*r==b){
					if(p<r||(p==r&&q<s)){
						swap(p,r);swap(q,s);
					}
					printf("%d %d %d %d\n",p,q,r,s);
					ok=true;break;
				}
			}
		}
		if(!ok)printf("Impossible\n");
	}
}

Measured memory_bytes: 1064
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

using Weight=long long;
static const Weight INF=1LL<<57;

template <class T>
using gp_queue=priority_queue<T, deque<T>, less<T>>;

struct Arc {
    // accessible to the reverse edge
    size_t src, dst;
    Weight capacity, cost, flow;
    size_t rev;
    Arc() {}
    Arc(size_t src, size_t dst, Weight capacity, Weight cost=0):
        src(src), dst(dst), capacity(capacity), cost(cost), flow(0), rev(-1)
    {}
    Weight residue() const {
        return capacity - flow;
    }
};

bool operator<(const Arc &e, const Arc &f) {
    if (e.cost != f.cost) {
        return e.cost > f.cost;
    } else if (e.capacity != f.capacity) {
        return e.capacity > f.capacity;
    } else {
        return e.src!=f.src? e.src<f.src : e.dst<f.dst;
    }
}

using Arcs=vector<Arc>;
using Node=vector<Arc>;
using FlowNetwork=vector<Node>;

void connect(FlowNetwork &g, size_t s, size_t d, Weight c=1, Weight k=0) {
    g[s].push_back(Arc(s, d, c, k));
    g[d].push_back(Arc(d, s, 0, -k));

    g[s].back().rev = g[d].size()-1;
    g[d].back().rev = g[s].size()-1;
}

void join(FlowNetwork &g, size_t s, size_t d, Weight c=1, Weight k=0) {
    g[s].push_back(Arc(s, d, c, k));
    g[d].push_back(Arc(d, s, c, k));

    g[s].back().rev = g[d].size()-1;
    g[d].back().rev = g[s].size()-1;
}

pair<Weight, Weight> mincost_flow(
    FlowNetwork &g, size_t s, size_t t, Weight F=INF
) {
    size_t V=g.size();
    pair<Weight, Weight> total;  // <cost, flow>
    while (F > total.second) {
        vector<Weight> d(V, INF); d[s]=0;
        vector<Arc *> prev(V, NULL);
        for (size_t i=0; i<V; ++i) {
            bool updated=false;
            for (size_t v=0; v<V; ++v) {
                if (d[v] == INF) continue;
                for (Arc &e: g[v]) {
                    if (e.capacity <= 0) continue;

                    if (d[e.dst] > d[e.src] + e.cost) {
                        d[e.dst] = d[e.src] + e.cost;
                        prev[e.dst] = &e;
                        updated = true;
                    }
                }
            }

            if (!updated) break;
        }

        if (d[t] == INF) {
            total.first = -1;
            return total;
        }

        Weight f=F-total.second;
        for (Arc *e=prev[t]; e!=NULL; e=prev[e->src])
            f = min(f, e->capacity);

        total.second += f;
        total.first += f * d[t];
        for (Arc *e=prev[t]; e!=NULL; e=prev[e->src]) {
            e->capacity -= f;
            g[e->dst][e->rev].capacity += f;
        }
    }

    return total;
}

int main() {
    size_t V, E;
    Weight F;
    scanf("%zu %zu %lld", &V, &E, &F);

    FlowNetwork g(V);
    for (size_t i=0; i<E; ++i) {
        size_t u, v;
        Weight c, d;
        scanf("%zu %zu %lld %lld", &u, &v, &c, &d);

        connect(g, u, v, c, d);
    }

    printf("%lld\n", mincost_flow(g, 0, V-1, F).first);
    return 0;
}

Measured memory_bytes: 2884
import java.io.*;
import java.util.StringTokenizer;
import java.util.Arrays;

class Main {
	public static int max = 0;

	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int[][] s = new int[100][51];
		int[][] res = new int[100][51];
		int yp = 0;

		for (int i=0;i<100;i++)	{
			Arrays.fill(s[i],-1);
			Arrays.fill(res[i],0);
		}

		try {
			s[yp++][0] = Integer.parseInt(br.readLine());

			int xp = 0;
			while (true) {
				StringTokenizer st = new StringTokenizer(br.readLine(),",");
				int count = st.countTokens();
				for (int i=0;i<count;i++) {
					s[yp][xp++] = Integer.parseInt(st.nextToken());
				}
				if (count==1) break;
				xp = 0;
				yp++;
			}

			//check_s(s,yp);

			res[0][0] = s[0][0];
			for (int i=1;i<=yp;i++) {
				for (int j=0;s[i][j]!=-1;j++) {
					if (i<=(yp/2)) {
						if (j==0) {
							res[i][j] = res[i-1][j]+s[i][j];
						} else if (s[i-1][j]==-1) {
							res[i][j] = res[i-1][j-1]+s[i][j];
						} else {
							int t1 = res[i-1][j]+s[i][j];
							int t2 = res[i-1][j-1]+s[i][j];
							if (t1>t2) res[i][j] = t1;
							else res[i][j] = t2;
						}
					} else {
						int t1 = res[i-1][j]+s[i][j];
						int t2 = res[i-1][j+1]+s[i][j];
						if (t1>t2) res[i][j] = t1;
						else res[i][j] = t2;
					}
				}
			}
			System.out.println(res[yp][0]);

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static void check_s(int[][] s,int yp) {
		for (int i=0;i<=yp;i++) {
			int j = 0;
			while (s[i][j]!=-1) System.out.print(s[i][j++]);
			System.out.println();
		}
	}
}

Measured memory_bytes: 24952
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let d: usize = scan(tokens);
    let x = 2 * d + 1;
    println!("{}", (n + x - 1) / x);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

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

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
constexpr int MOD = 1000000007;
constexpr int INF = 1e18;

using namespace std;


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

  vector<pair<int, int>> p(N);
  REP(i, N){
    cin >> p[i].first >> p[i].second;
  }

  sort(ALL(p),   // dai -> syou
      [](pair<int, int> const & l, pair<int, int> const &  r){
      return atan2(l.first, l.second) > atan2(r.first, r.second);
      });

  double ans = 0.0;
  REP(i, N) REP(j, N+1){
    int cnt = 0;
    double X = 0.0, Y = 0.0;
    while(cnt < j){
      X += p[i+cnt<N?i+cnt:i+cnt-N].first;
      Y += p[i+cnt<N?i+cnt:i+cnt-N].second;
      cnt++;
    }
    chmax(ans, sqrt(X*X+Y*Y));
  }
  printf("%.15lf\n", ans);

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <sstream>
#include <string>
#include <queue>
using namespace std;

int parent(int i){
	return i/2;
}

int left(int i){
	return 2*i;
}

int right(int i){
	return 2*i +1;
}

int maxheapify(vector <int> &X, int i){
	int l, r;
	l = left(i);
	r = right(i);

	if (r <=X[0] && X[r] > X[i] && X[l] < X[r]){
		swap(X[r], X[i]);
		maxheapify(X, r);
	}
	else if (l <= X[0] && X[l] > X[i]){
		swap(X[l], X[i]);
		maxheapify(X, l);
	}
	return 0;
}

int buildmaxheap(vector <int> &X){
	for (int i= X[0]/2; i>0; i--){
		maxheapify(X, i);
	}
	return 0;
}

int maxheapinsert(vector <int> &X, int key){
	
	if (X[0]<X.size()-1){
		X[0]++;
		X[X[0]] = key;
	}
	else{
		X[0]++;
		X.push_back(key);
	}
	int i = X[0], p = parent(i);
	while (i > 1 && X[p] < X[i]){
		swap(X[i], X[p]);
		i = p;
		p = parent(i);
	}
	return 0;
}

int heapincreasekey(vector <int> &X, int i, int key){
	if (i > X[0] || key < X[i]) return NULL;
	X[i] = key;
	int p=parent(i);
	while (i > 1 && X[p] < X[i]){
		swap(X[i], X[p]);
		i = p;
		p = parent(i);
	}
	return 0;
}

int heapextractmax(vector <int> &X){
	if (X[0] < 1) return NULL;

	int maxheap = X[1];
	X[1] = X[X[0]--];
	maxheapify(X, 1);
	return maxheap;
}
int print(vector <int> &X){
	int *tmp = &X[0];
	for (int i=1; i<=X[0]; i++){
		tmp++;
		cout<<*tmp<<" ";
	}
	cout<<endl;
	return 0;
}

int str2int(string text){
    stringstream buf;
    int n;
 
    buf<<text;
    buf>>n;
    return n;
}

int main(void){
	int n;
	priority_queue <int> X;
	string text;

	while (true){
		cin>>text;
		if (text[2] == 'd'){
			break;
		}
		else if (text[0] == 'i'){
			cin>>n;
			X.push(n);
		}
		else if (text[0] == 'e'){
			cout<<X.top()<<endl;
			X.pop();
		}
	}
	return 0;
} 

Measured memory_bytes: 6752
#include <iostream>

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    int maxl = 1, minr = n;
    for (int i = 0; i < m; i++){
        int lhs, rhs;
        cin >> lhs >> rhs;
        maxl = max(maxl, lhs);
        minr = min(minr, rhs);
    }
    int ans = minr - maxl + 1;
    cout << max(ans, 0) << endl;
}


Measured memory_bytes: 256
package main

import "fmt"
import "bufio"
import "os"
import "strconv"

var _sw = bufio.NewScanner(os.Stdin)

func main() {
	N := NextInt()

	var (
		T = make([]int, N+1)
		F = make([]int, N)
	)
	for i := range T {
		T[i] = NextInt()
	}
	for i := range F {
		F[i] = NextInt()
	}

	C := make([]int, N*2)
	for k := 0; k < N; k++ {
		if k == 0 {
			C[0] = Min(T[0], F[0])
		} else {
			C[2*k] = Min(T[k]-C[2*k-1], F[k])
		}
		C[2*k+1] = Min(T[k+1], F[k]-C[2*k])
	}

	sum := 0
	for _, c := range C {
		sum += c
	}
	fmt.Println(sum)
}

func init() {
	_sw.Split(bufio.ScanWords)
}

func NextInt() int {
	if _sw.Scan() == false {
		panic(_sw.Err())
	}
	i, e := strconv.Atoi(_sw.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func NextString() string {
	if _sw.Scan() == false {
		panic(_sw.Err())
	}
	return _sw.Text()
}

func Max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func Min(x, y int) int {
	if x > y {
		return y
	}
	return x
}


Measured memory_bytes: 6272
#include<string>
#include<sstream>
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<ios>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<type_traits>
#include<random>
#include<vector>
#include<map>

using namespace std;


int main()
{
	string S;
	cin >> S;
	int cnt_0 = 0;
	int cnt_1 = 0;
	for(int i=0;i<S.size();i++)
	{
		if(S[i]=='0')
		{
			cnt_0 = cnt_0 + 1;
		}
		else
		{
			cnt_1 = cnt_1 + 1;
		}
	}
	cout << 2*min(cnt_0,cnt_1) << endl;


}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define N 100005
#define pb push_back
vector<int>adj[N];
vector<bool>vis(N,false);
int cnt=0;
void dfs(int v)
{   
    vis[v]=true;
    for(auto it:adj[v])
        if(!vis[it])
            dfs(it);
}
int main()
{
  int h,w,n;
  cin>>h>>w>>n;
  if(n%max(h,w)==0)
    cout<<n/max(h,w);
  else
    cout<<n/max(h,w)+1;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll MOD = 998244353;
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}

const int N = 300300;
int n;
char s[N];
int a[4];
int b[4];
ll ans = 1;

int getId(char c) {
	if (c == 'R') return 0;
	if (c == 'G') return 1;
	if (c == 'B') return 2;
	throw;
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d %s", &n, s);
	a[0] = n;
	for (int i = 0; i < 3 * n; i++) {
		int p = getId(s[i]);
		b[p]++;
		int q = 0;
		for (int j = 0; j < 3; j++)
			if (b[j] > b[p])
				q++;
		b[p]++;
		ans = mult(ans, a[q]);
		a[q]--;
		a[q + 1]++;
	}
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int[] A = new int[M];
		for(int i = 0; i < M; i++) {
			A[i] = sc.nextInt();
		}
		for(int i = 0; i < M - 1; i++) {
			if(X < A[0] || X > A[M - 1]) {
				System.out.println(0);
				break;
			}
			if(X > A[i] && X < A[i+1]) {
				if(i < (M / 2)) {
					System.out.println(i + 1);
					break;
				}else if(i == (M / 2)){
					System.out.println(Math.min(i + 1, M - (i + 1)));
					break;
				}else{
					System.out.println(M - (i + 1));
					break;
				}
			}
		}
		sc.close();
	}

}


Measured memory_bytes: 23124
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
using NX = System.Int64;


public class Prog
{
    public static void Solve()
    {
        int r = NextInt();
        Console.WriteLine(r*r);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
        return;
    }
    public static long RepPow(long x, long p, long m = 1000000007)
    {
        if (p == 1) return x % m;
        long b = RepPow(x, p / 2, m) % m;
        if (p % 2 == 0) { return (b * b) % m; }
        else { return (x * ((b * b) % m)) % m; }
    }
}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int n,k;
vector<int > h;
vector<long> cost;


long solve(int i){
	if(i==0){
		cost[i]=0;
		return cost[i];
	}
	else if(i==1){
		cost[i]=abs(h[1]-h[0]);
	}
	else if(cost[i]!=-1)
		return cost[i];
	else{
		cost[i]=10000000000;
		for(int j=1;j<=k;j++){
			if(i-j<0)break;
			cost[i]=min((abs(h[i-j]-h[i])+solve(i-j)),cost[i]);
		}
		//cost[i]=min(abs(h[i-1]-h[i])+solve(i-1),(abs(h[i-2]-h[i])+solve(i-2)));
		return cost[i];
	}

}


	
int main(){
	cin>>n;
	cin>>k;
	h.assign(n,0);
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	cost.assign(n,-1);
	cout<<solve(n-1);
	return 0;
}



Measured memory_bytes: 9216
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

N = II()
T = ILI()
M = II()
PX = [list(ISI()) for _ in range(M)]
for i in range(M):
    tmp = T[PX[i][0]-1]
    T[PX[i][0]-1] = PX[i][1]
    print(sum(T))
    T[PX[i][0]-1] = tmp

Measured memory_bytes: 3064
n, m = map(int, input().split())
A = list()
for i in range(n):
	A.append(list(map(int, input().split())))
B = list()
for i in range(m):
	B.append(int(input()))
for i in range(n):
	ans = 0
	for j in range(m):
		ans += A[i][j] * B[j]
	print(ans)


Measured memory_bytes: 6004
import java.util.*;
public class Main {
	static List<Integer> henkan(String n){
		List<Integer> m = new ArrayList<Integer>();
		for(int i=0;i<n.length();i++)m.add(Integer.parseInt(n.charAt(i)+""));
		return m;
	}
	
	static int big (List<Integer> m){
		String a = "";
		Collections.sort(m);
		for(int s=m.size()-1;s>=0;s--)a+=m.get(s);
		return Integer.parseInt(a);
	}
	static int small (List<Integer> m){
		String a = "";
		Collections.sort(m);
		for(int s=0;s<m.size();s++)a+=m.get(s);
		return Integer.parseInt(a);
	}
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		for(int k=0;k<n;k++){
			String input = in.next();
			List<Integer> m = henkan(input);
			System.out.println(big(m)-small(m));
		}
	}
}

Measured memory_bytes: 17208
#include<bits/stdc++.h>
#define maxn 520300
using namespace std;
typedef long long ll;
ll ans,a[maxn],b[maxn],sum,n,r;
bool cmp(int x,int y){
    return x>y;
}

int main(){
    cin >> n;
    for (int i=0;i<n;i++){
        scanf("%lld%lld",&a[i],&b[i]);
        if (a[i]>0) ans=max(ans,a[i]*2);
        if (b[i]<0) ans=max(ans,-b[i]*2);
    }
    sort(a,a+n+1,cmp); sort(b,b+n+1); sum=0; int j=0;
    for (j=0;j<=n;j++) if (a[j]-b[j]>0) sum+=a[j]-b[j];
    ans=max(ans,sum*2);
    cout << ans << endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; ++i) {
        int p, q;
        cin >> p >> q;
        a[i] = make_pair(p, q);
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < n; ++i) cout << a[i].first << " " << a[i].second << endl;
}



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

int main(){
    char n[3];
    cin>>n;
    int i;
    for(i=0; i<3; i++){
        if(n[i]=='1'){
            n[i]='9';
        }
        else if(n[i]=='9'){
            n[i]='1';
        }
    }
    cout<<n<<endl;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define print(x) cout<<(x)<<'\n'
using ll=long long;
using pl=pair<ll,ll>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vs=vector<string>;

bool inRange(ll h, ll w, ll H, ll W) {return (0 <= h && h < (H-2) && 0 <= w && w < (W-2));}

void solve() {
    ll H,W,N;
    cin >> H >> W >> N;
    map<pl, ll> color;
    ll a,b;
    rng(i,0,N){
        cin >> a >> b;
        a--;b--;
        rng(dh, 0, 3) {
            rng(dw, 0, 3) {
                ll h = a - (ll)dh;
                ll w = b - (ll)dw;
                if(!inRange(h,w,H,W)) continue;
                pl p = make_pair(h,w);
                color[p]++;
            }
        }
    }
    vl ans(10, 0);
    for(auto p:color){
        auto x = p.first;
        ll val = p.second;
        ans[val]++;
    }
    ans[0] = (H-2)*(W-2) - color.size();
    for(auto an:ans) print(an);
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}


Measured memory_bytes: 59896
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <unordered_map>

using namespace std;


int main() {
   

    int x;
    cin >> x;
    cout << x*x*x << endl;


}


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

#[allow(unused_macros)]
macro_rules! echo {
    ($($e:expr),+) => ( { $(println!("{}", $e))+ } );
}

fn main() {
    input! {
        n: usize,
    }

    let n = n % 10;

    if n == 3 {
        echo!("bon");
    } else if n == 0 || n == 1 || n == 6 || n == 8 {
        echo!("pon");
    } else {
        echo!("hon");
    }
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
using ll = long long;
using P = pair<ll, ll>;

const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void fail() {
    cout << -1 << endl;
    exit(0);
}

int main(){
    ll n, h, w;
    cin >> n >> h >> w;
    ll cnt = 0, a, b;
    for(ll i=0; i < n; i++){
        cin >> a >> b;
        if(a >= h && b >= w){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
//g++  7.4.0

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll N; cin>>N;
    ll arr[N];
    ll pre[N];
    ll MAXX = 1e18;
    ll dp[N][N];
    
    for(ll i=0;i<N;++i)
    {
        cin>>arr[i];
        pre[i] = ((i > 0) ? pre[i - 1] : 0) + arr[i];
    }
    
    for(ll diff=0;diff<N;++diff)
    {
        for(ll i=0;i<N;++i)
        {
            ll j = i + diff;
            if(j >= N)
                continue;
            
            dp[i][j] = MAXX;
            
            if(diff == 0)
            {
                dp[i][j] = 0;
                continue;
            }
            
            for(ll k=i;k<j;++k)
            {
                ll one = pre[j];
                ll two = ((i > 0) ? pre[i - 1] : 0);
                dp[i][j] = min(dp[i][j],dp[i][k] + dp[k + 1][j] + one - two);
            }
        }
    }
    
    cout<<dp[0][N - 1]<<endl;
}

Measured memory_bytes: 4880
#include <stdio.h>
int main(){
  int a,b,op;

  while(1){
    scanf("%d %c %d",&a,&op,&b);
    if(op == '+'){
      printf("%d\n",a+b);
    }
    else if(op == '-'){
      printf("%d\n",a-b);
    }
    else if(op == '*'){
      printf("%d\n",a*b);
    }
    else if(op == '/'){
      printf("%d\n",a/b);
    }
    else break;
  }
  return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;
public class Main {
		public static void main(String[] args){
	    	Scanner sc =new Scanner(System.in);
	    	int a = sc.nextInt();
	    	int b = sc.nextInt();
	    	double c= sc.nextInt();	
	    	if(a + b >= c) {
				System.out.println("Yes");
			}
	    	else {
	    		System.out.println("No");
	    	}
	    	
	    }
	}


Measured memory_bytes: 21844
import sys
table={}
def dfs(a,b):
    global table
    if not (a,b) in table:
        if a==0:return 1
        elif b==0 or a < 0:return 0
        table[(a,b)]=sum([dfs(a-i,b-1) for i in xrange(10)])
    return table[(a,b)]
for i in sys.stdin.readlines():
    print dfs(int(i.strip()),4)

Measured memory_bytes: 4236
#include <bits/stdc++.h>
using namespace std; using ll=int_fast64_t; using ld=long double; using pll=pair<ll,ll>; using pld=pair<ld,ld>; const ll INF=1LL<<60;
void solve(); int main(){cin.tie(0); ios::sync_with_stdio(false); cout<<fixed<<setprecision(10); solve();}
#define fi first
#define se second
#define SELECTOR(_1,_2,_3,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}
template<class T> void contout(const T &v){for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n"))cout<<*it;}

void solve(){
  ll n,m,p; cin>>n>>m>>p;
  vector<tuple<ll,ll,ll>> E;
  vector<vector<ll>> to(n),ot(n);
  vector<ll> state(n);
  rep(_,m){
    ll a,b,c; cin>>a>>b>>c;
    --a; --b;
    to[a].push_back(b);
    ot[b].push_back(a);
    E.emplace_back(a,b,p-c);
  }
  // dfs
  function<void(ll)> dfs=[&](ll v){
    if(state[v]&1) return;
    state[v]+=1;
    for(ll nv:to[v]) dfs(nv);
  };
  dfs(0);
  function<void(ll)> rdfs=[&](ll v){
    if(state[v]&2) return;
    state[v]+=2;
    for(ll nv:ot[v]) rdfs(nv);
  };
  rdfs(n-1);
  // Bellman-Ford
  vector<ll> d(n,INF);
  d[0]=0;
  rep(step,n){
    for(auto tup:E){
      ll a,b,c;
      tie(a,b,c)=tup;
      if(!(state[a]&1) || !(state[b]&2)) continue;
      if(chmin(d[b],d[a]+c) && step==n-1){
        cout<<-1<<"\n";
        return;
      }
    }
  }
  cout<<max(-d[n-1],(ll)0)<<"\n";
}

Measured memory_bytes: 896
#include<iostream>
#include<cstdio>
using namespace std;
int main ()
{
  long long int a[45];
  a[0]= 1;
  a[1] = 1;
  for(int i = 2;i<=44;i++)
     a[i] = a[i-1]+a[i-2];
  int n;
  scanf("%d",&n);
  printf("%lld\n",a[n]);
  return 0 ;
}



Measured memory_bytes: 3212
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  map<int,int> m;
  REP(i,N){
    int A;
    cin>>A;
    m[A]++;
  }
  int temp;
  for(auto e:m){
    if(e.second%2==0)temp++;
  }
  if(temp%2==0)cout<<m.size()<<endl;
  else cout<<m.size()-1<<endl;
  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
typedef long long ll;

int main(){
	string s;
	cin >> s;
	int l = s.size();
	int num_one = 0;
	int num_zero = 0;
	rep(i,l){
		if(s[i]=='0'){
			num_zero ++;
		}else{
			num_one ++;
		}
	}
	cout << 2*min(num_one, num_zero);
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define re register
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int n,m,a[200002],b[200002],c[200002],ans;
vector<int>h[200002],s[200002],r1[400002],l1[400002],l2[400002],r2[400002];
int main(){
	n=read();ans=1e8;
	for(re int i=1;i<=n;++i)a[i]=read(),b[i]=read(),c[i]=getchar();
	for(re int i=1;i<=n;++i){
		if(c[i]=='D')s[a[i]].push_back(b[i]);
		if(c[i]=='L')h[b[i]].push_back(a[i]);
		if(c[i]=='L')l1[b[i]-a[i]+200000].push_back(a[i]),l2[b[i]+a[i]].push_back(a[i]);
		if(c[i]=='R')r1[a[i]+b[i]].push_back(a[i]),r2[b[i]-a[i]+200000].push_back(a[i]);
	}
	for(re int i=0;i<=200000;++i)s[i].push_back(1e8),h[i].push_back(1e8),sort(s[i].begin(),s[i].end()),sort(h[i].begin(),h[i].end());
	for(re int i=0;i<=400000;++i)l1[i].push_back(1e8),r1[i].push_back(1e8),l1[i].push_back(-1e8),r1[i].push_back(-1e8),l2[i].push_back(1e8),r2[i].push_back(1e8),l2[i].push_back(-1e8),r2[i].push_back(-1e8),sort(l1[i].begin(),l1[i].end()),sort(l1[i].begin(),l1[i].end()),sort(l2[i].begin(),l2[i].end()),sort(r1[i].begin(),r1[i].end()),sort(r2[i].begin(),r2[i].end());
	for(re int i=1,x;i<=n;++i){
		if(c[i]=='U'){
			x=*lower_bound(s[a[i]].begin(),s[a[i]].end(),b[i]);
			ans=min(ans,(x-b[i])*5);
		}
		if(c[i]=='R'){
			x=*lower_bound(h[b[i]].begin(),h[b[i]].end(),a[i]);
			ans=min(ans,(x-a[i])*5);
		}
		if(c[i]=='U'){
			x=*(--upper_bound(r1[a[i]+b[i]].begin(),r1[a[i]+b[i]].end(),a[i]));
			ans=min(ans,(a[i]-x)*10);
			x=*(lower_bound(l1[b[i]-a[i]+200000].begin(),l1[b[i]-a[i]+200000].end(),a[i]));
			ans=min(ans,(x-a[i])*10);
		}
		if(c[i]=='D'){
			x=*(--upper_bound(r2[b[i]-a[i]+200000].begin(),r2[b[i]-a[i]+200000].end(),a[i]));
			ans=min(ans,(a[i]-x)*10);
			x=*(lower_bound(l2[b[i]+a[i]].begin(),l2[b[i]+a[i]].end(),a[i]));
			ans=min(ans,(x-a[i])*10);
		}
	}
	if(ans^100000000)printf("%d",ans);
	else puts("SAFE");
}

Measured memory_bytes: 116996
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;cin>>S;
  int k;cin>>k;
  int n=S.size();
  set<string> st;
  for(int j=1;j<=k;j++){
    for(int i=j-1;i<n;i++){
      string s="";
      for(int t=i+1-j;t<=i;t++){
        s+=S[t];
      }
      st.insert(s);
    }
  }
  for(int i=0;i<k-1;i++){
    string s=*begin(st);
    st.erase(s);
  }
  cout<<*begin(st)<<endl;
}

Measured memory_bytes: 1664
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
#pragma warning(disable:4996)
int n, c[120000]; long double x[60000], r[60000], a1[60000], a2[60000];
bool solve(long double p) {
	vector<long double>v; v.push_back(-1e9);
	for (int i = 0; i < n; i++) {
		if (r[i] < p) { a1[i] = -1e9; a2[i] = -1e9; continue; }
		long double e = sqrtl(r[i] * r[i] - p*p);
		a1[i] = x[i] - e; v.push_back(a1[i]);
		a2[i] = x[i] + e; v.push_back(a2[i]);
	}
	sort(v.begin(), v.end());
	for (int i = 0; i <= v.size() + 200; i++)c[i] = 0;
	for (int i = 0; i < n; i++) {
		if (a1[i] < -1e8)continue;
		int pos1 = lower_bound(v.begin(), v.end(), a1[i]) - v.begin();
		int pos2 = lower_bound(v.begin(), v.end(), a2[i]) - v.begin();
		c[pos1]++; c[pos2]--;
	}
	for (int i = 1; i <= v.size() + 1; i++)c[i] += c[i - 1];
	long double maxn = 0, ret = -1e9;
	for (int i = 1; i < v.size(); i++) {
		if (c[i - 1] == 0 && c[i] >= 1) { ret = v[i]; }
		if (c[i - 1] >= 1 && c[i] == 0) { maxn = max(maxn, v[i] - ret); }
	}
	if (maxn >= p*2.0l)return true;
	return false;
}
int main() {
	while (true) {
		cin >> n; if (n == 0)break;
		for (int i = 0; i < n; i++)scanf("%Lf%Lf", &x[i], &r[i]);
		for (int i = 0; i < n; i++) { a1[i] = 0; a2[i] = 0; }
		long double L = 0.0l, R = 1.2e5, M;
		for (int i = 0; i < 60; i++) {
			M = (L + R) / 2;
			if (solve(M) == true)L = M;
			else R = M;
		}
		printf("%.16Lf\n", M * 2.0l);
	}
	return 0;
}

Measured memory_bytes: 10160
#include <iostream>
#include <vector>
#include <cstdlib>
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;
}
const long long INF = 1LL << 60;
long long dp[100100];
int main(void){
	
    int N;cin>>N;
	int K;cin>>K;  
	for(int i=0;i<100100;i++)dp[i]=INF;
	long long h[N+100]={0};
    for(int i=0;i<N;i++)cin>>h[i];
    dp[0]=0;
    for(int i=0;i<N;i++){
      	for(int j=1;j<=K;j++){
        	chmin(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
        }
    }
    cout<<dp[N-1]<<endl;
    return 0;
}


Measured memory_bytes: 1792
N,M=map(int,input().split())
inp=[list(map(int,input().split())) for _ in range(M)]
g=[[] for _ in range(N)]
[g[a-1].append(b-1) for a,b in inp]
[g[b-1].append(a-1) for a,b in inp]
 
from itertools import permutations
seq=[i for i in range(N)]
test=list(permutations(seq))
cnt=0
for t in test:
    if t[0]==0:
        for i in range(N-1):
            if t[i+1] not in g[t[i]]:
                break
        else:
            cnt+=1
print(cnt)

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

struct UF {
	UF *p;
	int s, a;
	UF() :p(nullptr), s(1), a(0) {}
	UF *Find() {
		if (p == nullptr)
			return this;
		return p = p->Find();
	}
	int Union(UF &n) {
		auto *r = Find(), *nr = n.Find();
		if (r == nr) return 0;
		if (r->s < nr->s) swap(r, nr);
		nr->p = r, r->s += nr->s;
		r->a += nr->a;
		return 1;
	}
} u[222222];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < 100000; i++)
		u[i + 1].a = 1;
	for (int i = 0; i < n; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		u[x].Union(u[y + 100000]);
	}
	long r = 0;
	for (int i = 0; i < 200000; i++)
		if (u[i + 1].p == nullptr)
			r += u[i + 1].a*long(u[i + 1].s - u[i + 1].a);
	cout << r - n << endl;
	return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

int days[100005][3];
int d[100005][3];
int dp(int prev, int i, int n);
vector<int> opt(int x);

int main()
{
  memset(d, -1, sizeof d);
  int n;
  cin >> n;
  for(int i = 1; i <= n; i++) cin >> days[i][0] >> days[i][1] >> days[i][2];
  cout << dp(-1, 1, n) << endl;
}

int dp(int prev, int i, int n)
{
  if(i > n) return 0;
  if(d[i][prev] != -1) return d[i][prev];
  int a = opt(prev)[0], b = opt(prev)[1];
  if(opt(prev).size() == 3)
  {
    int c = opt(prev)[2];
    d[i][prev] = max(max(dp(a, i + 1, n) + days[i][a], dp(b, i + 1, n) + days[i][b]), dp(c,i + 1, n) + days[i][c]);
    return d[i][prev];
  }
  //cout << prev << ' ' << a << ' ' << b << endl;
  d[i][prev] = max(dp(a, i + 1, n) + days[i][a], dp(b, i + 1, n) + days[i][b]);
  return d[i][prev];
}

vector<int> opt(int x)
{
  vector<int> t;
  for(int i = 0; i < 3; i++)
  {
    if(i != x) t.push_back(i); 
  }
  return t;
}

Measured memory_bytes: 13568
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(){

  int n;
  int d;
  int i;
  int cnt = 0;

  scanf("%d %d", &n, &d);

  i = 2*d + 1;

  while(n > 0){
    n = n - i;
    cnt++;
  }

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

  return 0;
}


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

using namespace std;

int pow(int a,int b){
    int ans=1;
    for (int i = 0; i < b; ++i) {
        ans=ans*a;
    }
    return ans;
}

int main() {
    int a,b;
    cin>>a>>b;
    if(a>8||b>8)cout<<":("<<endl;
    else cout<<"Yay!"<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const int maxn = 100010;
const int mod = 1e9+7;

int n = 0, p1 = 0, p2 = 0;
ll A, B, S[maxn];

int sum[2][maxn<<2], tag[2][maxn<<2];

void pushUp(int ty, int rt) {
	sum[ty][rt] = (sum[ty][rt<<1] + sum[ty][rt<<1|1]) % mod;
}

void clear(int ty, int rt) {
	tag[ty][rt] = 1;
	sum[ty][rt] = 0;
}

void pushDown(int ty, int rt) {
	if (tag[ty][rt]) {
		clear(ty, rt<<1);
		clear(ty, rt<<1|1);
		tag[ty][rt] = 0;
	}
}

void update(int ty, int p, int v, int l, int r, int rt) {
	if (l == r) {
		sum[ty][rt] = (sum[ty][rt] + v) % mod;
		return;
	}
	pushDown(ty, rt);
	int m = (l + r) >> 1;
	if (p <= m) update(ty, p, v, l, m, rt<<1);
	else update(ty, p, v, m+1, r, rt<<1|1);
	pushUp(ty, rt);
}

int query(int ty, int L, int R, int l, int r, int rt) {
	if (L > R) return 0;
	if (L <= l && r <= R) return sum[ty][rt];
	int ret = 0;
	pushDown(ty, rt);
	int m = (l + r) >> 1;
	if (L <= m) ret = (ret + query(ty, L, R, l, m, rt<<1)) % mod;
	if (R > m) ret = (ret + query(ty, L, R, m+1, r, rt<<1|1)) % mod;
	return ret;
}

void print(int ty) {
	for (int i = 1; i <= n; i++) printf("%d ", query(ty, i, i, 1, n, 1));
	printf("\n");
}

int main() {
	scanf("%d%lld%lld", &n, &A, &B);
	for (int i = 1; i <= n; i++) scanf("%lld", &S[i]);
	update(0, 0, 1, 0, n, 1);
	update(1, 0, 1, 0, n, 1);
	for (int i = 2; i <= n; i++) {
		while (p1+1 < i && S[i] - S[p1+1] >= A) ++ p1;
		while (p2+1 < i && S[i] - S[p2+1] >= B) ++ p2;
		int v1 = query(0, 0, p2, 0, n, 1);
		int v2 = query(1, 0, p1, 0, n, 1);
		if (S[i] - S[i-1] < A) {
			clear(0, 1);
		}
		if (S[i] - S[i-1] < B) {
			clear(1, 1);
		}
		update(1, i-1, v1, 0, n, 1);
		update(0, i-1, v2, 0, n, 1);
	}
	printf("%d\n", (sum[0][1] + sum[1][1]) % mod);
	return 0;
}

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

int main() {
  long long a,b;
  long long v,w;
  long long t;
  cin >> a >> v;
  cin >> b >> w;
  cin >> t;

  if(v > w){
    if(abs(b-a) <= (v-w)*t){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

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

	int N;
	cin >> N;

	VI A(N + 2);
	REP(i, N) cin >> A[i + 1];
	A[0] = A[N + 1] = 0;

	LL sum = 0;
	FOR(i, 0, N + 1){
		sum += abs(A[i] - A[i + 1]);
	}

	FOR(i, 1, N + 1){
		LL tmp = 0;
		tmp -= abs(A[i - 1] - A[i]) + abs(A[i] - A[i + 1]);
		tmp += abs(A[i - 1] - A[i + 1]);
		cout << sum + tmp << endl;
	}

	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n - 1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
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; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{	
	int n, m; cin >> n >> m;
	vector<vector<int>> a(n,vector<int>(m));
	rep(i,n)rep(j,m)cin >> a[i][j];
	vector<int> b(m);
	rep(i,m)cin >> b[i];
	rep(i,n)
	{
		int ans = 0;
		rep(j,m)
		{
			ans +=a[i][j] * b[j];
		}
		cout << ans << endl;
	}
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}



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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

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

    int S=s.size();
    int a=-1, b=-1;

    bool found=false;
    //2文字
    rep(i,S-1)
    {
        if(s[i]==s[i+1])
        {
            a=i+1;
            b=i+2;
            found=true;
            break;
        }
    }

    if(!found)
    {
        //3文字
        rep(i,S-2)
        {
            if(s[i]==s[i+2])
            {
                a=i+1;
                b=i+3;
                found=true;
                break;
            }
        }
    }

    printf("%d %d\n",a,b);
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll x;
    cin >> x;
    for(ll i = 0; i <= 1000; i++)
    {
        for(ll j = -1000; j <= 1000; j++)
        {
            if(i * i * i * i * i - j * j * j * j * j == x)
            {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3592
s = input()
s_start = -1
s_end = -1

for i in range(len(s)):
    if i == len(s)-1:
        break
    elif i ==  len(s)-2:
        if s[i] == s[i+1]:
            s_start = i+1
            s_end = i+2
            break
    elif s[i] == s[i+1]:
        s_start = i+1
        s_end = i+2
        break
    elif s[i] == s[i+2]:
        s_start = i+1
        s_end = i+3
        break
print(s_start,s_end)




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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int N;
  cin>>N;
  ll ans=0;
  for(int i=1;i<N;i++){
    ll r=1000001;
    ll l=0;
    ll m;
    while(r-l>1){
      m=(r+l)/2;
      if(i*m<N)l=m;
      else r=m;
    }
    ans+=l;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int>A(1010);
    for(int i=0;i<N;++i)cin>>A[i];
    
    bool flag=true;
    for(int i=0;i<N;++i){
        if(A[i]%2==0){
            if(A[i]%3!=0&&A[i]%5!=0){
                flag=false;
                break;
             }
        }
    }
    if(flag==true)cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;
}


Measured memory_bytes: 256
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;


string days[7] = {"SUN", "MON","TUE","WED","THU","FRI","SAT"};

int main() {
    string s; cin >> s;
    for (int i = 0; i < 7; ++i) {
        if (s == days[i])
            cout << (7-i) << endl;
    }
    return 0;
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

int main() {
  int N, A[100000];

  cin >> N;
  for(int i = 0; i < N; i++) cin >> A[i];

  int ret = 0;
  for(int i = 0; i < N; i++) ret ^= A[i];

  for(int i = 0; i < N; i++) A[i] ^= A[i] - 1;

  int bit = 0;
  for(int i = 0; i < N; i++) bit |= 1 << (__builtin_popcount(A[i]) - 1);

  int add = 0;
  for(int i = 30; i >= 0; i--) {
    if((ret >> i) & 1) {
      if((bit >> i) & 1) {
        ret ^= -1;
        ++add;
      } else {
        cout << -1 << endl;
        return 0;
      }
    }
  }

  cout << add << endl;
}


Measured memory_bytes: 640