akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int X,Y;
int main()
{
	cin>>X>>Y;
	int sum=0;
	if(X<=3) sum+=3-X+1;
	if(Y<=3) sum+=3-Y+1;
	if(X==1&&Y==1) sum+=4;
	if(sum==0) cout<<"0"<<endl;
	else cout<<sum<<"00000"<<endl;
}

Measured memory_bytes: 256
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST            ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll              long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define all(a)          (a).begin(),(a).end()
#define clz(a)          __builtin_clz(a) // count leading zeroes
#define ctz(a)          __builtin_ctz(a) // count trailing zeroes
#define popc(a)         __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define rep(i,a,b)      for(int i=a;i<b;i++)
#define rfor(i,a,b)     for(int i=a; i>=b; i--)
#define debug(x)        cerr << #x << " = " << x << endl;
#define F               first
#define S               second
#define endl            '\n'
#define SIZE            1000005
#define deci(n)         cout<<fixed<<setprecision(n)
#define ordered_set     tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const ll lul2 = 998244353;
const ll lul = 1000000007;

void mod(ll &x)
{
    if(x>=lul) x-=lul;
    if(x<0) x+=lul;
}

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

ll expo(ll n, ll p)
{
    if(p == 0) return 1;
    ll x = expo((n*n)%lul, p/2)%lul;
    if(p&1) return (x*n)%lul;
    return x;
}
//---------------------------------------------------------------------

int ans = 0;
vector<ll> fact;
void factor(ll n)
{
    for(ll i=1; i*i<=n; i++)
    {
        if(n%i == 0)
        {
            if(n!=1) fact.pb(n/i);
            if(i!=1 and i*i!=n) fact.pb(i);
        }
    }
}
void compute(ll n)
{
    factor(n);
    for(auto i:fact)
    {
        ll val = n;
        while(val%i == 0) val/=i;
        if(val%i == 1) ans++;
    }
}
void solve()
{
    ll n; cin>>n;
    factor(n-1);
    ans+=(int)fact.size();
    fact.clear();
    compute(n);
    cout<<ans;
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    rep(i,1,t+1){
        solve();
    }
    return 0;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};
const ll MAX_N = 1e5;
ll N;
int main(){
   cin >> N;
   Vi a(3 * N);
   REP(i, 3 * N) cin >> a[i];

   RSORT(a);
   ll ans = 0;
   REP(i, N) ans += a[2 * i + 1];
   cout << ans << endl;
}


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

int main(){

    char C11, C12, C13;
    char C21, C22, C23;

    cin >> C11 >> C12 >> C13;
    cin >> C21 >> C22 >> C23;

    if(C11 == C23 && C12 == C22 && C13 == C21) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main()
{
  int R[MAX], n;

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

  int maxv = -2000000000; // 充分に小さい初期値を設定
  int minv = R[0];

  for (int i = 1; i < n; i++)
  {                                // ここで毎回R[i]を読み込めば、配列は不要
    maxv = max(maxv, R[i] - minv); // 最大値の更新
    minv = min(minv, R[i]);        // ここまでの最小値を保持しておく
  }

  cout << maxv << endl;

  return 0;
}


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

int main() {
  string s, t, u;
  int64_t a, b;
  cin >> s >> t >> a >> b >> u;

  if (s == u) a--;
  if (t == u) b--;
  cout << a << " " << b << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;
const int mod = 1000000007;

struct UnionFind
{
    vector<int> par;
    vector<int> s;
    
    UnionFind(int N) : par(N), s(N){
        rep(i, N) par[i] = i;
        rep(i, N) s[i] = 1;
    }
    
    int root(int x){
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] = ry;
        s[rx] += s[ry];
        s[ry] = s[rx];
    }
    
    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    
    int size(int x){
        int rx = root(x);
        return s[rx];
    }
};

int main(){
    int N, M; cin >> N >> M;
    UnionFind tree(N);
    rep(i, M){
        int a, b;
        cin >> a >> b;
        a--; b--;
        tree.unite(a, b);
    }
    int ans = 0;
    rep(i, N){
        ans = max(ans, tree.size(i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 11172
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  int h, w; cin >> h >> w;
  vector<string> v(h); rep(i, h) cin >> v[i];

  for (int hi = 0; hi < h; hi++) {
    for (int wi = 0; wi < w; wi++) {
      if (v[hi][wi] == '#') continue;

      int count = 0;
      for (int di = 0; di < 8; di++) {
        int nhi = hi + dy[di];
        int nwi = wi + dx[di];

        if (nhi >= 0 && nhi < h && nwi >= 0 && nwi < w && v[nhi][nwi] == '#') count++;
      }
      v[hi][wi] = (char)('0' + count);
    }
  }

  for (string vi : v) outl(vi);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 632
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];

    bool even = false;
    bool odd = false;
    rep(i, n){
        if((abs(x[i]) + abs(y[i])) % 2 == 0){
            even = true;
        }
        if((abs(x[i]) + abs(y[i])) % 2 == 1){
            odd = true;
        }
    }
    if(even && odd){
        cout << -1 << endl;
        return 0;
    }

    vector<int> d;
    for(int i = 32; i >= 0; i--){
        d.push_back(pow(2, i));
    }
    if(even){
        d.push_back(1);
    }

    int m = d.size();

    cout << m << endl;
    rep(i, m-1){
        cout << d[i] << " ";
    }
    cout << d[m-1] << endl;

    rep(i, n){
        vector<int> s = {x[i] + y[i], x[i] - y[i]};

        vector<vector<int>> dd(2, vector<int>(m));
        rep(i, 2){
            int dist = 0;
            rep(j, m){
                if(abs(dist + d[j] - s[i]) < abs(dist - d[j] - s[i])){
                    dist += d[j];
                    dd[i][j] = 0;
                }else{
                    dist -= d[j];
                    dd[i][j] = 1;
                }
            }
        }

        string ans = "";
        rep(j, m){
            if(dd[0][j] == 0 && dd[0][j] == dd[1][j]){
                ans.push_back('R');
            }
            if(dd[0][j] == 1 && dd[0][j] == dd[1][j]){
                ans.push_back('L');
            }
            if(dd[0][j] == 0 && dd[0][j] != dd[1][j]){
                ans.push_back('U');
            }
            if(dd[0][j] == 1 && dd[0][j] != dd[1][j]){
                ans.push_back('D');
            }
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<deque>
#include<set>
#include<map>
#include<string>
#include<math.h>

using namespace std;
#define ll long long
#define pb push_back
#define ld long double
#define mod 1000000007
ll cd(ll a,ll b)
{
	if(a==0)return b;
	else if (b==0)return a;
	else return cd(b,a%b);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	ll l[n+5];
	for(int i=0;i<n;i++)cin>>l[i];
	ll ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			for(int k=j+1;k<n;k++)
			{
				if(l[i]!=l[j]&&l[j]!=l[k]&&l[i]!=l[k])
				{
					if(l[i]+l[j]>l[k]&&l[j]+l[k]>l[i]&&l[k]+l[i]>l[j])ans++;
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3184
a, b = map(int, input().split())
ans = 0
if(a >= b):
    ans += (a - b + 1) / a

k = []
s = b - 1
while(s >= 1):
    k.append(int(s))
    s /= 2

cnt = len(k) - 1
m = min(a, b - 1)
for i in range(1, m + 1):
    if(i > k[cnt]):
        cnt -= 1
    ans += (1/a) * (1/2) ** (cnt + 1)

print(ans)



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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  string s;
  while(cin>>s,s!="#"){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    a--;b--;c--;d--;
    vector<string>str;
    string now="";
    for(int i=0;i<s.size();i++){
      if(s[i]=='/'){
	str.pb(now);
	now="";
      }else{
	now+=s[i];
      }
    }
    str.pb(now);
    vector<vector<char> >vvc(str.size());
    for(int i=0;i<str.size();i++){
      for(int j=0;j<str[i].size();j++){
	if(isdigit(str[i][j])){
	  for(int k='0';k<str[i][j];k++)
	    vvc[i].pb('.');
	}else{
	  vvc[i].pb('b');
	}
      }
    }
    vvc[a][b]='.';
    vvc[c][d]='b';
    // for(int i=0;i<vvc.size();i++){
    //   for(int j=0;j<vvc[i].size();j++)
    // 	cout<<vvc[i][j];
    //   cout<<endl;
    // }
    vector<string>ans;
    for(int i=0;i<vvc.size();i++){
      string str2="";
      int cnt=0;
      for(int j=0;j<vvc[i].size();j++){
	while(j<vvc[i].size()&&vvc[i][j]=='.'){
	  cnt++;
	  j++;
	}
	if(cnt>0)
	  str2+=(char)(cnt+'0');
	if(j!=vvc[i].size())
	  str2+=vvc[i][j];
      cnt=0;
      }
      ans.pb(str2);
    }

    for(int i=0;i<ans.size();i++){
      cout<<ans[i];
      if(i!=ans.size()-1)
	cout<<'/';
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 3120
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
int n, A, B , C;
int v[100];
int compute(int cnt , int a, int b , int c)
{
    if(cnt == n)
    {
        if (!a || !b || !c) return 999999999;
        return abs(a - A) + abs(b - B) + abs(c - C) - 30;
    }
    int rez0 = compute(cnt + 1, a , b , c);
    int rez1 = compute(cnt + 1 , a + v[cnt] , b , c) + 10;
    int rez2 = compute(cnt + 1 , a , b + v[cnt],  c) + 10;
    int rez3 = compute(cnt + 1 , a , b , c + v[cnt]) + 10;
    return min(rez0 , min(rez1 , min(rez2 , rez3)));
}
int main()
{
    scanf("%d%d%d%d" , &n , &A , &B , &C);
    for(int i = 0; i < n ; i ++)
    {
        scanf("%d" , &v[i]);
    }
    printf("%d" ,compute(0 , 0 , 0 , 0));
}


Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<iostream>
#include<cmath>
using namespace std;
int h,w,k;
char s[1330][1330];
int used[1330][1330];
int main()
{
	cin>>h>>w>>k;
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			cin>>s[i][j];
		}
	} 
	int ite=0;
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(s[i][j]=='#')
			{
				ite++;
				used[i][j]=ite;
				for(int k=j-1;k>=1;k--)
				{
					if(!used[i][k])
					{
						if(s[i][k]!='#')
						{
							used[i][k]=ite;
						}
						else
						{
							break;
						}
					}
					else
					{
						break;
					}
				}
				for(int k=j+1;k<=w;k++)
				{
					if(!used[i][k])
					{
						if(s[i][k]!='#')
						{
							used[i][k]=ite;
						}
						else
						{
							break;
						}
					}
					else
					{
						break;
					}
				}
			}
		}
	}
	for(int i=1;i<=h;i++)
	{
		if(i!=1)
		{
			if(!used[i][1])
			{
				for(int k=1;k<=w;k++)
				{
					used[i][k]=used[i-1][k];
				}
			}
		 } 
		if(i==1&&used[i][1]==0)
		{
			int j=i;
			while(!used[j][1])
			{
				j++;
			}
			for(int k=1;k<=w;k++)
			{
				used[i][k]=used[j][k];
			}
		}
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			printf("%d ",used[i][j]);
		}
		printf("\n");
	}
	return 0;
} 

Measured memory_bytes: 4352
#include<stdio.h>
#include<string.h>

int sum[101][101];
int num(int y1,int x1,int y2,int x2){
	int a,b,c,d;
	a=sum[y1-1][x1-1];
	b=sum[y1-1][x2];
	c=sum[y2][x1-1];
	d=sum[y2][x2];
	return d-c-b+a;
}

int main(){
	int n,w,h,s,t;
	int i,j,tmp,ans;
	while(scanf("%d",&n)==1&&n){
		scanf("%d%d",&w,&h);
		memset(sum,0,sizeof(sum));
		for(i=0;i<n;i++){
			int x,y;
			scanf("%d%d",&x,&y);
			sum[y][x]=1;
		}
		scanf("%d%d",&s,&t);
		for(i=1;i<=h;i++){
			for(j=1;j<=w;j++){
				sum[i][j] = sum[i][j]+sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
			}
		}
		ans=0;
		for(i=1;i+t-1<=h;i++){
			for(j=1;j+s-1<=w;j++){
				tmp = num(i,j,i+t-1,j+s-1);
				if(ans<tmp)ans=tmp;
			}
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 0
H, W = map(int, input().split())
c = []

for i in range(H):
    c.append([int(i) for i in input().split()])
dp = [[0 for i in range(W)] for i in range(H)]

maxwidth = 0

for i in range(H):
    for j in range(W):
        dp[i][j] = (c[i][j] + 1) % 2
        maxwidth |= dp[i][j]

for i in range(1, H):
    for j in range(1, W):
        if c[i][j]:
            continue
        else:
            dp[i][j] = min(dp[i-1][j], dp[i-1][j-1], dp[i][j-1]) + 1
            maxwidth = max(maxwidth, dp[i][j])

print(maxwidth**2)


Measured memory_bytes: 56456
use proconio::input;

fn main() {
    input! {
        n:i64,
        a:[i64; n],
    };

    let m = 1000000007;
    let mut cnt = vec![0; 60];

    let mut ans = 0;

    for v in &a {
        for i in 0..60 {
            if (v >> i) & 1 == 1 {
                cnt[i] += 1;
            }
        }
    }

    let mut x = n;
    for v in &a {
        for i in 0..60 {
            if (v >> i) & 1 == 1 {
                ans += (1 << i) % m * (x - cnt[i]) % m;
            }
            else {
                ans += (1 << i) % m * cnt[i] % m;
            }
            ans %= m;
        }
        for i in 0..60 {
            if (v >> i) & 1 == 1 {
                cnt[i] -= 1;
            }
        }
        x -= 1;
    }

    println!("{}", ans % m);
}

Measured memory_bytes: 9908
#include<stdio.h>

int main() {
	int len, min, div, cur;
	scanf("%d", &len);
	scanf("%d", &min);
	scanf("%d", &cur);
	div = cur - min;
	if (cur < min)min = cur;
	for (int i = 2; i < len; i++) {
		scanf("%d", &cur);
		if (cur - min > div) {
			div = cur - min;
		}
		if (cur < min) {
			min = cur;
		}
	}

	printf("%d\n", div);

	return 0;
}


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

using namespace std;

string s;
map <char, bool> mp;

int main () {
    cin >> s;
    for (auto c : s) mp[c]=1;
    if ((mp['N'] ^ mp['S'] == 0) && (mp['E'] ^ mp['W'] == 0)) cout << "Yes"; else cout << "No";
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use itertools_num::ItertoolsNum;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::iter;
#[allow(unused_imports)]
use superslice::*;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n = sc.read_chars();

    let mut sum = 0;
    for c in n.into_iter() {
        sum += c as u8 - '0' as u8;
        sum %= 9;
    }

    if sum % 9 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


Measured memory_bytes: 2348
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<ctime>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 1000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define P_TYPE int
typedef pair<P_TYPE, P_TYPE> P;
typedef pair<P, P_TYPE> PI;
typedef pair<P_TYPE, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

#define N 22
#define MOD 1000000007

int n;
int a[N][N], b[N];
int s[1<<N];

int main() {
  scanf("%d", &n);
  rep(i, n) rep(j, n) scanf("%d", &a[i][j]);
  int all = (1 << n);
  s[all-1] = 1;
  replr(k, 1, n) {
    int c = 0;
    rep(i, n) if(a[k-1][i]) b[c++] = i;
    int v = (1 << k) - 1;
    while(v < all) {
      int w = s[v];
      rep(i, c) if(v & (1 << b[i])) s[v ^ (1 << b[i])] += w, s[v ^ (1 << b[i])] %= MOD;
      int x = v & -v, y = v + x; v = ((v & ~y) / x >> 1) | y;
    }
  }
  printf("%d\n", s[0]);

  return 0;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i = a; i < b;i++)
#define pb push_back
typedef long long ll;
int mod = 1e9 + 7;

void add_self(int &a, int b)
{
    a += b;
    if(a >= mod) a-= mod;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string k;
    int d;
    cin >> k;
    cin >> d;
    int n = k.length();
    //n++;
    vector<vector<int>> dp (d, vector<int>(2));
    //memset(dp,0,sizeof(dp));
    //reverse(k.begin(), k.end());
    dp[0][0] = 1;
    //dp[0][0][1] = 1;

    fo(i,0,n)
    {
        vector<vector<int>> new_dp (d,vector<int>(2));
        fo(j,0,d)
        {
            for(bool l : {false, true})
            {
                fo(dig,0,10)
                {
                    if(dig > k[i]-'0' && !l) break;
                    add_self(new_dp[(j+dig)%d][l || (dig < k[i] - '0')], dp[j][l]);
                    //cout << dp[i][j][l] << endl;
                }
                //cout << dp[i][j][l] << endl;
            }
        }
        dp = new_dp;
    }

    int res = (dp[0][false] + dp[0][true]) % mod;
    --res;
    if(res == -1) res += mod;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
program main;
var
    i,j,k:integer;
    sum,n,m,haha:Int64;
begin
    readln(n,m);
    sum:=0;
    for i:=1 to m do begin
        read(haha);
        sum:=sum+haha;
    end;
    if (n-sum>=0) then writeln(n-sum) else writeln(-1);
end.

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

int main() {
    int A,B,num=0,i,a,b,c,d,e;
    
cin >> A >> B;
for ( i = A; i <= B; i++){
    a = i/10000;
    b = (i-a*10000)/1000;
    c = (i-a*10000-b*1000)/100;
    d = (i-a*10000-b*1000-c*100)/10;
    e = (i-a*10000-b*1000-c*100-d*10)/1;
 // cout << a << b << c<< d << e <<endl;
    if(a==e&&b==d)
num ++;
     }

cout << num <<endl;
return 0;
}


Measured memory_bytes: 256
S = list(input())
ans = 0
if len(S) % 2 == 0:
  for i in range(int(len(S)/2)):
    if S[i] != S[len(S)-1-i]:
      ans += 1
else:
  for i in range(int((len(S)-1)/2)):
    if S[i] != S[len(S)-1-i]:
      ans += 1

print(ans)

Measured memory_bytes: 3060
n, d = map(int, input().split())
X = []
for _ in range(n):
    X.append([int(x) for x in input().split()])
ans = 0
for i in range(n):
  for j in range(i):
    s = sum((X[i][k] - X[j][k])**2 for k in range(d))
    if (s ** .5).is_integer():
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int N, M;
  cin >> N >> M;
  vector<string> A;
  rep(i, N) {
    string ai;
    cin >> ai;
    A.pb(ai);
  }

  vector<string> B;
  rep(i, M) {
    string bi;
    cin >> bi;
    B.pb(bi);
  }

  
  // 合わせ位置の二重ループ
  bool isFound = false;
  repto (x, (N - M)) {
    if (isFound) break;

    repto (y, (N - M)) {
      bool isMatch = true;

      // 一つの画像の二重ループ
      rep (i, M) {
        if (!isMatch) break;
        rep (j, M) {
          if (A[x + i][y + j] != B[i][j]) {
            isMatch = false;
            break;
          } 
        }
      }

      if (isMatch) {
        isFound = true;
        break;
      }
    }
  }

  if(isFound) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

    int a, b, c, d, e, f; cin>>a>>b>>c>>d>>e>>f;

    double ma = -1;
    P ans;
    for(int i=0; i<=f; i+=100*a){
        for(int j=0; i+j<=f; j+=100*b){
            for(int k=0; i+j+k<=f; k+=c){
                for(int l=0; i+j+k+l<=f; l+=d){
                    if((i + j) / 100 * e < k + l) continue;

                    if(ma < 1. * (k + l) * 100 / (i + j + k + l)){
                        ma = 1. * (k + l) * 100 / (i + j + k + l);
                        ans = P(i + j + k + l, k + l);
                    }
                }
            }
        }
    }

    cout << ans.first << " " << ans.second << endl;

    return 0;
}

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

using namespace std;

int main() {
    int N, Q;
    string S;

    cin >> N >> Q;

    vector <int> l(Q);
    vector <int> r(Q);
    vector <int> t(N+1);
    //vector <int> result(Q);

    cin >> S;

    for(int i = 0; i < Q; i++) {
        cin >> l[i] >> r[i];
    }

    //cout << S.substr(0, 2) << endl;

    
    t[0] = 0;
    for(int i = 0; i < N; i ++) {
        int tmp = 0;

        if(S.substr(i, 2) == "AC") {
            tmp ++;
        } 

        t[i+1] = t[i] + tmp;
    }


    /*
    for(int i = 0; i < N; i++) {
        cout << t[i] << endl;
    }
    */

    for(int i = 0;i < Q; i++) {
        cout << t[r[i]-1] - t[l[i]-1] << endl;
    }
    
}

Measured memory_bytes: 2176
N,M=list(map(int,input().split()))

e_list = []
for i in range(M):
    a,b,c = list(map(int,input().split()))
    e_list.append([a-1,b-1,-c])

vi=0
min_dis_list = [10**27 for i in range(N)]
min_dis_list[vi] = 0
prev_list = [-1 for i in range(N)]

for i in range(N-1):
    for e in e_list:
        u,v,d = e
        if min_dis_list[v]>min_dis_list[u]+d:
            min_dis_list[v]=min_dis_list[u]+d
            prev_list[v]=u

neg_loop_flag=[False for i in range(N)]

for i in range(N):
    for e in e_list:
        u,v,d = e
        if min_dis_list[u] + d < min_dis_list[v]:
            neg_loop_flag[v]=True
            min_dis_list[v] = min_dis_list[u] + d
        if neg_loop_flag[u]:
            neg_loop_flag[v]=True
        
if neg_loop_flag[N-1]:
    print("inf")
else:
    print(-min_dis_list[N-1])

Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <climits>

using namespace std;

int main() {
  int k, n;
  cin >> k >> n;
  vector<int> vec(2*n);
  for (int i = 0; i < n; ++i) {
    cin >> vec[i];
    vec[i + n] = vec[i] + k;
  }

  int ans = INT_MAX;
  for (int i = 0; i < n; ++i)
    ans = min(ans, vec[i + n -1] - vec[i]);

  cout << ans << endl;
}

Measured memory_bytes: 1792
//#include<bits/stdc++.h>
#include<iostream>
#define pb push_back
#define pf push_front


using namespace std;	
typedef long long int lli;

lli n,k,l,m,t,a,b,r,c,temp1,temp2,x,y,temp,q,d,mod=1e9+7,w,p;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    
    if(s=="SSS")cout<<"0"<<endl;
    else if(s=="RRR")cout<<3<<endl;
    else if(s=="RRS"||s=="SRR")cout<<2<<endl;
    else cout<<1<<endl;
}

Measured memory_bytes: 3580
s = gets.chomp.split('')
odd = Hash.new(false)
odd['R'] = true
odd['U'] = true
odd['D'] = true

even = Hash.new(false)
even['L'] = true
even['U'] = true
even['D'] = true
result = true
s.each_with_index do |v, i|
  result = result && odd[v] if i % 2 == 0
  result = result && even[v] if i % 2 == 1
end
puts result ? 'Yes' : 'No'

Measured memory_bytes: 1788
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
char mt,s[100001];
int mark=1,ans=1000000000,a,b,p[100001];
int main(){
	scanf("%s",s);
	a=strlen(s);
	for(int i=0;i<a-1;i++){
		if(s[i]!=s[i+1]){
			mark=0;
			ans=min(ans,max(i+1,a-i-1));
		} 
	}
	if(mark) {
		printf("%d",a);
	}
	else printf("%d",ans);
	return 0;
}

Measured memory_bytes: 384
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n = int(input())
    s = input()

    res = s.count('R') * s.count('G') * s.count('B')
    if res == 0:
        print(0)
        sys.exit()
    for i1 in range(n):
        for i2 in range(i1+1, n):
            if i2 * 2 - i1 <= n - 1:
                if s[i1] != s[i2]:
                    res -= s[i1] != s[i2*2 - i1] and s[i2] != s[i2*2 - i1]
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9196
#include<cstdio>

long long a, b, c;

int main() {
  scanf("%lld %lld %lld", &a, &b, &c);
  if (c > a + b && (c - a - b)*(c - a - b) > 4*a*b) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}


Measured memory_bytes: 128
H = []
W = []

while True:
    h, w = map(int, input().split())
    if h == w and h == 0:
        break
    H.append(h)
    W.append(w)

for i in range(len(H)):
    for j in range(H[i]):
        if j == 0 or j == H[i] - 1:
            print('#' * W[i])
        else:
            print('#' + '.' * (W[i] - 2) + '#')
    print('')



Measured memory_bytes: 5624
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, S: str):

    c = S.count('RL')
    
    hap = 0
    for i in range(1,N):
        if(S[i-1] == S[i]):
            hap += 1
    print(min(hap+2*K, N-1))

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, K, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define ll long long int 
#define w(x) ll x;cin>>x; while(x--)
#define pb push_back
#define mp make_pair
using namespace std;
int main(){
#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll l,r,d,c=0,m=0;
	cin>>l>>r>>d;
	ll e=d;
	ll f=d;
	ll i=1;
	// if(l==r && r==d){
	// 	cout<<1;
	// 	return 0;
	// }
	while(e<r){
		e=d*i;
		i++;
		if(e<=r){
			c++;
		}
	}
	ll j=1;
	while(f<l){
		f=d*j;
		j++;
		if(f<l)
			m++;
	}
	cout<<c-m;


}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


int n, a[101010], b[101010];
int aa[101010], bb[101010];
int d[101010];
bool used[101010], used2[101010];

void dfs(int now){
	if(used[now]){
		return;
	}
	used[now] = 1;
	dfs(d[now]);
	return;
}

P p[101010];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		aa[i] = a[i];
	}
	for(int i = 0; i < n; i++){
		cin >> b[i];
		bb[i] = b[i];
		p[i] = P(b[i], a[i]);
	}
	sort(aa, aa+n);
	sort(bb, bb+n);
	sort(p, p+n);
	for(int i = 0; i < n; i++){
		if(aa[i] > bb[i]){
			cout << "No" << endl;
			return 0;
		}
	}
	for(int i = 0; i < n; i++){
		bb[i] = p[i].first;
		aa[i] = p[i].second;
	}
	bool ans = 0;
	for(int i = 0; i < n; i++){
		d[i] = (lower_bound(bb, bb+n, aa[i])) - bb;
	}
	
	dfs(0);
	for(int i = 0; i < n; i++){
		if(!used[i]) ans = 1;
	}
	
	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 3840
A, B, H, M = gets.chomp.split.map(&:to_i)

A_ANGLE = ((H + M / 60.0) / 12.0) * 2 * Math::PI
B_ANGLE = (M / 60.0) * 2 * Math::PI

DIFF_ANGLE = A_ANGLE - B_ANGLE
ANGLE = [DIFF_ANGLE, 2 * Math::PI - DIFF_ANGLE].min

ans = (A**2 + B**2 - 2 * A * B * Math.cos(ANGLE))**0.5
puts ans 

Measured memory_bytes: 14908
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
struct edge {
  int from, to, cost;
};

const int MAX_V = 2501;
const int MAX_E = 5001;
const int INF = 1 << 30;
edge es[MAX_E];
set<int> inf_list;

int d[MAX_V];
int V, E;

// bool shortest_path(int s) {
//   for (int i = 0; i < V; i++) d[i] = INF;
//   d[s] = 0;
//   int cnt = 0;
//   while (1) {
//     bool update = false;
//     for (int i = 0; i < E; i++) {
//       edge e = es[i];
//       if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
//         d[e.to] = d[e.from] + e.cost;
//         update = true;
//       }
//     }
//     if (!update) break;
//     cnt++;
//     if (cnt > MAX_V) {
//       return 0;
//     }
//   }
//   return 1;
// }
bool shortest_path(int s) {
  for (int i = 0; i < V; i++) d[i] = INF;
  d[s] = 0;
  int cnt = 0;
  bool ret = 0;
  while (1) {
    bool update = false;
    cnt++;
    for (int i = 0; i < E; i++) {
      edge e = es[i];
      if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
        d[e.to] = d[e.from] + e.cost;
        update = true;
        if (cnt >= MAX_V) {
          inf_list.insert(e.to);
        }
      }
    }
    if (!update) break;
    if (cnt >= MAX_V) {
      ret = 1;
    }
    if (cnt > 2 * MAX_V) {
      return ret;
    }
  }
  return ret;
}

int main() {
  int N, M, P;
  cin >> N >> M >> P;
  V = N;
  E = M;
  REP(i, 0, M) {
    int f, t, c;
    cin >> f >> t >> c;
    f--;
    t--;
    c -= P;
    es[i] = {f, t, -c};
  }
  shortest_path(0);
  if (inf_list.count(N - 1)) {
    cout << -1 << endl;
    return 0;
  }
  cout << max({0, -d[N - 1]}) << endl;
  // REP(i, 0, N) { cerr << -d[i] << endl; }

  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S = sc.next();
		int[] cnt = new int[N+1];
		for(int i = 0;i < N-1;i++) {
			cnt[i+1] = cnt[i] + (S.substring(i,i+2).equals("AC") ? 1 : 0);
		}
		for(int i = 0;i < Q;i++) {
			int L = sc.nextInt();
			int R = sc.nextInt();
			System.out.println(cnt[R-1]-cnt[L-1]);
		}
		sc.close();
	}
}


Measured memory_bytes: 72644
n = int(input())
lis = list(map(int,input().split()))
cou = 0
ans = 1
for i in range(n-1):
  r = lis[i+1]-lis[i]
  if r * cou < 0:
    ans += 1
    cou = 0
  elif r != 0:
    cou = r
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int i,c1=0,c2=0,c;
  string s;
  cin>>s;
  int n=s.length();
  for(i=0;i<n/2;i++)
  {
    if (s[i]!=s[n-1-i])
      c1++;
  }
  for(i=n/2;i<n;i++)
  {
    if (s[i]!=s[n-1-i])
      c2++;
  }
  if (c1<=c2)
    c=c1;
  else
    c=c2;
  cout<<c;
}

Measured memory_bytes: 256
import heapq

n, m = map(int, input().split())
*a, = map(int, input().split())

ans = []
for i in range(n):
    heapq.heappush(ans, -a[i])

for i in range(m):
    temp = -heapq.heappop(ans)
    heapq.heappush(ans, -(temp//2))

print(-sum(ans))

Measured memory_bytes: 14180
#include <iostream>

using namespace std;

int main()
{
    long long N ;
    long long sumini = 1;
    long long sumend = 26;
    long long a = 26;
    int math;
    cin >> N;
    for(int i = 0;i < 20; i++)
    {
        
        if(N >= sumini && N <=sumend)
        {
            math = i+1;
            break;
        }
        sumini = sumini + a;
        a = a*26;
        sumend = sumend + a;
    }
    int iBuf[math];
    N = N - (sumini -1);
    a = a/26;
    for(int j = 0; j < math; j++)
    {
        for(int k = 0;k < 26;k++)
        {
            if(N >= k*a && N <= (k+1)*a )
            {
                iBuf[j] = k+1;
                N = N - k*a;
                a = a/26;
                break;
            }
        }
        
    }
    string alhabet = "0abcdefghijklmnopqrstuvwxyz";
    string ans(math,'a');
    for(int m = 0; m < math; m++)
    {
        ans[m] = alhabet[iBuf[m]];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
 
long long n, a[200010], ans = 0;
int main() {
	scanf("%lld", &n);
	for(int i = 0; i < n; i++) scanf("%lld", &a[i]);
	if(a[0]) return !printf("-1");
	a[n] = a[n-1];
	for(int i = 1; i <= n; i++) {
		if(a[i] - a[i-1] > 1) return !printf("-1");
		if(a[i] <= a[i-1]) ans += a[i-1];
	}
	printf("%lld", ans);
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int num=0;
    int a[n+1]={0};
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]%2!=0&&i%2!=0)
            num++;
    }
    cout<<num<<endl;
}


Measured memory_bytes: 3660
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

typedef long long ll;

int N;
ll a[200000 + 10], b[200000 + 10];
vector<ll> amod[30], bmod[30];

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

	for (int k = 1; k <= 30; k++) {
		amod[k - 1].resize(N), bmod[k - 1].resize(N);
		ll bit = (1LL << k);
		for (int i = 0; i < N; i++) {
			amod[k - 1][i] = a[i] % bit;
			bmod[k - 1][i] = b[i] % bit;
		}
	}

	ll ans = 0;

	for (int i = 0; i < 30; i++) {
		sort(bmod[i].begin(), bmod[i].end());
	}

	
	for (int k = 0; k <= 29; k++) {
		ll cnt1 = 0;
		for (int i = 0; i < N; i++) {
			//[2^k, 2 * 2^k)
			cnt1 += (lower_bound(bmod[k].begin(), bmod[k].end(), ((1LL << k) * 2) - amod[k][i]) - 
				lower_bound(bmod[k].begin(), bmod[k].end(), (1LL << k) - amod[k][i]));
			
			//[3 * 2^k, 4 * 2^k)

			cnt1 += (lower_bound(bmod[k].begin(), bmod[k].end(), ((1LL << k) * 4) - amod[k][i]) -
				lower_bound(bmod[k].begin(), bmod[k].end(), ((1LL << k) * 3) - amod[k][i]));
		}
		if (cnt1 & 1) {
			ans += (1LL << k);
		}
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 97152
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>
#include <cctype>

#define MAX_SIZE 100000000
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  vector<bool> table(26, false);
  string S; cin>>S;
  string ans = "yes";
  for(auto c : S) {
    int i = c - 'a';
    if(table[i] == true) {
      ans = "no";
      break;
    }
    table[i] = true;
  }

  cout << ans << endl;
}


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

using namespace std;

int a, b, angle;
double c, area, length, height;
int main(){
    cin >> a >> b >> angle;
    area = 0.5 * a * b * sin(angle / 180.0 * M_PI);
    c = sqrt(a * a + b * b - 2.0 * a * b * cos(angle / 180.0 * M_PI));
    length = a + b + c;
    height = 2.0 * area / a;
    cout << fixed << setprecision(8) << area << endl;
    cout << fixed << setprecision(8) << length << endl;
    cout << fixed << setprecision(8) << height << endl;
    return 0;
}


Measured memory_bytes: 3668
let print_a_frame h w =
  let buf = Buffer.create 256 in
  let s1  = (String.make w '#') ^ "\n" in
  let s2  = "#" ^ (if w>2 then String.make (w-2) '.' else "") ^ "#\n" in
  let rec loop i =
    if i > h then Buffer.contents buf
    else if i=1 || i=h then (Buffer.add_string buf s1; loop (i+1))
    else (Buffer.add_string buf s2; loop (i+1))
  in print_endline (loop 1)
    

let () =
  let rec loop () =
    let line = read_line () in
    let h,w = Scanf.sscanf line "%d %d" (fun h w -> h,w) in
    if (h,w) = (0,0) then ()
    else loop (print_a_frame h w);
  in loop ()

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

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define mod (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vb vector<bool>
#define vs vector<string>
#define vii vector<vector<int>>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()

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

void print(bool f)
{
    cout << (f ? "Yes" : "No") << endl;
}

void Print(bool f)
{
    cout << (f ? "YES" : "NO") << endl;
}

vll ans(100000, -1);
ll n, m, cnt = 1;

void bfs(vllll path)
{
    queue<ll> q;
    q.push(0);
    vb pass(n, false);
    pass[0] = true;
    while (!q.empty())
    {
        ll x = q.front();
        q.pop();
        rep(i, 0, path[x].size())
        {
            ll sp = path[x][i];
            if (!pass[sp])
            {
                q.push(sp);
                pass[sp] = true;
                ans[sp] = x + 1;
                cnt++;
            }
        }
    }
}

int main(void)
{
    cin >> n >> m;
    ll a, b;
    vllll path(n, vll());
    rep(i, 0, m)
    {
        cin >> a >> b;
        a--, b--;
        path[a].push_back(b);
        path[b].push_back(a);
    }
    bfs(path);
    print(1);
    rep(i, 1, n) cout << ans[i] << endl;
}


Measured memory_bytes: 19532
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
const int N = 1000005;
using namespace std;
int n, a[N];
int main() {
	scanf("%d", &n);
	rep(i, 1, n) scanf("%d", &a[i]);
	int ans = 0, op;
	for (int i = 1, j; i <= n; i = j) {
		++ ans;
		for (j = i + 1; j <= n && a[j] == a[j - 1]; ) ++ j;
		if (j <= n) op = a[j] > a[j - 1];
		for ( ; j <= n && (op ? a[j] >= a[j - 1] : a[j] <= a[j - 1]); ) ++ j;
	}
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;
using ll = long long;

template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_V(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_M(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}

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

    int ans = 0;
    while(n){
        ans++;
        n /= k;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
S = input()

a = int(S[:2])
b = int(S[2:])

if (1 <= a <= 12) and (1 <= b <= 12) :
    print("AMBIGUOUS")
elif (1 <= a <= 12) :
    print("MMYY")
elif (1 <= b <= 12) :
    print("YYMM")
else:
    print("NA")
    

Measured memory_bytes: 3060
#ABC129 C
N, M = (int(_) for _ in input().split())
a = [0 for i in range(M)]
MOD = 10 ** 9 + 7
for i in range(M):
    a[i] = int(input())
a.append(0)
dp = [0 for i in range(N + 1)]
j = 0
for i in range(N + 1):    
    if i == a[j] and M != 0:
        j += 1
    elif i == 0:
        dp[i] = 1
    elif i == 1:
        dp[i] = 1
    else:
        dp[i] = dp[i - 1] + dp[i - 2]
print(dp[N] % MOD)

Measured memory_bytes: 460056
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    if(n%2!=0){
      System.out.println(0);
    }
    else{
      long a=0;
      long cur=5;
      while(cur<=n){
        a=a+(n/cur)/2;
        cur=cur*5;
      }
      System.out.println(a);
  } 
  }
}

Measured memory_bytes: 22612
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<sstream>
using namespace std;
int inf = 1e9;
int main(){
  int n, x;
  cin >> n >> x;
  int cnt = 0;
  int tmp = inf;
  for(int i=0; i<n; i++){
    int m; cin >> m;
    tmp = min(tmp, m);
    x -= m;
    cnt++;
  }

  cnt += (x / tmp);
  cout << cnt << endl;


  return 0;
}


Measured memory_bytes: 256