akhauriyash/Code-Regression huggingface dataset:
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        s: Chars,
    }
    let mut alpha: Vec<usize> = vec![0;26];
    for i in 0..s.len() {
        alpha[s[i] as usize - 'a' as usize] += 1;
    }
    for i in 0..alpha.len() {
        if alpha[i] > 1 {
            println!("no");
            return;
        }
    }
    println!("yes");
}


Measured memory_bytes: 2180
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int num, org;
    cin>> num >> org;
    int cnt=0;
    for (int i=0; i<num; i++){
        long long int a, b;
        cin>>a >> b;
        cnt+= a*a + b*b <= org*org;
    }
    cout<<cnt;
}


Measured memory_bytes: 3588
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let r:usize = read();
    let d:usize = read();
    let mut x:usize = read();
    for _ in 0..10 {
        x = r*x - d;
        println!("{}", x);
    }
}


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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n;
    cin >> n;
    vec<ll> x(n);
    REP(i, n) {
        cin >> x[i];
    }
    Array b = x;
    sort(all(b));

    REP(i, n) {
        if(x[i] < b[n / 2]) {
            cout << b[n / 2] << en;
        } else {
            cout << b[n / 2 - 1] << en;
        }
    }
}

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

    solve();
    // ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 6332
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

int main() {
	#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
	#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll n; cin >> n;
	vl a(n); REP(i, n) cin >> a[i];
	ll sum = 1, num = 0;
	REP(i, n) {
		num++;
		if (a[i] / 2 + a[i] % 2 < num) {
			sum = sum * num % mod;
			num--;
		}
	}
	REP(i, num) {
		sum = sum * (num - i) % mod;
	}
	cout << sum << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>

#define N 10000
#define NIL -1

void print(int);
void rec1(int, int);
int rec2(int);
int get(int);

struct Node {
  int p;
  int l;
  int r;
};

struct Node T[N];
int x,data[N],dat[N];

int main() {
  int i,x,y,z,w,r;

  scanf("%d",&x);
  for(i = 0; i < x; i++) {
    T[i].p = NIL;
  }

  for(i = 0; i < x; i++) {
    scanf("%d",&y);
    scanf("%d",&z);
    scanf("%d",&w);
   
    T[y].l = z;
    T[y].r = w;
    if(z != NIL) {
      T[z].p = y;
    }
    if(w != NIL) {
      T[w].p = y;
    }
  }
  for(i = 0; i < x; i++) {
    if(T[i].p == NIL) {
      r = i;
    }
  }
  rec1(r,0);
  rec2(r);
  for(i = 0; i < x; i++) {
    print(i);
  }
  
  return 0;
}

void rec1(int a, int b) {
  data[a] = b;
  if(T[a].r != NIL) {
    rec1(T[a].r,b + 1);
  }
  if(T[a].l != NIL) {
    rec1(T[a].l,b + 1);
  }
}

int rec2(int a) {
  int h1 = 0,h2 = 0;
  if(T[a].l != NIL) {
    h1 = rec2(T[a].l) + 1;
  }
  if(T[a].r != NIL) {
    h2 = rec2(T[a].r) + 1;
  }
  return dat[a] = (h1 > h2 ? h1 : h2);
}

int get(int a) {
  if(T[a].p == NIL) {
    return NIL;
  }
  if(T[T[a].p].l != a && T[T[a].p].l != NIL) {
    return T[T[a].p].l;
  }
  if(T[T[a].p].r != a && T[T[a].p].r != NIL) {
    return T[T[a].p].r;
  }
  return NIL;
}
  


void print(int a) {
  int deg = 0;
  printf("node %d: ",a);
  printf("parent = %d, ",T[a].p);
  printf("sibling = %d, ",get(a));

  if(T[a].l != NIL) {
    deg++;
  }
  if(T[a].r != NIL) {
    deg++;
  }
  printf("degree = %d, ",deg);
  printf("depth = %d, ",data[a]);
  printf("height = %d, ",dat[a]);

  if(T[a].p == NIL) {
    printf("root\n");
  }else if(T[a].l == NIL && T[a].r == NIL) {
    printf("leaf\n");
  }else{
    printf("internal node\n");
  }
}
  



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

d = {i:0 for i in range(4)}

for _ in range(3):
    A, B = map(int, input().split())
    d[A-1] += 1
    d[B-1] += 1

if max(d.values()) == 2:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3316
#include <stdio.h>
int main(void){
    double x1,y1,x2,y2,xq,yq,t;
    while (scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x1,&y1,&x2,&y2,&xq,&yq)!=EOF) {
        t=((x2-x1)*(xq-x1)+(y2-y1)*(yq-y1))/((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
        printf("%lf %lf\n",2*(1-t)*x1+2*t*x2-xq,2*(1-t)*y1+2*t*y2-yq);
    }
    return 0;
}

Measured memory_bytes: 652
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>

using namespace std;

int main(){

long long  A0,B0,C0;
cin >> A0 >> B0 >> C0 ;
long long K;
cin >> K;
long long sum1=A0+B0+C0;

long long Ans;
if(K%2==0){
    Ans=A0-B0;
}
else{
    Ans=B0-A0;
}
    cout <<Ans<<endl;

 return 0;
}

Measured memory_bytes: 256
s=input()
n=len(s)
L,R=[0]*n,[0]*n
lc,rc=0,0
for i in range(n):
  if s[i]=="R":
    lc=0
  else:
    lc+=1
    L[i]=lc
  if s[n-1-i]=="L":
    rc=0
  else:
    rc+=1
    R[n-1-i]=rc
m=max(max(R),max(L))
Ans_m=[0]*n
Ans_mm=[0]*n
for i in range(n):
  if s[i]=="R":
    cur=i+R[i]
    if (m-R[i])%2==0:
      Ans_m[cur]+=1
      Ans_mm[cur-1]+=1
    else:
      Ans_mm[cur]+=1
      Ans_m[cur-1]+=1
  else:
    cur=i-L[i]
    if (m-L[i])%2==0:
      Ans_m[cur]+=1
      Ans_mm[cur+1]+=1
    else:
      Ans_mm[cur]+=1
      Ans_m[cur+1]+=1
if m%2==0:
  print(*Ans_m)
else:
  print(*Ans_mm)



Measured memory_bytes: 12000
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <functional>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

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

	int c1, c5, c10, c50, c100, c500;
	cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
	int all = 0;
	all += 1 * c1;
	all += 5 * c5;
	all += 10 * c10;
	all += 50 * c50;
	all += 100 * c100;
	all += 500 * c500;

	int ans = all / 1000;
	if (ans != 0) {
		cout << "1" << endl;
	}
	else {
		cout << "0" << endl;
	}
	
	/*
	int ans = 0;

	c5 += c1 / 5;
	c10 += c5 / 2;
	c50 += c10 / 5;
	c100 += c50 / 2;
	c500 += c100 / 5;
	ans = c500 / 2;
	cout << ans << endl;
	*/
	return 0;
}

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

int main() {
	int L[10],a=0;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> L[i];
	}
	sort(L, L + n);
	for (int i = 0; i < n - 1; i++) {
		a += L[i];
	}
	if (L[n-1] < a)cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    int n = s.size(), ans = 0;
    for(int i = 0; i < n; ++i){
        if(s[i]!=t[i]) ans += 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3928
import java.awt.geom.*
import kotlin.math.*

fun <T> readList(del:String = " ",f:String.()->T) = readLine()!!.split(del).map {f(it)}

fun main() {
	val (a,b,h,m) = readList {toInt()}

	val sa = Point2D.Double(0.0,a.toDouble())
	val sb = Point2D.Double(0.0,b.toDouble())
	val da = Point2D.Double()
	val db = Point2D.Double()
	AffineTransform.getRotateInstance(PI*2/12*(h+m/60.0)).transform(sa,da)
	AffineTransform.getRotateInstance(PI*2/60*m).transform(sb,db)
	println(da.distance(db))
}


Measured memory_bytes: 36672
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    var (a, b, c, d) = readIntegerList()
    while (true) {
        c -= b
        if (c <= 0) {
            println("Yes")
            return
        }
        
        a -= d
        if (a <= 0) {
            println("No")
            return
        }
    }
}


fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 36444
from collections import defaultdict
inpl = lambda: list(map(int,input().split()))
M = 10**9 + 7

N, X = inpl()
S = sorted(inpl())
P = defaultdict(lambda: -1)

def ModuloOperations(i, x):
    if i == 0:
        return x
    else:
        if P[(i,x)] < 0:
            P[(i,x)] = (ModuloOperations(i-1,x)*(i-1) + ModuloOperations(i-1, x % S[i-1])) % M
        return P[(i,x)]

print(ModuloOperations(N,X))

Measured memory_bytes: 143948
#include <iostream>
#include <string>
#include <iterator>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <sstream> 
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <functional>
#pragma GCC optimize("O3")
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define sp system("pause");
#define MOD 998244353 
#define mxN 2005
#define MXINT 1e9+5


void solve()
{
	ll n;
	cin >> n;
	while (n)
	{
		if (n % 10 == 7)
		{
			cout << "Yes";
			return;
		}
		n /= 10;
	}
	cout << "No";
}

int main()
{
	fast;
	solve();

	return 0;
}



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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll INF=1LL<<60;
const ll MOD=1e9+7;

int main(){
    int N; cin >> N;
    vi P(N);
    for(auto &x: P) cin >> x;
    int mi=P[0];
    int res=1;
    for(int i=1; i<N; i++){
        if(P[i] <= mi){
            mi=P[i];
            res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4052
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define MAXN 999999
using namespace std;
bool is_prime[MAXN];
int prime[MAXN];
int main()
{
    int p=0;
    for(int i=0;i<=MAXN;i++) is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    for(int i=2;i<=MAXN;i++)
        if(is_prime[i])
    {
        prime[p++]=i;
        for(int j=2*i;j<=MAXN;j+=i) is_prime[j]=false;
    }
    int n,x;
    while(scanf("%d",&n)!=EOF)
    {
      x=lower_bound(prime,prime+p,n)-prime;
      if(prime[x]==n) printf("%d\n",x+1); else printf("%d\n",x);
    }
    return 0;
}

Measured memory_bytes: 4332
s=gets.chomp.chars
p [*1...s.size].combination(3).count{|e|
	t=s.dup
	e.reverse_each{|i|t.insert(i,'.')}
	t.join.split('.').all?{|_|
		n=_.to_i
		n<256 && n.to_s==_
	}
}



Measured memory_bytes: 6948
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;

int main(){
  int n,x,t;
  cin >> n >> x >> t;

  int ans = 0;

  int cnt = 0;
  while(cnt < n){
    cnt += x;
    ans += t;
  }
  cout << ans << endl;

}


Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }

int N;
int D, X;

signed main()
{
	cin >> N;
	cin >> D >> X;

	int ans = 0;
	REP(i, N)
	{
		int a;
		cin >> a;

		for (int i = 1; i <= D; i += a)
		{
			ans++;
		}
	}
	cout << (ans + X) << endl;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<(int)(r); i++)
#define rep_eq(i,l,r) for(int i=l; i<=(int)(r); i++)
#define all(vec) vec.begin(),vec.end()
#define allr(vec) vec.rbegin(),vec.rend()
using namespace std;

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

using ll=int64_t;

using vb=vector<bool>;
using vc=vector<char>;
using vs=vector<string>;
using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;

ll gcd(ll a,ll b) {
  return (b ? gcd(b,a%b):a);
}

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

  ll N,M; cin >>N >>M;
  string S,T; cin >>S >>T;

  ll g=gcd(N,M);
  ll ans=N/g*M;
  N/=g;
  M/=g;
  bool flag=true;
  for (ll i=0;i<g;i++) {
    if (S[i*N]!=T[i*M]) {
      flag=false;
    }
  }

  cout <<(flag ? ans:-1) <<'\n';
  return 0;
}


Measured memory_bytes: 3724
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Data.Char
import Data.Array

main = do
    s <- getLine
    let arr = array ((0,0),(12,9)) [((i,j), (i*10+j) `mod` 13)| i <- [0..12], j <- [0..9]]
    let f v c | c == '?' = VU.create $ do
                                vec <- VUM.replicate 13 (0 :: Int)
                                forM_ [0..12] $ \i -> do
                                    forM_ [0..9] $ \j -> do
                                        let a = v VU.! i
                                        VUM.modify vec (\b -> (a + b) `mod` 1000000007) (arr ! (i,j))
                                return vec
              | otherwise = VU.create $ do
                                vec <- VUM.replicate 13 (0 :: Int)
                                forM_ [0..12] $ \i -> do
                                    VUM.write vec (arr ! (i, digitToInt c)) (v VU.! i)
                                return vec
    let ans = foldl' f (VU.fromList (1 : replicate 12 0)) s
    print $ ans VU.! 5

Measured memory_bytes: 8244
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

bool AC(string str) {
    if(str == "AC")
        return true;

    return false;
}

Int imos[200000];

int main(void) {
    int N,Q;
    string S;

    cin>>N>>Q;
    cin>>S;

    for(int i = 1;i < N;i++) {
        bool flag = AC(S.substr(i-1,2));
        if(flag)
            imos[i] = imos[i-1]+1;
        else
            imos[i] = imos[i-1];
    }

    for(int i = 0;i < Q;i++) {
        int l,r;
        cin>>l>>r;

        --r,--l;
        cout<<imos[r]-imos[l]<<endl;
    }

    return 0;
}




Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(), x.end()
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const ll inf = 1e9;
const int MAX_N = 500;

int main() {
    string s; cin >> s;
    int ans = 0;
    rep(i,4) {
        if (s[i] == '+') ans++;
        else ans--;
    }
    cout << ans << endl;
}

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

int cnt[2][100001];
int main() {
	int n;
	scanf("%d",&n);
	fup(i,0,n-1,1)
	{
		int x;
		scanf("%d",&x);
		cnt[i&1][x]++;
	}
	VPi v0,v1;
	fup(i,1,100000,1)if(cnt[0][i])v0.pb(mp(cnt[0][i],i));
	fup(i,1,100000,1)if(cnt[1][i])v1.pb(mp(cnt[1][i],i));
	sort(v0.rbegin(),v0.rend());
	sort(v1.rbegin(),v1.rend());
	if(v0.size()==1 && v1.size()==1)
	{
		if(v0[0].Y!=v1[0].Y)return !printf("0");
		return !printf("%d",n/2);
	}
	if(v0.size()==1 && v1.size()>1)
	{
		int t=v0[0].Y;
		if(v1[0].Y==t)return !printf("%d",n/2-v1[1].X);
		else return !printf("%d",n/2-v1[0].X);
	}
	if(v1.size()==1 && v0.size()>1)
	{
		int t=v1[0].Y;
		if(v0[0].Y==t)return !printf("%d",n/2-v0[1].X);
		else return !printf("%d",n/2-v0[0].X);
	}
	if(v0[0].Y!=v1[0].Y)return !printf("%d",n-v0[0].X-v1[0].X);
	else return !printf("%d",n-max(v0[0].X+v1[1].X,v0[1].X+v1[0].X));
}

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

template<long long mod>
class modint{
private:
  long long a;
public:
  constexpr modint(const long long x = 0) noexcept : a(x%mod) {}
  constexpr long long& value() noexcept { return a; }
  constexpr const long long& value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint& operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if(a >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(modint rhs) noexcept {
    long long k = mod-2;
    while(k > 0){
      if(k&1){
        *this *= rhs;
      }
      rhs *= rhs;
      k /= 2;
    }
    return *this;
  }
  friend ostream& operator<<(ostream &os, const modint &X){
    return os << X.a;
  }
  friend istream& operator>>(istream &is, modint &X){
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};

int main(){
  int N, K;
  cin >> N >> K;
  using mint = modint<(int)1e9+7>;
  vector<vector<mint>> dp(N+1,vector<mint>(K+1,0));
  dp[0][0] = 1;
  for(int i = 0; i < N; ++i){
    vector<vector<mint>> dp_(N+1,vector<mint>(K+1,0));
    for(int j = 0; j <= N; ++j){
      for(int k = 0; k <= K; ++k){
        if(k+2*j <= K)
          dp_[j][k+2*j] += dp[j][k]*(2*j+1);
        if(j > 0 and k+2*(j-1) <= K)
          dp_[j-1][k+2*(j-1)] += dp[j][k]*j*j;
        if(j < N and k+2*(j+1) <= K)
          dp_[j+1][k+2*(j+1)] += dp[j][k];
      }
    }
    dp = dp_;
  }
  mint ans = dp[0][K];
  cout << ans << endl;
}


Measured memory_bytes: 2316
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstdlib>

using namespace std;
typedef long long ll;

int main(){
    ll n,m,sum = 0,tmp = 0;
    cin >> n >> m;
    for(ll i = 0; i < m; i++){
        cin  >> tmp;
        sum += tmp;
    }
    if(n >= sum){
        cout << n - sum << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int P = sc.nextInt();
		
		int ki = 0;
		int gu = 0;
		for (int i = 0; i < N; i++) {
			int num = sc.nextInt();
			if (num % 2 == 0) {
				gu++;
			} else {
				ki++;
			}
		}
		
		if (ki == 0) {
			System.out.println(P == 0 ? 1L << N: 0);
		} else {
			System.out.println(1L << N-1);
		}
	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>
#include <set>
#include <unordered_set>

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

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

#define INF 1000000000

using namespace std;
typedef long long ll;

ll newton(long long int a, long long int  b)
{
	if(a==b)
		return a;
	while(a != 0 && b != 0)
	{
		if(a > b)
		{
			b += a;
			a = b-a;
			b -= a;
		}
		b %= a;
	}
	return a;
}

struct UnionFind {
	vector<int> p;
	UnionFind(int N):p(N)
	{
		for(int i=0; i< N; i++)
		{
			p[i] = i;
		}
	}
	int root(int x)
	{
		if(p[x] == x)
			return x;
		return p[x] = root(p[x]);
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		p[rx] = ry;
	}
	bool issame(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

//大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる

ll div2mul_calc(ll a, ll b, ll m)
{
	if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = div2mul_calc(a, b / 2, m);
        return (d * d) % m;
    } else {
        return (a * div2mul_calc(a, b - 1, m)) % m;
    }
}
ll div2mul(ll n, ll mod)
{
	return div2mul_calc(n, mod-2, mod);
}

ll twoRow(ll a, ll b, ll mod)
{
	ll ret = 1;
	for(ll i = 1 ;i <= a+b;++i)
	{
		ret *= i;
		ret %= mod;
	}
	for(ll i = 1 ;i <= a;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	for(ll i = 1 ;i <= b;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	return ret;
}

struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end());
  return (ret);
}
/*
*/

int main()
{
	ll i,j,k,a,b,c;
	ll N,M;
	vector<ll> v[610];
	double mp[610] = {0.0};
	double rt[610] = {0.0};
	cin >> N >> M;
	for(i=0;i<M;++i)
	{
		cin >> j >> k;
		v[j-1].push_back(k-1);
	}
	mp[N-1] = 0.0;
	for(i=N-2;i>=0;--i)
	{
		j = v[i].size();
		mp[i] = 0.0;
		for(k=0; k<j; ++k)
		{
			mp[i] += mp[v[i][k]];
		}
		if(j > 0)
			mp[i] /= (double)j;
		mp[i] ++;
		//cout << mp[i] << endl;
	}
	rt[0] = 1.0;
	for(i=0;i<N-1;++i)
	{
		j = v[i].size();
		for(k=0; k<j; ++k)
		{
			rt[v[i][k]] += (double)rt[i]/j;
		}
	}
	/*
	for(i=0;i<N;++i)
	{
		cout << rt[i] << " "<< mp[i] << endl; 
	}*/

	double mx = 0.0;
	for(i=0;i<N-1;++i)
	{
		j = v[i].size();
		if(j > 1)
		{
			for(k=0;k<j;++k)
			{
				a = v[i][k];
				double d = (double)rt[i]*(mp[i] - (mp[i]*v[i].size()-(mp[a]+1))/(v[i].size()-1));
				if(d > mx)
				{
					mx = d;
				}
			}
		}
	}
	cout << setprecision(8)<< mp[0]-mx << endl;
	return 0;
}




















Measured memory_bytes: 2560
#include<stdio.h>
#include<stdlib.h>
int compare_int(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}
void gcd(int *a,int *b){
  int r,temp;
  if(a<b){
    temp=*a;*a=*b;*b=temp;
  }
  r=*a%*b;
  while(r!=0){
    *a=*b;
    *b=r;
    r=*a%*b;
  }
}
int main(void)
{
  int n,lx,a,b;
  scanf("%d%d",&n,&lx);
  int x[n],absx[n];
  for(int i=0;i<n;i++){
    scanf("%d",&x[i]);
    absx[i]=abs(lx-x[i]);
  }
  //qsort(x,n,sizeof(int),compare_int);
  for(int i=0;i<n-1;i++){
    a=absx[i];b=absx[i+1];
    gcd(&a,&b);
    absx[i+1]=b;
  }
  printf("%d",absx[n-1]);
  return 0;
}


Measured memory_bytes: 896
<?php

// Dice1
$input = trim(fgets(STDIN));
$labels = explode(" ", $input);
$dice1 = new Dice($labels);

// Dice2
$input = trim(fgets(STDIN));
$labels = explode(" ", $input);
$dice2 = new Dice($labels);

$dice1_top = $dice1->getLabel("T");

$ans = "No";
$check_dirs = "NWSSSW";
foreach (str_split($check_dirs) as $dir)
{
  $dice2->roll($dir);
  $dice2_top = $dice2->getLabel("T");
  if ($dice1_top == $dice2_top) {
    for ($i = 0; $i < 4; $i++) {
      if ($dice1->isEqual($dice2)) {
        $ans = "Yes";
        break;
      }
      $dice2->roll("R");
    }
  }

  if ($ans === "Yes") {
    break;
  }
}

echo "${ans}" . PHP_EOL;

//========================================

class Dice
{
  private $labels;
  private $TBL_ROLL = array(
    array(4, 0, 2, 3, 5, 1),  // -> S
    array(3, 1, 0, 5, 4, 2),  // -> E
    array(2, 1, 5, 0, 4, 3),  // -> W
    array(1, 5, 2, 3, 0, 4),  // -> N
    array(0, 3, 1, 4, 2, 5),  // -> sidespin : right
    array(0, 2, 4, 1, 3, 5)   // -> sidespin : left
  );

  public function __construct($labels)
  {
    $this->labels = $labels;
  }

  public function roll($dirs)
  {
    foreach (str_split($dirs) as $dir) {
      $idx = strpos("SEWNRL", $dir);
      if ($idx === false) {
        continue;
      }

      $old = $this->labels;
      for ($i = 0; $i < 6; $i++) {
        $this->labels[$i] = $old[$this->TBL_ROLL[$idx][$i]];
      }
    }
  }

  public function isEqual($dice) {
    return ($this->labels == $dice->getLabels());
  }

  public function getLabel($dir) {
    $idx = strpos("TSEWNB", $dir);
    if ($idx !== false) {
      return $this->labels[$idx];
    }
    return false;
  }

  public function getLabels() {
    return $this->labels;
  }

  public function getDirection($number) {
    $idx = array_search($number, $this->labels);
    if ($idx !== false) {
      return "TSEWNB"[$idx];
    }
    return false;
  }
}

Measured memory_bytes: 15524
#include<bits/stdc++.h>
using namespace std;
#ifdef _LOCAL
    #define test(x) cerr << #x << "=" << x << endl
#else
    #define test(x)
#endif

typedef long long LL;

const int N = 1e5+5;

int a[N];

int main(){
    #ifdef _LOCAL
        freopen("data.in", "r", stdin);
    #endif
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i ++) scanf("%d", &a[i]);
    a[1] --;
    for(int i = 2; i <= n; i ++){
        if(a[i] > a[i-1]) a[i] --;
    }
    bool ok = true;
    for(int i = 2; i <= n; i ++){
        if(a[i] < a[i-1]){
            ok = false;
            break;
        }
    }
    if(ok) puts("Yes");
    else puts("No");
    #ifdef _LOCAL
        fprintf(stderr, "T: %d ms\n", int(1000.0 * clock() / CLOCKS_PER_SEC));
    #endif
    return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    private static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            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;
        }
    }

    public static void main(final String[] args) throws IOException {
        FastReader in = new FastReader();
        PrintWriter out = new PrintWriter(System.out, true);

        long n = in.nextLong();
        if (n == 1) {
            out.println(0);
        } else {
            long sum = ((n - 1) * n) / 2L;
            out.println(sum);
        }
    }
}


Measured memory_bytes: 22996
import java.util.*;
public class Main { 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
		int cnt = 0;
      	for(char c : str.toCharArray())
          if(c == '1') cnt++;
      	System.out.println(cnt);
        
    }
}

Measured memory_bytes: 21840
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
long long a[1000005],b[1000005],ans;
int n;
int find(int l,int r,long long x)
{
	while (l<r)
	{
		int mid=(l+r+1)>>1;
		if (b[mid]<=x) l=mid;
		else r=mid-1;
	}
	return l;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%lld",&a[i]),b[i]=b[i-1]+a[i];
	ans=1000000000000000000ll;
	for (int i=2;i<=n-2;i++)
	{
		int t1=find(0,i,b[i]/2),t2=t1+1;
		int t3=find(i+1,n,b[i]+(b[n]-b[i])/2),t4=t3+1;
		int t5,t6;
		if (abs(b[i]-b[t1]-b[t1])<abs(b[i]-b[t2]-b[t2])) t5=t1; else t5=t2; 
		if (abs(b[n]-b[t3]-b[t3]+b[i])<abs(b[n]-b[t4]-b[t4]+b[i])) t6=t3; else t6=t4;
	//	cout<<i<<" "<<t1<<" "<<t2<<" "<<t3<<" "<<t4<<" "<<t5<<" "<<t6<<endl;
		ans=min(max(max(b[t5],b[i]-b[t5]),max(b[t6]-b[i],b[n]-b[t6]))-min(min(b[t5],b[i]-b[t5]),min(b[t6]-b[i],b[n]-b[t6])),ans); 
	}
	printf("%lld\n",ans);
	return 0;
}

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

#define INF 1000000

using namespace std;

int main(void){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> dst(N);
    for(int i = 0; i < M; i++){
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        dst[u].push_back(v);
    }
    int S, T;
    cin >> S >> T;
    S--;
    T--;
    priority_queue<pair<int, int>, vector<pair<int, int>>, std::greater<pair<int, int>>> q;
    vector<vector<int>> d(N, vector<int>(3, INF));
    d[S][0] = 0;
    q.push(make_pair(0, S));

    while(!q.empty()){
        pair<int, int> i = q.top();
        // cout << i.second << endl;
        q.pop();
        for(int f : dst[i.second]){
            int fd = i.first + 1;
            if(fd < d[f][fd % 3]){
                d[f][fd % 3] = fd;
                q.push(make_pair(fd, f));
                // cout << f << " " << fd << endl;
            }
        }
    }
    if(d[T][0] < INF) cout << d[T][0] / 3 << endl;
    else cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define REP(i, l, r) for (int i=(l); i<(r); ++i)
#define RREP(i, r, l) for (int i=(r); i>(l); --i)
#define CASET int _T; cin >> _T; REP(caset, 0, _T)
#define print(x) cout << to_string(x) << '\n'
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vvi vector<vi>
#define vvb vector<vb>
#define pii pair<int,int>
#define t3i tuple<int,int,int>
#define mii map<int,int>
#define vpii vector<pii>
#define vt3i vector<t3i>
#define sq(x) (x)*(x)
#define inv(x) powa(x, MOD-2)
 
long long INF = 1LL<<60;
long long MOD = 1e9+7;
 
string to_string(char &c) {string x(1, c); return x;}
string to_string(const char s[]) {return (string)s;}
string to_string(string &s) {return s;}
string to_string(vb &v) {string res; for (const bool &x : v) res += to_string(x) + ' '; return res;}
template <class C> string to_string(C &v) {string res; for (auto &x : v) res += to_string(x) + ' '; return res;}
template <typename A, typename B> istream &operator>>(istream &is, pair<A, B> &pr) {is >> pr.first >> pr.second; return is;}
template <typename A> istream &operator>>(istream &is, vector<A> &v) {for (auto &x : v) is >> x; return is;}
ostream &operator<<(ostream &os, char &c) {os << (char)c; return os;}
ostream &operator<<(ostream &os, const char s[]) {os << (string)s; return os;}
ostream &operator<<(ostream &os, string &s) {for (char &c : s) os << (char)c; return os;}
template <typename A, typename B> ostream &operator<<(ostream &os, pair<A, B> pr) {os << '(' << pr.first << ", " << pr.second << ')'; return os;}
ostream &operator<<(ostream &os, vb &v) {
    bool first = true;
    os << '[';
    for (const bool &x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
template <class C> ostream &operator<<(ostream &os, C &v) {
    bool first = true;
    os << '[';
    for (auto &x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
string bin_string(int x) {
    const int d = 32;
    string res(d, ' ');
    REP(i, 0, d) res[d-1-i] = '0'+(x>>i & 1LL);
    return res;
}
int powa(int base, int exp) {
    int res = 1;
    while (exp) {
        if (exp&1) res = res*base % MOD;
        base = base*base % MOD;
        exp >>= 1;
    }
    return res;
}

main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    int n;
    cin >> n;
    int k = 0;
    while (n) {
        n /= 2;
        ++k;
    }
    int res = 1;
    REP(i, 0, k) res *= 2;
    res -= 1;
    print(res);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,a[100010]={0},t=0,s;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++)
    {
        if(a[i]!=0)
        {
            s=0;
            if(a[i]<=n)
            {
                for(int j=1;j<=n;j++)
                {
                    if(a[j]!=0&&a[j]==a[i]&&j!=i)
                    {
                        a[j]=0;
                        s++;
                    }
                }
                s++;
                if(s!=a[i])
                {
                    if(s>a[i]) t+=s-a[i];
                    else t+=s;
                }
            }
            else t++;
        }
    }
    cout<<t<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
	int n;
	std::cin >> n;

	std::vector<int> p(n), q(n);
	for (auto&& e : p)
		std::cin >> e;
	for (auto&& e : q)
		std::cin >> e;

	std::vector<int> perm(n);
	for (int i = 0; i < n; ++i)
		perm[i] = i + 1;

	int a, b;
	for (int i = 1; true; ++i) {
		if (perm == p)
			a = i;
		if (perm == q)
			b = i;

		if (!std::next_permutation(perm.begin(), perm.end()))
			break;
	};

	std::cout << std::abs(a - b) << std::endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
#define mems(p) memset(p,-1,sizeof(p))
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define nl "\n"

const int mxN = 1e5;
const ll MOD = 1e9 + 7;

void fast()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

ll gcd(ll a, ll b) {
	return b ? gcd(b, a%b) : a;
}

int main() {
	fast();
	ll mn = 2e9 + 1, mnn = 2e9 + 1, mxx = -2e9 - 1, mx = -2e9 - 1;
	int n;
	cin >> n;
	ll x, y;
	for (int i = 0; i < n; ++i)
	{
		cin >> x >> y;
		mn = min(mn, x+y);
		mx = max(mx, x+y);
		mnn = min(mnn, x-y);
		mxx = max(mxx, x-y);
	}
	cout << max(abs(mx - mn), abs(mnn-mxx)) << nl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, m, x, y, a;
  in2(n, m);
  in2(x, y);
  rep(i, n){
    in(a);
    x = max(a, x);
  }
  rep(i, m){
    in(a);
    y = min(y, a);
  }
  if(x < y)
    out("No War");
  else
    out("War");
  memi;
}

Measured memory_bytes: 256
s = input()
start = -float('inf')
best_length = -float('inf')
for i,w in enumerate(s):
  if w=='A' and start < 0:
    start = i
  elif w=='Z' and start >= 0:
    length = i - start + 1
    if length > best_length:
      best_length = length
print(best_length if best_length > 0 else 0)

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	
	int n; cin >> n;
	if(n == 3 || n == 5 || n == 7) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int N, X[15], Y[15], P[15];
vector<int> LX, LY;
 
int power[30];
int V0[1 << 15];
int V1[1 << 15][15];
int V2[1 << 15][15];
long long Answer[30];
 
int main() {
	// 入力
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> X[i] >> Y[i] >> P[i];
	}
  
	// 最終チェック
	assert(1 <= N && N <= 15);
	for (int i = 0; i < N; i++) {
		assert(-10000 <= X[i] && X[i] <= 10000);
		assert(-10000 <= Y[i] && Y[i] <= 10000);
		assert(1 <= P[i] && P[i] <= 1000000);
    }
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			assert(X[i] != X[j] || Y[i] != Y[j]);
        }
    }
 
	// 前準備
	for (int i = 0; i < N; i++) LX.push_back(X[i]);
	for (int i = 0; i < N; i++) LY.push_back(Y[i]);
	sort(LX.begin(), LX.end()); LX.erase(unique(LX.begin(), LX.end()), LX.end());
	sort(LY.begin(), LY.end()); LY.erase(unique(LY.begin(), LY.end()), LY.end());
	for (int i = 0; i < N; i++) X[i] = lower_bound(LX.begin(), LX.end(), X[i]) - LX.begin();
	for (int i = 0; i < N; i++) Y[i] = lower_bound(LY.begin(), LY.end(), Y[i]) - LY.begin();
	for (int i = 0; i < 2 * N; i++) power[i] = (1LL << i);
	for (int i = 0; i < N; i++) Answer[i] = (1LL << 60);
 
	// ビット数をかぞえる
	for (int i = 0; i < (1 << N); i++) {
		for (int j = 0; j < N; j++) V0[i] += (i / (1 << j)) % 2;
	}
 
	// 横方向
	for (int i = 0; i < power[LX.size()]; i++) {
		for (int j = 0; j < N; j++) V1[i][j] = min(abs(LX[X[j]]), abs(LY[Y[j]]));
		for (int j = 0; j < LX.size(); j++) {
			if ((i & (1 << j)) == 0) continue;
			for (int k = 0; k < N; k++) V1[i][k] = min(V1[i][k], abs(LX[j] - LX[X[k]]));
		}
	}
 
	// 縦方向
	for (int i = 0; i < power[LY.size()]; i++) {
		for (int j = 0; j < N; j++) V2[i][j] = min(abs(LX[X[j]]), abs(LY[Y[j]]));
		for (int j = 0; j < LY.size(); j++) {
			if ((i & (1 << j)) == 0) continue;
			for (int k = 0; k < N; k++) V2[i][k] = min(V2[i][k], abs(LY[j] - LY[Y[k]]));
		}
	}
 
	// 全体
	for (int i = 0; i < power[LX.size()]; i++) {
		bool used[15], used2[15]; vector<int> vec;
		for (int j = 0; j < LX.size(); j++) used[j] = false;
		for (int j = 0; j < LY.size(); j++) used2[j] = false;
		for (int j = 0; j < LX.size(); j++) { if ((i & (1 << j)) != 0) used[j] = true; }
		for (int j = 0; j < N; j++) { if (used[X[j]] == false) used2[Y[j]] = true; }
		for (int j = 0; j < LY.size(); j++) { if (used2[j] == true) vec.push_back(j); }
 
		for (int j = 0; j < power[vec.size()]; j++) {
			int x = 0;
			for (int k = 0; k < vec.size(); k++) {
				if ((j & (1 << k)) != 0) x += (1 << vec[k]);
			}
			int e = V0[i] + V0[x]; long long r = 0;
			for (int k = 0; k < N; k++) r += 1LL * min(V1[i][k], V2[x][k]) * P[k];
			Answer[e] = min(Answer[e], r);
		}
	}
	for (int i = 0; i < N; i++) Answer[i + 1] = min(Answer[i + 1], Answer[i]);
 
	// 出力
	for (int i = 0; i <= N; i++) cout << Answer[i] << endl;
	return 0;
}

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

using namespace std;

#define int long long

void solve()
{
	int k, x;
	cin >> k >> x;
	
	if(k * 500 >= x)
		cout << "Yes\n";
	else
		cout << "No\n";
}

main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int t = 1;
//	cin >> t;
	
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 256
import Data.List
main = interact$show.solve.sort.map read.tail.words

solve :: [Int] -> Int
solve x = length (tower x)
tower :: [Int] -> [Int]
tower (a:[]) = [a]
tower (a:b:[]) = if a==b then [b] else [a,b]
tower (a:b:x) = if a==b then tower (b:x) else [a] ++ tower (b:x)

Measured memory_bytes: 1020
#include<stdio.h>
int R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//挿入関数
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int main(){
  int n,i,d[100010],a;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    hin(a);
  }
  for(i=0;i<n;i++)d[i]=N[hout()];
  printf("%d\n",d[n/2]-d[n/2-1]);
  return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>
int main(){
    int c5=0,c7=0,i,t;
    for(i=0;i<3;i++){
        scanf("%d",&t);
        if(t==5) c5++;
        else if(t==7) c7++;
    }
    if(c5==2 && c7==1) printf("YES");
    else printf("NO");
    return 0;
}


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

using namespace std;

int main() {
	int sx, sy, tx, ty;
	string ans = "";
	int i;

	cin >> sx >> sy >> tx >> ty;

	int x = tx - sx;
	int y = ty - sy;

	for (i = 0; i < y; i++)	ans +='U';
	for (i = 0; i < x; i++)	ans += 'R';
	for (i = 0; i < y; i++)	ans += 'D';
	for (i = 0; i <= x; i++)	ans += 'L';
	for (i = 0; i <= y; i++)	ans += 'U';
	for (i = 0; i <= x; i++)	ans += 'R';
	ans += "DR";
	for (i = 0; i <= y; i++)	ans += 'D';
	for (i = 0; i <= x; i++)	ans += 'L';
	ans += 'U';

	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main() {
	int n, m = 0;
	cin >> n;
	int v[22];
	for (int i = 0; i < n; i++)
		cin >> v[i];
	for (int i = 0; i < n; i++) {
		int c;
		cin >> c;
		m += max(0, v[i] - c);
	}
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <string>
#include <limits.h>
#include <iomanip>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <set>
#include <bitset>
#include <unordered_map>
#include <string.h>
#define fastIo                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define MOD 1000000007

using namespace std;
int main()
{
    fastIo;
    
    ll n;
    cin>>n;
    if(n%2==0 || n%5==0)
        {
            cout<<-1<<endl;
            return 0;
        }
    ll ans=7;
    ll c=1;

    bool found = false; 
    while(true)
    {
        if(c>n)
            break;
        
        ans%=n;
        if(ans==0)
            {
                found=true;
                break;
            }
        ans = ans*10+7;
        c++;
    }
    if(found)
        cout<<c<<endl;
    else
    {
        cout<<-1<<endl;
    }
    


    return 0;
}

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

long double n, m, s = 0, mn, cnt = 0;
const int MAXN = 110;

int a[MAXN];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    cin >> n >> m;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
        s += a[i];
    }

    mn = s / 4 / m;
    sort(a + 1, a + (int)n + 1);
    for(int i = n; i > 0; --i) {
        if(cnt >= m) break;
        if(a[i] >= mn) cnt++;
        else break;
    }

    if(cnt >= m) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  ll n, k;
  cin >> n >> k;
  vll a(n);
  rep(i,n) cin >> a[i];
  ll ng = 0;
  ll ok = 1000000000LL;
  while(ok-ng>1) {
    ll m = (ok+ng)/2;
    ll cnt = 0LL;
    rep(i,n) cnt += (ceil)((double)a[i]/(double)m)-1;
    if(cnt>k) ng = m;
    else ok = m;
  }
  cout << ok << endl;
  return 0;
}

Measured memory_bytes: 4796
using System;

class program
{
    public static void Main()
    {

        int length = int.Parse(Console.ReadLine());
        int[, ,] rooms = new int[4, 3, 10];

        for (int k = 0; k < length; k++)
        {
            var query = Console.ReadLine().Split(' ');
            rooms[int.Parse(query[0])-1, int.Parse(query[1])-1, int.Parse(query[2])-1] += int.Parse(query[3]);
        }

        for (int count = 0; count < 4; count++)
        {
            for (int height = 0; height < 3; height++)
            {
                for (int width = 0; width < 10; width++)
                {
                    if (rooms[count, height, width] > 0)
                    {
                        Console.Write(" {0}", rooms[count, height, width]);
                    }
                    else
                    {
                        Console.Write(" " + 0);
                    }
                    
                }
                Console.WriteLine();
            }

            if (count < 3)
            {
                for (int i = 0; i < 20; i++)
                {
                    Console.Write("#");
                }
                Console.WriteLine();
            }
        }
    }

}

Measured memory_bytes: 5676