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

using ll = long long;
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}

int main()
{
    ll N, W; cin >> N >> W;
    vector<ll> w(N), v(N);
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }

    ll ans = 0;
    map<ll, ll> dp;
    dp[0] = 0;
    for (int i = 0; i < N; i++) {
        map<ll, ll> t(dp);
        for (auto p : t) {
            ll sum_w = p.first + w[i];
            ll sum_v = p.second + v[i];
            if (sum_w <= W) {
                if (chmax(dp[sum_w], sum_v)) {
                    chmax(ans, sum_v);
                }
            }
        }
    }

    cout << ans << endl;    
}


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

const double EPS = 1e-10;
bool equals(double a, double b) {
	return fabs(a - b) < EPS;
}

class Point {
public:
	double x, y;

	Point(double x = 0, double y = 0): x(x), y(y) {}

	Point operator + (Point p) {
		return Point(x + p.x, y + p.y);
	}
	Point operator - (Point p) {
		return Point(x - p.x, y - p.y);
	}
	Point operator * (double k) {
		return Point(k * x, k * y);
	}
	Point operator / (double k) {
		return Point(x / k, y / k);
	}

	double norm() {
		return x * x + y * y;
	}
	double abs() {
		return sqrt(norm());
	}

	bool operator < (const Point &p) const {
		return x != p.x ? x < p.x : y < p.y;
	}

	bool operator == (const Point &p) const {
		return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
	}
};

typedef Point Vector;

double dot(Vector a, Vector b) {
	return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
	return a.x * b.y - a.y * b.x;
}

void check(Vector v0, Vector v1) {
	double c = cross(v0, v1);
	if (equals(c, 0)) {
		if (dot(v0, v1) < 0) cout << "ONLINE_BACK";
		else if (v1.norm() > v0.norm()) cout << "ONLINE_FRONT";
		else cout << "ON_SEGMENT";
	} else if (c > 0) {
		cout << "COUNTER_CLOCKWISE";
	} else {
		cout << "CLOCKWISE";
	}
	cout << endl;
}

int main() {
	int x0, y0, x1, y1, q;
	cin >> x0 >> y0 >> x1 >> y1 >> q;
	Vector v0 = Vector(x1 - x0, y1 - y0);
	int x2, y2;
	for (int i = 0; i < q; i++) {
		cin >> x2 >> y2;
		Vector v1 = Vector(x2 - x0, y2 - y0);
		check(v0, v1);
	}
	return 0;
}

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

using namespace std;

int main() {
	int K, X;
	cin >> K >> X;
	if (K == 1) {
		cout << X;
		return 0;
	}
	else {
		int i = 1;
		while (1) {
			cout << X - K + i << " ";
			i++;
			if (K + X == X - K + i) {
				return 0;
			}
		}
	}


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  int a, b;
  cin >> a >> b;

  cout << a + (b / 2) << endl;


  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc() {
	ll n, m;
	ll ans = 0;

	cin >> n >> m;

	vector<P> q(m);

	ll s, c;
	rep(i, m) {
		cin >> s >> c;
		q[i] = make_pair(s, c);
	}

	V d(n, -1);
	rep(i, m) {
		s = q[i].first - 1;
		c = q[i].second;
		if (d[s] != -1) {
			if (d[s] != c) {
				cout << "-1" << "\n";
				return;
			}
		}
		else {
			d[s] = c;
		}
	}

	if (n == 1 && d[0] <= 0) {
		cout << "0" << "\n";
		return;
	}

	if (n >= 2 && d[0] == 0) {
		cout << "-1" << "\n";
		return;
	}

	rep(i, n) {
		if (d[i] == -1) {
			if (i == 0) {
				cout << "1";
			}
			else {
				cout << "0";
			}
		}
		else {
			cout << d[i];
		}
	}

	cout << "\n";
}

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

	solve_abc();

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    long long int N;
    cin >> N;
    
    if(N%2==1) {
        cout << 0 << endl;
        return 0;
    }
    
    long long int ans=0;
    long long int fif=10;
    while(fif<=N) {
        ans += N/fif;
        fif *= 5;
    }
    
    cout << ans << endl;

    return 0;
    
}

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

int main(){
    int n, m=0; cin >> n;
    vector<int> a(n), b;
    vector<bool> hasBall(n, false);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = n-1; i >= 0; i--){
        int cnt = 0;
        for(int j = i; j < n; j += i+1){
            if(hasBall[j]) cnt++;
        }
        if((cnt%2)!=a[i]){
            hasBall[i] = true;
            b.push_back(i);
            m++;
        }
    }
    cout << m << endl;
    for(int i = m-1; i >= 0; i--){
        cout << b[i]+1;
        if(i) cout << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
#define ll int
#define ld double
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pll pair <ll,ll>
#define nl "\n"
const int L = 1<<22 + 5;
ll n;
ll a[22][22];
ll dp[L];
ll fx(ll mask)
{
	ll idx = __builtin_popcount(mask);
	if(idx == n)
	{
		if(mask == (1<<n) - 1)
			return dp[mask]=1;
		else
			return dp[mask]=0;
	}
	if(dp[mask] != -1)
		return dp[mask];
	ll su = 0;
	for(int i=0;i<n;i++)
	{
		if(mask&(1<<i))
			continue;
		if(a[idx][i])
		{
			if(dp[mask | (1<<i)] != -1)
				su = (su + dp[mask | (1<<i)])%mod;
			else
				su = (su + fx(mask | (1<<i)))%mod;
		}
	}
	return dp[mask] = su;
} 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	ll i,j;
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
			cin>>a[i][j];
	for(i=0;i<L;i++)
		dp[i]=-1;
	cout<<fx(0)<<nl;
	return 0;
}

Measured memory_bytes: 527852
#include<algorithm>
#include<cstdio>
int change(int n)
{
	int k=n,p=0;
    while(k%2==0)
	{
        p++;
        k/=2;
    }
    return p;
}
bool cmp(int a,int b)
{
	return change(a)<change(b);
}
int n,t=0,num[205];
int main()
{
	scanf("%d",&n);
	for(;t<n;t++)
	{
		scanf("%d",&num[t]);
	}
	std::stable_sort(num,num+n,cmp);
	printf("%d",change(num[0]));
}

Measured memory_bytes: 256
import java.text.DecimalFormat;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        DecimalFormat df = new DecimalFormat("0.00000000");

        final int N = Integer.parseInt(sc.next());
        final int M = Integer.parseInt(sc.next());
        int sum = 0;
        for (int i = 0; i < M; i++) {
            sum += Integer.parseInt(sc.next());
        }
        out.println(N >= sum ? N - sum : "-1");
        
        out.flush();
    }
}

Measured memory_bytes: 41704
import collections
N = int(input())
A = list(map(int, input().split()))
S = [0]
for i in range(len(A)):
  S.append(A[i]+S[i])
L = list(collections.Counter(S).values())
s = 0
for l in L:
  s += int((l-1)*l//2)
print(s)

Measured memory_bytes: 41696
#include <bits/stdc++.h>
using namespace std;
int main(){
long long n,a,b;
cin>>n>>a>>b;
long long s=n/(a+b);
long long sum=s*a;
long long t=n%(a+b);
if(t>=a)sum+=a;
else sum+=t;
cout<<sum<<endl;

}

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;
const long mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   long field[128][128];
   void solve() {
      for(long i = 0; i < 128; ++i) {
         for(long k = 0; k < 128; ++k) {
            field[i][k] = 0;
         }
      }
      long h, w; scan(h, w);
      long n; scan(n);
      LI xs(n); for(long &x : xs) scan(x);
      long dx[4] = {0, 0, 1, -1};
      long dy[4] = {1, -1, 0, 0};
      long x = 0, y = 0;
      long c = 0;
      loop {
         field[y][x] = c + 1;
         xs[c] -= 1;
         if( xs[c] == 0 ) c += 1;
         if( c == n ) break;
         for(long k = 0; k < 4; ++k) {
            long nx = x + dx[k], ny = y + dy[k];
            if( not ( 0 <= nx and nx < w and 0 <= ny and ny < h ) ) continue;
            if( field[ny][nx] != 0 ) continue;
            x = nx, y = ny;
            break;
         }
         dumplll(c, x, y);
      }
      for(long i = 0; i < h; ++i) {
         printf("%ld", field[i][0]);
         for(long k = 1; k < w; ++k) {
            printf(" %ld", field[i][k]);
         }
         putchar('\n');
      }
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const long long INF = 1LL << 60;
const ll C = 1000000000+7;

int main(void)
{
    int N, ans = 0;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++) {
        cin >> a[i];
        ans += a[i] - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <math.h>

using namespace std;


int main()
{
	int n;
	bool prime[300000];

	for (int i = 0; i < 300000 + 1; i++){
		prime[i] = true;
	}

	prime[0] = prime[1] = false;
	for (int i = 2; i < 300000 + 1; i++){
		if (prime[i]){
			for (int j = 0; i * (j + 2) < 300000; j++){
				prime[i * (j + 2)] = false;
			}
		}
	}

	while (true){
		scanf("%d", &n);
		if (n == 0){
			break;
		}

		int cnt = 0;
		for (int i = n + 1; i <= n * 2; i++){
			if (prime[i]){
				cnt++;
			}
		}

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

	return (0);
}

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

typedef pair<long,int> P;
int main(){
  int x,y,z,k;
  cin >> x >> y >> z >> k;
  long a[x],b[y],c[z];
  for(int i = 0;i < x;i++){
    cin >> a[i];
  }
  for(int i = 0;i < y;i++){
    cin >> b[i];
  }
  for(int i = 0;i < z;i++){
    cin >> c[i];
  }
  vector<long> d;
  for(int i = 0;i < x;i++){
    for(int j = 0;j < y;j++){
      d.push_back(a[i]+b[j]);
    }
  }
  sort(d.begin(),d.end());
  reverse(d.begin(),d.end());
  vector<long> e;
  for(int i = 0;i < min(k,x*y);i++){
    e.push_back(d.at(i));
  }
  vector<long> f;
  for(int i = 0;i < e.size();i++){
    for(int j = 0;j < z;j++){
      f.push_back(e.at(i)+c[j]);
    }
  }
  sort(f.begin(),f.end());
  reverse(f.begin(),f.end());
  for(int i = 0;i < k;i++){
    cout << f.at(i) << endl;
  }
}

Measured memory_bytes: 43268
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int N;
    int[] C;	//次の駅到着にかかる時間
    int[] S;	//各駅の最初の発車時間(開通式後)
    int[] F;	//各駅の二番目以降の発車時刻の間隔
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.N = sc.nextInt();
        C = new int[N-1];
        S = new int[N-1];
        F = new int[N-1];
        for (int i=0; i<N-1; i++) {
        	C[i] = sc.nextInt();
        	S[i] = sc.nextInt();
        	F[i] = sc.nextInt();
        }
    }
    
    //解答処理
    private int[] solve() {
        int[] x = new int[N];
        
        for (int i=0; i<N; i++) {	//i番目の駅から出発
        	int t = 0;  //現在時刻
        	for (int j=i; j<N-1; j++) {	//j番目の駅からN番目の駅までの移動
        		if (t <S[j]) {	//その駅の始発がまだ出ていないとき
        			t = S[j] + C[j];
        		} else if (t%F[j] == 0) {
        			t += C[j];
        		} else {
        			t += F[j] - t%F[j] + C[j];
        		}
        	}
        	x[i] = t;
        }
        
        return x;
    }
    
    //出力
    public void show(int[] answer) {
        for (int i=0; i<answer.length; i++) {
        	System.out.println(answer[i]);       	
        }
    }

}


Measured memory_bytes: 39072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ios                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define fill(x, v) memset(x, v, sizeof(x))
const ll mod = 1000000007;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
/*
std::cout << std::setprecision(9) << f << '\n';//3.141590000;
map<char,int>::reverse_iterator rit;
*/
// --------dsu-- --------

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

int main()
{
    int n;
    cin >> n;
    set<string> st;
    for (int i = 0; i < n; i++)
    {
        string x;
        cin >> x;
        st.insert(x);
    }
    cout << st.size() << endl;
}


Measured memory_bytes: 19208
n = int(input())
h = list(map(int, input().split()))
ans = "Yes"
for i in range(n-1, 0, -1):
    if h[i] < h[i-1]:
        h[i-1] -= 1
    if h[i] < h[i-1]:
        ans = "No"

print(ans)


Measured memory_bytes: 14396
#include <stdio.h>
#include <string.h>
 
int main()
{
    char a[200001];
    char b[200001];
    scanf("%s",a);
    scanf("%s",b);
    int s=strlen(a);
    int i;
    int cnt=0;
    for(i=0;i<s;i++){
        if(a[i]!=b[i]){
            cnt++;
        }
    }
    printf("%d",cnt);
    return 0;
}

Measured memory_bytes: 2112
#include <stdio.h>
int MIN(int a,int b){
    return a<b?a:b;
}
int main()
{   int h,w,a,b;
    scanf("%d%d%d%d",&h,&w,&a,&b);
    int arr[1000][1000]={0};
    int i=0;
    for(i=0;i<b;i++){
        for(int j=a;j<w;j++)arr[i][j]=1;
    }
   for(i;i<h;i++){
       for(int j=0;j<a;j++){
           arr[i][j]=1;
       }
   }
    for(int i=0;i<h;i++){
        for(int k=0;k<w;k++){
            printf("%d",arr[i][k]);
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 4992
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<utility> 
using namespace std;
vector<pair<long long,long long>> prime;
long long f(long long v){
	long long i;
	for(i=1;;i++){
		if(i*(i+1)/2>v)
			break;
	}
	return i-1;
}
int main(){
	long long i,a;
	scanf("%lld",&a);
	for(i=2;i*i<=a;i++){
		int cnt=0;
		while(a%i==0){
			a/=i;
			cnt++;
		}
		if(cnt)
			prime.emplace_back(i,cnt);
	}
	if(a>1)
		prime.emplace_back(a,1);
	long long ans=0;
	for(auto x:prime)
		ans+=f(x.second);
	printf("%lld\n",ans);
}


Measured memory_bytes: 3240
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	char name[12];
	int time, shift;
} process;

int q;

int cmp(const void *a, const void *b) {
	process *pa = (process *)a, *pb = (process *)b;
	return (pa->time - 1) / q - (pb->time - 1) / q;
}

// ???????????????????????????????????¨????????¢?????? O(log n) ??§?§£????????????

int main(void) {
	int now = 0, N, i, j, maxGroup = 0, sum = 0;
	process *ps, **begins;
	int *counts;
	scanf("%d %d", &N, &q);
	ps = malloc(sizeof(process) * N);
	begins = calloc(50000/q, sizeof(process *));
	counts = calloc(50000/q, sizeof(int));
	for (i = 0; i < N; i++) {
		scanf("%s %d", ps[i].name, &ps[i].time);
		for (j = 0; j < (ps[i].time - 1) / q; j++)
			counts[j]++;
		ps[i].shift = counts[j];
		counts[j] = 0;
		if (begins[j] == NULL) begins[j] = &ps[i];
		if (j > maxGroup) maxGroup = j;
	}
	for (i = 0; i <= maxGroup; i++) {
		if (i > 0 && begins[i] != NULL) {
			begins[i]->shift += sum;
			sum = 0;
		}
		sum += counts[i];
	}
	// fprintf(stderr, "count table ---\n");
	// for (i = 0; i < 10; i++) fprintf(stderr, "counts[%d] = %d\n", i, counts[i]);
	// fprintf(stderr, "-----\n");
	// for (i = 0; i < N; i++) {
	// 	fprintf(stderr, "> %s %d\n", ps[i].name, ps[i].shift);
	// }
	qsort(ps, N, sizeof(process), cmp);
	// fprintf(stderr, "-----\n");
	// for (i = 0; i < N; i++) {
	// 	fprintf(stderr, "> %s %d\n", ps[i].name, ps[i].shift);
	// }
	for (i = 0; i < N; i++) {
		now += ps[i].shift * q + (ps[i].time % q == 0 ? q : ps[i].time % q);
		printf("%s %d\n", ps[i].name, now);
	}

}

Measured memory_bytes: 3600
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;


int main() {
	
	int n, m;
	cin >> n >> m;
	map<int, int>ac;
	map<int, int>wa;
	
	rep(i, m) {
		int proNum;
		string res;
		cin >> proNum >> res;

		if (res == "WA") {
			if (ac[proNum] > 0) {
				continue;
			}
			wa[proNum]++;
		}
		else {
			if (ac[proNum] > 0) {
				continue;
			}
			ac[proNum]++;
		}
	}
	int ans_ac = 0;
	int ans_wa = 0;
	for (auto x : ac) {
		ans_ac += x.second;
		if (x.second > 0) {
			ans_wa += wa[x.first];
		}
		
	}
	cout << ans_ac << " " << ans_wa << endl;
	return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;

template <typename T>//	Tはintかll
T gcd(T a, T b) {//	最大公約数
	if (a < 0) { a = -a; }
	if (b < 0) { b = -b; }
	if (a == 0) { return b; }
	if (b == 0) { return a; }
	if (a < b) {
		return gcd(a, b % a);
	}
	return gcd(b, a % b);
}

int main() {
	ll A, B; cin >> A >> B;
	cout << A * B / gcd(A, B) << endl;
	return 0;
}


Measured memory_bytes: 384
def resolve():
    N = int(input())
    H = list(map(int, input().split()))

    for i in range(N-1):
        if H[i] < H[i+1]:
            H[i+1] -= 1

        if H[i] > H[i+1]:
            print('No')
            return

    print('Yes')

    return
resolve()

Measured memory_bytes: 20668
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int k, x;
  cin >> k >> x;
  rep(i, x - k + 1, x + k) { cout << i << " "; }
  return 0;
}

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

int main(void){
	ll h,w;
	cin >> h >> w;
  	if(h==1 ||w ==1){
    	cout << 1;
        return 0;
    }
	if(h%2==0){
		cout << (h/2)*w;
	}else if(w%2==1){
		cout << (h/2+1)*(w/2+1)+(h/2)*(w/2);
	}else {
    	cout << h*(w/2);
    }
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int n,last,temp;
    scanf("%d%d",&n,&last);
    printf("%d",last);
    for(int i=1;i<n;i++){
        scanf("%d",&temp);
        if(temp!=last){
            last=temp;
            printf(" %d",temp);
        }
    }
    printf("\n");
}


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

int main() {
  map<string, int> WEEK {
    {"SUN", 0 },
    {"MON", 1 },
    {"TUE", 2 },
    {"WED", 3 },
    {"THU", 4 },
    {"FRI", 5 },
    {"SAT", 6 }
  };
  string S;
  cin >> S;

  cout << 7 - WEEK[S] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

int a[200000], cnt[200000];
signed main(){
	int n, m;
	scanf("%lld%lld",&n, &m);
	rrep(i,n)cnt[i] = 1;
	a[1] = 1;
	rep(i,m){
		int x, y;
		scanf("%lld%lld", &x, &y);
		if(a[x])a[y] = 1;
		if(cnt[x]-1 == 0){
			a[x] = 0;
		}
		cnt[x]--;cnt[y]++;
	}
	int ans = 0;
	rrep(i,n)ans += a[i];
	printf("%lld\n", ans);
	return 0;
}







Measured memory_bytes: 1792
#include <bits/stdc++.h>
int main() {
    std::string str, tmp;
    std::cin >> str;
    int s = str.size();
    int N, ans=0;
    bool isMatched;
    std::cin >> N;
    for (int i = 0; i < N; i++) {
        std::cin >> tmp;
        int size = tmp.size();
        for (int i = 0; i < size; i++) {
            if (str[0] == tmp[i]) {
                isMatched = true;
                for (int j = 1; j < s; j++) {
                    if (str[j] != tmp[((i+j)%size)]) {
                        isMatched=false; break;
                    }
                }
                if (isMatched) { ans++; break; }
            }
        }
    }
    std::cout << ans << std::endl;
}



Measured memory_bytes: 3216
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int N = 200005;
const int mod = (int) 1e9 + 7;

int n;
int dp[N][2];
vector <int> adj[N];

void dfs(int u, int p) {
  bool leaf = 1;
  int c = 0;
  for (int v : adj[u]) {
    if (v == p) continue;
    dfs(v, u);
    c++;
    leaf = 0;
  }
  if (leaf) {
    dp[u][0] = 1;
    dp[u][1] = 1;
  } else {
    dp[u][0] = dp[u][1] = 1;
    for (int v : adj[u]) {
      if (v == p) continue;
      dp[u][0] = (1ll * dp[u][0] * (dp[v][0] + dp[v][1])) % mod;
      dp[u][1] = (1ll * dp[u][1] * dp[v][0]) % mod;
    }
  }
}

int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs(1, -1);
  cout << (dp[1][0] + dp[1][1]) % mod << endl;
  return 0;
}


Measured memory_bytes: 16512
import 'dart:io';

void main() {
  String input = stdin.readLineSync();
  int x = int.parse(input);
  int f = 0;
  int xLength = input.length;
  for (int i = 0; i < xLength; i++) {
    f = f + int.parse(input[i]);
  }
  if (x % f == 0) {
    print("Yes");
  } else {
    print("No");
  }
}

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

#define ll                  long long int
#define llu                 long long unsigned
#define ld                  long double
#define fast                ios_base::sync_with_stdio(0);cin.tie(0);
#define endl                "\n"
#define pb                  push_back
#define bp                  pop_back
#define pf                  push_front
#define fp                  pop_front
#define mp                  make_pair
#define ms(a,b)             memset((a),(b),sizeof(a))
#define min3(a,b,c)         min(a,min(b,c))
#define max3(a,b,c)         max(a,max(b,c))
#define min4(a,b,c,d)       min(min(a,b),min(c,d))
#define max4(a,b,c,d)       max(max(a,b),max(c,d))
#define max5(a,b,c,d,e)     max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e)     min(min3(a,b,c),min(d,e))
#define NUM                 1000000
#define PI		            2*acos(0.0)
#define maximum             (-1*INF)
#define READ(f) 	        freopen("f", "r", stdin)
#define WRITE(f) 	        freopen("f", "w", stdout)
const int INF = 1e5 + 10 ;

int main()
{
    ll a, b, c, d;
    cin>>a>>b>>c>>d;
    ll t, x;
    if(c%b)
        t = (c/b)+1;
    else
        t = c/b;
    if(a%d)
        x = (a/d)+1;
    else
        x = a/d;
    if(t <= x)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 3636
#include <algorithm>
    #include <bits/stdc++.h>
    #include <cctype>
    #include <cmath>
    #include <cstdio>
    #include <iomanip>
    #include <iostream>
    #include <list>

    #include <stack>
    #include <string>
    #include <vector>
    #include <bits/stdc++.h>
    #define INFINI (1000 * 1000 * 1000)

    using namespace std;
    //#define s(T) scanf("%d", &T)
    #define sl(T) scanf("%lld", &T)
    #define fill(a, val) memset(a, val, sizeof(a))
    #define mp make_pair
    #define pb push_back
    #define all(x) x.begin(), x.end()
    #define DREP(x) sort(all(x)); x.erase(unique(all(x)), x.end())
    #define INDEX(a, val) (lower_bound(all(a), val) - a.begin())
    #define mod ll(1e9+7)
    typedef long long ll;


    bool compare_first(pair<ll,ll >a,pair<ll,ll >b)
    {
        return a.first<b.first;
    }

     bool compare_second(pair<int,pair<int , int> > a,pair<int,pair<int , int> > b)
    {
        return a.second.first<b.second.first;
    }


    ll min(ll a,ll b)
    {
        if(a>b)return b;
        return a;
    }

    ll toINT(string s)
    {
        ll a=0;
        for(ll index=0;index<s.size();index++)
            a=a*10+(s[index]-'0');
        return a;
    }



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

      int a,b,c;
      cin>>a>>b>>c;
      int ans=0;

      if(a!=b)
      {
          ans+=2;
          if(b!=c&&c!=a)
            ans++;
      }
      else
      {
          if(b!=c)
            ans+=2;
          else
            ans++;
      }
      cout<<ans<<endl;
return 0;
    }

/*

 }
 */


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


def solve(N: int, M: int, X: "List[int]"):
    if N >= M:
        return 0
    X = sorted(X)
    D = [x2 - x1 for x1, x2 in zip(X, X[1:])]
    return sum(sorted(D)[:M-N])


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    X = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    print(solve(N, M, X))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 16556
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

int main() {
    fastIO;
    int p, q, r;
    cin >> p >> q >> r;
    cout << (min(p + q, min(q + r, r + p)));
}

Measured memory_bytes: 3612
def proc(i):
    l  = len(i)
    o = [ i[0] ]
    io = 1
    ii = 1

    while ii < l:
#        print(o)
#        print("io={0} d={1} c={2} o={3}".format(io,i[ii:ii+2],i[ii+2],o))
        if i[ii:ii+2] == "<-":
            io -= 1
        else:
            io += 1

        if (io == 0):
            o.insert(io,i[ii+2])
            io += 1
        elif (io == len(o)+1):
            o.insert(io,i[ii+2])
        else:
#            print("i={0} o={1}".format(i[ii+2],o[io-1]))
            if i[ii+2] != o[io-1]:
                raise untimeError("error")

        ii += 3

    s = ""
    for c in o:
        s += c
    return s


n = int(input())

for _ in range(n):
    l = input()
    r = proc(l)
    print(r)

Measured memory_bytes: 7708
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N, X, A[50], B[50];
	bool ANS[51] = {};
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> B[i];
	for (int i = 0; i < N; i++) {
		if (A[i] != B[i] && A[i] <= 2 * B[i]) {
			cout << -1 << endl;
			return 0;
		}
	}
	for (int i = 0; i <= 50; i++) ANS[i] = true;
	for (int i = 50; i >= 1; i--) {
		bool S[51] = {};
		for (int j = 1; j <= 50; j++) if (ANS[j] && i != j) S[j] = true;
		long long WF[51][51] = {}, INF = 1000;
		for (int j = 0; j <= 50; j++) {
			for (int k = 0; k <= 50; k++) {
				if (j != k) WF[j][k] = INF;
			}
		}
		for (int j = 1; j <= 50; j++) {
			if (S[j]) {
				for (int k = 0; k <= 50; k++) {
					if (k != k % j) WF[k % j][k] = 1;
				}
			}
		}
		for (int l = 0; l <= 50; l++) {
			for (int j = 0; j <= 50; j++) {
				for (int k = 0; k <= 50; k++) {
					WF[j][k] = min(WF[j][k], WF[j][l] + WF[l][k]);
				}
			}
		}
		bool check = true;
		for (int j = 0; j < N; j++) {
			if (WF[B[j]][A[j]] >= INF) check = false;
		}
		if (check) ANS[i] = false;
	}
	long long COUNT = 0;
	for (int i = 1; i <= 50; i++) {
		if (ANS[i]) COUNT += (1LL << i);
	}
	cout << COUNT << endl;
}

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int ab, bc, ca;
  cin >> ab >> bc >> ca;

  int res = ab * bc / 2;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
rd = dict()
rd[0] = 0
def check(x):
    r = 0
    for a, b, c, d in X:
        if x[b-1]-x[a-1] == c:
            r += d
    return r

def dfs(x, l):
    if len(x) == N:
        rd[0] = max(rd[0], check(x))
        return
    for i in range(l, M+1):
        dfs(x+[i], i)
N, M, Q = map(int, input().split())
X = []
for _ in range(Q):
    a, b, c, d = map(int, input().split())
    X.append((a, b, c, d))
dfs([], 1)
print(rd[0])


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

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> arr;
	for (int i = 0; i < n; ++i)
	{
		int x;
		cin >>x;
		if(x == 0){
			k--;
			continue;
		}
		arr.push_back(x);

	}

	int index = arr.size();

	for (int i = 0; i < arr.size(); ++i)
	{
		if(arr[i] > 0){
			index = i;
			break;
		}
	}

    int ans = INT_MAX;

	for (int i = 0; i < arr.size() && arr[i] < 0; ++i)
	{
		int temp = index-i;
		if(temp > k){
			continue;
		}

		int temp2 = index + k - temp - 1;
		if(temp2 >= arr.size() && temp < k){
			continue;
		}
		if(temp2 >= arr.size() || k-temp == 0){

			ans = min(ans, abs(arr[i]));
			continue;
		}
		else{
			ans = min(ans, min(2*abs(arr[i])+abs(arr[temp2]), 2*abs(arr[temp2])+abs(arr[i])));
		}
		
	}
	if(index+k-1<arr.size()){
		ans = min(ans, arr[index+k-1]);
	}
	if(ans == INT_MAX){
		ans = 0;
	}
	cout << ans << endl;










}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
vector<int> vr, vg, vb;
int main()
{
    string s;
    int n;
    long long ans = 0;
    cin >> n >> s;
    for (int i = 0; i < n;i++)
    {
        if(s[i]=='R')
            vr.push_back(i);
        else if(s[i]=='G')
            vg.push_back(i);
        else
            vb.push_back(i);
    }
 
    int r = vr.size(), g = vg.size(), b = vb.size();
    ans = 1ll * r * g * b;
    for (int i = 0; i < r;i++)
    {
        for (int j = 0; j < g;j++)
        {
            int dist = abs(vr[i] - vg[j]);
            int left = min(vr[i], vg[j]), right = max(vr[i], vg[j]);
            if((dist%2==0)&&(s[left+dist/2]=='B'))
                ans--;
            if(left-dist>=0)
                ans = s[left - dist] == 'B' ? ans - 1 : ans;
            if(right+dist<n)
                ans = s[right + dist] == 'B' ? ans - 1 : ans;
        }
    }
    cout << ans;
    return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0; i<(int)n; i++)
    
int main(){
    int n, x; cin >> n >> x;
    int l[n];
    int d[n+1]; 
    int cnt = 1;
    d[0] = 0;
    
    rep(i, n) {
        cin >> l[i];
        d[i+1] = d[i] + l[i];
        if(d[i+1] <= x) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
using namespace std;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/

int main()
{
ll n,m,i,x,y,c=0,a,b;
cin>>n>>m;
vector<pair<ll,ll> >v;
set<ll>s;
for(i=0;i<m;i++)
    s.insert(i);
for(i=0;i<n;i++)
{
    cin>>x>>y;
    v.pb({y,x});
}
sort(v.begin(),v.end(),greater<pair<ll,ll> >());
for(i=0;i<v.size();i++)
{
    a=m-v[i].ss;
    auto it=s.lower_bound(a);
    if(*it==a)
    {
        c=c+v[i].ff;
        s.erase(it);
    }
    else if(it==s.begin())
        continue;
    else
    {
        it--;
        c=c+v[i].ff;
        s.erase(it);
    }
}
cout<<c<<endl;
}


Measured memory_bytes: 7156
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <list>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <fstream>
#include <sstream>
#include <unordered_map>
#include <ctime>
#include <assert.h>
using namespace std;

const unsigned long long MOD = (unsigned long long)(1e9 + 7);

#define FROM_0(i, n) for(int i = 0; i < (n); i++)
#define FROM_S(i, s, e) for(int i = (s); i < (e); i++)
#define ITER_BEGIN_END(iter, vec) for(auto iter = vec.begin(); iter != vec.end(); iter++)

unsigned long long count(int ab)
{
    unsigned long long ret = 0;
    int end = sqrt(ab);
    if (ab % 2 == 0)
    {
        FROM_S(i, 1, end + 1)
        {
            if (ab % i == 0)
            {
                ret += i * i == ab ? 1 : 2;
            }
        }
    }
    else
    {
        for (int i = 1; i <= end; i += 2)
        {
            if (ab % i == 0)
            {
                ret += i * i == ab ? 1 : 2;
            }
        }
    }
    //cout << ab << ' ' << ret << endl;
    return ret;
}

int main()
{
    int n;
    cin >> n;
    unsigned long long result = 0;
    FROM_S(c, 1, n)
    {
        int ab = n - c;
        result += count(ab);
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3652
<?php
fscanf(STDIN, '%d', $cnt);
$nums = array_map('intval', explode(' ', trim(fgets(STDIN))));
$flag = true;
for ($i=0; $i < $cnt; $i++) { 
    if ($nums[$i] % 2 !== 0) {
        continue;
    }
    if ($nums[$i] % 3 !== 0 && $nums[$i] % 5 !== 0) {
        $flag = false;
    }
}
echo $flag ? 'APPROVED' : 'DENIED';
echo "\n";

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

const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

int main(){
	int N, M;
	cin >> N >> M;
	if(1 < abs(N - M)){
		cout << 0 << endl;
		return 0;
	}
	
	mint ans(1);
	for(int i = 0; i < N; ++i){
		ans *= N - i;
	}
	for(int i = 0; i < M; ++i){
		ans *= M - i;
	}
	if(N == M){
		ans *= 2;
	}
	cout << ans << endl;
	return 0;
}



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

int main(){
    int n,k;
    cin>>n>>k;
    int a[n];
    vector<int>d(n+1);
    for(int i=0;i<n;i++){
        cin>>a[i];
        d[a[i]]++;
    }
    sort(d.rbegin(),d.rend());
    int tmp=0;
    for(int i=0;i<k;i++){
        tmp+=d[i];
    }
    cout<<n-tmp<<endl;
    
    return 0;
}


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
int main(){
  ll n,k, ans = 0;
  cin >> n >> k;
  ll t = k / 2;
  ll mod[2] = {};

  FOR(i,1, (n+1)){
      if(i % k == 0) mod[0]++;
      else if(i % k == t && k % 2 == 0) mod[1]++;
  }
  
  REP(i, 2){
      ans += pow(mod[i],3);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;


int main()
{
	int n;
	cin>>n;
	vector<ll> a(n+1,0);
	a[1] = 1;
	for(int i = 2; i <= n; i++){
		int res = i;
		for(int j = 2; j*j <= n; j++){
			while(res%j==0){
				a[j]++;
				res /= j;
			}
		}
		a[res]++;
	}

	ll ans =1;
	for(int i = 2; i <= n; i++){
		ans *= (a[i]!=0?a[i]+1:1);
		ans %= mod;
	}
	cout << ans << endl;

	return 0;
}

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

template<class T> struct rge { T b, e; };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
    ~debug(){cerr<<endl;}
    template<class T> debug& operator<<(T x){cerr<<boolalpha<<x; return *this;}
    template<class B, class C> debug& operator<<(pair<B, C> x){return *this<<"("<<x.first<<", "<<x.second<<")";}
    template<class T> debug& operator<<(rge<T> x){*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}return *this<<"]";}
    template<class T> debug& operator<<(vector<T> x){ return *this<<range(x.begin(),x.end());}
#else
    template<class T> debug& operator <<(const T&){return *this;}
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
using ll = long long;

#define forn(i, n) for(int i = 0; i < int(n); i++)
#define ford(i, n) for(int i = n-1; i >= 0; i--) 

template<typename T> 
void min_self(T& a, T b) { 
    a = min(a, b); 
}
template<typename T>
void max_self(T& a, T b) { 
    a = max(a, b); 
}

const int inf = 1e9+5;

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    forn(i, n) {
        cin >> a[i];
    }
    
    int ans = inf;
    for(int i = 0, j = k-1; j < n; i++, j++) {
        int L = a[i], R = a[j];
        if(L <= 0 && 0 <= R) {
            int extra = min(-L, R);
            min_self(ans, R - L + extra);
        } else if(L > 0) {
            int extra = L;
            min_self(ans, R - L + extra);
        } else if(R < 0) {
            int extra = -R;
            min_self(ans, R - L + extra);
        }
    }
    
    cout << ans << endl;
}













// Don't worry, you're getting better

// Read statement carefully
// Solve on paper first!
// Make your infinity big enough
// Overflows (long long)

// Author: blondie


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int l0=2;
int l2=1;

int pl(int p,int q){
 return p+q; 
}
 
int main() {
  int64_t x;
  int a;
  cin >> a;
  int64_t p= 2;int64_t q=1;
  for(int i=0;i<a-1;i++){
    x = p+q;
    p = q;
    q = x;
  }
  if(a==1){cout<< 1 <<endl;}else{
  cout << x << endl;}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool f[10];
int main(){
  int n,cnt=0,ans=0;
  int a;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    if(1<=a&&a<=399)f[0]=1;
    else if(a<800)f[1]=1;
    else if(a<1200)f[2]=1;
    else if(a<1600)f[3]=1;
    else if(a<2000)f[4]=1;
    else if(a<2400)f[5]=1;
    else if(a<2800)f[6]=1;
    else if(a<3200)f[7]=1;
    else cnt++;
  }
  for(int i=0;i<8;i++)ans+=f[i];
  if(ans==0)cout<<1<<' ';
  else cout<<ans<<' ';
  cout<<ans+cnt<<endl;
  return(0);
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
mean = sum(a) / n
if mean >= -0.5:
  common = int(mean + 0.5)
else:
  common = int(mean - 0.5)
cost = 0
for i in range(n):
  cost += (a[i] - common) ** 2
print(cost)

Measured memory_bytes: 3064
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

alias TA = Tuple!(long, long);

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

TA minTA(long t, long a) {
    auto g = gcd(t, a);
    return tuple(t/g, a/g);
}

void main(){
    auto N = readInt();
    auto currentVote = tuple(1L,1L);
    foreach(i; iota(N)) {
        auto ta = readLongs();
        auto m = minTA(ta[0], ta[1]);
        auto r = max(currentVote[0]/m[0], currentVote[1]/m[1]);
        auto n = tuple(m[0] * r, m[1] * r);
        while(n[0] < currentVote[0] || n[1] < currentVote[1]) {
            n[0] += m[0];
            n[1] += m[1];
        }
        currentVote = n;
    }
    writeln(currentVote[0] + currentVote[1]);
}



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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

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

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N; cin >> N;
  ll a[3*N]; rep(i,3*N) cin >> a[i]; sort(a,a+3*N,greater<int>());
  ll result = 0; rep(i,N) result += a[i*2+1];
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
int N,A,B,a,i;main(){auto f=[=](int i,int r=0){for(;i;r+=i%10,i/=10);return r>=A&&r<=B;};for(std::cin>>N>>A>>B;i<=N;a+=f(i++)?i-1:0);std::cout<<a<<"\n";}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

N = int(input())
A = list(map(int, input().split()))

def f(n):
  res = 0
  while n % 2 == 0:
    n //= 2
    res += 1
  return res

answer = 0
for a in A:
  answer += f(a)

print(answer)

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    vector<int> v(6);
    int k;
    for(int i=1;i<6;i++)cin>>v[i];
    cin>>k;
    sort(v.begin(),v.end());
    int n;
    n=v[5]-v[1];
  //for(int i=1;i<6;i++)cout<<v[i]<<" ";
  //cout<<n<<endl;
    if(n>k)cout<<":("<<endl;
    else cout << "Yay!"<<endl;
}

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

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  string anser = "";
  anser += toupper(s1[0]);
  anser += toupper(s2[0]);
  anser += toupper(s3[0]);
  cout << anser << endl;
  return 0;
}

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

using namespace std;

typedef long long int lli;

int main(int argc, char const *argv[]) {
  lli n, anso = 0, anse = 0, sum = 0;
  cin >> n;
  vector<lli> a(n);
  for (size_t i = 0; i < n; i++) cin >> a[i];
  for (size_t i = 0; i < n; i++) {
    sum += a[i];
    if (i%2==1 and sum <= 0) {
      anso += abs(1-sum);
      sum = 1;
    }
    if (i%2==0 and sum >= 0) {
      anso += abs(-1-sum);
      sum = -1;
    }
  }
  sum = 0;
  for (size_t i = 0; i < n; i++) {
    sum += a[i];
    if (i%2==0 and sum <= 0) {
      anse += abs(1-sum);
      sum = 1;
    }
    if (i%2==1 and sum >= 0) {
      anse += abs(-1-sum);
      sum = -1;
    }
  }

  cout << min(anso, anse) << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<cstring>
#include <iomanip>

using namespace std;

#ifdef LDEBUG
#define debug(x) cout << #x << ":" << x << endl
#else
#define debug(...)
#endif

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

typedef unsigned long long u64;
typedef long long i64;

int n, k;

int p[10000];


void run(){
        int m = 1;
        int j = 0;
        for (int i=n; i>0; i--) {
                int a = i;
                while (m*a < k) {
                        m *= 2;
                        j++;
                }

                p[j]++;
        }
}


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

        cin >> n >> k;

        run();

        double a = 0;
        REP(i,10000)
                a += p[i] * pow(0.5, i);
        a /= n;

        cout << fixed <<  setprecision(14) <<  a << endl;

        return 0;
}


Measured memory_bytes: 384