akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}


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

	int s = 7 % k;

	for(int c=1; c<=k; c++){

		if(!s){
			cout << c << endl;
			return 0;
		}
		s = (s * 10 + 7) % k;
	}
	cout << -1 << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using vi = vector<int>;

#define in(v) v; cin >> v;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
void debug2() {cerr << "\n";}
template<class First> void debug2(const First& first) {cerr<<first<<" ";}
template<class First, class... Rest> void debug2(const First& first, const Rest&... rest) {cerr<<first<<" ";debug2(rest...);}
#else
#define debug(...) 42
#define debug2(...) 42
#endif

int main() {
  int A, B, C, K;
  ins(A, B, C, K);

  if (A >= K) {
    cout << K << endl;
  } else {
    if (A + B >= K) {
      cout << A << endl;
    } else {
      cout << A - (K-(A+B)) << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <numeric>
#include <cassert>

using namespace std;

class abcB {
public:
    void solve(istream& in, ostream& out) {
        int N, M;
        in >> N >> M;
        vector<pair<int,int>> ab(N), cd(M);
        for (int i = 0; i < N; ++i) {
            in >> ab[i].first >> ab[i].second;
        }
        for (int i = 0; i < M; ++i) {
            in >> cd[i].first >> cd[i].second;
        }
        for (int i = 0; i < N; ++i) {
            int mn = 1000*1000*1000, ind = -1;
            for (int j = 0; j < M; ++j) {
                int tmp = abs(ab[i].first - cd[j].first) + abs(ab[i].second - cd[j].second);
                if (tmp < mn) {
                    mn = tmp;
                    ind = j;
                }
            }
            out << ind+1 << "\n";
        }
    }
};


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

	abcB solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  int a=in();
  char op; cin>>op;
  int b=in();
  if(op=='+') print(a+b);
  else print(a-b);

  return 0;
}

Measured memory_bytes: 256
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
A = list(map(int,input().split()))
S = sum(A) % mod
for i in range(n):
  S =(S- A[i]) % mod
  ans += S * A[i]
  ans %= mod
print(ans)

Measured memory_bytes: 103536
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;


int main() {
    string sky;
    string R("R");
    string S("S");
    cin >> sky;
    if (sky[0] == R[0]) {
        if (sky[1] == R[0]){
            if (sky[2] == R[0]) {
                cout << 3;
                return 0;
            }
            else {
                cout << 2;
                return 0;
            }

        }
        else {
            cout << 1;
            return 0;
        }
    }
    else if (sky[1] == R[0]) {
        if (sky[2] == R[0]) {
            cout << 2;
            return 0;
        }
        else
        {
            cout << 1;
            return 0;
        }

    }
    else if (sky[2] == R[0]) {
        cout << 1;
        return 0;
    }
    else {
        cout << 0;
        return 0;
    }
    
    return 0;
}

Measured memory_bytes: 3164
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<vector>

using namespace std;

int main(){
	int n;
	int d,c;
	int count;
	int date[51][31];
	int holder[51][51];
	int t=1;

	while(cin>>n,n){
	
		for(int i=1;i<51;i++){
			for(int j=1;j<31;j++)
				date[i][j]=0;
		}
		for(int i=1;i<51;i++){
			for(int j=1;j<51;j++)
				holder[i][j]=0;
		}
		
	for(int i=1;i<=n;i++){
		cin>>c;
		holder[i][i]=1;
		for(int j=0;j<c;j++){
			cin>>d;
			date[i][d]=1;
		}
	}
	int count1=0,count2=0;
	for(t=1;t<31;t++){	
		if(count1==n ||count2==n)break;
		for(int i=1;i<=n;i++){	
			if(count1==n ||count2==n)break;
			if(date[i][t]==1){
			
				for(int j=i+1;j<=n;j++){
					if(count1==n ||count2==n)break;
					count1=0;
			        count2=0;

					if(date[j][t]==1){
						
						for(int k=1;k<=n;k++){
							if(holder[j][k]==1){
								holder[i][k]=1;
								count1++;
							}
							 if(holder[i][k]==1){
								holder[j][k]=1;
								count2++;
							}

						}
						if(count1==n ||count2==n){
							cout<<t<<endl;
							if(t==30)t=32;
							break;
						}
					}

				}
			}
		}
	}
	if(t==31)cout<<-1<<endl;
	}

	return 0;
}

Measured memory_bytes: 1172
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			long[] a = in.nextLongArray(n);

			long ans = 0;

			for (int i = 0; i < n; i++) {
				while (a[i] % 2 == 0) {
					a[i] /= 2;
					ans++;
				}
			}

			out.println(ans);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}
}


Measured memory_bytes: 25300
#include <stdio.h>
int main(void){
    // Your code here!
    int N, A[20], B[20], C[20];
    long sum = 0;
    scanf("%d",&N);
    
    for(int i = 0; i < N; i++)
        scanf("%d",&A[i]);
    for(int i = 0; i < N; i++)
        scanf("%d",&B[i]);
    for(int i = 0; i < N-1; i++)
        scanf("%d",&C[i]);
    
    sum += B[A[0]-1];
    for(int i = 1; i < N; i++)
    {
        if(A[i]-A[i-1] == 1)
            sum += B[A[i]-1] + C[A[i-1]-1];
        else
            sum += B[A[i]-1];
    }
        
    printf("%ld\n",sum);
}


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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	int cnt = 0;
	for(int i=1;i<n+1;i++){
		int a;
		cin >> a;
		if(a % 2 != 0 && i % 2 != 0){
			cnt++;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3176
/*
[ ( ^ _ ^ ) ]
*/
// problem: atc/abc166_b
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1000000000



int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    vector<int> f(n+1);
    for(int i=0; i<k; i++) {
        int d;
        scanf("%d", &d);
        for(int j=0; j<d; j++) {
            int s;
            scanf("%d", &s);
            f[s] = 1;
        }
    }
    int rs = 0;
    for(int i=1; i<=n; i++) {
        if(f[i]==0) rs++;
    }
    printf("%d\n", rs);
}


Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str[2];
    string str1;
    cin>>str[0]>>str[1];
    int a[2];
    cin>>a[0]>>a[1];
    cin>>str1;
    if(str1==str[0])
    {
        cout<<a[0]-1<<" "<<a[1]<<endl;
    }
    else if(str1==str[1])
    {
        cout<<a[0]<<" "<<a[1]-1<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int x,y,z;
int main()
{
	scanf("%d %d %d",&x,&y,&z);
	int cik=fabs(z-y);
	//printf("%d",cik);
	if(cik%2==0)
		printf("Alice");
	else
		printf("Borys");
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int n,i,a[6]={0,0,0,0,0,0},j;
double x;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%lf",&x);
if(x<165)
a[0]++;
else if(170>x)
a[1]++;
else if(175>x)
a[2]++;
else if(180>x)
a[3]++;
else if(185>x)
a[4]++;
else a[5]++;
}
for(i=0;i<6;i++){
printf("%d:",i+1);
for(j=0;j<a[i];j++)
printf("*");
printf("\n");
}
return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cmath>
#include <vector>

using namespace std;

double stdev(vector<double> s) {
    double ave=0, sq_ave=0;
    for (double d: s) {
        ave += d;
        sq_ave += d*d;
    }
    ave /= s.size();
    sq_ave /= s.size();

    return sqrt(sq_ave-ave*ave);
}

int main() {
    while (true) {
        size_t n;
        scanf("%zu", &n);
        if (!n) return 0;

        vector<double> s(n);
        for (size_t i=0; i<n; ++i)
            scanf("%lf", &s[i]);

        printf("%.12f\n", stdev(s));
    }
}

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

#define SIZE_STRING 101	// 10の1乗が2桁なので、10の100乗は101桁
#define SIZE_NUM 2
#define FIRST_IS_LARGE 1
#define FIRST_IS_SMALL 2
#define FLG_EQUAL 0

int main(void)
{
	/* 変数宣言 */
	char cNUM[SIZE_NUM][SIZE_STRING + 1];	// 数字格納配列。NULLストッパ入りのサイズ
	int iLoop;								// ループカウンタ
	int iFlg = FLG_EQUAL;					// 数の大小フラグ
	int iFirst = 0;							// 1つ目の数字の1桁を格納する変数
	int iSecond = 0;						// 2つ目の数字の1桁を格納する変数
	
	/* 変数初期化 */
	memset(cNUM, 0x00, sizeof(cNUM));
	
	/* 読み込み */
	for(iLoop = 0; iLoop < SIZE_NUM; iLoop++)
	{
		scanf("%s", cNUM[iLoop]);
	}
	
	/************************************************************************/
	/* ●数の大小比較 														*/
	/* 101桁ループさせて、上の桁から順に、1桁ずつ比較。						*/
	/* 1桁ずつ比較で大小があれば大小フラグを立てる。						*/
	/* ただし、ループの途中で片方がNULLになったら、もう片方のほうが大きい。 */
	/************************************************************************/
	for(iLoop = 0; iLoop < SIZE_STRING; iLoop++)
	{
		/* 文字→数値変換 */
		iFirst  = cNUM[0][iLoop] - '0';
		iSecond = cNUM[1][iLoop] - '0';
		
		/* 片方がNULLなら、もう片方が大きいと判定し、break */
		/* 両方がNULLなら、break */
		if(cNUM[0][iLoop] != 0x00 && cNUM[1][iLoop] == 0x00)
		{
			iFlg = FIRST_IS_LARGE;
			break;
		}
		
		if(cNUM[0][iLoop] == 0x00 && cNUM[1][iLoop] != 0x00)
		{
			iFlg = FIRST_IS_SMALL;
			break;
		}
		
		if(cNUM[0][iLoop] == 0x00 && cNUM[1][iLoop] == 0x00)
		{
			break;
		}
		
		/* 数の大小フラグが初期値以外の場合、1桁ずつの比較はもうしない */
		if(iFlg != FLG_EQUAL)
		{
			continue;
		}
		
		/* 大小がある場合数の大小フラグを立てる */
		if(iFirst > iSecond)
		{
			iFlg = FIRST_IS_LARGE;
		}
		
		if(iFirst < iSecond)
		{
			iFlg = FIRST_IS_SMALL;
		}
	}
	
	/* 結果出力 */
	switch(iFlg){
	case FIRST_IS_LARGE:
		printf("GREATER\n");
		break;
	
	case FIRST_IS_SMALL:
		printf("LESS\n");
		break;
		
	default:
		printf("EQUAL\n");
		break;
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m,x[100000],ans=0,memo[100000];
    scanf("%d%d",&n,&m);
    rep(i,m){
        scanf("%d",x+i);
    }
    sort(x,x+m);
    if(m==1)cout<<0<<endl;
    else{
        rep(i,m-1){
            memo[i]=x[i+1]-x[i];
            ans+=x[i+1]-x[i];
        }
        sort(memo,memo+m-1);
        rep(i,n-1){
            ans-=memo[m-i-2];
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main(){
    int n;
    cin >> n;
    vector<pii> vp;
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        vp.push_back({a+b, a});
    }
    sort(vp.rbegin(), vp.rend());
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += (i%2)*(-vp[i].first)+vp[i].second;
    } 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
k = int(input())
#print(k)
i = list(map(int, input().split()))
#print(i[0])
#print(i[1])
x = 0
for n in range(i[0], i[1]+1):
  if n % k == 0:
    print("OK")
    x = 1
    break
if x == 0:    
  print("NG")

Measured memory_bytes: 9124
#include <cstdio>
#include <queue>
#include <vector>
#include <cstdlib>
#include <algorithm>
using namespace std;

#define ST 999

class Node
{
public:
	int n,d,s;
	vector<int> to,c;
	Node()
	{}
	
	Node(int n, int d, int s)
	:n(n),d(d),s(s)
	{}
};

class Trl
{
public:
	int p,h,l,w;
	double c;
	Trl(int p, double c, int h, int l, int w)
	:p(p),c(c),h(h),l(l),w(w)
	{}
	
	bool operator<(const Trl& t) const
	{
		return c>t.c;
	}
};

short h[15][1<<15];

int main()
{
	int N;
	scanf("%d", &N);
	Node node[15];
	
	for(int i=0; i<N; i++)
	{
		int n,d,s;
		scanf("%d%d%d", &n,&d,&s);
		
		node[i]=Node(n,d,s);
	}
	
	for(int i=0; i<N; i++)
	for(int j=i+1; j<N; j++)
	{
		int d=abs(node[i].d-node[j].d);
		node[i].to.push_back(j);
		node[j].to.push_back(i);
		node[i].c.push_back(d);
		node[j].c.push_back(d);
	}
	
	priority_queue<Trl> q;
	for(int i=0; i<N; i++)
		q.push(Trl(i,0,(1<<i), ST, node[i].s));

	for(int i=0; i<(1<<15); i++)
	for(int j=0; j<15; j++)
		h[j][i]=-2;
		
	while(1)
	{
		Trl t=q.top(); q.pop();
		if(h[t.p][t.h]!=-2) continue;
		h[t.p][t.h]=t.l;
		
		if(t.h==(1<<N)-1)
		{
			int p=t.p, th=t.h;
			vector<int> paths;
			while(1)
			{
				paths.push_back(node[p].n);
				short tp=h[p][th];
				th^=(1<<p);
				p=tp;
				if(p==ST) break;
			}
			reverse(paths.begin(), paths.end());
			for(int i=0; i<paths.size(); i++)
			{
				if(i!=0) printf(" ");
				printf("%d", paths[i]);
			}
			puts("");
			break;
		}
		
		for(int i=0; i<node[t.p].to.size(); i++)
		{
			int next=node[t.p].to[i];
			if(t.h&(1<<next)) continue;
			
			int th=t.h|(1<<next);
			if(h[next][th]!=-2) continue;
			
			int tw=t.w+node[t.p].s;
			double tc=node[t.p].c[i]*(70+tw*20.0)/(2000.0);
			
			q.push(Trl(next, t.c+tc, th, t.p, tw));
		}
	}
}

Measured memory_bytes: 14000
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

const int INF = 1 << 30;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> grid(H);
    for (auto& g : grid) {
        cin >> g;
    }
    int white = 0;
    for (auto& g : grid) {
        for (auto& c : g) {
            if (c == '1') {
                ++white;
            }
        }
    }
    if (white <= K) {
        cout << 0 << endl;
        return 0;
    }
    int ans = INF;
    rep(mask, 1, 1 << (H - 1)) {
        vector<int> sep;
        rep(i, 0, H - 1) {
            if ((mask >> i) & 1) {
                sep.push_back(i);
            }
        }
        vector<vector<int>> domain(H, vector<int>(W));
        int now_h = 0;
        int now_domain = 0;
        for (auto& s : sep) {
            while (now_h <= s) {
                rep(w, 0, W) {
                    domain[now_h][w] = now_domain;
                }
                ++now_h;
            }
            ++now_domain;
        }
        while (now_h < H) {
            rep(w, 0, W) {
                domain[now_h][w] = now_domain;
            }
            ++now_h;
        }
        ++now_domain;
        int now_ans = __builtin_popcount(mask);
        vector<int> cnt(now_domain, 0);
        vector<bool> cutted(W + 1, false);
        rep(w, 0, W) {
            rep(h, 0, H) {
                if (grid[h][w] == '1') {
                    ++cnt[domain[h][w]];
                }
            }
            bool is_full = false;
            rep(d, 0, now_domain) {
                if (cnt[d] > K) {
                    is_full = true;
                    break;
                }
            }
            bool impossible = false;
            if (is_full) {
                if (w == 0) {
                    impossible = true;
                    now_ans = INF;
                    break;
                }
                ++now_ans;
                rep(d, 0, now_domain) {
                    cnt[d] = 0;
                }
                rep(h, 0, H) {
                    if (grid[h][w] == '1') {
                        ++cnt[domain[h][w]];
                    }
                }
                rep(d, 0, now_domain) {
                    if (cnt[d] > K) {
                        impossible = true;
                        now_ans = INF;
                        break;
                    }
                }
                if (impossible) {
                    break;
                }
            }
        }
        chmin(ans, now_ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#ifdef LOCAL111
#else
	#define NDEBUG
#endif
#include <bits/stdc++.h>
const int INF = 1e8;
using namespace std;

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RBP(i,a) for(auto& i : a)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
#define rangej(a,b,c) ((a) <= (c) and (c) < (b))
#define rrangej(b,c) rangej(0,b,c)
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;
typedef pair<LL,LL> LP;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	string s;
	while(cin >> s){
		int cs = 0;
		int c = 0;
		REP(i,SZ(s)){
			if(s[i] == 'S') cs++;
			else{
				if(cs == 0){
					c++;	
				}else{
					cs--;
				}
			}
		}
		cout << c+cs << endl;
	}
	return 0;
}


Measured memory_bytes: 720
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H,W = map(int,readline().split())
A = [list(map(int,readline().split())) for _ in range(H)]
B = [list(map(int,readline().split())) for _ in range(H)]

X = (H + W) * 80
# X点持った状態から始める
dp = [[0] * W for _ in range(H)]
d = abs(A[0][0] - B[0][0])
dp[0][0] = (1 << (X - d))
for h in range(H):
    for w,(a,b) in enumerate(zip(A[h],B[h])):
        if h == w == 0:
            continue
        d = abs(a - b)
        x = 0
        if h != 0:
            x |= (dp[h-1][w] << d) 
            x |= (dp[h-1][w] >> d)
        if w != 0:
            x |= (dp[h][w-1] << d) 
            x |= (dp[h][w-1] >> d)
        dp[h][w] = x

dp = dp[-1][-1]

B = bin(dp)[2:]
can_make = [i - X for i,b in enumerate(B[::-1]) if b == '1']

answer = min(x if x >= 0 else -x for x in can_make)
print(answer)

Measured memory_bytes: 20724
#include <stdio.h>

int main(void)
{
    int k;
	scanf("%d", &k);

	if(k == 32)
	printf("51");
	else if(k == 24)
	printf("15");
	else if(k == 16)
	printf("14");
	else if(k == 28||k == 30)
	printf("4");
	else if(k == 8|| k==12||k== 18||k== 20|| k== 27)
	printf("5");
	else if(k == 4|| k==6||k== 9||k== 10|| k== 14||k==21||k==22||k==25||k==26)
	printf("2");
	else
	printf("1");

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF 100000000
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)






int main(){
    int k, x;
    cin >> k >> x;
    if (k * 500 >= x) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
   
  int x,y,z,r;
   
   
  scanf("%d%d",&x,&y);
   
  if(x<y){
    z=x;
    x=y;
    y=z;
  }
   
  r=x%y;
   
  while(r!=0){
    x=y;
    y=r;
    r=x%y;
     
    if(r==0) break;
  }
   
   
   
  printf("%d\n",y);
   
  return 0;
   
}

Measured memory_bytes: 1828
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <numeric>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// using namespace std;

using ll = long long;

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

void Main() {
  int N;
  std::cin >> N;

  std::vector<int> d(N);

  for (auto &di : d) {
    std::cin >> di;
  }
  std::sort(d.begin(), d.end());

  int res = d[N / 2] - d[N / 2 - 1];

  std::cout << res << std::endl;
}

int main() {
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int mod =1e9+7;
const int N = (int)2e5 + 5;

void solve(){
	int a,b,k;
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++){
		if(i%k==0){
			cout<<"OK";
			return;
		}
	}
	cout<<"NG";
    
}

int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

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

int main(){
    int k, a, b;
    cin >> k >> a >> b;

    string ans = "NG";
    for(int i=a;i<=b;i++){
        if(i%k == 0){
            ans = "OK";
            break;
        }
    }
     
    cout << ans << endl;

}

Measured memory_bytes: 3588
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}


// auto mod int
struct mint {
    LL x;
    mint(LL 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(const 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;
    }
    LL operator()() const {
        return x;
    }
};
using VM = vector<mint>;
using VVM = vector<VM>;

void solve() {
    LL n,k;
    cin >> n >> k;
    mint sum = 0;
    REP(i,k,n+2) {
        sum += 1LL * i * n - 2 * (1LL * (i - 1) * i / 2) + 1;
        //dump(sum());
    }
    cout << sum() << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int N=201010;
vector<int> adj[N];
int dist[N];
void dfs(int u,int p=-1){
	for(auto &x:adj[u]){
		if(x==p)continue;
		dist[x]=dist[u]+1;
		dfs(x,u);
	}
}
int dp[N];
int main(){
	int n;scanf("%d",&n);
	for(int i=1;i<n;i++){
		int u,v;scanf("%d%d",&u,&v);u--;v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	dfs(0);
	int a=max_element(dist,dist+n)-dist;
	dist[a]=0;
	dfs(a);
	int d=*max_element(dist,dist+n);
	dp[0]=1;dp[1]=0;
	for(int i=2;i<N;i++){
		if(dp[i-1]==0||dp[i-2]==0)dp[i]=1;
	}
	if(dp[d])puts("First");
	else puts("Second");
}

Measured memory_bytes: 22144
# coding: utf-8


def solve(*args: str) -> str:
    h1, m1, h2, m2, k = map(int, args[0].split())
    return str((h2-h1)*60 + (m2-m1) - k)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


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

int main() {
  int n, t, a;
  cin >> n >> t >> a;
  vector<int>h(n);
  rep(i,n) cin >> h[i];
  vector<int>d(n);
  int res = 1001001001;
  rep(i,n){
    d[i] = abs((t*1000-h[i]*6)-a*1000);
    res = min(res, d[i]);
  }
  rep(i,n){
    if(d[i]==res) cout << i+1 << endl;
    else continue;
  }
  return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int a,b;cin >>a>>b;
    int ans=a+b;
    ans--;ans/=2;
    ans++;
    cout <<ans <<endl;
}


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

const int N=2e5+20,MOD=1e9+7;

int n,k;
long long ans;

int main()
{
	cin>>n>>k;
	n++;
	for(int i=k;i<=n;i++)
	{
		long long lo=1ll*i*(i+1)/2,hi=1ll*i*(n-i+1+n)/2;
		ans+=hi-lo+1;
		ans%=MOD;
	}
	cout<<ans;
}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = int.Parse(ReadLine());
        var t = ReadLine().Split().Select(int.Parse).ToArray();
        var sum = t.Sum();
        var m = int.Parse(ReadLine());
        for(int i = 0; i < m; i++)
        {
            var s = ReadLine().Split().Select(int.Parse).ToArray();
            WriteLine(sum - t[s[0] - 1] + s[1]);
        }
    }
}


Measured memory_bytes: 19076
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
const int MX = 1e5 + 10, MD = 1e9 + 7;
int n, m, a, ans, tmp;
int main(){
    ios::sync_with_stdio(0) ; cin.tie(0) ;
    cin >> n >> m >> a;
    if(n + m >= a){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<int MOD>
struct ModInt {
	static const int kMod = MOD;
	unsigned x;
	ModInt() :x(0) {}
	ModInt(signed x_) { x_ %= MOD; if (x_ < 0)x_ += MOD; x = x_; }
	ModInt(signed long long x_) { x_ %= MOD; if (x_ < 0)x_ += MOD; x = x_; }
	int get()const { return (int)x; }
	ModInt &operator+=(ModInt m) { if ((x += m.x) >= MOD)x -= MOD; return *this; }
	ModInt &operator-=(ModInt m) { if ((x += MOD - m.x) >= MOD)x -= MOD; return *this; }
	ModInt &operator*=(ModInt m) { x = (unsigned long long)x*m.x%MOD; return *this; }
	ModInt &operator/=(ModInt m) { return *this *= m.inverse(); }
	ModInt operator+(ModInt m)const { return ModInt(*this) += m; }
	ModInt operator-(ModInt m)const { return ModInt(*this) -= m; }
	ModInt operator*(ModInt m)const { return ModInt(*this) *= m; }
	ModInt operator/(ModInt m)const { return ModInt(*this) /= m; }
	ModInt operator-()const { return ModInt(kMod - x); }
	bool operator==(ModInt m)const { return x == m.x; }
	bool operator!=(ModInt m)const { return x != m.x; }
	ModInt inverse()const {
		signed a = x, b = MOD, u = 1, v = 0;
		while (b) {
			signed t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		if (u < 0)u += MOD;
		return ModInt(u);
	}
};
template<int MOD>
ostream &operator<<(ostream &os, const ModInt<MOD> &m) { return os << m.x; }
template<int MOD>
istream &operator>>(istream &is, ModInt<MOD> &m) { signed long long s; is >> s; m = ModInt<MOD>(s); return is; };

using mint = ModInt<MOD>;

template<int MOD>
ModInt<MOD> pow(ModInt<MOD> a, unsigned long long k) {
	ModInt<MOD> r = 1;
	while (k) {
		if (k & 1)r *= a;
		a *= a;
		k >>= 1;
	}
	return r;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, X; cin >> N >> X;
	vector<int> S(N); rep(i, 0, N) {
		cin >> S[i];
	}
	sort(all(S), greater<>());
	dump(S);

	vector<vector<mint>> dp(2, vector<mint>(X + 1));
	dp[0][X] = 1;
	int p = 0;
	rep(i, 0, N) {
		rep(j, 0, X + 1) {
			dp[p ^ 1][j % S[i]] += dp[p][j];
			dp[p ^ 1][j] += dp[p][j] * (N - 1 - i);
		}
		dp[p].assign(X + 1, 0);
		p ^= 1;
	}
	mint ans = 0;
	rep(j, 0, X + 1) {
		ans += dp[N & 1][j] * j;
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
	int res, n;
	string ch;

	cin >> res;
	while (1) {
		cin >> ch;
		if (ch == "=")break;
		cin >> n;
		if (ch == "+")res += n;
		else if (ch == "-")res -= n;
		else if (ch == "*")res *= n;
		else if (ch == "/")res /= n;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(snip_i, n) cin >> a.at(snip_i);
  vector<ll> sum(n, 0);
  rep(i, n){
    if(i == 0) sum.at(i) = a.at(i);
    else sum.at(i) = sum.at(i-1) + a.at(i);
  }
  ll ans = 1e18;
  rep(i, n-1){
    ll s = sum.at(i), a = sum.at(n-1) - s;
    ans = min(ans, abs(s-a));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(reader.readLine());
        int bsizea = 0;
        int sizea = 0;
        int bsize = 0;
        int count = 0;
        for (int i = 0; i < n; i++) {
            String s = reader.readLine();
            for (int idx = s.indexOf("AB"); idx > -1; idx = s.indexOf("AB", idx + 2)) {
                count++;
            }
            if (s.startsWith("B") && s.endsWith("A")) {
                bsizea++;
            } else if (s.endsWith("A")) {
                sizea++;
            } else if (s.startsWith("B")) {
                bsize++;
            }
        }
        System.out.println(count + Integer.min(sizea, bsize)
                + ((sizea + bsize == 0) ? Integer.max(bsizea - 1, 0) : bsizea));
    }
}


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

int main(){
	int e, y;
	cin >> e >> y;
	
	if(e == 1) cout << 1867 + y << endl;
	else if(e == 2) cout << 1911 + y << endl;
	else if(e == 3) cout << 1925 + y << endl;
	else if(e == 4) cout << 1988 + y << endl;
	
	else{
		if(1868 <= y && y <= 1911) cout << "M" << y - 1867 << endl;
		else if(1912 <= y && y <= 1925) cout << "T" << y - 1911 << endl;
		else if(1926 <= y && y <= 1988) cout << "S" << y - 1925 << endl;
		else if(1989 <= y && y <= 2016) cout << "H" << y - 1988 << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3104
s = input()

right = [0]*(len(s)+1)
for i in range(len(s)):
    if s[i] == '<':
        right[i+1] = right[i] + 1

left = [0]*(len(s)+1)
for i in range(len(s)-1, -1, -1):
    if s[i] == '>':
        left[i] = left[i+1] + 1

ans = 0
for i in range(len(s)+1):
    ans += max(right[i], left[i])

print(ans)

Measured memory_bytes: 32920
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int count = 0;
      int result = 0;
      for(int i = 1;i <= n;i++){
      	for(int j = 1;j <= i;j++){
        	if(i%j == 0 && i%2!=0)count++;
        }
        if(count == 8)result++;
        count = 0;
      }
      System.out.println(result);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define INF 100000000
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define de cout << "debug" << endl;

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> A(N);
  vector<int> B(N);

  REP(i,N){
    cin >> A[i] >> B[i];
  }

  vector<pair<int,int>> AB(N);
  REP(i,N) AB[i] = make_pair(A[i],B[i]);
 
  sort(AB.begin(),AB.end());
  ll ans = 0;
  REP(i,N){

    int stock = AB[i].second;
    ll tmp;
    if(stock <= M){
      tmp = stock;
    }
    else {
      tmp = M;
    }
    
    M -= tmp;
    ans += AB[i].first * tmp;
    
    if(M == 0) break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

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

	sort.Sort(sort.Reverse(sort.IntSlice(ts)))

	a := ts[0]
	for i := 1; i < n; i++ {
		b := ts[i]
		d := gcd(a, b)

		a /= d
		a *= b
	}
	fmt.Println(a)
}

func gcd(a, b int) int {
	r := a % b
	for r != 0 {
		a = b
		b = r
		r = a % b
	}
	return b
}


Measured memory_bytes: 512
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<deque>

using namespace std;

void MakePrimeArray(deque<bool>& A,int n){
	
	A[0] = A[1] = false;
	for(int i=2;i<n;i++){
		A[i] = true;
	}
	
	for(int	i=2;i*i<n;i++){
	if(A[i]){
			for(int j=i*i;j<n;j+=i){
				A[j] = false;
			}
		}
	}
	
}

void yotuko(deque<int>& A){
	deque<int>::iterator it=A.begin();
	for(int i=0;i<A.size()-3;i++){
		if((*(it+1)==((*it)+2)&&(*(it+2))==(*it+6))&&(*(it+3)==(*it+8)))
			A.erase(it);
		else
			it++;
	}
}


int main(){
	
	int n=10000001;

	deque<bool> primearray;
	
	primearray.resize(n);
	
	MakePrimeArray(primearray,n);
	/*
	deque<int> prime;
	
	for(int i=13;i<n;i++){
		if(primearray[i]){
			prime.push_back(i);
		}
	}
	
	yotuko(prime);
*/
	while(true){
		int innum;
		cin >> innum;
		//scanf("%d",&innum);
		
		if(innum==0) break;
		
		int answer=0;
		answer=innum;
		while(true){
			if(primearray[answer]&&primearray[answer-2]&&primearray[answer-6]&&primearray[answer-8]){
				break;	
			}
			answer--;
		}
		cout << answer << endl;
	}
	
	return 0;
}

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

int N;
string S[60];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> S[i];

    int cnt[N][26];
    memset(cnt, 0, sizeof(cnt));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < S[i].length(); j++) {
            cnt[i][S[i][j] - 'a']++;
        }
    }

    for (int i = 0; i < 26; i++) {
        int min_i = 1.0e9;
        for (int j = 0; j < N; j++) {
            min_i = min(min_i, cnt[j][i]);
        }

        for (int j = 0; j < min_i; j++) {
            cout << (char)(i + (int)'a');
        } 
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
// D - Friend Suggestions
// UnionFinde version (None rank)
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

class UnionFind{//union-find class (None rank)
	vector<int> parent;//parent number
	public:
	UnionFind(int n){
		parent.resize(n);
		init();
	}
	void init(){//initialize all parent to root
		for(int v=0; v<parent.size(); ++v) parent[v] = v;
	}
	int root(int v){//get root
		if(parent[v]==v) return v;//root
		return parent[v] = root(parent[v]);//path compression
	}
	void unite(int v, int u){
		v = root(v); u = root(u);
		if(v==u) return;
		parent[v] = u;
	}
	bool same(int v, int u){return root(v)==root(u);}//v & u the same set
};

int main(){
	int N,M,K; scanf("%d%d%d",&N,&M,&K);
	UnionFind uf(N+1);
	vi C(N+1), gid(N+1);
	int s,t;
	rp(i,0,M){
		scanf("%d%d",&s,&t);
		uf.unite(s,t);
		C[s]++; C[t]++;
	}
	rp(i,0,K){
		scanf("%d%d",&s,&t);
		if(uf.root(s) == uf.root(t)) C[s]++, C[t]++;
	}
	vi cnt(N+1); rp(i,1,N+1) cnt[uf.root(i)]++;
	rp(i,1,N+1) printf("%d ", cnt[uf.root(i)]-C[i]-1);
}

Measured memory_bytes: 2816
import sys
input = sys.stdin.readline

n = int(input())
Pre = iter([int(x) for x in input().split()])
In = [int(x) for x in input().split()]
C = []

def Reconstruction(l, r):
    if l >= r:
        return
    c = next(Pre)
    m = In.index(c)
    Reconstruction(l, m)
    Reconstruction(m+1, r)
    C.append(c)

Reconstruction(0, n)
print(*C)


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

int main(){
	int L, A, B, C, D;
	
	cin >> L >> A >> B >> C >> D;
	
	if(A % C == 0){
		A = A / C;
	}else {
		A = A / C + 1;
	}
	if(B % D == 0){
		B = B / D;
	}else {
		B = B / D + 1;
	}
	
	L = L - max(A, B);
	
	cout << L << endl;
	
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
int a[5];
int ans;

int main() {
	for(int i = 1; i <= 3; i++) cin >> a[i];
	sort(a + 1, a + 4);
	ans += a[3] - a[2];
	a[1] += ans;
	while(a[1] < a[3]) {
		ans++;
		a[1] += 2;
	}
	if(a[1] > a[3]) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

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

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    ll res = a[0];
    ll min_diff = 100000000000;
    debug(a);
    FOR(i, 1, n) {
        if (min(abs(a[n - 1 - i] - a[n - 1] / 2),
                abs(a[n - 1 - i] - (a[n - 1] + 1) / 2)) < min_diff) {
            min_diff = min(abs(a[n - 1 - i] - a[n - 1] / 2),
                           abs(a[n - 1 - i] - (a[n - 1] + 1) / 2));
            res = a[n - 1 - i];
        }
    }
    cout << a[n - 1] << " " << res << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n;
    cin>>n;
    ll ta=1,ao=1;
    for(int i=0;i<n;i++){
        ll t,a;
        cin>>t>>a;
        ll z=max((ta+t-1)/t,(ao+a-1)/a);
        ta=z*t;
        ao=z*a;
    }
    cout<<ta+ao<<endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<string> keihin(N);
  for (int i = 0; i < N; i++) {
    cin >> keihin.at(i);
  }
  sort(keihin.begin(), keihin.end());
  int ans = 1;
  for (int i = 0; i < N - 1; i++) {
    if (keihin.at(i) != keihin.at(i + 1)) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 9600