akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    string s;
    cin >> s;
    int c = 1;
    int acc = 0;
    vector<int> r;

    for(int i=0; i<N; ++i){
        if(s[i]=='0'+c){
            ++acc;
            if(i==N-1) r.push_back(acc);
        }
        else{
            c = 1-c;
            r.push_back(acc);
            acc = 1;
        }
    }
    if(r.size()%2==0) r.push_back(0);

    if(K>=(r.size()-1)/2){
        int count = 0;
        for(auto e : r){
            count += e;
        }
        cout << count << endl;
        return 0;
    }

    int count = 0;
    for(int i=0; i<K; i++){
        count += r[i*2] + r[i*2+1];
    }
    count += r[2*K];

    int m = count;
    for(int i=0; 2*(i+K)<r.size()-2; ++i){
        count = count + r[2*(i+K)+1] + r[2*(i+K)+2] - r[2*i] - r[2*i+1];
        if(count>m) m = count;
    }
    cout << m << endl;
}


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

using namespace std;

int n, T, x;
char s[200005];

int main() {
    scanf("%s", s);
    int ans = 0;
    for (int i = 0; s[i]; i++)
        ans += s[i] - '0';
    puts(ans%9==0?"Yes":"No");
    return 0;
}

Measured memory_bytes: 3848
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N;

int main()
{
	in >> N;
	if (N % 2 == 0) out << N << std::endl;
	else out << 2 * N << std::endl;
	return 0;
}


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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

const ll linf = 1LL << 60;

struct SEG {
	static const int mxn = 1 << 18;
	ll mx[mxn << 1];
	SEG() { memset(mx, -0x3f, sizeof(mx)); }
	void upd(int x, ll v) {
		for (x += mxn; x; x >>= 1)
			mx[x] = max(mx[x], v);
	}
	ll qry(int l, int r) {
		ll ans = -linf;
		for (l += mxn, r += mxn; l < r; l >>= 1, r >>= 1) {
			if (l & 1) ans = max(ans, mx[l ++]);
			if (r & 1) ans = max(ans, mx[-- r]);
		}
		return ans;
	}
} sl, sr;

const int mxn = 2e5 + 5;
int n, x[mxn], y[mxn], vy[mxn], ysz, id[mxn];

bool comp(int a, int b) {
	return x[a] < x[b];
}

int main() {
	scanf("%d", &n);
	rep(i, n) scanf("%d %d", &x[i], &y[i]), vy[ysz ++] = y[i];
	sort(vy, vy + ysz); ysz = unique(vy, vy + ysz) - vy;
	rep(i, n) id[i] = i;
	sort(id, id + n, comp);
	ll ans = -linf;
	rep(xx, n) {
		int i = id[xx];
		int p = lower_bound(vy, vy + ysz, y[i]) - vy;
		ans = max(ans, x[i] + y[i] + sl.qry(0, p + 1));
		ans = max(ans, x[i] - y[i] + sr.qry(p, ysz));
		sl.upd(p, -x[i] - y[i]);
		sr.upd(p, -x[i] + y[i]);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 15040
def main():
    N = int(input())

    def enum_divisors(n):
        # 約数列挙
        divs = []
        for i in range(1, n+1):
            if i*i > n:
                break
            if n % i == 0:
                divs.append(i)
                if n//i != i:
                    # i が平方数でない
                    divs.append(n//i)
        return divs

    ans = 0
    for k in enum_divisors(N-1):
        if 2 <= k:
            ans += 1

    for k in enum_divisors(N):
        if 2 <= k:
            n = N
            while n > 1 and n % k == 0:
                n //= k
            if n % k == 1:
                ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 65012
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
const int maxn=50+5;
int main()
{
    int n,k;
    while(scanf("%d%d",&n,&k)!=EOF)
    {
        long long num,i,j,even=0,odd=0;
        for(i=1; i<=n; i++)
            cin>>num,even+=(!(num&1)),odd+=(num&1);
        if(k)
        {
            if(odd)
                cout<<(1ll<<(odd-1+even))<<endl;
            else
                cout<<0<<endl;
        }
        else
        {
            if(odd==0)
                cout<<(1ll<<n)<<endl;
            else
                cout<<(1ll<<(odd-1+even))<<endl;
        }

    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for (int i = 0; i < (a); i++)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
typedef long long ll;
template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.first>>v.second;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.first<<","<<v.second;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>ll suma(const vector<T>&a){ll res(0);for(auto&&x:a)res+=x;return res;}

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":	" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template <typename T> struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T> using Matrix = vector<vector<T>>;

const ll LINF = 1LL << 60;
const int INF = 1001001001;

/////////////////////////////////////////////////////////////////////

int main() {
  ll k,s; cin>>k>>s;

  ll ans = 0;
  for (int i=0; i<=k; i++) {
    for (int j=0; j<=k; j++) {
      ll t = s-i-j;
      if (0 <= t && t <= k) ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3560
#include<set>  
#include<map>  
#include<stack>  
#include<cstdio>  
#include<queue>  
#include<cmath>  
#include<vector>  
#include<cstring> 
#include<climits>  
#include<iostream> 
#include<algorithm> 
using namespace std;
#define INF 0x3f3f3f3f
#define LL long long
LL read(){ 
    LL f=1,x=0; 
    char c=getchar(); 
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();} 
    while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();} 
    return f*x; 
}
#define MAXN 10
LL a,ans;
int len;
char A[MAXN+5];
LL Pow[15]={1,10,100,1000,10000,100000,1000000,10000000,100000000ll,1000000000ll,10000000000ll};
void DFS(int x,LL sum,LL l){
	if(x>len-1){
		if(!l) ans+=sum;
		return ;
	}
	DFS(x+1,sum,l);
	sum+=l/Pow[len-x-1],l%=Pow[len-x-1];
	DFS(x+1,sum,l);
	return ;
}
int main(){
	scanf("%s",A);
	len=strlen(A);
	sscanf(A,"%lld",&a);
	DFS(0,0,a);
	printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll n;
  cin >> n;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
    a[i] -= i + 1;
  }
  sort(a.begin(), a.end());

  if (n % 2 == 1){
    ll res = 0;
    ll t = (a[n/2] + a[(n-1)/2])/2;
    for (int i = 0; i < n; i++){
      res += abs(t - a[i]);
    }
    cout << res << endl;
  }
  else {
    ll res = 0;
    ll t = a[n/2];
    for (int i = 0; i < n; i++){
      res += abs(t - a[i]);
    }
    cout << res << endl;
  }
  
  

  return 0;
}


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

typedef long long lli;

const lli INF = 2000000000LL;

string S;
lli K, x, mem[1111], next[1111];

lli init_rec() {
  lli res = 0;
  while (1) {
    if (isalpha(S[x])) {
      res = min(res + 1, INF);
      x++;
    } else if (isdigit(S[x])) {
      string num = "";
      while (isdigit(S[x])) {
        num += S[x++];
      }
      lli n = atoll(num.c_str());
      if (isalpha(S[x])) {
        x++;
        res = min(res + n, INF);
      } else {
        lli &len = mem[x];
        lli &nx = next[x];
        lli tmp = x;
        x++;
        len = init_rec();
        x++;
        nx = x;
        lli add = min(n * len, INF);
        res = min(res + add, INF);
      }
    } else {
      return res;
    }
  }
}

void rec() {
  while (1) {
    if (isalpha(S[x])) {
      if (--K == 0) {
        throw S[x];
      }
      x++;
    } else if (isdigit(S[x])) {
      string num = "";
      while (isdigit(S[x])) {
        num += S[x++];
      }
      lli n = atoll(num.c_str());
      if (isalpha(S[x])) {
        K -= n;
        if (K <= 0) {
          throw S[x];
        }
        x++;
      } else {
        lli len = mem[x];
        lli add = min(n * len, INF);
        if (K <= add) {
          K = (K - 1) % len + 1;
          x++;
          rec();
          assert(false);
        } else {
          K -= add;
          x = next[x];
        }
      }
    } else {
      return;
    }
  }
}

int main() {
  while (cin >> S >> K) {
    if (S == "0" && K == 0) return 0;
    K++;
    S += "$";
    x = 0;
    init_rec();
    try {
      x = 0;
      rec();
      cout << 0 << endl;
    } catch(char ans) {
      cout << ans << endl;
    }
  }
  return 0;
}

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

#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define PI acos(-1.0)
const int N=1e5 + 5;
const int M=1e5 + 5;


int main()
{
	ios_base::sync_with_stdio(false);
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k%2==0) cout<<a-b<<endl;
	else cout<<b-a<<endl;
		
	
		
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	bool boool=0,should=0;
	char a[100000];
	cin>>a;
	int b;
	b=strlen(a);
	for(int i=0;i<=b-1;++i)
	{
		if(a[i]=='C')
		boool=1;
		if(a[i]=='F'&&!boool)
		{
		}
		if(a[i]=='F'&&boool)
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mondai0063
{
	class Program
	{
		static void Main(string[] args)
		{
			int	cnt	= 0;
			var	s	= "";
			while( (s = Console.ReadLine()) != null ) {
				bool	palindrome	= true;
				for( int i = 0; i < s.Length / 2; i ++ ) {
					if( s[ i ] != s[ s.Length - i - 1] ) {
						palindrome	= false;
						break;
					}
				}
				if( palindrome ) {
					cnt++;
				}
			}
			Console.WriteLine( cnt );
		}
	}
}

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

int main(){

  int n, t[100], m, p[100], x[100], sum=0;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>t[i];
    sum+=t[i];
  }
  cin>>m;
  for(int i=0;i<m;i++) cin>>p[i]>>x[i];

  for(int i=0;i<m;i++) cout<<sum-t[p[i]-1]+x[i]<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdint>
#include <type_traits>
#include <algorithm>
#include <string>
#include <vector>
#include <assert.h>

template<typename RET = uint64_t, typename Integral>
RET combination(Integral all, Integral get)
{
	assert(all >= get);
	get = std::min(all - get, get);
#if 1
	constexpr int32_t ALL_MAX = 10'000;
	static std::vector<RET> DP_comb[ALL_MAX+1];
	if (!DP_comb[all].empty())
	{
		return DP_comb[all][get];
	}

	if (DP_comb[0].empty())
	{
		DP_comb[0].resize(1);
		DP_comb[0][0] = (RET)1;
		DP_comb[1].resize(1);
		DP_comb[1][0] = (RET)1;
	}
	for (int32_t i = 2; i <= all; i++)
	{
		if (DP_comb[i].empty())
		{
			int32_t size = i/2 + 1;
			DP_comb[i].resize(size);
			DP_comb[i][0] = (RET)1;
			for (int32_t j = 1; j < size-1; j++)
			{
				DP_comb[i][j] = DP_comb[i - 1][j - 1] + DP_comb[i - 1][j];
			}
			DP_comb[i][size-1] = DP_comb[i - 1][size - 2] + DP_comb[i - 1][(i&1)?(size-1):(size - 2)];
		}
	}
	return DP_comb[all][get];
#else
	RET ret = (RET)1;
	for (Integral i = 1; i <= get; ++i)
	{
		ret *= all+1-i;
		ret /= i;
	}
	return ret;
#endif
}
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>


#define in std::cin
#define out std::cout

int32_t N;
int32_t MIN, MAX;
int64_t A[100];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> N;
	in >> MIN >> MAX;
	for (size_t i = 0; i < N; i++)
	{
		in >> A[i];
	}
	std::sort(A, A + N, std::greater<>{});

	uint64_t sum = 0;
	for (size_t i = 0; i < MIN; ++i)
	{
		sum += A[i];
	}
	out << std::fixed << std::setprecision(10) << (double)(sum) / MIN << endl;

	auto range = std::equal_range(A, A + N, A[MIN - 1], std::greater<>{});
	auto range_lrngth = range.second - range.first;
	if (range_lrngth == 1)
	{
		out << 1 << endl; return 0;
	}
	auto not_free = range.first - A;
	uint64_t count = 0;
	if (not_free == 0)
	{
		for (int i = MIN; i <= std::min<int>(MAX, range_lrngth); ++i)
		{
			auto free = (MIN - not_free) + (i - MIN);
			//count += fact_v[range_lrngth] / fact_v[free] / fact_v[range_lrngth - free];
			count += combination(range_lrngth, free);
		}
	}
	else
	{
		auto free = (MIN - not_free) + (MIN - MIN);
		//count += fact_v[range_lrngth] / fact_v[free] / fact_v[range_lrngth - free];
		count += combination(range_lrngth, free);
	}
	out << count << endl;

	return 0;
}
#endif

Measured memory_bytes: 512
A,B,K=map(int,input().split())

if A>=1:
    if K>=A:
        K=K-A
        if K>=B:
            B=0
            print('0 0')
        elif K<B:
            B=B-K
            print('0 '+str(B))
    elif K<A:
        A=A-K
        print(str(A)+' '+str(B))
else:
    if K>=B:
        print('0 0')
    else:
        print('0 '+str(B-K))


Measured memory_bytes: 3060
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll h,w;cin>>h>>w;
    if(h==1||w==1){
        cout<<1<<endl;
        return 0;
    }
    if(h%2==0){
        cout<<h/2*w<<endl;
    }
    else if(w%2==0){
        cout<<w/2*h<<endl;
    }
    else{
        ll a=h/2+1;
        ll b=w/2+1;
        cout<<a*b+(a-1)*(b-1)<<endl;
    }
    
    ll a,b,c;cin>>a>>b>>c;
    
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

using namespace std;
using P = pair<int, int>;

long long MOD = 1000000007;
long long dp[100005][4];

int main() {
	string S;
	cin >> S;

	int size = S.size();

	for (int i = 0; i < 100005; ++i)for (int j = 0; j < 3; ++j)dp[i][j] = 0;
	dp[0][0] = 1;

	for (int i = 0; i < size;++i) {
		switch (S[i]) {
		case 'A':
			dp[i + 1][1] = (dp[i][1] + dp[i][0]) % MOD;
			dp[i + 1][2] = dp[i][2];
			dp[i + 1][3] = dp[i][3];
			dp[i + 1][0] = dp[i][0];
			break;
		case 'B':
			dp[i + 1][1] = dp[i][1];
			dp[i + 1][2] = (dp[i][2] + dp[i][1]) % MOD;
			dp[i + 1][3] = dp[i][3];
			dp[i + 1][0] = dp[i][0];
			break;
		case 'C':
			dp[i + 1][1] = dp[i][1];
			dp[i + 1][2] = dp[i][2];
			dp[i + 1][3] = (dp[i][3] + dp[i][2]) % MOD; 
			dp[i + 1][0] = dp[i][0];
			break;
		case '?': 
			dp[i + 1][1] = (dp[i][1] * 3 + dp[i][0]) % MOD;
			dp[i + 1][2] = (dp[i][2] * 3 + dp[i][1]) % MOD;
			dp[i + 1][3] = (dp[i][3] * 3 + dp[i][2]) % MOD;
			dp[i + 1][0] = (dp[i][0] * 3) % MOD;
			break;
		}
	}

	cout << dp[size][3] << endl;
}


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

typedef long long int ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<ll, ll> Pair;
typedef vector<Pair> VP;

#define MOD 1000000007
#define times(n) rep(_idx, n)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n; i > 0; i--)
#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mk make_pair
#define out(x) cout << (x) << endl;
#define DU(x) cerr << #x << " = " << (x) << endl;
#define VEC(v, x) VI v; v.resize(x);
#define MAT(m, x, y) VVI m; m.resize(x); rep(i, x) m[i].resize(y);

template <typename _Ty>ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "[]";return ostr;}ostr << "[" << v.front();for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}ostr << "]";return ostr;}

int N;
string S;
int main() {
    cin >> N >> S;
    ll ans = 0;
    rep(i, 10) rep(j, 10) rep(k, 10) {
        int pos = 0;
        while(pos < N && S[pos] - '0' != i) pos++;
        if(S[pos] - '0' == i) pos++;
        while(pos < N && S[pos] - '0' != j) pos++;
        if(S[pos] - '0' == j) pos++;
        while(pos < N && S[pos] - '0' != k) pos++;
        if (pos < N) ans++;
    }
    out(ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int A, P;
	cin >> A >> P;

	cout << (A * 3 + P) / 2 << endl;
	return 0;
}



Measured memory_bytes: 764
from math import degrees, atan, pi


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

if x >= (a ** 2) * b / 2:
    t = 2 / (a ** 3) * (b * a ** 2 - x)
    theta = atan(t)
else:
    theta = pi / 2 - atan((2 * x) / (a * b ** 2))

print(degrees(theta))


Measured memory_bytes: 3060
// ref: https://atcoder.jp/contests/abc120/clarifications

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    uint A, B, K; cin >> A >> B >> K;
    uint i=1;
    uint cnt=1;
    vector<int> vDiv;
    for(; i<=min(A, B); ++i){
        if(A%i!=0 || B%i!=0){ continue; }
        vDiv.push_back( i );
        ++cnt;
    }
    cout << vDiv[vDiv.size()-K] << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long cnt = 0;
        for(int i = 1;i <= n/2;i++){
            if(n != 2*i)
                cnt++;
        }
        System.out.println(cnt);
    }
}

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

int main() {
  int i,x,y,z,tab;
  cin>>x>>y>>z;
  
  tab=x;
  x=y;
  y=tab;
  tab=x;
  x=z;
  z=tab;

  cout<<x<<" "<<y<<" "<<z;
  return 0;
}

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

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    cin >> n;
    while (n--)
    {
        int a;
        cin >> a;
        if (a & 1)
        {
            continue;
        }
        if (a % 3 && a % 5)
        {
            cout << "DENIED" << endl;
            return;
        }
    }
    cout << "APPROVED" << endl;
}

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


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

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(a == b && b == c){
		cout << "No";
	}else if(a != b && b != c && a != c){
		cout << "No";
	}else{
		cout << "Yes";
	}
	cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < b; i++)
int N;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> N;
    vector<ll> h(N);
    rep(i, 0, N) { cin >> h[i]; }
    bool flg = true;

    for(int i = N - 2; i >= 0; i--) {
        if(h[i] > h[i + 1]) {
            h[i]--;
        }
    }
    // rep(i, 0, N) { cout << h[i] << " "; }
    // cout << endl;
    rep(i, 0, N - 1) {
        if(h[i] > h[i + 1]) {
            flg = false;
        }
    }
    cout << (flg ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3932
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto x = RD;

	writeln(x^1);
	stdout.flush;
	debug readln;
}


Measured memory_bytes: 2712
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <math.h>
#include <stdio.h>
using namespace std;

int main() {
	int N;

	cin >> N;
	vector <int> x(N);
	vector <int> y(N);

	for (int i = 0; i < N; i++) {
		cin >> x.at(i) >> y.at(i);
	}

	double sum = 0;
	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++) {
			int distance = (x.at(i) - x.at(j)) * (x.at(i) - x.at(j)) + (y.at(i) - y.at(j)) * (y.at(i) - y.at(j));
			sum += sqrt(distance);
		}
	}

	sum *= 2;

	//cout << sum / N << endl;

	printf("%lf", sum / N);

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var cities = new List<City>();
            for (var i = 0; i < n[1]; i++)
            {
                var values = Console.ReadLine().Split(' ');
                cities.Add(new City{ Index = i, Pref = int.Parse(values[0]), Year = int.Parse(values[1]) });
            }

            foreach (var g in cities.GroupBy(x => x.Pref))
            {
                var i = 1;
                foreach (var c in g.OrderBy(x => x.Year))
                {

                    c.Code = c.Pref.ToString("D6") + i.ToString("D6");
                    i++;
                }
            }

            foreach (var c in cities.OrderBy(x => x.Index))
            {
                Console.WriteLine(c.Code);
            }

        }

        
    }

    class City
    {
        public int Index { get; set; }
        public string Code { get; set; }
        public int Pref { get; set; }
        public int Year { get; set; }
    }
}


Measured memory_bytes: 39928
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=305;
const int MOD=998244353;
int n,m;
int a[N];
long long f[N][N*N],g[N][N*N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]),m+=a[i];
	f[0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=m;j++)
		{
			f[i][j]=f[i-1][j]*2%MOD;
			if(j>=a[i]) f[i][j]=(f[i][j]+f[i-1][j-a[i]])%MOD;
		}
	long long ans=1;
	for(int i=1;i<=n;i++)
		ans=ans*3%MOD;
	for(int j=(m+1)/2;j<=m;j++)
		ans=(ans-f[n][j]*3%MOD+MOD)%MOD;
	if(m%2==0)
	{
		g[0][0]=1;
		for(int i=1;i<=n;i++)
			for(int j=0;j<=m;j++)
			{
				g[i][j]=g[i-1][j];
				if(j>=a[i]) g[i][j]=(g[i][j]+g[i-1][j-a[i]])%MOD;
			}
		ans=(ans+g[n][m/2]*3%MOD)%MOD;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 426588
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mod 1000000007
#define N 1001

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll r, d, x;
	cin >> r >> d >> x;
	ll k = x;
	for (int i = 0; i < 10; ++i)
	{
		k = r * k - d;
		cout << k << "\n"; 
	}
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LOCAL
#pragma region Macros
typedef long long ll;
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X; cin >> X;
    cout << (X>=30?"Yes":"No") << '\n';
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int n,h[25];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>h[i];
	int hi=0,ans=0;
	for(int i=1;i<=n;i++)
	{
		hi=max(hi,h[i]);
		if(h[i]>=hi)
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}


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

int main(){
    map<string,int> f;
    string s;
    int n,m;
    cin>>n;
    for(int i=0;i<n;i++){
      cin>>s;
      f[s]++;
    }
    cin>>m;
    for(int i=0;i<m;i++){
      cin>>s;
      f[s]--;
    }
    int ans=0;
    for(auto iter=f.begin();iter!=f.end();iter++){
      ans=max(ans,iter->second);
    }
    cout<<ans;
}


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

int a, b, c, e, f, g;

main(){
    for (int i = 0; i < 3; i++){
        cin >> a >> b >> c >> e >> f >> g;
        if (g < c){
            if (f > 0)f--, g += 60;
            else e--, f += 59, g += 60;
        }
        if (f < b)e--, f += 60;
        cout << (e - a) << " " << (f - b) << " " << (g - c) << endl;
    }
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
 
#define ll long long
#define ull unsigned long long
 
#define vi vector < int >
#define vll vector < ll >
#define vs vector < string >
 
#define pii pair < int, int >
#define pll pair < ll, ll >
 
#define pb push_back
 
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
 
using namespace std;
 
int main()
{
    fast;
 
    int n;
 
    cin >> n;
 
    int a[n + 5], xr = 0;
 
    for(int i = 0; i < n; i++) cin >> a[i], xr ^= a[i];
 
    for(int i = 0; i < n; i++) cout << (xr ^ a[i]) << ' ';
 
    cout << endl;
 
    return 0;
}

Measured memory_bytes: 4400
n=int(input())
a=list(map(int,input().split()))
M=10**9+7
cnt=[0]*n
ans=1
for i in range(n):
    if a[i]==0:
        cnt[a[i]]+=1
    else:
        ans*=(cnt[a[i]-1]-cnt[a[i]])
        cnt[a[i]]+=1
    ans%=M
for i in range(cnt[0]):
    ans*=3-i
    ans%=M
print(ans)


Measured memory_bytes: 53868
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#define _m_ 1
const int INF = 1e9;

int cost[101][101];
int tim[101][101];
int d[101];
bool used[101];
int V;

void dijkstra(int s, int o){
	std::fill(d, d + V, INF);
	std::fill(used, used + V, false);
	d[s] = 0;
	while(_m_){
		int v = -1;
		for(int u = 0; u < V; ++u){
			if(!used[u] && (v == -1 || d[u] < d[v])) v = u;
		}
		if(v == -1)break;
		used[v] = true;
		if(o == 0){
			for(int u = 0; u < V; ++u){
				d[u] = std::min(d[u], d[v] + cost[v][u]);
			}
		}else {
			for(int u = 0; u < V; ++u){
				d[u] = std::min(d[u], d[v] + tim[v][u]);
			}
		}
	}
}

int main(){
	int n, m;
	while(scanf("%d %d",&n,&m), n+m){
		for(int i=0;i<m;++i){
			for(int j=0;j<m;++j){
				cost[i][j]=INF;
				tim[i][j]=INF;
			}
		}
		for(int i = 0; i < n; ++i){
			int a, b, co, ti;
			scanf("%d %d %d %d",&a, &b, &co, &ti);
			a--,b--;
			cost[a][b] = co, cost[b][a] = co;
			tim[a][b] = ti, tim[b][a] = ti;
		}
		V = m;
		int k;
		scanf("%d", &k);
		for(int i = 0; i < k; ++i){
			int p, q, r;
			scanf("%d %d %d", &p, &q, &r);
			p--, q--;
			dijkstra(p, r);
			printf("%d\n", d[q]);
		}
	}
}

Measured memory_bytes: 1268
#include<stdio.h>
#include<string.h>
int main(){
char s[103];
scanf("%s",s);
int l=strlen(s);
int count=0;
for(int i=0;i<l/2;i++){
    if(s[i]!=s[l-1-i])
    count++;
}
printf("%d",count);

}

Measured memory_bytes: 1724
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(readline())


def ints(): return list(map(int, readline().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, readline().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from math import gcd


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


N, K = ints()
print(N - K + 1)


Measured memory_bytes: 68336
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let k: i32 = read();
    let h: Vec<i32> = (0..n).map(|_| read()).collect();

    println!("{}", h.iter().filter(|&&x| x >= k).count());
}

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


Measured memory_bytes: 4352
import java.math.BigInteger;
import java.util.*;

public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int [] data = new int[n];
			for(int i = 0; i < n; i++){
				data[i] = sc.nextInt();
			}
			
			int count = 0;
			int prev = data[0];
			for(int i = 1; i < n; i++){
				if(data[i] == prev){
					prev = -1;
					count++;
				}
				else{
					prev = data[i];
				}
			}
			System.out.println(count);
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

}


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

int main() {
  string s;
  cin >> s;

  if (s[0] == s[1] && s[1] == s[2]) {
    cout << "Yes" << endl;
  } else if (s[1] == s[2] && s[2] == s[3]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

using ll = long long int;
using P = std::pair<int, int>;

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

int main()
{
    int a, b;

    std::cin >> a >> b;

    std::cout << a * b << std::endl;

    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#pragma GCC optimize(3)
#pragma GCC optimize(2)
#define max(a,b) a>b?a:b
#define min(a,b) a<b?a:b
using namespace std;
typedef long long ll;
const int N = 2e5+5;
const double eps = 1e-6;
const int INF = 1e9;

ll a[N],b[N];

struct node{
	int x,y;
	int dir;
}p[N];

bool cm1(node x1,node x2){
	if((x1.x-x1.y)==(x2.x-x2.y)) return x1.x<x2.x;
	else return (x1.x-x1.y)<(x2.x-x2.y);
}
bool cm2(node x1,node x2){
	if((x1.x+x1.y)==(x2.x+x2.y)) return x1.x<x2.x;
	else return (x1.x+x1.y)<(x2.x+x2.y);
}
bool cmp1(node x1,node x2){
	if(x1.x!=x2.x){
		return x1.x<x2.x;
	}else {
		return x1.y>x2.y;
	}
}
bool cmp2(node x1,node x2){
	if(x1.y!=x2.y){
		return x1.y>x2.y;
	}else {
		return x1.x<x2.x;
	}
}

map<char,int> mp;
map<pair<int,int> ,int> mpp1;
map<pair<int,int> ,int> mpp2;
map<pair<int,int> ,int> mpp3;
map<pair<int,int> ,int> mpp4;

inline void init(){
	mp['U'] = 1;
	mp['R'] = 2;
	mp['D'] = 3;
	mp['L'] = 4;
	return ;
}
	

int main() {
	int n;init();
	scanf("%d",&n);
	 
	for(int i=1;i<=n;i++){
		char c;
		cin>>p[i].x>>p[i].y>>c;
		p[i].dir = mp[c];
	}
	sort(p+1,p+1+n,cm1);
	
	int flag = 0;
	int ans = INF;
	for(int i=1;i<=n;i++){
		int dxy = p[i].x-p[i].y;
		if(p[i].dir==4&&mpp1[{dxy,1}]){
			flag = 1;
			ans = min(ans,abs(p[mpp1[{dxy,1}]].x-p[i].x)*10);
		}
		if(p[i].dir==3&&mpp1[{dxy,2}]){
			flag = 1;
			ans = min(ans,abs(p[mpp1[{dxy,2}]].x-p[i].x)*10);
		}
		mpp1[{p[i].x-p[i].y,p[i].dir}] = i;
	}
	
	sort(p+1,p+1+n,cm2); 
	for(int i=1;i<=n;i++){
		int dxy = p[i].x+p[i].y;
		if(p[i].dir==4&&mpp2[{dxy,3}]){
			flag = 1;
			ans = min(ans,abs(p[mpp2[{dxy,3}]].y-p[i].y)*10); 
		}
		if(p[i].dir==1&&mpp2[{dxy,2}]){
			flag = 1;
			ans = min(ans,abs(p[mpp2[{dxy,2}]].y-p[i].y)*10);
		}
		mpp2[{dxy,p[i].dir}] = i;
	}

	sort(p+1,p+1+n,cmp1);
	for(int i=1;i<=n;i++){
		if(p[i].dir==1&&mpp3[{p[i].x,3}]){
			flag = 1;
			ans = min(ans,abs(p[mpp3[{p[i].x,3}]].y-p[i].y)*5);
		}
		mpp3[{p[i].x,p[i].dir}] = i;
	}

	sort(p+1,p+1+n,cmp2);
	for(int i=1;i<=n;i++){
		if(p[i].dir==4&&mpp4[{p[i].y,2}]){
			flag = 1;
			ans = min(ans,abs(p[mpp4[{p[i].y,2}]].x-p[i].x)*5);
		}
		mpp4[{p[i].y,p[i].dir}] = i;
	}
	if(flag){
		cout<<ans<<endl;
		return 0;
	}
	cout << "SAFE\n";
    return 0;
}

Measured memory_bytes: 65092
#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 int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

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 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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n; cin>>n;
  vi a(n);
  rep(i,n) cin>>a[i];
  int ans=INF;
  for(int i=-100;i<=100;i++){
    int tmp=0;
    rep(j,n){
      tmp+=(a[j]-i)*(a[j]-i);
    }
    chmin(ans,tmp);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll k,a[100010],m=2,M=3;
    cin>>k;
    rep(i,k) cin>>a[i];
    reverse(a,a+k);
    if(a[0]!=2){
        cout<<-1<<endl;
        return 0;
    }
    rep2(i,1,k){
        if(M-m+1<a[i] && m%a[i]<M%a[i] && m%a[i]!=0){
            cout<<-1<<endl;
            return 0;
        }
        if(m%a[i]!=0){
            m=m+(a[i]-m%a[i]);
        }
        M=(M/a[i])*a[i]+(a[i]-1);
        // cout<<i<<" "<<m<<" "<<M<<endl;
    }
    cout<<m<<" "<<M<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()

const vector<int> pr={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};


int main(){
    int n,ans=0;
    cin>>n;
    map<int,int> mp;
    for(int i=2; i<=n; ++i){
       for(auto&v :pr){
           int a=i;
           while(a%v==0){
               mp[v]++;
               a/=v;
           }
       }
    }
    vector<int> cn(2,0);
    for(auto&v: mp){
        if(v.second>1 && v.second<4) cn[0]++;
        else if(v.second>=4) cn[1]++; 
    }
    ans+=cn[0]*cn[1]*(cn[1]-1)/2;
    ans+=(cn[1]*(cn[1]-1)*(cn[1]-2))/2;
    //cout<<ans<<endl;
    cn[0]=0; cn[1]=0;
    for(auto&v :mp){
        if(v.second>=2){
            if(v.second>=24) cn[0]++;
            else cn[1]++;
        }
    }
    ans+=cn[0]*cn[1];
    ans+=cn[0]*(cn[0]-1);
    //cout<<ans<<endl;
    cn[0]=0; cn[1]=0;
    for(auto&v: mp){
        if(v.second>=4){
            if(v.second>=14) cn[1]++;
            else cn[0]++;
        }
    }
    ans+=cn[0]*cn[1];
    ans+=cn[1]*(cn[1]-1);
    //cout<<ans<<endl;
    cn[0]=0; cn[1]=0;
    for(auto&v : mp){
        if(v.second>=74) cn[0]++;
    }
    ans+=cn[0];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline #文字列入力はするな！！
sys.setrecursionlimit(10**9) #再帰の上限をあげる
n=int(input())
a=list(map(int,input().split()))
z=[0]*(10**6+1)
ans=0
for i in a:
    z[i]+=1

x=[-1]*(10**6+1) #2以上の自然数に対して最小の素因数を表す
x[0]=0
x[1]=1
i=2
prime=[]
while i<=10**6:
    if x[i]==-1:
        x[i]=i
        prime.append(i)
    for j in prime:
        if i*j>10**6 or j>x[i]:break
        x[j*i]=j
    i+=1

for i in a:
    f=0
    u=i
    if z[u]>=2:
        f=1
    w=[]
    p=x[u]
    cnt=1
    while u>1:
        if p==x[u//p]:
            cnt+=1
            u=u//p
        else:
            w.append([p,cnt])
            cnt=1
            u=u//p
            p=x[u]

    m=len(w)
    y=1
    def s(d,h,y):
        global m
        global i
        global f
        if d==m-1:
            p=y*(w[d][0]**h)
            if p!=i and z[p]>=1:
                f=1
        else:
            y*=w[d][0]**h
            for j in range(w[d+1][1]+1):
                s(d+1,j,y)
    if m==0:
        if z[1]>=2:
            f=1
    else:
        for j in range(w[0][1]+1):
            s(0,j,1)
    if f==0:
        ans+=1
print(ans)




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

int main() {
    int N;
    cin >> N;
    vector<long> A(N), B(N);
    N %= 10;
    if (N == 3) cout << "bon" << endl;
    else if (N == 0 || N == 1 || N == 6 || N == 8) {
        cout << "pon" << endl;
    } else cout << "hon" << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>

using namespace std;

using P = pair<int, int>;
using i64 = int64_t;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;


int main(int argc, char **argv) {
    int n;
    cin >> n;
    double total{0.};
    for (int i=0; i<n; ++i) {
        int tmp;
        cin >> tmp;
        total += 1. / tmp;
    }

    cout << std::setprecision(10) << 1./total << endl;

    return 0;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
A = []
for i in range(h) :
    a = list(input())
    if '#' in a :
        A.append(a)
h = len(A)

l = [0]*w
for i in range(h) :
    for j in range(w) :
        if A[i][j] == '.' :
            l[j]+= 1

for i in range(w) :
    if l[i] == h :
        for j in range(h) :
            A[j][i] = 0

for i in range(h) :
    aa = [i for i in A[i] if i != 0]
    ans = ''.join(aa)
    print(ans)


Measured memory_bytes: 3188