akhauriyash/Code-Regression huggingface dataset:
#include <queue>
#include <set>
#include <unordered_set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
typedef pair<int,int> pii;

/// pair<int,int> hasher
namespace std{
	template<typename I>
	class hash<pair<I,I>>{
		public:
		size_t operator()(const pair<I,I> &p) const {return hash<long long>() (((long long)(p.first))<<32|p.second);}
	};
}

double solve(const vector<pii> &a){
	set<int>ys;
	for(auto &e:a)ys.insert(e.second);
	int n=a.size();
	vector<double>mx,my;
	for(int i=0;i<n;i++){
		mx.push_back(a[i].first);
		my.push_back(a[i].second);
		if(i==n-1)continue;
		//??????????????§y??§?¨??????????ys?????????????????????
		if(a[i].second<a[i+1].second){ //??????i????°???§??????
			for(auto it=ys.begin();it!=ys.end();++it){
				if(a[i].second<*it && *it<a[i+1].second){
					double dy=a[i+1].second-a[i].second;
					double dx=(a[i+1].first-a[i].first)/dy*(*it-a[i].second);
					mx.push_back(a[i].first+dx);
					my.push_back(*it);
				}
			}
		}else{ //??????i????±±??§??????
			for(auto it=ys.end();it--!=ys.begin();){
				if(a[i+1].second<*it && *it<a[i].second){
					double dy=a[i+1].second-a[i].second;
					double dx=(a[i+1].first-a[i].first)/dy*(*it-a[i].second);
					mx.push_back(a[i].first+dx);
					my.push_back(*it);
				}
			}
		}
	}
	int m=mx.size();
	priority_queue<pair<double,pii>>q;
	unordered_set<pii>se;
	q.push({0,{0,m-1}});
	for(;!q.empty();){
		double c=q.top().first;
		int l=q.top().second.first;
		int r=q.top().second.second;
		q.pop();
		if(se.find({l,r})!=se.end())continue;
		se.insert({l,r});
		if(l==r)return -c;
		for(int i=-1;i<2;i++)for(int j=-1;j<2;j++)
			if(0<=l+i&&l+i<m && 0<=r+j&&r+j<m && fabs(my[l+i]-my[r+j])<1e-9)
				q.push({c-hypot(mx[l]-mx[l+i],my[l]-my[l+i])-hypot(mx[r]-mx[r+j],my[r]-my[r+j]),{l+i,r+j}});
	}
	abort();
}

int main(){
	int N,x,y;
	for(;scanf("%d",&N),N;){
		vector<pii>a(N);
		for(int i=0;i<N;i++)scanf("%d%d",&a[i].first,&a[i].second);
		printf("%f\n",solve(a));
	}
}

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

int main(void) {
  string S;
  cin >> S;

  int ans = 0;
  rep(i, S.size()) {
    ans += S[i] == '+' ? 1 : -1;
  }

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3596
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug { 
    ($($a: expr),*) => { 
        println!(concat!($(stringify!($a)," = {:?}, "),*), $($a),*);
    } 
}
const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

fn gcd(a: usize, b: usize) -> usize {
    if a == usize::default() {
        b
    } else {
        gcd(b % a, a)
    }
}
fn lcm(a: usize, b: usize) -> usize {
    a * b / gcd(a, b)
}

fn solve() {
    let ( n,  m) = get!(usize, usize);
    let  s = get!(String).chars().collect::<Vec<_>>();
    let  t = get!(String).chars().collect::<Vec<_>>();

    let g = gcd(n,m);
    let nl = n/g;
    let ml = m/g;
    for i in 0..g {
        if s[i*nl] != t[i*ml] {
            println!("-1");
            return;
        }
    }
    println!("{}", lcm(n,m));
}


Measured memory_bytes: 8572
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

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

int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i; 
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

int main() {
    char S[10];
    int i, max = 0, count = 0;
    stin(S);
    REP(i, strlen(S)) {
        if (S[i] != 'A' && S[i] != 'C' && S[i] != 'G' &&S[i] != 'T') {
            if (max < count) max = count;
            count = 0;
            continue;
        }
        count++;
    }
    if (max < count) max = count;
    iout(max);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define REV(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

static const double EPS = 1e-9;

typedef pair<int, int> P;
typedef long long ll;

template<class T>
inline T sq(T a){return a*a;}

P a[3010];
int main(){
	int n;
	while(cin >> n, n){
		rep(i, n) cin >> a[i].X >> a[i].Y;
		sort(a, a+n);
		int ans = 0;
		rep(i, n) rep(j, n){
			if(i == j) continue;
			P p;
			p.X = -(a[i].Y - a[j].Y);
			p.Y = a[i].X - a[j].X;
			P u, v;
			u.X = a[i].X+p.X, u.Y = a[i].Y+p.Y;
			v.X = a[j].X+p.X, v.Y = a[j].Y+p.Y;
			if(binary_search(a, a+n, u) && binary_search(a, a+n, v)){
				ans = max(ans, sq(p.X)+sq(p.Y));
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1188
#include <stdio.h>
#include <limits.h>
long long llmax(long long a, long long b){return a>b?a:b;}

int main(void){
    long long n,k;
    scanf("%lld%lld",&n,&k);
    long long a[n],ans=LLONG_MAX;
    for (int i=0; i<n; i++){
        scanf("%lld",&a[i]);
    }
    for (int i=0; i<(1<<n); i++){
        long long score=0,count=1,tmp=a[0];

        for (int j=1; j<n; j++){
            tmp=llmax(tmp,a[j-1]);
            if ((1&i>>j)==1){
                count++;
                if (a[j]<=tmp){
                    score+=tmp-a[j]+1;
                    tmp=tmp+1;
                } else {
                    tmp=a[j];
                }
            }
        }
        if (ans>=score && count>=k){
            ans=score;
        }
    }
    printf("%lld\n",ans);
	return 0 ;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

string ss[110];

int main(void) {
  int n, len;
  cin >> n >> len;
  REP(i, n) {
    cin >> ss[i];
  }

  sort(ss, ss+n);
  REP(i, n){
    cout << ss[i];
  }
  cout << endl;
  return 0;
}


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

using namespace std;


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, H[30];
  int ans = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
      cin >> H[i];
      bool tmp = 1;
      for (int j = 0; j < i; ++j) {
          if (H[j] > H[i]) tmp = 0;
      }
      ans += tmp;
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
using ll=long long;

int main(){
    double a,b,x;
    cin>>a>>b>>x;
    double s=x/a;
    double rad;
    if(s>=a*b/2){
        double h=(a*b-s)*2/a;
        rad=atan2(h,a);
    }else{
        double w=2*s/b;
        rad=atan2(b,w);
    }
    double pi=acos(-1);
    double deg=rad/(2*pi)*360;
    printf("%.10f\n",deg);
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <vector>
#include <algorithm>

int main(void) {
    int N, B, a, b, X, i;
    scanf("%d", &N);
    std::vector<int> P(N);
    std::vector<int> Q(N);
    for (i=0; i<N; i++) scanf("%d", &P[i]);
    for (i=0; i<N; i++) scanf("%d", &Q[i]);
    a=0;
    while (1) {
        a++;
        B=1;
        for (i=0; i<N; i++) {
            if (P[i]!=i+1) {
                B=0;
                break;
            }
        }
        // for (i=0; i<N; i++) printf("%d ", P[i]);
        // printf("\n");
        if (B==1) break;
        prev_permutation(P.begin(), P.end());
    }
    b=0;
    while (1) {
        b++;
        B=1;
        for (i=0; i<N; i++) {
            if (Q[i]!=i+1) {
                B=0;
                break;
            }
        }
        if (B==1) break;
        prev_permutation(Q.begin(), Q.end());
    }
    X=a-b;
    if (X<0) X=-X;
    printf("%d", X);
    // next_permutation(s.begin(),s.end()));
}


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

int main(){
    ll n; cin >> n;
    ll num = 1;
    ll org = n;
    while(n > 0){
        num *= 26;
        n -= num;
    }
    if(n <= 0) n += num;
    n--;

    string ans = " ";
    while(num > 1){
        num /= 26;
        int ord = n / num;
        n -= ord*num;
        ans += string(1, 'a'+ord);
    }
    cout << ans.substr(1,ans.size()) << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int main(){
    int x,y; cin>>x>>y;
    int ans=0;
    if(x<y){
        ans=min(y-x,abs(y+x)+1);
    }else{
        ans=min(x-y+2,abs(y+x)+1);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
n = input()
output = 0
for i, _ in enumerate(n[::-1]):
    # if len(n) == 1:
    #     output += int(n) + 1
    if i % 2 == 0:
        if i < len(n) - 1:
            output += 10 ** (i + 1) - 10 ** i
        else:
            output += int(n) - 10 ** i + 1

print(output)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pf push_front
#define pb push_back
deque<int> A, B;
LL n;
int now = 1;

void work(LL x) {
    if (x == 1) return; else work(x / 2);
    A.pf(++now), B.pf(now);
    if (x & 1) A.pf(++now), B.pb(now);
}
 
int main() {
    cin >> n;
    work(n + 1);
    printf("%d\n", A.size() + B.size());
    for(int i = 0; i < A.size(); i++) printf("%d ", A[i]);
    for(int i = 0; i < B.size(); i++) printf("%d ", B[i]);
}

Measured memory_bytes: 256
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))

# mv_array = [set() for _ in range(n)]
# score_mv_array = [[] for _ in range(n)]
score_array = [0]*n

def get_sum(array):
    score_array = [0]
    for i, a in enumerate(array):
        score_array.append(score_array[i]+a)
    return max(score_array)

def get_max(array, q, mod):
    if q == 0:
        m_score = get_sum(array[:mod])
    else:
        m_score = get_sum(array+array[:mod])
        m_score = sum(array)*(q-1) + m_score
    return m_score

for i in range(n):
    score = 0
    max_score = c[i]
    score_mv_array = []
    pos = i
    start_pos = p[pos]-1
    for j in range(k):
        pos = p[pos]-1
        if j!=0 and pos == start_pos:
            # len_mv = len(score_mv_array)
            len_mv = j
            q, mod = divmod(k-j, len_mv)
            score += get_max(score_mv_array, q, mod)
            max_score = max(score, max_score)
            break
        score += c[pos]
        score_mv_array.append(c[pos])
        max_score = max(score, max_score)
    score_array[i] = max_score

print(max(score_array))

Measured memory_bytes: 146244
import java.util.*;
public class Main{

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int w = Integer.parseInt(sc.next());
        int h = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
        int r = Integer.parseInt(sc.next());
        
        if(x-r >= 0 && x+r <= w && y-r >= 0 && y+r <= h) System.out.println("Yes");
        else System.out.println("No");

    }

}



Measured memory_bytes: 26104
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const O = input[0][0];
  const E = input[1][0];

  const password: string[] = [];

  for (let i = 0; i < E.length; i++) {
    password.push(O[i]);
    password.push(E[i]);
  }

  if (O.length !== E.length) {
    password.push(O[O.length - 1]);
  }

  return password.join("");
};

console.log(main(read()));


Measured memory_bytes: 29584
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

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

    return 0;
}


Measured memory_bytes: 888
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint mo;
lint dp[3010][3010];
lint co[3010][3010];
lint zyo[9001001];
lint zy2[3010];
int main()
{
	int n;
	cin>>n>>mo;
	rep(i,3005){
		co[i][0]=co[i][i]=1;
		REP(j,1,i) co[i][j]=(co[i-1][j]+co[i-1][j-1])%mo;
	}
	memset(dp,0,sizeof(dp));dp[0][0]=1;
	rep(i,3005) rep(j,3005){
		if(i>0 && j>0) dp[i][j]+=dp[i-1][j-1];
		if(i>0) dp[i][j]+=dp[i-1][j]*(j+1);
		dp[i][j]%=mo;
	}
	zyo[0]=1;rep(i,9001000) zyo[i+1]=(zyo[i]*2)%mo;
	zy2[0]=2;rep(i,3005) zy2[i+1]=(zy2[i]*zy2[i])%mo;
	lint out=0;
	rep(i,n+1) rep(j,i+1){
		lint t=(dp[i][j]*co[n][i])%mo;
		t*=zyo[j*(n-i)];t%=mo;
		t*=zy2[n-i];
		//cout<<i<<' '<<j<<' '<<t<<endl;
		if(i%2==0) out+=t;else out-=t;out%=mo;
	}
	out%=mo;out+=mo;out%=mo;cout<<out<<endl;
}


Measured memory_bytes: 212224
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int mod=1000000007;
int n,top,num;
ll K,a[210],c[210],d[210];
pair<ll,ll> qj[12010];
struct node
{
    ll t[210],a1;
    int k;
}s[12010];
bool operator <(const node &a,const node &b)
{
    for(int i=1;i<n;i++)
        if(a.t[i]<b.t[i]) return 1;
        else if(a.t[i]>b.t[i]) return 0;
    return 0; 
}
bool check(node &a,node &b)
{
    for(int i=1;i<n;i++)
        if(a.t[i]!=b.t[i]) return 0;
    return 1;   
}

int maxpop(ll x,ll y)
{
    if(x==-1) return 0;
    int re=0;
    for(int i=60;i>=0;i--)
        if(((x>>i)&1)==((y>>i)&1)) re+=((x>>i)&1);
        else {re++;break;}
    return re;  
}
ll dp()
{
    sort(qj+1,qj+num+1);
    ll re=0,l=0,r=-1;
    for(int i=1;i<=num;i++)
    {
        if(qj[i].first>r) {re+=(r-l+1);l=qj[i].first;}
        r=qj[i].second;
    }
    re+=(r-l+1);
    return re;  
}
int main()
{
    scanf("%d%lld",&n,&K);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    sort(a+1,a+n+1);    
    for(int i=0;i<=60;i++)
    {
        for(int j=1;j<=n;j++)
            c[j]=(a[j]&((1ll<<i)-1));   
        sort(c+1,c+n+1);
        c[0]=-1;
        int sz=unique(c+1,c+n+1)-c-1;
        for(int j=1;j<=sz;j++)
            if(a[1]>=c[j])
            {
                int P=maxpop(c[j-1],c[j]);
                for(int l=1;l<=n;l++)
                    d[l]=((a[l]-c[j])>>i);  
                s[++top].a1=d[1];s[top].k=i+P;
                for(int l=1;l<n;l++)
                    s[top].t[l]=d[l+1]-d[l];        
            }
    }
    sort(s+1,s+top+1);
    num=0;
    ll ans=0;
    for(int i=1;i<=top;i++)
    {
        if(i!=1&&!check(s[i],s[i-1])) ans=(ans+dp())%mod,num=0; 
        if(s[i].k<=K)qj[++num]=make_pair(max(s[i].a1-K+s[i].k,0ll),s[i].a1);
    }
    ans=(ans+dp())%mod;
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 16640
#define zone(h) ( (11<=(h)&&(h)<15)?0:(18<=(h)&&(h)<21)?1:(21<=(h)&&(h)<26)?2:3 )
int a[3],b[3];
char s[9];char *r(int i){strcpy(s,"no guest");if(a[i])sprintf(s,"%d",b[i]*100/a[i]);return s;}
main(n,h,m,H,M){
	for(;scanf("%d",&n),n;){
		a[0]=a[1]=a[2]=b[0]=b[1]=b[2]=0;
		for(;n;n--){
			scanf("%d:%d %d",&h,&m,&M);
			if(h<2)h+=24;
			H=M<m?h+1:h;
			if(zone(h)>2)continue;
			a[zone(h)]++;
			if((H*60+M)-(h*60+m)<=8)b[zone(h)]++;
		}
		printf("lunch %s\n",r(0));
		printf("dinner %s\n",r(1));
		printf("midnight %s\n",r(2));
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;
const LL MOD = 1e9 + 7;
void marmot0814() {
    int n, k; cin >> n >> k;
    vector<LL> dp(k + 1, 0); dp[0] = 1;
    for (int i = 0 ; i < n ; i++) {
        LL v; cin >> v;
        LL sum = 0;
        vector<LL> tmp;
        for (int j = 0 ; j < v ; j++) {
            (sum += dp[j]) %= MOD;
            tmp.push_back(sum);
        }
        for (int j = v ; j <= k ; j++) {
            (sum += dp[j]) %= MOD;
            tmp.push_back(sum);
            (sum -= dp[j - v] - MOD) %= MOD;
        }
        dp = tmp;
    }
    cout << dp.back() << '\n';
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int t = 1, kase = 0; // cin >> t;
    while (t--) {
        // cout << "Case #" << ++kase << ":";
        marmot0814();
    }
}

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

using namespace std;

int main(void) {
  string s;
  cin >> s;

  int price = 700;
  for(int i = 0; i < 3; i++) {
    if(s[i] == 'o') {
      price += 100;
    }
  }

  cout << price << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;



int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s, t;
    cin >> s >> t;

    bool res = false;
    if (s.length() + 1 == t.length()) {
        if (t.substr(0, s.length()) == s) {
            res = true;
        }
    }

    if (res) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main() {
	char c1, c2 = {'a'};
	bool a = true;
	for (int i = 0; i < 4; i++) {
		cin >> c1;
		if (c1 == c2)a = false;
		c2 = c1;
	}
	if (a)cout << "Good" << endl;
	else cout << "Bad" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main()
{
  int n,q,i,x,j;
  int array_n[10000];
  int array_q[10000];
  int count=0;
 
  for(i=0;i<100;i++){
    array_n[i]=0;
    array_q[i]=0;
  }
 
  scanf("%d",&n);
  for (i=0;i<n;i++){
    scanf("%d",&array_n[i]);
  }
 
  scanf("%d",&q);
  for (i=0;i<q;i++){
    scanf("%d",&x);
    for (j=0;j<n;j++){
      if (array_n[j]==x){
        count++;
        break;
      }
    }
  }
 
  printf("%d\n",count);
 
  return 0;
}



Measured memory_bytes: 2144
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define ll long long
#define inf 0x3f3f3f3f
#define mod 1000000007
#define maxn 500010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20];
	int len=0;
	if(x<0)putchar('-'),x=-x;
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
int a[maxn],last[maxn],cnt[maxn];
int pos[(1<<20)+5];
ll f[maxn],g[maxn],sum[maxn];
int n;
ll power(ll a,ll b)
{
	ll ans=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1)ans=ans*a%mod;
	return ans;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		a[i]=a[i-1]^read();
	cnt[0]=1;
	for(int i=1;i<=n;i++)
		cnt[i]=cnt[i-1]+(!a[i]);
	for(int i=1;i<=n;i++){
		last[i]=pos[a[i]];
		pos[a[i]]=i;
	}
	for(int i=1;i<=n;i++){
		f[i]=(g[last[i]]+(ll)(cnt[i-1]-cnt[last[i]])*sum[last[i]]+1)%mod;
		sum[i]=(sum[last[i]]+f[i])%mod; g[i]=(g[last[i]]+(ll)(cnt[i-1]-cnt[last[i]])*sum[last[i]])%mod;
	}
	ll ans=0;
	if(a[n])ans=f[n];
	else{
		int tot=0;
		for(int i=1;i<n;i++)
			if(a[i])ans+=f[i];
			else ++tot;
		ans=(ans+power(2,tot))%mod;
	}
	writeln(ans);
	return 0;
}

Measured memory_bytes: 21888
#include<stdio.h>
 
int search(int A[],int n,int key){
    int i=0;
    A[n]=key;
    while(A[i] != key)
        i++;
    return i != n;
}
 
int main()
{
    int i,n,A[10000+1],q,key,sum=0;
     
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&A[i]);
         
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d",&key);
        if(search(A,n,key))
            sum++;
    }
    printf("%d\n",sum);
     
    return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int X[100][100];

bool f(int x) {
  int i	= 0;
  while(i * i <= x) {
    if(i * i ==	x) return true;
    i++;
  }
  return false;
}

int main() {
  int N, D; cin>>N>>D;
  int ans = 0;
  REP(i,N) REP(j,D) cin>>X[i][j];
  for(int i = 0; i < N; i++) {
    for(int j = i+1; j < N; j++) {
      int sum = 0;
      REP(k,D) {
	int d = (X[i][k]-X[j][k]);
        sum += d*d;
      }
        if(f(sum)) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define ls rt<<1
#define rs (rt<<1)+1
#define PI acos(-1)
#define eps 1e-8
#define ll long long
#define fuck(x) cout<<#x<<"     "<<x<<endl;
typedef pair<int,int> pii;
const int inf=2e9;
const int maxn=2e5+10;
int d[4][2]={1,0,-1,0,0,1,0,-1};
//int lowbit(int x){return x&-x;}
//void add(int x,int v){while(x<=n)bit[x]+=v,x+=lowbit(x);}
//int sum(int x){int ans=0;while(x>=1) ans+=bit[x],x-=lowbit(x);return ans;}
inline ll read() {
    ll s = 0,w = 1;
    char ch = getchar();
    while(!isdigit(ch)) {
        if(ch == '-') w = -1;
        ch = getchar();
    }
    while(isdigit(ch))
        s = s * 10 + ch - '0',ch = getchar();
    return s * w;
}
inline void write(ll x) {
    if(x < 0)
        putchar('-'), x = -x;
    if(x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}

char s[maxn];
int dp[maxn][3];

int main(){
    scanf("%s",s+1);
    int n=strlen(s+1);
    dp[1][1]=1;
    dp[1][2]=0;
    dp[2][1]=(s[1]==s[2])?0:2;
    dp[2][2]=1;
    for(int i=3;i<=n;i++)
    {
        if(dp[i-1][1]&&s[i-1]!=s[i])
            dp[i][1]=max(dp[i][1],dp[i-1][1]+1);
        if(dp[i-1][2])
            dp[i][1]=max(dp[i][1],dp[i-1][2]+1);
        if(dp[i-2][1])
            dp[i][2]=max(dp[i][2],dp[i-2][1]+1);
        if(i==3) continue;
        if(dp[i-2][2]&&(s[i-2-1]!=s[i-1]||s[i-2]!=s[i]))
            dp[i][2]=max(dp[i][2],dp[i-2][2]+1);
    }
//    for(int i=1;i<=6;i++)
//        cout<<dp[i][1]<<"   "<<dp[i][2]<<endl;
    write(max(dp[n][1],dp[n][2]));puts("");
    return 0;
}







Measured memory_bytes: 2816
package main

import (
  "fmt"
  "sort"
)

func main() {
  var n int
  fmt.Scan(&n)
  cards := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&cards[i])
  }
  sort.Sort(sort.Reverse(sort.IntSlice(cards)))

  var alice, bob, i int
  for {
    if n > 0 {
      alice += cards[i]
      i++
      n--
    } else {
      break
    }
    if n > 0 {
      bob += cards[i]
      i++
      n--
    } else {
      break
    }
  }
  fmt.Println(alice - bob)
}

Measured memory_bytes: 512
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int taste = sc.nextInt();
        int max = 0;
        
        int[] arr = new int[N];
        
        for(int i = 0; i< N;i++) {
        	arr[i] = taste +i;
        	max += arr[i];
        }
        if(arr[0] > 0) {
        	System.out.println(max-arr[0]);
        }else if (arr[N-1] < 0) {
        	System.out.println(max-arr[N-1]);
        }else {
        	System.out.println(max);
        }
    }
}

Measured memory_bytes: 23380
#include <iostream>

using namespace std;
int main(void)
{
    int n;
    int count[101] = {0};
    int d;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> d;
        count[d]++;
    }

    int ans = 0;
    for (int i = 1; i <= 100; i++) {
        if (count[i] > 0) {
            ans++;
        }
    }


    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


input = sys.stdin.readline
def IS(cb): return cb(input().strip())
def IL(cb): return [cb(s) for s in input().strip().split()]
def IR(cb, rows): return [IS(cb) for _ in range(rows)]
def ILL(cb, rows): return [IL(cb) for _ in range(rows)]


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

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def bit_count(i):
    i = i - ((i >> 1) & 0x55555555)
    i = (i & 0x33333333) + ((i >> 2) & 0x33333333)
    i = (i + (i >> 4)) & 0x0f0f0f0f
    i = i + (i >> 8)
    i = i + (i >> 16)
    return i & 0x3f


def solve():
    N = IS(int)
    facts = factorization(N)
    ans = 0
    for p, e in facts:
        if p == 1:
            continue

        ans += int(((1 + 8 * e) ** 0.5 - 1) // 2)

    print(ans)

solve()


Measured memory_bytes: 9544
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"r=lambda x:x*(u[x]<0)or r(u[x])\n"
"i=lambda:map(int,input().split()[:2])\n"
"n,m=i()\n"
"u=[-1]*-~n\n"
"while m:\n"
" x,y=sorted(map(r,i()));m-=1\n"
" if x!=y:u[x]+=u[y];u[y]=x\n"
"print(sum(i<0for i in u)-1)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 7620
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int d[100];
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	for (int i = 0; i <= 1000; i++)if (a*i%b == c)
	{
		printf("YES\n");
		return 0;
	}
	printf("NO\n");
}

Measured memory_bytes: 256
#i!/usr/bin/env python
# coding: utf-8

import sys
input = sys.stdin.readline

def main():
    N, K = list(map(int, input().split()))
    l = []
    for _ in range(N):
        t, d = list(map(int, input().split()))
        l.append((d, t))
    l.sort(reverse=True)
    first = []
    second = []
    t_set = set()
    for k in range(K):
        if l[k][1] not in t_set:
            first.append(l[k])
            t_set.add(l[k][1])
        else:
            second.append(l[k])
    yummy = sum(e[0] for e in first) + sum(e[0] for e in second)
    best_ans = yummy + len(t_set)**2
    for k in range(K, N):
        if len(second) == 0:
            break
        if l[k][1] in t_set:
            continue
        sushi = second.pop(-1)
        yummy -= sushi[0]
        yummy += l[k][0]
        t_set.add(l[k][1])
        first.append(l[k])
        ans = yummy + len(t_set)**2
        if ans  > best_ans:
            best_ans = ans
    print(best_ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19700
using System;

namespace abc146
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            if(S == "SUN") Console.WriteLine(7);
            if(S == "MON") Console.WriteLine(6);
            if(S == "TUE") Console.WriteLine(5);
            if(S == "WED") Console.WriteLine(4);
            if(S == "THU") Console.WriteLine(3);
            if(S == "FRI") Console.WriteLine(2);
            if(S == "SAT") Console.WriteLine(1);
        }
    }
}


Measured memory_bytes: 11220
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define loop(a,t) for(int a=0;a<t;a++) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
int ans[300];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (true) {
		int a, b, c, n;
		cin >> a >> b >> c;
		if (a == 0 && b == 0 && c == 0) { break; }
		cin >> n;
		int ak[1000], bk[1000], ck[1000];
		loop(i, 1000) {
			ak[i] = bk[i] = ck[i] = -1;
			if (i < 300) {
				ans[i] = 2;
			}
		}
		loop(i, n) {
			int an, bn, cn, or1;
			cin >> an >> bn >> cn >> or1;
			if (or1 == 1) {
				ans[an - 1] = 1;
				ans[bn - 1] = 1;
				ans[cn - 1] = 1;
			}
			else {
				ak[i] = an - 1;
				bk[i] = bn - 1;
				ck[i] = cn - 1;
			}
		}
		loop(i, n) {
			if (ak[i] != -1) {
				if (ans[ak[i]] == 2 && ans[bk[i]] == 1 && ans[ck[i]] == 1) {
					ans[ak[i]] = 0;
				}
				if (ans[ak[i]] == 1 && ans[bk[i]] == 2 && ans[ck[i]] == 1) {
					ans[bk[i]] = 0;
				}
				if (ans[ak[i]] == 1 && ans[bk[i]] == 1 && ans[ck[i]] == 2) {
					ans[ck[i]] = 0;
				}

			}
		}
		loop(i, a + b + c) {
			cout << ans[i] << endl;
		}

	}
	return 0;

}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    int a, b;
    cin >> a >> b;
    if (a <= 9 && b <= 9)
    {
        cout << a * b << endl;
    }
    else
    {
        cout << -1 << endl;
    }

    return 0;
}


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

using namespace std;


map<int, int> tree;

int find(int o){
	if (tree[o] == o){
		return o;
	}
	else{
		tree[o] = find(tree[o]);
		return tree[o];
	}
}

bool check(int a, int b){
	return (find(a) == find(b));
}

void unite(int a, int b){
	if (find(a) == find(b)){ return; }
	tree[find(a)] = find(b);
}

int main(){
	int n;
	int NumberOfOperation;

	cin >> n >> NumberOfOperation;
	
	for (int i = 0; i < n; ++i){
		tree[i] = i;
	}



	for (int j = 0; j < NumberOfOperation; ++j){
		int TypeOfOperation;
		int TrialNumbers[2];

		cin >> TypeOfOperation >> TrialNumbers[0] >> TrialNumbers[1];

		if (TypeOfOperation == 0){
			
			unite(TrialNumbers[0], TrialNumbers[1]);
		}
		else{
			cout << check(TrialNumbers[0],TrialNumbers[1])<<endl;
		}


	}

	
	return 0;


}

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

using namespace std;
using ll = long long;

int main() {
    ll n = 0;
    cin >> n;
    vector<ll> a(n,0);
    for(ll i = 0; i < n; i++) {
        cin >> a.at(i);
    }

    for(int i = 0; i < n; i++) {
        if(n - 1 - 2*i >= 0) {
            cout << a.at(n - 1 - 2*i);
        } else {
            cout << a.at(2*i - n);
        }
        if(i != n - 1) {
            cout << ' ' << endl;
        }
    }
    cout << endl;


    return 0;
}

Measured memory_bytes: 4816
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n,m;
  cin >> n >> m;
  vector<vector<char>> a(n,vector<char>(n));
  vector<vector<char>> b(m,vector<char>(m));
  rep(i,n){
    rep(j,n){
      cin >> a[i][j];
    }
  }
  rep(i,m){
    rep(j,m){
      cin >> b[i][j];
    }
  }
  bool A=false;
  rep(i,n-m+1){
    rep(j,n-m+1){
      bool B=true;
      rep(k,m){
        rep(l,m){
          if(a[i+k][j+l]!=b[k][l]){
            B=false;
          }
        }
      }
      if(B){
        A=true;
      }
    }
  }
  if(A){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,y,a1=-1,a2=-1,a3=-1;
bool f;
//void dfs(int x1,int x2,int x3){
//	cout<<x1<<" "<<x2<<" "<<x3<<endl;
//	if ((x1*10000+x2*5000+x3*1000)>y||(x1+x2+x3)>n) return;
//	if (f) return;
//	if (x1*10000+x2*5000+x3*1000==y){a1=x1;a2=x2;a3=x3;f=1;}
//	for (int i=0;;i++){
//		for (int j=0;;j++){
//			for (int z=0;;z++)
//		}
//		dfs(x1,x2,x3+1);
//		dfs(x1,x2+1,x3);
//		dfs(x1+1,x2,x3);
//	}
//	return;
//}
int main() {
	cin>>n>>y;
	if (y%1000!=0){cout<<"-1 -1 -1";return 0;}
	//dfs(0,0,0);
	for (int i=0;i<=n;i++){
		for (int j=0;i+j<=n;j++){
			if (f) break;
		    int ij=i*10000+j*5000;
		    if (ij<=y){
			int z=(y-ij)/1000;
			if (i+j+z==n){a1=i;a2=j;a3=z;f=1;}
		}
		}
	}
	cout<<a1<<" "<<a2<<" "<<a3;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int i, ans, n, dp[100010][3], a[100010], b[100010], c[100010];
  cin >> n;
  REP(i, n){cin >> a[i] >> b[i] >> c[i]; dp[i][0] = 0; dp[i][1] = 0; dp[i][2] = 0;}
  FOR(i, 1, n+1){
    dp[i][0] = max(dp[i-1][1] + a[i-1], dp[i-1][2] + a[i-1]);
    dp[i][1] = max(dp[i-1][0] + b[i-1], dp[i-1][2] + b[i-1]);
    dp[i][2] = max(dp[i-1][0] + c[i-1], dp[i-1][1] + c[i-1]);
  }
  ans = max({dp[n][0], dp[n][1], dp[n][2]});
  cout << ans << endl;
}

Measured memory_bytes: 2688
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <vector>

using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if((a == b && a != c) || (a == c && a != b) || (b == c && b != a)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

static const int MAX = 200000;

int main(){
	int R[MAX], n;

	cin >> n;
	for( int i = 0; i < n; i++)cin >> R[i];

	int maxv = -2000000000;
	int minv  = R[0];

	for( int i = 1; i < n; i++){
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}

	cout << maxv << endl;

	return 0;
} 

Measured memory_bytes: 3856
N = int(input())
A = list(map(int, input().split()))

cnt4 = 0
cnt2 = 0
for a in A:
    if a % 4 == 0:
        cnt4 += 1
    elif a % 2 == 0:
        cnt2 += 1

if cnt2 == 0:
    cnt2 = 1
m = cnt4*2+1 + cnt2-1
if m < N:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int c[3][3]; rep(i,3) rep(j,3) cin >> c[i][j];
    bool can = true;
    if(c[0][0] - c[0][1] != c[1][0] - c[1][1] || c[1][0] - c[1][1] != c[2][0] - c[2][1]) can = false;
    if(c[0][1] - c[0][2] != c[1][1] - c[1][2] || c[1][1] - c[1][2] != c[2][1] - c[2][2]) can = false;
    if(c[0][0] - c[1][0] != c[0][1] - c[1][1] || c[0][1] - c[1][1] != c[0][2] - c[1][2]) can = false;
    if(c[1][0] - c[2][0] != c[1][1] - c[2][1] || c[1][1] - c[2][1] != c[1][2] - c[2][2]) can = false;
    if(can) Yes;
    else No;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String[] args){
	  Scanner scan = new Scanner(System.in);
	  int N = scan.nextInt();
      int X = scan.nextInt();
      int T = scan.nextInt();
      int time = 0;
      if(N%X == 0) time = (N/X) * T;
      else time = ((N/X)+1)*T;
      System.out.println(time);
	}
}

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

#define ll long long
#define db double
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ino freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);

#define fr(i,n) for(i=0;i<n;i++)
#define frs(i,a,n) for(i=a;i<n;i++)
#define frv(i,n) for(i=n-1;i>=0;i--)

#define ne cout<<"\n";
#define cas(i) cout<<"Case #"<<i<<": "

#define vpi vector <pair <int,int> >
#define vpin(v,a,b) v.push_back(make_pair(a,b))
#define vsort(v) sort(v.begin(),v.end());

#define todegree(rad) rad*(180.0/pi)
#define isnttriangle(a,b,c) (a+b<c||a+c<b||b+c<a)
#define pi acos(-1)
#define siz 10000019
#define mx 10000005
bool prm[siz];
ll ar[siz];

void sieve()
{
    ll i,p,j=0;
    memset(prm,false,sizeof(prm));
    prm[1]=true;
    for(p=2;p*p<=mx;p++)
    {
        if(!prm[p])
        {

            for(i=p*2;i<=mx;i+=p) prm[i]=true;
        }
    }
    for(p=2;p<=mx;p++)
    {
        if(!prm[p])
        {
            ar[j++]=p;
        }
    }
}
bool prms(ll n)
{
    ll m,k;
    db a=sqrt(n);
    m=floor(a);
    if(m*m==n&&!prm[m]) {
            return true;
    }
    return false;
}
ll sol(ll n)
{
    if(n==1) return 1;
    ll i,cn=1;
    for(i=0;;i++)
    {
        if(ar[i]*ar[i]*ar[i]>n)
            break;
        ll pp=1;
        while(n%ar[i]==0)
        {
            n/=ar[i];
            pp++;
        }
        cn*=pp;
    }
    if(!prm[n]) cn*=2;
    else if(prms(n)) cn*=3;
    else if(n!=1) cn*=4;
    return cn;
}

int main()
{
    sieve();
    ll num,ans=0;


    cin>>num;

    for(ll i=1;i<=num;i++)
    {
        ans+=(i*sol(i));
    }
    cout<<ans<<"\n";
    return 0;
}



Measured memory_bytes: 18572
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define N (1<<21)+10
#define mr emplace_pair
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
int a[N],n,K,dp[N][22],ne[N][2],no[24],ho[N][22],an[N];
void di(int x,int y){if (y>1)di(x/2,y-1);cout<<x%2;}
int main(){
	read(n);read(K);
	for (int i=0;i<=n;i++){
		for (int j=0;j<(1<<i);j++){
			char ch=getchar();
			while (ch!='0'&&ch!='1')ch=getchar();
			if (ch=='1'){a[(1<<i)+j]=1;dp[(1<<i)+j][0]=1;}
		}
	}
	for (int i=0;i<(1<<(n+1));i++){
		for (int j=0,k=i;j<=n;j++,k>>=1)no[j]=k&1;
		for (int j=0,k=0;j<=n;k+=no[j]*(1<<j),j++)ho[i][j]=k;
		ne[i][0]=ne[i][1]=-1;
		for (int k=n;k>=0;k--){
			if (no[k]){
				for (int p=0,s=0;p<k;s+=no[p]*(1<<p),p++)ne[i][no[p]]=s+(1<<p);
				break;
			}
		}
	}
	for (int i=0;i<=n;i++){
		for (int j=0;j<(1<<(n+1));j++){
			if (dp[j][i]){
				if (ne[j>>i][0]!=-1)dp[(ne[j>>i][0]<<(i+1))+ho[j][i]*2][i+1]=dp[(ne[j>>i][0]<<(i+1))+ho[j][i]*2][i+1]+dp[j][i];
				if (ne[j>>i][1]!=-1)dp[(ne[j>>i][1]<<(i+1))+ho[j][i]*2+1][i+1]=dp[(ne[j>>i][1]<<(i+1))+ho[j][i]*2+1][i+1]+dp[j][i];
				an[ho[j][i]+(1<<i)]+=dp[j][i];
			}
		}
	}
	for (int i=n;i>=1;i--)
		for (int j=0;j<(1<<i);j++)
			if (an[(1<<i)+j]>=K){di(ho[j][i],i);return 0;}
	return 0;
}

Measured memory_bytes: 393600
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
using namespace std;
template<typename T> void read(T &num){
	char c=getchar();T f=1;num=0;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){num=(num<<3)+(num<<1)+(c^48);c=getchar();}
	num*=f;
}
template<typename T> void qwq(T x){
	if(x>9)qwq(x/10);
	putchar(x%10+'0');
}
template<typename T> void write(T x){
	if(x<0){x=-x;putchar('-');}
	qwq(x);putchar('\n');
}
template<typename T> void chkmax(T &x,T y){x=x>y?x:y;}
int co[1000010];

int main(){
	int K,N;read(K);read(N);
	rep(i,1,N)read(co[i]);
	
	int ret=0;
	rep(i,1,N-1)chkmax(ret,co[i+1]-co[i]);
	chkmax(ret,co[1]+K-co[N]);
	write(K-ret);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll s, t, u, v;
  s = c - d + b;
  t = d + c - a;
  u = s - c + a;
  v = t - d + b;
  cout << s << " " << t << " " << u << " " << v << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

int main(){
ll x,y;cin>>x>>y;
ll ans=0;
while(x<=y)x*=2,ans++;
cout<<ans;
}

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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll k;
    cin>>k;
    ll sum=7;
    fr(i,1,1e7)
    {
        if(sum%k==0)
        {
            cout<<i<<endl;
            return;
        }
        sum*=10;
        sum+=7;
        sum%=k;
    }
    cout<<"-1\n";
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<":\n";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 3648