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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int H, W; scanf("%d %d", &H, &W);

  ll ans = LLINF;
  for (ll i = 1; i <= W / 2; ++i) {
    ll a = i * H;
    ll w1 = (W - i) / 2, w2 = (W - i) - w1;
    ll b = w1 * H;
    ll c = w2 * H;
    ans = min(ans, max({ a, b, c }) - min({ a, b, c }));

    ll h1 = H / 2, h2 = H - h1;
    ll w3 = W - i;
    ll d = w3 * h1, e = w3 * h2;
    ans = min(ans, max({ a, d, e }) - min({ a, d, e }));
  }

  for (ll i = 1; i <= H / 2; ++i) {
    ll a = i * W;
    ll h1 = (H - i) / 2, h2 = (H - i) - h1;
    ll b = h1 * W, c = h2 * W;
    ans = min(ans, max({ a, b, c }) - min({ a, b, c }));

    ll h = H - i;
    ll w1 = W / 2, w2 = W - w1;
    ll d = h * w1, e = h * w2;
    ans = min(ans, max({ a, d, e }) - min({ a, d, e }));
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<cstring>

#define visited(p) visited[p.first][p.second]
#define maze(p) maze[p.first][p.second]
#define dist(p) dist[p.first][p.second]

using namespace std;

int h, w;
char maze[21][21];
bool visited[21][21];
int dist[21][21];

bool validRow(int row){
	return row >= 0 && row < h;
}

bool validCol(int col){
	return col >= 0 && col < w;
}

int bfs(pair<int, int> start)
{
	int ret = 0;
	queue<pair<int, int>> q;
	visited(start) = true;
	q.push(start);
	int size;
	while(!q.empty())
	{
		size = q.size();
		while(size--)
		{
			pair<int, int> cur = q.front();
			q.pop();
			for(int i = -1 ; i <= 1 ; i += 2)
			{
				pair<int, int> cand(cur.first + i, cur.second);
				if(validRow(cand.first) && maze(cand) == '.' && !visited(cand))
				{
					visited(cand) = true;
					dist(cand) = dist(cur) + 1;
					ret = max(ret, dist(cand));
					q.push(cand);
				}
			}
			for(int i = -1 ; i <= 1 ; i += 2)
			{
				pair<int, int> cand(cur.first, cur.second + i);
				if(validCol(cand.second) && maze(cand) == '.' && !visited(cand))
				{
					visited(cand) = true;
					dist(cand) = dist(cur) + 1;
					ret = max(ret, dist(cand));
					q.push(cand);
				}
			}
		}
	}
	return ret;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	cin >> h >> w;
	for(int i = 0 ; i < h ; i++)
		for(int j = 0 ; j < w ; j++)
			cin >> maze[i][j];
	int ans = 0;
	for(int i = 0 ; i < h ; i++){
		for(int j = 0 ; j < w ; j++){
			if(maze[i][j] == '.'){
				memset(visited, false, sizeof(visited));
				memset(dist, 0, sizeof(dist));
				ans = max(ans, bfs(make_pair(i, j)));
			}
		}
	}
	cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
  auto input = readln.chomp.split.map!(to!int);
  auto n = input[0];
  auto K = input[1];
  long[] xs;
  long[] ys;
  bool[long] xset;
  bool[long] yset;
  alias Point = Tuple!(long, "x", long, "y");
  bool[Point] set;
  foreach (i; 0 .. n)
  {
    auto xy = readln.chomp.split.map!(to!int);
    int x = xy.front;
    int y = xy.back;
    xs ~= x;
    ys ~= y;
    xset[x] = true;
    yset[y] = true;
    set[Point(x, y)] = true;
  }
  long[] xlist = xset.keys;
  long[] ylist = yset.keys;
  std.algorithm.sort(xlist);
  std.algorithm.sort(ylist);
  long ans = long.max;
  auto yn = ylist.length;
  auto xn = xlist.length;
  int[][] imos = new int[][](yn + 1, xn + 1);
  foreach (i; 0 .. yn)
  {
    foreach (j; 0 .. xn)
    {
      imos[i + 1][j + 1] += imos[i + 1][j] + (Point(xlist[j], ylist[i]) in set ? 1 : 0);
    }
    stderr.writeln;
  }
  foreach (i; 0 .. xn)
  {
    foreach (j; 0 .. yn)
    {
      imos[j + 1][i + 1] += imos[j][i + 1];
    }
  }
  foreach (i; 0 .. yn + 1)
  {
    foreach (j; 0 .. xn + 1)
    {
      stderr.write = (j ? " " : "") ~ imos[i][j].to!string;
    }
    stderr.writeln;
  }
  foreach (i; 0 .. yn)
  {
    foreach (j; i .. yn)
    {
      foreach (k; 0 .. xn)
      {
        foreach (l; k .. xn)
        {
          // TODO
          int cnt = imos[j + 1][l + 1] - imos[j + 1][k] - imos[i][l + 1] + imos[i][k];
          if (cnt >= K) {
            ans = min(ans, (xlist[l] - xlist[k]) * (ylist[j] - ylist[i]));
          }
        }
      }
    }
  }
  ans.writeln;
}

Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
string tihuan(string a,string b,int pos)
{
	string c=a;
	int i = 0;
	for(;i<pos;i++)
	{
		if(c[i]=='?')
		{
			c[i]='a';
		}
	} 
	for(;i<pos+b.size();i++) 
	{
		c[i]=b[i-pos];
	}
	for(;i<a.size();i++)
	{
		if(c[i]=='?')
		{
			c[i]='a';
		}
	}
	return c;
}
int main() 
{
	string s,t;
	cin>>s>>t; 
	if(s.size()<t.size())
	{
		cout<<"UNRESTORABLE"<<endl;
		return 0;
	}
	string minStr="";
	bool hasOk = false; 
	//搜索可替换的，再求最小值 
	for(int i=0;i<=s.size()-t.size();i++)
	{
		//能替换吗 
		bool isok = true;
		string th=s.substr(i,t.size());
		for(int j=0;j<th.size();j++)
		{
			if( th[j]!='?' && th[j]!=t[j] )
			{
				isok=false;
				break;
			}
		}	
		//可以替换 
		if(isok)
		{
			hasOk = true;
			string beiyong=tihuan(s,t,i);
			//最小值 
			if( minStr.size() == 0 ) 
				minStr = beiyong;
			else
				minStr = minStr>beiyong?beiyong:minStr;
		}	
	}
	if(!hasOk)
	{
		cout<<"UNRESTORABLE";
	}
	else
		cout<<minStr<<endl;
	return 0;
}

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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

template <typename T>
void debug_out(T t) {
  cerr << t;
}

template <typename A, typename B>
void debug_out(pair<A, B> u) {
  cerr << "(" << u.first << " " << u.second << ")";
}

template <typename T>
void debug_out(vector<T> t) {
  int sz = t.size();
  for(int i = 0; i < sz; i++) {
    debug_out(t[i]);
    if(i != sz - 1) cerr << ", ";
  }
}

template <typename T>
void debug_out(vector<vector<T>> t) {
  int sz = t.size();
  for(int i = 0; i < sz; i++) {
    debug_out(t[i]);
    if(i != sz - 1) cerr << endl;
  }
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_out(__VA_ARGS__), cerr << endl;

const int md = 998244353;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
#if !defined(_WIN32) || defined(_WIN64)
  return (int) ((long long) a * b % md);
#endif
  unsigned long long x = (long long) a * b;
  unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
  asm(
    "divl %4; \n\t"
    : "=a" (d), "=d" (m)
    : "d" (xh), "a" (xl), "r" (md)
  );
  return m;
}

inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

const int N = 444444;
int n;
string s;
vector<vector<int>> dis(N);

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  range(i, 1, N) {
    for(int j = i; j < N; j += i) dis[j].push_back(i);
  }
  cin >> n >> s;
  vector<int> d = dis[2 * n];
  vector<int> p(N);
  p[0] = 1;
  range(i, 1, N) p[i] = mul(p[i - 1], 2);
  vector<int> dp(2 * n + 1);
  auto solve = [&] (int v) {
    v >>= 1;
    int res = 0;
    range(i, 0, v) {
      if(s[i] == '0') continue;
      add(res, p[v - i - 1]);
    }
    range(i, v, n) {
      int c = i / v, x = i % v;
      c &= 1;
      int u = (s[x] - '0') ^ c;
      int sv = s[i] - '0';
      if(u < sv) break;
      if(u > sv) return res;
    }
    add(res, 1);
    return res;
  };
  debug(d);
  for(int u : d) {
    if(n % u == 0) continue;
    dp[u] = solve(u);
  }
  for(int i : d) {
    if(n % i == 0) continue;
    for(int u : dis[i]) {
      if(u == i || (i / u) % 2 == 0) continue;
      sub(dp[i], dp[u]);
    }
  }
  int res = 0;
  range(i, 1, 2 * n + 1) {
    add(res, mul(i, dp[i]));
  }
  cout << res;
  return 0;
}


Measured memory_bytes: 53016
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = 1001002003004005006ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	rep(i, n) cin >> v[i];
	int r = min(n, k);
	int ans = -inf;
	rep(a, r + 1) rep(b, r + 1) {
		if (a + b > r) continue;
		int tmp = 0;
		priority_queue<int, vector<int>, greater<int>> pq;
		rep(i, a) {
			tmp += v[i];
			pq.push(v[i]);
		}
		rrep(i, b + 1) {
			tmp += v[n - i];
			pq.push(v[n - i]);
		}
		rep(i, k - (a + b)) {
			if (pq.empty()) break;
			int now = pq.top();
			if (now >= 0) break;
			pq.pop();
			tmp -= now;
		}
		maxs(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}

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


int main(){
    int X;
    cin >> X;
    int cnt_b = (int)X/500;
    X -= cnt_b*500;
    int cnt_s = (int)X/5;
    int cnt = cnt_b*1000 + cnt_s*5;
    cout << cnt << endl;
    
}


Measured memory_bytes: 256
h,w = map(int, input().split())
wb = {'#':1, '.':0}
wall = 0
edges = [wall for i in range(w+2) ]
# grid = [list(map(wb.get, input().split())) for _ in range(h)]
grid = [edges]
for i in range(1,h+1):
    S = [wall]+list(map(wb.get, input()))+[wall]
    grid.append(S)
grid.append(edges)
# [print(i) for i in grid]
dxy = [(1,0), (-1,0), (0,1), (0,-1)]
for y in range(1,h+1):
    for x in range(1,w+1):
        if grid[y][x] == 0:
            continue
        for dy, dx in dxy:
            y_,x_ = y+dy,x+dx
            # print(y_, x_)
            if grid[y_][x_]:
                break
        else:
            # print(y,x, grid[y][x])
            print('No')
            exit()
print('Yes')


Measured memory_bytes: 3064
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
using namespace std;
#define loop(i,a,b) for(int i = a; i < b; i++)
#define rep(i,a) loop(i,0,a)
#define shosu(x) fixed<<setprecision(x)
typedef long long ll;

int main()
{	
		ll x,y;
		cin>>x>>y;
		ll a=abs(abs(x)-abs(y));
		if(x<0 && y<0 && y<x)
			a+=2;
		else if(x<0 && y>0)
			a++;
		else if(x>0 && y<0)
			a++;
		else if(x>0 && y>0 &&x>y)
			a+=2;
		else if((x==0 || y==0)){
			if(x==0&& y<0)
				a++;
			else if(x>0&&y==0)
				a++;
		}
		
		cout<<a<<endl;
		
			return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
char a[101],b[1050];
int i,n,j=1,k=50,e;
scanf("%d",&n);
for(i=0;i<n;i++){
for(e=0;e<100;e++){
a[e]='A';
}
scanf("%s\n",b);
a[k]=b[0];
while(b[j]!='\0'){
if(b[j]=='<'){
k--;
}
else{
k++;
}
j=j+2;
a[k]=b[j];
j++;
}
for(e=0;e<100;e++){
if(a[e]!='A'){
printf("%c",a[e]);
}
}
printf("\n");
j=1,k=50;
}
return 0;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

char b[5][5];

int main() {
   rep (i, 3) {
         cin >> b[i];
   }
   cout << b[0][0] << b[1][1] << b[2][2] << endl;

   return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define sqr(a) a*a


using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int,int> pi;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll h;
    cin >> h;
    ll res = 0;
    ll now_most = 1;
    while(h > 0){
        res += now_most;
        now_most *= 2;
        h /= 2;
    }
    cout << res;
}

Measured memory_bytes: 256
#include <iostream>
#include<cmath>
#include<vector>
#include<map>
#include<sstream>
#include<deque>
#include<iomanip>
#include<algorithm>
#include<set>
#include<queue>
#include<bitset>
#include<stack>
#include<unordered_set>
using namespace std;
//	int x=atoi(s.c_str()); s_to_in;
int dx[] = { -1,0,0 };
int dy[] = { 0,1,-1 };
#define endl '\n'
long long mo = 1e9;
const long double P = 3.141592653589793238L;
void trust_yourself()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
long long gcd(long long x, long long y)
{
	if (x == 0)
		return y;
	return gcd(y%x, x);
}
long long fast_power(long long x, long long y, long long mo)
{
	long long p = 1;
	while (y)
	{
		if (y & 1)
			p = (p*x) % mo;
		y = (y >> 1); //y/=2
		x = (x*x) % mo;
	}

	return p;
}
long long convert_to_num(string x) {
	long long  num = 0;
	for (int i = 0; i < x.size(); i++) {
		num *= 2;
		num += x[i] - '0';
	}
	return num;
}

long long com(long long n, long long r) {
	long long p = 1, p1 = 1;
	for (long long i = r + 1; i <= n; i++) {
		p = p * i;
		p /= p1;
		p1++;
	}
	return p;
}


int main()
{
	trust_yourself();
	
	long long n,m,l;
  cin>>n>>m;
  l=abs(n-m);
if(n<=m)
  cout<<min(n,l);
  else {
    cout<<min((n%m),abs((n%m)-m));
  }
	return 0;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    string str;
    std::cin >> a>>b;
    if(a==b)
    str="a == b";
    else if(a<b)
    str="a < b";
    else if(a>b)
    str="a > b";
    std::cout << str << std::endl;
}


Measured memory_bytes: 3200
#include<iostream>
#include<algorithm>
using namespace std;
int main (void)
{
  int b,a;
  cin>>a>>b;
  int i,ans=0;
  for(i=0;i<(b-a);i++)
  {
    ans+=i;
  }
  ans-=a;
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

using ll = long long;

int main()
{
    int s, w;
    cin >> s >> w;
    if (w >= s) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();
    string s, t ;
    cin >> s >> t ;
    vint cnts(26,0) ;
    vint cntt(26,0) ;
    REP(i,SZ(s)){
        cnts[s[i]-'a']++ ;
    }  
    REP(i,SZ(t)){
        cntt[t[i]-'a']++ ;
    }
    sort(ALL(cnts)) ;
    sort(ALL(cntt)) ;
    if(cnts==cntt){
        yes() ;
    }
    else{
        no() ;
    }


    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



Measured memory_bytes: 916
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<P, P>PP;
typedef pair<PP, PP>PPPP;
struct edge { int to; int cost; };
int kj[200006], kji[200006];
int modpow(int n, int x, int mod) {
	if (!x)return 1;
	int res = modpow(n*n%mod, x / 2, mod);
	if (x & 1)res = res*n%mod;
	return res;
}
int comb(int r, int c) {
	return kj[r] * kji[c] % mod * kji[r - c] % mod;
}

signed main() {
	kj[0] = 1;
	rep(i, 200003) {
		kj[i + 1] = kj[i] * (i + 1);
		kj[i + 1] %= mod;
	}
	rep(i, 200003)kji[i] = modpow(kj[i], mod - 2, mod);
	int n, m, k; cin >> n >> m >> k;
	int sumn = 0, summ = 0;
	rep(i, n + 1) {
		sumn += i*m*m*(n - i);
		sumn %= mod;
	}
	rep(i, m+1) {
		summ += i*n*n*(m - i);
		summ %= mod;
	}

	cout <<( (summ + sumn) % mod)*comb(m*n - 2, k - 2) % mod << endl;
}

Measured memory_bytes: 3328
#include <stdio.h>

int count(long in, long lim, int chk){
	int cnt = 0;
	if(in <= lim){
		if(chk == 7)
			cnt++;
		cnt += count(in * 10 + 3, lim, chk | 1)
			+ count(in * 10 + 5, lim, chk | 2)
			+ count(in * 10 + 7, lim, chk | 4);
		return cnt;
	}else
		return 0;
}

int main(void){
	long n;
	scanf("%ld", &n);
	printf("%d\n", count(0, n, 0));
	return 0;
}


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

using namespace std;

int main()
{
    long long int n1, n2, hcf, temp, lcm;
    cin >> n1 >> n2;
    hcf = n1;
    temp = n2;
    while(hcf != temp)
    {
        if(hcf > temp)
            hcf -= temp;
        else
            temp -= hcf;
    }
    lcm = (n1 * n2) / hcf;
    cout<< lcm;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
   
class Main{
    public static void main(String[] args) throws IOException{
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        int x = Integer.parseInt(br.readLine());
        String[] str = br.readLine().split(" ");
 
        for(int i = str.length; i > 0; i--){
		System.out.print(str[i-1]);
		if(i != 1){
			System.out.print(" ");
		}
	}
	System.out.println();
    }
}

Measured memory_bytes: 16908
from itertools import combinations
n, k = map(int, input().split())
a = [i for i in range(n)]
rs = []
for c in combinations(a, k):
    tmp = sum(1 << i for i in c)
    rs.append([tmp, *c])
for ans in sorted(rs):
    print(str(ans[0]) + ":", *ans[1:])


Measured memory_bytes: 18372
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
 
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s,t;
	cin >> s;
	int n = s.size();
	rep(i,n){
		if(i % 2 == 0) t += s[i];
	}
	cout << t << '\n';
	return 0;
}


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

int main() {
  int n;
  cin >>n;
  cout<< n+pow(n,2)+pow(n,3)<<endl;
}

Measured memory_bytes: 4128
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <map>
#include <string.h>
#define ll long long

using namespace std;

const int MAXN = 2 * 1e5;

int n, m, q;
priority_queue<int> pq[505];
vector<int> range[505];

int main(){
	
	cin >> n >> m >> q;
	for(int i = 1; i <= m; i ++){
		int l, r; cin >> l >> r;
		range[l].push_back(r);
	}
	for(int i = 1; i <= n; i ++)
		sort(range[i].begin(), range[i].end());
	for(int i = 1; i <= q; i ++){
		int l, r; cin >> l >> r;
		int out = 0;
		for(int j = l; j <= r; j ++){
			int kiri = 0, kanan = range[j].size() - 1, ans = -1;
			while(kiri <= kanan){
				int tengah = (kiri + kanan) / 2;
				if(range[j][tengah] <= r){
					kiri = tengah + 1;
					ans = tengah;
				}else{
					kanan = tengah - 1;
				}
			}
			out += ans + 1;
		}
		cout << out << endl;
	}

	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
	int n;
	cin >> n;
	string s;
	vector<int> min_cnt(26, 100000);
	for (int i = 0; i < n; ++i) {
		cin >> s;
		vector<int> cnt(26, 0);
		for (int j = 0; j < s.size(); ++j) {
			++cnt[s[j] - 97];
		}
		for (int j = 0; j < 26; ++j) {
			min_cnt[j] = min(min_cnt[j], cnt[j]);
		}
	}
	string ans;
	for (int i = 0; i < 26; ++i) {
		for (int j = 0; j < min_cnt[i]; ++j) {
			ans += i + 97;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

void solve()
{
	int n, ans, x;
	cin >> n >> ans;
	for (int i = 0; i < n-1; i++)
	{
		cin >> x;
		ans = __gcd(ans, x);
	}
	cout << ans << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
N, W = map(int, input().split())
item = [[0] * 2 for _ in range(N)]
for i in range(N):
    w, v = map(int, input().split())
    item[i][0], item[i][1] = w, v
dp = [[0] * (W+1) for _ in range(N+1)]
for n in range(1, N+1):
    for w in range(W+1):
        if item[n-1][0] <= w:
            dp[n][w] = max(dp[n-1][w], dp[n-1][w-item[n-1][0]] + item[n-1][1])
        else:
            dp[n][w] = dp[n-1][w]
print(dp[N][W])

Measured memory_bytes: 120172
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int a, b, c;
    cin >>a >> b >> c;
    cout << ((a+b+c >= 22)?"bust":"win") << endl;
}


Measured memory_bytes: 256
# coding: utf-8

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

# A = [None for i in range(N)]
output = B[0]  # when i == 0
# A[0] = B[0]
for i in range(1, N-1):
    output += min(B[i], B[i-1])
    # A[i] = min(B[i], B[i-1])

output += B[N-2]
# A[N-1] = B[N-2]

# print(A)
print(output)


Measured memory_bytes: 2940
from sys import stdin


def main():
    _ = int(input())
    a_lists = [int(x) for x in stdin.readline().rstrip().split()]
    z = 0

    for a in a_lists:
        z ^= a

    if z == 0:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 14116
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<deque>
#include<cmath>
#include<algorithm>
using namespace std;
#define int long long int
#define mod 1000000007		
struct node 
{ 
    int to, weight; 
};	
int zeroOneBFS(vector<node> edges[],int src,int dest,int V) 
{ 
    int dist[V]; 
    for (int i=0; i<V; i++) 
        dist[i] = 10000000000; 
    deque <int> Q; 
    dist[src] = 0; 
    Q.push_back(src); 
  
    while (!Q.empty()) 
    { 
        int v = Q.front(); 
        Q.pop_front(); 
  
        for (int i=0; i<edges[v].size(); i++) 
        { 
            if (dist[edges[v][i].to] > dist[v] + edges[v][i].weight) 
            { 
                dist[edges[v][i].to] = dist[v] + edges[v][i].weight; 
                if (edges[v][i].weight == 0) 
                    Q.push_front(edges[v][i].to); 
                else
                    Q.push_back(edges[v][i].to); 
            } 
        } 
    } 
    return dist[dest];
} 
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int h,w;
	cin>>h>>w;
	int p,q,x,y;
	cin>>p>>q>>x>>y;
	p--;
	q--;
	x--;
	y--;
	char mat[h][w];
	map<pair<int,int>,int> mp;
	int ptr=0;
	int i,j;
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			cin>>mat[i][j];
		}
	}
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			mp[{i,j}]=ptr;
			ptr++;
		}
	}
	vector<node> edges[ptr+5];
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			if(mat[i][j]=='#')
			   continue;
			int src=mp[{i,j}];
			int a,b;
			for(a=-2;a<=2;a++)
			{
				for(b=-2;b<=2;b++)
				{
					if(a==0&&b==0)
					   continue;
					if(i+a>=0&&i+a<h&&j+b>=0&&j+b<w&&mat[i+a][j+b]=='.')
					{
						int diff=abs(a)+abs(b);
						int wt=0;
						if(diff>1)
						   wt=1;
						int dest=mp[{i+a,j+b}];
						edges[src].push_back({dest,wt});
						edges[dest].push_back({src,wt});
					}
				}
			}
		}
	}
	int src=mp[{p,q}];
	int dest=mp[{x,y}];
	int answer=zeroOneBFS(edges,src,dest,ptr+5);
	if(answer>=1000000000)
	{
		cout<<-1<<endl;
	}
	else
	   cout<<answer<<endl;
}


Measured memory_bytes: 354072
import sys
import itertools
input = sys.stdin.readline

N, M = map(int, input().split())
L = [[int(v) for v in input().split()] for _ in range(M)]

class UnionFind:
    def __init__(self, n):
        self.data = [0] * N
        for i in range(N):
            self.data[i] = i
            
    def get_root(self, x):
        r = self.data[x]
        if r == x:
            return r
        p = self.get_root(r)
        self.data[x] = p
        return p
    
    def unite(self, x, y):
        rx = self.get_root(x)
        ry = self.get_root(y)
        
        if rx != ry:
            self.data[rx] = ry
            
    def same(self, x, y):
        return self.get_root(x) == self.get_root(y)

ans = 0

for i in range(M):
    u = UnionFind(N)
    for j in range(M):
        if i != j:
            u.unite(L[j][0] - 1, L[j][1] - 1)

    for j in range(N - 1):
        if u.same(j, j + 1) == False:
            ans += 1
            break

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
  {
   int n;
  cin>>n;
  string s;
  cin>>s;
  int count=0;
  char prev=s[0];
  for(int i=1;i<n;i++)
  {
    if(s[i]!=prev)
    {
      count++;
      prev=s[i];
    }
  }
  cout<<count+1<<endl;
   return 0;
  }

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

int main(){
    int x = 0;
    cin>>x;
    
    switch(x){
     case 3:
     cout<<"YES"<<endl;
     break;
     
     case 5:
     cout<<"YES"<<endl;
     break;
     
     case 7:
     cout<<"YES"<<endl;
     break;
     
     default:
     cout<<"NO"<<endl;
     break;
     
    }
    return 0;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  for (int i = 0;3 > i;i++) {
    if (s[i] != t[2-i]) {
      cout <<"NO"<<endl;
      return 0;
    }
  }
  cout <<"YES"<<endl;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int n;
    cin >> n;
    dump(n * (n - 1) / 2);
    return 0;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var arr=Arr[0].split(" ");
var a="";
var b="";
var obj={};
var cnt=0;
arr.forEach(function(v){
   if(a.length<=v.length)a=v;
   (v in obj) ? obj[v]++ : obj[v]=1;
   if(cnt<=obj[v]){
      b=v;
      cnt=obj[v];
   }
});
console.log(b+" "+a);

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

using namespace std;

int r[30][100000];

int calc(int v, int d){
    if(d == 0) return v;
    int n = 1;
    for(int i = 0; i < 30; i++){
        if(n&d){
            if(d-n == 0) return r[i][v];
            else return calc(r[i][v], d-n); 
        }
        n = (n<<1);
    }
}

int main(){
    int N;
    int x[100000];
    int L;
    int Q;
    cin >> N;
    for(int i = 0; i < N; i++) cin >> x[i];
    cin >> L;
    for(int i = 0; i < N-1; i++){
        int *p = upper_bound(x, x+N, x[i]+L);
        r[0][i] = p-x-1;
    }
    r[0][N-1] = N-1;
    for(int i = 1; i < 30; i++){
        r[i][N-1] = N-1;
        for(int j = 0; j < N-1; j++){
            r[i][j] = r[i-1][r[i-1][j]];
            //cout << r[i][j] << ' ';
        }
        //cout << endl;
    }

    cin >> Q;
    for(int i = 0; i < Q; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if(a > b) swap(a, b);
        int l = 0;
        int r = N;
        while(r-l > 1){
            int c = (l+r)/2;
            if(calc(a, c) >= b) r = c;
            else l = c;
        }
        cout << r << endl;
    }
}

Measured memory_bytes: 12928
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

bool map[1001][1001];

int flow[1001][1001];

int H, W, n;

void search(int x, int y){
	if(x >= W || y >= H){
		printf("%d %d\n", y + 1, x + 1);
		return;
	}
	if(map[y][x]){
		search(x + 1, y);
	}else{
		search(x, y + 1);
	}
}

int main(){
	
	while(true){
		cin >> H >> W >> n;
		if(H == 0 && W == 0 && n == 0){
			break;
		}
		int d;
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				cin >> d;
				if(d == 1){
					map[i][j] = true;
				}else{
					map[i][j] = false;
				}
				flow[i][j] = 0;
			}
		}
		
		flow[0][0] = n - 1;
		
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				if(flow[i][j] % 2 == 0){
					flow[i + 1][j] += flow[i][j] / 2;
					flow[i][j + 1] += flow[i][j] / 2;
				}else{
					if(map[i][j]){
						flow[i + 1][j] += flow[i][j] / 2;
						flow[i][j + 1] += flow[i][j] / 2 + 1;
					}else{
						flow[i + 1][j] += flow[i][j] / 2 + 1;
						flow[i][j + 1] += flow[i][j] / 2;
					}
					map[i][j] = !map[i][j];
				}
			}
		}
		search(0, 0);
	}
	
	return 0;
}

Measured memory_bytes: 6036
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define INF 999999999
typedef long long ll;
using namespace std;
int main() {
    string c1, c2;
    cin >> c1 >> c2;
    if( c1[0] == c2[2] &&
        c1[1] == c2[1] &&
        c1[2] == c2[0]) {
            puts("YES");
    }else{
        puts("NO");
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

long long power(long long a, long long b,long long m) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %m;
        a = a * a %m;
        b >>= 1;
    }
    return res;
}
string a[1005];
int n,m,x,y,z,w;
int dis[1005][1005];
int dx[5]={-2,-1,0,1,2};
deque<pair<int,int> >qq;

void find(pair<int,int>pp,int z)
{
    if(pp.first<1||pp.first>n)
        return ;
    if(pp.second<1||pp.second>m)
        return ;
    if(a[pp.first][pp.second]=='#')
        return ;
    for(int i=0;i<5;i++)
    {
        for(int j=0;j<5;j++)
        {
            if(pp.first+dx[i]>=1 && pp.first+dx[i]<=n&&pp.second+dx[j]>=1 && pp.second+dx[j]<=m)
            {
                if(dis[pp.first+dx[i]][pp.second+dx[j]]>z+1 && a[pp.first+dx[i]][pp.second+dx[j]]=='.')
                {
                    dis[pp.first+dx[i]][pp.second+dx[j]]=z+1;
                    qq.push_back({pp.first+dx[i],pp.second+dx[j]});
                }
            }
        }
    }
}


void bc(pair<int,int>pp,int z)
{
    if(pp.first<1||pp.first>n)
        return ;
    if(pp.second<1||pp.second>m)
        return ;
    if(a[pp.first][pp.second]=='#')
        return ;
    if(dis[pp.first][pp.second]>z)
    {
        dis[pp.first][pp.second]=z;
        qq.push_front(pp);
    }
}

void bfs()
{
    qq.push_front({x,y});
    fill_n(&dis[0][0],1005*1005,1e17);
    dis[x][y]=0;

    while (!qq.empty())
    {
        pair<int,int>pp=qq.front();
        qq.pop_front();
        bc({pp.first-1,pp.second},dis[pp.first][pp.second]);
        bc({pp.first,pp.second-1},dis[pp.first][pp.second]);
        bc({pp.first,pp.second+1},dis[pp.first][pp.second]);
        bc({pp.first+1,pp.second},dis[pp.first][pp.second]);
        find(pp,dis[pp.first][pp.second]);
    }    
}

signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif      

    cin>>n>>m;
    cin>>x>>y;
    cin>>z>>w;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        a[i]="#"+a[i];
    }
    bfs();
    if(dis[z][w]<1e17)
    {
        cout<<dis[z][w];
    }
    else
    {
        cout<<-1;
    }
    
}           


Measured memory_bytes: 12772
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

typedef pair<int,int> P;
typedef long long ll;

int main(){
	int a,b;
	cin >> a >> b;
	if(b%a==0){
		cout << a+b << endl;
	}else{
		cout << b-a << endl;
	}
	return 0;
}

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

using namespace std;

typedef __int128_t ll;
typedef pair<ll, ll> P;

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

map<char, ll> pri;
string op = "+-*";
string s;
ll pos = 0;
bool end() {
    return pos == s.size();
}
void read_char(char c) {
    assert(!end() && s[pos] == c);
    ++pos;
}
ll parse(ll);
ll number() {
    if (s[pos] == '(') {
        read_char('(');
        ll res = parse(0);
        read_char(')');
        return res;
    }
    else {
        string res = "";
        while ( !end() && isdigit(s[pos]) ) {
            res += s[pos++];
        }
        return stoll(res);
    }
}
ll parse(ll oid) {
    if (oid == op.size()) return number();
    ll res = parse(oid+1);
    while ( !end() && pri.count(s[pos]) > 0 && pri[s[pos]] == oid ) {
        char op = s[pos];
        read_char(op);
        ll right = parse(oid+1);
        switch (op) {
            case '*': res *= right; break;
            case '+': res += right; break;
            case '-': res -= right; break;
        }
    }
    return res;
}
ll parse() {
    pos = 0;
    return parse(0);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> s;
    ll ans = -linf;
    rep(a, 3) rep(b, 3) rep(c, 3) {
        vector<ll> v{a, b, c};
        // vector<ll> v{1, 1, 1};
        rep(i, 3) pri[op[i]] = v[i];
        if (a == 0 && b == 0 && c == 0) ans = parse();
        else chmax(ans, parse());
        // chmax(ans, parse());
    }
    cout << (long long)ans << endl;
}



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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

 int main(){
 int N, K;
 cin >> N >> K;
 vector<int>x(N);
 REP(i, N) cin >> x.at(i);

int ans = MOD;
 for(int i = 0; i < N - (K - 1); i++){ 
      int now;
      if(x.at(i) >= 0) now = x.at(i + (K - 1));
      else if(x.at(i + (K - 1)) <= 0) now = -x.at(i);
      else if(-x.at(i) > x.at(i + (K - 1))) now = x.at(i + (K - 1)) * 2 + (-x.at(i));
      else if(-x.at(i) < x.at(i + (K - 1))) now = x.at(i + (K - 1)) + (-x.at(i)) * 2;
    ans = min(ans, now);
 }

print(ans);
 }

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <stdio.h>

using namespace std;

bool bynary_ser(int S[], int n, int a){
    int left = 0;
    int right = n;
    
    while(left<right){
        int mid = (left+right)/2;
        if(S[mid] == a){
            return true;
        }
        else if(S[mid] < a){
            left = mid+1;
        }
        else {
            right = mid;
        }
    }
    return false;
}

int main(int argc, const char * argv[]) {
    // insert code here...
    
    
    
    /////////
    //write//
    /////////
    
    
    int n; cin >> n;
    int S[100001];
    for(int i=0; i<n; i++){
        cin >> S[i];
    }
    int q; cin >> q;
    int T[50001];
    for(int i=0; i<q; i++){
        cin >> T[i];
    }
    
    //output
    int cnt = 0;
    for(int i=0; i<q; i++){
        if(bynary_ser(S, n, T[i])){
            cnt++;
        }
    }
    cout << cnt << endl;
    
    
    return 0;
}



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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
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;
}

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) (x).erase(unique(all(x)), (x).end())
#define int long long

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;

/* main */
signed main(void)
{
    int a, b, k, cnt = 0, tmp;
    cin >> a >> b >> k;
    vector<int> v(100);
    for (int i = 100; i >= 1; i--)
    {
        if (((a % i) == 0) && ((b % i) == 0))
        {
            cnt++;
            tmp = i;
        }
        if (cnt == k)
        {
            cout << tmp << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import sys

n = int(sys.stdin.readline().rstrip())
*a, = map(int, sys.stdin.readline().split())
*b, = map(int, sys.stdin.readline().split())

def attack(i, j, cnt):
    if b[i] <= a[j]:
        a[j] -= b[i]
        cnt += b[i]
        b[i] = 0
    else:
        b[i] -= a[j]
        cnt += a[j]
        a[j] = 0
    return cnt

def main():
    cnt = 0
    for i in range(n):
        cnt = attack(i, i, cnt)
        cnt = attack(i, i+1, cnt)
    return cnt

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 18624
#include <iostream>
#define rep(i,n) for(long i=0; i<(n); i++)
using namespace std;

int main(){
  long n,k;
  cin >> n >> k;
  long a[n];
  rep(i,n){
    cin >> a[i];
  }
  
  rep(i,n-k){
    if(a[i] < a[i+k]){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 5156
#include<bits/stdc++.h>
#define me(a,x) memset(a,x,sizeof(a))
#define sc scanf
#define itn int
using namespace std;
const int N=1e6;
const long long mod=1e9+7;
const long long mod2=998244353;
const int oo=0x7fffffff;
const int sup=0x80000000;
typedef long long ll;
typedef unsigned long long ull;
template <typename it>void db(it *begin,it *end){while(begin!=end)cout<<(*begin++)<<" ";puts("");}
template <typename it>
string to_str(it n){string s="";while(n)s+=n%10+'0',n/=10;reverse(s.begin(),s.end());return s;}
template <typename it>int o(it a){cout<<a<<endl;return 0;}
ll mul(ll a,ll b,ll c){ll ans=0;for(;b;b>>=1,a=(a+a)%c)if(b&1)ans=(ans+a)%c;return ans;}
ll ksm(ll a,ll b,ll c){ll ans=1;for(;b;b>>=1,a=mul(a,a,c))if(b&1)ans=mul(ans,a,c);return ans;}

int main(){
	//freopen("in.txt","r",stdin);
	ll a,b;
	cin>>a>>b;if(a<b)o(0);else o(10);
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    static char str[100001];
    unsigned long long int count = 1;
    int len;//文字列の長さ
    int i;
    
    unsigned int bucket[26] = {0};
    
    scanf("%d", &len);
    scanf("%s", str);
    
    for(i = 0; i < len; i++){
        bucket[str[i] - 'a']++;
    }
    
    for(i = 0; i < 26; i++){
        if(bucket[i]){
            count *= (bucket[i] + 1);
        }
        
        if(count > 1000000007){
            count  %= 1000000007;
        }
    }
    
    printf("%llu\n", (count-1) % 1000000007);
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

ll X, Y;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> X >> Y;
  cout << (abs(X - Y) <= 1 ? "Brown" : "Alice") << endl;  

  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) {
    cin >> p[i];
  }
  vector<int> q(n);
  rep(i, n) {
    cin >> q[i];
  }
  vector<int> arr(n);
  rep(i, n) {
    arr[i] = i+1;
  }
  int a = 0, b = 0, cnt = 0;
  do {
    rep(i, n) {
      if (p[i] != arr[i]) {
        break;
      }
      if (i == n-1) {
        a = cnt;
      }
    }
    rep(i, n) {
      if (q[i] != arr[i]) {
        break;
      }
      if (i == n-1) {
        b = cnt;
      }
    }
    cnt++;
  } while(next_permutation(arr.begin(), arr.end()));
  
  cout << abs(a-b) << endl;
  return 0;
}

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

using namespace std;

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

char field[550][550];
int H,W;

int dis[550][550],dis2[550][550];
vector<int> si,sj;

void bfs(int res[550][550]){
	for(int i=0;i<H;i++) for(int j=0;j<W;j++) res[i][j]=-1;
	queue<int> qi,qj;
	for(int i=0;i<si.size();i++){
		qi.push(si[i]);
		qj.push(sj[i]);
		res[si[i]][sj[i]]=0;
	}
	while(!qi.empty()){
		int i=qi.front();
		qi.pop();
		int j=qj.front();
		qj.pop();
		int c=res[i][j];
		for(int k=0;k<4;k++){
			int nc=c+1;
			int ni=i+dx[k];
			int nj=j+dy[k];
			if(field[ni][nj]!='.') continue;
			if(res[ni][nj]!=-1&&res[ni][nj]<=nc) continue;
			res[ni][nj]=nc;
			qi.push(ni);
			qj.push(nj);
		}
	}
}

bool check(long double x){
	int cnt=0;
	long double sum=0;
	for(int i=0;i<H;i++) for(int j=0;j<W;j++){
		if(field[i][j]!='.') continue;
		long double tmp=1e11;
		if(dis[i][j]!=-1){
			tmp=dis[i][j];
		}
		if(dis2[i][j]!=-1){
			tmp=min(tmp,x+dis2[i][j]);
		}
		sum+=tmp;
		cnt++;
	}
	if(x<sum/cnt) return true;
	return false;
}

int main(){
	scanf("%d%d",&W,&H);
	for(int i=0;i<H;i++){
		scanf("%s",field[i]);
	}
	int sti=-1,stj=-1;
	int gi=-1,gj=-1;
	int cnt=0;
	for(int i=0;i<H;i++) for(int j=0;j<W;j++){
		if(field[i][j]=='s'){
			field[i][j]='.';
			sti=i,stj=j;
		}
		else if(field[i][j]=='g'){
			field[i][j]='#';
			gi=i,gj=j;
		}
		else if(field[i][j]=='*'){
			si.push_back(i);
			sj.push_back(j);
			cnt++;
		}
	}
	bfs(dis2);
	si.clear();
	sj.clear();
	si.push_back(gi);
	sj.push_back(gj);
	bfs(dis);
	if(cnt==0){
		printf("%d\n",dis[sti][stj]);
		return 0;
	}
//	for(int i=0;i<H;i++){
//		for(int j=0;j<W;j++) printf("%d ",dis[i][j]);
//		printf("\n");
//	}
	long double lb=0,ub=1e10;
	for(int stage=0;stage<500;stage++){
		long double mid=(ub+lb)/2;
		bool flg=check(mid);
		if(flg) lb=mid;
		else ub=mid;
	}
	long double ans=1e10;
	if(dis[sti][stj]!=-1) ans=dis[sti][stj];
	if(dis2[sti][stj]!=-1) ans=min(ans,dis2[sti][stj]+lb);
	printf("%.9llf\n",ans);
	return 0;
}

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

int main(){
 int A, B, K;
 cin >> A >> B >> K;
 vector<int> divisor;
 int count = 0;
 for(int i = 1; i <= min(A, B); i++){
   if(A % i == 0 && B % i == 0){
     divisor.push_back(i);
   }
 }
 reverse(divisor.begin(), divisor.end());
 cout << divisor.at(K-1) << endl;
}


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

int main(){
    int A,B;
    cin >> A >> B;
    if(A >= 13){
        cout << B << endl;
    }
    else if(A <= 5) {
        cout << 0 << endl;
    }
    else {
        cout << B/2 << endl;
    }
}



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

vector<int>v;
double EPS=1e-9;
//ll pre[500010],a[500010],res[1000001];
const ll mod=1e9+7;
ll fastpow(ll a, ll n)
{
    if(n == 0) return 1;
    ll x = fastpow(a, n/2);
    ll ans = x * x % mod;
    if(n % 2 == 1) ans = ans *a % mod;
    return ans%mod;
}

ll C(ll n,ll m) {
    if(n < m) return 0;
    ll res = 1;
    for(ll i=1; i<=m; i++) {
        ll a = (n+i-m)%mod;
        ll b = i%mod;
        res = res*(a*fastpow(b,mod-2)%mod)%mod;
    }
    return res;
}

ll Lucas(ll n,ll m) {
    if(m == 0) return 1;
    return C(n%mod, m%mod) * Lucas(n/mod,m/mod)%mod;
}
vector <ll> v1,v2;

int a[200010],vis[200010],suf[200010];

int main()
{
    ll n;
cin>>n;
/*bool p=0;
while(n>0)
{
    ll temp=n%10;
    if(temp==7){p=1;}
    n/=10;
}
if(p==1)cout<<"Yes";
else cout<<"No";*/
    ll sum=0;
    for(int i=1;i<=n;i++)
{
    if(i%3!=0&&i%5!=0)sum+=i;
}
cout<<sum;
return 0;
}


Measured memory_bytes: 3644