akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef unsigned long long ULL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

ULL a, b, x;
int main() {
    std::cin >> a >> b >> x;
    if(a) {
        std::cout << b/x - (a-1)/x << std::endl;
    } else {
        std::cout << b/x + 1 << std::endl;
    }
}

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

using namespace std;

using i64 = long long;

const i64 MOD = i64(1e9) + 7;
const i64 INF = i64(1e18) + 7;


void solve(i64 k){

    auto f = [&](i64 n){
        string s = to_string(n);
        i64 m = 1;
        __int128_t ans = 0;
        for(int i = 0; i < s.size() - 1; ++i){
            i64 fizz_cnt = ((m * 10 - 1) / 3) - ((m - 1) / 3);
            i64 buzz_cnt = ((m * 10 - 1) / 5) - ((m - 1) / 5);
            i64 fizzbuzz_cnt = ((m * 10 - 1) / 15) - ((m - 1) / 15);
            ans += (m * 10 - m - fizz_cnt - buzz_cnt + fizzbuzz_cnt) * (i + 1);
            ans += fizz_cnt * 4;
            ans += buzz_cnt * 4;
            m *= 10;
        }

        i64 fizz_cnt = (n / 3) - ((m - 1) / 3);
        i64 buzz_cnt = (n / 5) - ((m - 1) / 5);
        i64 fizzbuzz_cnt = (n / 15) - ((m - 1) / 15);
        ans += (n - (m - 1) - fizz_cnt - buzz_cnt + fizzbuzz_cnt) * s.size();
        ans += fizz_cnt * 4;
        ans += buzz_cnt * 4;
        return ans;
    };
    i64 ok = -1, ng = INF;
    while(ng - ok > 1){
        i64 mid = (ok + ng) / 2;
        (f(mid) >= k ? ng : ok) = mid;
    }

    int len = to_string(ng).size();
    if(ng % 15 == 0)
        len = 8;
    else if(ng % 5 == 0)
        len = 4;
    else if(ng % 3 == 0)
        len = 4;
    i64 prefix = len + (k - f(ng)) - 1;
    // i64 prefix = len - (k - f(ng)) - 1;
    // i64 prefix = k - f(ok);

    // cout << ng << " " << prefix << endl;

    int di = 20;
    for(i64 p = ng; di; ++p){
        string s = to_string(p);
        if(p % 15 == 0)
            s = "FizzBuzz";
        else if(p % 3 == 0)
            s = "Fizz";
        else if(p % 5 == 0)
            s = "Buzz";
        s = s.substr(prefix);
        prefix = 0;
        if(s.size() > di)
            s = s.substr(0, di);
        di -= s.size();
        cout << s;
    }
    cout << endl;
}

signed main(){
    i64 k;
    cin >> k;
    solve(k);
    /*
    for(int i = 1; i <= 40; ++i){
        cout << i << ": ";
        solve(i);
    }
    */
}



Measured memory_bytes: 3284
#include <stdio.h>
#define MAX(a,b) ((a > b) ? a : b)

int main ()
{
  int A,B,K,i,j,l;
  
  scanf("%d%d%d", &A,&B,&K);

  for(i = MAX(A,B) ; i >= 1 ; i-- ){

    if(A % i == 0 && B % i == 0){
      j++;
      if(j == K){
	l = i;
      }
    }
  }
  
  printf("%d\n", l);

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,i;
	cin>>a>>b;
	if(b+b>=a)
	{
	cout<<"0"<<endl;
	return 0;
}
	else
	{
	cout<<a-b-b<<endl;
	return 0;
}
 } 

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

int main(){
  int A,B,C,X;
  cin>>A>>B>>C>>X;
  
  int sum=0;
  
  for(int i=0;i<=A;i++){
    if(X-i*500>=0){
    for(int j=0;j<=B;j++){
      if(X-i*500-j*100>=0){
        for(int l=0;l<=C;l++){
          if((X-i*500-j*100-l*50)==0){
       sum++;
     }
    }
  }
  }
    }
  }
  cout<<sum<<endl;
}

    

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

//Coding below.
int main (){
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c >= 22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N,*as=$<.read.split.map(&:to_i)

as = as.map {|a|
  if a % 4 == 0
    2
  elsif a % 2 == 0
    1
  else
    0
  end
}

ret = N/2*2 <= as.inject(&:+)

puts (ret ? 'Yes' : 'No')



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

int main()
{
	int n, t, a, j, jh = 1000000;
	cin >> n >> t >> a;

	for (int i = 0; i < n; i++) {
		int h;
		cin >> h;

		if (abs((t - a) * 1000 - h * 6) < jh) {
			jh = abs((t - a) * 1000 - h * 6);
			j = i;
		}
	}

	cout << j + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{

	// #ifndef HAPHAZARD_CODE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("output.txt","w",stdout);
	// #endif

		string s1,s2;
		cin>>s1>>s2;
int k,count,temp=99999,l=s2.size();

		for(int i=0;i<s1.size()-s2.size()+1;i++)
		{ 
			count=0;k=0;
			for(int j=i;j<l+i;j++)
			{
				if(s1[j]!=s2[k]) count++;
				k++;
			}
			if(count<temp) temp=count;
		}

cout<<temp<<endl;

	return 0;
}



Measured memory_bytes: 3632
from math import sqrt

n = int(input())
ans = 0
divisor = [0 for _ in range(n+1)]
for k in range(1, n+1):
    i = 1
    while 1:
        divisor[k*i] += 1
        i += 1
        if k*i > n:
            break
for i in range(1, n+1):
    ans += i * divisor[i]
print(ans)


Measured memory_bytes: 219180
def solve():
    from sys import stdin
    f_i = stdin
    
    n = int(f_i.readline())
    A = f_i.readline().split()
    q = int(f_i.readline())
    for i in range(q):
        b, m, e = map(int, f_i.readline().split())
        x = A[b:m]
        y = A[m:e]
        A = A[:b] + y + x + A[e:]
    print(' '.join(A))

solve()


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

int main() {
    ll MAX_N = 100005;
    vector<ll> v(MAX_N);

    ll n; cin >> n;
    rep(i, n) {
        int x;
        cin >> x;
        v[x]++;
    }

    ll sum = 0;
    rep(i, MAX_N) {
        sum += v[i] * i;
    }

    ll q; cin >> q;
    rep(i, q) {
        int b, c;
        cin >> b >> c;
        sum += (c - b) * v[b];
        cout << sum << endl;
        v[c] += v[b];
        v[b] = 0;
    }
    return 0;
}

Measured memory_bytes: 3852
#include<bits/stdc++.h>
using namespace std;
main()
{
    deque<int> r,g,cl;
    int a,b,c,x,y,i,j,e;
    long long int sum=0,cnt=0;
    scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
    for(i=0;i<a;i++){
        scanf("%d",&e);
        r.push_back(e);
    }
    for(i=0;i<b;i++){
        scanf("%d",&e);
        g.push_back(e);
    }
    for(i=0;i<c;i++){
        scanf("%d",&e);
        cl.push_back(e);
    }
    sort(r.begin(),r.end());
    sort(g.begin(),g.end());
    sort(cl.begin(),cl.end());
    
    if(x<a){
        c=a-x;
        while(c--)
        r.pop_front();
        
    }
    else if(x>a){
        c=x-a;
        while(c--){
            sum+=cl.back();
            cl.pop_back();
        }
    }
    
    if(y<b){
        c=b-y;
        while(c--)
        g.pop_front();
        
    }
    else if(y>b){
        c=y-b;
        while(c--){
            sum+=cl.back();
            cl.pop_back();
        }
    }
    
    while(!cl.empty()){
        e=cl.back();
        if(r.front()<e&&r.front()<g.front())
        {
            r.pop_front();
            r.push_back(e);
            cl.pop_back();
        }
        else if(g.front()<e)
        {
            g.pop_front();
            g.push_back(e);
            cl.pop_back();
        }
        else break;
    }
    
    while(!r.empty()){
        sum+=r.back();
        r.pop_back();
    }
    while(!g.empty()){
        sum+=g.back();
        g.pop_back();
    }
    
    cout<<sum<<"\n";
}

Measured memory_bytes: 1536
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

int main() {
	string str;
	cin >> str;
	sort(str.begin(), str.end());
	bool ans =true;
	int i = 0;
	while (i < str.size()) {
		if (str[i] != str[i + 1])ans = false;
		i += 2;
	}
	if (ans)cout << "Yes" << endl;
	else cout << "No" << endl;


	}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,k;
vector<int> a(200005);
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	vector<int> s;
	vector<int> ord(n+1,-1);
	int v=1;
	int c,l;
	while(ord[v]==-1)
	{
		ord[v]=s.size();
		s.push_back(v);
		v=a[v-1];
	}
	c=s.size()-ord[v];
	l=ord[v];
	if(k<l)
	{
		cout<<s[k];
	}
	else
	{
		k-=l;
		k%=c;
		cout<<s[k+l];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 5796
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include <ctime>

using namespace std;
int main()
{

	

	string s; cin>>s; int max=0;
	for(int i=0; i<=(int)s.size()-1; ++i)
	{
		        int sum=0;
			    if(s[i]=='R'){
			    	int j=i;
			    	while(s[j]=='R')
			    	{
			    		sum++;
			    		j++;
			    	}
			    	if(sum>max) max=sum;

			    }

			}cout<<max<<endl;







  	return 0;
  }


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<ll> A(N);

    REP(i, N){
        cin >> A[i];
    }

    ll ans = gcd(A[0], A[1]);

    for(ll i=2; i<N; i++){
        ans = gcd(ans, A[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
//gauravsinghh
#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 ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define ffo(i, a, b) for(int i = a; i >= b; i--)
#define MAX 100005
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

bool comp(const pair < ll, ll >&a, const pair < ll, ll >&b){
    return ((a.ss < b.ss) || (a.ss == b.ss && a.ff < b.ff));
}

signed main(){ 
    IOS
    //io_set();
    ll n, k, l, r;
    cin >> n >> k;
    string s;
    cin >> s;
    ll a[n+1] = {0};
    rep(i, n){
        if(i-1 >= 0 && s[i] == 'C' && s[i-1] == 'A'){
            a[i+1] = a[i] + 1;
        }
        else{
            a[i+1] = a[i];
        }
    }
    rep(i, k){
        cin >> l >> r;
        cout << a[r] - a[l] << endl;
    }
    return 0;
}



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

int main(){
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  if(a + b <= 2 * c) cout << a * x + b * y << endl;
  else if(x > y){
    int ans1 = a * (x - y) + 2 * c * y;
    int ans2 = 2 * c * x;
    int ans = ans1 > ans2 ? ans2 : ans1;
    cout << ans << endl;
  }
  else{
    int ans1 = 2 * c * x + b * (y - x);
    int ans2 = 2 * c * y;
    int ans = ans1 > ans2 ? ans2 : ans1;
    cout << ans << endl;
  }
  return 0;
}

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

int main(){
  ll N,P=10,sum=0;cin >> N;
  if(N%2==1){
    cout << 0 << endl;
    return 0;
  }
  while(P<=N){
    sum += (N/P);
    P *= 5;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
import collections
from functools import lru_cache


def read():
    return input().strip()


def readInt():
    return int(input().strip())


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


def solve(N, arr):
    l = 0
    r = N-1

    ans = 0

    while l < r:
        while l < r and arr[l] != "W":
            l += 1

        while l < r and arr[r] != "R":
            r -= 1

        if l < r:
            ans += 1
            l += 1
            r -= 1

    return ans


N = readInt()
arr = [ch for ch in read()]

print(solve(N, arr))


Measured memory_bytes: 88364
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k,n,ans=1;
  scanf("%d %d",&n,&k);
  while(ans<k){
    ans=ans*2;
    n--;
    if(n==0){
      cout<<ans<<endl;
      return 0;
    }
  }
  cout<<ans+n*k<<endl;
  return 0;
}


Measured memory_bytes: 256
///cREATED bY BERNARB.01
#include<bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(0);
	cin.tie(0);
    long long n, a, b;
    cin >> n >> a >> b;
    long long c = n/(a+b);
    n%=(a+b);
    cout << min(n, a)+(c*a) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
long fm(int n)
{
  long a = 1;
  while(n) a = (a * (long)n--) % MOD;
  return a;
}
int main(void)
{
  int n, m;
  long ans;
  cin >> n >> m;
  if(abs(n - m) > 1) ans = 0;
  else if(n == m) ans = (2 * fm(n) * fm(n)) % MOD;
  else ans = (fm(n) * fm(m)) % MOD;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n, m = gets.chomp.split(' ').map(&:to_i)
arr = Array.new(n, "0")

m.times do
  s, c = gets.chomp.split(' ').map(&:to_i)
  if !(arr[s-1]=="0" || arr[s-1]=="1") && arr[s-1]!=c || (n>2 && s==1 && c==0)
    print(-1)
    exit
  else
    arr[s-1] = c
  end
end
arr[0] = "1" if arr[0]=="0" && n!=1
print(arr.join)

Measured memory_bytes: 3836
// After contest.
// If v is odd, then v ^ (v+1) = 1
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

long long f(long long n) {
	if (n < 2)
		return n;

	long long k = n / 2, res = 0;
	if (n%2 == 0)
		--k;

	if (k%2 == 0)
		res = 1;

	if (n%2 == 0)
		res ^= n;

	return res;
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	long long a, b, ans;
	cin >> a >> b;

	ans = f(b);
	if (a > 0)
		ans ^= f(a-1);
	
	cout << ans << endl;

	return 0;
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;

void solve() {
    i64 n, k;
    cin >> n >> k;
    vector<i64> a(n);
    for (auto& e : a) cin >> e;

    for (i64 i = k; i < n; i++) {
        cout << (a[i - k] < a[i] ? "Yes" : "No") << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 4760
<?php
list($N,$L) = explode(" ",trim(fgets(STDIN)));
$a = explode(" ",trim(fgets(STDIN)));

for($i = 0;$i < $N - 1;$i++){
    $sum2[] = $a[$i] + $a[$i + 1];
}

if(max($sum2) >= $L){
    echo "Possible\n";
    $num = array_search(max($sum2),$sum2);
    for($i = 1;$i < $num + 1;$i++){
        echo $i ."\n";
    }
    for($i = $N - 1;$i > $num;$i--){
        echo $i ."\n";
    }
}else{
    echo "Impossible";
}

Measured memory_bytes: 35912
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <algorithm>

using namespace std;

typedef pair<int, int> pii;

#define mp make_pair

const int MAXN = 20;
const int MAXM = 300005;

pii f[2][MAXM];

int a[MAXM], g[MAXM];

int n, N;

inline void merge(pii &x, pii &y, pii u, pii v)
{
	pii s[4] = {x, y, u, v};
	sort(s, s + 4);
	reverse(s, s + 4);
	unique(s, s + 4);
	x = s[0], y = s[1];
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N, n = (1 << N); 
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 1; i < n; i++)
	{
		pii x(a[0], 0), y(a[i], i);
		if (x < y)
			swap(x, y);
		for (int j = 1; j < n; j <<= 1)
			if (i & j)
				merge(x, y, f[0][i ^ j], f[1][i ^ j]);
		f[0][i] = x, f[1][i] = y;
		g[i] = x.first + y.first;
	}
	for (int i = 2; i < n; i++)
		g[i] = max(g[i], g[i - 1]);
	for (int i = 1; i < n; i++)
		cout << g[i] << endl;
	return 0;
}


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

int main() {
    string S; cin >> S;
    if (S == "A") cout << "T";
    else if (S == "T") cout << "A";
    else if (S == "C") cout << "G";
    else if (S == "G") cout << "C";
    cout << endl;
}

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

#define int long long

signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s;
    cin>>s;
    int ans=0,x=0;
    for(int i=0; i<3; i++){
        if(s[i]=='R')
            x++;
        else{
            x=0;
        }
        ans=max(ans,x);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  char C;
  cin >> C;

  cout << (char)(C + 1) << "\n";
  
  return 0;
}


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

#define int long long

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

int c[3][3];
signed main() {
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }
    for (int i = 0; i <= 100; i++) {
        for (int j = 0; j <= 100; j++) {
            for (int k = 0; k <= 100; k++) {
                int b1 = c[0][0] - i, b2 = c[0][1] - i, b3 = c[0][2] - i;
                if (j + b1 == c[1][0] && k + b1 == c[2][0] &&
                    j + b2 == c[1][1] && k + b2 == c[2][1] &&
                    j + b3 == c[1][2] && k + b3 == c[2][2]) {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<cstdlib>

typedef struct{
    int n;
    char c;
    int order;
} T;

void QuickSort(T*, int, int);
int Partition(T*, int, int);
void BubbleSort(T*, int);

void Swap(T*, T*);

int main(){
    int i, j, n, stableflag = 1;
    T *tr, *cpy;
    
    scanf("%d", &n);
    tr = (T *)malloc(sizeof(T) * n);
    //cpy = (T *)malloc(sizeof(T) * n);
    for (i = 0; i < n; i++) {
        scanf(" %c %d", &tr[i].c, &tr[i].n);
        tr[i].order = i;
    }
    
    QuickSort(tr, 0, n-1);
    
    // see if stable or not
    for (i = 0; i < n-1; i++) {
        for (j = i; ; j++) {
            if (tr[j].n != tr[j+1].n) {
                i = j;
                break;
            }else if(tr[j].order > tr[j+1].order){
                stableflag = 0;
                i = n;
                break;
            }
        }
    }
    
    
    if (stableflag) {
        printf("Stable\n");
    }else{
        printf("Not stable\n");
    }
    
    for (i = 0; i < n; i++) {
        printf("%c %d\n", tr[i].c, tr[i].n);
    }
    
    return 0;
}


void QuickSort(T* A, int p, int r){
    int mid;
    if (p < r) { // when !(there are less than or equal to three elements)
        mid = Partition(A, p, r);
        QuickSort(A, p, mid-1);
        QuickSort(A, mid+1, r);
    }
}

// Partition from A[p] to A[r]
int Partition(T* A, int p, int r){
    int x = A[r].n, i = p-1, j;
    
    for (j = p; j < r; j++) {
        if (A[j].n <= x) {
            i++;
            Swap(&A[i], &A[j]);
        }
    }
    Swap(&A[i+1], &A[r]);
    
    return i+1;
}

void BubbleSort(T* A, int n){
    int i, j;
    for (i = 0; i < n; i++) {
        for (j = 0; j < n-1 - i; j++) {
            if (A[j].n > A[j+1].n) {
                Swap(&A[j], &A[j+1]);
            }
        }
    }
}

void Swap(T *x, T *y){
    T tmp;
    tmp = *y;
    *y = *x;
    *x = tmp;
}




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

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#define ABS(x, y) ((x) > (y) ? ((x) - (y)) : ((y) - (x)))

#define MOD(x, y) ((x) % (y))
#define DIVCEIL(x, y) (((x) + ((y) - 1)) / (y))
#define DIVFLOOR(x, y) (((x) + ((y) / 2)) / (y))
#define DIVROUND(x, y) ((x) - MOD(x, y) >= MOD(x, y) ? DIVCEIL(x, y) : DIVFLOOR(x, y))

constexpr int MAX_N = 30;
constexpr int MAX_K = 3;

int dp[MAX_N+1];

int main() {
  int N;
  while (true) {
    cin >> N;
    if (N == 0)
      break;
    fill_n(dp, MAX_N+1, 0);
    dp[0] = 1;
    dp[1] = 1;
    dp[2] = 2;

    for (int i{MAX_K}; i <= N; ++i) {
      for (int j{1}; j <= MAX_K; ++j) {
        dp[i] += dp[i-j];
      }
    }

    cout << DIVCEIL(dp[N], 3650) << endl;
  }

  return 0;
}



Measured memory_bytes: 2988
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)

// 同じカードを2回以上使わないだけ
// あとのとペアにしたいからできるだけ手前の使う

void solve() {
    int n;
    cin >> n;
    pii ba = {0, 0};
    ll ans = 0;
    rep(i, n) {
        int a;
        cin >> a;
        
        ans += min(ba.S, a);
        a -= min(ba.S, a);
        
        ans += a / 2;
        a -= a / 2 * 2;
        ba = {i + 1, a};
    }
    out(ans);
}

int main() {
    solve();
}


Measured memory_bytes: 384
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   
ll a[212345],b[212345];
int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int i;
    rep(i,n){
    	cin>>a[i]>>b[i];
    }
    ll ans=0,mini=inf,flag=0;
    rep(i,n){
    	if(a[i]!=b[i])
    		flag=1;
    	ans+=a[i];
    	if(a[i]>b[i]){
    		mini=min(mini,b[i]);
    	}
    }
    if(flag){
    	 cout<<ans-mini<<endl;
    }
    else{
    	cout<<0<<endl;
    }
   
    return 0;  
    
}



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

namespace _0233
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = RInt();
                if (n == 0) break;

                string res = string.Empty;
                while (n != 0)
                {
                    int q = n / -10;
                    int r = n - (q * -10);

                    if (r < 0)
                    {
                        r += 10;
                        q += 1;
                    }

                    res += r.ToString();
                    n = q;
                }
                Console.WriteLine(WAr(res.Reverse(),string.Empty));
            }
        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



Measured memory_bytes: 16224
s=input()
n=len(s)

cnt=0
ans=0

for i in range(n-1):
    if s[i]=="A":
        cnt+=1
    elif s[i:i+2]=="BC":
        ans+=cnt
    elif i>0 and s[i-1:i+1]=="BC":
        pass
    else:
        cnt=0

print(ans)
    

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

void solve(){
    int N,M;
    cin >> N >> M;
    vector<int> A(N);
    vector<int> left(N+1),cnt(N+1);
    rep(i,0,N+1) left[i]=i;
    rep(i,0,N){
        cin >> A[i];
        --left[A[i]];
        if(0<=left[A[i]]) ++cnt[left[A[i]]];
    }

    i64 ans=0;
    rep(i,0,N) if(!cnt[i]) ++ans;
    rep(i,0,M){
        int X,Y;
        cin >> X >> Y;
        --X;
        if(0<=left[A[X]]){
            --cnt[left[A[X]]];
            if(!cnt[left[A[X]]]) ++ans;
        }
        ++left[A[X]];

        A[X]=Y;

        --left[Y];
        if(0<=left[Y]){
            ++cnt[left[Y]];
            if(cnt[left[Y]]==1) --ans;
        }
        cout << ans << endl;
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 3840
# https://atcoder.jp/contests/abc116/tasks/abc116_c C - Grand Garden
n=int(input())
Tree_List=list(map(int,input().split()))

ct =0
for i in range(n):
    while Tree_List[i] != 0:
        ##一番最後の要素を確認しているようであればそこだけ処理すればよい
        if i == n-1:
            Tree_List[i] -= 1
        ##それ以外は、一緒に処理ができるものがないか確認する
        else:
            ##二番目以降の探索
            k = i + 1
            while Tree_List[k] != 0: 
                k+=1
                if k == n:
                    break
            Tree_List[i:k]=map(lambda x:x-1,Tree_List[i:k])
        
        ct += 1
        
print(ct)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.rbegin(), v.rend());//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define OUT(x) cout << x << endl
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

vector<pair<int64_t, int64_t> > prime_factorize(int64_t n) {
    vector<pair<int64_t, int64_t> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int64_t num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));//p^num
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main(){
  int64_t n,p;
  cin >> n>>p;
  if(n==1){
    cout << p << endl;
    return 0;
  }
  vector<pair<int64_t,int64_t>> res=prime_factorize(p);
  vector<int64_t> tmp;
  REP(i,res.size()){
    int64_t num= res[i].second / n;
    while(num>0){
      tmp.push_back(res[i].first);
      num--;
    }
  }
  int64_t ans=1;
  REP(i,tmp.size()){
    ans*=tmp[i];
  }
  if(p==1) cout << 1 << endl;
  else cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define MAX 1000

int main(void){

	int i, n, temp[MAX];
	double sum, ave, sd;

	while(1){
		scanf("%d", &n);

		if(n == 0){
			break;
		}

		sum = 0.0;
		for(i = 0; i < n; i++){
			scanf("%d", &temp[i]);
			sum += (double)temp[i];
		}

		ave = sum / (double)n;
		
		sd = 0.0;
		for(i = 0; i < n; i++){
			sd += (ave - (double)temp[i]) * (ave - (double)temp[i]);
		}
		sd /= (double)n;
		printf("%f\n", sqrt(sd));
	}


	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  rep (i, N) cin >> A[i];
  int l = 0, r = 1e9;
  while(r - l > 1){
    int x = (r + l) / 2;
    bool solve = [&]{
      long long now = 0;
      rep (i, N) now += (A[i] - 1) / x;
      return now <= K;
    }();
    if(solve) r = x; else l = x; 
  }
  cout << r << endl;
}


Measured memory_bytes: 3876
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <cstdio>
#include <cstdlib>
using namespace std;

int main()
{
	string str;
	
	while (getline(cin, str)){
		stack<double> st;
		stringstream ss;
		
		ss << str;
		string item;
		while (ss >> item){
			char c = item.at(0);
			
			if (c == '+' || (c == '-' && item.length() == 1) || c == '*' || c == '/'){
				double a, b;
				
				b = st.top(); st.pop();
				a = st.top(); st.pop();
				if (c == '+') st.push(a + b);
				else if (c == '-') st.push(a - b);
				else if (c == '*') st.push(a * b);
				else st.push(a / b);
			}
			else {
				st.push(atof(item.c_str()));
			}
		}
		printf("%f\n", st.top());
	}
	
	return 0;
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int k;
    cin>>k;
    char c;
    c=s[k-1];
    for(int i=0;i<n;i++){
        if(s[i]!=c){
            s[i]='*';
        }
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
//Use valgrind once if the submission doesn't go through. It can detect uninitialized variables and see where they could be an issue.
#include <bits/stdc++.h>
using namespace std;

int main(){

	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);
	
	int n,x,t;
	cin>>n>>x>>t;
	if(n%x==0){
		cout<<(n/x)*t<<endl;
	}
	else{
		cout<<static_cast<int>(ceil((n/(x*1.0))))*t<<endl;
	}
}


Measured memory_bytes: 3552
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef pair<P,P> PPP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
typedef pair<ll,PPP> S;

#define N 101
int h, w;
ll t[N][N];
string s[N];
//unordered_map<PPP,ll> d;
map<PPP,ll> d;

int sum(int xl, int xr, int yl, int yr){
	if(xl>xr||yl>yr) return 0;
	return t[xr+1][yr+1]-t[xr+1][yl]-t[xl][yr+1]+t[xl][yl];
}

int main(){
	cin>>h>>w;
	rep(i, h) cin>>s[i];
	rep(i, h) rep(j, w) t[i+1][j+1] += t[i][j+1]+t[i+1][j]-t[i][j]+(s[i][j]=='o');
	int sx, sy;
	rep(i, h) rep(j, w){
		if(s[i][j]=='E'){
			PPP p = PPP(P(i, i), P(j, j));
			d[p] = 0;
			sx = i;
			sy = j;
		}
	}
	ll res = 0;
	while(!d.empty()){
		map<PPP,ll> d2;
		for(auto &&v: d){
			chmax(res, v.snd);
			P x = v.fst.fst, y = v.fst.snd;
			int xl = x.fst, xr = x.snd;
			int yl = y.fst, yr = y.snd;
			int len = v.snd;
			//cerr<<xl<<" "<<xr<<" "<<yl<<" "<<yr<<" "<<len<<endl;
			auto upd = [&](int a, int b, int c, int d){
				int xl2 = xl+a, xr2 = xr+b, yl2 = yl+c, yr2 = yr+d;
				if(xl2<0||xr2>=h||yl2<0||yr2>=w) return;
				if(a&&xl2<xr-sx) return;
				if(b&&xr2>xl+h-sx-1) return;
				if(c&&yl2<yr-sy) return;
				if(d&&yr2>yl+w-sy-1) return;
				PPP p = PPP(P(xl2, xr2), P(yl2, yr2));
				int len2 = len;
				if(a||b){
					int yl3 = max(yl, yr-sy);
					int yr3 = min(yr, yl+w-sy-1);
					len2 = len-sum(xl, xr, yl3, yr3)+sum(xl2, xr2, yl3, yr3);
				} else {
					int xl3 = max(xl, xr-sx);
					int xr3 = min(xr, xl+h-sx-1);
					len2 = len-sum(xl3, xr3, yl, yr)+sum(xl3, xr3, yl2, yr2);
				}
				if(d2[p]<len2) d2[p] = len2;
			};
			upd(-1, 0, 0, 0);
			upd(0, 1, 0, 0);
			upd(0, 0, -1, 0);
			upd(0, 0, 0, 1);
		}
		d.swap(d2);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
int N;
int che(int num,int hou){
    int amari=num%hou;
    return amari;
}

void solve(){
    cin>>N;
    bool flag=false;
    for(int i=0;i<N+1;i++){
        //i
       if((che(i,4)==0)&&(che(N-i,7)==0)){cout<<"Yes"<<endl;return;}
        //N-i
          
    }
    cout<<"No"<<endl;
}
int main(){
    solve();

    return 0;
}

Measured memory_bytes: 256
def main():
  n,k,*t=map(int,open(0).read().split())
  e=[set()for _ in[0]*n]
  for a,b in zip(t[::2],t[1::2]):
    e[a-1]|={b-1}
    e[b-1]|={a-1}
  c,q=k,[0]
  while q:
    v,i=q.pop(),1
    for w in e[v]:
      c=c*(k-i-(v>0))%(10**9+7)
      e[w]-={v}
      q.append(w)
      i+=1
  print(c)
main()

Measured memory_bytes: 49216
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            string str = Console.ReadLine();

            int a = 0;

            for (int i = 0; i < 4; i++)
            {
                if (str[i] == '+') a++;
                else a--;
            }
            Console.Write(a);

            Console.ReadKey();
        }
    }

}

Measured memory_bytes: 11092
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
a = na()
ct = 0
for i in range(n-2):
    if a[i] <= a[i+1] <= a[i+2] or a[i+2] <= a[i+1] <= a[i]:
        ct += 1
print(ct)


Measured memory_bytes: 38420
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main(){
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		int N;
		cin>>N;
		int ma=0,prec=0;
		int val=0;
		for(int i=0;i<N;i++){
			int a;
			cin>>a;
			if(a<=prec){
				prec=a;
				val++;
			}else{
				prec=a;
				val=0;
			}
			ma=max(ma,val);
		}
		cout<<ma;
		return 0;
}


Measured memory_bytes: 256
#https://tjkendev.github.io/procon-library/python/string/rolling_hash.html
class RollingHash():
    def __init__(self, s, base, mod):
        self.mod = mod
        self.pw = pw = [1]*(len(s)+1)

        l = len(s)
        self.h = h = [0]*(l+1)

        v = 0
        for i in range(l):
            h[i+1] = v = (v * base + s[i]) % mod
        v = 1
        for i in range(l):
            pw[i+1] = v = v * base % mod
    def get(self, l, r):
        return (self.h[r] - self.h[l] * self.pw[r-l]) % self.mod
N=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[a[i%N]^a[(i+1)%N] for i in range(2*N)]
d=[b[i]^b[(i+1)%N] for i in range(N)]
P=RollingHash(c,97,10**9+7)
Q=RollingHash(d,97,10**9+7)

for k in range(N):
    if P.get(k,k+N)==Q.get(0,N):
        x=b[0]^a[k]
        print(k,x)

Measured memory_bytes: 128208
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        Task task = new Task();
        task.solve(sc, out);
        out.flush();
        sc.close();
    }
    static class Task{
        public void solve(Scanner sc, PrintWriter out){
            String S = nstr(sc);
            String T = nstr(sc);
            for (int i=0; i<S.length(); i++){
                S = S.substring(1) + S.charAt(0);
                if (S.equals(T)){
                    out.println("Yes");
                    return;
                }
            }
            out.println("No");
        }
    }

    static int nint(Scanner sc){
        return Integer.parseInt(sc.next());
    }
    static long nlong(Scanner sc){
        return Long.parseLong(sc.next());
    }
    static double ndouble(Scanner sc){
        return Double.parseDouble(sc.next());
    }
    static float nfloat(Scanner sc){
        return Float.parseFloat(sc.next());
    }
    static String nstr(Scanner sc){
        return  String.valueOf(sc.next());
    }
    static long[] longLine(Scanner sc, int size){
        long[] lLine = new long[size];
        for (int i = 0; i < size; i++) {
            lLine[i] = nlong(sc);
        }
        return lLine;
    }
    static int[] intLine(Scanner sc, int size){
        int[] iLine = new int[size];
        for (int i = 0; i < size; i++) {
            iLine[i] = nint(sc);
        }
        return iLine;
    }
    static String[] strLine(Scanner sc, int size){
        String[] strLine = new String[size];
        for (int i = 0; i < size; i++) {
            strLine[i] = nstr(sc);
        }
        return strLine;
    }
}

Measured memory_bytes: 21588
def slove():
    import sys
    input = sys.stdin.readline
    ans = list("CODEFESTIVAL2016")
    cnt = 0
    s = str(input().rstrip('\n'))
    for i in range(len(s)):
        if s[i] != ans[i]:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    ll n; cin >> n;
    ll ans = 0;
    vector<ll> A(100001,0);

    for(int i=0;i<n;i++){
        ll a; cin >> a;
        if(a > 100000) ans++;
        else A[a]++;
    }

    for(int i=1;i<=100000;i++){
        if(A[i] < i) ans += A[i];
        else ans += A[i] - i;
    }

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



Measured memory_bytes: 1024
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

ll t1,t2,a1,a2,b1,b2;

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    if(a1==b1 || a2==b2 || a1*t1+a2*t2==b1*t1+b2*t2)
    {
        cout << "infinity" << endl;
        return 0;
    }
    ll x = (a1-b1)*t1;
    ll y = (a2-b2)*t2;
    if(x<0)
    {
        x = -x;
        y = -y;
    }
    if(y>-x)
    {
        cout << 0 << endl;
        return 0;
    }
    ll cha = -(x+y);
    if(x%cha == 0)
    {
        cout << (x/cha) * 2 << endl;
    }
    else cout << (x/cha) * 2 + 1 << endl;
}


Measured memory_bytes: 256
import sys
#input=sys.stdin.read
adj=[[] for i in range(4)]
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

for i in range(3):
    a,b=MAP()
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)
for i in range(4):
    if len(adj[i])>2:
        print("NO")
        exit()
print("YES")


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

using namespace std;

typedef long long LL;
const LL Mod = 1000000007;
LL qpow(LL base, LL times, LL mod)
{
    LL ans = 1;
    LL tmp = base % mod;
    while (times)
    {
        if (times & 1)
            ans = ans * tmp % mod;
        tmp = tmp * tmp % mod;
        times >>= 1;
    }
    return ans;
}
LL jie[2002], fan[2002];
void init()
{
    jie[0] = jie[1] = 1;
    fan[0] = fan[1] = 1;
    for (int i = 2; i <= 2001; i++)
    {
        jie[i] = (jie[i - 1] * i) % Mod;
        fan[i] = (fan[i - 1] * qpow(i, Mod - 2, Mod)) % Mod;
    }
}
LL cal(int m, int n)
{
    return (jie[n] * fan[m] % Mod) * fan[n - m] % Mod;
}
int main()
{
    init();

    int S;
    while (~scanf("%d", &S))
    {
        int zu = S / 2;
        LL ans = 0;
        for (int i = 1; i <= zu; i++)
        {
            int ge = S - i * 2;
            if (ge < i)
                break;
            // cout << "ge = " << ge << "\n";
            // ans = (ans + qpow(ge, i - 1, Mod)) % Mod;
            ans = (ans + cal(i - 1, S - i * 2 - 1)) % Mod;
        }
        printf("%lld\n", ans);
    }
    // scanf("%d", &S);
}

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

typedef long long ll;


int poker(int a,int b){
    if(a == 1) a = 14;
    if(b == 1) b = 14;
    if(a>b){
        printf("Alice");
    }
    else if(a<b){
        printf("Bob");
    }else{
        printf("Draw");
    }
}

int main(){
    int A,B;
    cin >> A >> B;

    poker(A,B);
    return 0;
}


Measured memory_bytes: 256
S = input()
N = len(S)
X = [i-1 if S[i] == "L" else i+1 for i in range(N)]
for k in range(1, 20):
    X = [X[X[i]] for i in range(N)]
A = [0]*N
for i in range(N):
    A[X[i]] += 1
print(*A)

Measured memory_bytes: 10324
n, m, r = map(int, input().split())
*R, = map(int, input().split())
E = [[10**18]*n for i in range(n)]
for i in range(n):
    E[i][i] = 0
for i in range(m):
    a, b, c = map(int, input().split())
    E[a-1][b-1] = E[b-1][a-1] = c
for k in range(n):
    for i in range(n):
        for j in range(n):
            E[i][j] = min(E[i][j], E[i][k] + E[k][j])

memo = {}
ALL = 2**r-1
def dfs(state, pos):
    if (state, pos) in memo:
        return memo[state, pos]
    if state == ALL:
        return 0
    res = 10**18
    for i in range(r):
        if state & (1 << i) == 0:
            res = min(res, dfs(state | (1 << i), R[i]-1) + E[pos][R[i]-1])
    memo[state, pos] = res
    return res
print(min(dfs(0, i) for i in range(n)))


Measured memory_bytes: 50776
c = []
for i in range(3):
    line = [int(data) for data in input().split()]
    c.append(line)

for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            if (c[0][0] - a1 == c[1][0] - a2 and c[1][0] - a2 == c[2][0] - a3) \
                    and (c[0][1] - a1 == c[1][1] - a2 and c[1][1] - a2 == c[2][1] - a3) \
                    and (c[0][2] - a1 == c[1][2] - a2 and c[1][2] - a2 == c[2][2] - a3):
                print("Yes")
                exit()
print("No")



Measured memory_bytes: 3188