akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3

import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

MOD = 10 ** 9 + 7

n = int(readline())
s = list(readline().rstrip())

r = s.count(ord('R'))
g = s.count(ord('G'))
b = s.count(ord('B'))

count = r * g * b
for i in range(n):
    for j in range(1, min(i + 1, n - i)):
        if s[i - j] != s[i] and s[i] != s[i + j] and s[i - j] != s[i + j]:
            count -= 1

print(count)


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

using namespace std;

template <class T>
T GCD(T a, T b) { return b == 0 ? a : GCD(b, a%b); }

int main()
{
  int N, X; cin >> N >> X;
  vector<int> x(N);
  for (int i = 0; i < N; ++i) cin >> x[i];
  x.push_back(X);

  sort(x.begin(), x.end());

  vector<int> diff(N);
  for (int i = 0; i < N; ++i) {
    diff[i] = x[i+1] - x[i];
  }
  int ans = diff[0];
  for (int i = 1; i < diff.size(); ++i) {
    ans = GCD(ans, diff[i]);
  }

  cout << ans << endl;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    int x[100002], y[100002];
    int d[100002] {0};
    int count[100002];
    for(int i = 1; i <= n; i++) count[i] = 1;
    d[1] = 1;
    int ans = 1;
    for(int i = 0; i < m; i++){
        cin >> x[i] >> y[i];
        count[x[i]]--;
        count[y[i]]++;
        if(d[x[i]] == 1){
            if(count[x[i]] == 0){
                d[x[i]] = 0;
                ans--;
            }
            if(d[y[i]] == 0){
                d[y[i]] = 1;
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(){

  int i,a;
  int b[31]={0};

  for(i=1;i<=28;i++){
    scanf("%d",&a);
    b[a]=1;
  }

  for(i=1;i<=30;i++){
    if(b[i]==0){
      printf("%d\n",i);
    }

  }

  return 0;
}

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

using namespace std;
typedef long long LL;
const LL N=100010;

LL i,n,m,t,mmax,tmp,agcd=0;

int gcd(int x,int y){  
    if(y==0) return x;  
    else return(gcd(y,x%y));  
}  

int main()
{
    scanf("%lld%lld%lld",&n,&m,&agcd);
    mmax=agcd;
    for(i=1;i<n;i++){
        scanf("%lld",&t);
        if(t>mmax)mmax=t;
        agcd=gcd(t,agcd);
    }
    if(mmax>=m&&m%agcd==0)printf("POSSIBLE");
    else printf("IMPOSSIBLE");
    //system("pause");
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
const int MAXN = 200005;
const ll MOD = 998244353;
char str[MAXN];
int y[MAXN];
struct Mint {
	ll val;
	Mint() { val = 0; }
	Mint(const ll& x) {
    val = (-MOD <= x && x <= MOD) ? x : x % MOD;
		if (val < 0) val += MOD;
  }
	friend bool operator==(const Mint& a, const Mint& b) { return a.val == b.val; }
	friend bool operator!=(const Mint& a, const Mint& b) { return !(a == b); }
	friend bool operator<(const Mint& a, const Mint& b) { return a.val < b.val; }
	Mint& operator+=(const Mint& m) { if ((val += m.val) >= MOD) val -= MOD; return *this; }
  Mint& operator-=(const Mint& m) { if ((val -= m.val) < 0) val += MOD; return *this; }
  Mint& operator*=(const Mint& m) { val = (ll)val * m.val % MOD; return *this; }
  friend Mint pow(Mint a, ll p) {
		Mint ans = 1;
		for (; p; p >>= 1, a *= a) if (p & 1) ans *= a;
		return ans;
	}
  Mint& operator/=(const Mint& m) { return *this *= pow(m, MOD - 2); }
  Mint& operator++() { return *this += 1; }
  Mint& operator--() { return *this -= 1; }
  Mint operator++(int) { Mint result(*this); *this += 1; return result; }
  Mint operator--(int) { Mint result(*this); *this -= 1; return result; }
  Mint operator-() const { return Mint(-val); }
  friend Mint operator+(Mint a, const Mint& b) { return a += b; }
	friend Mint operator-(Mint a, const Mint& b) { return a -= b; }
	friend Mint operator*(Mint a, const Mint& b) { return a *= b; }
	friend Mint operator/(Mint a, const Mint& b) { return a /= b; }
	friend ostream& operator<<(ostream& os, const Mint& x) { return os << x.val; }
};
Mint g[MAXN * 2], p2[MAXN * 2];
int main() {
	p2[0] = 1;
	for (int i = 1; i < MAXN * 2; ++i) p2[i] = p2[i - 1] * 2;
	int n;
	scanf("%d%s", &n, str);
	for (int d = 1; d < 2 * n; ++d) {
		if (2 * n % d || n % d == 0) {
			g[d] = 0;
			continue;
		}	
		assert(d % 2 == 0);
		// y[i] = y[i + d]
		for (int i = 0; i < d / 2; ++i) {
			if (str[i] == '1') {
				g[d] += p2[d / 2 - i - 1];
			}
			y[i] = str[i] - '0';
		}
		bool same = true;
		for (int i = d / 2; i < n; ++i) {
			y[i] = 1 - y[i - d / 2];
			if (y[i] < str[i] - '0') {
				break;
			}
			if (y[i] > str[i] - '0') {
				same = false;
				break;
			}
		}
		if (same) ++g[d];
		for (int e = d + d; e <= 2 * n; e += d) {
			g[e] -= g[d];
		}
	}
	++g[2 * n];
	for (int i = 0; i < n; ++i) {
		if (str[i] == '1') {
			g[2 * n] += p2[n - i - 1];
		}
	}
	Mint ans = 0;
	for (int d = 1; d <= 2 * n; ++d) {
		ans += g[d] * d;
	}
	printf("%lld\n", ans.val);
}


Measured memory_bytes: 7424
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size() - 8; i++) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n, x, t = LI()
    print(math.ceil(n/x)*t)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 76516
use proconio::input;
use proconio::marker::Usize1;

fn main() {
    input! {
        n: usize,
        mut es: [(i64, i64); n],
    }
    let mut angles = vec![0.0; n];
    for i in 0..n {
        let e = es[i];
        angles[i] = (e.1 as f64).atan2(e.0 as f64);
    }
    let mut es = angles
        .into_iter()
        .zip(es.into_iter())
        .collect::<Vec<(f64, (i64, i64))>>();
    es.sort_by(|a, b| a.partial_cmp(b).unwrap());
    let mut max = 0;
    for i in 0..n {
        for j in i..n {
            let mut total = vec![0, 0];
            for k in i..j {
                total[0] += (es[k].1).0;
                total[1] += (es[k].1).1;
            }
            max = std::cmp::max(max, total[0] * total[0] + total[1] * total[1]);

            let mut total = vec![0, 0];
            for k in 0..i {
                total[0] += (es[k].1).0;
                total[1] += (es[k].1).1;
            }
            for k in j..n {
                total[0] += (es[k].1).0;
                total[1] += (es[k].1).1;
            }

            max = std::cmp::max(max, total[0] * total[0] + total[1] * total[1]);
        }
    }

    println!("{}", (max as f64).sqrt());
}


Measured memory_bytes: 2992
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
string s;
string str[4]={"dream","dreamer","erase","eraser"};
bool check(int st,int x)
{
	for(int i=st;i<st+str[x].size();i++)if(s[i]!=str[x][i-st])return false;
	return true;
}
int main()
{
	cin>>s;
	int i=0;
	for(;i<s.size();)
	{
		if(s[i]=='d')
		{
			if(i+4>=s.size())break;
			if(i+6<s.size() && s[i+5]=='e' && (i+7==s.size() || s[i+7]!='a'))
			{
				if(check(i,1))i+=7;else break;
			}
			else
			{
				if(check(i,0))i+=5;else break;
			}
		}
		else if(s[i]=='e')
		{
			if(i+4>=s.size())break;
			if(i+5<s.size() && s[i+5]=='r')
			{
				if(check(i,3))i+=6;else break;
			}
			else
			{
				if(check(i,2))i+=5;else break;
			}
		}
		else break;
	}
	if(i==s.size())
	{
		printf("YES");
	}
	else printf("NO");
	return 0;
}

Measured memory_bytes: 512
use std::io;

fn main() {
    loop {
        let mut line = String::new();
        io::stdin().read_line(&mut line).ok();

        let mut iter = line.split_whitespace().map(|w| w.parse::<i32>().unwrap());
        let h = iter.next().unwrap();
        let w = iter.next().unwrap();

        if h == 0 && w == 0 { break; }

        for _ in 0..h {
            for _ in 0..w {
                print!("#");
            }
            println!("");
        }
        println!("");
    }
}



Measured memory_bytes: 5024
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    string w;
    cin >> w;
    int alpha_cnt[26] = {0};
    for (int i = 0; i < w.size(); i++) {
        alpha_cnt[w[i] - 'a']++;
    }
    int cnt = 0;
    for (int i = 0; i < 26; i++) {
        if (alpha_cnt[i] % 2 == 0) cnt++;
    }
    if (cnt == 26) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime> 
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>
 
using namespace std;

const int N = 1e5 + 7;
const int MOD = 1e9 + 7;
const string need = "ABC";

int add(int a, int b) {
	return (a + b) % MOD;
}

int dp[N][4];

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
	int n = (int)s.size();
	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 4; j++) {
			for (char c = 'A'; c <= 'C'; c++) {
				if (s[i] != '?' && s[i] != c) continue;
				dp[i + 1][j] = add(dp[i + 1][j], dp[i][j]);
				if (j < 3 && c == need[j]) {
					dp[i + 1][j + 1] = add(dp[i + 1][j + 1], dp[i][j]);
				}
			}
		}
	}
	cout << dp[n][3] << endl; 
}

Measured memory_bytes: 4840
import java.util.Scanner;

public class Main {

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

        int n = scan.nextInt();
        int k = scan.nextInt();

        int i=0;
        for (;;) {
            n /= k;
            i++;
            if (n == 0) {
                System.out.println(i);
                break;
            }
        }
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#pragma gcc optimize("Ofast")
using namespace std;

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

struct Rect {
	int lti, ltj, rbi, rbj;
	char color;
	const bool operator<(const Rect& r) const {
		return color < r.color;
	}
};

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	int h, w;
	for (int tt = 0; tt < n; tt++) {
		cin >> h >> w;
		vector<string> grid(h);
		rep(i, 0, h) cin >> grid[i];
		set<char> colors;
		rep(i, 0, h) rep(j, 0, w) if (grid[i][j] != '.') colors.insert(grid[i][j]);
	
		vector<Rect> rects;
		bool isbad = false;
		for (char color : colors) {
			int lti = -1, ltj = -1, rbi = -1, rbj = -1;
			rep(i, 0, h) rep(j, 0, w) if (grid[i][j] == color) {
				if (lti == -1) lti = rbi = i, ltj = rbj = j;
				else {
					if (i < lti) lti = i;
					if (j < ltj) ltj = j;
					if (i > rbi) rbi = i;
					if (j > rbj) rbj = j;
				}
			}
			//printf("%c: (%d, %d) - (%d, %d)\n", color, lti, ltj, rbi, rbj);
			
			for (int i = lti; i <= rbi; i++) for (int j = ltj; j <= rbj; j++) if (grid[i][j] == '.') {
				isbad = true;
			}
			rects.push_back(Rect {lti, ltj, rbi, rbj, color});
		}

		if (isbad) {
			cout << "SUSPICIOUS" << endl;
			continue;
		}

		vector<string> grid2(h, string(w, '.'));
		bool isgood = false;

		sort(all(rects));
		do {
			for (Rect r : rects) {
				for (int i = r.lti; i <= r.rbi; i++) for (int j = r.ltj; j <= r.rbj; j++)
					grid2[i][j] = r.color;
			}
			if (grid2 == grid)
				isgood = true;
		} while (next_permutation(all(rects)));

		cout << (!isgood ? "SUSPICIOUS" : "SAFE") << '\n';
	}
}



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

#define MAX 100000

class Queue_c{

private:  
  int time[MAX];
  string name[MAX];
  int head,tail;
  int sum;

public:

  Queue_c();
  bool isEmpty();
  bool isFull();
  void enqueue(string n, int t);
  void dequeue(int q);

};

Queue_c::Queue_c(){
  head = tail = sum = 0;
}
bool Queue_c::isEmpty(){
  return head==tail;
}
bool Queue_c::isFull(){
  return head==(tail+1)%MAX;
}
void Queue_c::enqueue(string n, int t){

  time[tail]=t;
  name[tail]=n; 

  if(++tail == MAX)
    tail = 0;

}
void Queue_c::dequeue(int q){

  
  if(time[head]-q <= 0){
    sum += time[head];
    cout << name[head]+' ' << sum << endl;
    head++;
  }
  else{
    enqueue(name[head],time[head]-q);
    if(++head == MAX){ head = 0; }
    sum += q;
  }
    
}


int main(){

  int n,q;
  int time;
  string name;

  Queue_c Que;


  cin >> n >> q;


  for(int i=0; i<n; i++){
    cin >> name >> time;
    Que.enqueue(name,time);
  }

  while(!Que.isEmpty()){
    
    Que.dequeue(q);

  }


  return 0;

}

Measured memory_bytes: 4720
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		
		int N = scan.nextInt();
		int K = scan.nextInt();
		
		int[] height = new int[N];
		
		for (int i = 0; i < N; i++) {
			height[i] = scan.nextInt();
		}
		
		Arrays.sort(height);
		
		int count = 0;
		for (int i = 0; i < height.length; i++) {
			if (height[i] >= K) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 51028
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		sc.close();
		if(str.contains("A")  && str.contains("B")) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

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

const int MAXN = 100005;

int n;
pii in[MAXN];

int main(){
	ios::sync_with_stdio(0),cin.tie(0);
	int res;
	ll pre;
	while (cin >> n) {
		for (int i = 0; i < n; ++i) {
			ll a, b;cin >> a >> b;
			in[i].first = a - b;
			in[i].second = a + b;
		}
		sort(in, in + n);
		res = 0;
		pre = -2000000000ll;
		for (int i = 0; i < n; ++i) {
			if (pre > in[i].first) {
				res++;
				pre = min(in[i].second, pre);
			}else {
				pre = in[i].second;
			}
		}
		cout << n - res << '\n';
	}
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() 
{
    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    int cost[n+1];
    cost[1]=0;
    cost[2]=abs(a[2]-a[1]);
    for(int i=3;i<=n;i++)
    {
        int x=cost[i-1]+abs(a[i]-a[i-1]);
        int y=cost[i-2]+abs(a[i]-a[i-2]);
        cost[i]=min(x,y);
    }
    cout<<cost[n]<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s1, s2;
	cin >> s1 >> s2;
	if (s1.size() + 1 != s2.size()) {
		cout << "No" << endl;
	}
	else {
		if (s2.substr(0, s1.size()) == s1)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
    IOS();
    ll a,b;
    cin >> a >> b;
    cout << max({a+b,a-b,a*b}) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
typedef double real;

real dp[2][17][1 << 16];
int n, m;
real p[17][17];

int main(){
	cin >> m >> n;
	for(int i = 0;i < m;i++)
		for(int j = 0;j < n;j++)
			cin >> p[i][j];
	
	
	for(int j = 0;j < 17;j++)
		for(int k = 0;k < (1<<16);k++)
			dp[n%2][j][k] = 1;

	for(int i = n-1;i >= 0;i--){
		int id = i % 2;
		for(int k = (1<<m)-1;k >= 0;k--){
			for(int j = 0;j < m;j++){
				dp[id][j][k] = 0;
				if((1<<j) & k)continue;
				dp[id][j][k] = dp[!id][j][k] * p[j][i] + dp[id][16][k | (1<<j)] * (1-p[j][i]);
			}
			dp[id][16][k] = 0;
			for(int j = 0;j < m;j++){
				dp[id][16][k] = max(dp[id][16][k], dp[id][j][k]);
			}
		}
	}

	printf("%.10lf\n", dp[0][16][0]);
	return 0;
}


Measured memory_bytes: 20692
let () =
  let s = read_line () in
  Printf.printf "%d\n" @@ fst @@ 
  Array.fold_left (fun (acc, s) c ->
    match s, c with
    | '1' :: s, '0' | '0' :: s, '1' -> (2 + acc, s)
    | _, _ -> (acc, c :: s)) (0, []) @@
  Array.init (String.length s) @@ String.get s



Measured memory_bytes: 6016
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 998244353
#define int long long
#define inf 2e15
const int minnodes=1005;
#define ll long long

#define EPS 0.000000001
#define N 2000000 


 
int32_t main()
{
    IOS;

    int n;
    cin >> n;
    vector<int> v(n+1);
    bool ch = 1;
    for(int i = 1;i <= n;i++)
    {
        cin >> v[i];

    }
    v[1] -= 1;
    for(int i = 2; i <= n;i++)
    {
        if(v[i] > v[i-1])
            v[i] -= 1;
        if(v[i] < v[i-1])
            ch = 0;
    }
    if(ch)
        cout << "Yes";
    else
        cout << "No";


}
 

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

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

using namespace std;

using ll = long long;

#define FOR(i,n,m) for(ll i=(n);i<(m);++i)
#define REP(i,n) FOR(i,0,n)

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  bool isWake=true;
  int cnt=a;
  for(int t=1;t<4000;t++){
    bool preWake=isWake;
    cnt--;
    if(cnt==0){
      if(isWake){
	cnt=b;
      }else{
	cnt=a;
      }
      isWake=!isWake;
    }
    if((preWake || isWake) && t%60==c){
      cout<<t<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 3088
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		int num[] = new int[4];
		for(int i = 0; i < 4; i++) {
			num[i] = Integer.parseInt(str.substring(i, i + 1));
		}
		
		int ans_ary[] = new int[4];
		ans_ary[0] = num[0];
		
		for(int i = 0; i < Math.pow(2, 3); i++) {
			int ans = num[0];
			for(int j = 0; j < 3; j++) {
				if((1 & i >> j) == 1) {
					ans += num[j + 1];
					ans_ary[j + 1] = num[j + 1];
				} else {
					ans -= num[j + 1];
					ans_ary[j + 1] = -num[j + 1];
				}
			}
			if(ans == 7) {
				break;
			}
		}
		
		String ans_str = String.valueOf(ans_ary[0]);
		for(int i = 0; i < 3; i++) {
			if(ans_ary[i + 1] >= 0) {
				ans_str += "+" + String.valueOf(ans_ary[i + 1]);
			} else {
				ans_str += String.valueOf(ans_ary[i + 1]);
			}
		}
		
		System.out.println(ans_str + "=7");
	}
}

Measured memory_bytes: 25300
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		scan.close();
			
		long sum = 0;
		
		for(int i = 1; i <= n; i++) 
			for(int j = 1; j <= n; j++)
				for(int k = 1; k <= n; k++)
					sum += gdc(i,j,k);
		
		System.out.println(sum);
	}
	
	public static int gdc(int a, int b) {
		if(a < b) {
			int t = a;
			a = b;
			b = t;
		}
		if(a%b == 0) {
			return b;
		}else {
			return gdc(b,a%b);
		}
	}
	
	public static int gdc(int a, int b, int c) {
		return gdc(a,gdc(b,c));
	}
}

Measured memory_bytes: 35740
import sys
from collections import deque

def main():
    input = sys.stdin.readline
    n, m = map(int, input().split())
    roads = [[] for _ in range(n)]
    ans = [0]*n
    for i in range(m):
        a, b = map(int, input().split())
        roads[a-1].append(b-1)
        roads[b-1].append(a-1)
    
    already = [False]*n
    dist = [0]*n
    par = [0]*n
    not_yet = deque(roads[0])
    for v in roads[0]:
        dist[v] = 1
        par[v] = 1
        already[v] = True
    already[0] = True
    
    while not_yet:
        key = not_yet.popleft()
        for v in roads[key]:
            if already[v]:
                continue
            already[v] = True
            par[v] = key+1
            dist[v] = dist[key] + 1
            not_yet.append(v)
    
    if all(already):
        print("Yes")
        for i in range(1, n):
            print(par[i])
    else:
        print("No")
  


if __name__ == "__main__":
    main()

Measured memory_bytes: 39428
#include <cstdio>

using namespace std;

int main(){
	int co[1000], qua[1000];
	int i = 0;
	int sum = 0,ave = 0;
	
	while (scanf("%d,%d", &co[i], &qua[i]) != EOF){
		sum += co[i] * qua[i];
		ave += qua[i];
		i++;
	}
	
	ave = (ave*10)/i + 5;
	ave /= 10;
	
	printf("%d\n%d\n", sum, ave);
}

Measured memory_bytes: 1024
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    if ((s[0] == s[1] && s[1] == s[2]) || (s[2] == s[3] && s[1] == s[2]))yes;
    else no;
}


Measured memory_bytes: 256
W = input()
words = {}
odd = False

for w in W:
    if w in words:
        words[w] = words[w] + 1
    else:
        words[w] = 1

for word in words:
    if words[word] % 2 == 1:
        odd = True
        
if odd:
    print('No')
else:
    print('Yes')

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s; cin >>s;
	int n = sz(s);
	VI ans(n), kgr, atm;
	rep(i, n){
		if(s.substr(i, 2)=="LR" ) kgr.push_back(i+1);
		if(s.substr(i, 2)=="RL" ) atm.push_back(i);
	}
	kgr.push_back(n);
	
	int stt =0;
	rep(i, sz(kgr)){
		int m = kgr[i] - stt;
		ans[atm[i]] = ans[atm[i]+1] = m/2 ;
		if(m%2){
			if(stt%2 == atm[i]%2) ans[atm[i]]++; else ans[atm[i]+1]++;
		}
		stt = kgr[i];
	}
	
	for(auto x :ans) cout<<x<<" "; cout<<"\n";
	return 0;
	
}


Measured memory_bytes: 4260
from collections import Counter

n = int(input())
A = list(map(int, input().split()))

B = set(A)
C = sorted(list(B))
A = Counter(A)


ans = 0
keep = 0

for i in C:
    kazu = A[i]
    if kazu >= 4:
        ans = i**2
        keep = i
    elif kazu >= 2:
        ans = keep * i
        keep = i
print(ans)


Measured memory_bytes: 28584
#include <bits/stdc++.h>
using namespace std;
int n;
int mod(int a,int b)
{
	if(a<0&&a%b!=0)
	{
		n=a/b+1;
		return a-(a/b+1)*b;
	}
	n=a/b;
	return a%b;
}
 
int main()
{
	int r,n2,i;
	char a[20]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J'};//利用字符
	vector<int> array;
	scanf("%d",&n);
	if(n==0)
	{
		printf("0");
		return 0;
	}
	n2=n;
	while(n!=0)
		array.push_back(mod(n,-2));
	for(i=array.size()-1;i>=0;i--)
		printf("%c",a[array[i]]);
	return 0;
}

Measured memory_bytes: 256
from collections import deque

S = input()
Q = int(input())

q = deque()
rev = 0

for s in S:
  q.append(s)

for _ in range(Q):
  TFC = input()
  if len(TFC) == 1: # T == 1
    rev ^= 1
  else:
    T, F, C = (i for i in TFC.split())  
    if (F == '2' and not rev) or (F == '1' and rev):
      q.append(C)
    else:
      q.appendleft(C)
      
ans = ''.join(q)

if rev:
  print(ans[::-1])
else:
  print(ans)

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

using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
const vector<int> c{10, 50, 100, 500};

int main(){
    bool f = false;
    int pay;
    while(cin >> pay, pay){
        if(f)cout << '\n'; else f = true;
        pay = -pay;
        vector<int> hand(4), change(4);
        rep(i, 4){
            cin >> hand[i];
            pay += c[i] * hand[i];
        }
        for(int i=3; i>=0; --i){
            change[i] = pay / c[i];
            pay -= change[i] * c[i];
        }
        rep(i, 4){
            if(hand[i] <= change[i])continue;
            cout << c[i] << ' ' << hand[i] - change[i] << '\n';
        }
    }
    return 0;
}

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

using namespace std;

typedef pair<int,int> pii;

#define size(x) ((int) x.size())

const int MAXN = 100 + 5;

char ch[MAXN][MAXN];

int n, m;

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; i++) 
        for (int j = 0; j < m; j++)
            cin >> ch[i][j];
    for (int i = 0; i <= m + 1; i++)
        cout << "#";
    cout << endl;
    for (int i = 0; i < n; i++) {
        cout << "#";
        for (int j = 0; j < m; j++)
            cout << ch[i][j];
        cout << "#" << endl;
    }
    for (int i = 0; i <= m + 1; i++)
        cout << "#";
    cout << endl;
    return 0;
}


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

int main(void){
    string s;
    int a[30];
    for (int i = 0; i < 26; i++) a[i] = 0;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        a[s[i] - 'a'] = i + 1;
    }
    
    if (s.size() != 26) {
        cout << s;
        for (int i = 0; i < 26; i++) {
            if (a[i] == 0) {
                cout << (char)(i + 97) << endl;
                return 0;
            }
        }
    }
    
    for (int i = 24; i >= 0; i--) {
        if (s[i] < s[i + 1]) {
            for (int j = 0; j < i; j++) cout << s[j];
            for (int k = 0; s[i] - 'a' + k < 26; k++){
                if (a[s[i] - 'a' + k + 1] > i) {
                    cout << char(s[i] + k + 1);
                    return 0;
                }
            }
        }
    }
    
    if (s == "zyxwvutsrqponmlkjihgfedcba") cout << -1 << endl;
    
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();

    int ans = 0;
    for (int i = 0; i < 2; i++) {
      if (A > B) {
        ans += A;
        A--;
      } else {
        ans += B;
        B--;
      }
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
#include <cstdio>
#include <vector>
using namespace std;

bool con1[200001];
bool conN[200001];
int N, M;

void add(int a, int b)
{
	if (a > b) {
		add(b, a);
		return;
	}
	if (a == 1)
		con1[b] = true;
	if (b == N)
		conN[a] = true;
}

int main()
{
	int a, b;
	scanf("%d %d", &N, &M);
	while (M--) {
		scanf("%d %d", &a, &b);
		add(a, b);
	}
	for (int i = 2; i < N; i++) {
		if (con1[i] && conN[i]) {
			printf("POSSIBLE\n");
			return 0;
		}
	}
	printf("IMPOSSIBLE\n");
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
//ミョ(-ω- ?)
int main() {
    int n;
    cin >> n;
    vector<int> a(n,0);
    int sum = 0;
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    int c = (sum+n-1)/n;
    int f = sum/n;

    int cost[2] = {0,0};
    rep(i,n){
        cost[0] += pow(c-a[i],2);
        cost[1] += pow(f-a[i],2);
    }
    cout << min(cost[0],cost[1]) << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    tokens = lines[0].split(" ")
    n = int(tokens[0])
    x = int(tokens[1])
    ls = [int(l) for l in lines[1].split(" ")]

    return (n, x, ls)


def solve(n, x, ls):

    d = 0
    count = 1
    for i in range(0, n):
        d = d + ls[i]
        if d <= x:
            count = count + 1
        else:
            break


    return count


def main():
    # 出力

    print("%s" % solve(*parse_input()))

#    solve(*parse_input())

if __name__ == '__main__':

    main()


Measured memory_bytes: 3064
N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]+[float("inf")]*(N-1)
for i in range(N):
    for k in range(1,K+1):
        if i+k > N-1:
            break
        dp[i+k] = min(dp[i+k],dp[i]+abs(h[i+k]-h[i]))
print(dp[N-1])


Measured memory_bytes: 55136
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  char sb = S[0];
  int ans=1;
  for(int i=1;i<N;i++){
    if (sb!=S[i]) ans++;
    sb=S[i];
  }
  cout << ans;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define str string

ll MOD = 1000000007, INFL = 1ll << 60, INF = 1 << 30,mod = 1e9 + 7,Max = INF, Min = -1;
ll a = 0, b = 0,c = 0, n = 0, sum = 0;
ll A[500000] = {}, B[500000] = {},ruiseki[500000] = {},dp[100][10] = {};
int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
vector <ll> v;
str S;
bool check = false, check2 = false;

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

int main() {

	//Code Line
cin >> n >> a >> b;
cout << min(n*a,b) << endl;

		return 0;
	}


Measured memory_bytes: 256
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
using namespace std;
int find(int n,int r)
{
	int x=1,y=1;
	for(int i=n;i>=n-r+1;i--)
		x=(x*i)%mod;
	for(int i=r;i>=1;i--)
		y=(y*i)%mod;
//	cout<<x<<" "<<y<<endl;
	int p=mod-2;
	int inverse=power(y,p)%mod;
	int ans=(x*inverse)%mod;
	return ans%mod;
}
int solve()
{
	int n,a,b;
	cin>>n>>a>>b;
	int total_ways=(power(2,n)-1)%mod;
	int x=find(n,a)%mod;
	int y=find(n,b)%mod;
	total_ways=modsub(total_ways,x);
	total_ways=modsub(total_ways,y);
	cout<<total_ways<<endl;
}
signed main()
{
	fastio;
	clock_t start, end;
//	test
	{
		start=clock();
		solve();
		end=clock();
		double time_taken=double(end-start)/double(CLOCKS_PER_SEC);
//		cout<<time_taken<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <complex>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1e9+7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX

ll mpow(ll a, ll b){
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= MOD;
	if(b%2) t1 *= a;
	t1 %= MOD;
	return t1;
}

void solve(){
	string s;
	cin >> s;
	ll ans = 0;
	ll c = 0;
	forn(i,(ll)s.size()-1){
		if(s[i]=='A') c++;
		else if(s[i]=='B' && s[i+1]=='C'){
			ans += c;
			s[i-c]='B';
			s[i-c+1]='C';
			i++;
		}
		else{
			c = 0;
		}
	}
	cout << ans << ln;
}


int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    // cin >> t;
    forn(i,t) solve();
    return 0;
}

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

#define ll long long

const int Nmax = 100;
int A[Nmax];

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

  int n;
  ll res = 1000;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> A[i];
    if (i > 0 && A[i] > A[i - 1]) {
      ll unit = res / A[i - 1];
      res = res - unit * A[i - 1] + unit * A[i];
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3664
#include <stdio.h>
int main(void)
{
    long int n, a[10*10*10*10*10*10], ans, cnteven[10*10*10*10*10*10], i;
    long int cntodd[10*10*10*10*10*10], maxeven=0, maxodd=0, max=0,
        evenidx, oddidx;
    long int maxodd2=0, maxeven2=0;
    scanf("%d", &n);
    for(i=0;i<n;i++){
        scanf("%d", &a[i]);
        if(a[i]>max) max=a[i];
    }

    for(i=0;i<n;i++){
        if(i%2==0) cnteven[a[i]]++;
        else cntodd[a[i]]++;
    }

    for(i=0;i<=max;i++){
        if(maxeven<cnteven[i]){
            maxeven2=maxeven;
            maxeven=cnteven[i];
            evenidx=i;
        }
        else if(maxeven2<cnteven[i]){
            maxeven2=cnteven[i];
        }
        if(maxodd<cntodd[i]){
            maxodd2=maxodd;
            maxodd=cntodd[i];
            oddidx=i;
        }
        else if(maxodd2<cntodd[i]){
            maxodd2=cntodd[i];
        }
    }

    if(oddidx != evenidx) ans=n-maxeven-maxodd;
    else if(n-maxodd-maxeven2<n-maxodd2-maxeven) ans=n-maxodd-maxeven2;
    else ans=n-maxodd2-maxeven;
    
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 9088
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define all(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    ans += 1;
    int dis = 0;
    while (i + dis < N and S[i] == S[i + dis + 1]) {
      dis += 1;
    }
    i = i + dis;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=9e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,m,a[25][25]={},b[25]={},c,ans=0,cnt=0;
  cin >> n >> m >> c;
  for(int i=0; i<m; i++) {
    cin >> b[i];
  }
  for(int i=0; i<n; i++) {
    for(int j=0; j<m; j++) {
      cin >> a[i][j];
    }
  }
  for(int i=0; i<n; i++) {
    cnt=0;
    for(int j=0; j<m; j++) {
      cnt+=a[i][j]*b[j];
    }
    cnt+=c;
    if(cnt>0) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    d,t,s=MI()
    
    tt=d/s
    
    if t<tt:
        print("No")
    else:
        print("Yes")

main()


Measured memory_bytes: 61844
#include <cmath>
#include <iostream>
#include <algorithm>
#include <list>

struct Point
{
    double x;
    double y;
};
typedef std::list<Point> List;
Point GetU(const Point& s, const Point& t)
{
    const double thete = 60. / 180. * M_PI;
    Point st = {t.x - s.x, t.y - s.y};
    Point su = {st.x * std::cos(thete) - st.y * std::sin(thete), st.x * std::sin(thete) + st.y * std::cos(thete)};
    Point u = {s.x + su.x, s.y + su.y};
    return u;
}
void InsertKochCurve(List& list, List::iterator p1, List::iterator p2, int n)
{
    if(!n) return;
    double x = (p2->x - p1->x) / 3;
    double y = (p2->y - p1->y) / 3;
    Point s = {p1->x + x, p1->y + y};
    Point t = {p2->x - x, p2->y - y};
    Point u = GetU(s, t);
    List::iterator ti = list.insert(p2, t);
    List::iterator ui = list.insert(ti, u);
    List::iterator si = list.insert(ui, s);
    
    InsertKochCurve(list, p1, si, n - 1);
    InsertKochCurve(list, si, ui, n - 1);
    InsertKochCurve(list, ui, ti, n - 1);
    InsertKochCurve(list, ti, p2, n - 1);
}
void Output(const List& list)
{
    for(List::const_iterator i = list.begin();
        i != list.end();
        ++i)
    {
        std::cout << i->x << " " << i->y << std::endl;
    }
}

int main()
{
    int n;
    std::cin >> n;
    List list;
    Point alpha = {  0, 0};
    Point omega = {100, 0};
    list.push_back(alpha);
    list.push_back(omega);
    InsertKochCurve(list, list.begin(), --list.end(), n);
    Output(list);
    return 0;
}

Measured memory_bytes: 1468
#include<stdio.h>
int main(void){
	int n;
	scanf("%d",&n);
	if(n>=195) printf("5\n");
	else if(n>=189) printf("4\n");
	else if(n>=165) printf("3\n");
	else if(n>=135) printf("2\n");
	else if(n>=105) printf("1\n");
	else printf("0\n");
	return 0;
}

Measured memory_bytes: 128
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

 main()

{
    fast
    int n;
    cin>>n;
    int a[n+2];
    f(i,1,n)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    reverse(a+1,a+n+1);
    int baki=n-2;
    int ses=a[1];
    int pos=2;
    while(1)
    {
       if(baki<=0)break;
       if(baki>=2)
       {
           baki-=2;
           ses+=(a[pos]);
           ses+=(a[pos]);
           pos++;
           if(baki==0)break;
       }
       else if(baki==1)
       {
           baki-=1;
           ses+=a[pos];
           pos++;
           if(baki==0)break;
       }
    }
    cout<<ses<<endl;

    return 0;

}





































Measured memory_bytes: 5220
import sys
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
index = n - m + 1


def check(a, b):
    for u, v in zip(a, b):
        for i in range(m):
            if u[i] == v[i]:
                pass
            else:
                return False
    return True


for i in range(index):
    x = a[i:i + m]
    for j in range(index):
        r = []
        for w in x:
            y = w[j:j+m]
            r.append(y)
        if check(r, b):
            print("Yes")
            sys.exit()

print("No")





Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

vector<int> IntegerToVerctor(int bit, long long N)
{
    vector<int> S;
    for (int i = 0; i < N; ++i)
    {
        if (bit & (1 << i))
        {
            S.push_back(i);
        }
    }
    return S;
}

int main()
{
    long long N, M, X;
    cin >> N >> M >> X;
    vector<long long> C(20);
    vector<vector<long long>> A(20, vector<long long>(20));
    for (int i = 1; i <= N; i++)
    {
        cin >> C[i];
        for (int j = 1; j <= M; j++)
        {
            cin >> A[i][j];
        }
    }
    long long mincost = 100000000;
    long long cost;
    bool flag;
    vector<int> sum(20);
    for (int bit = 0; bit < (1<<N); ++bit)
    {
        cost = 0;
        flag = 1;
        for (int j = 1; j <= M; j++)
        {
            sum[j] = 0;
        }
        vector<int> S = IntegerToVerctor(bit, N);
        for (int i : S)
        {
            cost += C[i + 1];
            for (int j = 1; j <= M; j++)
            {
                sum[j] += A[i + 1][j];
            }
        }
        for (int i = 1; i <= M; i++)
        {
            if(sum[i] < X)
            {
                flag = 0;
                break;
            }
        }
        if(flag == 1)
        {
            mincost = min(cost, mincost);
        }

    }

    if (mincost == 100000000)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << mincost << endl;
    }
    
    return 0;
}




Measured memory_bytes: 3608
#include <iostream>
#include <cctype>

/** memo
 * expr ::= term { ( '+' | '-' ) term }
 * term ::= fact { ( '*' | '/' ) fact }
 * fact ::= '(' expr ')' | digit
 **/

using namespace std;

int expr();
int term();
int fact();

char buf[101];
int p;

int expr() {
	int v = term();
	while(buf[p] == '+' || buf[p] == '-') {
		if(buf[p] == '+') {
			p++;
			v += term();
		}
		else {
			p++;
			v -= term();
		}
	}
	return v;
}


int term() {
	int v = fact();
	while(buf[p] == '*' || buf[p] == '/') {
		if(buf[p] == '*') {
			p++;
			v *= fact();
		}
		else {
			p++;
			v /= fact();
		}
	}
	return v;
}

int fact() {
	int v = 0;
	if(buf[p] == '(') {
		p++;
		v = expr();
		p++; // skip ')'
	}
	else {
		while(isdigit(buf[p])) {
			v = v * 10 + buf[p] - '0';
			p++;
		}
	}
	return v;
}

int main() {
	int times;
	int ans;

	cin >> times;
	for(int i = 0; i < times; i++) {
		cin >> buf;
		p = 0;
		ans = expr();
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1164