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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

#define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline void chmax(T& a,T const& b){a=max(a,b);}
template<class T> inline void chmin(T& a,T const& b){a=min(a,b);}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60; 
const int MAX_N = 200005;

using sz = ll;

long long maximum_rectangle(const std::vector<sz> &h) {
  // ヒストグラム中の最大長方形
  int n = h.size();
  std::stack<sz> s;
  std::vector<sz> L(n), R(n);
  for (int i = 0; i < n; i++) {
    while (s.size() && h[s.top()] >= h[i]) s.pop();
    L[i] = s.size() ? (s.top() + 1) : 0;
    s.push(i);
  }
  while (s.size()) s.pop();
  for (int i = n - 1; i >= 0; i--) {
    while (s.size() && h[s.top()] >= h[i]) s.pop();
    R[i] = s.size() ? s.top() : n;
    s.push(i);
  }
  long long res = 0;
  for (int i = 0; i < n; i++) {
    res = std::max(res, (long long)h[i] * (R[i] - L[i]));
  }
  return res;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  vector<sz> h(N); rep(i,N) cin >> h[i];
  cout << maximum_rectangle(h) << endl;
  return 0;
}


Measured memory_bytes: 6072
use std::str::FromStr;

trait Readable: std::marker::Sized {
    fn read(s: &str) -> Self;
    fn read_line(s: String) -> Self {
        Self::read(&s)
    }
}

impl Readable for String {
    fn read(s: &str) -> String { s.to_string() }
    fn read_line(s: String) -> String { s }
}

impl Readable for f64 {
    fn read(s: &str) -> f64 { f64::from_str(s).expect("cannot parse f64") }
}

impl Readable for isize {
    fn read(s: &str) -> isize { isize::from_str(s).expect("cannot parse isize") }
}

impl Readable for i8 {
    fn read(s: &str) -> i8 { i8::from_str(s).expect("cannot parse i8") }
}

impl Readable for i16 {
    fn read(s: &str) -> i16 { i16::from_str(s).expect("cannot parse i16") }
}

impl Readable for i32 {
    fn read(s: &str) -> i32 { i32::from_str(s).expect("cannot parse i32") }
}

impl Readable for i64 {
    fn read(s: &str) -> i64 { i64::from_str(s).expect("cannot parse i64") }
}

impl Readable for usize {
    fn read(s: &str) -> usize { usize::from_str(s).expect("cannot parse usize") }
}

impl Readable for u8 {
    fn read(s: &str) -> u8 { u8::from_str(s).expect("cannot parse u8") }
}

impl Readable for u16 {
    fn read(s: &str) -> u16 { u16::from_str(s).expect("cannot parse u16") }
}

impl Readable for u32 {
    fn read(s: &str) -> u32 { u32::from_str(s).expect("cannot parse u32") }
}

impl Readable for u64 {
    fn read(s: &str) -> u64 { u64::from_str(s).expect("cannot parse u64") }
}

impl<T1: Readable, T2: Readable> Readable for (T1, T2) {
    fn read(s: &str) -> (T1, T2) {
        let items: Vec<&str> = s.split(' ').collect();
        assert!(items.len() == 2);
        (T1::read(items[0]), T2::read(items[1]))
    }
}

impl <T1: Readable, T2: Readable, T3: Readable> Readable for (T1, T2, T3) {
    fn read(s: &str) -> Self {
        let items: Vec<&str> = s.split(' ').collect();
        assert!(items.len() == 3);
        (T1::read(items[0]), T2::read(items[1]), T3::read(items[2]))
    }
}

#[allow(dead_code)]
fn read<T: Readable>() -> T {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();

    let last = line.pop();
    match last {
        Some(ch) if ch != '\n' => line.push(ch),
        _ => ()
    }

    T::read_line(line)
}

#[allow(dead_code)]
fn read_lines<T: Readable>() -> Vec<T> {
    use std::io::{stdin, BufRead};
    let mut v = Vec::new();
    let stdin = stdin();
    for line in stdin.lock().lines() {
        v.push(T::read_line(line.unwrap()));
    }
    v
}

fn main() {
    let (_, capacity, persistence): (u32, u32, u32) = read();
    let mut ts: Vec<u32> = read_lines();
    ts.sort();
    let mut i = 0;
    let mut bus_count = 0;

    while i < ts.len() {
        bus_count += 1;
        let limit = ts[i] + persistence;

        i += 1;
        let mut boarded = 1;
        while i < ts.len() && ts[i] <= limit && boarded < capacity {
            i += 1;
            boarded += 1;
        }
    }

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


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

string S;
vector<int> can_lists;

int main(){
    cin >> S;
    int num = S.length();
    int tmp = 0;
    for (int i = 0; i < num; i++){
        if ((S[i] == 'A') || (S[i] == 'T') || (S[i] == 'G') || (S[i] == 'C')){
            tmp += 1;
            // cout << tmp << endl;
        }
        else{
            can_lists.push_back(tmp);
            tmp = 0;
        }
    }
    if (tmp != 0){
        can_lists.push_back(tmp);
    }
    int maximum = 0;
    for (int i = 0; i < can_lists.size(); i++){
        if (maximum < can_lists[i]){
            maximum = can_lists[i];
        }
    }
    cout << maximum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<vector>
#include<cmath>
#include<set>
using namespace std;
int main() {
	int n, x;
	cin >> n >> x;
	vector<int> l(n), sum(n + 1, 0);
	for(int i = 0; i < n; ++i) {
		cin >> l[i];
		if(i != 0)
			sum[i] += (sum[i - 1] + l[i]);
		else
			sum[i] += l[i];
		if(sum[i] > x) {
			cout << i+1 << endl;
			return 0;
		}
	}
	cout << n+1 << endl;
}

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

using namespace std;

using int64 = long long;

int main() {
  vector< int > V(3);
  cin >> V[0] >> V[1] >> V[2];
  int ret = 0;
  sort(begin(V), end(V));
  while(V[0] != V[2]) {
    if(V[1] < V[2]) ++V[0], ++V[1];
    else if(V[0] + 2 <= V[2]) ++V[0], ++V[0];
    else ++V[2], ++V[0];
    ++ret;
    sort(begin(V), end(V));
  }
  cout << ret << endl;
}

Measured memory_bytes: 768
# import math
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque
# from collections import Counter

import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())

if n%2 == 0:
    ans = 0.5
elif n==1:
    ans = 1.0
else:
    ans = (n+1)/(2*n)

print("{0:.10f}".format(ans))

Measured memory_bytes: 12484
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    if (S[0]=='1' || S[0]=='0' || S[0]=='6' || S[0]=='8') cout << "pon"; 
    else if (S[0]=='2' || S[0]=='4' || S[0]=='5' || S[0]=='7' || S[0]=='9') cout << "hon"; 
    else cout << "bon";
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define all(z) (z).begin(),(z).end() 
#define MOD 1000000007
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll isprime(ll n)
{
	for(int i=2;i<n;i++)
		if(n%i==0)
		return 0;
		
	return 1;	
}
int main()
{ 
    FAST;
	string s,t;
	cin>>s;
	cin>>t;
	ll s1=s.size();
	ll t1=t.size();
	ll m=INT_MAX;
	for(int i=0;i<s1-t1+1;i++)
	{
		ll tmp=0;
		ll cnt=0;
		for(int j=0;j<t1;j++)
		{
			//cout<<t[j]<<" "<<s[i+tmp]<<endl;
			if(t[j]==s[i+tmp])cnt++;
			tmp++;
		}
		//cout<<cnt<<endl;
		m=min(m,t1-cnt);
	}
	cout<<m;
	
}


Measured memory_bytes: 3588
#include <stdio.h>

int main(){

int S, h, m, s;

scanf("%d", &S);

if(S >= 86400){
return 0;}

else{

h = S/3600;
m = (S%3600)/60;
s = (S%60);

printf("%d:%d:%d\n",h, m, s);

return 0;

}

}

Measured memory_bytes: 592
n = int(input())
a = input()
b = input()
c = input()
ans = 0
for i in range(n):
    if a[i] == b[i] and b[i] == c[i]:
        pass
    elif a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
        ans += 1
    else:
        ans += 2
print(ans)

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

int main(){
      int N;
      cin >> N;
      long long sum=1,x=10,y=9;
      x=pow(x,y);
      for(int i=1; i<=N; i++){
        sum *= i;
        sum = sum%(x+7);
      }
      sum = sum%(x+7);
      cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#define int long long
#define mod 1000000007
#define puts(x) cout << x << endl
using namespace std;
int ans, n, k;
signed main() {
	cin >> n >> k;
	for (int i = k; i <= n + 1; i++)ans = (ans + i * (n - i + 1) + 1) % mod;
	puts(ans);
}

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

int main()
{
  string s;
  ll k;
  cin >> s >> k;
  char ans = '1';
  if(k == 1) cout << s[0] << endl;
  else{
    int n = s.size();
    rep(i, n){
      if(k == i) break;
      if(s[i] == '1') continue;
      ans = s[i];
      break;
    }
    cout << ans << endl;
  }
       

  return 0;
}


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

int64_t combination(int n, int r) {
    if (r * 2 > n) r = n - r;
    int64_t dividend = 1;
    int64_t divisor = 1;
    for (int i = 1; i <= r; ++i) {
        dividend *= (n - i + 1);
        divisor *= i;
    }
    return dividend / divisor;
}

int main() {
    int N;
    cin >> N;
    vector< int > A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }

    map< int, int > cnt_map;
    for (int i = 0; i < N; i++) {
        if (cnt_map.count(A.at(i))) {
            ++cnt_map[A.at(i)];
        } else {
            cnt_map[A.at(i)] = 1;
        }
    }

    map< int, int64_t > ans_map;
    int64_t ans = 0;
    for (auto p : cnt_map) {
        if (p.second == 1) {
            ans_map[p.first] = 0;
        } else {
            int64_t com = combination(p.second, 2);
            ans_map[p.first] = com;
            ans += com;
        }
    }

    for (int i = 0; i < N; i++) {
        int64_t a = ans;
        int cnt = cnt_map[A.at(i)];
        if (cnt == 1) {
        } else if (cnt == 2) {
            --a;
        } else {
            a -= ans_map[A.at(i)];
            a += combination(cnt - 1, 2);
        }
        cout << a << endl;
    }
}

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

#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define fst first
#define snd second

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> b(n);
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    vector<char> used(n, false);
    vector<int> a;
    vector<int> ans;
    for (int i = 0; i < n; i++)
    {
        bool ok = false;
        for (int j = n - 1; j >= 0; j--)
        {
            if (used[j])
                continue;
            int cnt = 0;
            for (int k = j; k < n; k++)
                if (used[k])
                    cnt++;
            if (SZ(ans) + 1 - b[j] == cnt)
            {
                used[j] = true;
                ans.PB(b[j]);
                a.insert(a.begin() + b[j] - 1, b[j]);
                ok = true;
                break;
            }
        }
        if (!ok)
        {
            cout << -1;
            return 0;
        }
    }
    for (auto x : ans)
    {
        cout << x << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N, M, ans = 0;
  cin >> N >> M;
  vector<int> H(N);
  vector<pair<int, int>> AB(M);
  for (int i=0; i<N; i++) cin >> H[i];
  for (int i=0; i<M; i++) {
    cin >> AB[i].first >> AB[i].second;
    if (AB[i].first>AB[i].second) swap(AB[i].first, AB[i].second);
  }
  sort(AB.begin(), AB.end());
  vector<bool> memo(N, true);
  for (int i=0; i<M; i++) {
    if (H[AB[i].first-1]<H[AB[i].second-1]) memo[AB[i].first-1] = false;
    else if (H[AB[i].first-1]>H[AB[i].second-1]) memo[AB[i].second-1] = false;
    else memo[AB[i].first-1] = false, memo[AB[i].second-1] = false;
  }
  for (int i=0; i<N; i++) {
    if (memo[i]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4580
#include<stdio.h>
#include<string.h>
int MAX(int a,int b){return a<b?b:a;}
int P[1010],L[1010],R[1010],H[1010],C=1;
//int hyouka(int i,int x){return N[i]<=x?N[i]<x?-1:0:1;}
char N[1010][110];
int hyouka(int i,char *s){return strcmp(s,N[i]);}
int h(int a){return H[R[a]]-H[L[a]];}
void rotr(int a){//printf("r %d\n",a);
  int b=L[a],r=P[a];
  L[r]==a?(L[r]=b):(R[r]=b);
  if(R[b])P[R[b]]=a;
  L[a]=R[b];
  R[b]=P[b];
  P[b]=P[a];
  P[a]=b;
  H[a]=MAX(H[L[a]],H[R[a]])+1;
  H[b]=MAX(H[L[b]],H[L[b]])+1;
}
void rotl(int a){//printf("l %d\n",a);
  int b=R[a],r=P[a];
  L[r]==a?(L[r]=b):(R[r]=b);
  if(L[b])P[L[b]]=a;
  R[a]=L[b];
  L[b]=P[b];
  P[b]=P[a];
  P[a]=b;
  H[a]=MAX(H[L[a]],H[R[a]])+1;
  H[b]=MAX(H[L[b]],H[R[b]])+1;
}
int mfind(char *x){
  int i,j,r,n;
  if(C==1){
    L[0]=C;
    //N[C]=x;
    strcpy(N[C],x);
    H[C]=1;
    P[C++]=0;
    return 1;
  }
  for(i=L[0];r=hyouka(i,x);i=n){//printf("%d %s\n",r,x);
    if(r<0){
      if(L[i]==0){
	L[i]=C;
	P[C]=i;
	H[i]=MAX(2,H[i]);
	//N[C]=x;
	strcpy(N[C],x);
	H[C]=1;
	C++;
      }
      n=L[i];
    }
    else{
      if(R[i]==0){
	R[i]=C;
	P[C]=i;
	H[i]=MAX(2,H[i]);
	strcpy(N[C],x);
	//N[C]=x;
	H[C]=1;
	C++;
      }
      n=R[i];
    }
  }//printf("%d\n",i);
  //for(j=0;j<C;j++)printf(":%d %d %d %d %s\n",P[j],L[j],R[j],H[j],N[j]);
  j=P[i];
  while(1){
    H[j]=MAX(H[L[j]],H[R[j]])+1;
    if(h(j)<-1){
      if(h(L[j])>0)rotl(L[j]);
      rotr(j);
      break;
    }
    if(h(j)>1){
      if(h(R[j])<0)rotr(R[j]);
      rotl(j);
      break;
    }
    if(h(j)==0)break;
    j=P[j];
    if(j==0)break;
  }//printf("%d\n",i);
  return i;
}      
void prim(int n){
  int i;
  if(L[n])prim(L[n]);
  for(i=0;i<H[n];i++)printf("  ");
  printf("%s\n",N[n]);
  if(R[n])prim(R[n]);
}
/*int main(){
  int n,i;
  //for(i=0;i<100;i++)H[i]=-1;
  char s[10];
  while(~scanf("%s",s)){
    printf("%d\n",mfind(s));
    for(i=0;i<C;i++)printf("%d %d %d %d %s\n",P[i],L[i],R[i],H[i],N[i]);
    prim(L[0]);printf("end\n");
  }
  return 0;
}/*/
int main(){
  int i,l,max=0,mj=1,r,a[1010]={};
  char *c,*mi,s[1020];
  fgets(s,1010,stdin);
  mi=strtok(s," \n");
  a[mj=mfind(mi)]++;
  max=strlen(mi);
  // printf("%s\n",mi);
  while(c=strtok(NULL," \n")){
    //printf("%s\n",c);
    a[r=mfind(c)]++;
    //printf("%d\n",r);
    l=strlen(c);//printf("%s %d\n",mi,l);
    if(max<l){
      max=l;
      strcpy(mi,c);
    }//printf("a\n");
    if(a[r]>a[mj])mj=r;//printf("a\n");
  }
  //printf("%s %d\n",mi,mj);
  printf("%s %s\n",N[mj],mi);
  return 0;
  }//*/

Measured memory_bytes: 564
/*
ID: jayyesh
LANG: C++                 
*/

#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
    string s1,s2,temp;
    int a,b;
    cin>>s1>>s2>>a>>b>>temp;
    if(!(s1.compare(temp)))
    {
        a--;
    }
    else
    {
        b--;
    }
    cout<<a<<" "<<b;
        

    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#define rep(i, n) for(int i=0; i<(int)(n); i++)
inline void cmax(int &a, int b) { if(a<b) a=b; }
#define INF (1<<28)

int L, N, M, X, se[200], ss[200], e[200], s[200], dp[200][1024];
char buf[128];

int main() {
    for(;;) {
        scanf("%d%d%d%d", &L, &N, &M, &X);
        if(L==0) return 0;
        rep(i, N) scanf("%s%d%d", buf, se+i, ss+i);
        rep(i, M) scanf("%s%d%d", buf, e+i, s+i);
        rep(i, 200) rep(j, 1024) dp[i][j] = -INF;
        dp[0][0] = 0;
        rep(k, M) for(int i=k; i>=0; i--) rep(j, L+1-e[k]) {
            cmax(dp[i+1][j+e[k]], dp[i][j]+s[k]);
        }
        for(int x=X+1; x<=M; x++) rep(i, L+1) cmax(dp[X][i], dp[x][i]);
        rep(i, L) cmax(dp[X][i+1], dp[X][i]);
        int ans = -INF;
        rep(i, N) if(se[i]<=L) {
            cmax(ans, ss[i]+dp[X][L-se[i]]);
            rep(j, i) if(se[i]+se[j]<=L) {
                cmax(ans, ss[i]+ss[j]+dp[X][L-se[i]-se[j]]);
            }
        }
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n; cin >> n;
    if(n == 25) cout << "Christmas" << endl;
    else if(n == 24) cout << "Christmas Eve" << endl;
    else if(n == 23) cout << "Christmas Eve Eve" << endl;
    else if(n == 22) cout << "Christmas Eve Eve Eve" << endl;
}

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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  map<int, int> m;
  for (int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    if (s == 1 && c == 0 && N > 1) {
      cout << -1 << endl;
      return 0;
    }
    auto it = m.find(s);
    if (it != m.end() && it->second != c) {
      cout << -1 << endl;
      return 0;
    }
    m[s] = c;
  }

  for (int x = 0; x <= 9; x++) {
    for (int y = 0; y <= 9; y++) {
      for (int z = 0; z <= 9; z++) {
        const int n = 100 * x + 10 * y + z;
        if (N == 3 && n <= 99) continue;
        if (N == 2 && (n < 10 || n >= 100)) continue;
        if (N == 1 && (n >= 10)) continue;

        bool ok = true;
        for (const auto p : m) {
          auto s = p.first;
          auto c = p.second;
          if (N == 1 && s == 1) ok = (c == z);
          if (N == 2 && s == 1) ok = (c == y);
          if (N == 2 && s == 2) ok = (c == z);
          if (N == 3 && s == 1) ok = (c == x);
          if (N == 3 && s == 2) ok = (c == y);
          if (N == 3 && s == 3) ok = (c == z);
          if (!ok) break;
        }
        if (ok) {
          cout << n << endl;
          return 0;
        }
      }
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
#define MOD 1000000007
typedef long long ll;
//------------------------------------------------------------------------

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

  int n,r; cin >> n >> r;

  if(n>=10) cout << r << endl;
  else {
    cout << r + (100*(10-n)) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;


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

  string s;
  cin >> s;
  if (s[0]==s[s.length()-1]){
    cout << ((s.length()%2==0) ? "First" : "Second") << "\n";
  } else {
    cout << ((s.length()%2==1) ? "First" : "Second") << "\n";
  }
  return 0;
}


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

int main(){
  string a;
  int b=0;
  cin>>a;
  rep(i,3){
    if(a.at(i)=='1'){
      b++;
    }
  }
  cout<<b<<endl;

}

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

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 101010
#define DEBUG_OUT true

#define ALL(x) (x).begin(), (x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//BELOW
//-----CODE------//

void DFS(int v,int p,vector<vector<pair<int,int> > > & graph,vector<int> & dist)
{
  for (auto &&x : graph[v])
  {
    if(x.first == p)continue;

    dist[x.first] = dist[v]^x.second;

    // DEBUG(x.first,v,p,dist[p],dist);
    DFS(x.first,v,graph,dist);
  }
  
}

void DFS2(int v,int p,int d,int xx,vector<int> & dist,vector<vector<pair<int,int> > > & graph,map<int,int> & cnt,int &res)
{
  res += cnt[xx^d];
  for (auto &&x : graph[v])
  {
    if(x.first == p)continue;
    DFS2(x.first,v,dist[x.first],xx,dist,graph,cnt,res);
  }
  
}

  

void solve(void)
{
  int n;cin>>n;
  vector<int> vec (n,0);
  int sum = 0;
  for (int i = 0; i < n; i++)
  {
     cin>>vec[i];
     sum += vec[i];
  }  
  int k = n*(n+1)/2;
  int valid_flg = 1;
  if(sum%k != 0) valid_flg = 0;
  int cnt = sum/k;
  for (int i = 0; i < n; i++)
  {
     int b = vec[(i+1)%n] - vec[i] - cnt;
     if(b%n != 0 || b > 0)valid_flg = 0;
  }
  if(valid_flg)
  {
    cout<<"YES"<<endl;
  }
  else
  {
    cout<<"NO"<<endl;
  }
  
  


  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3992
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

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

  int a;
  cin>>a;
  
  cout<<a+a*a+a*a*a<<endl;

  return 0;
}

Measured memory_bytes: 3644
import scala.collection.mutable.ListBuffer
import scala.io.StdIn.readLine

object Main extends App {
  val lines = Iterator.continually(readLine()).takeWhile { _ != "-" }

  val datasets = {
    val buf = ListBuffer.empty[(String, Seq[Int])]

    while (lines.hasNext) {
      val line = lines.next()
      val m    = lines.next().toInt
      val xs   = Seq.fill(m)(lines.next().toInt)
      buf.append((line, xs))
    }

    buf.toList
  }

  val results = datasets.map {
    case (line, xs) =>
      xs.foldLeft(line) { (s, n) =>
        val (a, b) = s.splitAt(n)
        b + a
      }
  }

  results.foreach(println)
}



Measured memory_bytes: 44060
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  ll A[N];
  for(int i=0;i<N;++i) cin>>A[i];
  ll ans = 0;
  ll maxa = A[0];
  for(int i=1;i<N;++i) {
    if(maxa>A[i]) {
      ans += maxa-A[i];
    }
    else maxa = A[i];
  }
  cout<<ans<<endl;
}



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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> t chmax(t&a,u b){if(a<b)a=b; return a;};
template<class t, class u> t chmin(t&a,u b){if(a>b)a=b; return a;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

ll N;
vector<vector<vector<double>>> dp;

double search(ll a3, ll a2, ll a1){
  if(dp[a3][a2][a1]>=0.0) return dp[a3][a2][a1];
  if(a3==0 && a2==0 && a1==0) return 0.0;
  ll n = a3+a2+a1;
  double ans = (double)N/n;
  if(a3) ans += a3*search(a3-1, a2+1, a1)/n;
  if(a2) ans += a2*search(a3, a2-1, a1+1)/n;
  if(a1) ans += a1*search(a3, a2, a1-1)/n;
  return dp[a3][a2][a1] = ans;
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  IN(N);
  vll P(4, 0);
  REP(i,N){
    ll a;
    IN(a);
    P[a]++;
  }
  dp.resize(P[3]+1, vector<vector<double>>(P[3]+P[2]+1, vector<double>(N+1, -1.0)));
  dp[0][0][0] = 0.0;

  printf("%.12lf\n", search(P[3], P[2], P[1]));

  return 0;
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;

int N;
pii XD[200200];
int righ[200200];
int righ2[200200];
int dp[200200];

signed main() {
    cin >> N;
    rep(i, N) {
        int x, d;
        cin >> x >> d;
        XD[i] = pii(x, d);
    }
    sort(XD, XD + N);
    for (int i = N - 1; i >= 0; --i) {
        if (i == N - 1) {
            righ[i] = N;
            righ2[i] = N;
            continue;
        }
        int idx = lower_bound(XD, XD + N, pii(XD[i].first + XD[i].second, 0)) - XD - 1;
        //ロボットi+1,i+2,...idxの中で最も右
        if (idx == i) {
            righ[i] = i + 1;
            righ2[i] = i + 1;
            continue;
        }
        righ[i] = righ2[idx];
        for (int j = i; righ2[j] < righ[i]; ++j) {
            righ2[j] = righ[i];
        }
    }
    
    dp[N] = 1;
    for (int i = N - 1; i >= 0; --i) {
        if (i == N - 1) {
            dp[i] = 2;
            continue;
        }
        dp[i] = dp[i + 1];//i番目を起動しない
        dp[i] += dp[righ[i]];//i番目を起動する
        dp[i] %= 998244353;
    }
    int ans = dp[0];
    ans += 998244353;
    ans %= 998244353;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8064
import fractions

N,X = map(int,input().split())
x = list(map(int,input().split()))

y = [0] * N
for i in range(N):
    y[i] = abs(X-x[i])

ans = y[0]
for i in range(1,N):
    ans = fractions.gcd(ans,y[i])
print(ans)


Measured memory_bytes: 16368
#include<iostream>
#include<cstdio>
using namespace std;
const int INF=-1;
int main(){
    int W,cnt=0;
    while(cin>>W,W){
        cnt++;
        int dp[1001],n;
        cin>>n;

        for(int i=0;i<1001;i++)dp[i]=INF;

        dp[0]=0;
        for(int i=0;i<n;i++){
            int v,w;
            scanf("%d,%d",&v,&w);
            for(int j=W;j>=0;j--){
                if(dp[j]==INF)continue;
                if(j+w>W)continue;
                dp[j+w]=max(dp[j+w],dp[j]+v);

            }
        }
        pair<int,int>P;
        P.first=0;
        for(int i=0;i<=W;i++){
            if(dp[i]>P.first){
                P.first=dp[i];
                P.second=i;
            }
        }
        cout<<"Case "<<cnt<<":"<<endl;
        cout<<P.first<<endl<<P.second<<endl;
    }
    return 0;

}

Measured memory_bytes: 1244
//http://kamui108.hatenablog.com/entry/2014/12/08/224628
//↑参考にさせて頂いた解説

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>
#include <cstring>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll INF = 1e13 + 7;

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

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

int main()
{
    int N, K, MOD = 10000;
    cin >> N >> K;
    map<int, int> data;
    for (int i = 0; i < K; i++)
    {
        int a, b;
        cin >> a >> b;
        data[a] = b;
    }
    int dp[200][3][3]={0};//一つでも変数が使われていると0初期化されない？
    for (int i = 1; i <= N; i++)
    {
        map<int, int>::iterator pa;
        bool it = false;
        if (data.find(i) != data.end())
        { //i日に予定があるかどうか
            pa = data.find(i);
            it = true;
        }

        if (i == 1)
        { //1日目のみの処理、初期化とも言える？
            if (it)
            {                                 //予定がある場合。
                dp[i][pa->second - 1][1] = 1; //予定のパスタの種類に代入
            }
            else
            { //ない場合。
                for (int j = 0; j < 3; j++)
                { //全ての通りが考えられるため全てのパスタの種類に代入。また、連続日数はi=1のため1固定
                    dp[i][j][1] = 1;
                }
            }
        }
        else
        {
            if (it)
            { //i≠1の時に予定がある場合。
                for (int j = 0; j < 3; j++)
                { //for文によって予定の料理とかぶるか被らないかを判定、処理している？
                    if (j != pa->second - 1)
                        dp[i][pa->second - 1][1] += dp[i - 1][j][1] + dp[i - 1][j][2]; //被らなかったときに、i日目の被らなかったメニューの場所へにi-1日,及び、i-2日の通り数を足して代入する。
                    dp[i][pa->second - 1][1] %= MOD;                                   //modで割る
                }
                dp[i][pa->second - 1][2] = dp[i - 1][pa->second - 1][1]; //下段のコメントと同一と思われる
            }
            else
            {
                for (int k = 0; k < 3; k++)
                {
                    for (int j = 0; j < 3; j++)
                    { //連続しない時の通りを処理
                        if (j != k)
                            dp[i][k][1] += dp[i - 1][j][1] + dp[i - 1][j][2]; //パスタが被らないときは連続日数を1にして、jのパスタの前日までの連続日数1と2の日の通りを足す。
                        dp[i][k][1] %= MOD;
                    }
                    dp[i][k][2] = dp[i - 1][k][1]; //連続するということはパスタの種類が同一でなければならないため。
                }
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < 3; i++)
    {
        ans += dp[N][i][1] + dp[N][i][2]; //最終日の通り全てを足す。
    }
    cout << ans % MOD << endl;
    return 0;
}

//a=97,z=122


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  string s;
  cin>>s;
  string s1;
  rep(i,s.size()){
    if(s[i]=='1'){
      s1+='1';
    }
    if(s[i]=='0'){
      s1+='0';
    }
    if(s[i]=='B'&&s1.size()!=0){
      s1.pop_back();
    }
  }
  cout<<s1<<endl;
}

Measured memory_bytes: 3644
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val dd = readLine()!!.split(" ").map { it.toInt() }
    val m = readLine()!!.toInt()
    val mm = readLine()!!.split(" ").map { it.toInt() }

    val dSet = mutableMapOf<Int, Int>()
    dd.forEach {
        dSet[it] = (dSet[it] ?: 0)+1
    }

    mm.forEach {
        dSet[it] = (dSet[it] ?: 0) - 1

        if (dSet[it]!! < 0) {
            println("NO")
            return
        }
    }

    println("YES")
}

Measured memory_bytes: 125316
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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


int main() {
	int n, k;
	cin >> n >> k;
	vector<ll> h(n);
	rep(i, n) cin >> h[i];
	sort(h.begin(), h.end());

	int res = INF;
	rep(i, n - k + 1) {
		int tmp = h[i + k - 1] - h[i];
		if (tmp < res) res = tmp;
	}
	cout << res << endl;
	return 0;
}

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


int main(){
    int n, m;
    cin >> n >> m;
    int X[m];
    rep(i,m) cin >> X[i] ;
    sort(X,X+m, greater<int>());
    int l = X[0]-X[m-1];

    if (n >= m){
        cout << 0 << endl;
        return 0;
    }

    int span[m-1];
    rep(i,m-1){
        span[i] = X[i] - X[i+1];
    }
    sort(span,span+m-1,greater<int>());
    rep(i,n-1){
        l -= span[i];
    }
    cout << l << endl;
    return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3

from pprint import pprint
from bisect import bisect_left
import sys

sys.setrecursionlimit(10 ** 6)
INF = float('inf')


N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
# print(N, A)

# 到着する順番は降順が最適
# 足せる回数は合計 N-1 回
# 最初の数字は 1 回、他は高々 2 回足される

ans = 0
times = N - 1

for i in range(N):
    limit = 2
    if i == 0:
        limit = 1
    for _ in range(limit):
        if times > 0:
            ans += A[i]
            times -= 1

print(ans)


Measured memory_bytes: 103380
#include <stdio.h>
#include <string.h>

#define M 1046527
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  else return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return 1+(key%(M-1)); }

int find(char str[]){
  long long key,i,h;
  key=getKey(str);
  for(i=0;; i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0) return 1;
    else if(strlen(H[h])==0) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key=getKey(str);
  for(i=0; ; i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0) return 1;
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



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

int main()
{
  string O, E;
  cin >> O >> E;
  int n = min(O.size(),E.size());
  for(int i = 0; i < n; i++)
    cout << O[i] << E[i];
  if(O.size() > n) cout << O[O.size()-1];
  cout << endl;
}

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

S = input().strip()
a = 0
sum_a = 0
c = 0
for s in S:
    if s == '<':
        if c > a:
            sum_a += int((1 + c) * c / 2 - a)
            a = 1
            sum_a += 1
            c = 0
        elif c > 0:
            sum_a += int((c) * (c - 1) / 2)
            a = 1
            sum_a += 1
            c = 0
        else:
            a += 1
            sum_a += a
            c = 0
    else:
        c += 1
else:
    if c > a:
        sum_a += int((1 + c) * c / 2  - a)
        a = 1
        c = 0
    elif c > 0:
        sum_a += int((c) * (c - 1) / 2)
        a = 1
        c = 0

print(sum_a)

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

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INF = pow(2,29);
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  int d[N]; rep(i,N) cin >> d[i];

  int result = 0;
  rep(i,N) rep(j,N) {
    if (i>j) result += d[i]*d[j];
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
heights = list(map(int,input().split()))
dp = [10**10 for i in range(n)]
dp[0] = 0
for i in range(n):
    for j in range(1,3):
        if(i-j>= 0):
            dp[i] = min(dp[i],dp[i-j] + abs(heights[i] - heights[i-j]))

print(dp[n-1])


Measured memory_bytes: 13976
a, b, k = map(int, input().split())


for i in range(k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
            a /= 2
            b += a            
        else:
            a /= 2
            b += a
    else:
        if b % 2 == 1:
            b -= 1
            b /= 2
            a += b
        else:
            b /= 2
            a += b

print(int(a), int(b))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    int n; cin >> n;
    string s; cin >> s;

    vector<vector<int>> dp(n+5, vector<int>(n+5, 0));
    int ans = 0;

    rep(i, n) repr(j, i+1, n) {
        if (s[i] == s[j]) dp[i+1][j+1] = min(j-i, dp[i][j]+1);
        else dp[i+1][j+1] = 0;
        chmax(ans, dp[i+1][j+1]);
    }
    cout << ans << endl;


    return 0;
}


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


int main() {
  int N;
  cin >> N;
  for (int a = 1;a < 10;a++){
  if(N%a == 0 && N/a < 10){
  cout << "Yes" << endl;
    break;
  }
  else if (a == 9 &&( N%9 != 0 || N/9 >= 10)){
   cout << "No" << endl;
   }
  }
  
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll k,a,b;
int main(){
	scanf("%lld%lld%lld",&k,&a,&b);
	if(k+1<=a||b<=a+2){
		printf("%lld",k+1);
		return 0;
	}
	ll s=a;
	k-=a-1;
	printf("%lld",s+(b-a)*(k/2)+(k%2));
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
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; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int d; cin >> d;
    string ans = "";
    if (d == 25) ans = "Christmas";
    else if (d == 24) ans = "Christmas Eve";
    else if (d == 23) ans = "Christmas Eve Eve";
    else ans = "Christmas Eve Eve Eve";
    cout << ans << endl;
}

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

#define forn(i, a, b) for (int i = a; i <= b; ++i)
#define forr(i, a, b) for (int i = a; i >= b; --i)

using namespace std;

const int N = (int)1e5 + 1;
const int INF = 1e9 + 7;

typedef long long ll;
typedef long double ld;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

int n, cura, curb, curc;
int main (){
  scanf ("%d", &n);
  int ok = 1;
  forn (i, 1, n){
    int a, b, c;
    scanf ("%d %d %d", &a, &b, &c);
    int d = abs(curb - b) + abs(curc - c);
    if (d <= (a - cura) && ((a - cura) % 2 == d % 2)){
      cura = a;
      curb = b;
      curc = c;
    } else ok = 0;
  }
  if (ok == 0) return printf ("No\n"), 0;
  printf ("Yes\n");
  return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)

double cutline_even(int i, int n, int r) {
	if (i <= 0 || i >= n) {
		return 0;
	}
	if (i == n / 2) {
		return 2 * r;
	}
	else {

		return  2*sqrt(pow(r,2)-pow(2*r*1.0/n*abs(n/2-i),2));
	}
}

double cutline_odd(int i, int n, int r) {
	if (i <= 0 || i >= n) {
		return 0;
	}
	else if (i > n / 2) {
		i = n - i;
	}
	int m = n / 2;
	return 2*sqrt(r*r - pow(r*1.0 / n + 2 * r*1.0 / n*(m - i), 2));
}


int main() {

	int n;
	cin >> n;

	vector<pair<int, int> > p(n);
	REP(i, n) {
		int a, b;
		cin >> a >> b;
		p[i] = make_pair(a, b);
	}
	SORT(p);
	int ans = 0;
	
	ans += p[0].first - 1;

	ans += p[n - 1].second;

	ans += p[n - 1].first - p[0].first + 1;

	ANS(ans);
	
	return 0;
}



Measured memory_bytes: 1024
t = [0]
x = [0]
y = [0]
n = int(input())
for i in range(n):
    ti, xi, yi = map(int, input().split())
    t.append(ti)
    x.append(xi)
    y.append(yi)
    
flg=True
for i in range(1, n+1):
    if((x[i]-x[i-1])+(y[i]-y[i-1])>(t[i]-t[i-1])):
        flg=False
    elif(((x[i]-x[i-1])+(y[i]-y[i-1]))%2!=(t[i]-t[i-1])%2):
        flg=False
if(flg):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 11816