akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{BufWriter, Write};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}
#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}
fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }

    input! {
        n: i64,
        a: i64,
        b: i64,
    }

    if (a - b) % 2 == 0 {
        println!("{}", (a - b).abs() / 2);
        return;
    }

    let mut ans = 0;
    {
        let dif = a - 1;
        let mut tmp = dif + 1;
        let a_ = 1;
        let b_ = b - dif - 1;
        tmp += (b_ - a_) / 2;
        ans = tmp;
    }
    {
        let dif = n - b;
        let mut tmp = dif + 1;
        let a_ = a + dif + 1;
        let b_ = n;
        tmp += (b_ - a_) / 2;
        ans = min(ans, tmp);
    }

    println!("{}", ans);
}
fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int A;
    int B;
    cin >> A >> B;
    map<int, int> cnt;
    cnt[A]++;
    cnt[B]++;
    for(int i = 1; i <= 3; i++) {
        if(cnt[i] == 0) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=2e5+5;
int cnt[N],vis[N],a[N],n,m,res;
inline void ins(R int x){++cnt[x];if(x-cnt[x]+1>=1&&!vis[x-cnt[x]+1]++)--res;}
inline void del(R int x){if(x-cnt[x]+1>=1&&!--vis[x-cnt[x]+1])++res;--cnt[x];}
int main(){
	scanf("%d%d",&n,&m),res=n;
	fp(i,1,n)scanf("%d",&a[i]),ins(a[i]);
	for(R int i=1,x,y;i<=m;++i){
		scanf("%d%d",&x,&y);
		del(a[x]),a[x]=y,ins(a[x]);
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int month = s.nextInt();
		int day = s.nextInt();
		s.close();
		int d1 = 0;
		int day10 = day / 10;
		int sum = 0;

		for (int i = 2; i <= month; i++) {
			//月ごとに処理する
			for (int j = 2; j <= day10; j++) {
				d1 = i / j;
				if ((j * 10 +d1) <= day 
						&& i % j ==0 
						&& d1>1
						&& 10 > d1 ) {
					sum++;
				}
			}
		}
		System.out.println(sum);

	}

}


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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back

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

    ll a,b,c,ans;
    cin >> a >> b >> c;
    if(b/a>=c) ans = c;
    else ans = b/a;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
//MADE BY Y_is_sunshine;
//#include <bits/stdc++.h>
//#include <memory.h>
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define INF 0x3f3f3f3f
#define MAXN 100005

typedef long long ll;

const ll mod = 1e9 + 7;
const double PI = acos(-1);

using namespace std;

int N, M, K;

int main(void)
{
#ifdef Sunshine
	freopen("data.txt", "r", stdin);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> N >> M;

	int sum = 0;
	for (int i = 1; i <= M; i++) {
		int temp;
		cin >> temp;
		sum += temp;
	}

	if (sum >= N)
		cout << "Yes\n";
	else
		cout << "No\n";












#ifdef Sunshine
	freopen("CON", "r", stdin);
	system("pause");
#endif
	return 0;
}

Measured memory_bytes: 256
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val Array(a, b, c) = in.readLine().split("\\s+").map(_.toInt)

    out.println(List(c, a, b).mkString(" "))
    out.flush()
  }
}


Measured memory_bytes: 25528
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int N, M, c, k, s;
vector<int> v;
vector<vector<int>> switches;
vector<int> cong;
int main() 
{
  scanf("%d%d", &N, &M);
  
  for (int i = 0; i < M; ++i) {
    vector<int> sw; scanf("%d", &k);
    for (int j = 0; j < k; ++j) {
      scanf("%d", &s);
      sw.push_back(s);
    }
    switches.emplace_back(sw);
  }

  for (int i = 0; i < M; ++i) {
    scanf("%d", &c);
    cong.push_back(c);
  }
  int ans = 0;
  for (int i = 0; i < (1 << N); ++i) {
    vector<bool> turnOn(N, false);
    int sw = i, j = N-1;
    while (sw) {
      turnOn[j] = sw % 2;
      j--;
      sw >>= 1;
    }

    int bulb_cnt = 0;
    for (int j = 0; j < M; ++j) {
      int cnt = 0;
      for (int & ss : switches[j]) {
        if (turnOn[ss-1]) {
          cnt++;
        }
      }
      if (cnt % 2 == cong[j]) bulb_cnt++;
    }
    if (bulb_cnt == M) ans++;
  }
  printf("%d", ans);
}

Measured memory_bytes: 256
fun main(args: Array<String>){
    val (N, Q) = readLine()!!.split(" ").map{ it.toInt() }
    val s = readLine()!!
    val lr = (1..Q).map { readLine()!!.split(" ").map { it.toInt() -1 }}

    val ac = IntArray(N)

    //Cumulative sum
    for (i in 1..N-1) {
        if(s[i-1] == 'A' && s[i] == 'C') ac[i] = ac[i-1] + 1
        else ac[i] = ac[i-1]
    }

    val ans = lr.map {
        val (l, r) = it
        ac[r] - ac[l]
    }

    ans.forEach { println(it) }
}

Measured memory_bytes: 71148
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	ll n;
	cin >> n;

	vector<ll> a(n);
	for (ll i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	ll cnt = 0;
	for (ll i = 1; i < n; i++)
	{
		if (a[i - 1] == a[i])
		{
			cnt++;
			a[i] = -1;
		}
	}

	println(cnt);
}

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

using namespace std;

const int N = 2000005;

bitset <N> reach;
int n, m, sum;

int main() {
	scanf("%d", &n);
	reach[0] = 1;
	while (n--) {
		scanf("%d", &m);
		sum += m;
		reach |= reach << m;
	}
	for (int i = (sum + 1) >> 1; i <= sum; ++i) {
		if (reach[i]) {
			printf("%d\n", i);
			return 0;
		}
	}
  return 0;
} 



Measured memory_bytes: 1024
n = int(input())
x = list(map(int, input().split()))

f = 10**100

for p in range(min(x), max(x) + 1):
    l = [(x[i] - p)**2 for i in range(n)]
    f1 = sum(l)
    f = min(f, f1)

print(f)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int a,b,mx;
    cin>>a>>b;
    mx= max(a+b,a-b);
    mx= max(mx,a*b);
    cout<<mx<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,deck[1000],m;

void cut(int k){
  int tmp1[1000],tmp2[1000];
  for(int i = 1 ; i <= k ; i++){
    tmp1[i] = deck[i];
  }
  int p = 1;
  for(int i = k+1 ; i <= 2*n ; i++){
    tmp2[p++] = deck[i];
  }
  for(int i = 1 ; i <= 2*n ; i++){
    if(i < p)deck[i] = tmp2[i];
    else deck[i] = tmp1[i-p+1];
  }
}

void refu(){
  int tmp1[1000],tmp2[1000];
  for(int i = 1 ; i <= n ; i++){
    tmp1[i] = deck[i];
  }
  int p = 1;
  for(int i = n+1 ; i <= 2*n ; i++){
    tmp2[p++] = deck[i];
  }
  p = 1;
  int s = 1;
  for(int i = 1 ; i <= 2*n ; i++){
    if(i%2 == 1)deck[i] = tmp1[p++];
    else deck[i] = tmp2[s++];
  }
}


int main(){

  cin >> n >> m;

  for(int i = 1 ; i <= 2*n ; i++)deck[i] = i;

  while(m--){
    int k;
    cin >> k;

    if( k > 0)cut(k);
    else refu();
  }
  for(int i = 1 ; i <= 2*n ; i++ )cout << deck[i] << endl;

  return 0;
}

Measured memory_bytes: 1168
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int T = sc.nextInt();
        int minCost = Integer.MAX_VALUE;

        for (int i = 0; i < N; i++) {
            int c = sc.nextInt();
            int t = sc.nextInt();
            if (t <= T && c < minCost) {
                minCost = c;
            }
        }
        System.out.println(minCost == Integer.MAX_VALUE ? "TLE" : minCost);
    }
}

Measured memory_bytes: 23636
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<int> t(n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> t[i];
    ans += t[i];
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int p, x;
    cin >> p >> x;
    cout << ans - t[p - 1] + x << endl;
  }
  return 0;
}

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

using namespace std;

int main ()
{
  int N,K;
  cin>>N>>K;
  vector<int> f;
  for(int i=0;i<N;i++)
  {
    int p;
    cin>>p;
    f.push_back(p);
  }
  sort(f.begin(),f.end());
  int sum=0;
  for(int i=0;i<K;i++)
  {
    sum+=f[i];
  }
  cout<<sum<<endl;
  return 0;
}

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

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

#define ll int64_t

using namespace std;

//memory exceed 
/*
int main() {
	int64_t n,m,k;
	cin >> n>>m>>k;
	
	vector<unsigned int> A(n+5);
	vector<unsigned int> B(m+5);

	rep(i,n){
		cin >> A[i];

	}
	rep(i,m){
		cin >> B[i];
	}
	
	vector<vector<unsigned int>> dp(n+5,vector<unsigned int>(m+5,0));
	int ans = 0;
	dp[1][0] = A[0];
	rep(i,n+1){
		if(i>1){
			dp[i][0] = dp[i-1][0] + A[i-1];
		}
		if(dp[i][0] > k)break;
		if(ans < i){
			ans = i;
		}
		rep(j,m+1){
			if(j==0)continue;
			dp[i][j] = dp[i][j-1] + B[j-1];
			if(dp[i][j] > k)break;

			if(ans < i+j){
				ans = i+j;
			}
		}
	}

	cout << ans;

	return 0;

}

*/

//time exceed 
/*
int main(){
	
	int64_t n,m,k;
	cin >> n>>m>>k;
	
	vector<int> A(n+5);
	vector<int> B(m+5);
	vector<int> Bsum(m+5);

	rep(i,n){
		cin >> A[i];

	}
	rep(i,m){
		cin >> B[i];
		if(i!=0){
			Bsum[i] = Bsum[i-1] + B[i-1];
		}
	}
	Bsum[m] = Bsum[m-1]+B[m-1];

	int64_t asum =0;
	int ans =0;

	rep(i,n+1){
		if(i!=0){
			asum = asum + A[i-1];
		}
		if(asum > k)break;

		rep(j,m+1){

			if(asum + Bsum[j] > k)break;
			if(ans < i+j)ans = i+j;

		}
	}
	cout << ans;

	return 0;
	
}

*/


int main(){
	
	int64_t n,m,k;
	cin >> n>>m>>k;
	
	vector<int> A(n+5);
	vector<int> B(m+5);

	ll sum =0;

	rep(i,n)cin >> A[i+1];
	rep(i,m)cin >> B[i+1];

	int j =0;
	while(sum < k && j < m+1){
		sum += B[j];
		j++;
	}
	j--;
	int ans =0;


	rep(i,n+1){
		sum += A[i];
		while(true){
			if(j==0||sum<=k)break;
			sum -= B[j];
			j--;
		}

		if(sum>k)break;
		ans = max(ans,i+j);
	}
	cout << ans;

	return 0;
	
}

Measured memory_bytes: 4848
N,P = map(int,input().split())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    arr.append([temp, 1])

    return arr

a = factorization(P) 
su = 1
for j,k in a:
  #print(j,k,a)
  if k>=N:
    su *= j**(k//N)
    #print(j,k,su)
print(su)

Measured memory_bytes: 3064
#include <iostream>

int main() {
    int a, b;
    std::cin >> a >> b;
    int result = 0;
    if (a > b) {
        result += a;
        a--;
    } else {
        result += b;
        b--;
    }
    if (a > b) {
        result += a;
        a--;
    } else {
        result += b;
        b--;
    }
    std::cout << result << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int,int> pii;
using namespace std;
using ll = long long;
#define PI 3.14159265358979323846264338327950L
const int mod =  998244353;



map<int,int> prime(int n ){
    map<int,int> ret;
    while(n%2 == 0){
        n/=2;
        ret[2]++;
    }
    for(int i = 3; i*i <= n; i = i + 2){
        while(n%i == 0){
            n/=i;
            ret[i]++;
        }
    }
    if (n>2) ret[n]++;
    return ret;
}

bool ok;

void dfs(vector<int>& ps, vector<int>& pw, int i, int v,map<int,int>& seen){
    if (i == pw.size()){
        if (v==1) return;
        ok |= seen[v];
        //cout << v << endl;
        return;
    }
    for(int j = 0; j <= pw[i]; j++){
        dfs(ps,pw,i+1,v*pow(ps[i],j),seen);
    }
}

bool check(map<int,int>& p, map<int,int>& seen){
    ok = false;
    vector<int> ps,pw;
    for(auto e:p){
        ps.push_back(e.first);
        pw.push_back(e.second);
    }
    dfs(ps,pw,0,1,seen);
    return ok;
}

void solveD(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    SORT(a);
    if (a[0] == a[n-1]){
        cout << 0;
        return;
    }
    int ans = 0;
    map<int,int> seen;
    
    for(int i = 0; i < n; i++){
        auto p = prime(a[i]);
        
        if (check(p,seen)) ans++;
        seen[a[i]] = 1;
    }
    
    cout << n - ans;
}

void solveC(){
    int x,n;
    cin >> x >> n;
    map<int,int> seen;
    rep(i,n){
        int p;
        cin >> p;
        seen[p] = 1;
    }
    int diff = 1001001001;
    int ans = 0;
    for(int i = -1000; i <= 1000; i++){
        if (seen[i]) continue;
        if (abs(i-x) < diff){
            diff = abs(i-x);
            ans = i;
        }
    }
    cout << ans;
}


void solveB(){
    int x,y;
    cin >> x >> y;
    if (y%2==1){
        cout << "No";
        return;
    }
    int b = y-2*x;
    b/=2;
    int a = x - b;
    
    if (a>=0 && b>=0){
        cout <<"Yes";
        return;
    }
    cout << "No";
}

void solveA(){
    rep(i,5){
        int x;
        cin >> x;
        if (x==0){
            cout << i+1;
            return;
        }
    }
}

int main(){
    int T;
    T = 1;
    while(T--){
        solveA();
        cout << endl;
    }
}


Measured memory_bytes: 3728
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
cnt = 0
for i in a:
    if i%2:
        cnt += 1
if cnt%2:
    print('NO')
else:
    print('YES')

Measured memory_bytes: 58736
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N, M, i, K, j, tmp, ans=0;
    cin >> N >> M;

    vector< int > F(M);

    for (i=0; i<N; i++){
        cin >> K;
        for (j = 0; j<K; j++){
            cin >> tmp;
            F[tmp-1]++;
        }
    }

    for (i=0; i<M; i++){
        if (F[i]==N) ans++;
    }

    cout << ans << '\n';
}

   

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int w, h, x, y, r;
    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
    if (x >= r && y >= r && (w - x) >= r\
        && (h - y) >= r) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}

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

int main()
{
    ll n;
    cin >> n;
    vector<int> b(n);
    ll ans = 0;
    rep(i, n) {
        ll a;
        cin >> a;
        if(a + i + 1 <= n - 1) b[a + i + 1]++;
        if(a <= i + 1) ans += b[i + 1 - a]; 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3988
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s =new Scanner(System.in);
        int[] a =new int[6];
        while(s.hasNext()){
            for(int i=0;i<6;i++){
                a[i]=s.nextInt();
            }
            double x=(-a[2]*a[4]+a[1]*a[5]) / (double)(-a[0]*a[4]+a[1]*a[3]),
                    y=(a[2]*a[3]-a[0]*a[5]) /  (double)(a[1]*a[3]-a[0]*a[4]);
        if( x == 0 || x == -0 ) x = 0;
        if( y == 0 || y == -0 ) y = 0;
            System.out.printf("%.3f %.3f\n",x,y);
        }
    }

}


Measured memory_bytes: 26156
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

template<typename T>
void chkmax(T& x,T y) { if (y>x) x=y; }
int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=15+5;

int n,m,sumw=0;
vector<pair<int,int>> E[N];
int sum[1<<15],dp[N][1<<15];

int main() {
	n=read(),m=read();
	for (int i=1;i<=m;++i) {
		int u=read()-1,v=read()-1,w=read();
		sumw+=w;
		E[u].emplace_back(make_pair(v,w));
		E[v].emplace_back(make_pair(u,w));
		for (int S=0;S<1<<n;++S)
			if ((S&(1<<u))&&(S&(1<<v)))
				sum[S]+=w;
	}
	memset(dp,0xc0,sizeof(dp)); dp[0][1]=0;
	for (int S=1;S<1<<n;S+=2)
		for (int i=0;i<n;++i) {
			if (!(S&(1<<i))) continue;
			for (auto v:E[i]) {
				int j=v.first,w=v.second;
				if (S&(1<<j)) continue;
				chkmax(dp[j][S|(1<<j)],dp[i][S]+w);
			}
			int US=((1<<n)-1)^S;
			for (int T=US;T;T=(T-1)&US)
				chkmax(dp[i][S|T],dp[i][S]+sum[T|(1<<i)]);
		}
	printf("%d\n",sumw-dp[n-1][(1<<n)-1]);
	return 0;
}

Measured memory_bytes: 6364
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

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

signed main(){
    int n, k;
    cin >> n >> k;
    cout << ceil((double)(n-1) / (k-1)) << endl;

    return 0;
}


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

int main() {
  int n,m,c;
  cin>>n>>m>>c;
  int arr[m];
  long long cnt=0;
  for(int i=0;i<m;i++)
  {
  	cin>>arr[i];
  }
  while(n--)
  { long long sum=0;
  for(int i=0;i<m;i++)
  {
  	int x;
  	cin>>x;
  	sum+=(long long)(x*arr[i]);
  }
  sum+=c;
  if(sum>0)cnt++;
  }
  cout<<cnt;
	return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vll a(n);
  REP(i, n) cin >> a[i];
  ll su = 0;
  ll now = a[0];
  FOR(i, 1, n) {
    if(now > a[i]) {
      su += now - a[i];
    } else {
      now = a[i];
    }
  }
  cout << su << endl;

}








Measured memory_bytes: 4768
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#define llong long long
#define fr(i,l,r) for(i=(l);i<(r);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000//10^12

int main(void)
{
	//変数の宣言
	llong int k,a,b;
	llong int num[5];
	llong int ans;
	llong int i;
	llong int flag;
	llong int mod;
	
	//データの読み込み
	
	scanf("%lld %lld %lld",&k,&a,&b);

//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	if(b-a<=2){
		ans=1+k;
	}else{
		k=k-a+1;
		mod=k%2;
		k=k-mod;
		ans=a+(b-a)*k/2+mod;
	}
	
//	printf("計算部分終了\n");
	
	//出力
	printf("%lld",ans);
	
//	printf("結果の出力終了\n");
	
	return 0;
}



Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)
B = [0] * (N + 1)
for i in range(N, 0, -1):
  j = i * 2
  s = 0
  while (j <= N):
    s += B[j]
    j += i
  B[i] = (s + A[i]) % 2
print(sum(B))
if sum(B) > 0:
  ans = ''
  for i in range(1, N + 1):
    if B[i] == 1:
      ans += str(i) + ' '
  print(ans.strip())

Measured memory_bytes: 9916
def bs_left(A, target):
    low, high = 0, len(A)
    while low<high:
        mid = (low+high)//2
        if A[mid]<target:
            low = mid+1
        else:
            high = mid
    return low

def bs_right(C, target):
    low, high = 0, len(C)
    while low<high:
        mid = (low+high)//2
        if target<C[mid]:
            high = mid
        else:
            low = mid+1
    return low
if __name__ == '__main__':
    N = int(input())

    A = map(int,input().split())
    B = map(int,input().split())
    C = map(int,input().split())
    A = sorted(A)
    B = sorted(B)
    C = sorted(C)

    count = 0
    for i in range(N):
        b = B[i]
        count = count + bs_left(A,b) * (N - bs_right(C,b))
    print(count)


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int h = s[0], w = s[1], a = s[2], b = s[3];

            for (var i = 0; i < b; i++)
                Console.WriteLine(new string('0', a) + new string('1', w - a));

            for (var i = 0; i < h - b; i++)
                Console.WriteLine(new string('1', a) + new string('0', w - a));
        }
    }
}


Measured memory_bytes: 16336
import java.util.Scanner;

public class Main {
    public static long BIG = 1000000007;

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] xs = new int[n];
        int[] ys = new int[m];
        for (int i = 0; i < n; i++) {
            xs[i] = sc.nextInt();
        }
        for (int i = 0; i < m; i++) {
            ys[i] = sc.nextInt();
        }
        long mx = 0;
        long my = 0;
        for (int i = 0; i < n - 1; i++) {
            long d = add(xs[i + 1], -xs[i]);
            long c = (long) (i + 1) * (long) (n - i - 1);
            mx = add(mx, mul(d, c));
        }
        for (int i = 0; i < m - 1; i++) {
            long d = add(ys[i + 1], -ys[i]);
            long c = (long) (i + 1) * (long) (m - i - 1);
            my = add(my, mul(d, c));
        }
        System.out.println(mul(mx, my));
    }

    public static long add(long x, long y) {
        return (x + y) % BIG;
    }

    public static long mul(long x, long y) {
        return (x * y) % BIG;
    }
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();
		double length = l/3.0;
		System.out.println(length*length*length);
	}

}


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

int main() {
  int N;
  cin >> N;
  set<string> s;
  
  string str;
  
  for(int i=0; i < N; i++){
    cin >> str;
    s.insert(str);
  }
  
  cout << s.size() << endl;
	return 0;
}


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

void swap(int *a, int *b){
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}


int main(int argc, const char * argv[]) {
    int a, b, c;
    
    cin >> a >> b >> c;
    
    if(a > b){
        swap(&a, &b);
    }
    if(b > c){
        swap(&b, &c);
    }
    if(a > b){
        swap(&a, &b);
    }
    cout << a << " " << b << " " << c << endl;
    
    return 0;
}



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

using namespace std;

int main(){

 int n;
 cin>>n;

 string s; cin>>s;

 int left=0,right=0;

 for(int i=0;i<s.length();i++){

    if(s[i] == '(') left++;
    else {

      if(left > 0) left--;
      else right++;
    }
 }

 for(int i=0;i<right;i++)
    cout<<'(';

 cout<<s;

 for(int j=0;j<left;j++)
    cout<<')';

 cout<<endl;



return 0;
}



















Measured memory_bytes: 384
/*** akshaykumar99 ***/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long INF = INT_MAX;
const long long LINF = LLONG_MAX;
const long long N = 1e5+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
    string s, t;
    cin>>s>>t;
    if(s.size()==t.size()-1 && s == t.substr(0, s.size()))
    {
        cout<<"Yes\n";
    }
    else
        cout<<"No\n";

}

int32_t main()
{
    IOS(); 
   
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 3652
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, k = map(int, read().split())
x, y = 0, 0
for i in range(1, n + 1):
    if i % k == 0:
        x += 1
    elif i * 2 % k == 0:
        y += 1
print(x ** 3 + y ** 3)


Measured memory_bytes: 2940
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
ll modpow(ll a, ll b, ll m) {
    if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll h = modpow(a, b / 2, m);
        return h * h % m;
    } else {
        return a * modpow(a, b - 1, m) % m;
    }
}
ll comb(ll a, ll b, ll m) {
    if (b > a - b) {
        return comb(a, a - b, m);
    }
    ll c = 1, d = 1;
    REP(i, b) {
        c *= (a - i);
        d *= (b - i);
        c %= m;
        d %= m;
    }
    return c * modpow(d, m - 2, m) % m;
}

ll solve(ll x, ll c, ll d) {
    ll y = lcm(c, d);
    return x - x / c - x / d + x / lcm(c, d);
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    A--;
    ll x = lcm(C, D);
    ll res1 = B - B / C - B / D + B / x;
    ll res2 = A - A / C - A / D + A / x;
    cout << res1 - res2 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
  
public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();
        int x = Integer.parseInt(input);
        int h = x / 3600;
        int m = x % 3600 / 60;
        int s = x % 3600 % 60;
        System.out.println(h + ":" + m + ":" + s);
    }
}

Measured memory_bytes: 24356
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 1987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

ll fac[200001];
ll inv[200001];
ll nCr(int n, int r)
{
	if(r>n)return 0;
	ll c = fac[n];
	c = (c*inv[r]) % MOD;
	c = (c*inv[n - r]) % MOD;
	return c;
}
ll n,a,b,c;
ll tt=POW(100,MOD-2);
ll mul(ll a,ll b){return (a*b)%MOD;}
ll add(ll &a,ll b){a=(a+b)%MOD;}
int main(){
	fac[0] = inv[0] = 1;
	fup(i, 1, 200000, 1)
		fac[i] = (fac[i - 1] * i) % MOD;
	inv[200000] = POW(fac[200000], MOD - 2);
	fdn(i, 199999, 1, 1)
		inv[i] = (inv[i + 1] * (i+1)) % MOD;
	scanf("%lld%lld%lld%lld",&n,&a,&b,&c);
	a=mul(a,tt),b=mul(b,tt),c=mul(c,tt);
	ll ans=0;
	fup(i,n,2*n-1,1)
	{
		ll t=mul(POW(a,n),POW(b,i-n));
		add(t,mul(POW(b,n),POW(a,i-n)));
		t=mul(t,mul(i,nCr(i-1,i-n)));
		t=mul(t,POW(POW(a+b,i),MOD-2));
		add(ans,t);
	}
	ans=mul(ans,POW(1+MOD-c,MOD-2));
	printf("%lld",ans);
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <queue>
#include <algorithm>
#include <functional>

using namespace std;

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
	
struct cxy{
	int cost,x,y;
	bool operator<(const cxy& rhs)const{
		return cost<rhs.cost;
	}
	bool operator>(const cxy& rhs)const{
		return cost>rhs.cost;
	}
};

int CalcTable(int* ret){
	int w,h,x,y;
	scanf("%d%d%d%d",&w,&h,&x,&y);
	static int m[500][500];
	REP(i,h)
		REP(j,w)
			scanf("%d",&m[i][j]);
	ret[0]=0;
	priority_queue<cxy,vector<cxy>,greater<cxy> > pq;
	static bool used[500][500];
	REP(i,h)
		REP(j,w)
			used[i][j]=false;
	pq.push({1,--x,--y});
	used[y][x]=true;
	int c=0;
	static const int dxy[] = {0,-1,0,1,0};
	int b=0;
	while(!pq.empty()){
		cxy t=pq.top();
		pq.pop();
		b=max(b,t.cost);
		ret[++c]=b;
		REP(i,4){
			int nx=t.x+dxy[i];
			int ny=t.y+dxy[i+1];
			if(0<=nx&&nx<w&&0<=ny&&ny<h)
				if(!used[ny][nx]){
					pq.push({m[ny][nx],nx,ny});
					used[ny][nx]=true;
				}
		}
	}
	return w*h+1;
}
	
int main(){
	while(1){
		int r;
		scanf("%d",&r);
		if(r==0)
			break;
		static int buf1[250001];
		static int buf2[250001];
		int r1 = CalcTable(buf1);
		int r2 = CalcTable(buf2);
		int ans=1145141919;
		REP(i,r1){
			int j=r-i;
			if(0<=j&&j<r2)
				ans = min(ans,buf1[i]+buf2[j]);
		}
		printf("%d\n",ans);
	}
}

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

using namespace std;

typedef long long ll;

int H,W;
int h,w;
int A[51][51];
int B[51][51];
int C[51][51];

int main(){

  cin>>H>>W;
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      cin>>A[i][j];
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      cin>>B[i][j];
  cin>>h>>w;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      cin>>C[i][j];
  const ll INF=1LL<<60;
  ll res=-INF;
  for(int i=0;i+h<=H;i++){
    for(int j=0;j+w<=W;j++){
      bool ok=true;
      for(int k=0;k<h;k++){
        for(int l=0;l<w;l++){
          if(C[k][l]!=B[i+k][j+l])
            ok=false;
        }
      }
      if(ok){
        ll sum=0;
        for(int k=0;k<h;k++)
          for(int l=0;l<w;l++)
            sum+=A[i+k][j+l];
        res=max(res,sum);
      }
    }
  }
  if(res==-INF)cout<<"NA"<<endl;
  else cout<<res<<endl;
  
  return 0;
}


Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    string s; cin >> s;
    int n = s.size();
    bool ok = true;
    rep(i, n) {
        if (s[i] != s[n-i-1]) ok = false;
    }
    rep(i, (n-1)/2) {
        if (s[i] != s[(n-1)/2 - i - 1]) ok = false;
    }
    for (int i = (n+3)/2 - 1; i < n; i++) {
        if (s[i] != s[n-i-1]) ok = false;
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 384
n=int(input())
P=[int(i) for i in input().split()]


sc=0
for s in range(n-2):
    if (P[s]<P[s+1]) and (P[s+1]<P[s+2]):
        sc+=1
        #print(P[s],P[s+1],P[s+2])
    elif (P[s]>P[s+1]) and (P[s+1]>P[s+2]):
        sc+=1
        #print(P[s],P[s+1],P[s+2])

print(sc)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define sz(x) int(x.size())
using ll = long long;
using P = pair<int,int>;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;

int main()
{
    int N,K;
    cin >> N >> K;
    vector<int> A(N);
    int ans=0;
    for(int i=0;i<N;i++){
        cin >> A[i];
        if(A[i] >= K){
            ans++;
        }   
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



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

	string S; cin >> S;
	int cnt = 0;
	if (S == "RRR") {
		cout << 3 << endl;
	}
	else if (S == "RRS" || S == "SRR") {
		cout << 2 << endl;
	}
	else if (S == "SSS") {
		cout << 0 << endl;
	}
	else cout << 1 << endl;


	return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using tii = tuple<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}
};

void out(vb v) {
	rep(i, v.size()) {
		cout << (v[i]?'S':'W');
	}
	cout << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vb s(n), ans(n);
	char c;
	rep(i, n) {
		cin >> c;
		s[i] = ((c == 'o') ? true : false);
	}
	rep(i, 4) {
		ans[0] = (i>=2); ans[1] = (i%2==1);
		range(i, 2, n) {
			ans[i] = ((ans[i - 1] == s[i - 1]) ? ans[i - 2] : !ans[i - 2]);
		}
		bool ok = true;
		if ((ans[n - 1] == s[n - 1]) == !(ans[n - 2] == ans[0]))ok = false;
		if ((ans[0] == s[0]) == !(ans[n - 1] == ans[1]))ok = false;
		if (ok) {
			out(ans); return 0;
		}
	}
	cout << -1 << endl;

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    int a, b, c; cin >> a >> b >> c;
    bool ok = false;
    if(a+b >= c) ok = true;
    if(ok) Yes();
    else No();
}


Measured memory_bytes: 256
//2019.12.22
//s1270188 xxxmk2
//alds1_06b

#include<stdio.h>
#include<stdlib.h>

//prototype
int partition(int,int);

//global
int *A, num;

int main(){
  int i, x;

  //input
  scanf("%d",&num);
  A=(int *)malloc(sizeof(int)*num);
  for(i=0;i<num;i++) scanf("%d",&A[i]);

  //paritition
  x=partition(0,num-1);

  //output
  for(i=0;i<num-1;i++){
    if(i==x) printf("[%d] ",A[i]);
    else printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);
  
  free(A);
  return 0;
}

int partition(int p,int r){
  int x, i, j, sub;

  x=A[r];
  i=p-1;

  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      sub=A[i];
      A[i]=A[j];
      A[j]=sub;
    }
  }

  sub=A[i+1];
  A[i+1]=A[r];
  A[r]=sub;

  return i+1;
}




Measured memory_bytes: 2108
#include <iostream>
#include <string>

using namespace std;

int main()	{
  string a, b;
  cin >> a >> b;
  string c = a + b;
  int j = 0, k = 0;
  for (int i = 0; i < a.length() + b.length(); i++)	{
    if (i % 2 == 0)	{
      c[i] = a[j];
      j++;
    }
    else	{
      c[i] = b[k];
      k++;
    }
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 3604
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

const char C[4] = {'A', 'T', 'C', 'G'};

int main(){
  string S; cin >> S;
  int ans = 0, now = 0;
  for (int i = 0; i < S.length(); i++){
    bool flag = false;
    for (int j = 0; j < 4; j++){
      if (S[i] == C[j]) flag = true;
    }
    if (flag) now++;
    else{
      ans = max(ans, now); now = 0;
    }
  }
  ans = max(ans, now);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> L(M), R(M);
    int l = 0, r = N;
    rep(i, M)
    {
        cin >> L[i] >> R[i];
        l = max(l, L[i]);
        r = min(r, R[i]);
    }
    int ans=r-l+1;
    if(ans<0)ans=0;
    cout << ans << endl;
 //   system("pause");
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) begin(x), end(x)
using namespace std;

int main() {
    int M, D; cin >> M >> D;
    int cnt = 0;
    REP3 (m, 1, M + 1) {
        REP3 (d, 1, D + 1) {
            int d10 = d / 10;
            int d1 = d % 10;
            if (d1 >= 2 and d10 >= 2 and d1 * d10 == m) {
                ++ cnt;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = a; i < b; i++)
#define rep(i, n) FOR(i, 0, n)
#define rFOR(i, a, b) for(ll i = a - 1; i >= b; i--)
#define rrep(i, a) rFOR(i, a, 0)
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ld PI = acos(-1);
const ll INF = 1e18;
struct edge{ll to, cost;};

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
      a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll a,b,c,d,e,f,g;
    cin >> a >> b >> c >> d >> e >> f >> g;
    ll res0=a/2*2+d/2*2+e/2*2+(a%2*d%2*e%2*3);
    a--;d--;e--;
    ll ans=b+res0;
    if(a>=0&&d>=0&&e>=0){
        ll res1=3+a/2*2+d/2*2+e/2*2+(a%2*d%2*e%2*3);
        chmax(ans,b+res1);
    }
    cout << ans << '\n';
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 3612