akhauriyash/Code-Regression huggingface dataset:
class RollingHash:
    def __init__(self, s):
        b1, b2 = 1007, 2009
        mod1, mod2 = 10**9+7, 10**9+9
        self.size = len(s)
        self.string = s

        self.hash1 = self.make_hashtable(b1, mod1)
        self.hash2 = self.make_hashtable(b2, mod2)
        self.pow1 = self.make_powtable(b1, mod1)
        self.pow2 = self.make_powtable(b2, mod2)

    def make_hashtable(self, B, MOD):
        hashtable = [0] * (self.size+1)
        for i in range(1, self.size+1):
            hashtable[i] = (hashtable[i-1] * B + ord(self.string[i-1]))%MOD
        return hashtable
    
    def make_powtable(self, B, MOD):
        power = [0] * (self.size+1)
        power[0] = 1
        for i in range(1, self.size+1):
            power[i] = (B * power[i-1])%MOD
        return power

    def get_hash(self, l, length):
        r = length+l-1
        l -= 1
        mod1, mod2 = 10**9+7, 10**9+9
        h1 = (self.hash1[r]-self.hash1[l]*self.pow1[r-l])%mod1
        h2 = (self.hash2[r]-self.hash2[l]*self.pow2[r-l])%mod2
        return (h1, h2)

from collections import defaultdict

def solve1():
    N = int(input())
    S = input()
    size = len(S)
    hash_table = RollingHash(S)

    ans = 0
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if S[i-1]!=S[j-1]:continue

            left = 1
            right = min(j-i, size-j+1)+1

            while right-left>1:
                m = (left+right)//2
                if hash_table.get_hash(i, m)==hash_table.get_hash(j, m):
                    left = m
                else:
                    right = m
            ans = max(ans, left)

    print(ans)


def solve2():
    N = int(input())
    S = input()
    size = len(S)
    hash_table = RollingHash(S)

    def check(m):
        d = defaultdict(lambda :10**20)
        for i in range(1, size-m+2):
            h = hash_table.get_hash(i, m)
            d[h] = min(d[h], i)
            if (i-d[h])>=m:
                return True
        return False

    left, right = 0, size//2 + 1
    while right-left>1:
        m = (right+left)//2
        if check(m):
            left = m
        else:
            right = m

    print(left)

if __name__ == "__main__":
    # solve1()
    solve2()



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

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

const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const ll Inf = 1LL << 62;

int main() {
#ifdef Mr_Emrul
	freopen("inputf.in", "r", stdin);
#endif /// Mr_Emrul

	long double n, x, sum = 0;
	cin >> n;
	while(n--) {
		cin >> x;
		sum += (1 / x);
	}
	cout << setprecision(12) << 1 / sum << fixed << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    n = input()
    a = list(map(int, input().split()))
    flg = True
    for i in a:
        if i % 2 == 0:
            if i % 3 == 0 or i % 5 == 0:
                pass
            else:
                flg = False
                break

    if flg:
        print('APPROVED')
    else:
        print('DENIED')


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
  int n;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i <= n; i++)
  {
    if(!(i%5==0||i%3==0)){
      ans += i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(void){
  int a, b;
  cin >> a >> b;

  if(a > b) cout << "a > b" << endl;
  else if(a < b) cout << "a < b" << endl;
  else cout << "a == b" << endl;

  return 0;
}

Measured memory_bytes: 1160
def mi():return map(str,input().split())
from decimal import *

a,b,c=mi()
getcontext().prec=1500
a=Decimal(a)**Decimal("0.50")
b=Decimal(b)**Decimal("0.50")
c=Decimal(c)**Decimal("0.50")

if c>a+b:
    print("Yes")
else:
    print("No")




Measured memory_bytes: 5076
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

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


int main(){
    int N, K;
    string S;
    cin >> N >> K >> S;

    S[K-1] = S[K-1] - ('A'-'a');

    cout << S << endl;


}



Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
	int i,j,n,save=0,a[200]={0},b[200]={0},c[200]={0};
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i]>>b[i]>>c[i];
	}
	for(i=0;i<n;i++){
		save=a[i];
		for(j=i+1;j<n;j++){
			if(save==a[j]){
				a[i]=0;
				a[j]=0;
			}
		}
	}
	save=0;
	for(i=0;i<n;i++){
		save=b[i];
		for(j=i+1;j<n;j++){
			if(save==b[j]){
				b[i]=0;
				b[j]=0;
			}
		}
	}
	save=0;
	for(i=0;i<n;i++){
		save=c[i];
		for(j=i+1;j<n;j++){
			if(save==c[j]){
				c[i]=0;
				c[j]=0;
			}
		}
	}
	int sum=0;
	/*cout<<"\n";
	for(i=0;i<n;i++){
		cout<<"a[i]="<<a[i]<<" "<<"b[i]="<<b[i]<<" "<<"c[i]="<<c[i]<<endl;
	}*////debug
	for(i=0;i<n;i++){
		sum=a[i]+b[i]+c[i];
		cout<<sum<<endl;
	}
	return 0;
}
//Complete sourse!


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if((x >= r) && (y >= r) && (W-x >= r) && (H-y >= r)) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3120
n = int(input())
a = [list(map(int, input().split())) for _ in range(2)]

ans = 0
for i in range(n):
    tmp_ans = 0
    for j in range(n):
        if j < i:
            tmp_ans += a[0][j]
        elif j == i:
            tmp_ans += a[0][j] + a[1][j]
        else:
            tmp_ans += a[1][j]

    ans = max(ans, tmp_ans)

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define for_int(i,a,b) for(int i=(a);i<=(b);++i)
#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)
#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)
#define ull unsigned long long
#define ll long long
#define db double
#define HPMAX 1005
#define KMP_MAX 1005
#define prime_MAX 1e6+5
#define quick_pow_mod 1e9+7
#define PII pair<int,int>
const int factor_N = 1e7 + 5;
const int tree_arr_N = 1e6 + 5;
using namespace std;
//快读
int read() {
	char c = getchar();
	int x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-') f = -1;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
	return x * f;
}
int n;
db d, x, y;
int ans;
int main() {
	n = read();
	cin >> d;
	while (n--) {
		cin >> x >> y;
		db dis = sqrt(x * x + y * y);
		if (d >= dis) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
	int N,K;
	cin >> N >> K;
	vector<int> h(N);
	rep(i,N){cin >> h[i];}
	sort(h.begin(),h.end());
	ll D;
	ll ans = 1e18;
	for(int i=0; i<N-K+1; i++){
		D = h[i+K-1] - h[i];
		ans = min(ans, D);
	}
	

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main() {
	int n, m;
	while (cin >> n >> m, n) {
		int a[1010],ma = -1;
		for (int i = 0; i < n; i++) cin >> a[i];
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (a[i] + a[j] <= m) ma = max(ma,a[i] + a[j]);
			}
		}
		if (ma < 0) cout << "NONE" << endl;
		else cout << ma << endl;
	}
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int A;
    cin >> A;
    N -= A;
  }
  int ans = N < 0 ? -1 : N;
  cout << ans << endl;
  return 0;
}


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

int lcs(string x,string y,int n,int m,string& s)
{
    int dp[n+1][m+1];
    for(int i=0; i<n+1; i++)
    {
        for(int j=0; j<m+1; j++)
        {
            if(i==0||j==0)
                dp[i][j]=0;
            else
            {
                if(x[i-1]==y[j-1])
                    dp[i][j]=1+dp[i-1][j-1];
                else
                    dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    int i=n,j=m;
    while(i>0&&j>0)
    {
        if(x[i-1]==y[j-1])
        {
            s.push_back(x[i-1]);
            i--;
            j--;
        }
        else
        {
            if(dp[i-1][j]>dp[i][j-1])
                i--;
            else
                j--;
        }
    }
    reverse(s.begin(),s.end());
    return dp[n][m];
}

int main()
{
    string x,y;
    cin>>x>>y;
    string s;
    int l=lcs(x,y,x.length(),y.length(),s);
    cout<<s;
}

Measured memory_bytes: 38552
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b,c,d=0,r=0,p=0;
  cin>>a>>b>>c;
  p=a;
  for(int i=c;i>=p;r++){
    d=b+d;
   p=a*(2+r);
  }
  cout<<d<<"\n";
}


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

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++){
      string s;
      cin >> s;
      if (s == "Y") {
          cout << "Four" << endl;
          return 0;
      }
  }

  cout << "Three" << endl;
  return 0;

}


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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define itrout(x) for(int i=0;i<x.size();i++) {cout << x[i] << (i==x.size()-1 ? "\n" : " ");}
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long N, std::vector<long long> x, std::vector<long long> y, std::vector<long long> h){
    rep(cx, 0,101) rep(cy,0,101) {
        bool valid = true;
        ll H = -1;
        rep(i,0,N) {
            if (h[i] != 0) {
                H = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
                break;
            }
        }
        if (H == -1) continue;
        rep(i,0,N) {
            if (max<ll>(H - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i]) {
                valid = false;
                break;
            }
        }
        if (valid) {
            vector<ll> answer = {cx, cy, H};
            itrout(answer)
            return;
        }
    }
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    std::vector<long long> h(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
        scanf("%lld",&h[i]);
    }
    solve(N, std::move(x), std::move(y), std::move(h));
    return 0;
}


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

using namespace std;

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

  if (S.size() > L) {
    cout << S.substr(0, L) << "..." << endl;
  } else {
    cout << S << endl;
  }

  return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main(void){
	int a,b,c;
	cin >> a >> b >> c;

	int ans=0;

	rep(loop,100){
		if(a&1 or b&1 or c&1) break;
		ans++;

		int na = b/2 + c/2;
		int nb = c/2 + a/2;
		int nc = a/2 + b/2;

		a = na, b = nb, c = nc;
	}


	if(ans == 100) ans = -1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int r=0 ;
int D=0 ;
int x=0;
int y=0;
int i=1;
scanf("%d %d %d",&r,&D,&x);
for(i=1;i<11;i++){

    y = r*x - D;
    x=y;
    printf("%d\n",y);

}
return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
 
int main(){
 
  LL N, K, kukan, ans;
  cin >> N >> K;
  LL a[N + 10] = {};
  
 for(LL i = 0;i < N;i++){
   cin >> a[i];
 } 
  
  ans = 300000010;

 if(N != K){  
 for(LL i = 0;i <= N - K;i++){
 if(((a[i] < 0) && (a[i + K - 1] > 0)) || ((a[i] > 0) && (a[i + K - 1] < 0))){
   kukan = min(abs(a[i]), abs(a[i + K - 1])) + abs(a[i + K - 1] - a[i]);
   ans = min(ans, kukan);
 }
 else if(((a[i] < 0) && (a[i + K - 1] < 0))){
 kukan = abs(a[i]);
   ans = min(ans, kukan);
 } 
 else{
 kukan = a[i + K - 1];
   ans = min(ans, kukan);
 } 
 }
 }

  else{
    if((a[0] < 0) && (a[N - 1] < 0)) ans = abs(a[0]);
    else if((a[0] > 0) && (a[N - 1] > 0)) ans = a[N - 1];
    else ans = min(abs(a[0]), abs(a[N - 1])) + abs(a[N - 1] - a[0]);
  }
  
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i=s;i<n;++i)
#define drep(i,s,n) for (int i=n;i>=s;--i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;

int gcd(int a,int b)
{if (a%b == 0) return(b);
 else          return(gcd(b,a%b));}
int lcm(int a,int b)
{return a*b/gcd(a,b);}
void printv(vector<auto> v) {cout<<'[';rep(i,0,v.size()){cout<<v[i]<<',';}cout<<']'<<endl;}
void printvv(vector<vector<auto>> vv)
{
  cout<<'['<<endl;
  rep(q,0,vv.size()){cout<<'[';rep(p,0,vv.at(q).size())cout<<vv.at(q).at(p)<<',';cout <<']'<<endl;}
  cout<<']'<<endl;
}
void solve(); int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}
int step_x[] = {-1,0,0,1};
int step_y[] = {0,-1,1,0};
ll INF=10e12;
//------------------------------------------------------------
ll N,M;
void solve() {
  cin>>N>>M;

  vector<ll> H(N);
  rep(i,0,N) cin>>H[i];
  
  vector<ll> n(N, 0);

  rep(i,0,M)
  {
    ll A,B;
    cin>>A>>B;
    --A; --B;

    if(H[A]==H[B])
    {
      n[A]=-INF; n[B]=-INF;
      continue;
    }

    if(n[A]>=0) n[A] = H[A]-H[B];

    if(n[B]>=0) n[B] = H[B]-H[A];
  }

  ll count=0;

  rep(i,0,N) if(n[i]>=0) ++count;

  print(count);

  return;
}


Measured memory_bytes: 4780
#include<stdio.h>
#include<iostream>
#include<cmath>
using namespace std;

int N;
int a[110];
int main(){
    cin >> N;
    int sum = 0;
    for(int i=0; i<N; i++) {
        cin >> a[i];
        sum += a[i];
    }
    int x = 0,y = 0;
    for(int i=0; i<N; i++) {
        x += pow( sum / N + 1 - a[i],2);
        y += pow( sum / N - a[i] ,2);
    }
    int ans = min( x, y);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    final Scanner scanner = new Scanner(System.in);

    final Integer K = scanner.nextInt();
    final Integer N = scanner.nextInt();

    final List<Integer> As = new ArrayList<>();
    for (Integer i = 0; i < N; i++) {
      As.add(scanner.nextInt());
    }

    int max = K - (As.get(As.size() - 1) - As.get(0));
    for (int i = 0; i < As.size() - 1; i++) {
      final int diff = As.get(i + 1) - As.get(i);
      max = Math.max(diff, max);
    }
      System.out.println(K - max);
  }
}


Measured memory_bytes: 88204
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;

bool sorted(vector<int>& v) {
  for(int i = 0; i < v.size(); i++) {
    if(v[i] != i+1) return false;
  }
  return true;
}

void solve() {
  vector<int> v;
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) {
    int t;
    cin >> t;
    v.push_back(t);
  }
  bool ret = sorted(v);
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < i; j++) {
      swap(v[i], v[j]);
      ret |= sorted(v);
      swap(v[i], v[j]);
    }
  }
  if(ret) cout << "YES\n";
  else cout << "NO\n";
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 256
# 2019/06/29
# AtCoder Beginner Contest 132 - B

# Input
n = int(input())
p = list(map(int,input().split()))

cnt = 0
# Count
for i in range(1, n-1):
    if p[i] != max(p[i-1], p[i], p[i+1]) and p[i] != min(p[i-1], p[i], p[i+1]):
        cnt += 1

# Output
print(cnt)


Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

int main() {

	string s;
	cin >> s;

	int ans = 700;
	for (int i = 0; i < (int)s.size(); i++) if (s[i] == 'o') ans += 100;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;


class DICE {
	enum {
		Top,
		Front,
		Right,
		Left,
		Rear,
		Bottom
	};

	void Roll(const char*Directions) {
		for (int i = 0; Directions[i] != '\0'; i++) {
			Roll(Directions[i]);
		}
	}

	void Roll(const char Direction) {
		int tmpTop = Num[Top];

		switch (Direction) {
		case'E':
			Num[Top] = Num[Left];
			Num[Left] = Num[Bottom];
			Num[Bottom] = Num[Right];
			Num[Right] = Num[tmpTop];
			break;
		case'N':
			Num[Top] = Num[Front];
			Num[Front] = Num[Bottom];
			Num[Bottom] = Num[Rear];
			Num[Rear] = tmpTop;
			break;
		case'S':
			Num[Top] = Num[Rear];
			Num[Rear] = Num[Bottom];
			Num[Bottom] = Num[Front];
			Num[Front] = tmpTop;
			break;
		case'W':
			Num[Top] = Num[Right];
			Num[Right] = Num[Bottom];
			Num[Bottom] = Num[Left];
			Num[Left] = tmpTop;
			break;
		}
	}

	bool SameDiceDirectionFlag(DICE Dice) {
		for (int i = 0; i < 6; i++) {
			if (Num[i] != Dice.Num[i])return false;
		}
		return true;
	}

public:
	int Num[6];

	bool SameDiceNoneDirectionFlag(DICE Dice) {
		const char Directions[][3] = { "N","N","N","NW","WW","\0" };

		for (int i = 0; i < 6; i++) {
			if (Num[Top] == Dice.Num[Top]) {
				for (int j = 0; j < 4; j++) {
					if (SameDiceDirectionFlag(Dice))return true;

					int tmpFront = Dice.Num[Front];
					Dice.Num[Front] = Dice.Num[Right];
					Dice.Num[Right] = Dice.Num[Rear];
					Dice.Num[Rear] = Dice.Num[Left];
					Dice.Num[Left] = tmpFront;
				}
			}

			Dice.Roll(Directions[i]);
		}

		return false;
	}

};

int main() {
	DICE Dice1, Dice2;

	for (int j = 0; j < 6; j++) {
		cin >> Dice1.Num[j];
	}
	for (int j = 0; j < 6; j++) {
		cin >> Dice2.Num[j];
	}

	cout << (Dice1.SameDiceNoneDirectionFlag(Dice2) ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <set>
using namespace std;
set<int> s;
int n, a;
int main()
{
	scanf("%d", &n);
	while (n--)
	{
		scanf("%d", &a);
		if (s.count(a))
			s.erase(a);
		else
			s.insert(a);
	}
	printf("%d\n", s.size());
	return 0;
}

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

int main(){
  int N;
  cin>>N;
  int sum=0;
  int A;
  cin>>A;
  while(A%2==0){
    A/=2;
    sum++;
  }
  for(int i=0;i<N-1;i++){
    int B;
    cin>>B;
    int x=0;
     while(B%2==0){
    B/=2;
    x++;
     }
  if(x<sum){
    sum=x;
  }
  }
  cout<<sum<<endl;
}
  


Measured memory_bytes: 256
public class Main {


		public static void main(String[] args) {
		java.util.Scanner scan = new java.util.Scanner(System.in);
		int a, b, c, d, e;
		long f;
		a = scan.nextInt();
		d = -1000000;
		e = 1000000;
		f = 0;
		if(0 <= a && a <= 10000){
		for(b = 1; b <= a ; b++){
		
			c = scan.nextInt();
		 if(-1000000<=c && c <= 1000000){
			
			if(c >= d){
				d = c;
			}
			if(c <= e){
				e = c;
			}
			f += c;
		}
	
		}
		}
		
		System.out.print(e+" ");
		System.out.print(d+" ");
		System.out.println(f);
		}
		



		}

Measured memory_bytes: 42456
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    string s,t; cin >> s >> t;
    vi ms(26),mt(26);
    int ss=SIZE(s), st=SIZE(t);
    rep(i,ss) ms[s[i]-'a']++;
    rep(i,st) mt[t[i]-'a']++;
    sort(ms.rbegin(), ms.rend());
    sort(mt.rbegin(), mt.rend());
    if(ms == mt) yes();
    else no();
    return 0;
}


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

using namespace std;

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    
    bool swap = false;
    
    while (true)
    {
        int nEven = 0, nOdd = 0;
        int theOdd = -1;
        for (int i = 0; i < n; i++)
        {
            if (a[i] % 2 == 1)
            {
                nOdd++;
                theOdd = a[i];
            }
            else
                nEven++;
        }
        
        if (n % 2 != nOdd % 2)
        {
            // first wins, no need to do shit
            
            cout << (!swap ? "First" : "Second") << '\n';
            return 0;
        }
        else
        {
            // try swap
            if (nOdd == 1 && theOdd != 1)
            {
                int g = 0;
                for (int i = 0; i < n; i++)
                {
                    if (a[i] % 2 == 1)
                    {
                        a[i]--;
                    }
                    g = __gcd(g, a[i]);
                }
                
                for (int i = 0; i < n; i++)
                    a[i] /= g;
                
                swap = !swap;
            }
            else
            {
                cout << (!swap ? "Second" : "First") << '\n';
                return 0;
            }
        }
    }
    
    return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF 1000000000000000007

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

int a, b;

int main(){
	cin >> a >>b;
	
	if(a > 8 || b > 8){
		cout << ":(" << endl;
	}
	else cout << "Yay!" << endl;
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll a, b, k, i;
	cin >> a >> b >> k;

	for ( i = a ; i < a + k && i < b; i++ )
		cout << i << endl;	
	for ( i = i < b - k + 1 ? b - k + 1 : i ; i <= b ; i++ )
		cout << i << endl;	

	return 0;
}


Measured memory_bytes: 256
S = input()
n = S.count("N")
s = S.count("S")
w = S.count("W")
e = S.count("E")
if (n == s == 0 or (n > 0 and s > 0)) and (w == e == 0 or (w > 0 and e > 0)):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 8992
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int n = s[0];
            int m = s[1];
            int[] x = ReadLine().Split(' ').Select(int.Parse).ToArray();


            var ls = new List<int>();
            var sorted = x.OrderBy(hoge => hoge).ToArray();
            for (int i = 0; i < m - 1; i++)
            {
                ls.Add(sorted[i + 1] - sorted[i]);
            }

            ls.Sort();
            ls.Reverse();
            long ans = ls.Sum();

            if (n >= m){ WriteLine(0); return; }
            else
            for (int i = 0; i < n-1; i++)
            {
                ans -= ls[i];
            }
            WriteLine(ans);
        }

        

    }
}


Measured memory_bytes: 23648
#include <stdio.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;
void enqueue(P);
P dequeue(void);

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
  head=1;
  tail=n+1;
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  while(head!=tail){
    elaps+=q;
    u=dequeue();
    u.t-=q;
    if(u.t<=0){
      elaps+=u.t;
      printf("%s %d\n",u.name,elaps);
    }
    else enqueue(u);
  }
  return 0;
}
void enqueue(P u){
  Q[tail]=u;
  if(tail+1==LEN) tail=0;
  else tail++;
}
P dequeue(void){
  P x;
  x=Q[head];
  if(head+1==LEN) head=0;
  else head++;
  return x;
}



Measured memory_bytes: 12012
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,a;
    cin>>n>>a;
    ll b[60];
    for(int i=1;i<=n;i++)
    {
        cin>>b[i];
    }
    ll dp[5000][5000];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=i-1;j>=0;j--)
        {
            for(int k=0;k<=2500;k++)
            {
                dp[j+1][k+b[i]]+=dp[j][k];
            }
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        ans+=dp[i][a*i];
    }
    cout<<ans;
    return 0;
}







Measured memory_bytes: 198960
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define EPS 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f3f3f3f3f
#define MEM(a, b) memset(a, b, sizeof(a))
#define PPER(i, n, m) for (int i = n; i >= m; i--)
#define REPP(i, n, m) for (int i = n; i <= m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define PER(i, n, m) for (int i = n; i > m; i--)
#define SA(n) scanf("%d", &(n))
#define SLLA(n) scanf("%lld", &(n))
#define MP make_pair
#define FF first
#define SS second
#define PB push_back
#define DE(val) cout << #val << ": " << val << endl;
 
const int dx44[6] = {0, -1, -1, 1, 1};
const int dy44[6] = {0, -1, 1, -1, 1};
const int dx4[6] = {0, 0, 1,-1};
const int dy4[6] = {1, -1, 0,0};
const int dx8[9] = {0, -1, 0, 1, 0, 1, 1, -1, -1};
const int dy8[9] = {0, 0, 1, 0, -1, 1, -1, 1, -1};
const int dx82[9] = {0, -1, -1, 1, 1, 2, 2, -2, -2};
const int dy82[9] = {0, 2, -2, 2, -2, 1, -1, 1, -1};

void update(ll& x,ll v){
    if(x==-1)x=v;
    else if(x>v)x=v;
}
 
ll po(ll a, ll b, ll mod)
{
    ll res = 1;
    a %= mod;
    for (; b; b >>= 1)
    {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
ll gcd(ll a, ll b)
{
    if (a == 0)
    {
        return b;
    }
    else
    {
        return gcd(b % a, a);
    }
}
void extgcd(ll a, ll b, ll &d, ll &x, ll &y)
{
    if (!b)
    {
        d = a;
        x = 1;
    }
    else
    {
        extgcd(b, a % b, d, y, x);
        y -= x * (a / b);
    }
}
ll inverse(ll a, ll n)
{
    ll d, x, y;
    extgcd(a, n, d, x, y);
    return d == 1 ? (x + n) % n : -1;
}
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const int maxn = 2e5 + 15;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
#define mst(x, a) memset(x, a, sizeof(x))
/*************************************************************************/

void solve() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int cnt = 0;
    while(a > 0 && c > 0) {
        if(cnt & 1) {
            a-=d;
        } else {
            c-=b;
        }
        cnt++;
    }
    if(a<=0) {
        puts("No");
    } else {
        puts("Yes");
    }
} 

int main()
{   
#ifndef ONLINE_JUDGE
    // freopen("i.txt", "r", stdin);
    // freopen("o.txt", "w", stdout);
#endif

    solve();
    // int t;
    // SA(t);
    // REPP(i,1,t) {
    //     printf("Case #%d: ", i);
    //     solve();
    // }
    return 0;
 
}
 

Measured memory_bytes: 3124
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>

using namespace std;
const int INF = 1001001001;
#define rep(i,n) for(int i=0;i<n;i++)
int W,H;
int map[110][110];
int done[110][110];
queue<pair<int,int> > q;



int main(){
	scanf("%d %d",&W,&H);
	rep(i,H)rep(j,W)scanf("%d",&map[i+1][j+1]);
	q.push(make_pair(0,0));
	int ans=0;
	while(!q.empty()){
		pair<int,int> a;
		a=q.front();
		q.pop();
		if(a.first>W+1||a.second>H+1||a.first<0||a.second<0)continue;
		if(map[a.second][a.first]==1){ans++;}
		done[a.second][a.first]++;
		if(done[a.second][a.first]>1){continue;}	
		if(map[a.second][a.first]==0){
			q.push(make_pair(a.first+1,a.second));
			q.push(make_pair(a.first-1,a.second));
			q.push(make_pair(a.first,a.second+1));
			q.push(make_pair(a.first,a.second-1));
			if(a.second%2==0){
				q.push(make_pair(a.first-1,a.second-1));
				q.push(make_pair(a.first-1,a.second+1));
			}else{
				q.push(make_pair(a.first+1,a.second-1));
				q.push(make_pair(a.first+1,a.second+1));
			}
		}

	}
	printf("%d\n",ans);
}

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

int main(){
  int a,b;
  cin >> a >> b;
  int tapN = 1;
  int tapD = 0;
  for(int i=1;i<30;i++){
    if(tapN >= b){
      break;
    }
    tapN += a - 1;
    tapD ++;    
  }
  cout << tapD << endl ;
}

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

const int kN = 2e5 + 5;

int n, k, a[kN];

int main() {
	scanf("%d%d", &k, &n);
	int ans = 0;
	for(int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
	}
	for(int i = 1; i < n; ++i)
		ans = std::max(ans, a[i + 1] - a[i]);
	ans = std::max(ans, k - a[n] + a[1]);
	printf("%d", k - ans);
	return 0;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

template <ll mod>
class modint
{
public:
    constexpr modint(ll value = 0) : _value(value >= 0 ? value % mod : (value % mod) + mod) {}

    constexpr modint operator+() const { return *this; }
    constexpr modint operator-() const { return modint(-_value); }

    constexpr modint &operator+=(const modint &rhs) {
        if ((_value += rhs._value) >= mod) _value -= mod;
        return *this;
    }
    constexpr modint &operator-=(const modint &rhs) {
        if ((_value += mod - rhs._value) >= mod) _value -= mod;
        return *this;
    }
    constexpr modint &operator*=(const modint &rhs) {
        (_value *= rhs._value) %= mod;
        return *this;
    }
    constexpr modint &operator/=(const modint &rhs) {
        *this *= rhs.inv();
        return *this;
    }
    constexpr modint operator+(const modint &rhs) const { return modint(*this) += rhs; }
    constexpr modint operator-(const modint &rhs) const { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint &rhs) const { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint &rhs) const { return modint(*this) /= rhs; }

    constexpr modint operator++() { *this += 1; return *this; }
    constexpr modint operator--() { *this -= 1; return *this; }
    constexpr modint operator++(int) { modint tmp = *this; ++*this; return tmp; }
    constexpr modint operator--(int) { modint tmp = *this; --*this; return tmp; }

    constexpr bool operator==(const modint &rhs) const { return _value == rhs._value; }
    constexpr bool operator!=(const modint &rhs) const { return _value != rhs._value; }

    constexpr modint inv() const {
        ll a = _value, b = mod, u = 1LL, v = 0LL;
        while (b > 0) {
            ll tmp = a / b;
            a -= tmp * b; swap(a, b);
            u -= tmp * v; swap(u, v);
        }
        return modint(u);
    }

    constexpr modint pow(ll n) const {
        modint e = *this, res = 1;
        while (n) {
            if (n & 1) res *= e;
            e *= e, n >>= 1;
        }
        return res;
    }

    friend ostream &operator<<(ostream &os, const modint &m) {
        os << m._value;
        return os;
    }

    friend istream &operator>>(istream &is, modint &m) {
        ll in;
        is >> in;
        m = modint(in);
        return is;
    }

private:
    ll _value;
};
using mint = modint<1000000007>;

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

    int n, k; cin >> n >> k;

    vector<mint> dp(k + 1);
    for (int i = k; i > 0; i--) {
        dp[i] = mint(k / i).pow(n);
        for (int j = 2; i * j <= k; j++) {
            dp[i] -= dp[i * j];
        }
    }
    mint ans = 0;
    for (int i = 1; i <= k; i++) {
        ans += dp[i] * i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3940
// Created by ...
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // long long t;
    string t;
    long long sum=0;
    cin>>t;
   	for (int i = 0; i <t.length(); ++i)
   	{
   		/* code */
   		sum+=(t[i]-'0');

   	}
   	if (sum%3==0)
   	{
   		puts("Yes");
   		/* code */
   	}
   	else
   		puts("No");
    return 0;
}

Measured memory_bytes: 3624
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = nextInt()
    val hh = listOfInt()

    var count = 0
    var max = 0

    for (i in 0..n-2) {
        if (hh[i] >= hh[i+1]) {
            count++
        } else {
            if (count > max) max = count
            count = 0
        }
    }

    if (count > max) max = count
    println(max)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 59384
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[105];
signed main(){
	int n,ans=1000;
	cin>>n;
	for(int i=1;i<=n;i++)
	    cin>>a[i];
	for(int i=1;i<=n-1;i++){
		int s=0;
		if(a[i]<a[i+1]) s=ans/a[i];
		ans+=(a[i+1]-a[i])*s;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3644
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    private static int fact(int n) { int ans=1; for(int i=2;i<=n;i++) ans*=i; return ans; }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        int n = in.nextInt();
        int a[] = new int[n];
        for(int i=0;i<n;i++){
            a[i] = in.nextInt();
        }
        int cost[] = new int[n];
        cost[1] = Math.abs(a[0]-a[1]);
        for(int i=2;i<n;i++){
            cost[i] = Math.min(cost[i-2]+Math.abs(a[i]-a[i-2]),cost[i-1]+Math.abs(a[i]-a[i-1]));
        }
        // for(int i:cost){
        //     out.print(i+" ");
        // }
        out.println(cost[n-1]);
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 33632
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,a,n) for(int i = (a);i < (n);i++)

bool lu,ru,ld,rd;
bool up,down;

void init(){
    lu = ru = false;
    ld = rd = true;

    up = false;
    down = true;
}

int go(string s){
    if(s == "lu"){
        lu = true;
        ld = false;
    }else if(s == "ru"){
        ru = true;
        rd = false;
    }else if(s == "ld"){
        ld = true;
        lu = false;
    }else if(s == "rd"){
        rd = true;
        ru = false;
    }

    //up
    if(!up && ru && lu){
        up = true;
        down = false;
        return 1;
    }

    //down
    if(!down && rd && ld){
        up = false;
        down = true;
        return 1;
    }

    return 0;
}

int main(){
    int n;
    string s;
    while(cin >> n,n){
        init();
        int ans = 0;
        rep(i,0,n){
            cin >> s;
            ans += go(s);
            // cout << s << ":" << ans << endl;
        }
        cout << ans << endl;
    }
}




Measured memory_bytes: 3152
import java.util.*;

public class Main{

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int N = s.length();
        String ans = "Yes";
        StringBuilder sb1 = new StringBuilder(s);
        if(!(s.equals(sb1.reverse().toString()))){
          ans = "No";
        }
      
        String str1 = s.substring(0,(N-1)/2);
        StringBuilder sb2 = new StringBuilder(str1);
        if(!(str1.equals(sb2.reverse().toString()))){
          ans = "No";
        }
      
        String str2 = s.substring((N+3)/2-1,N);
        StringBuilder sb3 = new StringBuilder(str2);
        if(!(str2.equals(sb3.reverse().toString()))){
          ans = "No";
        }
      
      System.out.println(ans);
      
	}

}

Measured memory_bytes: 35792
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	int N;
	char* s;
	scanf("%d", &N);
	s = (char *)malloc(sizeof(char) * N);
	scanf("%s", s);
	int i;
	int count = 0;
	for (i = 0; i < N; i++) {
		if (s[i] == 'R') {
			count++;
		}
	}
	if (count > N / 2) {
		printf("Yes");
	}
	else {
		printf("No");
	}
}

Measured memory_bytes: 128
def main():
    MOD = 10 ** 9 + 7
    n, k = map(int, input().split())
    a = list(range(n + 1))
    x = a.copy()
    y = a.copy()
    ans = 0
    for i in range(1, n+1):
        x[i] = a[i] + x[i-1]

    for i in range(n-1, -1, -1):
        y[i] = a[i] + y[i+1]

    for j in range(k-1, n+1):
        ans += y[-j-1] - x[j] + 1
    return ans%MOD


print(main())


Measured memory_bytes: 38044
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

const vector<string> p3 = {
    ".aa",
    "a..",
    "a.."
};
const vector<string> p4 = {
    "aacd",
    "bbcd",
    "dcbb",
    "dcaa"
};
//const vector<string> p5 = {
//    "aabaa",
//    "b.bcc",
//    "bac..",
//    ".ac.b",
//    "bbaab"
//};
const vector<string> p5 = {
    "aabba",
    "b.cca",
    "bc..b",
    "ac..b",
    "abbaa"
};
//const vector<string> p7 = {
//    "aabb..a",
//    ".cc.cca",
//    "a...abb",
//    "a..ba  ",
//    ".aab.aa",
//    "a..ab..",
//    "a..ab.."
//};
const vector<string> p7 = {
    ".aabbcc",
    "a.dd.dd",
    "ad..d..",
    "bd..d..",
    "b.dd.dd",
    "cd..d..",
    "cd..d.."
};

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

    if (N == 2) {
        write(-1);
        return 0;
    }

    vector<string> ans(N);
    rep(i, N) ans[i] = string(N, '.');

    if (N == 3) ans = p3;
    else if (N == 4) ans = p4;
    else if (N == 5) ans = p5;
    else if (N == 6) {
        rep(i, 3) rep(j, 3) {
            ans[i][j] = ans[3 + i][3 + j] = p3[i][j];
        }
    }
    else if (N == 7) ans = p7;
    else {
        int k4 = (N - 8) / 4;
        rep(k, k4) {
            rep(i, 4) rep(j, 4) {
                ans[4 * k + i][4 * k + j] = p4[i][j];
            }
        }
        int M = 4 * k4;

        if (N - M == 8) {
            rep(i, 4) rep(j, 4) {
                ans[M + i][M + j] = p4[i][j];
            }
            M += 4;
            rep(i, 4) rep(j, 4) {
                ans[M + i][M + j] = p4[i][j];
            }
        }
        else if (N - M == 9) {
            rep(i, 9) rep(j, 9) {
                ans[M + i][M + j] = p3[i % 3][j % 3];
            }
        }
        else if (N - M == 10) {
            rep(i, 5) rep(j, 5) {
                ans[M + i][M + j] = p5[i][j];
            }
            M += 5;
            rep(i, 5) rep(j, 5) {
                ans[M + i][M + j] = p5[i][j];
            }
        }
        else if (N - M == 11) {
            rep(i, 4) rep(j, 4) {
                ans[M + i][M + j] = p4[i][j];
            }
            M += 4;
            rep(i, 7) rep(j, 7) {
                ans[M + i][M + j] = p7[i][j];
            }
        }
    }

    rep(i, N) write(ans[i]);
}

Measured memory_bytes: 2304
#include <iostream>

using namespace std;

int main()
{
    int a,b,cb,cifb=0,c,p=1,ok=0,i;
    cin>>a>>b;
    cb=b;
    while(cb!=0)
    {
        cb/=10;
        cifb++;
    }
    for(i=1;i<=cifb;i++)
    {
        p*=10;
    }
    c=a*p+b;
    for(i=1;i*i<=c;i++)
    {
        if(i*i==c)
        {
            ok=1;
        }
    }
    if(ok==0)
    {
        cout<<"No";
    }
    else
        cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256