akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<int> cnt(3);
  for (int i = 0; i < n; ++i) {
    cnt[s[i] - 'a']++;
  }
  int q = n / 3, r = n % 3;
  sort(cnt.begin(), cnt.end(), greater<int>());
  bool found = false;
  for (int i = 0; i < 3; ++i) {
    if (i < r) {
      if (cnt[i] != q + 1) found = true;
    } else {
      if (cnt[i] != q) found = true;
    }
  }
  cout << (found ? "NO" : "YES") << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cstring>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <stack>
using namespace std;
#define ll long long
#define pb push_back
#define pp pair<long long,long long>
#define ppp pair<pair<long long,long long>,long long>
#define f first
#define s second
#define pd pair<double,long long>
multiset<ll> st1,st2;
pp arr[200100];
int main() {
	ll t,n,i,j,k,l,m;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll p;
	t=1;
	//cin>>t;
	while (t--) {
		cin>>n;
		for (i=1;i<=n;i++) {
			cin>>j>>k;
			arr[i].f=j,arr[i].s=k;
			st1.insert(j+k);
			st2.insert(j-k);
		}
		ll ans=0;
		for (i=1;i<=n;i++) {
			ll op1 = arr[i].f+arr[i].s;
			st1.erase(st1.find(op1));
			ll x = *(st1.begin());
			ans=max(ans,op1-x);
			x = *(st1.rbegin());
			ans=max(ans,x-op1);
			st1.insert(op1);
			ll op2 = arr[i].f-arr[i].s;
			st2.erase(st2.find(op2));
			ll y = *(st2.begin());
			ans=max(ans,op2-y);
			y=*(st2.rbegin());
			ans=max(ans,y-op2);
			st2.insert(op2);
		}
		cout<<ans<<'\n';
	}
	return 0;
}

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

int64_t MOD = 1000000007;
double PI = 3.141592653589793;

int64_t mypow(int64_t x, int64_t y) //x ^ y
{
    if (y == 0)
        return 1;
    if (y == 1)
        return x;
    else if (y % 2 == 1)
        return mypow(x, y - 1) * x % MOD;
    else
    {
        int64_t tmp = mypow(x, y / 2);
        return tmp * tmp % MOD;
    }
}

int64_t soujo(int64_t x, int64_t y) //x ~ yの積
{
    if (y < x)
        swap(x, y);
    if (x == y)
        return y;
    else
        return x * soujo(x + 1, y) % MOD;
}

int64_t combi(int64_t x, int64_t y) //x C y,y < x
{
    if (y > x)
        swap(x, y);
    int64_t X = soujo(x - y + 1, x);
    int64_t Y = soujo(1, y);
    return X * mypow(Y, MOD - 2) % MOD;
}

int main()
{
    int64_t S;
    cin >> S;
    int64_t ans = 0;
    for (int i = 1; i <= S / 3; i++)
    {
        int tmp = S - i * 3;
        ans += combi(tmp + i - 1, i - 1);
        ans %= MOD;
    }
    if (S >= 3)
        cout << (ans + 1) % MOD;
    else
        cout << 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    ll t1, t2, a1, a2, b1, b2; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    ll da1 = t1*a1, da2 = da1 + t2*a2, db1 = t1*b1, db2 = db1 + t2*b2;
    ll res = ((da1-db1)/abs(da1-db1))*(da2-db2);
    if(res > 0){
        cout << 0 << endl;
    }else if(res == 0){
        cout << "infinity" << endl;
    }else{
        if((da1-db1)%(da2-db2)){
            cout << abs(da1-db1)/abs(da2-db2)*2 + 1 << endl;
        }else{
            cout << abs(da1-db1)/abs(da2-db2)*2 << endl;
        }
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <sstream>

using namespace std;

struct pos{
	int x1;
	int y1;
	int x2;
	int y2;
};

int W, H;
bool memo[60][60][60][60];

string field1[60], field2[60];

bool check1(int x, int y){
	if(x < 0 || y < 0 || x >= W || y >= H){
		return true;
	}else if(field1[y][x] == '#'){
		return true;
	}
	return false;
}

bool check2(int x, int y){
	if(x < 0 || y < 0 || x >= W || y >= H){
		return true;
	}else if(field2[y][x] == '#'){
		return true;
	}
	return false;
}

int main(){
	
	while(true){
		
		cin >> W >> H;
		if(W == 0){
			break;
		}
		
		for(int i = 0; i < H; i++){
			cin >> field1[i] >> field2[i];
		}
		
		for(int i = 0; i <= 50; i++){
			for(int j = 0; j <= 50; j++){
				for(int k = 0; k <= 50; k++){
					for(int l = 0; l <= 50; l++){
						memo[i][j][k][l] = false;
					}
				}
			}
		}
		
		int ini_x1, ini_x2, ini_y1, ini_y2;
		int goal_x1, goal_x2, goal_y1, goal_y2;
		
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				if(field1[i][j] == 'L'){
					ini_x1 = j;
					ini_y1 = i;
				}
				if(field2[i][j] == 'R'){
					ini_x2 = j;
					ini_y2 = i;
				}
				if(field1[i][j] == '%'){
					goal_x1 = j;
					goal_y1 = i;
				}
				if(field2[i][j] == '%'){
					goal_x2 = j;
					goal_y2 = i;
				}
			}
		}
		
		queue<pos> que;
		pos pos_first;
		pos_first.x1 = ini_x1;
		pos_first.y1 = ini_y1;
		pos_first.x2 = ini_x2;
		pos_first.y2 = ini_y2;
		que.push(pos_first);
		
		memo[ini_x1][ini_y1][ini_x2][ini_y2] = true;
		
		int dx_[4] = {1, 0, -1, 0};
		int dy_[4] = {0, 1, 0, -1};
		
		bool flag = false;
		
		while(!que.empty()){
			
			pos p = que.front();
			que.pop();
			
			//cout << p.x1 << " " << p.y1 << " " << p.x2 << " " << p.y2 << endl;
			for(int i = 0; i < 4; i++){
				int dx1 = dx_[i];
				int dy1 = dy_[i];
				int dx2 = -dx1;
				int dy2 = dy1;
				if(check1(p.x1 + dx1, p.y1 + dy1)){
					dx1 = 0;
					dy1 = 0;
				}
				if(check2(p.x2 + dx2, p.y2 + dy2)){
					dx2 = 0;
					dy2 = 0;
				}
				pos pp;
				pp.x1 = p.x1 + dx1;
				pp.y1 = p.y1 + dy1;
				pp.x2 = p.x2 + dx2;
				pp.y2 = p.y2 + dy2;
				if(memo[pp.x1][pp.y1][pp.x2][pp.y2]){
					continue;
				}
				
				if((pp.x1 == goal_x1 && pp.y1 == goal_y1) || (pp.x2 == goal_x2 && pp.y2 == goal_y2)){
					if((pp.x1 == goal_x1 && pp.y1 == goal_y1) && (pp.x2 == goal_x2 && pp.y2 == goal_y2)){
						flag = true;
					}
					continue;
				}
				memo[pp.x1][pp.y1][pp.x2][pp.y2] = true;
				que.push(pp);
			}
		}
		
		if(flag){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 13252
#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>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, M;
    cin >> A >> B >> M;
    int minA = 1e9, minB = 1e9;
    vector<int> a(A), b(B);
    rep(i,A){
        cin >> a[i];
        chmin(minA, a[i]);
    }
    rep(i,B){
        cin >> b[i];
        chmin(minB, b[i]);
    }
    int ans = minA + minB;
    rep(i,M){
        int x, y, c;
        cin >> x >> y >> c;
        x--; y--;
        chmin(ans, a[x]+b[y]-c);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  ll N; cin>>N;
  
  if (N%2 == 1) { 
    // f(N) = N*(N-2)*(N-4)*...5*3*1 : 2 が出ないので 10 も出ない
    cout << 0 << endl;
    return 0;
  }

  assert(N%2 == 0);
  // f(N) = N*(N-2)*(N-4)*...6*4*2
  //      = (N/2)! * 2^(N/2)
  // (N/2)! = (N/2)*(N/2-1)*...* 10 *9*8*7*6* 5 *4*3*2
  
  // (N/2)! 中の 5 の数を数える
  ll cnt5 = 0;
  ll n = N/2;
  while(n>0) {
    cnt5 += n/5;
    n /= 5;
  }

  ll ans = cnt5;
  cout << ans << endl;


  return 0;
}


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

#define fi first
#define se second
#define show(x) cerr << #x << "=" << "\n"
typedef long long ll;
typedef unsigned long long ull;

using namespace std;
const ll llinf = LLONG_MAX;
const ull ullinf = ULLONG_MAX;

ll n, k;
ll mod[200011];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1 = freopen("in.txt", "r", stdin);
  //stream2 = freopen("out.txt", "w", stdout);
  if (stream1 == NULL) return 0;
  //if (stream2 == NULL) return 0;:w
#endif
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    mod[i % k]++;
  }
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    int b = (k - (i % k)) % k;
    if ((2 * b) % k == 0) ans += mod[b] * mod[b];
  }
  cout << ans << endl;
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}



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

using namespace std;

int main(void) {
	int x,y;
	cin >> x >> y;

	for (int i = 0; i <= x; i++) {
		if (2 * i + 4 * (x - i)==y) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 3632
// AtCoder ABC112: B - Time Limit Exceeded
// 2020.1.29 bal4u

#include <stdio.h>

int main()
{
	int N, T, c, t, ans;
	
	scanf("%d%d", &N, &T);
	ans = 10000;
	while (N--) {
		scanf("%d%d", &c, &t);
		if (t <= T && c < ans) ans = c;
	}
	if (ans > 1000) puts("TLE");
	else printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
N = int(input())
S = list(input() for i in range(N))  #スペース抜きの単語を複数行

import collections
A = collections.Counter(S)

B = max(A.values())
C = [i for i in A.keys() if A[i] == B]
C = sorted(C)

for i in C:
    print(i)

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

int main(){
	int n,m;
	cin>>n>>m;
	vector<int> dp(n+1,1);
	vector<int> red(n+1,0);
	red[1]=1;
	
	int x,y;
	for(int i=0;i<m;i++){
		cin>>x>>y;
		dp[y]++;
		dp[x]--;
		if(red[x]==1){
			red[y]=1;
		}
		if(dp[x]==0){
			red[x]=0;
		}
	}
	
	int ans=0;
	
	for(int i=0;i<n+1;i++)if(red[i]!=0)ans++;
	
	cout<<ans<<endl;
	return 0;
	
}

Measured memory_bytes: 1024
/************************Code by Hardik Aggarwal!!!!***********************************/


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
/*#define endl '\n'*/
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn=100005;
ll a[55],p[55];
ll solve(ll n,ll x)
{	
	if(x>=a[n]) return p[n];
	if(x<=0) return 0;
	ll ans=0;
	if(x>=a[n]/2+1)
		{	ans++;
			ans+=solve(n-1,x-(a[n]/2+1));
		}
	ans+=solve(n-1,x-1);
	return ans;

}
int main()
{
	

/*	ll t;
	cin>>t;
	while(t--)
	{	
		string s1,s2;
		cin>>s1>>s2;

		ll pos,ans;
		reverse(s1.begin(),s1.end());
		reverse(s2.begin(),s2.end());
		
			for(ll i=0;i<s2.size();i++)
			{
				if(s2[i]=='1')
				{
					pos=i;
					break;
				}
			}

			for(ll i=pos;i<s1.size();i++)
			{
				if(s1[i]=='1')
					{ans=i-pos;break;}
				
			}
		


		cout<<ans<<endl;

	}

*/


	ll n,x;
	cin>>n>>x;
	a[0]=1;
	p[0]=1;

	for(ll i=1;i<=n;i++)
	{
		a[i]=2*a[i-1]+3;
		p[i]=2*p[i-1]+1;
	}

	ll ans=solve(n,x);
	cout<<ans;






}
	

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

int main(void) {
	// input
	int N;
	long long T;
	std::cin >> N >> T;
	std::vector<long long> t(N);
	for(int i = 0; i < N; ++i) std::cin >> t[i];
	
	long long X = 0;
	for(int i = 1; i < N; ++i) {
		X += std::min(T, t[i] - t[i-1]);
	}
	X += T;

	std::cout << X << std::endl;

	return 0;
}


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	long long n;
	long long sum = 0;
	vector<long long> a;
	cin >> n;

	for(int i=0; i<n; i++){
		int t;
		cin >> t;
		a.pb(t);
		sum += t;
	}
	long long m = (long long)n * (n+1) / 2;
	if(sum % m != 0){
		puts("NO");
		return 0;
	}
	long long k = sum / m;

	vector<long long> b;
	b.push_back(a[n-1] - a[0]);
	for(int i=1; i<n; i++){
		b.push_back(a[i-1] - a[i]);
	}
	bool f = true;
	for(int i=0; i<n; i++){
		b[i] += k;
		if(b[i] < 0){
			f = false;
			break;
		}
		//printf("%d ", b[i]);
		if(b[i] % n != 0) {
			f = false;
			break;
		}
	}
	if(f) puts("YES");
	else puts("NO");
	
	return 0;
}


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

using namespace std;

#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define F(i,x,n,y) for(i=x;i<n;i+=y)
#define fi(i,x,n) for(i=x;i<n;++i)
#define f(n) for(int i=0;i<n;++i)
#define fr(i,x,n) for(i=x;i>=n;--i)
#define endl '\n'

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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    int ans=0;
    for(auto x:s){
        if(x=='1') ++ans;
    }
    cout<<ans<<endl;

    return 0;
}



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

#include <iostream>
#include <string>

#define INF (1 << 29)
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

string S,T;

bool comp(int i){
  for(int j=0;j<T.length();j++){
    if(i+j >= S.length()){
      return false;
    }
    if(!(S[i+j] == T[j] || S[i+j] == '?')){
      return false;
    }
  }
  return true;
}

int main(){
  cin >> S >> T;
  bool flag = false;
  for(int i = S.length()-1;i>=0;i--){
    if(comp(i)){
      for(int j = 0;j<T.length();j++){
        S[i+j] = T[j];
      }
      flag = true;
      break;
    }
  }
  if(!flag){
    cout<<"UNRESTORABLE"<<endl;
    return 0;
  }
  REP(i,S.length()){
    if(S[i]=='?') cout<<"a";
    else cout<<S[i];
  }
  cout<<endl;
}


Measured memory_bytes: 384
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib> 
#include <ctime>
#include <unordered_map>
using namespace std;
typedef long long ll;
int main() {
	ll n, x, ret = 0;
	cin >> n;
	if (n & 0x1) {
		cout << 0 << endl; return 0;
	}
	for (x = 5; (n / x / 2) >= 1; x *= 5) {
		ret += n / x / 2;
	}
	cout << ret << endl;
}

Measured memory_bytes: 256
a[50][50],b[50][50],c[50][50];
main(){
	int H,W,h,w,i,j,k,R=-99999,r;
	scanf("%d%d",&H,&W);
	for(i=0;i<H;i++)for(j=0;j<W;j++)scanf("%d",a[i]+j);
	for(i=0;i<H;i++)for(j=0;j<W;j++)scanf("%d",b[i]+j);
	scanf("%d%d",&h,&w);
	for(i=0;i<h;i++)for(j=0;j<w;j++)scanf("%d",c[i]+j);
	for(i=0;i<=H-h;i++)for(j=0;j<=W-w;j++){
		for(r=k=0;k<h*w;k++){
			r+=a[i+k/w][j+k%w];
			if(b[i+k/w][j+k%w]!=c[k/w][k%w])break;
		}
		if(k==h*w&&R<r)R=r;
	}
	printf(R==-99999?"NA\n":"%d\n",R);
exit(0);}


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

char unlock(char ld,int key){
	for(int i=0;i<key;i++){
		if(ld=='a')ld='Z';
		else if(ld=='A')ld='z';
		else --ld;
	}
	return ld;
}


int main(){
	while(true){
		int n;
		vector<int>key;
		vector<int>::iterator ki;
		string data;
		cin>>n;
		if(n==0)break;
		key.resize(n);
		ki=key.begin();
		for(int i=0;i<n;i++)cin>>key[i];
		cin>>data;
		for(string::iterator di=data.begin();di!=data.end();++di){
			*di=unlock(*di,*ki);
			ki++;
			if(ki==key.end())ki=key.begin();
		}
		cout<<data<<endl;
	}
	return 0;
}

Measured memory_bytes: 1208
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n,k = Is()
if k == 1 or n == k:
    print(0)
else:
    print(n-k)

Measured memory_bytes: 5472
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>

#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

struct kasu {
    double aho;
};

int main()
{
    int n, a, b; cin >> n >> a >> b;
    string ans;
    if (a == 1 && b == 2) {
        cout << "Borys" << endl; return 0;
    }
    if ((b - a) % 2 == 0) {
        ans = "Alice";
    }
    else {
        ans = "Borys";
    }
    cout << ans << endl;
}

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



int main(){

    int n;
    cin>>n;
    for(int i=n/105;i<=n/100;i++){
        int t=n-100*i;
        if(t>=0 && t<=i*5){
            printf("1\n");
            return 0;
        }
    }
    printf("0\n");

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a>=1&&a<=13&&b>=1&&b<=13){
	
	if(a==1&&b!=1)
		cout<<"Alice";
		else if(b==1&&a!=1){
			cout<<"Bob";}
			else if(a>b)
			cout<<"Alice";
			else if(b>a)
			cout<<"Bob";
			else
			cout<<"Draw";
		}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define rv(s) reverse(s.begin(),s.end());
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  string s;cin>>s;
  int n=s.size();
  
  int ans=0;
  rep(i,n){
    if(s[i]=='0')ans++;
  }
  chmin(ans,n-ans);
  cout(ans*2);
}

Measured memory_bytes: 512
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using namespace std;

int main(){
    int n;
    while(true){
        scanf("%d", &n);
        if(n == 0) break;
        int par[100000];
        fill(par, par + 100000, 0);
        for(int _ = 0; _ < n; _++){
            int h, m, s;
            scanf("%d:%d:%d", &h, &m, &s);
            par[3600 * h + 60 * m + s] += 1;
            scanf("%d:%d:%d", &h, &m, &s);
            par[3600 * h + 60 * m + s] -= 1;
        }
        int acc = 0, ans = 0;
        for(int i = 0; i < 100000; i++){
            acc += par[i];
            ans = max(ans, acc);
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 1576
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, t;
    cin >> a >> b >> t;
    cout << (t / a) * b << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
d = defaultdict(lambda : "no such property")

check, *yaml = list(open(0))
before = []
beforei = []
ka = defaultdict(lambda :-1)
bv = -1
for y in yaml:
    y = y.split(":")
    vacant = y[0].count(" ")
    if bv >= vacant:
        for num,b in enumerate(beforei):
            if b == vacant:
                break
        before = before[:num]
        beforei = beforei[:num]
    bv = vacant
    before.append(y[0].strip(" "))
    beforei.append(bv)
    x = y[1][1:-1]
    d[tuple(before)] = "object" if x == "" else "string \""+x+"\""
ans = tuple(check.strip("\n").split(".")[1:])
print(d[ans])



Measured memory_bytes: 6148
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#include <string>
#include <cmath>
using namespace std;

#define INF ((1LL << 31) - 1)

using ll = long long;

ll N;

int main() {
  cin >> N;

  for (ll n = 1; n <= 3500; n++) {
    for (ll w = 1; w <= 3500; w++) {
      ll lh, rh, h, a, b;
      lh = 1, rh = 3501;
      a = N * n * w, b = 4 * n * w - N * (n + w);

      while (rh - lh > 1) {
        h = (lh + rh) / 2;
        //cerr << lh << " " << rh << endl;
        if (a == h * b) {
          cout << h << " " << n << " " << w << endl;
          return 0;
        }
        else if (a < h * b) {
          rh = h;
        }
        else {
          lh = h;
        }
      }
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N , K , A , B;
  int x = 1;
  // ここにプログラムを追記
  

    cin >> N >> K;
 for (int i = 0; i < N; i++) {
      A = x * 2;
      B = x + K;
     if (A < B) {
       x = A; }
     else {x = B; }
} 
  
  cout << x << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define all(v) v.begin(), v.end()

const ll mod=1000000007;

int countBits(int in){
  int res=0;
  for(int i=0;i<10;i++){
    int msk=1<<i;
    if((in&msk)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string outputYesNo(bool ans){
  return (ans?"YES":"NO");
}
int main() {
  int a,b,c;cin>>a>>b>>c;
  cout<<outputYesNo(b-a==c-b)<<endl;
  return 0;
}


Measured memory_bytes: 256
//124 B - Great Ocean View 2019/04/13
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int n; cin >> n;
    vector<int> h(n);
    rep(i ,n) cin >> h[i];
    int __view=0;bool f[n]={false};f[0]=true;
    for(int i=n-1;i>0;--i){ 
        int j=i; 
        while(j>0){  
            if(h[i]<h[j-1]) break;
            --j;
        }
        if(j==0) f[i]=true;
    }
    rep(i ,n){
        if(f[i]) ++__view;
    }
    cout << __view << endl;
}


Measured memory_bytes: 256
X, Y = input().split()

X = int(X)
Y = int(Y)

if (2*X > Y) or (4*X < Y):
    print("No")
    exit()
elif(Y % 2 != 0):
    print("No")
    exit()


for kame in range(0, 26):
    for tsuru in range(0, 51):
        if(tsuru * 2 + kame * 4) == Y:
            print("Yes")
            exit()
    
print("No")
exit()

Measured memory_bytes: 9196
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 200009
ll n,m,i,j,k,l,t,arr[sz],brr[sz],x,y,z;
vector<ll>v,v1;
int main()
{
    scanf("%lld",&n);
    n%=10;
    if(n==3)
    {
        printf("bon\n");
    }
    else if(n==0 || n==1 || n==6 || n==8)
        printf("pon\n");
    else
        printf("hon\n");
    return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long n ;
  cin >> n ;
  long long ans = n*(n+1)/2 - 3*(n/3)*(n/3+1)/2 - 5*(n/5)*(n/5+1)/2 + 15*(n/15)*(n/15+1)/2 ;
  cout << ans ;
  return 0 ;
}

Measured memory_bytes: 3536
import itertools
a=int(input())
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
d=[]
for i in range(1,a+1):
    d.append(i)
e=list(itertools.permutations(d))

count_b=0
count_c=0
for i in range(len(e)):
    if list(e[i])==b:
        count_b=i+1
    if list(e[i])==c:
        count_c=i+1
        
ans=count_b-count_c
if ans<0:
    ans*=-1
print(ans)

Measured memory_bytes: 8052
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[100005];
int main(){
	scanf("%d",&n);
	int rem=-1,k,w,maxnum=-1;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(a[i]>maxnum) maxnum=a[i],w=i;
	} 
	
	for(int i=1;i<=n;i++) if(min(a[i],maxnum-a[i])>rem&&i!=w) k=a[i],rem=min(a[i],maxnum-a[i]);
	cout<<maxnum<<" "<<k<<endl;
}

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

bool is_palindrome(const string &s, int head, int tail){
  while(head<tail){
    if (s[head]!=s[tail-1]) return false;
    head++;
    tail--;
  }
  return true;
}

int main(){
  string s;
  cin >> s;
  int n = s.size();
  if (is_palindrome(s, 0, n) && is_palindrome(s, 0, (n-1)/2) && is_palindrome(s, (n+3)/2 - 1, n)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc =  new Scanner (System.in);
		while(true){
			int h = sc.nextInt(),
				d = sc.nextInt(),
				s = sc.nextInt();
			if( h == -1 & d == -1 & s == -1)break;
			int sum = h*3600 + d*60 + s;
			int ans1 = 2*3600 - sum;
			int ans2 = 2*3600*3 - sum*3;
			System.out.printf("%02d:%02d:%02d\n", ans1/3600 , ans1%3600/60, ans1%60);
			System.out.printf("%02d:%02d:%02d\n", ans2/3600 , ans2%3600/60, ans2%60);
		}
	}

}

Measured memory_bytes: 26308
from math import sqrt
def f(a, b):
    c = max(a, b)
    ret = 0
    while(c != 0):
        c //= 10
        ret += 1
    return ret

N = int(input())
cand = []
for i in range(1, int(sqrt(N) + 2)):
    if N % i != 0:
        continue
    cand.append(f(i, N // i))
print(min(cand))

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

signed main() {
	int r, d, x;
	cin >> r >> d >> x;
	int ans = 0;
	rep(i, 10) {
		x = r * x - d;
		cout << x << endl;
	}
}


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

int n;
long long a[200010], pos[200010], neg[200010];

void calc_pos() {
    vector<long long> b(n);
    stack<pair<long long, int>> st;
    for (int i = n-1; i >= 0; i--) {
        b[i] = a[i], pos[i] = pos[i+1];
        if (b[i] < 0) pos[i]++, b[i] *= -2;
        if (i == n-1) continue;
        if (b[i] <= b[i+1]) {
            int cnt = 0;
            while (b[i] <= b[i+1]) {
                   cnt++, b[i+1] /= 4;
            }
            if (cnt > 1) st.emplace(i, cnt-1);
        } else {
            int cnt = 0;
            while (b[i] > b[i+1]) {
                cnt++, b[i+1] *= 4;
            }
            while (!st.empty() && cnt > 0) {
                int x = min(cnt, st.top().second);
                st.top().second -= x, cnt -= x;
                pos[i] += x * (st.top().first - i) * 2;
                if (st.top().second == 0) st.pop();
            }
            if (cnt > 0) pos[i] += (n - 1 - i) * cnt * 2;
        }
    }
}

void calc_neg() {
    vector<long long> b(n);
    stack<pair<long long, int>> st;
    for (int i = 0; i < n; i++) {
        b[i] = a[i], neg[i+1] = neg[i];
        if (b[i] < 0) b[i] *= -1;
        else neg[i+1]++, b[i] *= 2;
        if (i == 0) continue;
        if (b[i-1] >= b[i]) {
            int cnt = 0;
            while (b[i-1] >= b[i]) {
                   cnt++, b[i-1] /= 4;
            }
            if (cnt > 1) st.emplace(i, cnt-1);
        } else {
            int cnt = 0;
            while (b[i-1] < b[i]) {
                cnt++, b[i-1] *= 4;
            }
            while (!st.empty() && cnt > 0) {
                int x = min(cnt, st.top().second);
                st.top().second -= x, cnt -= x;
                neg[i+1] += x * (i - st.top().first) * 2;
                if (st.top().second == 0) st.pop();
            }
            if (cnt > 0) neg[i+1] += i * cnt * 2;
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    calc_pos(), calc_neg();
    long long ans = 1e18;
    for (int i = 0; i < n; i++) {
        ans = min(ans, pos[i] + neg[i]);
    }
    cout << ans << "\n";
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumlate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  int n; cin >> n; cout << n/3 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define llu unsigned long long
#define U unsigned int
#define SIZE 1000002
#define pie 3.14159265358979323
#define minuss 1e-6
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
    ll n;
    cin>>n;
    ll str[n+3];
    for(int i=0; i<n; i++)
        cin>>str[i];
     ll save=0;
     ll in=-4;ll lock=0;
    for(int i=0; i<n-1; i++)
    {
        if(str[i]>str[i+1])
        {
              save++;
              if(save==1)
                  in=i;
        }
        if(save==2)
        {
           swap(str[in],str[i+1]);
           break;
        }
    }
    for(int i=0;i<n-1;i++)
    {
        if(str[i]>str[i+1])
        {
            lock=1;
            break;
        }
    }
    if(lock==1)
        cout<<"NO"<<endl;
    else
        cout<<"YES"<<endl;
        memset(str,0,n);
}


Measured memory_bytes: 256
#include <cstdio>

int main() {
    int A, B;
    char op;

    scanf("%d %c %d", &A, &op, &B);
    if (op == '+') {
        printf("%d\n", A+B);
    } else if (op == '-') {
        printf("%d\n", A-B);
    }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public class Main {


  private void solve(InputReader in, PrintWriter out) {
    int n = in.nextInt();
    int c = n;
    int sum = 0;
    while (c > 0){
      sum += c % 10;
      c /= 10;
    }
    out.println(n % sum == 0 ? "Yes" : "No");

  }



  public static void main(String[] args) {
    new Main().run();
  }

  private void run() {
    try (
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out)) {
      solve(in, out);
    }
  }


  static class InputReader implements AutoCloseable {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

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

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

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

    @Override
    public void close() {

    }
  }

}

Measured memory_bytes: 20948
#include<stdio.h>

int main(void){
    int i, n, num, cnt = 0;
    scanf("%d %d %d", &i, &n, &num);
    for(; i <= n; i++){
        if(num%i == 0){
            cnt++;
        }
    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 2140
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0);

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    string s; cin >> s;
    bool ok = false;
    rep(i,3){
        if(s[i] == '7') ok = true;
    }
    cout << (ok?"Yes":"No") << endl;
}



Measured memory_bytes: 3624
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] b = new int[n];
    for (int i = 1; i < n; i++) {
      int num = sc.nextInt();
      b[i] = num;
    }
    long total = b[1];
    for(int i = 2; i < n; i++) {
      int min = Math.min(b[i], b[i-1]);
      total += min;
    }
    System.out.println(total + b[n-1]);
  }
}


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

typedef long long ll;
ll ans=-1;
const int maxn=1010;
int a[maxn];
int n;
void doit(ll x)
{
	int pre=10;
	ll y=x;
	while (x)
	{
		int q=x%10;
		if (pre!=10 && q!=pre-1)	return;
		pre=q;
		x/=10;
	}
	ans=max(ans,y);
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for (int i=1;i<=n;i++)
		for (int j=i+1;j<=n;j++)
			doit(a[i]*1LL*a[j]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x1, y1, x2, y2, x3, y3, x4, y4;
    cin >> x1 >> y1 >> x2 >> y2;
    x3 = x2 + y1 - y2;
    y3 = y2 + x2 - x1;
    x4 = x3 + x1 - x2;
    y4 = y3 + y1 - y2;
    printf("%d %d %d %d\n", x3, y3, x4, y4);
}


Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 1e5 + 10 ;
int main(){
    fastio
    int n , m ;
    cin >> n >> m ;
    char g[n + 2][m + 2] ;
    for(int i = 0; i < n + 2; i++){
        for(int j = 0; j < m + 2; j++){
            g[i][j] = '.' ;
        }
    }
    for(int i = 1; i < n + 1; i++){
        for(int j = 1; j < m + 1; j++){
            cin >> g[i][j] ;
        }
    }
    int X[] = {-1, 1, 0, 0} ;
    int Y[] = {0, 0, -1, 1} ;
    for(int i = 1; i < n + 1; i++){
        for(int j = 1; j < m + 1; j++){
            if ( g[i][j] == '#' ){
                bool ok = false ;
                for(int k = 0; k < 4; k++){
                    if ( g[i + X[k]][j + Y[k]] == '#' )  ok = true ;
                }
                if ( not ok ){
                    cout << "No" << endl;
                    return 0 ;
                }
            }
        }
    }
    cout << "Yes" << endl; 
    return 0 ;
}

Measured memory_bytes: 3608
#include<iostream>
using namespace std;
using ll = long long;
int main() {
	ll a, res = 0;
	cin >> a;
	for (ll i = 1; i <= a; i++) {
		if (i % 3 && i % 5)
		res += i;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3548
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
int main() {
	int k;
	int ks;
	int a;
	cin >> k >> a;
	ks = k * 500;
	if (ks>=a)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int n,m,i,j,k,l,r;
int a[100005];
long long ans,tmp,ans_sum,sum1[200005],sum2[200005];

int main()
{
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;++i)scanf("%d",&a[i]);
	for(i=1;i<n;++i)
	{
		l=a[i];r=a[i+1];
		if(r<l)r+=m;
		ans_sum+=r-l;
		if(l+1<r)
		{
			++sum1[l+2];sum2[l+2]-=l+1;
			--sum1[r+1];sum2[r+1]+=l+1;
		}
	}
	for(i=1;i<=m+m;++i)sum1[i]+=sum1[i-1],sum2[i]+=sum2[i-1];
	for(i=1;i<=m;++i)
	{
		tmp=sum1[i]*i+sum2[i]+sum1[i+m]*(i+m)+sum2[i+m];
		if(tmp>ans)ans=tmp;
	}
	printf("%lld\n",ans_sum-ans);
}


Measured memory_bytes: 5236
#include <utility>
#include <bitset>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <ios>
#include <iomanip>
#include <sstream>
#include <climits>
#include <cmath>

using namespace std;

#ifdef USE_LOG
#define LOG(str)  cout << str << endl
#define DMP(var)  cout << #var << " = " << var << endl
#else
#define LOG(...)
#define DMP(...)
#endif

#define FOR(v, b, e)   for (int v = (b); v < (e); ++v)
#define RFOR(v, b, e)  for (int v = (e) - 1; (b) <= v; --v)
#define REP(v, n)      FOR(v, 0, n)
#define RREP(v, n)     RFOR(v, 0, n)

#define ALL(c)         (c).begin(), (c).end()

typedef long long           ll;
typedef unsigned long long  ull;

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

	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;

	string S;
	cin >> S;

	if (S.find("##", A) < C) {
		cout << "No" << endl;
		return 0;
	}

	if (S.find("##", B) < D) {
		cout << "No" << endl;
		return 0;
	}

	if (C < D) {
		cout << "Yes" << endl;
		return 0;
	}

	auto p = S.find("...", A - 1);
	if (p == string::npos) {
		cout << "No" << endl;
		return 0;
	}

	p = S.find("...", B - 2);
	if (p == string::npos) {
		cout << "No" << endl;
		return 0;
	}

	if (p > (D - 2)) {
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<cstdio>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef long long ll;
ll Q,A,B,l,r,s,t,e,f,X,Y,L,R,K;
char cal(int x){
	if(x<=s*(K+1)) return x%(K+1)?'A':'B';
	x-=s*(K+1);
	if(x<=e) return 'A';x-=e;
	if(x<=f) return 'B';x-=f;
	return x%(K+1)==1?'A':'B'; 
}
void work(){
	scanf("%lld%lld%lld%lld",&A,&B,&l,&r);
	K=max((A-1)/(B+1)+1,(B-1)/(A+1)+1);
	if(K*A<B) s=e=0,X=A,Y=B;
	else{
		L=0;R=min((A-1)/K,B);
		while(L<R){
			int md=(L+R+1)>>1;
			K*(A-md*K)>=B-md?L=md:R=md-1;
		}
		s=L;X=A-s*K;Y=B-s;L=1;R=X;
		while(L<R){
			int md=(L+R+1)>>1;
			K*(X-md+1)>=Y?L=md:R=md-1;
		}
		e=L;X-=L;
	}          
	f=Y-K*X;t=X;
	FOR(i,l,r) cout<<cal(i);cout<<'\n';                                                             
}
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d",&Q);
	while(Q--) work();
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define LL long long
const LL mod=1e9+7;
#define maxn 305
using namespace std;
struct node{
    int l,num;
    node(int l,int num):l(l),num(num){}
};
vector<node>e[maxn];
LL dp[maxn][maxn][maxn];
int n,m;
bool check(int r,int g,int b){
    int k=max(r,max(g,b));
    for(int i=0;i<e[k].size();i++){
        int cnt=0;
        int left=e[k][i].l;
        if(r>=left) cnt++;
        if(g>=left) cnt++;
        if(b>=left) cnt++;
        if(cnt!=e[k][i].num) return false;
    }
    return true;
}
int main(){
//  freopen("input.txt","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int l,r,x;
        cin>>l>>r>>x;
        e[r].push_back(node(l,x));
    }
    LL ans=0;
    dp[0][0][0]=1;
    for(int r=0;r<=n;r++){
        for(int g=0;g<=n;g++){
            for(int b=0;b<=n;b++){
                LL c=dp[r][g][b];
                if(!c) continue;
                if(!check(r,g,b)){
                    dp[r][g][b]=0;
                    continue;
                }
                int k=max(r,max(g,b))+1;
                if(k==n+1){
                    ans+=dp[r][g][b];
                    ans%=mod;
                }
                dp[k][g][b]=(dp[k][g][b]+dp[r][g][b])%mod;
                dp[r][k][b]=(dp[r][k][b]+dp[r][g][b])%mod;
                dp[r][g][k]=(dp[r][g][k]+dp[r][g][b])%mod;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 221440