akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll mod = 1e9 + 7;

const double PI=3.14159265358979323846;

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

    ll n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    REP(i, 2 * n) {
        if (i % 2 == 0) cout << s[i / 2];
        else cout << t[i / 2];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i, a, b) for(int i = (a);i < (b);++i)
#define FORR(i, b, a) for (int i = (b) - 1;i >= 0;--i)
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = (n) - 1;i >= 0;--i)
#define ITER(itr, v) for(auto itr = v.begin();itr != v.end();++itr)
#define SORT(v) sort(v.begin(), v.end())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int H, W;
	cin >> H >> W;
	vector<string> s(H);
	REP(i, H) cin >> s[i];
	vector<vector<int>> dp(H, vector<int>(W));
	dp[0][0] = (s[0][0] == '#');
	FOR(i, 1, H) {
		dp[i][0] = dp[i - 1][0] + (s[i - 1][0] == '.' && s[i][0] == '#');
	}
	FOR(j, 1, W) {
		dp[0][j] = dp[0][j - 1] + (s[0][j - 1] == '.' && s[0][j] == '#');
	}
	FOR(i, 1, H)FOR(j, 1, W) {
		int a = dp[i - 1][j] + (s[i - 1][j] == '.' && s[i][j] == '#');
		int b = dp[i][j - 1] + (s[i][j - 1] == '.' && s[i][j] == '#');
		dp[i][j] = min(a, b);
	}
	cout << dp[H - 1][W - 1] << endl;

	return 0;
}


Measured memory_bytes: 384
(V=(1..1+N=gets.to_i).find{|i|i*~-i/2==N})?(e=["#{V-1}"]*V
V.times{|i|i.times{|j|e[i]+=s=" #$."
e[j]+=s
$.+=1}}
puts:Yes,V,e):$><<"No"

Measured memory_bytes: 22524
#include <bits/stdc++.h>
using namespace std;
#define N 10000000
typedef long long ll;
ll search(ll a[], ll n, ll rem){
    if (a[n]<=rem)return n;
    if (a[1] > rem)return 0;
    int f = 1, l = n;
    ll ans = 0;
    while(f<=l){
        int mid = (f+l)/2;
        if (a[mid] <= rem){
            ans = mid;
            f = mid+1;
        }
        else l = mid-1;
    }
    return ans;
}
int main()
{
    ll n, m, k;
    cin>>n>>m>>k;
    ll a[n+1];
    ll b[m+1];
    for (int i=1; i<=n; i++)cin>>a[i];
    for (int j=1; j<=m; j++)cin>>b[j];
    ll asum[n+1], bsum[m+1]; asum[0] = 0, bsum[0]=0;
    for (int i=1; i<=n; i++){
        asum[i] = asum[i-1] + a[i];
    }
    ll ans  = 0;
    for (int i=1; i<=m; i++)bsum[i] = bsum[i-1] + b[i];
    for (int i=1; i<=n; i++){
        ll rem = k - asum[i];
        if (rem < 0)break;
        ll j = search(bsum, m, rem);

        ans = max(ans, i+j);
    }
    for (ll i=1; i<=m; i++){
        if (bsum[i] > k)break;
        ans = max(ans, i);
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 9884
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int f(int n) {
    int res = 0;
    vi v;
    for(int i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            v.push_back(i);
            if(i * i != n) {
                v.push_back(n / i);
            }
        }
    }
    res = v.size();
    return res;
}

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

    int ans = 0;
    for(int i = 1; i <= n; i++) {
        if(i % 2 == 0) continue;
        int t = f(i);
        if(t == 8) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
using System;

class F
{
	static void Main()
	{
		var h = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
		long l = h[0], a = h[1], b = h[2];
		M = h[3];

		var r = 0L;
		var d_max = (a + (l - 1) * b).ToString().Length;
		for (int d = a.ToString().Length; d <= d_max; d++)
		{
			var d10 = 1L;
			for (int i = 0; i < d; i++) d10 *= 10;
			var n_max = Math.Min(l - 1, (d10 - 1 - a) / b);
			var t_min = d10 / 10 - 1 - a;
			var n_min_ex = t_min < 0 ? -1 : t_min / b;

			long c = a + (n_min_ex + 1) * b, n = n_max - n_min_ex;
			var q = new long[,] { { d10 % M, 1, 0 }, { 0, 1, 1 }, { 0, 0, 1 } };
			q = MPow3(q, n);
			r = (q[0, 0] * r + q[0, 1] * (c % M) + q[0, 2] * (b % M)) % M;
		}
		Console.WriteLine(r);
	}

	static long M;

	static long[,] MPow3(long[,] b, long i)
	{
		var r = new long[,] { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } };
		for (; ; b = MProduct3(b, b))
		{
			if (i % 2 > 0) r = MProduct3(r, b);
			if ((i /= 2) < 1) return r;
		}
	}

	static long[,] MProduct3(long[,] a, long[,] b)
	{
		var r = new long[3, 3];
		for (var i = 0; i < 3; i++)
			for (int j = 0; j < 3; j++)
			{
				for (var k = 0; k < 3; k++) r[i, j] += a[i, k] * b[k, j];
				r[i, j] %= M;
			}
		return r;
	}
}


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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    ll x;
    cin>>x;
    int arr[]={8,7,6,5,4,3,2,1};
    x=x-400;
    x/=200;
    cout<<arr[x]<<"\n";
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


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

using namespace std;

const int nmax = 100009;

vector < int > g[nmax];
long long dp[nmax];
int a[nmax];
int i , n , x , y , no;

void dfs(int act , int dad)
{
    int leave = 1;

    for (int i = 0 ; i < g[act].size() ; ++i)
    {
        int nxt = g[act][i];
        if (nxt == dad) continue;

        leave = 0;
        dfs(nxt , act);
    }

    if (act == 1)
    {
        if (g[act].size() == 1) dp[act] = a[act];
        else dp[act] = a[act] + a[act];
    }
    else
    {
        if (leave) dp[act] = a[act];
        else dp[act] = a[act] + a[act];
    }

    for (int i = 0 ; i < g[act].size() ; ++i)
    {
        int nxt = g[act][i];
        if (nxt == dad) continue;

        dp[act] -= dp[nxt];
        if (dp[nxt] > a[act]) no = 1;
    }
    if (dp[act] > a[act]) no = 1;

    if (dp[act] < 0) no = 1;
}

int main()
{

//freopen("test.in" , "r" , stdin);
//freopen("test.out" , "w" , stdout);

scanf("%d" , &n);

for (i = 1 ; i <= n ; ++i)
scanf("%d" , &a[i]);

for (i = 2 ; i <= n ; ++i)
{
    scanf("%d" , &x);
    scanf("%d" , &y);

    g[x].push_back(y);
    g[y].push_back(x);
}

dfs(1 , 0);
if (dp[1]) no = 1;

if (no) printf("NO\n");
else printf("YES\n");

return 0;
}


Measured memory_bytes: 13568
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
using namespace std;

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

string s, t;
string ans = "";

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

  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  if (s < t) {
    ans = "Yes";
  } else {
    ans = "No";
  }

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


Measured memory_bytes: 256
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::Ordering;
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

impl<T: Copy> Copy for Rev<T> {}

fn main() {
    input! {
        a: i64,
        b: i64,
    }

    let a = (a-1) as f64;
    let b = (b-1) as f64;
    println!("{}", (b / a).ceil() as i64);
}


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

int main(void){
  char s[101];
  scanf("%s", s);
  long k;
  scanf("%ld", &k);
  
  int l = strlen(s);
  long change = 0;
  int count = 1;
  for (int i = 1; i < l; i++){
    if (s[i] == s[i - 1]) count++;
    else{
      change += count / 2;
      count = 1;
    }
  }
  change += count / 2;
  
  if (count == l){
    printf("%ld\n", l * k / 2);
    return 0;
  }
  
  int first = 1, end = 1;
  if (s[0] == s[l - 1]){
    for (int i = 1; i < l; i++){
      if (s[i] == s[i - 1]) first++;
      else break;
    }
    for (int i = l - 1; i > 0; i--){
      if (s[i] == s[i - 1]) end++;
      else break;
    }
  }
  change *= k;
  if (s[0] == s[l - 1] && first * end % 2 == 1){
    change += k - 1;
  }
  
  printf("%ld\n", change);
  return 0;
}


Measured memory_bytes: 128
/**
 * ????????¢?????¢?????¨??¨?????????

?????? a cm ?????? b cm ???????????¢?????¢?????¨??¨?????????????±???????????????°?????????????????????????????????

Input
a ??¨ b ????????????????????§????????????????????????????????????

Output
??¢?????¨??¨?????????????????????????????§????????£????????????????????????????????????

Constraints
1 ??? a, b ??? 100
Sample Input
3 5
Sample Output
15 16
????????¢?????¢?????¨??¨?????????

?????? a cm ?????? b cm ???????????¢?????¢?????¨??¨?????????????±???????????????°?????????????????????????????????

Input
a ??¨ b ????????????????????§????????????????????????????????????

Output
??¢?????¨??¨?????????????????????????????§????????£????????????????????????????????????

Constraints
1 ??? a, b ??? 100
Sample Input
3 5
Sample Output
15 16

 */

#include <iostream>
#include <sstream>

int main(int argc, char const *argv[]) {
  std::string param;

  unsigned int a, b = 0;

  while (true) {

    getline(std::cin, param);
    std::istringstream iss(param);
    iss >> a >> b;

    if ((a < 1 || a > 100) || (b < 1 || b > 100)) {
      std::cout << "Error: 1 <= a, b <= 100" << std::endl;
    } else {
      break;
    }
  }

  std::cout << a * b << " " << (a + b) * 2 << std::endl;
  return 0;
}

Measured memory_bytes: 3220
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  string S;
  cin >> S;

  int start = N;
  vector<int> answer;
  while (start > 0) {
    int check = max(0, start - M);
    while (S[check] == '1') check++;
    if (check == start) {
      cout << -1 << endl;
      return 0;
    }
    answer.emplace_back(start - check);
    start = check;
  }

  reverse(answer.begin(), answer.end());
  rep(i, (int)answer.size()) {
    if (i != 0) cout << " ";
    cout << answer[i];
  }
  cout << endl;
  return 0;
}


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

int main()
{

        long long N, K;
        cin >> N >> K;

        int keta = 1;
        int beki = 0;
        while (1) {

                beki = pow(K, keta);

                if (N <= (beki - 1)) {
                        cout << keta << endl;
                        break;
                }
                keta++;
        }







}


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

const int mod = 1000000007;

int main(){
    string b;
    cin>>b;
    int n=b.size();
    string s;
    rep(i,n){
        s+='x';
    }
    cout<<s<<endl;
}

Measured memory_bytes: 256
# https://at274.hatenablog.com/entry/2018/02/03/140504
class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        # 根への距離を管理
        self.weight = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 併合
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            # 木の高さが同じだった場合の処理
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]

N,M=map(int,input().split())
uf = WeightedUnionFind(N+1)
for i in range(M):
  l,r,d=map(int,input().split())
  if l>r:
    l,r=r,l
    d=-d
  if uf.same(l,r) and d != uf.diff(l,r):
    print('No')
    exit()
  uf.union(l,r,d)
print('Yes')

Measured memory_bytes: 15864
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 998244353
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
using namespace std;
string s,t;
int main(){
	ll i,j,ans=LINF,ts;
	cin>>s>>t;
	for(i=0;i+t.size()<=s.size();i++)
	{
		ts=0;
		for(j=0;j<t.size();j++)
		{
			if(s[i+j]!=t[j])
			{
				ts++;
			}
		}
		ans=min(ans,ts);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3624
N, K = map(int, input().split())

d = [0]*K
A = [[0]]*K
for i in range(K):
    d[i] = int(input())
    A[i] = list(map(int, input().split()))
    

ans = N
A = sum(A, [])
for i in range(1,N+1):
    if i in A:
        ans -= 1
      
     
print(ans)

Measured memory_bytes: 9264
n = int(input())
assert n <= 20 and n >= 3,"input error(3 <= n <= 20)"
p = list(map(int,input().split()))
res = 0
for i in range(1,n-1,1):
    if (p[i-1] < p[i] and p[i] < p[i+1]) or (p[i-1] > p[i] and p[i] > p[i+1]):
        res +=1

print(res)

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

int main(){
    string s; cin >> s;
    //池の面積は同じ高さにある坂（x座標をそれぞれi,jとする)に挟まれた水平部分を考えればj - iと分かることを使って計算していく　
    stack<int> stck1; //下り坂の左端
    stack<pair<int, int>> stck2; //<池の左端,池の面積>
    for(int i = 0; i < s.size(); i++){
        if(s.at(i) == '\\') stck1.push(i); 
        else if(s.at(i) == '/' && !stck1.empty()){ // これは\/がペアを作れる時
            int tmp = stck1.top(); stck1.pop();
            int a = i - tmp; //この/に対応する\で挟まれた水平部分の面積はi-tmpで表せる
            while(!stck2.empty() && stck2.top().first > tmp){ //池の左端が今考えている/に対応する\だった場合
                a += stck2.top().second; //より大きな池の面積が得られる
                stck2.pop(); 
            }
            stck2.push(make_pair(tmp, a)); //更新した値をstackへ
        }
    } 
    int sum = 0; //面積の和
    stack<int> ans; //答え用のスタック
    while(!stck2.empty()){
        ans.push(stck2.top().second); //各池の面積を左からの順に直す
        sum += stck2.top().second; 
        stck2.pop();
    }
    //以下出力の処理
    cout << sum << endl;
    cout << ans.size();
    while(!ans.empty()){
        cout << " " << ans.top();
        ans.pop();
    }
    cout << endl;
}


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

int main()
{
    long long int N;
    long long int T[5], sub[5];

    cin >> N;
    for (int i = 0; i < 5; i++) {
        cin >> T[i];
    }

    for (int i = 0; i < 5; i++) {
        sub[i] = (N / T[i]);
        if (N % T[i] > 0) {
            sub[i]++;
        }
    }

    long long int max_s = -1;
    int suf;
    for (int i = 0; i < 5; i++) {
        if (max_s < sub[i]) {
            suf = i;
            max_s = sub[i];
        }
    }

    cout << sub[suf] + 4 << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int A[100001];
int B[100000];

int main()
{
	int N, kill;
	ll ans = 0;

	cin >> N;
	rep(i, N + 1) cin >> A[i];
	rep(i, N) cin >> B[i];

	rep(i, N) {
		kill = min(B[i], A[i]);
		ans += kill;

		kill = min(B[i] - kill, A[i + 1]);
		A[i + 1] -= kill;
		ans += kill;
	}

	cout << ans << endl;

	return 0;
}


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

#undef int
int main()
{
#define int long long int
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n;
	cin>>n;
	vector<int> v(n), dp(n);
	for(int i = 0;i<n;i++)
		cin>>v[i];
	dp[1] = abs(v[0]-v[1]);
	for(int i = 2;i<n;i++)
		dp[i] = min(dp[i-1]+abs(v[i-1]-v[i]), dp[i-2]+abs(v[i-2]-v[i]));
	cout<<dp[n-1]<<endl;
	
	return 0;
}

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

int main()
{
  int N; cin >> N;
  int D[55];
  for (int i = 0; i < N; i++)
  {
    cin >> D[i];
  }
  
  int ans = 0;
  for (int j = 0; j < N - 1; j++)
  {
    for (int k = j + 1; k < N; k++)
    {
      ans += D[j] * D[k];
    }
  }
  
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl

using ld = double;
using P = complex<ld>;
using G = vector<P>;
const ld pi = acos(-1);
const ld eps = 1e-10;
const ld inf = 1e12;

ld cross(const P& a, const P& b) { return a.real()*b.imag() - a.imag()*b.real(); }
ld dot(const P& a, const P& b) { return a.real()*b.real() + a.imag()*b.imag(); }

using C = pair<ld, P>;
#define rad first
#define pnt second

template <class iter>
std::pair<P, ld> min_ball(iter left, iter right, int seed = 1333) {
    const int n = right - left;

    assert(n >= 1);
    if (n == 1) {
        return {*left, ld(0)};
    }

    std::mt19937 mt(seed);
    std::shuffle(left, right, mt);
    // std::random_shuffle(left, right); // simple but deprecated

    iter ps = left;
    using circle = std::pair<P, ld>;

    auto make_circle_3 = [](const P &a, const P &b, const P &c) -> circle {
        ld A = std::norm(b - c), B = std::norm(c - a), C = std::norm(a - b),
                S = cross(b - a, c - a);
        P p = (A * (B + C - A) * a + B * (C + A - B) * b + C * (A + B - C) * c) / (4 * S * S);
        ld r2 = std::norm(p - a);
        return {p, r2};
    };

    auto make_circle_2 = [](const P &a, const P &b) -> circle {
        P c = (a + b) / (ld)2;
        ld r2 = std::norm(a - c);
        return {c, r2};
    };

    auto in_circle = [](const P &a, const circle &c) -> bool {
        return std::norm(a - c.first) <= c.second + eps;
    };

    circle c = make_circle_2(ps[0], ps[1]);

    // MiniDisc
    for (int i = 2; i < n; ++i) {
        if (!in_circle(ps[i], c)) {
            // MiniDiscWithPoint
            c = make_circle_2(ps[0], ps[i]);
            for (int j = 1; j < i; ++j) {
                if (!in_circle(ps[j], c)) {
                    // MiniDiscWith2Points
                    c = make_circle_2(ps[i], ps[j]);
                    for (int k = 0; k < j; ++k) {
                        if (!in_circle(ps[k], c)) {
                            c = make_circle_3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}

int main(){
    int n;
    cin>>n;
    vector<complex<double>> c(n);
    for (int i = 0; i < n; ++i) {
        double a,b;
        cin>>a>>b;
        c[i]=complex<double>(a,b);
    }
    auto a=min_ball(c.begin(),c.end());
    cout<<setprecision(10);
    cout<<sqrt(a.second)<<endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    digits, orders = [int(x) for x in input().split()]
    number = [-1] * digits
    for _ in range(orders):
        left_count, numeral = [int(x) for x in input().split()]
        left_count -= 1
        if number[left_count] != -1:
            # already assigned!
            if number[left_count] != numeral:
                print(-1)
                return
        else:
            number[left_count] = numeral
    if digits > 1 and number[0] == 0:
        print(-1)
        return
    if number[0] == -1:
        if digits == 1:
            number[0] = 0
        else:
            number[0] = 1
    for x in number:
        if x == -1:
            x = 0
        print(x, end='')
    return


if __name__ == '__main__':
    main()


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;
typedef vector<pair<ll, ll>> vpll;

//mt19937 random(566);
//uniform_int_distribution<ll> distr;
//ll rnd(ll a, ll b) {return a + distr(random) % (b - a + 1);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, r;
    cin >> n >> r;
    if (n < 10) {
        cout << r + 100 * (10 - n) << "\n";
    } else {
        cout << r << "\n";
    }
    return 0;

}

Measured memory_bytes: 256
#include <iostream> 
#include <cstdio> 
#include <fstream> 
#include <algorithm> 
#include <cmath> 
#include <deque> 
#include <vector> 
#include <queue> 
#include <string> 
#include <cstring> 
#include <map> 
#include <stack> 
#include <set> 
typedef  long long ll;
const int  maxn = 5100;
const int mod = 1000000007;
using namespace std;
int n, m,p;
int s[maxn], e[maxn], v[maxn];
int d[maxn];
int vis[maxn],vs[maxn];
int flag;
int main()
{
	cin >> n >> m >> p;
	for (int i = 1; i <= m; i++)
	{
		scanf("%d %d %d", &s[i], &e[i],&v[i]);
		v[i] = p - v[i];
		if (e[i] == s[i])vis[i] = 1;
	}
	memset(d, 127, sizeof(d));
	d[1] = 0;
	for (int i = 1; i <= n - 1; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			if (d[e[j]] > d[s[j]] + v[j])
			{
				d[e[j]] = d[s[j]] + v[j];
				
			}
			if (d[s[j]] < 1000000000 && (e[j] == n || vs[e[j]]))
				{
					vs[s[j]] = 1;

				}
		}
	}
	int las = d[n];
	for(int i=1;i<=1000;i++)
	for (int j = 1; j <= m; j++)
	{
		
			if (d[e[j]] > d[s[j]] + v[j])
			{
				d[e[j]] = d[s[j]] + v[j];
				if (vs[s[j]]||vs[e[j]])flag = 1;
			}
	}
	if (d[n] != las)flag = 1;
	if (d[n] < 1000000000)
	{
		if (flag)printf("-1");
		else
		{
			printf("%d", max(0, -d[n]));
		}
	}
	else
	{
		printf("-1");
	}
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
int a,b,c;

int main()
{
    cin>>a>>b>>c;
    if (a==b && b==c)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}



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

using namespace std;
using ll = long long;

#define REP2(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; ++i)
#define REP3(i, l, r) for (int i = (l), i##_len = (int)(r); i < i##_len; ++i)
#define GET_MACRO_REP(_1, _2, _3, NAME, ...) NAME
#define REP(...) GET_MACRO_REP(__VA_ARGS__, REP3, REP2) (__VA_ARGS__)
#define RREP2(i, n) for (int i = (n - 1); i >= 0; --i)
#define RREP3(i, l, r) for (int i = (r - 1), i##_len = (l); i >= i##_len; --i)
#define GET_MACRO_RREP(_1, _2, _3, NAME, ...) NAME
#define RREP(...) GET_MACRO_REP(__VA_ARGS__, RREP3, RREP2) (__VA_ARGS__)
#define IN(type, n) type n; cin >> n
#define INALL(type, v) REP(i, v.size()) { IN(type, _tmp); v.at(i) = _tmp; }
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#ifdef _DEBUG
#define DEBUG(x) cout << #x << ": " << x << endl
#else
#define DEBUG(x)
#endif

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

int main() {
  IN(ll, N);
  ll count = 0;
  REP(i, 1, sqrt(N) + 1) {
    REP(j, i, N) {
      if (i * j < N) {
        if (i != j) count += 2;
        else count++;
      } else {
        break;
      }
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 3604
def side(p1, p2, pp)
  return (p2[0] - p1[0]) * (pp[1] - p1[1]) - (p2[1] - p1[1]) * (pp[0] - p1[0])
end

def inside_triangle?(data)
  p1 = data.slice(0, 2)
  p2 = data.slice(2, 2)
  p3 = data.slice(4, 2)
  pp = data.slice(6, 2)

  point_a = side(p1, p2, pp)
  point_b = side(p2, p3, pp)
  point_c = side(p3, p1, pp)

  (point_a > 0 && point_b > 0 && point_c > 0) || (point_a < 0 && point_b < 0 && point_c < 0)
end

while line = gets
  puts inside_triangle?(line.split(" ").map(&:to_f)) ? "YES" : "NO"
end

Measured memory_bytes: 6132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define vi vector<ll>
# define vvi vector<vi>
# define rep(i, N) for (int i = 0; i < N; i++)
# define Rep(i, N) for (int i = 1; i <= N; i++)
# define deb(x) cerr << #x << ": " << x << endl;
# define deb2(x, i) cerr << #x << "[" << i << "]: " << x[i] << endl;
/*
vi v(10, 2); 
rep(i, 10) deb2(v, i); 
*/

/*
int a; cin >> a;
int a, b; cin >> a >> b;
rep(i, n){cin >> v[i];}
cout <<   << endl;
*/

signed		main()
{
	double p = 3.14159265359;
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	double x = h * 30 + 30 * m / 60;
	double y = m * 6;
	double ang = x - y;

	//cout << x << " " << y << " " << ang << endl;
	//cout << cos(ang * p / 180) << endl; 
	
	double ans = sqrt(a * a + b * b + (-2) * a * b * cos(ang * p / 180));
	//cout << setprecision(12) << ans << endl;
	printf("%10.10f\n", ans);
}



Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
ll int large=(ll int)1e13+7;
ll int mod=(ll int)1e9+7;
ll int const N=(ll int)1e6+10;

ll int mod_exp(ll int x,ll int n)
{
    ll int result=1;
    while(n>0)
    {
        if(n%2==1)
            result=(result*x)%mod;
        x=(x*x)%mod;
        n=n/2;
    }
    return result;
}

ll int mod_inverse(ll int a)
{
    return mod_exp(a,mod-2);
}



int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
ll int T,i,j,ij;
T=1;
//cin>>T;
while(T--)
{
  ll int n;
  cin>>n;
  ll int a[n];
  rep(i,0,n)
  cin>>a[i];
  ll int x=0;
  rep(i,0,n)
  x=x^a[i];
  rep(i,0,n)
  cout<<(a[i]^x)<<" ";

}
return 0;
}
















Measured memory_bytes: 5116
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define SP << " " <<
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

#define int long long

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> a(N);
  REP(i, N) cin >> a[i];
  int tmp = a[0];
  FOR(i, 1, N) { tmp = tmp ^ a[i]; }
  if(tmp == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <limits.h>


using namespace std;

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

	vector<int> a;
	int wk;

	for (int i = 0; i < n; i++) {
		cin >> wk;

		a.push_back(wk);
	}

	vector<int> ans(n);
	for (int i = 0; i < n; i++)ans[i] = 0;
	int sum;
	int index;
	for (int i = n-1; i >= 0; i--) {
		sum = 0;
		index = 2 * i + 1;
		while (index < n) {
			sum += ans[index];
			index += i+1;
		}

		sum %= 2;

		if (sum != a[i]) {
			ans[i] = 1;
		}
		

	}

	vector<int> b;
	int anscount = 0;
	for (int i = 0; i < n; i++) {
		if (ans[i] == 1) {
			anscount++;
			b.push_back(i+1);
		}
	}

	if (anscount == 0) {
		cout << "0" << endl;
	}
	else {
		cout << b.size() << endl;
		cout << b[0];
		for (int i = 1; i < b.size(); i++) {
			cout << " " << b[i];
		}
		cout << endl;


	}


	

	return 0;





}



Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    string S,T;
    cin >> S >> T;
    bool ok = true;
    int N = S.size();
    map<char,int> mp_S,mp_T;
    REP(i,N) {
        if(mp_S.count(S[i])) mp_S[S[i]]++;
        else  mp_S[S[i]] = 1;
        if(mp_T.count(T[i])) mp_T[T[i]]++;
        else  mp_T[T[i]] = 1;
    }
    veci A;
    veci B;
    for(auto p : mp_S) A.push_back(p.second);
    for(auto p : mp_T) B.push_back(p.second);
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    if(A.size() != B.size()) ok = false;
    else {
        REP(i,A.size()) if(A[i] != B[i]) ok = false;
    }
    cout << (ok ? "Yes" : "No") << endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int main(){
    string S;
    cin >> S;
    int N = S.length();
    
    bool even = (N%2 == 0);
    bool same = (S[0] == S[N-1]);

    if(same && even || !same && !even){
        cout << "First" << endl;
    }
    else{
        cout << "Second" << endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a==1&&b==2||a==2&&b==1){
    printf("3\n");
  }
  else if(a==2&&b==3||a==3&&b==2){
    printf("1\n");
  }
  else if(a==3&&b==1||a==1&&b==3){
    printf("2\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> s(m), c(m);
    rep(i, m){
        cin >> s[i] >> c[i];
    }
    rep(x, 1000){
        int nx = x /10;
        vector<int> d(1, x%10);
        while(nx){
            d.push_back(nx%10);
            nx /= 10;
        }
        reverse(d.begin(), d.end());
        if(d.size() != n) continue;
        bool ok = true;
        rep(i, m){
            if (d[s[i] -1] != c[i]) ok = false;
        }
        if(ok){
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def SI(): return input()
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')

N = II()
H_li = LI()

counter = 0
for i, H in enumerate(H_li):
    nolook = False
    for j in range(i+1):
        if H_li[j] > H: nolook = True
    if not nolook: counter+=1

print(counter)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define endl '\n'
#define pb push_back
const int N=1e5+1;
const int INF=1e9+7;

int32_t main()
{
 ios_base::sync_with_stdio(0);
 cin.tie(0); cout.tie(0);
 int n; cin>>n; int A[n];
 for(int i=0;i<n;i++){cin>>A[i];} int ans=0; int x=1;
 int p[n]; p[0]=A[0];
 for(int i=1;i<n;i++)
 {
     p[i]=(A[i]+p[i-1])%INF;
 }
 for(int i=1;i<n;i++)
 {
     ans+=(A[i]*p[i-1]);
     ans%=INF;
 }
 cout<<ans<<endl;
}


Measured memory_bytes: 6704
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  //
  ll n;
  cin >> n;
  vl p(n);
  rep(i, n) cin >> p[i];
  sort(ALL(p), greater<ll>());
  ll sum = 0;
  sum += p[0] / 2;
  REP(i, 1, n) sum += p[i];
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  ll n;
  cin >> n;
  ll sum = 0;

  for (int i=1; i<=n; i++) {
   if (i % 15 == 0) continue;
   if (i % 3 == 0) continue;
   if (i % 5 == 0) continue;

    sum += i;
  }
  cout << sum << endl;
  return 0;
} 


Measured memory_bytes: 3192
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

main :: IO ()
main = do
    _ <- B.getLine
    as <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    let ls = concat $ filter (\s -> length s >= 2) $ group $ sortBy (flip compare) as
    print $ area ls
    where
        area [] = 0
        area [_] = 0
        area [_, _] = 0
        area [_, _, _] = 0
        area (a:_:c:d:_)
            | c == d = a * c
            | otherwise = a * d


Measured memory_bytes: 15740
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var n = Number(lines[0]);
 var ans = 0;

 for(i=1; i<=n; i++){
   var tmp = Math.floor(i * 1.08);
   if(tmp  == n){
     ans++;
     console.log(i);
   }
 }

 if(ans == 0){
   console.log(":(");
 }
});

Measured memory_bytes: 7756
//
// Created by pavao on 9/22/2019.
//

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<double> prices(n);
    for (int i = 0; i < n; i++) {
        cin >> prices[i];
    }
    make_heap(prices.begin(), prices.end());

    for (int i = 0; i < m; i++) {
        double first = prices.front();
        double r = first / 2.0;
//        first = round(r);
        pop_heap(prices.begin(), prices.end());
        prices.pop_back();
        prices.push_back(r);
        push_heap(prices.begin(), prices.end());

//        for(int i = 0; i< n; i++){
//            cout << prices[i] << endl;
//        }
//        cout << endl;
    }

    long long sum = 0;
    for(int i = 0; i< n; i++){
//        cout << prices[i] << endl;
        sum+=(int)(prices[i]);
    }

    cout << sum;

    return 0;
}


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

using namespace std;


int main()
{
  string s,t;
  cin >> s >> t;
  int j = 2;
  for(int i = 0;i < 3;i++){
    if(s.at(i) != t.at(j)) {
      cout << "NO";
      return 0;
    }
    j--;
  }
  cout << "YES";

}


Measured memory_bytes: 3588
#include <iostream>

using namespace std;

const int N = 200000;

int main()
{
    int n, array[N], max_value1 = -1, max_value2 = -1, max_index=0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> array[i];
    }

    for(int i=0;i<n;i++){
        if(max_value1 < array[i]){
            max_value1 = array[i];
            max_index = i;
        }
    }
    for(int i=0;i<n;i++){
        if(i == max_index) continue;
        if(max_value2 < array[i]){
            max_value2 = array[i];
        }
    }

    for(int i=0;i<n;i++){
        if(i != max_index)
            cout << max_value1 << endl;
        else
            cout << max_value2 << endl;
    }
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	int l, r, d;
	cin >> l >> r >> d;
	
	cout << r / d - (l - 1) / d << endl;
}

int main(){
#define MULTITEST 0
#if MULTITEST   
 
    CASET {
        solve();
    }
    
#else

    solve();
    
#endif

    return 0;
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define DUP(x, y) (((x) + (y) - 1) / (y))
#define YES puts("YES")
#define NO puts("NO")
#define Yes puts("Yes")
#define No puts("No")
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end())

using ll = std::int64_t;
using vint = std::vector<int>;
using vll = std::vector<ll>;
using vstr = std::vector<std::string>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

bool isPrime(int n) {
    if (n < 2)return false;
    else if (n == 2)return true;
    else if (n % 2 == 0)return false;

    double sqrt_n = sqrt(n);
    for (int i = 3; i <= sqrt_n; i += 2) {
        if (n % i == 0)return false;
    }
    return true;
}

void Main() {
    int n, m;
    cin >> n >> m;

    if (isPrime(m)) {
        puts("1");
        return;
    }

    int ans = 1;
    for (int i = n; i < m; ++i) {
        if (DUP(m, i) == m / i) {
            ans = m / i;
            break;
        }
    }
    cout << ans << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll A,B,C,D,E,F;
  cin>>A>>B>>C>>D>>E>>F;
  ll mx_water = 100;
  ll mx_sugar = 0;
  rep(a,0,31){
    rep(b,0,31){
      if(a==0&&b==0)continue;
      ll water = 100*A*a+100*B*b;
      if(water>F)continue;
      rep(c,0,3001){
        ll sugar1 = C*c;
        if(sugar1*100>water*E)continue;
        if(sugar1+water>F)continue;
        ll s1 = (E*water/100-sugar1)/D*D;
        ll s2 = (F-water-sugar1)/D*D;
        ll sugar2;
        if(s1<=s2)sugar2 = s1;
        else sugar2 = s2;
        if(mx_sugar*(water+sugar1+sugar2)<=(sugar1+sugar2)*(mx_water+mx_sugar)){
          mx_water = water;
          mx_sugar = sugar1+sugar2;
        }
      }
    }
  }
  cout << mx_water+mx_sugar << " " << mx_sugar << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

public class Main{
	public static ArrayList<Read> read;
	public static HashMap<Integer, Integer> table;
	public static HashMap<Integer, Integer> fsize;
	public static void main(String[] args) throws IOException{
		Scanner in = new Scanner(System.in);
		while(true){
			// 0:write 1:delete 2:read
			int n = in.nextInt();
			if(n==0) break;
			int[][] command = new int[n][3];
			read = new ArrayList<Read>();
			table = new HashMap<Integer, Integer>();
			fsize = new HashMap<Integer, Integer>();
			HashSet<Integer> used = new HashSet<Integer>();
			for(int i=0; i<n; i++){
				char c = in.next().charAt(0);
				if(c=='W'){
					command[i][1] = in.nextInt();
					command[i][2] = in.nextInt();
					fsize.put(command[i][1], command[i][2]);
				}else if(c=='D'){
					command[i][0] = 1;
					command[i][1] = in.nextInt();
				}else{
					command[i][0] = 2;
					command[i][1] = in.nextInt();
					if(used.contains(command[i][1])) continue;
					used.add(command[i][1]);
					read.add(new Read(command[i][1]));
				}
			}
			Collections.sort(read);
			int sum = 0;
			for(int i=0; i<read.size(); i++){
				sum = read.get(i).setSpace(sum);
				table.put(read.get(i).sector, i);
			}
			for(int i=0; i<n; i++){
				switch(command[i][0]){
				case 0:
					write(command[i][1], command[i][2]);
					break;
				case 1:
					delete(command[i][1]);
					break;
				case 2:
					System.out.println(read(command[i][1]));
					break;
				}
			}
			System.out.println();
		}
	}
	
	public static void delete(int file){
		int size = fsize.get(file);
		for(Read r: read){
			size -= r.delete(file);
			if(size == 0) break;
		}
	}
	
	public static int read(int sector){
		return read.get(table.get(sector)).read();
	}
	
	public static void write(int file, int size){
		for(Read r: read){
			size = r.write(file, size);
			if(size == 0) break;
		}
	}
}

class Read implements Comparable<Read>{
	int file = -1;
	HashMap<Integer, Integer> map
		= new HashMap<Integer, Integer>();
	int space;
	int sector;
	public Read(int sector){
		this.sector = sector;
		space = sector;
	}
	
	public int setSpace(int sum){
		space -= sum;
		return sum+space+1;
	}
	
	public int write(int f, int size){
		int res = 0;
		int wr = file == -1 ? 1 : 0;
		if(space == 0 && wr == 0) return size;
		if(size >= space + wr){
			res = size - space-wr;
			size = space;
			if(wr==1) file = f;
		}
		space -= size;
		map.put(f, size);
		return res;
	}
	
	public int delete(int f){
		if(!map.containsKey(f)) return 0;
		int size = map.get(f);
		space += size;
		map.remove(f);
		if(f == file){
			file = -1;
			size++;
		}
		return size;
	}
	
	public int read(){
		return file;
	}
	
	@Override
	public int compareTo(Read o) {
		return sector-o.sector;
	}
}

Measured memory_bytes: 107548
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const ll mod  = 1e9 + 7;
const ll N = 1e6 + 5;

int n,a[N];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
 	cin>>n;
 	for(int i=1;i<=n;i++) cin>>a[i];
 	vector<int> V;
 	V.push_back(a[1]);
 	for(int i=2;i<n;i++){
 		if(V.size() && a[i]>V.back() && a[i]>a[i+1]) {
	 		int id=V.size();
 			if(V.size()>=2 && V[id-1]>V[id-2]) V.pop_back();
 			V.push_back(a[i]);
 		}
 		else if(V.size() && a[i]<V.back() && a[i]<a[i+1]) {
 			int id=V.size();
 			if(V.size()>=2 && V[id-1]<V[id-2]) V.pop_back();
 			V.push_back(a[i]);
 		}
 	}
 	if(V.size() && a[n]>V.back()) V.push_back(a[n]);
 	ll ans=1000,cnt=0;
 	if(V.size()>=2){
	 	for(int i=0;i<V.size();i++){
	 		// cout<<V[i]<<" \n"[i==V.size()-1];
	 		if(V[i]>V[i+1]){
	 			if(cnt){
	 				ans+=cnt*V[i];
	 				cnt=0;
	 			}
	 		}else{
	 			if(ans){
	 				cnt+=ans/V[i];
	 				ans-=ans/V[i]*V[i];
	 			}
	 		}
	 	}
 	}
 	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 3644
# coding:utf-8
n = int(input())
value = [int(d) for d in input().split(" ")]
cost = [int(d) for d in input().split(" ")]
valueSum = 0
costSum = 0
vcdifList = list()
for i in range(n):
	vc = value[i] - cost[i]
	if vc > 0:
		vcdifList.append(vc)
print(sum(vcdifList))


Measured memory_bytes: 3060
stdin = input().split(' ')
x = int(stdin[0])
y = int(stdin[1])

if y%2 == 0:
    a = x + x - y/2
    b = y/2-x
    if a >= 0 and b >= 0:
        print('Yes')
    else:
        print('No')
else:
    print('No')


Measured memory_bytes: 9120