akhauriyash/Code-Regression huggingface dataset:
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    ll k,a,b;cin>>k>>a>>b;
    if(b-a<=2||k+1<=a){
        cout<<k+1<<endl;
    }else{
        k-=a-1;
        cout<<(a+k/2*(b-a)+k%2)<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
typedef long long ll;

using namespace std;

string s;
ll k;
int main() {
  cin >> s >> k;
  ll tmp = 0;

  while(s[tmp] == '1') tmp++;

  if(tmp >= k) cout << '1' << endl;
  else cout << s[tmp] << endl;
}
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int sum=0;
  cin>>s;
  if(s[0]==s[1])sum++;
  if(s[0]==s[2])sum++;
  if(s[0]==s[3])sum++;
  if(s[1]==s[2])sum++;
  if(s[1]==s[3])sum++;
  if(s[2]==s[3])sum++;
 if(sum==2)cout<<"Yes"<<endl;
 else cout<<"No"<<endl;
 return 0;
}

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

int main(){
    string s;
    cin >> s;
    vector<unsigned long> a(26);
    for(const auto& c : s)++a[c - 'a'];
    for(unsigned long i = 0; i < 26; ++i)if(!a[i])return 0 & putchar(i + 'a');
    puts("None");
}

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

using namespace std;

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

  uint64_t x, y;
  cin >> x >> y;

  int ans = 0;
  while (x < y) {
    x *= 2;
    ++ans;
  }
  ans += x == y;
  cout << ans << "\n";
}


Measured memory_bytes: 256
'use strict'

const main = (INPUT) => {
  const input = INPUT.split('\n')
  const H = input[0].split(' ')[0]
  const C = input.slice(1)

  for (let i = 0; i < H; i++) {
    console.log(C[i])
    console.log(C[i])
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 11180
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, k, a[100009];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int cnt = 1;
	n -= k;
	cnt += (n + k - 2)/ (k - 1);
	cout << cnt << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

#define ld  long double
#define ll  long long int
#define ull unsigned long long int
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,s,n) for(int i=s;i<n;i++)

const int    INF = 1e11;
const double EPS = 1e-11;

//切り上げ整数除算
int divRoundUp(const int& a, const int& b) { return (a + b - 1) / b; }
//四捨五入
int roundOff(const double& a) { return (int)(a + 0.5); }
// r の(誤差付きの)符号に従って, -1, 0, 1 を返す.
int sgn(const ld& r) { return (r > EPS) - (r < -EPS); }
// a, b の(誤差付きの)大小比較の結果に従って, -1, 0, 1 を返す.
int sgn(const ld& a, const ld& b) { return sgn(a - b); }

using namespace std;

inline void Main() {
	int a; cin >> a;
	int b; cin >> b;
	int ans = (a < 10 && b < 10) ? (a * b) : -1;
	cout << ans << "\n";
}

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

	Main();

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>

using namespace std;

int main()
{
	string source = "";
	cin >> source;

	if(source.length() > 10 || source.length() < 1)
	{
		return -1;
	}

	int max_i = static_cast<int>(pow(2, source.length() - 1));

	double sum = 0;

	for (int i = 0; i < max_i; ++i)
	{
		bitset<100> plus(i);

		double number = 0;

		string working = source;
		while(plus.any())
		{
			int i = 0;
			while(!plus[i]) ++i;
			sum += atof(working.substr(0, i + 1).c_str());
			plus >>= i + 1;
			working = working.substr(i + 1);
		}
		sum += atof(working.c_str());
	}

	cout.precision(0);
	cout << fixed << sum << endl;


	return 0;
}

Measured memory_bytes: 256
x = int(input())
for i in range(10**3+1):
    for j in range(i+1,10**3+1):
        if i**5-j**5==x:
            print(i,j)
            exit()
        if j**5-i**5==x:
            print(j,i)
            exit()
        if i**5+j**5==x:
            print(i,-j)
            exit()

Measured memory_bytes: 9128
use nqp;

my \a = $*IN.get.split(" ");
for <0 1 2> {
  nqp::if(
                nqp::cmp_s(a[nqp::mod_n(nqp::unbox_i($_),nqp::unbox_i(3))],a[nqp::mod_n(nqp::unbox_i($_+1),nqp::unbox_i(3))]) == nqp::unbox_i(0),
                nqp::say(a[nqp::mod_n(nqp::unbox_i($_+2),nqp::unbox_i(3))])
        )
}

Measured memory_bytes: 65536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 1001001001;

int main(){
    int n,k;
    cin >> n >> k;
    int ans = 1;
    for(int i=0;i<n;i++){
        ans = min(2*ans,ans+k);
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<long long> a(N), b(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  for (int i = 0; i < N; i++) cin >> b[i];

  long long a_sum = 0, b_sum = 0, a_cnt = 0, b_cnt = 0;
  for (int i = 0; i < N; i++) {
    a_sum += a[i], b_sum += b[i];
    if (a[i] < b[i]) {
      a_cnt += (b[i] - a[i]) / 2;
    } else if (a[i] > b[i]) {
      b_cnt += a[i] - b[i];
    }
  }

  if (a_cnt >= b_cnt) {
    puts("Yes");
  } else {
    puts("No");
  }

  return 0;
}

Measured memory_bytes: 384
fun main(args:Array<String>):Unit{
    loop@while(true){
        val line = readLine()
        when(line){
            null -> break@loop
            else -> {
                var joi = 0
                var ioi = 0
                for (i in 1 until (line.length - 1)){
                    if (line[i] == 'O' && line[i + 1] == 'I'){
                        when(line[i - 1]){
                            'I' -> ++ioi
                            'J' -> ++joi
                        }
                    }
                }
                println(joi)
                println(ioi)
            }
        }
    }
}


Measured memory_bytes: 24564
#include<stdio.h>

int main(void)
{
	int i, X, Y;
	scanf("%d%d", &X, &Y);

	if (Y % 2 == 0)
	{
		if (Y <= 4 * X&&Y>=2*X)
		{
			printf("Yes");
		}
		else
		{
			printf("No");
		}
	}
	else
	{
		printf("No");
	}
	return 0;
}


Measured memory_bytes: 1732
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &in, vector<T> &vec) {
    for (auto &e : vec) in >> e;
    return in;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    int N;
    read(N);

    vector<int> a(N);
    read(a);
    sort(all(a));
    if (N & 1) {
        print(0);
    } else {
        print(a[N/2] - a[N/2-1]);
    }

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,a,b;cin>>x>>a>>b;
    int ans = x-a;
    bool key = true;
    while(key){
        ans = ans-b;
        if(ans-b<0){key=false;}
    }
    cout<<ans<<endl;
}

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

int main(){
  int n,t;cin>>n>>t;
  int a[n],b[n];
  fol(i,n){
    cin>>a[i]>>b[i];
  }
  int ans = 1001;
  fol(i,n){
    if(b[i]<=t){
      ans=min(a[i],ans);
    }
  }
  if(ans==1001){
    cout << "TLE"<<endl;
  }else{
    cout << ans << endl;
  }
  return 0;
}


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

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;

const int INF = 1e9;
const int MAXN = 2e5 + 5;
const int MOD = 1e9 + 7;

int N, sz[MAXN];
ll ans[MAXN], fac[MAXN];
vector<int> G[MAXN]; 

ll POW(int a, int b) {
	if(b == 0) return 1;
	if(b == 1) return a;
	ll t = POW(a, b/2); t = (t*t) % MOD;
	if(b & 1) t = (a * t) % MOD;
	return t;
}
ll MOD_INV(int x) { return POW(x, MOD-2); }

ll dp[MAXN];
ll dfs0(int x, int p) {
	dp[x] = 1;
	for(int i : G[x]) if(i != p) {
		dp[x] = (dp[x] * dfs0(i, x)) % MOD;
		dp[x] = (dp[x] * MOD_INV(fac[sz[i]])) % MOD;
		sz[x] += sz[i];
	}
	dp[x] = (dp[x] * fac[sz[x]]) % MOD;
	sz[x]++;
	return dp[x];
}

void dfs(int x, int p) {
	ans[x] = fac[N-1];
	ll szp = N-1, val;
	for(int i : G[x]) if(i != p) {
		ans[x] = (ans[x] * dp[i]) % MOD;
		ans[x] = (ans[x] * MOD_INV(fac[sz[i]])) % MOD;
		szp -= sz[i];
	}
	if(x != 1) {
		val = ans[p];
		val = (val * MOD_INV(fac[N-1])) % MOD;
		val = (val * fac[N-1-sz[x]]) % MOD;
		val = (val * fac[sz[x]]) % MOD;
		val = (val * MOD_INV(dp[x])) % MOD;
		ans[x] = (ans[x] * val) % MOD;
		ans[x] = (ans[x] * MOD_INV(fac[szp])) % MOD;
	}
	for(int i : G[x]) if(i != p) dfs(i, x);
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	fac[0] = 1;
	for(int i=1; i<N; i++) {
		int a, b; cin >> a >> b;
		G[a].push_back(b); G[b].push_back(a);
		fac[i] = fac[i-1] * i % MOD;
	}
	fac[N] = (fac[N-1] * N) % MOD;

	dfs0(1, 0);
	dfs(1, 0);

	for(int i=1; i<=N; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 19444
#include<iostream>
using namespace std;
typedef long long li;
#define ceil(a,b) (((a)+(b)-1)/(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  int a,b,c,d; cin >> a >> b >> c >> d;
  print((ceil(c,b)<=ceil(a,d))?"Yes":"No");
}

Measured memory_bytes: 3584
# https://atcoder.jp/contests/abc159/tasks/abc159_d

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

box = [0] * (N + 1)
box_2 = [0] * (N + 1)
box_3 = [0] * (N + 1)

for i in range(N):
    box[A_list[i]] += 1

for i in range(N + 1):
    if box[i] > 1:
        box_2[i] = (box[i] * (box[i] - 1)) / 2
        box_3[i] = ((box[i] - 1) * (box[i] - 2)) / 2

ans_base = sum(box_2)

for i in range(N):

    if box[A_list[i]] > 0:
        diff = box_2[A_list[i]] - box_3[A_list[i]]
        print(int(ans_base - diff))
    else:
        print(int(ans_base))
    


Measured memory_bytes: 26140
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
vector<bool> visited(100001, false);
vector < vector <lli> > g(100001);
bool dfs(int i ){
    if(visited[i])return false;

    visited[i]= true;
    for(int x =0;x<g[i].size();x++){
        dfs(g[i][x]);
    }
    return true;
}
int main(){
    
    lli ans = 0;
    lli n,k;
    cin >> n>>k;
    for(int i =1;i<=k;i++){
        lli x,y,z;
        cin >> x >> y >> z;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    for(int i =1;i<=n;i++){
        if(dfs(i))ans++;
    }
    cout << ans << endl;
}

/*

*/


Measured memory_bytes: 8832
#include<math.h>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
//AtCoderC++.cpp

using namespace std;

vector<int> _prime;
vector<int> build_prime_table(int max) {
	vector<int> table = vector<int>(max + 1, -1);
	table[0] = 0;
	table[1] = 0;
	table[2] = 1;
	for (int i = 3; i <= max; i++) {
		if (i % 2 == 0) { table[i] = 0; continue; }
		if (table[i] != -1)continue;
		table[i] = 1;
		for (int j = i + i; j <= max; j += i) {
			table[j] = 0;
		}
	}
	return table;
}

inline int ceileing(int a, int b) {
	return a % b == 0 ? a / b : a / b + 1;
}


vector<long long> comb = vector<long long>(100 * 100, -1);

long long combination(long long n, long long r) {
	if (n == 1 || n == 0)return 1;
	if (n == r)	return 1;
	else if (r == 0)return 1;
	else if (r == 1)return n;
	else if (comb[100 * (n - 1) + (r - 1)] != -1) return comb[100 * (n - 1) + (r - 1)];
	else {
		auto res = combination(n - 1, r - 1) + combination(n - 1, r);
		comb[100 * (n - 1) + (r - 1)] = res;
		return res;
	}
}


struct step {
	int x, y, steps;
	vector<pair<int, int>> history{};
};

int main() {
	int H, W; cin >> H >> W;
	auto is_white = vector<bool>(H*W);
	int white_count = 0;
	string row;
	for (size_t i = 0; i < H; i++) {
		cin >> row;
		for (size_t j = 0; j < W; j++) white_count += (is_white[i*W + j] = (row[j] == '.'));
	}
	auto q = queue<step>();
	auto visited = vector<bool>(H*W, false);
	q.push({ 0, 0,0 }); visited[0] = true;
	step s;
	auto answers = vector<step>();
	while (!q.empty()) {
		s = q.front(); q.pop(); s.history.push_back({ s.x,s.y });
		if (s.x == W - 1 && s.y == H - 1) break;
		if (s.x > 0 && is_white[s.y*W + s.x - 1]&&!visited[s.y*W + s.x - 1]) {
			q.push({ s.x - 1,s.y,s.steps + 1,s.history });
			visited[s.y*W + s.x - 1] = true;
		}
		if (s.x < W - 1 && is_white[s.y*W + s.x + 1] && !visited[s.y*W + s.x + 1]) {
			q.push({ s.x + 1,s.y,s.steps + 1,s.history });
			visited[s.y*W + s.x + 1] = true;
		}
		if (s.y > 0 && is_white[(s.y-1)*W + s.x] && !visited[(s.y - 1)*W + s.x]) {
			q.push({ s.x ,s.y - 1,s.steps + 1 ,s.history });
			visited[(s.y - 1)*W + s.x] = true;
		}
		if (s.y < H - 1 && is_white[(s.y+1)*W + s.x] && !visited[(s.y + 1)*W + s.x]) {
			q.push({ s.x ,s.y + 1,s.steps + 1,s.history });
			visited[(s.y + 1)*W + s.x] = true;
		}
	}
//	for (auto p : s.history)cout << p.first << "," << p.second << endl;
	if (s.x == W - 1 && s.y == H - 1) cout << white_count - s.steps - 1 << endl;
	else cout << -1 << endl;
}

Measured memory_bytes: 384
n,k = map(int, input().split())
v = list(map(int, input().split()))

ans = 0
for x in range(k+1):# LeftHand
  for y in range(k-x+1):# RightHand
    temp1 = []
    temp2 = []
    if x+y >= n:
      for i in v:
        if i >= 0:
          temp1.append(i)
        else:
          temp2.append(i)
    else:
      for i in v[:x]:
        if i >= 0:
          temp1.append(i)
        else:
          temp2.append(i)
      for i in v[len(v)-y:]:
        if i >= 0:
          temp1.append(i)
        else:
          temp2.append(i)
    temp2.sort()
    ans = max(ans, sum(temp1) + sum(temp2[k-x-y:]))
print(ans)

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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i=0; i<n; i++) cin >> h[i];

  int max = h[0];
  int cnt = 1;
  for (int i=1; i<n; i++) {
    if (max <= h[i]) {
      cnt++;
      max = h[i];
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
import std.stdio,std.conv,std.string,std.algorithm,std.array;
void main(){
  auto s=readln().chomp().split().map!(to!int);
  int a=s[0],b=s[1];
  if(a<=8&&b<=8)
    writeln("Yay!");
  else
    writeln(":(");
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n, l;
	cin >> n >> l;
	vector<string>s(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	
	sort(s.begin(),s.end());
	for (int i = 0; i < n; i++) {
		cout << s[i];
	}
	cout << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int N;
	cin >> N;
	set<string> s;
	string tmp;
	REP(i, 0, N){
		cin >> tmp;
		s.insert(tmp);
	}
	cout << s.size();

}


Measured memory_bytes: 19252
import java.util.*;

public class Main {
	
	HashMap<String,Integer> cache = new HashMap<>();
	
	public int longest(String a, String b) {
		String cacheKey = a+","+b;
		if(cache.containsKey(cacheKey)) {
			return cache.get(cacheKey);
		}
		
		int answer = 0;
		if(a.isEmpty() || b.isEmpty()) {
			cache.put(cacheKey,answer);
			return 0;
		}
		
		if(a.charAt(0) == b.charAt(0)) {
			answer +=1+longest(a.substring(1),b.substring(1));
		}else {
		answer += Math.max(longest(a.substring(1),b),longest(a,b.substring(1)));
		}
		cache.put(cacheKey,answer);
		
		return answer;
	}
	
	public int longestFast(String a, String b) {
		int x= a.length();
		int y= b.length();
		
		int[][] matrix = new int[x+1][y+1];
		for(int i = 0; i<=x; i++) {
			for(int k =0; k<=y; k++) {
				matrix[i][k]=0;
			}
		}
		
		for(int i = 1; i<=x; i++) {
			for(int k =1; k<=y; k++) {
				if(a.charAt(i-1)==b.charAt(k-1)) {
					matrix[i][k]=matrix[i-1][k-1]+1;
				}else {
					matrix[i][k]=Math.max(matrix[i][k-1],matrix[i-1][k]);
				}
			}
		}
		
		return matrix[x][y];
		
		
	}

	public static void main(String[] args) {
		Main test = new Main();
		Scanner sc = new Scanner(System.in);
		int checks = sc.nextInt();
		for(int i =0;i<checks;i++) {
			System.out.println(test.longestFast(sc.next(),sc.next()));
		}
		
		
	}
}


Measured memory_bytes: 64864
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int h, n;
    cin >> h >> n;
    vi a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];

    vi dp(h+1, 1e10);
    dp[0] = 0;
    rep(i, n) {
        rep(j, h) {
            if(j+a[i] >= h) dp[h] = min(dp[h], dp[j]+b[i]);
            else dp[j+a[i]] = min(dp[j+a[i]], dp[j]+b[i]);
        }
    }

    cout << dp[h] << endl;
    
    return 0;
}

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

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

    vector<long long> A(n);
    vector<long long> B(n);
    for(int i=1; i<n; i++){
        cin >> A.at(i);
        B.at(A.at(i)-1)++;
    }

    for(int i=0; i<n; i++){
        cout << B.at(i) << endl;
    }
}


Measured memory_bytes: 6360
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	int out=0;
	int t=0;
	while(1){
		if(t==n)break;
		if(t==n-1){
			out++;
			t++;
			continue;
		}
		int l=t,r=t;
		while(l+1<n&&in[l]<=in[l+1])l++;
		while(r+1<n&&in[r]>=in[r+1])r++;
		out++;
		t=max(l,r)+1;
	}
	cout<<out<<endl;
}









Measured memory_bytes: 640
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 200005;
const int mod = 1000000007;

int y[maxn],idx[maxn];
int ans[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
 int n;
 cin>>n;
 for(int i=1;i<=n;i++){
   int x,yy;
   cin>>x>>yy;
   y[x] = yy;
   idx[x] = i;
 }
 int l=1, r=n;
 vector<int>vx,vy;
 set<pair<int,int>>st;
 for(int i=1;i<=n;i++){
   st.insert(make_pair(y[i],i));
 }
 while(l<=r&&!st.empty()){
   if(l==r){
     vx.push_back(l);
     vy.push_back(r);
     break;
   }
   int ll = l, rr = r;
   while(1) {
     auto mx = *st.rbegin();
     auto mi = *st.begin();
     if (mi.second < mx.second) {
       vx.push_back(l);
       vy.push_back(r);
       ll = rr + 1;
       break;
     }
     int mii = n + 1;
     for (int i = ll; i <= mx.second; i++) {
       mii = min(mii, y[i]);
     }
     int mxx = -1;
     for(int i=mi.second;i<=rr;i++){
       mxx = max(mxx, y[i]);
     }
     for (int i = ll; i <= mx.second; i++) {
       st.erase(make_pair(y[i],i));
     }
     for(int i=mi.second;i<=rr;i++){
       st.erase(make_pair(y[i],i));
     }
     if(mii==mx.first&&mxx==mi.first){
       ll = mx.second, rr = mi.second;
       vx.push_back(l);
       vy.push_back(ll);
       vx.push_back(rr);
       vy.push_back(r);
       break;
     }
     st.insert(make_pair(mii, mx.second));
     y[mx.second] = mii;
     st.insert(make_pair(mxx, mi.second));
     y[mi.second] = mxx;
   }
   l = ll+1, r = rr-1;
 }
 for(int i=0;i<vx.size();i++){
   int l = vx[i], r = vy[i];
   for(int j=l;j<=r;j++){
     ans[idx[j]] = r-l+1;
   };
 }
 for(int i=1;i<=n;i++)cout<<ans[i]<<endl;
  return 0;
}


Measured memory_bytes: 15296
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int D = scan.nextInt();
		int sum = N + D;
		if(sum %2 !=0) {
			System.out.println("IMPOSSIBLE");
		}
		else {
			System.out.println(sum/2);
		}
	}

}

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

int main()
{
	int n,t;
	unsigned int ans;
	while(cin >> n, n)
	{
		vector<unsigned int> v;
		while(n--)
		{
			cin >> t;
			v.push_back(t);
		}

		sort(v.begin(), v.end());

		ans=0;
		for(int i=0; i<v.size()-1; i++)
		{
			ans    += v[i];
			v[i+1] += v[i];
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 0
import math
n, d = map(int, input().split())
x = [list(map(int,input().split())) for i in range(n)]
cnt = 0
for i in range(n):
	for j in range(i+1,n):
		a = 0
		for k in range(d):
			a += (x[i][k] - x[j][k])**2
		b = math.sqrt(a)
		if b == int(b):
			cnt += 1
print (cnt)

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xs = readLine()!!.split(" ").map(String::toInt)
    val sort = xs.sortedDescending()
    val alice = sort.filterIndexed {
        index, value -> index % 2 == 0
    }.sum()
    val bob = sort.filterIndexed {
        index, value -> index % 2 == 1
    }.sum()
    println(alice - bob)
}

Measured memory_bytes: 36140
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        boolean ans = false;
        int n = 0;

        while(n <= B){
            if(n >= A){
                ans = true;
            }
            n += K;
        }

        System.out.println(ans?"OK":"NG");
    }
}


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

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

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

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

using namespace std;

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

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

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

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

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

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

    int n, m;
    cin >> n >> m;
    priority_queue< LL > pq;
    vector< LP > v;
    LP ar[SIZE];
    for( int i = 0; i < n; ++i ) {
        LL a, b;
        cin >> a >> b;
        v.pb( MP( a, b ) );

    }
    sort( all( v ) );

    int day = m - 1;
    LL res = 0;
    int vpos = 0;
    while( day >= 0 ) {
        while( vpos < v.size() && v[vpos].F + day <= m ) {
            pq.push( v[vpos].S );
            ++vpos;

        }
        if( pq.empty() ) {
            --day;
            continue;

        }
        LL p = pq.top(); pq.pop();
        res += p;
        --day;

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


Measured memory_bytes: 3568
#include<iostream>
#include<cstring>
#include<queue>
#include<cstdint>
using namespace std; // 575

const int MAX = 402;
const int around[5] = {0, 1, 0, -1, 0};

bool reverse(char a, char b) {
	return a == '.' && b == '#' || a == '#' && b == '.';
}
int main() {
	int H, W;
	string S[MAX];
	cin >> H >> W;
	for (int i = 0;i <= W + 1;++ i) S[0] += '*'; // 番兵の設置
	S[H + 1] = S[0];
	for (int i = 1;i <= H;++ i) {
		cin >> S[i];
		S[i] = '*' + S[i] + '*'; // これも番兵
	}
	int64_t black, white, ans = 0;
	queue<pair<int, int> > que;
	int x, y;
	for (int i = 1;i <= H;++ i) {
		for (int j = 1;j <= W;++ j) {
			black = white = 0;
			que.push(make_pair(j, i));
			while(!que.empty()) {
				int x = que.front().first, y = que.front().second;
				if (S[y][x] == '.') ++ white; else if (S[y][x] == '#') ++ black;
				for (int k = 0;k < 4;++ k) if (reverse(S[y][x], S[y + around[k]][x + around[k + 1]])) que.push(make_pair(x + around[k + 1], y + around[k]));
				S[y][x] = '*'; // 二度参照の禁止
				que.pop();
			}
			ans += black * white;
		}
	}
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

ある黒→白→……となるエリアを全部数えると、
そのエリアが黒nマス、白mマスとしてnmになることは自明
よってそれを数えていくだけ、O(HW)
なお、全部が市松模様としたときは最大でn=m=HW/2、よって答えが(HW)^2/4とオーバーフロー注意
*/

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

using namespace std;

int main(){
	int n,k,a;
	vector<int> lista;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a;
		lista.push_back(a);
	}
	sort(lista.begin(),lista.end());
	int res=-1;
	for(int i=0;i<n-k+1;i++){
		//cout<<lista[i+k-1]<<" "<<lista[i]<<endl;
		if(res==-1){
			res=lista[i+k-1]-lista[i];
		}
		else res=min(res,lista[i+k-1]-lista[i]);
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 892
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
import numpy as np
#import statistics
#import sys
#sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N=int(input())
    A=np.array(list(map(int,input().split())))

    for i in range(N):
        A[i]-=i+1

    B=abs(A-np.median(A))
    print(int(sum(B)))
resolve()

Measured memory_bytes: 34164
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
const ll INF = 1LL << 60;
#define MOD 1000000007
#define MAX_V 100010
#define MAX_N 100010

bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}

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

ll junnretu(ll n){
    ll ans=1;
    for (ll i=1;i<=n;i++){
        ans*=i;
    }
    return ans;
}

int main(){
    ll n,m;
    cin >> n >> m;
    bool x[m];
    fill(x,x+m,true);
    for (ll i=0;i<n;i++){
        ll k;
        cin >> k;
        bool xx[m];
        fill(xx,xx+m,false);
        for (ll j=0;j<k;j++){
            ll p;
            cin >> p;
            xx[p-1]=true;
        }
        for (ll j=0;j<m;j++){
            if (xx[j]){
                continue;
            }else{
                x[j]=false;
            }
        }
    }
    ll count=0;
    for (ll i=0;i<m;i++){
        if (x[i]){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 256
# coding:utf-8

import sys
from collections import Counter


# input = sys.stdin.readline
INF = float('inf')
MOD = 10 ** 9 + 7


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


S = input()
# print(S)
cnt = 0
ans = 0
for i in range(len(S)):
    if S[i] == 'B':
        continue
    ans += i - cnt
    cnt += 1
    # print(i, i - cnt)

print(ans)


Measured memory_bytes: 3880
#######################################
import numpy as np
import math
import copy
import re
import sys
#sys.exit(0)

inf = float("inf")
prime = 1

def check_print(check_flag, text, end="\n"):
  if check_flag:
    print(text, end=end)

def c2i(x):
    if str.isdecimal(x):
        return int(x)
    else:
        return x

def cout(*args):
  arglist = []
  for arg in args:
    if hasattr(arg, "__iter__"):
      arglist.extend(arg)
    else:
      arglist.append(arg)
      
  arglist = list(map(str, arglist))
  print(" ".join(arglist))
  
def count2(num):
  count=0
  while num%2==0:
    num/=2
    count+=1
  return count

def ketasum(num):
  nums = [int(s) for s in str(num)]
  return sum(nums)

#math
def gcd(a, b): #最大公約数
  while b:
    a, b = b, a % b
  return a

def lcm(a, b): #最小公倍数
  return a * b // gcd (a, b)

def gcd3(lis): #最大公約数(3over)
  ans = lis[0]
  for li in lis:
    ans = gcd(ans,li)

def lcm3(lis): #最小公倍数(3over)
  ans = lis[0]
  for li in lis:
    ans = lcm(ans,li)

def divisor(n): #nの約数を全て求める
  i = 1
  table = []
  while i * i <= n:
    if n%i == 0:
      table.append(i)
      table.append(n//i)
    i += 1
  table = list(set(table))
  return table

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

def is_prime(n):
  for i in range(2, n + 1):
    if i * i > n:
      break
    if n % i == 0:
      return False
  return n != 1

#input stock
"""
n = int(input())

#list
a = map(int, input().split())
a,b = map(int, input().split())

d=[]
for i in range(n):
  d[i]=int(input())

#2dim-list
a = [list(map(int, input().split())) for i in range(n)]

s = input()
ss =  [int(si) for si in s]
"""

#processing stock
"""
a = sorted(a)
a = sorted(a, reverse=True)

"""

#regex
"""
pattern = ""
result = re.search(pattern, s)

result = re.fullmatch(pattern, s)

result = re.finditer(pattern, s)
for res in result:
    print res.group()   # 1回目: ca      2回目: ca   
    print res.start()   # 1回目: 0       2回目: 6      
    print res.end()     # 1回目: 2       2回目: 8      
    print res.span()    # 1回目: (0, 2)  2回目: (6, 8)
"""

#######################################
a,b = map(int, input().split())

print(max(a+b,a-b,a*b))





Measured memory_bytes: 21244
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut xs = vec![0; n];
    let mut ys = vec![0; n];
    let mut hs = vec![0; n];
    for i in 0..n {
        xs[i] = read::<i64>();
        ys[i] = read::<i64>();
        hs[i] = read::<i64>();
    }
    for y in 0..101 {
        'outer_loop: for x in 0..101 {
            let mut h = 1 << 30;
            for i in 0..n {
                h = std::cmp::min(h, hs[i] + (x - xs[i]).abs() + (y - ys[i]).abs());
            }
            for i in 0..n {
                if hs[i] != std::cmp::max(0, h - (x - xs[i]).abs() - (y - ys[i]).abs()) {
                    continue 'outer_loop;
                }
            }
            println!("{} {} {}", x, y, h);
            return;
        }
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define N 1111116
#define mod 1000000007
#define next nxt
 
int n,x[N],y[N],next[N],p[N],h[N],q[N],s[N],cnt,cmt,cir;
long long fac[N],inv[N],ans;
vector<int> v[N];
 
long long C(int x,int y){
	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
 
void travel(int x,int pre){
	h[x]=true;q[++cnt]=x;
	for (int t=p[x];t;t=next[t],cmt++)
		if (!h[y[t]]) travel(y[t],x);
		else if (y[t]!=pre) cir=t;
}
 
void build(int x,int pre){
	for (int t=p[x];t;t=next[t])
		if (y[t]!=pre){
			if (y[t]<pre) v[x].push_back(y[t]),h[y[t]]=true;
			if (t/2!=cir/2) build(y[t],x);
		}
}
 
long long solve(int x){
	s[x]=0;long long ans=1;
	for (int i=0;i<(int)v[x].size();i++){
		ans=ans*solve(v[x][i])%mod;
		s[x]+=s[v[x][i]];
		ans=ans*C(s[x],s[v[x][i]])%mod;
	}
	s[x]++;return ans;
}
 
int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-')  f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}
 
int main(){
	n=read();
	for (int i=1;i<=2*n;i++){
		x[2*i]=y[2*i+1]=read();
		y[2*i]=x[2*i+1]=n+read();
		next[2*i]=p[x[2*i]];p[x[2*i]]=2*i;
		next[2*i+1]=p[x[2*i+1]];p[x[2*i+1]]=2*i+1;
	}
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	for (int i=2;i<N;i++) fac[i]=fac[i-1]*i%mod;
	for (int i=2;i<N;i++) inv[i]=-(mod/i)*inv[mod%i]%mod;
	for (int i=2;i<N;i++) inv[i]=inv[i-1]*inv[i]%mod;
	ans=fac[2*n];
	for (int i=1;i<=2*n;i++)
		if (!h[i]){
			cnt=cmt=0;travel(i,0);
			if (cmt!=cnt*2) {printf("0\n");return 0;}
			
			v[0].clear();
			for (int i=1;i<=cnt;i++)
				v[q[i]].clear(),h[q[i]]=false;
			build(y[cir],x[cir]);
			for (int i=1;i<=cnt;i++)
				if (!h[q[i]]) v[0].push_back(q[i]),h[q[i]]=true;
			long long tmp=solve(0);
			
			v[0].clear();
			for (int i=1;i<=cnt;i++)
				v[q[i]].clear(),h[q[i]]=false;
			build(x[cir],y[cir]);
			for (int i=1;i<=cnt;i++)
				if (!h[q[i]]) v[0].push_back(q[i]),h[q[i]]=true;
			tmp+=solve(0);
			
			ans=ans*tmp%mod*inv[cnt]%mod;
		}
	printf("%lld\n",(ans+mod)%mod);
	return 0;
}

Measured memory_bytes: 69884
#include <stdio.h>

int main(){
    int a,b,c,i,z;
    scanf( "%d",&z );
    for( i = 0;i < z;i++ ){
        scanf( "%d %d %d",&a,&b,&c );
        if( a >= b && a >= c ){
            printf( "%s\n",( a * a == b * b + c * c )?"YES":"NO" );
        }else if( b >= a && b >= c ){
            printf( "%s\n",( b * b == a * a + c * c )?"YES":"NO" );
        }else if( c >= a && c >= b ){
            printf( "%s\n",( c * c == a * a + b * b )?"YES":"NO" );
        }else{ printf( "NO\n" ); }
    }
    return 0;
}

Measured memory_bytes: 580
s=int(input())
def function(tmp):
    if tmp%2==0:
        return int(tmp/2)
    else:
        return int(3*tmp+1)
def hoge(t):
    if t==0:
        return s
    else:
        return function(a[t-1])
a=[]
for i in range(0,1000):
    if len(a):
        a.append(hoge(i))
    else:
        a=[hoge(i)]
    if a.count(hoge(i))==2:
        print(i+1)
        break

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;

typedef pair<int,int> P;

int main() {
  int n,m;
  m=0;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n,-1);

  for(int i=0; i<n; ++i) cin >> a[i];

  for(int i=n; i>0; --i) {
    bool f = a[i-1];
    int l = n/i;
    for(int j=l; j>0; --j) {
      if(b[i*j-1] == -1) {
        b[i*j-1] = f;
        if(f) m++;
        break;
      } else {
        if(b[i*j-1] == 1)
          f = !f;
      }
    }
  }

  cout << m << endl;
  for(int i=0; i<n; i++) {
    if(b[i] >= 1)
      cout << i+1 << endl;
  }
}

Measured memory_bytes: 2432
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#include <bits/stdc++.h>
#define rint register int
using namespace std;
const int MOD = 1000000007;
const int N = 3001;
int n,cur;
long long dp[2][N];
char ch;
inline void adj(long long &x) {if(x>=MOD)x-=MOD;}
int main()
{
    scanf("%d\n",&n);
    dp[0][1]=1LL;
    for (rint i=2;i<=n;i++,cur^=1)
    {
        scanf("%c",&ch);
        if (ch=='<')
        {
            dp[cur^1][1]=0LL;
            for (rint j=2;j<=i;j++) 
            {
                dp[cur^1][j]=dp[cur^1][j-1]+dp[cur][j-1];
                adj(dp[cur^1][j]);
            }
        }
        else 
        {
            dp[cur^1][i]=0LL;
            for (rint j=i-1;j>=1;j--) 
            {
                dp[cur^1][j]=dp[cur^1][j+1]+dp[cur][j];
                adj(dp[cur^1][j]);
            }
        }
    }
    for (rint i=1;i<n;i++) dp[cur][n]+=dp[cur][i];
    printf("%lld\n",dp[cur][n]%MOD);
    return 0;
}


Measured memory_bytes: 256
s = input()

for i in range(len(s)):
    s = s[:-1]
    if len(s) % 2 == 1:
        continue
    ss = s[len(s)//2:]
    flag = True
    for j in range(len(ss)):
        if ss[j] != s[j]:
            flag = False
            break
    if flag:
        print(len(s))
        break
    s = s[:-1]

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

using namespace std;

int p[10000007];

int factor(int x)
{
    int ans = 1;
    while (x > 1)
    {
        int k = p[x], c = 0;
        while (x % k == 0)
        {
            ++c;
            x /= k;
        }
        ans *= (c + 1);
    }
    return ans;
}


int main()
{
//    freopen("TEST.INP", "r", stdin);
    int n;
    cin >> n;
    for (int i = 2; i * i <= n; ++i)
        if (!p[i])
            for (int j = i * i; j <= n; j += i)
                p[j] = i;
    for (int i = 2; i <= n; ++i)
        if (!p[i]) p[i] = i;

    long long ans = 0;
    for (int i = 1; i <= n; ++i)
        ans += 1LL * i * factor(i);
    cout << ans;
    return 0;
}


Measured memory_bytes: 42684
N = int(input())
a = [0]*N
result = []
for i in range(N):
 a[i] = int(input())
a = sorted(a)
if N%2 != 0:
 a_sub = sorted(a,key=lambda x: -x)
 a_0 =a[N//2]
 for j in range(N//2):
  if j %2 ==0:
   result.insert(0,a_sub[j])
   result.append(a[j])
  else:
   result.insert(0,a[j])
   result.append(a_sub[j])
 tmp1 = abs(result[0] - a_0)
 tmp2 = abs(result[N-2] -a_0)
 if tmp1 < tmp2:
  result.append(a_0)  
 else:
  result.insert(0,a_0)
else:
 a_sub = sorted(a,key=lambda x: -x)
 for j in range(N//2):
  if j %2 ==0:
   result.insert(0,a_sub[j])
   result.append(a[j])
  else:
   result.insert(0,a[j])
   result.append(a_sub[j])
result_sum = 0
for k in range(N-1):
 result_sum = result_sum + abs(result[k] - result[k+1])
print(result_sum)

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

int kaijo(int num){
  if (num == 1) return num;
  return num * kaijo(num-1);
}

int main() {
  int n;
  cin >> n;
  int X = kaijo(n-1) * 2;
  vector<int> x(n), y(n);
  REP(i,n) cin >> x[i] >> y[i];
  auto dist = [&](int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return sqrt(dx*dx + dy*dy);
  };
  vector<int> p(n);
  REP(i,n) p[i] = i;
  double ren = 0;
  for (int i = 0; i < n-1; i++) {
    for (int j = i+1; j < n; j++) {
      ren += dist(p[i], p[j]) * X;
    }
  }
  double ans = ren/kaijo(n);

  printf("%.8f\n", ans);
  return 0;
}


Measured memory_bytes: 3852
/**
 * author: apikdech
 * created: 18:59:58 08-03-2020
 * last modified: 19:01:50 08-03-2020
**/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  string s;
  int ok = 1;
  cin >> s;
  if (s.length() & 1) cout << "No\n";
  else {
    for (int i = 0; i < s.length(); i += 2) {
      if (s[i] != 'h' || s[i+1] != 'i') ok = 0;
    }
    if (!ok) cout << "No\n";
    else cout << "Yes\n";
  }
  // cerr << "time = " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << " ms\n";
  return 0;
}

Measured memory_bytes: 384
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double

#define pll pair<ll,ll>
#define ff first
#define ss second

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

#define MOD  1000000007
const int N = 100005; 

#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
ll dx[] = {1,-1,0,0};
ll dy[] = {0,0,1,-1};

void solve()
{
    ll n,m;
    cin >> n >> m;
    ll s_i,s_j,e_i,e_j;
    cin >> s_i >> s_j >> e_i >> e_j;
    s_j--;s_i--,e_i--,e_j--;
    string s[n];
    for(ll i=0;i<n;i++)   cin >> s[i];
    ll dis[n][m];
    for(ll i=0;i<n;i++)   
    {
        for(ll j=0;j<m;j++)  dis[i][j] = 1e9;
    }
    dis[s_i][s_j] = 0;
    multiset<pair<ll,pair<ll,ll>>> q;
    q.insert({0,{s_i,s_j}});
    while(!q.empty())
    {
        pair<ll,pair<ll,ll>> p = *q.begin();
        ll x = p.ss.ff,y = p.ss.ss;
        q.erase(q.begin());
        for(ll i=0;i<4;i++)
        {
            ll n_x = x + dx[i];
            ll n_y = y + dy[i];
            if(n_x>=0 && n_x<n && n_y>=0 && n_y<m && dis[n_x][n_y]>dis[x][y] && s[n_x][n_y]=='.')
            {
                 dis[n_x][n_y] = dis[x][y];
                 q.insert({dis[n_x][n_y],{n_x,n_y}});
            }
        } 
        for(ll i=-2;i<=2;i++)
        {
            for(ll j=-2;j<=2;j++)
            {
                ll n_x = x + i;
                ll n_y = y + j;
                if(n_x>=0 && n_x<n && n_y>=0 && n_y<m && dis[n_x][n_y]>dis[x][y]+1 && s[n_x][n_y]=='.')
                {
                     dis[n_x][n_y] = dis[x][y] + 1;
                     q.insert({dis[n_x][n_y]+1,{n_x,n_y}});
                }
            }
        }
    }
    if(dis[e_i][e_j]==1e9)  dis[e_i][e_j] = -1;
    cout<<dis[e_i][e_j];
}

int main()
{
    FAST;
    int t = 1;
 // cin >> t;
    for(int i=1;i<=t;i++)
    {
        solve();
    }
}

Measured memory_bytes: 13100
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;


int main(){
    long long n;
    cin >> n;
    vector<pair<long long, long long> > a(n), b(n);
    for(int i = 0; i < n; ++i) cin >> a[i].second >> a[i].first;
    for(int i = 0; i < n; ++i) cin >> b[i].first >> b[i].second;
    sort(b.begin(), b.end());
    sort(a.begin(), a.end());
    long long ans = 0;
    cout << endl;
    for(int i = 0; i < n; ++i){
        long long s = b[i].first, f = b[i].second;
        int in = -1;
        for(int j = 0; j < n; ++j){
            if(a[j].first < f && a[j].second < s){
                in = max(in, j);
            }
        }
        if(in != -1){
            ans++;
            a[in].first = a[in].second = 1e9;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256