akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
    vector<int> v = {0, 1,3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    int x, y;
    cin >> x >> y;
    if(v[x] == v[y]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 10;

int n;
ll ans = 0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for1(i, n)
    {
        if (i % 3 != 0 && i % 5 != 0)
        {
            ans += i;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000001;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> vec(N);
    for(int i = 0;i < M;i++) {
        int A,B;
        cin >> A >> B;
        A--;
        B--;
        vec.at(A)++;
        vec.at(B)++;
    }
    bool ret = true;
    for(int i = 0;i < N;i++) {
        if(vec.at(i) % 2 != 0) {
            ret = false;
        }
    }
    if(ret == true) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

int main()
{
    int w, h, n;
    std::cin >> w >> h >> n;

    int x_l = 0, x_u = w, y_l = 0, y_u = h;
    for (int i = 0; i < n; ++i)
    {
        int x, y, a;
        std::cin >> x >> y >> a;
        switch (a)
        {
        case 1:
            x_l = std::max(x, x_l);
            break;
        case 2:
            x_u = std::min(x, x_u);
            break;
        case 3:
            y_l = std::max(y, y_l);
            break;
        case 4:
            y_u = std::min(y, y_u);
            break;
        default:
            break;
        }
    }
    if (x_l >= x_u || y_l >= y_u)
    {
        std::cout << 0 << std::endl;
    }
    else
    {
        std::cout << (x_u - x_l) * (y_u - y_l) << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
#define Int int64_t
using ll = long long;

int main() {
	int n, m;
	cin >> n >> m;

	vector<pair<int, int>> b(m, { 0,0 });
	for (int i = 0; i < m; i++) {
		cin >> b[i].second >> b[i].first;
	}

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

	int c = 1;

	int bb = b[0].first-1;

	for (int i = 1; i < m; i++) {
		if (b[i].second > bb ) {
			bb = b[i].first - 1;
			c++;
		}
	
	}

	cout << c << endl;


}

Measured memory_bytes: 1024
s = raw_input()

c = []
f = []
for i in xrange(len(s)):
    if s[i] == 'C':
        c.append(i)
    elif s[i] == 'F':
        f.append(i)

if len(c) and len(f) and c[0]<f[-1]:
    print 'Yes'
else:
    print 'No'

Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
using namespace std;

int main(){
//	IOS;
	int n,inp;
	cin >> n;
	map<int,int> num;
	vector<int> can;
	for(int i=0;i<n;i++){
		cin >> inp;
		num[inp]++;
		if(num[inp]%2==0) can.push_back(inp);
	}
	sort(can.begin(),can.end(),greater<int>());
	if(can.size()<2) cout << "0\n";
	else cout << (long long int)can[0]*can[1] << '\n';
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;
 
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; }
 
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }
 
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
 
inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}
 
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int N,A,B,C;
vi L;
int rec(int i, int a, int b, int c){
  if(i==N){
    if(!a||!b||!c) return INF;
    return abs(A-a)+abs(B-b)+abs(C-c);
  }
  int res=rec(i+1,a,b,c);
  
  chmin(res,rec(i+1,a+L[i],b,c)+(a?10:0));
  chmin(res,rec(i+1,a,b+L[i],c)+(b?10:0));
  chmin(res,rec(i+1,a,b,c+L[i])+(c?10:0));
  
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  int n=s.size();
  
  ll ans=0;
  for(int bit=0; bit<(1<<(n-1)); bit++){
    ll now=0;
    rep(i,n-1){
      if(bit&(1<<i)){
        ans+=stoll(s.substr(now,i-now+1));
        now=i+1;
      }
    }
    ans+=stoll(s.substr(now,n-now+1));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
def resolve():
    n,m = map(int,input().split())
    ac_list = [0]*n
    wa_count = [0]*n
    ac = 0
    wa = 0
    for _ in range(m):
        p,s = input().split()
        if s == 'WA' and (ac_list[int(p)-1]==0):
            wa_count[int(p)-1] += 1
        elif s == 'AC' and (ac_list[int(p)-1]==0):
            ac += 1
            ac_list[int(p)-1] = 1
    for (i,j) in zip(wa_count,ac_list):
        if j: wa+=i
    print(f'{ac} {wa}')
resolve()

Measured memory_bytes: 10340
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
      string s;
      cin>>s;
      if (s.size()<6)
      {
        cout<<"No"<<endl;
      }
      else if(s[2]==s[3] && s[4]==s[5])
      {
        cout<<"Yes"<<endl;
      }
      else
      {
        cout<<"No"<<endl;
      }
    }

Measured memory_bytes: 256
use std::cmp::{max, min};
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: ty),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, t: usize);
    'outer: for _ in 0..t {
        parse!(it, n: usize, a: [usize; n]);
        let s: Vec<bool> = it.next().unwrap().bytes().map(|x| x == b'1').collect();
        let mut bases = vec![];
        for i in (0..n).rev() {
            let mut res = a[i];
            for &b in bases.iter() {
                res = min(res, res ^ b)
            }
            if res != 0 {
                if s[i] {
                    println!("{}", 1);
                    continue 'outer;
                } else {
                    bases.push(res)
                }
            }
        }
        println!("{}", 0);
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 2396
#include <iostream>
#include <set>
#include <vector>
using namespace std;
typedef long long lli;
lli n;
vector<lli> x;
set<lli> s;
lli ans = 0;
int main(){
    cin >> n;
    x = vector<lli> (n+1);
    for(lli i = 1;i <= n;i++){
        lli a;
        cin >> a;
        x[a] = i;
    }
    s.insert(0);s.insert(n+1);
    for(lli i = 1;i <= n;i++){
        auto itr = s.lower_bound(x[i]);
        ans += i * (*itr - x[i]) * (x[i] - *(--itr));
        s.insert(x[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11264
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
function main()
  s=chomp(readline())
  n=length(s)
  ans=1
  pre=s[1]
  lookat=2
  while lookat<=n
    ans+=1
    if lookat==n-1 && s[end-1]==s[end]
      lookat+=2
    elseif pre==s[lookat]
      pre=s[lookat:lookat+1]
      lookat+=2
    else
      pre=s[lookat]
      lookat+=1
    end
  end
  println(ans)
end
main()
if isdefined(Base, :mystdin);close(mystdin);end


Measured memory_bytes: 159996
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a[12];
    for(int i=0;i<12;i++)cin>>a[i];
    sort(a,a+12);
    bool masatoy=true;
    for(int i=0;i<12;i=i+2){
        if(a[i]!=a[i+1])masatoy=false;
    }
    if(masatoy==true)cout<<"yes"<<endl;
    else cout<<"no"<<endl;
}

Measured memory_bytes: 3140
N = int(input()) 
e=[0]*(N+1)
for i in range(2, N+1):
    cur = i
    for j in range(2, i+1):
        while cur % j == 0:
            e[j] += 1
            cur //= j
def num(m):
    return len(list(filter(lambda x: x >= m-1, e)))
print(num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1)+ num(5) * (num(5) - 1) * (num(3) - 2) // 2) 


Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	
	int k;
	vector<int> an;
	int tmp;
	
	for(int i=0; i<5; i++){
		scanf("%d\n", &tmp);
		an.push_back(tmp);
	}
	scanf("%d\n", &k);
	
	if((*max_element(an.begin(), an.end()) - *min_element(an.begin(), an.end())) <= k){
		printf("Yay!\n");
	}else{
		printf(":(\n");
	}
	
	return 0;
	
}


Measured memory_bytes: 256
N, L = gets.chomp.split(" ").map(&:to_i)

s = N * (L - 1) + (N * (N + 1)) / 2

f = L
l = L + N - 1

if f < 0 && l > 0 then
  puts s
elsif f.abs < l.abs then
  puts (s - f)
else
  puts (s - l)
end


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MOD 1000000007
#define INF 100100100

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


int main(){
  int a, b, k;
  cin >> a >> b >> k;
  int count = 0;
  for (int i = 100; i >= 1; i--) {
    if(a % i == 0 && b % i == 0){
      count++;
      if(count == k){
        cout << i << endl;
        return 0;
      }
    }
  }
}



Measured memory_bytes: 256
#include <stdio.h>

int main() {

    char S[100000];
    scanf("%s", S);

    int odd = 0;
    int even = 0;
    int i;
    for (i=0; S[i] != '\0'; i++) {
        if (S[i] == '1' && (i+1) % 2 == 1) {
            odd += 1;
        } else if (S[i] == '0' && (i+1) % 2 == 0) {
            even += 1;
        }
    }

    int num1 = i - odd - even;
    int num2 = i - num1;

    int result;
    if (num1 > num2) {
        result = num2;
    } else {
        result = num1;
    }

    printf("%d\n", result);

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		String[] strs = read(1)[0].split(" ");
		
		int n = Integer.parseInt(strs[0]);
		int i = Integer.parseInt(strs[1]);
		
		System.out.println(n - i + 1);
	}
	
	private static String[] read(int len) {
		List<String> strList = new ArrayList<>();
		
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			for (int i = 0; i < len; i++) {
				strList.add(br.readLine());
			}
		} catch (IOException e) {
		}
		
		return strList.toArray(new String[0]);
	}
}


Measured memory_bytes: 22484
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
    if a[i]%2==0:
        b.append(a[i])
for i in b:
    if i%3!=0 and i%5!=0:
        print("DENIED")
        exit()
print("APPROVED")


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

int main() {
    int N;
    cin >> N;
    double ans = 0;
    rep(i, N) {
        double x;
        string u;
        cin >> x >> u;
        if (u == "JPY") ans += x;
        else ans += 380000.0*x;
    }
    printf("%.5lf", ans);
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
S = sum(A)
m = S
s = 0
a = 10**100
for i in range(N):
    m = m - A[i]
    s += A[i]
    if s > m:
        break
    a = m - s
b = s - m
ans = min(a,b)
print(ans)

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

int main() {
  int x;
  cin>>x;
  int a=x/1.08;
  if((int)(a*1.08)==x){
    cout<<a<<endl;
  }
  else if((int)((a+1)*1.08)==x){
    cout<<a+1<<endl;
  }
  else{
    cout<<":("<<endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>

inline void read(long long &T) {
	long long x=0;bool f=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=!f;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	T=f?-x:x;
}

int ans=0;
long long a=100,x;

int main() {
	read(x);
	while(a<x) {
		a+=a/100;
		++ans;
	}
	std::cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main(void){ 
    int n,m,a;
    int x=0;
    while(true){
        cin>>n>>m;
        if(n==0&&m==0)  break;
        else{
            int i;
            for(i=0;i<n;i++){
                cin>>a;
                if(a>=m/n)  x=x+m/n;
                else    x=x+a;
                
            }
            cout<<x;
            x=0;
            cout<<endl;
        }
    }
}



Measured memory_bytes: 3092
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

typedef struct Point{
	double x,y;
};

double areaTriangle(Point a,Point b){
	return (a.x*b.y - a.y*b.x)/2;
}

int main(){
	int n;
	Point *ver;
	double area=0;
	
	cin>>n;
	ver = new Point[n];
	
	for(int i=0;i<n;++i){
		cin>>ver[i].x>>ver[i].y;
	}
	
	for(int i=0;i<n;++i){
		area += areaTriangle(ver[i],ver[(i+1)%n]);
	}
	
	cout << fixed << setprecision(1) << area << endl;
}

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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    UnionFind(int N) : par(N),siz(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++){
             par[i] = i;
             siz[i] = 1;
        }
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        // merge technique（小を大にくっつける）
        if (siz[rx] < siz[ry]) swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    ll size(ll x){
        return siz[root(x)];
    }
};

signed main()
{
    gearup;
    ll k; cin >> k;
    ll mod_50 = k % 50;
    int n = 50;
    vl a;
    rep(i,50-mod_50)a.push_back(49-mod_50);
    rep(i,mod_50)a.push_back(50);
    rep(i,50)a[i] += k / 50;
    out(n);
    rep(i,n)out(a[i]);
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

#define all(x) begin(x), end(x)
#define x first
#define y second
typedef long long ll;
typedef long double ld;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<typename T>
using normal_queue = priority_queue<T, vector<T>, greater<T>>;

const int MAX_N = 2e5 + 10;

int a[MAX_N];

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	bool oneflag = 1;
	for (int i = 1; i < n; ++i) {
		if (a[i - 1] >= a[i]) {
			oneflag = 0;
		}
	}
	if (oneflag)
		return cout << "1\n", 0;
	int l = 1, r = n;
	while (r - l > 1) {
		int mid = (l + r) / 2;
		bool flag = 1;
		// cout << "checking for " << mid << ":" << endl;
		vector<pair<int, int>> current;
		for (int i = 1; i < n; ++i) {
			// cout << "at " << i << ": ";
			// for (auto p : current)
			// 	cout << p.x << ":" << p.y << " ";
			// cout << "\n";
			if (a[i - 1] < a[i])
				continue;
			while (current.size() && current.back().x >= a[i])
				current.pop_back();
			int cnt = a[i] - 1;
			while (current.size() && current.back().x == cnt && current.back().y == mid - 1) {
				current.pop_back();
				--cnt;
			}
			// cout << cnt << "\n";
			if (cnt == -1) {
				flag = 0;
				break;
			}
			if (current.size() && current.back().x == cnt) {
				++current.back().y;
			} else {
				current.push_back({cnt, 1});
			}
		}
		// for (auto p : current)
		// 	cout << p.x << ":" << p.y << " ";
		// cout << "\n";
		// cout << "result " << flag << endl;
		if (flag)
			r = mid;
		else
			l = mid;
	}
	cout << r << "\n";
	return 0;
}

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

typedef long long ll;

int main() {
    int h, w, n; cin >> h >> w >> n;
    int sr, sc; cin >> sr >> sc;
    --sr;
    --sc;
    string s, t; cin >> s >> t;
    char dirs[]={'L', 'U', 'R', 'D'};
    for (int i=0; i<4; ++i) {
        char d=dirs[i];
        char rd=dirs[(i+2)%4];
        int cur, lim;
        if (i%2==0) {
            cur=sc;
            lim=w;
        } else {
            cur=sr;
            lim=h;
        }
        if (i<2) {
            cur=lim-cur-1;
        }
        for (int k=0; k<n; ++k) {
            if (s[k]==d) {
                ++cur;
                if (cur>=lim) {
                    cout << "NO";
                    return 0;
                }
            }
            if (t[k]==rd) {
                if (cur>0) {
                    --cur;
                }
            }
        }
    }
    cout << "YES";
    return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  for(int N, M; cin >> N >> M && N && M;) {
    int sum[N + 1]; sum[0] = 0;
    rep(i, N) {
      int A; cin >> A; A %= M;
      sum[i + 1] = sum[i] + A;
      sum[i + 1] %= M;
    }

    set<int> st;

    int res = 0;

    REP(i, 1, N + 1) {
      auto it = st.upper_bound(sum[i]);
      if(it == st.end())
        maximize(res, sum[i]);
      else
        maximize(res, sum[i] + M - *it);
      st.insert(sum[i]);
    }

    cout << res << endl;

  }
  
  return 0;
}

Measured memory_bytes: 4408
#include <bits/stdc++.h>
#define FOR(i,a,b) for (long long i = (a); i <= (b); i++)
#define FORD(i,b,a) for (long long i = (b); i >= (a); i--)
#define endl "\n"
#define ll long long
#define x1 asdasdsaas
#define y1 cdaca1231
#define fi first
#define se second
#define pb push_back
using namespace std;
const int MAXN = 1e6;
const int dx[4] = { -1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
vector<int> res;
int trace[MAXN];
void solve() {
	// int n, h[MAXN], f[MAXN];
	// cin >> n;
	// FOR(i, 1, n) cin >> h[i];
	// f[1] = 0;
	// trace[1] = 1;
	// f[2] = abs(h[1] - h[2]);
	// trace[2] = 1;
	// FOR(i, 3, n) {
	// 	if ((abs(h[i - 2] - h[i]) + f[i - 2] < abs(h[i - 1] - h[i])) + f[i - 1]) {
	// 		f[i] = f[i - 2] + abs(h[i - 2] - h[i]);
	// 		trace[i] = i - 2;
	// 	} else {
	// 		f[i] = f[i - 1] + abs(h[i - 1] - h[i]);
	// 		trace[i] = i - 1;
	// 	}
	// 	// f[i] = min(f[i - 2] + abs(h[i - 2] - h[i]), f[i - 1] + abs(h[i - 1] - h[i]));
	// }
	// cout << f[n] << endl;
	// while (trace[n] != n) {
	// 	res.push_back(n);
	// 	n = trace[n];
	// }
	// res.push_back(1);
	// reverse(res.begin(), res.end());
	// for (auto x : res) cout << x << " ";
	int n, h[MAXN], k, f[MAXN];
	cin >> n >> k;
	FOR(i, 1, n) {
		cin >> h[i];
		f[i] = 1e9;
	}
	f[1] = 0;
	FOR(i, 2, n) {
		FORD(j, k, 1) {
			if (i - j > 0) f[i] = min(f[i], f[i - j] + abs(h[i - j] - h[i]));
		}
	}
	cout << f[n];
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 6656
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}*/


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

	int a, b, c;
	cin >> a >> b >> c;

	if (a + b >= c) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#ifdef LOCAL
//#define _GLIBCXX_DEBUG
#endif
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<char> Vc;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;
typedef vector<vector<char>> VVc;
typedef vector<vector<vector<ll>>> VVV;
typedef vector<vector<vector<vector<ll>>>> VVVV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define rEach(i, mp) for (auto i = mp.rbegin(); i != mp.rend(); ++i)
#ifdef LOCAL
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgset(st) cerr << #st << ":"<<endl; for (auto i = st.begin(); i != st.end(); ++i) { cerr << *i <<" ";}cerr<<endl;
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#else
#define dbg(...)
#define dbgmap(...)
#define dbgset(...)
#define dbgarr(...)
#define dbgdp(...)
#endif
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int solve(){
    ll n,x,t;
    cin>>n>>x>>t;
    ll ans = (n+x-1)/x;
    ans *= t;
    out(ans);
    return  0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);
//    ll T;
//    cin>>T;
//    while(T--)
    solve();
}


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

int sums[60] = { 0 }, roots[60] = { 0 };

void initialize(int n)
{
	for (int i = 0; i < n; ++i)
	{
		sums[i] = 1;
		roots[i] = i;
	}
}

int root(int index)
{
	while (roots[index] != index)
	{
		roots[index] = roots[roots[index]];
		index = roots[index];
	}
	
	return index;
}

void makeUnion(int x, int y)
{
	int rootOfA = root(x), rootOfB = root(y);
	
	if (sums[rootOfA] >= sums[rootOfB])
	{
		sums[rootOfA] += sums[rootOfB];
		roots[rootOfB] = rootOfA;
	}
	else
	{
		sums[rootOfB] += sums[rootOfA];
		roots[rootOfA] = rootOfB;
	}
}

int main()
{
	int n, m, x[60], y[60];
	std::cin >> n >> m;
	
	for (int i = 0; i < m; ++i)
	{
		std::cin >> x[i] >> y[i];
		--x[i];
		--y[i];
	}
	
	int ans = 0;
	
	for (int i = 0; i < m; ++i)
	{
		initialize(n);
		for (int j = 0; j < m; ++j)
		{
			if (i != j)
			{
				makeUnion(x[j], y[j]);
			}
		}
		
		if (root(x[i]) != root(y[i]))
			++ans;
	}
	
	std::cout << ans;
}

Measured memory_bytes: 256
M=10**9+7
n,m,*l=map(int,open(0).read().split())
dp=[1]+[0]*n
for i in l: dp[i]=-1
dp[1]+=1
for i in range(n-1):
  if dp[i+2]<0: dp[i+2]=0
  else: dp[i+2]=(dp[i]+dp[i+1])%M
print(dp[n])

Measured memory_bytes: 19976
S=list(input())
num=0
for c in S[1:]:
    if c == S[0]:
        num+=1

if S[1]==S[2]:
    num+=1
if S[1]==S[3]:
    num+=1
if S[2]==S[3]:
    num+=1
    
if num==2:
    print("Yes")
else:
    print("No")

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int m=0;
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    m=max(m,a.at(i));
  }
  vector<int> b(m,1);
  sort(a.begin(),a.end());
  
  for(int i=1;i<n;i++){
    if(a.at(i)==a.at(i-1)){
      b.at(a.at(i)-1)=0;
    }
  }
  
  for(int i=0;i<n;i++){
    int x=a.at(i)*2;
    while(x<=m){
      b.at(x-1)=0;
      x+=a.at(i);
    }
  }
  
  int ans=0;
  
  for(int i=0;i<n;i++){
    ans+=b.at(a.at(i)-1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 7940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl

int main()
{
  ll n;
  cin >> n;

  ll t = 1;
  string ans = "";
  for (int i = 1; i < 100; i++)
  {
    t *= 26;
    if (n <= t)
    {
      n--;
      for (int j = 0; j < i; j++)
      {
        ans += 'a' + n % 26;
        n /= 26;
      }
      break;
    }
    else
    {
      n -= t;
    }
  }

  reverse(all(ans));
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

int main() {
  string S, T;
  cin >> S >> T;

  cout << T+S << endl;
  return 0;
}


Measured memory_bytes: 256
#ifndef HOME
	#pragma GCC target("avx")
	#pragma GCC optimize("Ofast")
	#pragma GCC optimize("unroll-loops")
	#pragma comment(linker, "/stack:200000000")
	#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define MAX(a, b) __builtin_ia32_pmaxsd128(a, b)
#define MIN(a, b) __builtin_ia32_pminsd128(a, b)

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

using namespace __gnu_cxx;
using namespace __gnu_pbds;

template <class key_type>
using superTree = tree<key_type, null_type, less<key_type>, 
					   rb_tree_tag, tree_order_statistics_node_update>;
using v4si = int __attribute__ ((vector_size(16)));

const int MOD = 1000000007;

inline int _(int x, int y) {
	x += y;
	if (x >= MOD) { return x - MOD; }
	if (x < 0)    { return x + MOD; }
	return x; }

inline void __(int &x, int y) {
	x = _(x, y); }

/*
 * TO DO:
 *	
 * - long long instead of int
 * - bigger array sizes
 * - array / list instead of map / set
 * - can bruteforce with tricks pass system tests? 
 *
 * - NEVER STOP THINKING / CODING !!!
 */

const int DIM = 200005;

int dp[DIM];
vector<int> lst[DIM]; set<pair<int, int>> mst;

void solve(int c, int n, int &ans) {
	lst[c].push_back(n + 1); sort(lst[c].begin(), lst[c].end());
	ans = min(ans, *lower_bound(lst[c].begin(), lst[c].end(), dp[c]) - 2); }

int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
#ifdef HOME
	freopen("cf.in", "r", stdin);
	freopen("cf.out", "w", stdout);
#endif		
	int n, m, k; cin >> n >> m >> k;
	for (int i = 1; i <= k; ++i) {
		pair<int, int> pr; cin >> pr.first >> pr.second; 
		mst.insert(pr); lst[pr.second].push_back(pr.first); }
	dp[1] = 1; int ans = 1000000; solve(1, n, ans);
	for (int i = 2; i <= m; ++i) {
		pair<int, int> pr = make_pair(dp[i - 1] + 1, i - 1); 
		while (mst.find(make_pair(pr.first, pr.second + 1)) != mst.end()) {
			++pr.first; 
			if (pr.first > n) {
				break; } }
		if (pr.first > n) {
			break; }
		else {
			dp[i] = pr.first;
			solve(i, n, ans); } }
	cout << ans + 1; 
	return 0; }


Measured memory_bytes: 20864
#include<iostream>
#include<string>
#include<cctype>
#include<vector>
#include<algorithm>
using namespace std;
string s;
int now;
int rec(){
  if(isdigit(s[now])){
    int res = 0;
    while(now < s.size() && isdigit(s[now])) res = res * 10 + s[now++] - '0';
    return (res + 1) / 2;
  }else{
    vector<int> dat; int res = 0;
    while(s[now] == '[') now++ , dat.push_back(rec()) , now++;
    sort(dat.begin(),dat.end());
    for(int i = 0 ; i < ( dat.size() + 1 ) / 2 ; i++ ) res += dat[i];
    return res;
  }
}
int main(){
  int q;
  cin >> q;
  while(q--){
    now = 0;
    cin >> s;
    cout << rec() << endl;
  }
}

Measured memory_bytes: 1276
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 61
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={0,0,1,-1},dy[]={1,-1,0,0};

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

    double R1,R2;
    cin>>R1>>R2;
    printf("%.10lf\n",(R1*R2)/(R1+R2));
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int ans1=0,ans2=0;
    int n=s.length();
    for(int i=0;i<n;i++)
        if(s[i]=='g')
        ans1++;
    else
        ans2++;
    int ans4=n/2;
    int ans3=n-n/2;
    printf("%d\n",min(ans4,ans1)-min(ans3,ans2));
    return 0;
}


Measured memory_bytes: 512
import bisect

N, Q = list(map(int, input().split()))
S = list(input())
S2 = []
for i in range(N - 1):
    if S[i] == "A" and S[i + 1] == "C":
        S2.append(i)
for i in range(Q):
    l, r = list(map(int, input().split()))
    L = bisect.bisect_left(S2, l - 1)
    R = bisect.bisect_right(S2, r - 2)
    print(R - L)


Measured memory_bytes: 6508
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main(){
    int n,k;
    cin >> n >> k;
    int h[n];
    rep(i,n)cin >> h[i];

    sort(h,h+n,greater<int>());
    ll ans = INF; 
    rep(i,n-k+1)if(ans>h[i]-h[i+k-1])ans=h[i]-h[i+k-1];

    cout << ans;

    return 0;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define int int64_t
#define rep(i, N) for(int i=0; i<N; i++)
using namespace std;
using pair = pair<int, int>;
using tup  = tuple<int, int, int>;
using vec  = vector<int>;
using vvec = vector<vec>;
// " ", ' '
// std::string str;
// str = std::to_string(int i);

// プロトタイプ宣言
// int myfunc(int, vvec);

// グローバル変数
// int N, M;
// vvec data(N, vec(M));

// 関数：

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int N; cin >> N;
	vec A(N+1, 0), B(N+1, 0), C(N+1, 0);
	rep(i, N) {
		cin >> A.at(i);
		A.at(i) -= 1;
	}
	rep(i, N) cin >> B.at(i);
	rep(i, N-1) cin >> C.at(i);

	int ans = B.at(A.at(0));
	for(int i=1; i<N; i++) {
		if(A.at(i) == A.at(i-1)+1) {
		ans += B.at(A.at(i))+C.at(A.at(i-1));
		}
		else {
		ans += B.at(A.at(i));
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import random


class Dice(object):
    def __init__(self):
        self.t = 1
        self.s = 2
        self.e = 3
        self.w = 4
        self.n = 5
        self.b = 6

    def __init__(self, faces):
        self.t = faces[0]
        self.s = faces[1]
        self.e = faces[2]
        self.w = faces[3]
        self.n = faces[4]
        self.b = faces[5]

    def roll(self, direct):
        if direct == 0:
            self.t, self.s, self.b, self.n = self.n, self.t, self.s, self.b
        elif direct == 1:
            self.t, self.w, self.b, self.e = self.e, self.t, self.w, self.b
        elif direct == 2:
            self.n, self.w, self.s, self.e = self.w, self.s, self.e, self.n

    def is_equal(self, dice):
        if self.t == dice.t and self.s == dice.s and self.e == dice.e and self.w == dice.w and self.n == dice.n and self.b == dice.b:
            return True
        else:
            return False

    def get_nums(self):
        return {self.t, self.s, self.e, self.w, self.n, self.b}

n = int(input())
dice_list = []
flag_list = []
for _ in range(n):
    flag = False
    faces = list(map(int, input().split()))
    dice_list.append(Dice(faces))

    if n == 0:
        continue

    dice_a = dice_list[-1]
    for i in range(len(dice_list) - 1):
        dice_b = dice_list[i]

        if (dice_a.get_nums() == dice_b.get_nums()):
            for i in range(1000):
                dice_b.roll(random.randint(0, 3))
                if dice_a.is_equal(dice_b):
                    flag = True
                    break

        flag_list.append(flag)

if any(flag_list):
    print('No')
else:
    print('Yes')



Measured memory_bytes: 8280
#include <bits/stdc++.h>
#define NAME "INPUT"
using namespace std;
ifstream fi (NAME".inp");
ofstream fo (NAME".out");
int main(){
     int n;
     cin>>n;
     int x=n%10;
     set<int> a={2,4,5,7,9};
     set<int> b={0,1,6,8};
        if(a.find(x)!=a.end())
            cout<<"hon";
        if(b.find(x)!=b.end())
            cout<<"pon";
        if(x==3) cout<<"bon";
}





Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define INFTY powl(2,60)

vector<vector<long long>> m(101,vector<long long>(101));
vector<int> p(101);

long long matrixChainMultiplication(int n){
    for(int i=1;i<n+1;i++){
        m[i][i]=0;
    }
    for(int l=1;l<n;l++){
        for(int i=1;i<n-l+1;i++){
            int j=i+l;
            m[i][j]=INFTY;
            for(int k=i;k<j;k++){
                m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
            }
        }
    }
    return m[1][n];
}

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>p[i]>>p[i+1];
    }
    cout<<matrixChainMultiplication(n)<<endl;
}


Measured memory_bytes: 3224
##https://atcoder.jp/contests/dp/tasks/dp_a 
N = int(input())
Place_Height_List = list(map(int,input().split()))  
Min_List = [0,abs(Place_Height_List[1]-Place_Height_List[0])]

for i in range(2,len(Place_Height_List)):
    One_Step = abs(Place_Height_List[i] - Place_Height_List[i - 1]) 
    Two_Step = abs(Place_Height_List[i] - Place_Height_List[i - 2])
    Min_List.append(min(Min_List[i - 1] + One_Step,Min_List[i - 2] + Two_Step))
    
print(Min_List[-1])

Measured memory_bytes: 20464
#include<iostream>
using namespace std;
int main(){
    
    int x,i;
    i=0;
    while(i<=10000 && i>=0){
        
        cin>>x;
        if(x==0){break;}
             else{i++;
                 cout<<"Case "<<i<<": "<<x<<endl;}
             }
    return 0;}

Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N+1);
    rep(i, N+1) cin >> A.at(i);
    vector<pair<ll, ll>> bur(N+1);
    bur.at(N) = make_pair(A.at(N), A.at(N));
    rep(i, N){
        bur.at(N-i-1) = make_pair((bur.at(N-i).first+1)/2+A.at(N-i-1), bur.at(N-i).second+A.at(N-i-1));
    }
    if(1 < bur.at(0).first || bur.at(0).second < 1){
        cout << -1 << endl;
        return 0;
    }
    vector<ll> tdm(N+1);
    tdm.at(0) = 1;
    rep(i, N){
        tdm.at(i+1) = (tdm.at(i) - A.at(i)) * 2;
        chmin(tdm.at(i+1), bur.at(i+1).second);
    }
    vector<ll> nodes(N+1);
    ll ans = 0;
    rep(i, N+1){
        nodes.at(i) = min(bur.at(i).second, tdm.at(i));
        ans += nodes.at(i);
    }
    cout << ans << endl;
}

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

using ll = long long;

constexpr ll inf = 1e18;

int main() {
    int n, W; cin >> n >> W;
    vector<int> w(n), v(n);
    for(int i = 0; i < n; ++i) {
        cin >> w[i] >> v[i];
    }

    vector<ll> dp(1 << 18, inf);
    dp[0] = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = (1 << 18) - 1 - v[i]; j >= 0; --j) {
            dp[j + v[i]] = min(dp[j + v[i]], dp[j] + w[i]);
        }
    }

    for(int i = (1 << 18) - 1; i >= 0; --i) {
        if(dp[i] <= W) {
            cout << i << endl;
            return 0;
        }
    }
}


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

int main()
{
    int n,l,r,ans = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> l >> r;
        ans += r - l + 1;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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;

  if (s == "AAA" || s == "BBB") cout << "No" << endl;
  else cout << "Yes" << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define EPS 0.0000000001
#define INF 1000000000
#define MOD 1000000007
typedef long long ll;

int main()
{
    int a,b;
    cin>>a>>b;
    if(a==b){
        cout<<"Draw";
    }
    else if(a==1){
        cout<<"Alice";
    }
    else if(b==1){
        cout<<"Bob";
    }
    else if(a>b){
        cout<<"Alice";
    }
    else{
        cout<<"Bob";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#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; exit(0);}}
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); }

void solve(void)
{
  int N;cin>>N;
  int MIN = INF;
  for (int i = 0; i < 5; i++)
  {
    int X;cin>>X;
    chmin(MIN,X);
  }
  // DEBUG(MIN);
  cout<<4 + (N/MIN) +(N%MIN>0)<<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(9);
solve();

return 0;
}

Measured memory_bytes: 256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let S = rl();

    let first = S[0..2].parse::<i32>().unwrap();
    let second = S[2..4].parse::<i32>().unwrap();

    let maybeYyMm = 1 <= second && second <= 12;
    let maybeMmYy = 1 <= first && first <= 12;

    println!(
        "{}",
        match (maybeYyMm, maybeMmYy) {
            (true, true) => "AMBIGUOUS",
            (false, false) => "NA",
            (true, false) => "YYMM",
            (false, true) => "MMYY",
        }
    )
}


Measured memory_bytes: 4352
from itertools import accumulate
n = int(input())
a = list(map(int, input().split()))
a = [i+1 for i in a]

imos = [0] * (10**5 + 3)

for i in a:
    imos[i-1] += 1
    imos[i+2] -= 1

i = accumulate(imos)
print(max(i))


Measured memory_bytes: 56900