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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
#define int long long
//for set
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   
// for multiset
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_multiset;

#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return ((a%md)*(b%md))%md;}
int addmod(int a, int b, int md) {return (a+b)%md;}
int submod(int a, int b, int md) {return (((a-b)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
int n,k;
vi a(200010);
vi f(200010);
bool check(int v) {
	int cp=0;
	for(int i = 0; i < n; i++) {
		if(a[i]*f[i] <= v)
			continue;
		int req = v/f[i];
		cp += a[i]-req;
	}
	if(cp <= k)
		return true;
	return false;
}
int bn(int lo, int hi) {
	if(lo==hi) {
		if(check(lo))
			return lo;
		return lo+1;
	}
	int mid=(lo+hi)/2;
	if(check(mid)) {
		return bn(lo,mid);
	} else {
		return bn(mid+1,hi);
	}
}

int32_t main(void)
{
	IOS;
	cin>>n>>k;
	for(int i = 0; i < n; i++)
		cin>>a[i];
	for(int i = 0; i < n; i++)
		cin>>f[i];
	sort(a.begin(), a.begin()+n);
	sort(f.begin(), f.begin()+n, greater<int>());
	cout<<bn(0ll, (ll)1000010*(ll)1000010)<<endl;
	// cout<<bn(0ll, 100ll)<<endl;
	time();
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[15][15];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int lb = i % 10;
		int hb = i;
		while (hb >= 10) {
			hb /= 10;
		}
		a[hb][lb]++;
	}
	ll ans = 0;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			ans += a[i][j] * a[j][i];
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int MAX=1000000;
bool t[MAX+1];
int c[MAX+1];

void make_table(){
	t[0]=t[1]=1;
  for(int i=0;i<=MAX;i++){
 	if(!t[i]){
 		for(int j=i+i;j<=MAX;j+=i)
 			t[j]=1;
 	}
  }
}
int main(){
  make_table();
  	int n; 
	for(int i=1;i<=MAX;i++){
		c[i]=(t[i])?c[i-1]:c[i-1]+1;
	}

	while(cin>>n)
		cout<<c[n]<<endl;
	
}

Measured memory_bytes: 7976
#include <bits/stdc++.h>
using namespace std;
int  main(){
int A,B;
cin>>A>>B;
if((A+B)%2==0){
    cout<<(A+B)/2<<endl;
}
else if(abs(A-B)%2==0){
    cout<<abs(A-B)/2<<endl;
}
else
cout<<"IMPOSSIBLE"<<endl;
}


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

using namespace std;

int main(void)
{
    int N,K;
    cin >> N >> K;

    vector<int> H(N);
    for(auto& e : H)
    {
        cin >> e;
    }
    sort(H.begin(), H.end());

    int ans = 1000000000;
    for(int i = 0; i < N - K + 1; ++i)
    {
        ans = min(ans, H[i + K - 1] - H[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 888
n=int(input())
A=[int(i) for i in input().split()]

ans=0
for i in range(n-2):
    for q in range(i,n-1):
        for r in range(q,n):
            ck=[A[i],A[q],A[r]]
            ck.sort()
            if len(set(ck))==3 and ck[0]+ck[1]>ck[2]:
                ans+=1
print(ans)

Measured memory_bytes: 9196
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder
{
    public static class Program
    {
        static void Main()
        {
            var N = Console.ReadLine();
            var targets = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var count = 0;
            for (int i = 1; i < targets.Length - 1; i++)
            {
                var a = targets[i - 1] > targets[i] && targets[i] > targets[i + 1];
                var b = targets[i - 1] < targets[i] && targets[i] < targets[i + 1];
                if (a || b) ++count;
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>

using namespace std;

vector<map<int, int> > E;
int mxcol=0;

void dfs(int cur, int col) {
    int tmpcol=col+1;
    if(tmpcol>mxcol) tmpcol%=mxcol;
    for(auto itr=E[cur].begin(); itr!=E[cur].end(); itr++) {
        if(itr->second!=0) continue;
        itr->second = tmpcol;
        E[itr->first][cur] = tmpcol;
        dfs(itr->first, tmpcol);
        tmpcol++;
        if(tmpcol>mxcol) tmpcol%=mxcol;
    }
}

int main() {
    int N;
    cin >> N;
    E.resize(N+1);
    vector<pair<int, int> > Enum(N-1);
    for(int n=0; n<N-1; n++) {
        int a, b;
        cin >> a >> b;
        E[a][b]=0;
        E[b][a]=0;
        Enum[n] = make_pair(a, b);
        mxcol = max(mxcol, (int)max(E[a].size(), E[b].size()));
    }

    dfs(1, 0);

    cout << mxcol << endl;
    for(int n=0; n<N-1; n++) {
        cout << E[Enum[n].first][Enum[n].second] << endl;
    }
    

    return 0;
    
}

Measured memory_bytes: 15360
t_hp, t_atk, a_hp, a_atk = map(int, input().split())

t_count = 0
a_count = 0

while a_hp > 0:
    a_hp -= t_atk
    t_count += 1

while t_hp > 0:
    t_hp -= a_atk
    a_count += 1

if t_count <= a_count:
    print('Yes')
else:
    print('No')



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

int main() {
  string str;
  cin >> str;
  int tmp = 0;
  for (int i = 0; i < str.size(); i++) {
    if (str.at(i) == 'o') {
      tmp++;
    }
  }
  if (15 - str.size() + tmp >= 8) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] x = new int[n];
        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;
        for(int i = 0; i < n; i++){
            x[i] = scan.nextInt();
            if(min > x[i]) min = x[i];
            if(max < x[i]) max = x[i];
        }
        int out = Integer.MAX_VALUE;
        for(int i = min; i <= max; i++){
            int t = 0;
            for(int j = 0; j < n; j++){
                if(t < Math.abs(x[j] - i)) t = Math.abs(x[j] - i);
            }
            if(out > t) out = t;
        }
        System.out.println(out);
        scan.close();
    }
}


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

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

const long long MOD = 1000000007;

int main(){
  int n,m;
  cin>>n>>m;
  set<int> b;
  int t;
  rep(i,m){
    cin>>t;
    t;
    b.insert(t);
  }
  vector<ll> dp(n+2,0);
  dp.at(0)=1;
  rep(i,n){
    if(!b.count(i+1)){ 
      dp.at(i+1)+=dp.at(i);
      dp.at(i+1)%=MOD;
    }
    if(!b.count(i+2)){ 
      dp.at(i+2)+=dp.at(i);
      dp.at(i+2)%=MOD;
    }
  }
  cout<<dp.at(n)<<endl;
}


Measured memory_bytes: 5760
"""
クアドリアンとダルメシアン（自然言語）
入力：自然数N
出力：a-zを使用した文字列
手続き
1. 入力を受け取る
2. N-1を26で割った商をd, 余りをrとする
3. 文字列a-zの内r番目の文字列をresに格納する
4. Nにdを代入して，手続き2.に戻る
5. resに格納した文字列を反転させ，出力する
"""
import string
N = int(input())
def convert_26_decimal(N):
    res = ""
    d, r = 0, 0
    while N:
        d, r = (N-1)//26, (N-1)%26
        res += string.ascii_lowercase[r]
        N = d
    return res[::-1]
print(convert_26_decimal(N))

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

#define i64 long long int
#define ran 101101

priority_queue<int> pq;

int x, y, a, b, c;
int p[ran], q[ran], r[ran];

int main() {
	scanf("%d%d%d%d%d", &x, &y, &a, &b, &c);
	
	for(int i=0;i<a;i++) scanf("%d", &p[i]);
	for(int i=0;i<b;i++) scanf("%d", &q[i]);
	for(int i=0;i<c;i++) scanf("%d", &r[i]);
	sort(p, p+a);
	sort(q, q+b);
	sort(r, r+c);
	
	while(!pq.empty()) pq.pop();
	i64 ans = 0LL;
	for(int i=0;i<x;i++) {
		ans += p[a-1-i];
		pq.push(-p[a-1-i]);
	}
	for(int i=0;i<y;i++) {
		ans += q[b-1-i];
		pq.push(-q[b-1-i]);
	}
	for(int i=c-1;i>=0;i--)
		if(r[i] > -pq.top()) {
			ans += r[i] + pq.top();
			pq.pop();
			pq.push(-r[i]);
		} else break;
	
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 2552
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

int ans, h, w;
char masu[100][100];
int dp[100][100];


int main(){
	cin >> h >> w;
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			cin >> masu[i][j];
		}
	}
	for (int i = 0; i < 100; i++){
		for (int j = 0; j < 100; j++){
			dp[i][j] = MOD;
		}
	}

	dp[0][0] = 0;
	for (int i = 1; i < h; i++){
		dp[i][0] = dp[i-1][0];
		if (masu[i-1][0] == '#' && masu[i][0] == '.'){
			dp[i][0]++;
		}
	}
	for (int i = 1; i < w; i++){
		dp[0][i] = dp[0][i-1];
		if (masu[0][i-1] == '#' && masu[0][i] == '.'){
			dp[0][i]++;
		}
	}

	for (int i = 1; i < h; i++){
		for (int j = 1; j < w; j++){
			if (masu[i-1][j] == '#' && masu[i][j] == '.'){
				dp[i][j] = min(dp[i][j], dp[i-1][j] + 1);
			}else{
				dp[i][j] = min(dp[i][j], dp[i-1][j]);
			}
			if (masu[i][j-1] == '#' && masu[i][j] == '.'){
				dp[i][j] = min(dp[i][j], dp[i][j-1] + 1);
			}else{
				dp[i][j] = min(dp[i][j], dp[i][j-1]);
			}
		}
	}

	if (masu[h-1][w-1] == '#') dp[h-1][w-1]++;
	cout << dp[h-1][w-1] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  std::string S;
  std::cin >> S;
  ll N = S.size();

  std::string T;
  for (ll i = 0; i < N; i += 2) {
    T += S[i];
  }

  print(T);
  return 0;
}


Measured memory_bytes: 592
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
300iq as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         char[] arr = infile.readLine().toCharArray();
         int[] prefR = new int[N];
         int[] prefW = new int[N];
         if(arr[0] == 'R')
            prefR[0] = 1;
         else
            prefW[0] = 1;
         for(int i=1; i < N; i++)
         {
            if(arr[i] == 'R')
               prefR[i]++;
            else  
               prefW[i]++;
            prefR[i] += prefR[i-1];
            prefW[i] += prefW[i-1];
         }
         int A = 0; //RW
         int B = 0; //WR
         for(int i=0; i < N; i++)
            if(arr[i] == 'R')
               A++;
         int res = Math.min(prefR[N-1], prefW[N-1]);
         for(int i=0; i < N; i++)
         {
            if(arr[i] == 'R')
               A--;
            else
               B++;
            res = Math.min(res, cost(A,B));
         }
         System.out.println(res);
      }
      public static int cost(int X, int Y)
      {
         int shared = Math.min(X,Y);
         return X+Y-shared;
      }
   }

Measured memory_bytes: 38072
#include <stdio.h>
int main(void) {
	int number;
	double weight, height;

	while (scanf("%d,%lf,%lf ", &number, &weight, &height) != EOF) {
		if (25.0 <= weight / (height * height)) {
			printf("%d\n", number);
		}
	}
	return 0;
}

Measured memory_bytes: 632
#include <stdio.h>
int main(void){
	int a, b, c;
	for(a=1;a<10;a++){
	 for(b=1;b<10;b++){
	   c = a * b;
		printf("%dx%d=%d\n", a, b, c);
	   }
	}
	return 0;
}

Measured memory_bytes: 524
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
using namespace std;
#define vel vector<long long>
#define vvel vector<vel>
#define int long long
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
long long p = 1000000007;
vel kai(200001, 1);
vel ink(200001, 1);
int le = (1 << 20) + 1;
vel BIT(le, 0);
vel uni(vel &list) {
	if (list.size() == 0) { return list; }
	sort(list.begin(), list.end());
	vel ql(1, list[0]);
	rep(i, list.size() - 1) {
		if (list[i] != list[i + 1]) { ql.push_back(list[i + 1]); }
	}
	list = ql;
	return ql;
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; }
	return ans % p;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, 200000) { kai[i + 1] = (kai[i] * (i + 1)) % p; }
	rep(i, 200001) { ink[i] = inv(kai[i]); }
}
int com(int n, int r) {
	int ans = kai[n] * ink[r];
	ans %= p; ans *= ink[n - r]; ans %= p;
	return ans;
}
int per(int n, int r) {
	int ans = kai[n] * ink[n - r];
	ans %= p;
	return ans;
}
signed main() {
	int n; cin >> n;
	V<pair<pair<string, int>, int>> lis(n);
	rep(i, n) {
		string s; cin >> s;
		int p; cin >> p;
		lis[i] = mkp(mkp(s, -p), i);
	}
	sor(lis);
	rep(i, n) {
		cout << lis[i].second+1 << endl;
	}
	return 0;
}


Measured memory_bytes: 11520
#include <iostream>
#include <ctime>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <cassert>
#include <queue>
#include <deque>
#include <climits>
#include <cstring>
#include <random>
#include <bitset>

using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    #ifdef LOCAL
    assert(freopen("input.txt", "r", stdin));
    assert(freopen("output.txt", "w", stdout));
    #endif
    
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int dx = x1 - x2;
    int dy = y1 - y2;
    int x4 = x1 + dy;
    int x3 = x2 + dy;
    int y4 = y1 - dx;
    int y3 = y2 - dx;
    cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int n, m;

ll cnt[100010];
ll mn [100010];

void Work(int l, int r){
	if(l < r){
		cnt[l+1] += 1; cnt[r+1] -= 1;
		mn [l+1] += -(l+1); mn[r+1] -= -(l+1);
	} else {
		cnt[l+1] += 1;
		mn [l+1] += -(l+1);
		cnt[1] += 1; cnt[r+1] -= 1;
		mn [1] += m-l-1; mn[r+1] -= m-l-1;
	}
}

int Count(int l, int r){
	if(l < r) return r-l;
	return m-(l-r);
}

int main()
{
	read(n, m);
	int a; read(a);
	ll Ans = 0;
	for(int i=2; i<=n; ++i){
		int b; read(b);
		Work(a, b);
		Ans += Count(a, b);
		a = b;
	}
	for(int i=2; i<=m; ++i) cnt[i]+=cnt[i-1], mn[i]+=mn[i-1];
	ll Mx = 0;
	for(int i=1; i<=m; ++i){
		ll v = i*1LL*cnt[i] + mn[i];
		Mx = max(Mx, v);
	}
	printf("%lld\n", Ans - Mx);
	return 0;
}


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

int main()
{
    char s[4];
    cin >> s;
    if (strstr(s, "SUN")) cout << 7;
    else if (strstr(s, "MON")) cout << 6;
    else if (strstr(s, "TUE")) cout << 5;
    else if (strstr(s, "WED")) cout << 4;
    else if (strstr(s, "THU")) cout << 3;
    else if (strstr(s, "FRI")) cout << 2;
    else if (strstr(s, "SAT")) cout << 1;
    return 0;
}


Measured memory_bytes: 256
#!python3

def LI():
    return list(map(int, input().split()))

# input
M, K = LI()


def solve():
    n = 2 ** M
    l = [i for i in range(n) if i != K]
    ret = l + [K] + l[::-1] + [K]
    return ret


def main():
    if K >= 2 ** M:
        ans = [-1]
    elif M == 1:
        if K == 0:
            ans = [0, 0, 1, 1]
        else:
            ans = [-1]
    else:
        ans = solve()

    print(*ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 15240
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N, K;
    string S;
    cin >> N >> K >> S;

    vector<ll> X;
    char c = S[0];
    ll ct = 1;
    for (ll i = 1; i < len(S); ++i){
        if(c == S[i]) ++ct;
        else{
            X.pb(ct);
            ct = 1;
            c = S[i];
        }
    }
    X.pb(ct);

    ll x = len(X);
    vector<ll> sum(x);
    rep(i,x){
        if(!i) sum[i] = X[i];
        else sum[i] = X[i] + sum[i-1];
    }

    ll ans = 0;
    rep(i, x){
        ll a = i;
        ll b = min(K * 2 + 1, x);
        ll c = x - a - b;
        if(c < 0) break;

        ll sa, sb, sc;
        if(i == 0) sa = 0;
        else sa = sum[i - 1];

        sb = sum[i + b - 1] - a;
        sc = sum.back() - sa - sb;

        ll tmp = (sa - a) + (sb - 1) + (sc - c);
        ans = max(ans, tmp);
    }

    print(ans);

    return 0;
}

Measured memory_bytes: 2116
import java.util.Scanner;
import java.util.Arrays;

public class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int a=scan.nextInt();
int b=scan.nextInt();
int c=scan.nextInt();
int d=scan.nextInt();

int ta;
  if(a%d==0){
    ta=a/d;
  }else{
    ta=a/d+1;
  }
int ao;
  if(c%b==0){
    ao=c/b;
  }else{
    ao=c/b+1;
  }
  
  
if(ta>=ao){
System.out.println("Yes");
}else{
System.out.println("No");
}
  
}
}

Measured memory_bytes: 35760
#include<bits/stdc++.h>
#define ll long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=100005;
int n,flag,a[N];
int main()
{
	scanf("%d",&n);
	for(int i=0; i<20; i++) if((1<<i)==n) flag=1;
	if(flag){puts("No"); return 0;}
	puts("Yes");
	if(n%4==3){
		for(int i=1; i<2*n; i++) printf("%d %d\n",i,i+1);
		return 0;
	}
	else if(n%4==0){
		int x=n&(-n),y=n-x,len=2;
		a[1]=x; a[2]=y;
		for(int i=1; i<=n-1; i++) if(i!=x && i!=y) a[++len]=i;
		for(int i=1; i<n-1; i++) printf("%d %d\n",a[i],a[i+1]),printf("%d %d\n",a[i]+n,a[i+1]+n);
		printf("%d %d\n",a[n-1],a[1]+n);
		printf("%d %d\n%d %d\n",n,a[1],a[2],n+n);
	}
	else if(n%4==1){
		for(int i=1; i<n-2; i++) printf("%d %d\n",i,i+1),printf("%d %d\n",i+n,i+1+n);
		printf("%d %d\n",n-2,1+n);
		printf("%d %d\n%d %d\n",n,n-1,n-1,1);
		printf("%d %d\n%d %d\n",1,n+n,n+n,n-1+n);
	}
	else{
		int len=1; a[1]=3;
		for(int i=1; i<=n-3; i++) if(i!=3) a[++len]=i;
		for(int i=1; i<n-3; i++) printf("%d %d\n",a[i],a[i+1]),printf("%d %d\n",a[i]+n,a[i+1]+n);
		printf("%d %d\n",a[n-3],a[1]+n);
		printf("%d %d\n%d %d\n",n-1,n-2,n-2,1);
		printf("%d %d\n%d %d\n",1,n-1+n,n-1+n,n-2+n);
		printf("%d %d\n%d %d\n",n,3,n-2,n+n);
	}
	return 0;
}

Measured memory_bytes: 3200
import itertools
l, r = map(int, input().split())

if r-l >= 2018:
  print(0)
else:
  l_mod = l%2019
  r_mod = r%2019
  min_mod = float('inf')
  if l_mod <= r_mod:
    for c in itertools.combinations(range(l_mod, r_mod+1), 2):
      min_mod = min(min_mod, (c[0]*c[1])%2019)
    print(min_mod)
  else:
    print(0)

    




Measured memory_bytes: 40812
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <set>
#include <map>
// #include <bits/stdc++.h>

using namespace std;
typedef long long li;

// Index range: [1, n]
// sum(x) returns the sum over [1, x]
// add(x, v) adds v to the value at x.
struct BIT {
    int n;
    vector<li> bit;

    BIT(int _n): n(_n), bit(_n + 1) {}

    li sum(int i) {
        li s = 0;
        while (i > 0) {
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }

    void add(int i, li x) {
        while (i <= n) {
            bit[i] += x;
            i += i & -i;
        }
    }
};

int main() {
    li n;
    cin >> n;
    vector<li> xs(n);
    for (int i = 0; i < n; ++i) {
        cin >> xs[i];
        xs[i] = xs[i] * 1e6 + i;
    }

    const li cnt_threshold = n * (n + 1) / 2 / 2 + 1;
    li p = -1, q = 2e15 + 7;

    while (p + 1 < q) {
        li m = (p + q) / 2;

        li cnt = 0;
        BIT bit(4 * (n + 10));
        const li OFFSET = 2 * n + 10;
        li acc = 0;

        for (int i = 0; i < n; ++i) {
            li y = (xs[i] <= m) ? 1 : -1;
            bit.add(acc + OFFSET, 1);
            acc += y;
            // accumulate prev_count[<0]
            cnt += bit.sum(acc - 1 + OFFSET);
        }

        if (cnt < cnt_threshold) {
            p = m;
        } else {
            q = m;
        }
    }

    cout << q / (li) 1e6 << endl;
    return 0;
}


Measured memory_bytes: 4184
from collections import deque
n,m=map(int,input().split())
g=[[] for i in range(n)]
INF=1001001001
par=[INF for i in range(n)]
par[0]=0
for i in range(m):
  s,t=map(int,input().split())
  g[s-1].append(t-1)
  g[t-1].append(s-1)

q=deque([])
q.append(0)
while q:
  now = q.popleft()
  for i in g[now]:
    if par[i]==INF:
      par[i]=now
      q.append(i)

print("Yes")
for i in range(1,n):
  print(par[i]+1)

Measured memory_bytes: 33920
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define REP2(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; ++i)
#define REP3(i, l, r) for (int i = (l), i##_len = (int)(r); i < i##_len; ++i)
#define GET_MACRO_REP(_1, _2, _3, NAME, ...) NAME
#define REP(...) GET_MACRO_REP(__VA_ARGS__, REP3, REP2) (__VA_ARGS__)
#define RREP2(i, n) for (int i = (n - 1); i >= 0; --i)
#define RREP3(i, l, r) for (int i = (r - 1), i##_len = (l); i >= i##_len; --i)
#define GET_MACRO_RREP(_1, _2, _3, NAME, ...) NAME
#define RREP(...) GET_MACRO_REP(__VA_ARGS__, RREP3, RREP2) (__VA_ARGS__)
#define IN(type, n) type n; cin >> n
#define INALL(type, v) REP(i, v.size()) { IN(type, _tmp); v.at(i) = _tmp; }
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#ifdef _DEBUG
#define DEBUG(x) cout << #x << ": " << x << endl
#else
#define DEBUG(x)
#endif

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

int main() {
  IN(int, N);
  int count = 0;
  REP(i, N) {
    IN(int, D1);
    IN(int, D2);
    if (D1 == D2) {
      count++;
      if (count >= 3) {
        cout << "Yes" << endl;
        return 0;
      }
    } else {
      count = 0;
    }
  }
  cout << "No" << endl;

  return 0;
}


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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			int k = cin.Int();
			int[] p = cin.ArrayInt(n);


			var count = new int[n];
			var ss = new SortedSet<int>();
			for (int i = 0; i < k; i++) {
				ss.Add(p[i]);
				count[p[i]]++;
			}

			int ren = 0;
			int pp = -1;
			var ni = new bool[n];
			for (int i = 0; i < n; i++) {
				if (p[i] >= pp) {
					ren++;
					if (ren >= k) {
						ni[i] = true;
					}
				} else {
					ren = 1;
				}

				pp = p[i];
			}

			int ans = 1;
			bool isNoSort = ni[k - 1];
			for (int i = k; i < n; i++) {
				int min = ss.Min;
				count[p[i - k]]--;
				if (count[p[i - k]] == 0) {
					ss.Remove(p[i - k]);
				}

				ss.Add(p[i]);
				count[p[i]]++;

				int max = ss.Max;
				if (p[i - k] != min || p[i] != max) {
					if (ni[i]) {
						if (isNoSort == false) {
							++ans;
						}

						isNoSort = true;
					} else {
						++ans;
					}
				}
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}

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

int main() {
  int A, B;
  cin >>B >>A;
  
  int Ahi,Alow, Bhi, Blow;
  
  Alow=A*10;
  Ahi =(A+1)*10;
  Blow=ceil(B/0.08);
  Bhi =floor((B+1)/0.08);
  
  int st, en;
  if(Alow > Blow){
    st = Alow;
  }else{
    st = Blow;
  }
  
  if(Ahi>Bhi){
    en = Bhi;
  }else{
    en = Ahi;
  }
  
  //cout <<st<<" " <<en <<endl;
  
  int ans=-1;
  if(st<en) ans=st;
  
  cout<<ans<<endl;
  
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;


int main(){
  int N,M,C; cin>>N>>M>>C;
  vector<int> b(M);
  rep(i,M) cin>>b[i];

  vector<int> a(M);
  int ans=0;

  rep(i,N){
    int c=C;
    rep(j,M){
      cin>>a[j];
      c+=a[j]*b[j];
    }
    if(0<c)
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main()
{
    int n;

    scanf("%d",&n);

    int i,ans = 1,buf = 0;
    for (i = 1; i <= n; i++)
    {
        if((int)log2(ans) < (int)log2(i))ans = i;
    }

    printf("%d",ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto x : v) cerr << x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int i = 0; i < (n); ++i) cerr << a[i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
char S[6005];
int occa[3005], occb[3005], times[6005];
string ans[3005];
int main() {
	int n;
	scanf("%d%s", &n, S);
	int len = strlen(S);
	for (int i = 0, a = 0, b = 0; i < len; ++i) {
		if (S[i] == 'a') {
			occa[++a] = i;
			times[i] = a;
		} else {
			occb[++b] = i;
			times[i] = b;
		}
	}
	string best;
	for (int i = n; i >= 1; --i) {
		// start from i-th occurence
		if (occa[i] < occb[i]) {
			int t = i;
			for (int j = occa[i] + 1; j < occb[i]; ++j)
				t = max(t, times[j]);
			ans[i] = "ab" + ans[t + 1];
		} else {
			int t = i;
			while (t <= n && occb[t + 1] < occa[t]) {
				++t;
			}
			for (int j = occb[i]; j < len; ++j) {
				if (times[j] >= i && times[j] <= t) ans[i] += S[j];
			}
			ans[i] += ans[t + 1];
		}
		ans[i] = max(ans[i], ans[i + 1]);
		best = max(best, ans[i]);
	}
	printf("%s\n", best.c_str());
}


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

int main() {
  unsigned long long n,sum = 0;
  cin >> n;
  vector<unsigned long long> a(n);
  for(unsigned long long i = 0; i < n; i++){
  	cin >> a[i];
  }
  sort(a.begin(),a.end(),greater<unsigned long long>());
  sum += a[0];
  for(unsigned long long i = 3; i <= n ; i += 1){
    	sum += a[(i - 1)/2];
  }
  cout << sum << endl;
  return 0;
}

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

int main() {
  int N, K, x, ans;
  ans = 0;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> x;
    if (x > K - x) {
      ans += 2 * (K - x);
    }
    else {
      ans += 2 * x;
    }
  }
  cout << ans << endl;
  
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
const ll mod=1000000007; // 998244353 = (119<<23)+1
ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
// head
const int nax=1e5+7;
int A,B,q;
ll a[nax],b[nax];
int main() {
	  ios::sync_with_stdio(false);
  	cin.tie(0);
		cin>>A>>B>>q;
		rep(i,0,A) cin>>a[i];
		rep(i,0,B) cin>>b[i];
		sort(a,a+A);
		sort(b,b+B);
		rep(i,0,q) {
			ll x,ans=1e17;
			cin>>x;
			int p1=lower_bound(a,a+A,x)-a;
			int p2=lower_bound(b,b+B,x)-b;
			if(p1>0&&p2>0) ans=min(ans,x-min(a[p1-1],b[p2-1]));
			if(p1<A&&p2<B) ans=min(ans,max(a[p1],b[p2])-x);
			if(p1>0&&p2<B) ans=min(ans,min(abs(x-a[p1-1]),abs(x-b[p2]))*2+max(abs(x-a[p1-1]),abs(x-b[p2])));
			if(p2>0&&p1<A) ans=min(ans,min(abs(x-a[p1]),abs(x-b[p2-1]))*2+max(abs(x-b[p2-1]),abs(x-a[p1])));
			cout<<ans<<'\n';
		}
		return 0;
}

Measured memory_bytes: 2944
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')

N, H = LI()
a = [0]*N; b = [0]*N
for i in range(N):
    a[i], b[i] = LI()
maxa = max(a)
usefulb = []
for i in b:
    if i>maxa:
        usefulb.append(i)
#print(usefulb)
usefulb.sort(reverse = True)
cur = int(0)
LastH = H
for v in usefulb:
    LastH -= v
    cur +=1
    if LastH<=0:
        break
#print(LastH, maxa)
if LastH>0:
    cur += ((LastH+maxa-1)//maxa)

ans = cur
print(ans)

Measured memory_bytes: 49756
import java.util.Arrays;
import java.util.Scanner;

class Main{

	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
						int N = scanner.nextInt();
		//				int K = scanner.nextInt();

		int[] data = new int[N];
		for(int i = 0;i < N;i++){
			data[i] = scanner.nextInt();
		}
		Arrays.sort(data);
		int ans = 1;
		for(int i =0;i < N-1;i++){
			if(data[i] != data[i+1]){
				ans++;
			}
		}
		System.out.println(ans);
	}
}


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

int main() {
	int x, h, m, s;
	cin >> x;
	h = x / 3600;
	int a = x % 3600;
	m = a / 60;
	int b = a % 60;
	s = b;
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}

Measured memory_bytes: 3116
N = int(input())
H = tuple(map(int, input().split()))

dp = [0] * N
dp[1] = abs(H[1]-H[0])
if N > 2:
    for i in range(2, N):
        dp[i] = min(dp[i-2] + abs(H[i]-H[i-2]), dp[i-1] + abs(H[i]-H[i-1]))
else:
    print(dp[-1])
    exit()

print(dp[-1])


Measured memory_bytes: 14184
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#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 r,d,x;
    cin >> r >> d >> x;
    rep(i,10){
        x = x*r - d;
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    int s=0,maxi=0;
    cin>>t;
    while(t--)
    {
        int a,b;
        cin>>a>>b;
        if(a==b)
        {
            s++;
            maxi=max(s,maxi);

        }
        else
        {
            s=0;
        }
    }
    if(maxi>=3)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
}


Measured memory_bytes: 3604
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
ll gcd(ll a, ll b);
int main(){
cin.tie(0);
string t,s;
ll temp=0,result=9999990;
cin>>s;
cin>>t;
for(ll i=0;i<s.length()-t.length()+1;i++){
    temp=0;
    for(ll n=0;n<t.length();n++){
        if(s[i+n]!=t[n])temp++;
    }
    if(temp<=result)result=temp;
}
cout<<result;
return 0;
}






ll gcd(ll a, ll b){

   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }

}

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

int main(){
  int k;
  char c;
  string s;
  vector<string> strvec;
  
  cin >> s;
  cin >> k;
  for(int i=1;i<=5 && i<=s.size();i++){
    for(int j=0;j<s.size()-(i-1);j++){
      strvec.push_back(s.substr(j,i));
    }
  }
  /*for(string ss : strvec){
    cout << ss << endl;
  }*/
  sort(strvec.begin(),strvec.end());
  strvec.erase(unique(strvec.begin(),strvec.end()),strvec.end());
  cout << strvec.at(k-1) << endl;
}
      
  
        
        
        
    
  

Measured memory_bytes: 1660
#include <stdio.h>
#include <string.h>

int main(void)
{
    char ss[100];
    int l, i, j, ans_l, flg = 1;

    scanf("%s", ss);
    l = strlen(ss);

    ans_l = l - 7;


    for (i = 0; i < l; i++) {
        char ans[8];
        for (j = 0; j < l; j++) {
            if (j < i)
                ans[j] = ss[j];
            else if(j > i + ans_l - 1)
                ans[j - ans_l] = ss[j];
            }
        ans[7] = '\0';


        if (strcmp(ans, "keyence") == 0) {
            flg = 0; break;
        }
    }

    if (flg == 0)
        printf("YES");
    else
        printf("NO");

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>                          
using namespace std;
long long a,b,k;                                          
int main(){
    cin>>a>>b>>k;
    if(a<=k) cout<<0<<" ",k-=a;
    else cout<<a-k<<" ",k=0;
    if(b<=k) cout<<0;
    else cout<<b-k;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.next();
		int q = scanner.nextInt();

		List<String> before = new ArrayList<String>();
		List<String> after = new ArrayList<String>(Arrays.asList(s.split("")));

		boolean normal = true;
		boolean f;
		String c;
		for (int i = 0; i < q; i++) {
			if (scanner.nextInt() == 2) {
				f = scanner.nextInt() == 1;
				c = scanner.next();
				if (normal == f)
					before.add(c);
				else
					after.add(c);
			} else
				normal = !normal;
		}

		if (normal) {
			Collections.reverse(before);
			System.out.println(String.join("", before) + String.join("", after));
		} else {
			Collections.reverse(after);
			System.out.println(String.join("", after) + String.join("", before));
		}

	}

}


Measured memory_bytes: 174200
def is_paintable(h,w,matrix):
    # 上
    if h-1 >= 0 and w >= 0:
        if(matrix[h-1][w] == '#'):
            return True
        
    # 左
    if h >= 0 and w-1 >= 0:
        if(matrix[h][w-1] == '#'):
            return True
    
    # 右
    if h >= 0 and w+1 < W:
        if(matrix[h][w+1] == '#'):
            return True

    # 下
    if h+1 < H and w >= 0:
        if(matrix[h+1][w] == '#'):
            return True
            
    return False

H,W = map(int,input().split())

matrix = []
for i in range(H):
    matrix.append(list(input()))

paintable = True
for h in range(H):
    for w in range(W):
        if matrix[h][w] == '#':
            if(not is_paintable(h, w, matrix)):
                paintable = False
                break
    if(not paintable):
        break

if(paintable):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

signed main(){
    int N,M;
    cin>>N>>M;
    vector<vector<int>> AB(M,vector<int>(2));
    REP(i,M){
        REP(j,2){
            cin>>AB[i][j];
        }
    }
    for(int i=1;i<=N; i++){
        int ans = 0;
        REP(j,M){
            REP(k,2){
                if(AB.at(j).at(k)==i) ans ++;
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
a,b = map(int, input().split())

if a%2 == 0 and b%2 == 0:
  k = (a+b)/2
  print(int(k))
elif a%2 != 0 and b%2 != 0:
  k = (a+b)/2
  print(int(k))
else:
  print("IMPOSSIBLE")




Measured memory_bytes: 39792
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

const double pie = acos(-1.0);

// 最大公約数
ll gcd(ll a, ll b)
{
   if (a%b == 0) {
       return(b);
   } else {
       return(gcd(b, a%b));
   }
}

// 最小公倍数
ll lcm(ll a, ll b){
   return a / gcd(a, b) * b;
}

//素数判定
bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された
    if(n % 2 == 0 || n % 3 == 0) return false;
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }
    return true;
}

void solve() {
    ll n; cin >> n;
    ll ans = 1, t;
    rep(i, 0, n){
        cin >> t;
        ans = lcm(ans, t);
    }
    cout << ans << endl;
}

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

    solve();
    return 0;
}


Measured memory_bytes: 256
import statistics

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

t = []
for i in range(N):
    t.append(A[i] - i)

if len(A) % 2 == 1:
    b = statistics.median(t)
    ans = 0
    for i in range(N):
        ans += abs(A[i] - i - b)
    print(ans)
else:
    t.sort()
    b1 = t[len(t) // 2]
    b2 = t[(len(t) // 2) - 1]
    ans1 = 0
    ans2 = 0
    for i in range(N):
        ans1 += abs(A[i] - i - b1)
    for i in range(N):
        ans2 += abs(A[i] - i - b2)
    print(min(ans1, ans2))

Measured memory_bytes: 27256
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char* argv[])
{
  int A, B;
  std::cin >> A >> B;

  if (A + B > 9) {
    std::cout << "error" << std::endl;
  } else {
    std::cout << A+B << std::endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX = 10000;
int A[MAX];

int main()
{
	int n,k,y,x;
	scanf("%d %d %d %d", &n, &k, & y, &x);
	if (k > n)
		cout << n*y << endl;
	else
		cout<< k*y + x*(n-k) << endl;
 	return 0;
}

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

int main() {
  int H, W;
  while(1){
    cin >> H >> W;
    if(H == 0 && W == 0)break;
    for (int i = 1; i <= H; i++) {
      for (int j = 1; j <= W; j++) {
        if ( (i-j)%2 == 0 ) {
          cout << "#";
        } else {
          cout << ".";
        }
      }
      cout << "\n";
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
char s[2][100];
int dp[55][3][3];
int main() {
	int n;
	scanf("%d", &n);
	scanf("%s%s", s[0], s[1]);
	for (int a = 0; a < 3; ++ a) {
		for (int b = 0; b < 3; ++ b) {
			if ((s[0][0] == s[1][0]) == (a == b)) dp[0][a][b] ++;
		}
	}
	for (int i = 1; i < n; ++ i) {
		for (int a = 0; a < 3; ++ a) {
			for (int b = 0; b < 3; ++ b) {
				for (int c = 0; c < 3; ++ c) {
					for (int d = 0; d < 3; ++ d) {
						if ((s[0][i] == s[1][i]) == (c == d)) {
							if ((s[0][i] == s[0][i - 1]) == (c == a)) {
								if ((s[1][i] == s[1][i - 1]) == (d == b)) {
									(dp[i][c][d] += dp[i - 1][a][b]) %= MOD;
								}
							}
						}
					}
				}
			}
		}
	}
	int ans = 0;
	for (int a = 0; a < 3; ++ a) {
		for (int b = 0; b < 3; ++ b) {
			(ans += dp[n - 1][a][b]) %= MOD;
		}
	}
	printf("%d\n", ans);
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std ;
using vi = vector<int> ;

int cnt = 0 ;

void insertionsort(vi &a,int g){
	for(int i=g;i<a.size();i++){
		int v = a.at(i) ;
		int j = i-g ;
		while(j>=0&&a.at(j)>v){
			a.at(j+g) = a.at(j) ;
			j -= g ;
			cnt++ ;
		}
		a.at(j+g) = v ;
	}
}

void shellsort(vi &g,vi &a){
	for(int i=0;i<g.size();i++) insertionsort(a,g.at(i)) ;
}

int main(){
	int n ; cin >> n ;
	vi a(n) ;
	for(int i=0;i<n;i++) cin >> a.at(i) ;
	vi g ;
	int i = 1 ;
	while(i<=n){
		g.push_back(i) ;
		i = i*3+1 ;
	}
	reverse(g.begin(),g.end()) ;
	cout << g.size() << endl ;
	for(int i=0;i<g.size();i++){
		cout << g.at(i) ;
		if(i==g.size()-1) cout << endl ;
		else cout << " " ;
	}
	shellsort(g,a) ;
	cout << cnt << endl ;
	for(int i=0;i<n;i++){
		cout << a.at(i) << endl ;
	}
}


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

using ll = long long;
const ll INF=1e15+7;
struct Edge {
  int to;
  ll weight;
  Edge(int t, ll w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;

int n;
vector<ll> d;

void dijkstra(Graph &G, int x) {
  int i;
  priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> pq;
  for(i=0; i<n; i++)
    d.at(i) = INF;
  d.at(x) = 0;
  pq.push(make_pair(0,x));

  while(!pq.empty()) {
    pair<int,int> p = pq.top();
    pq.pop();
    int v = p.second;

    if(d[v] < p.first)
      continue;
    for(i=0; i<G[v].size(); i++) {
      Edge e = G[v][i];
      if(d[e.to] > d[v] + e.weight) {
        d[e.to] = d[v] + e.weight;
        pq.push(make_pair(d[e.to], e.to));
      }
    }
  }
}

int main() {
  int m,i,u,v,a,b,s,t;
  cin >> n >> m >> s >> t;
  d.resize(n);
  vector<ll> r(n);
  priority_queue<pair<ll,int>, vector<pair<ll,int>>, greater<pair<ll,int>>> res;

  Graph Gy(n), Gs(n);
  for(i=0; i<m; i++) {
    cin >> u >> v >> a >> b;
    Gy[u-1].push_back(Edge(v-1, a));
    Gy[v-1].push_back(Edge(u-1, a));
    Gs[u-1].push_back(Edge(v-1, b));
    Gs[v-1].push_back(Edge(u-1, b));
  }

  dijkstra(Gy, s-1);
  for(i=0; i<n; i++)
    r.at(i) = d.at(i);
  
  dijkstra(Gs, t-1);
  for(i=0; i<n; i++)
    r.at(i) += d.at(i);
    
  for(i=0; i<n; i++)
    res.push(make_pair(r.at(i), i));
  for(i=0; i<n; i++) {
    pair<ll,int> a = res.top();
    while(a.second < i) {
      res.pop();
      a = res.top();
    }
    cout << 1000000000000000 - a.first << endl;
  }
}

Measured memory_bytes: 19824