akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m+1;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;


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


int main(){
  int count1,count2;
  count1 =1;
  count2 =1;
  string S;cin >> S;
  int a,b,c;
  a =0;
  b =0;
  c= 0;
  char tem='0';
    if(S[0]==S[1]){
      if(S[2]==S[3] && S[0] != S[2]){
        a=1;
      }
    }else if(S[0]==S[2]){
      if(S[1]==S[3] && S[0] != S[1]){
        a=1;
      }
  }else if(S[0]==S[3]){
    if(S[1]==S[2] && S[0] != S[1]){
      a=1;
    }
  }

  if(a){
    cout <<"Yes"<<endl;
  }else{
    std::cout << "No" << '\n';
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int A[128],N;

int main(){
  A[0]=1;
  A[1]=1;
  A[2]=2;
  for(int i=3;i<=30;i++){
    A[i]=A[i-1]+A[i-2]+A[i-3];
  }
  while(cin >> N && N){
    cout << (A[N]+3649)/3650 << endl;
  }

}



Measured memory_bytes: 2984
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
 
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.map!(to!int).array; }
 
void calc(string s) {
    int a = s[0] - '0';
    int b = s[1] - '0';
    int c = s[2] - '0';
    int d = s[3] - '0';
 
    int reduce(int lhs, int rhs, int op) {
        return op == 0 ? lhs + rhs : lhs - rhs;
    }
    char op(int op) {
        return op == 0 ? '+' : '-';
    }
 
    for (int i = 0; i < 2; i++) {
        int x = reduce(a, b, i);
        for (int j = 0; j < 2; j++) {
            int y = reduce(x, c, j);
            for (int k = 0; k < 2; k++) {
                int z = reduce(y, d, k);
                if (z == 7) {
                    // writeln(a, op(i), b, op(j), c, op(k), d, "=7");
                    writefln("%s%s%s%s%s%s%s%s", a, op(i), b, op(j), c, op(k), d, "=7");
                    return;
                }
            }
        }
    }
}
 
void main() {
    auto s = readln.chomp;
    calc(s);
}

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

int main(){
    ll N;
    cin >>N;
    vector<ll> P(N);
    for (int i = 0; i < N; ++i) cin >> P[i];

    ll cnt = 0;
    ll minj = P[0];
    for (int i = 0; i < N; ++i) {
      minj = min(minj, P[i]);
      if (P[i] <= minj) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
  int a;
  int b;
  
  cin >> a >> b;
  
  if(((a * b) % 2) == 0){
  	cout << "Even" << endl;
  }else{
  	cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 10;
    // const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 179;
    // const ld PI = 3.1415926535;
#endif

// #pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")`

const int MAXN = 1e5 + 1;

int n, k;
vector<int> g[MAXN];

const int mod = 1e9 + 7;

int ans = 1;

void dfs(int v, int p, int d, int cur) {
    if (cur <= 0) ans = 0;
    ans *= cur;
    ans %= mod;
    int f = k - 1;
    if (d) f--;
    for (auto u : g[v]) {
        if (u != p) {
            dfs(u, v, d + 1, f);
            f--;
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    int u, v;
    for (int i = 0; i < n - 1; i++) {
        cin >> u >> v;
        u--, v--;
        g[u].pb(v);
        g[v].pb(u);
    }
    dfs(0, 0, 0, k);
    cout << ans;
}
/*

*/
    


Measured memory_bytes: 10368
a = [int(x) for x in input().split(" ")]
if a[0] < 2 or a[1] < 2:
    print(1)
    exit()
kisu = a[0] // 2 if a[0] % 2 == 0 else a[0] // 2 + 1
gusu = a[0] // 2
yokokisu = a[1] // 2 if a[1] % 2 == 0 else a[1] // 2 + 1
yokogusu = a[1] // 2
ans = kisu * yokokisu + gusu * yokogusu
print(ans)

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

int main(){
	
	int d[4]={0};
	int r[4]={6000,4000,3000,2000};
	
	for(int i=0;i<4;i++){
		int a,b;
		cin>>a>>b;
		d[a-1]=b;
		cout<<d[a-1]*r[a-1]<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 1160
<?php
// $n = (int)trim(fgets(STDIN));
$input = explode(' ', trim(fgets(STDIN)));

$n = (int)$input[0];
$k = (int)$input[1];
$mod = 1000000007;

$res = [];
for ($i=1; $i <= $k; $i++) { 
	$first = comb($n-$k+1, $i);
	if ($i === 1) {
		$second = 1;
	}else{
		$second = comb($k-1, $i-1);
	}
	$res[] = ($first * $second) % $mod;
}
echo implode(PHP_EOL, $res);

function comb($left, $right){
	if ($left === 0 && $right === 0) {
		return 1;
	}
	if ($left < $right || $left < 0) {
		return 0;
	}
	$mod = 1000000007;
	// $mod = 1000000007;
	$r_tbl[0] = 1;
	for($i = 1; $i <= 2001; $i++){
		$r_tbl[$i] = $r_tbl[$i-1] * $i % $mod;
	}
	// echo $left . ' ' . $right . PHP_EOL;
	return ((($r_tbl[$left] * my_pow($r_tbl[$right], $mod-2, $mod)) % $mod) * my_pow($r_tbl[$left-$right],$mod-2, $mod)) % $mod;
}
function my_pow($x, $n, $mod){
	$ans = 1;
	$bin = decbin($n);
	$cur_pos = strlen($bin) -1;
	while ($cur_pos >= 0) {
		if ($bin[$cur_pos] == '1') {
			$ans = ($ans * $x) % $mod;
		}
		$x = ($x * $x) % $mod;
		--$cur_pos;
	}
	return $ans;
}


Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
long long int a[2000005];
int main()
{
    int i,n;
    scanf("%d",&n);
    multiset<long long int>st;
    multiset <long long int > :: iterator itr;
    for(i=0; i<n; i++)
    {
        scanf("%lld",&a[i]);
        a[i]-=i+1;
        //printf("%lld\n",a[i]);

    }
    long long int ans=0;
    sort(a,a+n);
    for(i=0; i<n; i++)
    {
        ans+=abs(a[i]-a[n/2]);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1792
using System;
using System.Linq;

namespace AtCoder.Question
{
    public class QuestionC
    {
        public static void Main(string[] args)
        {
            var (a, b) = ReadValue<decimal, decimal>();
            Console.WriteLine(Math.Floor(a * b));
        }
        static T ReadValue<T>()
        {
            return (T)Convert.ChangeType(Console.ReadLine(), typeof(T));
        }
        static (T1, T2) ReadValue<T1, T2>()
        {
            var input = Console.ReadLine().Split(' ');
            return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)));
        }
        static (T1, T2, T3) ReadValue<T1, T2, T3>()
        {
            var input = Console.ReadLine().Split(' ');
            return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)), (T3)Convert.ChangeType(input[2], typeof(T3)));
        }
        static (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>()
        {
            var input = Console.ReadLine().Split(' ');
            return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)), (T3)Convert.ChangeType(input[2], typeof(T3)), (T4)Convert.ChangeType(input[3], typeof(T4)));
        }
        static T[] ReadValues<T>()
        {
            var input = Console.ReadLine().Split(' ');
            return input.Select(x => (T)Convert.ChangeType(x, typeof(T))).ToArray();
        }
    }
}


Measured memory_bytes: 27664
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
#define F first
#define S second
int fa[N];
pair<int,int> que[N];
int n,u,v,Head,Tail,cnt;
set<int> s[N];
set<int> :: iterator it;
map<pair<int,int>,int> Map;
inline int read(){
    int num=0; char ch=getchar();
    while (ch<'0' || ch>'9') ch=getchar();
    while (ch>='0' && ch<='9') num=(num<<3)+(num<<1)+ch-'0',ch=getchar();
    return num;
}
int find(int u){ return fa[u]==u?u:fa[u]=find(fa[u]); }
int main(){
    // freopen("B.in","r",stdin);
    // freopen("B.out","w",stdout);
    n=read();
    Head=1; Tail=0;
    for (int i=1; i<=2*n-2; i++){
        u=read(); v=read();
        s[u].insert(v); s[v].insert(u);
        Map[make_pair(u,v)]++;
        Map[make_pair(v,u)]++;
        if (Map[make_pair(u,v)]==2) que[++Tail]=make_pair(u,v);
    }
    for (int i=1; i<=n; i++) fa[i]=i;
    while (Head<=Tail){
        int u=find(que[Head].F),v=find(que[Head].S); Head++;
        s[u].erase(v); s[v].erase(u);
        if (s[u].size()<s[v].size()) swap(u,v);
        for (it=s[v].begin(); it!=s[v].end(); it++){
            int x=*it;
            s[x].erase(v);
            Map[make_pair(v,x)]=Map[make_pair(x,v)]=0;
            s[u].insert(x); s[x].insert(u);
            Map[make_pair(u,x)]++; Map[make_pair(x,u)]++;
            if (Map[make_pair(u,x)]==2) que[++Tail]=make_pair(u,x);
        }
        fa[v]=u; s[v].clear();
    }
    for (int i=1; i<=n; i++) cnt+=(i==fa[i]);
    if (cnt==1) puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 105984
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}

macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let cs: Vec<char> = sc.cin::<String>().chars().collect();
    let mut ds = vec![];
    {
        let mut i = 0 ;
        while i < cs.len() {
            if cs[i] == 'A' {
                ds.push('A');
                i += 1;
            } else if cs[i] == 'B' && i < cs.len() - 1 && cs[i + 1] == 'C' {
                ds.push('@');
                i += 2;
            } else {
                ds.push('X');
                i += 1;
            }
        }
    }
    // trace!(&ds);
    let mut ans: u64 = 0;
    let mut ac = 0;
    for &d in ds.iter() {
        match d {
            'A' => {
                ac += 1;
            }
            '@' => {
                ans += ac;
            }
            _ => {
                ac = 0;
            }
        }
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 6396
/**
 *    author: Behradm
 *    Created: 02.06.2020 12:23:34
 *    In the Name of God
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int dh = h2 - h1;
  int dm = m2 - m1;
  int res = dh * 60 + dm;
  cout << res - k << '\n';
  return 0;
}




Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int W,H,N;
    cin >> W >> H >> N;
    vector<vector<int> >vec(N, vector<int>(3));
    rep(i,N){
        rep(j,3){
            cin >> vec[i][j];
        }
    }
    vector<vector<int> > rect(W,vector<int>(H));
    rep(i,W){
        rep(j,H){
            rect[i][j] = 0;
        }
    }
    rep(i,N){
        if (vec[i][2] == 1){
            rep(j,vec[i][0]){
                rep(k,H){
                    rect[j][k] = 1;
                }
            }
        }
        else if (vec[i][2] == 2){
            for (int j = vec[i][0]; j < W; j++){
                rep(k,H){
                    rect[j][k] = 1;
                }
            }
        }
        else if (vec[i][2] == 3){
            rep(j,vec[i][1]){
                rep(k,W){
                    rect[k][j] = 1;
                }
            }
        }
        else if (vec[i][2] == 4){
            for (int j = vec[i][1]; j < H; j++){
                rep(k,W){
                    rect[k][j] = 1;
                }
            }
        }
    }
    int count = 0;
    rep(i,W){
        rep(j,H){
            if (rect[i][j] != 1){
                count++;
            }
        }
    }
    cout << count << endl;
}



Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
   int n , m ;
   cin>>n>>m;
   if(n+m==15) {
    cout<<"+";
    return 0;
   }
   if(n*m==15) {
    cout<<"*";
    return 0;
   }
   cout<<"x";


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a;
  string ans;
  cin >> n >> a;
  
  if ( n % 500 - a <= 0){
    ans = "Yes";
  }
  else {
    ans = "No";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int d,n,i;
  int num = 1;
  
  if(scanf("%d %d",&d,&n)){
  
      if(d == 1 && n != 100){
        num = 100 * n;
      }
     else if(d == 1 && n == 100){
        num = 10100;
      }
      else if(d == 2 && n != 100){
        num = 10000 * n;
      }
     else if(d == 2 && n == 100){
        num = 1010000;
      }
      else if(d == 0 && n != 100){
        num = n;
      }
       else if(d == 0 && n == 100){
        num = 101;
      }
      printf("%d",num);
  }
  return 0;
}

Measured memory_bytes: 128
R,C,N = map(int,input().split())

def outer_pos(x,y):
    if (0 < x < R) and (0 < y < C): return -1
    if y == 0: return x
    if x == R: return R + y
    if y == C: return R + C + (R-x)
    return R + C + R + (C-y)

outer = []
for i in range(N):
    x1,y1,x2,y2 = map(int,input().split())
    p1 = outer_pos(x1,y1)
    p2 = outer_pos(x2,y2)
    if p1 < 0 or p2 < 0: continue
    outer.append((p1,i))
    outer.append((p2,i))
outer.sort()

stack = []
for p,i in outer:
    if len(stack) == 0 or stack[-1] != i:
        stack.append(i)
    else:
        stack.pop()
print('NO' if stack else 'YES')

Measured memory_bytes: 27720
#define  _USE_MATH_DEFINES

#define  rep(i, n) for(int i = 0; i < n; i++)
#define  repx(i, a, n) for(int i = a; i < n; i++)
#define  loop while(1)
#define  lli long long int
 
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <utility>
#include <set>

using namespace std;
  
int main() {
  
  int h, w;
  cin >> h >> w;
  
  vector<string> grid(h, string());
  rep (i, h) cin >> grid[i];
  
  /*
  rep (i, h) {
    if (count(grid[i].cbegin(), grid[i].cend(), '#') == 0)
      grid[i].replace(grid[i].begin(), grid[i].end(), w, 'x');
  }
  */
  
  rep (i, h) {
    int cnt = 0;
    rep (j, w) if (grid[i][j] == '#') cnt += 1;
    if (cnt == 0) rep (j, w) grid[i][j] = 'x';
  } 
  
  rep (i, w) {
    int cnt = 0;
    rep (j, h) if (grid[j][i] == '#') cnt += 1;
    if (cnt == 0) rep (j, h) grid[j][i] = 'x';
  }   
  
  rep (i, h) {
    int cnt = 0;
    rep (j, w) {
      if (grid[i][j] != 'x') {
        cout << grid[i][j];
        cnt += 1;
      }
    }
    if (cnt > 0) cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using IP = pair<int, P>;
using LLP = pair<ll, LP>;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

// template specialization of std::hash for std::pair
namespace std {
template<typename T, typename U>
struct hash<pair<T, U> > {
    size_t operator()(const pair<T, U> &key) const noexcept {
        size_t h1 = hash<T>()(key.first);
        size_t h2 = hash<U>()(key.second);
        return h1 ^ (h2 << 1);
    }
};
} // namespace std

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    size_t sz = v.size();
    os << "[";
    for (size_t i = 0; i < sz-1; i++) {
        os << v[i] << ", ";
    }
    os << v[sz-1] <<  "]";
    return os;
}

template<typename T>
void printArray(T *arr, size_t sz) {
    cerr << "[";
    for (size_t i = 0; i < sz-1; i++) {
        cerr << arr[i] << ",";
    }
    cerr << arr[sz-1] <<  "]" << endl;
}

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

struct Compare {
    //vector<ll> &x_, &y_;
    //Compare(vector<ll> &x, vector<ll> &y): x_(x), y_(y) {}
    //bool operator()(const P &lhs, const P &rhs) {
    //    return x_[lhs.fi]+y_[lhs.se] < x_[rhs.fi]+y_[rhs.se];
    //}
    bool operator()(const int x, const int y) {
        return x < y;
    }
};

// print floating-point number
// cout << fixed << setprecision(12) <<

// }}}

int N, K;
int p[200010];
double e[200010];

void solve()
{
    REP (i, N) {
        e[i] = (double)(p[i]*(p[i]+1)) / 2;
        e[i] /= p[i];
    }
    double ans, exp = 0.;
    REP (i, K) {
        exp += e[i];
    }
    ans = exp;
    FOR (i, K, N) {
        exp = exp + e[i] - e[i-K];
        ans = max(ans, exp);
    }
    cout << fixed << setprecision(12) << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    REP (i, N) cin >> p[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 2560
use proconio::input;

fn main() {
    input!(n: usize, a: [proconio::marker::Usize1; n]);
    let mut ans = 0;
    let mut l = 0;
    let mut r;
    while l < n {
        while l < n && a[l] != l {
            l += 1;
        }
        r = l;
        while r < n && a[r] == r {
            r += 1;
        }
        ans += (r - l + 1) / 2;
        l = r;
    }
    println!("{}", ans);
}


Measured memory_bytes: 3204
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int s; cin >> s;

    const int v = 1000000000;

    int x = (v - s % v) % v;
    int y = (s + x) / v;

    cout << "0 0 1000000000 1 " << x << " " << y << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

d,n = map(int,input().split())
if n != 100:
    print(n*100**d)
else:
    print(101*100**d)

Measured memory_bytes: 3316
#include<iostream>
#include<cstring>
#include<math.h>
#include<stdlib.h>
#include<cstring>
#include<cstdio>
#include<utility>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;
const int Max = 2*1e5+5;
const int mod = 1e9+7;
const int Hash = 10000;
const int INF = 1<<30;
const ll llINF = 1e18;

int n, m;
struct edge
{
    int start, finish, w;
};
struct node
{
    int a,b, index;
};
node in[Max];//点的输入
edge arr[Max];//储存所有的边，在该数组上跑克鲁斯卡尔算法，O(nlogn)
bool cmp1(const node& t1, const node& t2)
{
    return t1.a<t2.a;
}
bool cmp2(const node& t1, const node& t2)
{
    return t1.b<t2.b;
}
bool cmp3(const edge& t1, const edge& t2)
{
    return t1.w<t2.w;
}
int isvisited[Max];
void init( )
{
    for(int i=0; i<Max; i++)
        isvisited[i] = i;
}
int f(int k)
{
    if(k != isvisited[k])
        isvisited[k] = f(isvisited[k]);
    return isvisited[k];
}
int main( )
{
    //freopen("input.txt", "r", stdin);
    while(~scanf("%d", &n))
    {
        for(int i=0; i<n; i++)
        {
            scanf("%d%d", &in[i].a, &in[i].b);
            in[i].index = i;
        }
        //将所有的可能生成树中的边都加到数组arr中
        int cnt = 0;
        sort(in, in+n, cmp1);
        for(int i=0; i<n-1; i++)
            arr[cnt++] = (edge){in[i].index, in[i+1].index, in[i+1].a-in[i].a};
        sort(in, in+n, cmp2);
        for(int i=0; i<n-1; i++)
            arr[cnt++] = (edge){in[i].index, in[i+1].index, in[i+1].b-in[i].b};
        //克鲁斯卡尔
        ll ans = 0;
        init( );
        sort(arr, arr+cnt, cmp3);
        for(int i=0; i<cnt; i++)
        {
            int a = f(arr[i].start);
            int b = f(arr[i].finish);
            if(a == b)
                continue;
            ans += arr[i].w;
            isvisited[a] = b;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 4608
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

// 移動元と行先と辺のコストを記録する構造体
template <typename T>
struct Edge {
    int from, to;
    T cost;
    Edge(int s, T d) : to(s), cost(d) {}
    Edge(int f, int s, T d) : from(f), to(s), cost(d) {}

    bool operator<(const Edge &e) const {
        return cost < e.cost;
    }
    bool operator>(const Edge &e) const {
        return cost > e.cost;
    }
};
#define Graph(type) vector< vector< Edge<type> > >

int memo[100010];
int calc(int p, vector< vector< Edge<int> > > &G) {
    if(memo[p] != -1) return memo[p];
    if(G[p].size() == 0) return memo[p] = 0;
    vector<int> v;
    rep(i,0,G[p].size()) {
        int k = G[p][i].to;
        int t = calc(k, G);
        v.pb(t);
    }
    sort(v.begin(), v.end(), greater<int>());
    int ma = 0;
    rep(i,0,v.size()) ma = max(ma, v[i] + i + 1);
    return memo[p] = ma;
}

signed main() {
    int n, inp; cin >> n;
    Graph(int) G(n);
    rep(i,1,n) {
        cin >> inp; inp--;
        G[inp].pb(Edge<int>(i, 1));
    }
    memset(memo, -1, sizeof(memo));
    cout << calc(0, G) << endl;
    rep(i,0,n) {
        // printf("memo[%lld] = %lld\n", i, memo[i]);
    }
    return 0;
}

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

int a, b, c;
int main(void){
    // Your code here!
    cin >> a >> b >> c;
    if(a <= c && c <= b){
        cout << "Yes" << endl;
    } else if(b <= c && c <= a){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(void) {
	int n;
	long long  a[100000];
	long long sum = 1,max=1000000000000000000;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}
	for(int i=0;i<n;i++){
		if(a[i] == 0){
			printf("0");
			return 0;
		}
	}
	for(int i=0;i<n;i++){
		if(max / a[i]< sum){
			sum = -1;
			break;
		}
		sum *= a[i];
	}

	printf("%lld",sum);
	return 0;
}


Measured memory_bytes: 2500
s=gets.chomp
ss1 = s[0..1].to_i
ss2 = s[2..3].to_i
if (ss1 == 0 && ss2 == 0) || (ss1 > 12 && ss2 > 12) || 
  (ss1 > 12 && ss2 == 0) || (ss1 == 0 && ss2 > 12)
  puts "NA"
elsif (ss1 <= 12 && (ss2 <= 12 && ss2 != 0) ) &&( (ss1 <= 12 && ss1 != 0 ) && ss2 <= 12 )
  puts "AMBIGUOUS"
elsif ss2 == 0
  puts "MMYY"
elsif ss1 == 0
  puts "YYMM"
elsif ss1 <= 12
  puts "MMYY"
elsif ss2 <= 12
  puts "YYMM"
end

Measured memory_bytes: 1788
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input {(source=$s:expr,$($r:tt)*) => {let mut iter=$s.split_whitespace(); let mut next=||{iter.next().unwrap()}; input_inner! {next,$($r)*}};($($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)*}};}
#[allow(unused_macros)]
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)*}};}
#[allow(unused_macros)]
macro_rules! read_value {($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:ty) => {$next().parse::<$t>().expect("Parse error")};}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX: usize = 100006;
#[allow(dead_code)]
const INF_U32: u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32: i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64: u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64: i64 = 1 << 62;
#[allow(dead_code)]
const MOD: i64 = 1e9 as i64 + 7;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(unused_imports)]
use std::f64;


fn main() {
    input!{n:usize, a:[i64;n]};
    let mut vq = VecDeque::new();
    for i in 0..n {
        if i%2==0 { vq.push_back(a[i]); }
        else { vq.push_front(a[i]); }
    }
    //debug!(vq);
    if n%2==0 {
        for el in vq.iter() {
            print!("{} ", el);
        }
    } else {
        for el in vq.iter().rev() {
            print!("{} ", el);
        }
    }
    println!("");
}

Measured memory_bytes: 10364
#include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
signed main(){
  int n,c,ans=1e9;
  cin>>n>>c;
  int a[n][n],d[c][c];
  int s[3][c];
 
  r(i,3)r(j,c)s[i][j]=0;
 
  r(i,c)r(j,c)cin>>d[i][j];
  r(i,n)r(j,n)cin>>a[i][j],a[i][j]--;
 
  r(i,n)r(j,n)s[(i+j)%3][a[i][j]]++;
  r(i,c)r(j,c)if(i!=j)r(k,c)if(i!=k&&j!=k){
    int sum=0;
    r(l,c){
      sum+=d[l][i]*s[0][l];
      sum+=d[l][j]*s[1][l];
      sum+=d[l][k]*s[2][l];
    }
    ans=min(ans,sum);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define rep(i, a, b) for(int i=(a) ; i<=(b) ; ++i)
#define Task ""
using namespace std;
int l;
vector < pair <pair <int, int >, int > > v;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen(Task".inp", "r", stdin);
    //freopen(Task".out", "w", stdout);
    cin >> l;
    int xx=log2(l);
    int n=xx+1;
    rep(i, 1, n-1) {
        v.push_back(make_pair(make_pair(i, i+1), 0));
        v.push_back(make_pair(make_pair(i, i+1), (1ll<<(i-1))));
    }
    int val=(1ll<<xx);
    if(val<l) {
        for(int i=n-1 ; i ; --i) {
            if(val+(1ll<<(i-1))<=l) {
                v.push_back(make_pair(make_pair(i, n), val));
                val+=1ll<<(i-1);
            }
        }
    }
    cout << n << ' ' << v.size() << '\n';
    for(auto P:v) {
        cout << P.first.first << ' ' << P.first.second << ' ' << P.second << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(ll num, ll idx) {return num | (1ll<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void GO(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
string st;
int vis[30];
int main(){
    cin>>st;
    for(int i=0;i<sz(st);i++) vis[st[i]-'A']++;
    if(vis[0]>0&&vis[1]>0){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
}













































Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
#define M 100005
#define rep(i,a,b) for(lli i=a;i<b;i++)
#define pii pair<lli,lli> 
#define Itr vector<lli> :: iterator
void fast()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
}

lli a[M] ; 
int main()
{
	fast();
	lli t,n;
	t=1;
	while(t--)
	{
		lli A,B;
		cin>>A>>B;
		lli rem = A - 2*B;
		if(rem<0)
			rem=0;
		cout<<rem<<"\n";
	}
return 0;
}

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

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

	namespace mp = boost::multiprecision;
	using Real = mp::number<mp::cpp_dec_float<1024>>;

	Real x(a), y(b), z(c);

	cout << ((mp::sqrt(x) + mp::sqrt(y) < mp::sqrt(z)) ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 384
N = int(input())
maxCount = 0
ans = 0
for i in range(1, N+1):
    tmpCount = 0
    j = i
    while True:
        if j % 2 != 0:
            break
        j = j/2
        tmpCount += 1
    
    if maxCount <= tmpCount:
        maxCount = tmpCount
        ans = i

print(ans)

Measured memory_bytes: 3060
S=input()
n=len(S)
left=int((n-1)/2)
right=int((n+3)/2)
#rint(right)
cnt=0
for a, b in zip(S[:left], reversed(S[left+1:])):
  #print(a,b)
  if a == b: 
    cnt += 1
if cnt==left:
  flag=1

  cnt=0
  for a, b in zip(S[right-1:], reversed(S[:n])):
    #print(a,b)
    if a == b: 
      cnt += 1
    #print(cnt)

  if cnt== left:
    print('Yes')
    exit() 
print("No")


Measured memory_bytes: 3064
(lambda f:f(f))(lambda T,A=lambda L,yp,ri=lambda l:R.append([{xi:x}for xi,x in enumerate(l)]):[P.__setitem__("x",L.index("@")),P.__setitem__("y",yp),ri(L)]if "@"in L else ri(L),S=lambda X,Y,s,u:[R[Y][X].__setitem__(X,"@"),s(X-1,Y,s,u)+s(X+1,Y,s,u)+s(X,Y+1,s,u)+s(X,Y-1,s,u)+1][1]if 0<=X<W[0]and 0<=Y<W[1]and u(X,Y)else 0,u=lambda X,Y:R[Y][X].get(X)is ".",g=globals:[g().__setitem__("W",list(map(int,input().split()))),g().__setitem__("R",[]),g().__setitem__("P",{"x":9,"y":9}),[A(input(),Y)for Y in range(W[1])],[R[P["y"]][P["x"]].__setitem__(P["x"],"."),print(S(P["x"],P["y"],S,u)),T(T)]if R else 9])

Measured memory_bytes: 8520
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=105;
LL n;
int is[MAXN],sta[MAXN];
int main()
{
	n=read();int mx=0;
	for(LL i=1;(i<<1)<=n;i<<=1)++mx;n-=1LL<<mx;
	int now=mx+2,tp=0,len=mx+1;
	for(int i=60;i>=0;i--)if(n&(1LL<<i))is[i]=sta[++tp]=now++,++len;
	pr2(len<<1);
	for(int i=0;i<=mx;i++)
	{
		if(i)pr1(i);
		if(is[i])pr1(is[i]);
	}
	for(int i=1;i<=mx;i++)pr1(i);
	pr1(mx+1);pr1(mx+1);
	for(int i=1;i<=tp;i++)pr1(sta[i]);puts("");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

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

int a, b, m;
vector<int> r, d;
vector<int> x, y, c;

int main() {
    cin >> a >> b >> m;
    r.resize(a), d.resize(b);
    for (int i = 0; i < a; i++) {
        cin >> r[i];
    }
    for (int i = 0; i < b; i++) {
        cin >> d[i];
    }
    x.resize(m);
    y.resize(m);
    c.resize(m);
    for (int i = 0; i < m; i++) {
        cin >> x[i] >> y[i] >> c[i];
        x[i]--, y[i]--;
    }
    int mr = *min_element(r.begin(), r.end());
    int md = *min_element(d.begin(), d.end());
    int ans = INT_MAX;
    chmin(ans, mr + md);
    for (int i = 0; i < m; i++) {
        int cand = r[x[i]] + d[y[i]] - c[i];
        chmin(ans, cand);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2176
#include<stdio.h>

int main()
{
    int n, r, temp, count=0;
    scanf("%d", &n);

   temp = n;
   while(temp>0)
   {
       r = temp%10;
       if(r==7)
        count=1;
       temp = temp/10;
   }
   if(count==1)
   printf("Yes\n");
   else
   printf("No\n");


    return 0;
}


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

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

    if (d == 22) {
        cout << "Christmas Eve Eve Eve" << endl;
    } else if (d == 23) {
        cout << "Christmas Eve Eve" << endl;
    } else if (d == 24) {
        cout << "Christmas Eve" << endl;
    } else {
        cout << "Christmas" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
def main():
    h, w = map(int,input().split())
    s = []
    for i in range(h):
        ss = list(input())
        s.append(ss)
    for i in range(h):
        for j in range(w):
            if check(s, i, j):
                if i != 0:
                    if check(s, i-1, j):
                        continue
                if i != h-1:
                    if check(s, i+1, j):
                        continue
                if j != 0:
                    if check(s, i, j-1):
                        continue
                if j != w-1:
                    if check(s, i, j+1):
                        continue
                print('No')
                return
    print('Yes')


def check(mtrx, n, m):
    if mtrx[n][m] == '#':
        return True
    else:
        return False
if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.io.*; 
import java.math.*;
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner sc = new FastScanner();
        int N = sc.nextInt();
        int[] nums = new int[N];
        int[][] sorted = new int[N][2];
        for (int i = 0; i < N; i++) {
        	nums[i] = sc.nextInt();
        	sorted[i] = new int[]{nums[i],i};
        }
        sorted = sort(sorted);
        int[] colors = new int[N];
        for (int i = 0; i < N; i++) {
        	colors[i] = -1;
        }
        int col = 0;
        TreeSet<Integer> colIndexes = new TreeSet<Integer>();
        for (int[] ni: sorted) {
        	int i = ni[1];
        	Integer colToBe = colIndexes.floor(i);
        	if (colToBe == null) {
        		colors[i] = col;
        		colIndexes.add(i);
        		col++;
        	} else {
        		colIndexes.remove(colToBe);
        		colors[i] = colors[colToBe];
        		colIndexes.add(i);
        	}
        }
        System.out.println(col);
    }
    
    public static int[][] sort(int[][] array) {
    	//Sort an array (immune to quicksort TLE)
		Random rgen = new Random();
		for (int i = 0; i< array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    int[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		Arrays.sort(array, new Comparator<int[]>() {
			  @Override
			  public int compare(int[] arr1, int[] arr2) {
				  //Ascending order
				  if (arr1[0] != arr2[0])
					  return arr1[0]-arr2[0];
				  else
					  return arr2[1]-arr1[1];
			  }
		});
		return array;
	}
    
    static class FastScanner { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try { 
                str = br.readLine(); 
            } catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str; 
        }
    }
}

Measured memory_bytes: 45376
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 1000000007
#define LINF 8000000000000000007
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
struct edge{int from,to,cost;};
int pow2(int n,int i){if(i==1)return n;return n*pow(n,i-1);};

typedef long long ll;

using namespace std;


int ans,ans2;
int n,m;
int dp[111111];
string s,t;
signed main(){  
    
    map<char,vector<int>> lis;
    cin>>s>>t;
    rep(i,s.size()){
        lis[s[i]].push_back(i);
    }
    int befindex=0;
    rep(i,t.size()){
        if(lis[t[i]].size()==0){
            ans=-1;
            break;
        }
        if(i==0){
            ans+=lis[t[i]][0]+1;
            befindex=lis[t[i]][0];
            DEB(lis[t[i]][0])END;
            continue;
        }

        int key=befindex;
        auto it_ok=upper_bound(lis[t[i]].begin(),lis[t[i]].end(),befindex);
        int ok=it_ok-lis[t[i]].begin();
        //DEB(lis[t[i]][ok])END
        if(ok==lis[t[i]].size()){
            ans+=s.size()-befindex-1+lis[t[i]][0]+1;//その文字が一番はじめにでてくるindex
            befindex=lis[t[i]][0];
            DEB(lis[t[i]][0])END
            DEB(ans)END
        }
        else{
            ans+=lis[t[i]][ok]-befindex;
            befindex=lis[t[i]][ok];
            DEB(lis[t[i]][ok])END
            DEB(ans)END
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#include <fstream>
#include <string>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>


typedef  long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_pbds;


#define endl "\n"
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
const int N=2e6+5;
int mod=1e9+7;
ll mul (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
ll add (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a+b+mod)%mod;
}
ll fastpow(ll b, ll p)
{
    if(p==0)
        return 1;
    ll ans=fastpow(b,p/2);
    ans=mul(ans,ans);
    if(p%2)ans=mul(ans,b);
    return ans;
}
int n,q;
int inter(int mx,pair<int ,int>p,pair<int ,int>f)
{
    pair<int,int>ans;
    ans.first=min(max(mx+1,p.first),p.second+1);
    ans.second=max(min(p.second,f.first-1),p.first-1);

    return max(0,((ans.second-ans.first)+1));
}
int xxx=0;
vector<int>build(vector<pair<int,int>>v)
{
    vector<vector<int>>add(n+2),rem(n+2);
    vector<int>t;
    t.resize(v.size(),0);
  set<int>st;
    for(int i=0; i<v.size(); i++)
    {
        add[v[i].first].push_back(i);
        rem[v[i].second+1].push_back(i);
    }
    for(int i=1;i<=n;i++)
    {
        while(add[i].size())
        {
            st.insert(add[i].back());
            add[i].pop_back();
        }
        while(rem[i].size())
        {
            st.erase(rem[i].back());
            rem[i].pop_back();
        }
        if(st.size()==0)
            xxx++;
        else if(st.size()==1)
        {
            t[*(st.begin())]++;
        }
    }

    return t;
}

int solve2(vector<pair<int,int>>v)
{
    vector<int>t=build(v);
    int mn=1e9,mx=0;
    for(int i=0; i<v.size(); i++)
    {
        mn=min(mn,t[i]);
    }
    return mn;
}

int solve(vector<pair<int,int>>v)
{
    vector<int>t=build(v);
    int mn=1e9;
    for(int i=0; i<v.size(); i++)
    {
        mn=min(mn,t[i]);

    }

    int ans=1e9;
    for(int i=v.size()-1; t.size(); i--)
    {
        if(t.back()==mn)
        {
            pair<int,int>tmp=v[i];
            v.erase((v.begin()+i));
            ans=min(ans,solve2(v));
            //   cout<<"Try==> "<<tmp.first<<"  "<<tmp.second<<" t = "<<t.back()<<" ans = "<<ans<<endl;
            v.insert((v.begin()+i),tmp);


        }
        t.pop_back();


    }
    return ans+mn;
}

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

    ll num=n/k;
    ll ans=num*num*num;
    if(k%2==0)
    {
        ll num2=n/(k/2);
        num2-=num;
    ans+=num2*num2*num2;


    }
    cout<<ans;

}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){

  int n,a[100],result=0;

  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n-1;i++) for(int j=n-2;j!=i-1;j--) if(a[j]>a[j+1]){
        swap(a[j],a[j+1]);
        result++;
      }
  for(int i=0;i<n-1;i++) cout<<a[i]<<" ";
  cout<<a[n-1]<<endl<<result<<endl;

  return 0;
  
}


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

int main()
{
    string s;
    cin>>s;
    const int n = s.size();
    int cnta =0;
    int cntb =0;
    char a[n],b[n];
    for(int i = 0;i < n;i += 2)
    {
        a[i] = '1';
        b[i] = '0';
        if(i < n)
        {
            a[i+1] = '0';
            b[i+1] = '1';
        }
    }
    for(int i = 0;i < n;i ++)
    {
        if(a[i] == s[i])
            cnta++;
        if(b[i] == s[i])
            cntb ++;
       // cout<<a[i];
    }
   // cout<<cnta<<cntb;
    if(cnta>=cntb)
        cout<<n-cnta;
    else
        cout<<n-cntb;
    return 0;
}

Measured memory_bytes: 640
import math

N,D=map(int,input().split())

arr=[list(map(int,input().split())) for i in range(N)]
count=0

def dis(x,y):
    a=0
    for i in range(len(x)):
        a+=(x[i]-y[i])*(x[i]-y[i])
    return math.sqrt(a)
    
for i in range(N-1):
    for j in range(i+1,N):
        if dis(arr[i],arr[j])%1==0:
            count+=1

print(count)

Measured memory_bytes: 9300
#![allow(non_snake_case)]
#![allow(unused_imports)]
 
use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;

#[fastout]
fn main() {
    input!{
        mut N: usize,
    }

    let mut ans: usize = 1;
    let mut max_cnt: usize = 0;


    for i in 1..=N {
        let mut cnt = 0;
        let mut num = i;
        while num % 2 == 0 {
            num = num / 2;
            cnt += 1;
        }
        if cnt > max_cnt {
            max_cnt = cnt;
            ans = i;
        }

    }

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


Measured memory_bytes: 2172