akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const ll MOD = 1000000007;

int main() {
    ll n;
    cin >> n;
    cout << n*(n-1)/2 << endl;
}

Measured memory_bytes: 256
M, D = map(int, input().split())
count = 0
for m in range(1,M+1):
    for d in range(1, D+1):
        d10 = d // 10
        d1 = d % 10
        if d1 * d10 == m and d1 > 1 and d10 > 1:
            count += 1
print(count)

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll a,b,c,d;
    string S;
    ll A[MAX_N];
    ll answer = 0;

    //cin >> a >> b >> c >> d;
    cin >> S;
    //rep(i, N) cin >> A[i];
    ll n = S.length();
    
    ll cnt = 0;
    ll big = 0;
    For(i, 2, n-1) if (S[i] == 'C') cnt ++;
    rep(i, n) if (S[i] >= 'A' && S[i] <= 'Z') big ++;
    if (S[0]=='A' && cnt == 1 && big == 2) cout << "AC" << endl;
    else cout << "WA" << endl;

    //cout << answer << endl;

    return 0;
}


Measured memory_bytes: 256
// Problem : A - Station and Bus
// Contest : AtCoder Beginner Contest 158
// URL : https://atcoder.jp/contests/abc158/tasks/abc158_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

#include<bits/stdc++.h>
using namespace std;
#define ff first
#define fs second
#define int long long
#define vi vector<int>
#define vvi vector< vector <int> >
#define vpii vector< pair<int, int> >
#define vb vector<bool>
#define si set<int>
#define mii map<int, int>
#define mci map<char, int>
#define md 1000000007
#define pb push_back
#define eb emplace_back
#define f(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define r(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define qw1(x) cerr<<#x<<": "<<x<<" "<<endl
#define qw2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define qw3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define qw4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl

void sieve(int n, vb &prime)
{
    prime[0]=false;     prime[1]=false;
    for(int i=2;i*i<=n;i++){
         if(prime[i]==true){
            for(int j=i*i;j<=n;j+=i)    prime[j]=false;
             }
    }
}
int32_t main ()
{
  //ios_base::sync_with_stdio (false); cin.tie (NULL);  cout.tie (NULL);
   string s;	cin>>s;
   if(s[0]==s[1] && s[1]==s[2]) cout<<"No";
   else cout<<"Yes";
 
}








Measured memory_bytes: 256
N = gets.to_i
edges = (N - 1).times.map { gets.split.map(&:to_i) }
cs = gets.split.map(&:to_i).sort_by { |n| -n }

graph = Array.new(N) { [] }
edges.each do |(u, v)|
  u -= 1
  v -= 1
  graph[u].push(v)
  graph[v].push(u)
end


def bfs(graph, cs, start)
  ans = Array.new(N)
  queue = [[start, -1]]
  i = 0
  while !queue.empty?
    u, parent = queue.shift
    ans[u] = cs[i]
    i += 1
    graph[u].each do |v|
      next if v == parent
      queue.push([v, u])
    end
  end
  ans
end

sum = cs[1..-1].reduce(0, &:+)
ans = bfs(graph, cs, 0)
puts sum
puts ans.join(' ')


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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    ll r;
    cin >> r;
    MSG(3 * pow(r, 2))
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define MOD 1000000007
#define EPS (1e-10)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<ll, ll>P;

P yt[100000], ya[100000];
int t[100000], a[100000];
int main() {
	int n; scanf("%d", &n);
	rep(i, n)yt[i] = ya[i] = P(1, INF);
	rep(i, n) {
		scanf("%d", &t[i]);
		if (!i)yt[i] = P(t[i], t[i]);
		else {
			if (t[i - 1] >= t[i])yt[i].second = t[i];
			if (t[i - 1] < t[i])yt[i] = P(t[i], t[i]);
		}
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		
	}
	for (int i = 0; i < n; i++) {
		if (i == n - 1)ya[i] = P(a[i], a[i]);
		else {
			if (a[i + 1] >= a[i])ya[i].second = a[i];
			if (a[i + 1] < a[i])ya[i] = P(a[i], a[i]);
		}
	}
	ll res = 1;
	rep(i, n) {
		ll Min = max(yt[i].first, ya[i].first);
		ll Max = min(yt[i].second, ya[i].second);
		if (Min > Max) {
			puts("0");
			goto g;
		}
		res = (res*(Max - Min + 1)) % MOD;
	}
	printf("%lld\n", res);
	g:;
}

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

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

    int N, M; cin >> N >> M;
    vector<int> A(M);
    for (int i = 0; i < M; i++) cin >> A[i];
    sort(A.begin(), A.end(), greater<int>());
    vector<int> B = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    vector<int> C(M);
    for (int i = 0; i < M; i++) C[i] = B[A[i]];

    vector<int> dp(N+1, -N);
    dp[0] = 0;
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j < M; j++) {
            if (i-C[j] < 0) continue;
            dp[i] = max(dp[i], dp[i-C[j]] + 1);
        }
    }

    int i = N;
    for (int j = 0; j < M; j++) {
        while (i-C[j] >= 0 && dp[i-C[j]] == dp[i]-1) {
            cout << A[j];
            i -= C[j];
        }
    }
    cout << "\n";
}

Measured memory_bytes: 256
#n = int(input())
#a, b = map(int,input().split())
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
s = input()
n = len(s)


def isrepeat(s):
    res = False
    n = len(s)
    if s[0:n//2]+s[0:n//2] == s:
        res = True
    return res


for delnum in range(1, n):
    if (n-delnum) % 2 == 0:
        if isrepeat(s[0:n-delnum]):
            ans = n-delnum
            break
print(ans)


Measured memory_bytes: 8984
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
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 (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> a(N); rep(i, 0, N) { cin >> a[i]; }
	vector<int>v(N); v[0] = a[0];
	int x(0);
	rep(i, 1, N) {
		if (v[x] < a[i])v[++x] = a[i];
		else *lower_bound(v.begin(), v.begin() + x + 1, a[i]) = a[i];
	}
	cout << x + 1 << endl;

	return 0;
}

Measured memory_bytes: 3512
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001



int N;
vector<vector<int>> E;
vector<int> path;
bool f = false;

void dfs(int on, int par){
    if(on == N-1){
        f = true;
        path.push_back(on);
        return;
    }
    for(int &to:E[on]){
        if(to==par || f) continue;
        dfs(to, on);
    }
    if(f) path.push_back(on);
    return;
}

int countX(int on, int par){
    int res = 1;
    int mid = path[(path.size()+1)/2];
    for(int &to:E[on]){
        if(to!= mid && to!=par){
            res += countX(to, on);
        }
    }
    return res;
}

int countO(int on, int par){
    int res = 1;
    int mid = path[(path.size()+1)/2 - 1];
    for(int &to:E[on]){
        if(to!= mid && to!=par){
            res += countO(to, on);
        }
    }
    return res;
}

int main() {
    cin >> N;
    E.resize(N);
    for(int i=0; i<N-1; i++){
        int a, b; cin >> a >> b;
        a--;
        b--;
        E[a].push_back(b);
        E[b].push_back(a);
    }
    
    dfs(0, -1);
    reverse(path.begin(), path.end());
    
    int X = max(countX(0, -1) - 1, 0);
    int O = max(countO(N-1, -1) - 1, 0);

    if(X > O) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
    
    return 0;
}


Measured memory_bytes: 11004
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);
            int K = int.Parse(s[2]);

            for (int i = Math.Min(A, B); i > 0; i--)
            {
                if (A % i == 0 && B % i == 0)
                {
                    K--;
                    if (K == 0)
                    {
                        Console.WriteLine(i);
                        return;
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 11092
//                                  _                 ______   ______   ______   ______
//                                 | |               |  __  | |  __  | |  __  | |____  |
//    __ _   ____    _____    _  _ | |____           | |__| | | |__| | | |__| |      | |
//  / _` | |  __| /  __  |  / _` | |  __  |          |____  | |____  | |____  |      | |
// | (_| | | |    | |  | | | (_| | | |__| |  ______   ____| |  ____| |  ____| |      | |
//  \__,_| |_|    |_|  |_|  \__,_| |______| |______| |______| |______| |______|      |_|

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

#define ll long long
#define endl '\n'
#define REP(i, n) for(int i=0; i<n; i++)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9+7;

void FAST(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int main(){
  FAST();

 int k;
 cin>>k;

 int ans = 0;
 for(int a = 1; a <= k; a++){
    for(int b = 1; b <= k; b++){
        for(int c = 1; c <= k; c++){
            ans += __gcd(a, __gcd(b ,c));
        }
    }
 }

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


Measured memory_bytes: 3692
import java.util.*;
import static java.lang.System.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int[] a = new int[3];
		for (int i=0; i<3; i++) a[i] = sc.nextInt();
		int[] b = new int[2];
		for (int i=0; i<2; i++) b[i] = sc.nextInt();
		Arrays.sort(a);
		Arrays.sort(b);
		out.println(a[0]+b[0]-50);
	}
}


Measured memory_bytes: 26192
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define endl        "\n"
#define P           pair<int, int>
#define dint        long double

const int mod = 998244353;
 
inline int add(int a, int b) { int res = a + b; if(res >= mod) res -= mod;  return res; }
inline int sub(int a, int b) { int res = a - b; if(res < 0) res += mod; return res;}
inline int mul(int a, int b) { return (a * b)%mod; }
 
int modpow(int a, int b) {
    if(a == 0 || a == 1 || b == 1) return a;
    int ans = 1;
    while(b) {
        if(b%2) ans = mul(ans, a);    
        b /= 2; a = mul(a, a);
    }   return ans;
}

struct qu {
    int a, b, c, d;
} v[55];

int n, m, q;
int Mx = 0;

void rec(vector<int> &cur, int val, int pos) {
    if(pos == n) {
        int ans = 0;
        for(int i=0; i<q; i++) {
            int p1 = v[i].a, p2 = v[i].b;
            if(cur[p2] - cur[p1] == v[i].c) {
                ans += v[i].d;
            }
        }
        Mx = max(Mx, ans);
        return;
    }
    /*if(val == m) {
        vector<int> ncur;
        for(int x : cur) ncur.push_back(x);
        while(ncur.size() != n) ncur.pus
    }*/
    for(int i=val; i<=m; i++) {
        cur.push_back(i);
        rec(cur, i, pos+1);
        cur.pop_back();
    }
}

void solve() {
    cin >> n >> m >> q;
    for(int i=0; i<q; i++) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        --a, --b;
        v[i] = {a, b, c, d};
    }
    vector<int> cur;
    for(int st=1; st<=m; st++) {
        cur.push_back(st);
        rec(cur, st, 1);
        cur.pop_back();
    }
    cout << Mx << endl;
}

signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(12);

    int T = 1;
    //cin >> T;
    for(int i=1; i<=T; i++) {
        solve();
    }
    return 0;

}



Measured memory_bytes: 3656
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();

        var m = s.Length / 2;
        for (int i = m; i < s.Length; ++i)
        {
            int j = m - (i - m);
            if (s[i] != s[j])
            {
                Console.WriteLine("No");
                return;
            }
        }
        for (int i = 0; i < m / 2; ++i)
        {
            int j = i + m + 1;
            if (s[i] != s[j])
            {
                Console.WriteLine("No");
                return;
            }
        }
        Console.WriteLine("Yes");
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;

long long bigmod(long long b,long long p,long long m){
    if(p==0)return 1%m;
    long long x=bigmod(b,p/2,m);
    x=(x*x)%m;
    if(p%2==1)x=(x*b)%m;
    return x;
}

ll ncr(ll n,ll r){
    r= r>n-r?n-r:r;

    ll ans=1ll;

    for(ll i=1;i<=r;i++){
        ans = (ans*(n-r+i))%M;;
        ans=(ans * bigmod(i,M-2,M))%M;
    }
    return ans;
}


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

    int t=1,te=0;
    // cin>>t;

     
    while(t--){
        ll n,a,b;
        cin>>n>>a>>b;

        ll res= bigmod(2,n,M);
        res =(res-1+M)%M;
        res =(res-ncr(n,a)+M)%M;
        res = (res-ncr(n,b)+M)%M;

        printf("%lld\n", res);


        //printf("Case %d: ",++te);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int total=0;
	for (int i=0; i<n; i++){
		int l,r;
		cin >> l >> r;
		total+=(r-l)+1;
	}
	printf("%d\n",total);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
template<class Key, class Compare = less<Key>>
using Tree = tree<Key, null_type, Compare, rb_tree_tag, tree_order_statistics_node_update>;







void Main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n), d(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
    d[i] = i;
  }
  sort(d.begin(), d.end(), [&](int i, int j) {
    return a[i] + b[i] < a[j] + b[j];
  });
  ll ans = 0;
  int t = 1;
  for (int i = n-1; i >= 0; --i) {
    if (t) {
      ans += a[d[i]];
    } else {
      ans -= b[d[i]];
    }
    t = !t;
  }
  cout << ans << '\n';
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  #ifdef _DEBUG
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  #endif
  Main();
  return 0;
}


Measured memory_bytes: 1408
import java.util.*;
public class Main {
	public static void main(String[] args){
      
		Scanner sc = new Scanner(System.in);
      
        double w = sc.nextInt();
        double h = sc.nextInt();
        double x = sc.nextInt();
        double y = sc.nextInt();
        double ans = w*h/2;      
        if(x==w/2&&y==h/2){
           System.out.println(ans + " 1");        
        }else{
           System.out.println(ans + " 0");
        }
    }
}

Measured memory_bytes: 22868
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>

using namespace std;

typedef long long int int64;

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

#define MOD 1000000007

int main(int argc, char **argv)
{
    int H, W;
    cin >> H >> W;

    char grid[H][W];
    REP(i, H) REP(j, W) cin >> grid[i][j];

    int64 dp[H][W];
    dp[0][0] = 1;
    // row = 0
    for (int i = 1; i < W; ++i) {
        if (grid[0][i] == '#') dp[0][i] = 0;
        else dp[0][i] = dp[0][i - 1];
    }
    // column = 0
    for (int i = 1; i < H; ++i) {
        if (grid[i][0] == '#') dp[i][0] = 0;
        else dp[i][0] = dp[i - 1][0];
    }
    // other
    for (int i = 1; i < H; ++i) {
        for (int j = 1; j < W; ++j) {
            if (grid[i][j] == '#') dp[i][j] = 0;
            else dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
        }
    }
    cout << dp[H - 1][W - 1] << endl;

    return 0;
}


Measured memory_bytes: 9088
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:Chars
    }

    let mut i = 0;
    let mut ans = 0;
    let mut tmp = 0;
    loop {
        if i >= 3 {
            break;
        }
        tmp = 0;
        if n[i] == 'R' {
            tmp += 1;
            while i + 1 < 3 && n[i + 1] == 'R' {
                tmp += 1;
                i += 1;
            }
            ans = max(ans, tmp);
        }
        i += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2172
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author test
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc187_b solver = new abc187_b();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc187_b {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long aa = in.nextLong();
            long bb = in.nextLong();
            long cc = in.nextLong();
            long dd = in.nextLong();
            long max = -1999999999;

            out.println(Math.max(aa * cc, Math.max(aa * dd, Math.max(bb * cc, dd * bb))));
        /*
        max = Math.max(max,aa*cc);
        max = Math.max(max,aa*dd);
        max = Math.max(max,bb*cc);
        max = Math.max(max,bb*dd);

        out.println(max);


         */
        /*
        int X = Math.max(aa,bb);
        int Y = Math.max(cc,dd);

         */


        /*
        long X = aa<bb?bb:aa;
        long Y = cc<dd?dd:cc;

        if (bb<0 && dd<0){
            out.println(aa * dd);
            return;
        } else if (cc>0 && dd<0) {
            out.println(aa*dd);
            return;

        }
        out.println(X*Y);

         */
/*
        if ((X <0) && (Y>=0))
        {

        }

        if (X<Y) {
            if (X<0) {
                Y = cc;
            }
        } else if (X>Y) {
            if (Y<0) {
                X = aa;
            }
        }
        out.println(X*Y);
         */
        }

    }
}



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

using vi=vector<int>;
using vvi=vector<vector<int>>;

int main(){
  double a,b,x,y;cin>>a>>b>>x>>y;
  cout<<a*b/2<<" ";
  if(a==x*2&&b==y*2)cout<<1<<endl;
  else cout<<0<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;

int main(){
  int n,m; cin >> n >> m;
  priority_queue<P> q;
  for(int i = 0; i < n; i++){
    int a; cin >> a;
    q.push(P(a,1));
  }

  for(int i = 0; i < m; i++){
    int b,c; cin >> b >> c;
    q.push(P(c,b));
  }
  ll ans = 0;
  for(int i = 0; i < n; i++){
    P p = q.top(); q.pop();
    ans += p.first;
    p.second--;
    if(p.second != 0) q.push(p);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2548
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

char S[1300020];
char S2[200000];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);

	fread(S, 1, 1300020, stdin);

	int L = -1;
	int R = 99999;
	while (L + 1 < R) {
		int H = (L + R) / 2;
		if (S[H] >= 'a' && S[H + 1] >= 'a') L = H;
		else R = H;
	}
	int N = R + 1;
	char* ci = S + N + 1;
	char ct;
	int Q = 0;
	while ((ct = *ci++) >= '0') Q = Q * 10 + ct - '0';

	char* tmp = ci + Q * 6 - 2;
	while (*tmp < '0') tmp -= 4;
	int nagasa = tmp - ci + 2;
	nagasa -= Q * 2;
	int kazu = nagasa / 4;
	bool dotti = (Q - kazu) % 2;

	ci += 4;
	
	if (dotti) {
		char* smae = S2, * sato = S2 + kazu;
		bool gyaku = 0;
		rep(i, Q) {
			char c = *ci;
			if (c < 'a') {
				ci += 2;
				gyaku = !gyaku;
			}
			else {
				bool f = *(ci - 2) - '1';
				if (f ^ gyaku)* --sato = c;
				else *smae++ = c;
				ci += 6;
			}
		}
		reverse(S, S + N);
		fwrite(sato, 1, kazu - (sato - S2), stdout);
		fwrite(S, 1, N, stdout);
		fwrite(S2, 1, smae - S2, stdout);
	}
	else {
		char* smae = S2 + kazu, * sato = S2;
		bool gyaku = 0;
		rep(i, Q) {
			char c = *ci;
			if (c < 'a') {
				ci += 2;
				gyaku = !gyaku;
			}
			else {
				bool f = *(ci - 2) - '1';
				if (f ^ gyaku)* sato++ = c;
				else *--smae = c;
				ci += 6;
			}
		}
		fwrite(smae, 1, kazu - (smae - S2), stdout);
		fwrite(S, 1, N, stdout);
		fwrite(S2, 1, sato - S2, stdout);
	}


	Would you please return 0;
}

Measured memory_bytes: 1920
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
div=7+10**9
ans=1
t=0
i,j=0,N-1

if A[-1]<0 and K%2==1:
    for i1 in range(N-K,N):
        ans*=A[i1]
        ans%=div
else:
    while t<K-1:
        if A[i]*A[i+1]>A[j]*A[j-1]:
            ans*=A[i]*A[i+1]
            ans%=div
            i+=2
            t+=2
        else:
            ans*=A[j]
            ans%=div
            j+=-1
            t+=1
    if t==K-1:
        ans*=A[j]
        ans%=div

print(ans)

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int N, M, n;
	cin >> N >> M;
	REP(i, 0, M){
		cin >> n;
		N -= n;
		if(N < 0){
			N = -1;
			break;
		}
	}
	cout << N;

}


Measured memory_bytes: 3624
def gcd(x,y):
    while y>0:
        x,y = y,x%y
    return x

N = int(input())
A = sorted(list(map(int,input().split())))
amin = A[0]
ind = 0
for i in range(1,N):
    a = gcd(amin,A[i])
    if a<amin:
        ind = i
        amin = a
a0 = A[1]
for i in range(2,N):
    a0 = gcd(a0,A[i])
a1 = A[0]
for i in range(2,N):
    a1 = gcd(a1,A[i])
a = A[0]
for i in range(1,N):
    if i != ind:
        a = gcd(a,A[i])
print(max(a0,a1,a))

Measured memory_bytes: 63984
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i = 0, j, ans = 0;
	string s;
	cin >> num >> s;
	j = num - 1;
	while (true) {
		while (i < num && s[i] == 'R')
			i++;
		while (0 <= j && s[j] == 'W')
			j--;
		if (i >= j)
			break;
		i++;
		j--;
		ans++;
	}
	cout << ans << "\n";
	return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const int MN = 100010;

int n;
int sz[MN];
vi g[MN], g2[MN];
bool f[MN], vis[MN];

void ng()
{
	puts("-1");
	exit(0);
}

void show(vi vec)
{
	rep(i, vec.size()) {
		printf("%d%c", vec[i], i+1 == vec.size() ? '\n' : ' ');
	}
}

vi solve(vi deg)
{
	vi res;
	res.pb(1);
	int now = 1;

	rep(i, deg.size()) {
		int x = deg[i];
		if (i == 0) --x;
		if (i+1 == (int)deg.size()) --x;

		int nx = ++now;

		while (x) {
			res.pb(++now);
			--x;
		}
		res.pb(nx);
	}

	res.pb(++now);
	//show(res);
	return res;
}

int main() {
	cin >> n;

	rep(i, n-1) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		g[a].pb(b); g[b].pb(a);
		++sz[a]; ++sz[b];
	}

	if (n == 2) {
		puts("1 2");
		return 0;
	}

	rep(i, n) {
		for (int to : g[i]) {
			if (sz[i] >= 2 && sz[to] >= 2 && i < to) {
				g2[i].pb(to);
				g2[to].pb(i);
			}
		}
	}

	int cnt = 0;

	rep(i, n) {
		if (g2[i].size() > 2) {
			ng();
		}
		if (g2[i].size() > 0) {
			++cnt;
		}
	}
	//printf("cnt=%d\n", cnt);

	vi ans;

	rep(i, n) if (g2[i].size() == 1) {
		vi vs;
		int c = i;

		while (true) {
			bool fd = 0;
			vs.pb(c);
			vis[c] = 1;

			for (int to : g2[c]) {
				if (!vis[to]) {
					fd = 1;
					c = to;
					break;
				}
			}
			if (!fd) {
				break;
			}
		}

		if ((int)vs.size() != cnt) {
			ng();
		}

		vi vec;

		rep(i, vs.size()) {
			vec.pb((int)g[vs[i]].size() - (int)g2[vs[i]].size());
		}

		vi cand = solve(vec);
		reverse(ALL(vec));

		vi cand2 = solve(vec);
		show(min(cand, cand2));
		return 0;
	}

	rep(i, n) {
		if (sz[i] >= 2) {
			vi vec;
			vec.pb(sz[i]);
			vi t = solve(vec);
			show(t);
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 14196
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<limits>
#include<map>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define ll_INF 	9223372036854775807
#define MOD 1e+7
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
using namespace std;

ll nC2(ll n) {
	if (n < 1) {// where n = 0,-1
		return 0;
	}
	else {
		return n * (n - 1) / 2;
	}
}

int main() {
	int N;
	cin >> N;
	vll As(N, 0);
	vll Balls(N);
	vll Intact(N), Minus1(N);
	rep(i, N) {
		int x;
		cin >> x;
		Balls[i] = x;
		As[--x]++;
	}
	ll ans = 0;

	rep(i, N) {
		Intact[i] = nC2(As[i]);
		Minus1[i] = nC2(As[i] - 1);
		ans += Intact[i];
	}

	rep(i, N) {
		ll temp = 0;
		temp = ans - Intact[Balls[i]-1] + Minus1[Balls[i]-1];
		cout << temp << endl;
	}
}


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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int W, H, N;
    cin >> W >> H >> N;

    int X[W] = {0};
    int Y[H] = {0};

    for(int i = 0; i < N; ++i){
        int x, y, a;
        cin >> x >> y >> a;

        if(a == 1){

            for(int j = x - 1; j > -1; --j) X[j] += 1;
        }

        if(a == 2){

            for(int j = x; j < W; ++j) X[j] += 1;
        }

        if(a == 3){

            for(int j = y - 1; j > -1; --j) Y[j] += 1;
        }

        if(a == 4){

            for(int j = y; j < H; ++j) Y[j] += 1;
        }
    }

    int w = 0;
    int h = 0;

    for(int i = 0; i < W; ++i){

        if(X[i] == 0) ++w;
    }

    for(int i = 0; i < H; ++i){

        if(Y[i] == 0) ++h;
    }

    cout << w * h << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n, a[1000000];

int main(){
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        a[i] -= i-1;
    }
    sort(a, a+n);
    ll ans = 0;
    for (int i = 0; i < n; i++){
        ans += abs(a[i] - a[n/2]);
    }
    cout << ans;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;

ll g(ll n, ll b) {
	ll r=0;
	for(; n; n/=b) r += n%b;
	return r;
}

ll f(ll n, ll s) {
	ll i;
	if(n==s) return n+1;
	if(n<s) return -1;
	for(i=2; i*i<=n; i++) if(g(n,i)==s) return i;
	n -= s;
	for(; i>0; i--) if(n%i==0 && g(n+s, n/i+1)==s) return n/i+1;
	return -1;
}

int main() {
	ll n, s;
	cin>>n>>s;
	cout<<f(n,s);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define speed                   \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define oprecision    \
  cout.precision(30); \
  cerr.precision(7);
#define ll long long
#define ld long double
#define ss string
#define pii pair<int, int>
#define pll pair<ll, ll>
#define forn(n) for (int i = 1; i <= n; i++)
#define forlr(l, r) \
  for (int i = l; (l > r ? i >= r : i <= r); (l > r ? i-- : i++))
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pb(x) push_back(x)
#define pc(x) __builtin_popcount(x)
#define pcll(x) __builtin_popcountll(x)
#define mp(x, y) make_pair(x, y)
#define F first
#define S second
using namespace std;
ll n, a[500005], ans;
int main() {
  speed;
  oprecision;
  // code
  cin >> n;
  forn(n) {
    cin >> a[i];
    if (a[i] < a[i - 1]) ans += a[i - 1] - a[i];
    a[i] = max(a[i], a[i - 1]);
  }
  cout << ans;
  // endl
#ifndef ONLINE_JUDGE
  cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 5220
#include "bits/stdc++.h"

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };

using namespace std;

typedef complex<double> Comp;
void koch(Comp left, Comp right, vector<Comp> &v, int i,int n) {
	if (i == n) return;
	double r = sqrt(((conj(right - left)*(right - left)).real()))/3;
	Comp nextr = (left + Comp(2) * right) / Comp(3),
		nextl = (Comp(2)*left + right) / Comp(3),
		next;
	if (nextl.imag() == nextr.imag()) {
		if (nextl.real() < nextr.real())next = { nextl.real() + r * 1 / 2 ,nextl .imag() + r*sqrt(3) / 2 };
		else next = { nextr.real() + r * 1 / 2,nextr.imag()-r*sqrt(3)/2 };
	}
	else if (nextl.real() < nextr.real()) {
		if(nextl.imag() < nextr.imag())	next = { nextr.real() - r,nextr.imag() };
		else next = { nextl.real() + r,nextl.imag() };
	}
	else {
		if (nextl.imag() < nextr.imag()) next = { nextl.real() - r,nextl.imag() };
		else next = { nextr.real() + r,nextr.imag() };
	}
	auto p = find(ALL(v),left);
	v.insert(p + 1, nextl);
	p = find(ALL(v), left);
	v.insert(p + 2, next);
	p = find(ALL(v), left);
	v.insert(p + 3, nextr);
	koch(left, nextl, v, i + 1, n);
	koch(nextl, next, v, i + 1, n);
	koch(next, nextr, v, i + 1, n);
	koch(nextr, right, v, i + 1, n);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<Comp> v;
	v.push_back({ 0,0 });
	v.push_back({ 100,0 });
	koch({ 0,0 }, { 100,0 }, v, 0, n);
	REP(i, v.size()) {
		cout <<fixed<<setprecision(10)<< v[i].real() << " " << v[i].imag() << endl;
	}
	return 0;
}

Measured memory_bytes: 3356
x, n = map(int, input().split())
p = []
p = list(map(int, input().split()))
i = 0
j = 0
ans = 0
check = 0
if(n == 0):
    check = 1
    print(x)
for i in range(200):
    X = x + ((-1) ** (i)) * int((i + 1) / 2)
    for j in range(n):
        if(X == p[j]):
            ans = 1
            break
        ans = 0
    if(ans == 0) and (check == 0):
        print(X)
        break

Measured memory_bytes: 9220
#include<iostream>
#include<cstdio>
const int N=1e5+5;
int vis[N]={},n;
char s[20];
void dfs(int l,int r) {
    int mid=(l+r)>>1;
    printf("%d\n",mid);
    fflush(stdout);
    scanf("%s",s);
    if(s[0]=='V') return;
    else if(s[0]=='F') vis[mid]=1;
    else vis[mid]=0;
    int v=(mid-l)&1;
    if(vis[mid]!=vis[l]^v) dfs(l,mid);
    else dfs(mid,r);
}
int main() {
    scanf("%d",&n);
    printf("%d\n",0);fflush(stdout);
    scanf("%s",s);
    if(s[0]=='V') return 0;
    else if(s[0]=='F') vis[0]=1;
    else vis[0]=0;
    printf("%d\n",n-1);fflush(stdout);
    scanf("%s",s);
    if(s[0]=='V') return 0;
    else if(s[0]=='F') vis[n-1]=1;
    else vis[n-1]=0;
    dfs(0,n-1);
    return 0;
}


Measured memory_bytes: 852
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class A_169_Multiplication_1
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var A = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            long result = A[0] * A[1];

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28124
#include <bits/stdc++.h>
#define int long long
#define gcd            __gcd
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x,y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int power(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int modi(int a, int m)
{
    return power(a, m - 2, m);
}
int32_t main()
{
    nitin;
    int n;
    cin>>n;
    int sum=0;
    int temp=n;
    while(temp)
    {
        sum+=temp%10;
        temp=temp/10;
    }
    if(n%sum==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3604
import java.util.*;
public class Main {
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int []z = new int[3];
	int A = sc.nextInt();
	int B = sc.nextInt();
	z[0]=A+B;z[1]=A-B;z[2]=A*B;
	int max = z[0];
	for(int i=1;i<3;i++) {
    if(max<z[i]){
    	max = z[i];
    }		
	}
	System.out.println(max);	
	}
}

Measured memory_bytes: 23252
#include <cstdio>
#include <string> 
#include <string.h>
using namespace std;

int main(void)
{
	char	S[1000] = {0};
	char    ans[1000] = {0};
	int		w, i, cnt;

	scanf( "%s", S );
	scanf( "%d", &w );

	
	for( cnt = i = 0; i < strlen(S); i+=w, cnt++ ){
		ans[cnt] = S[i];
	}

	printf( "%s", ans );
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(int argc, char const *argv[])
{
    int a,b,c,temp;
    scanf("%d %d %d",&a,&b,&c);
    if(b<a){
        temp=b;b=a;a=temp;
    }
    printf("%s\n",(a<c&&c<b)?"Yes":"No");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
stack<int>st;
queue<int>q;
vector<long long int >v;
set<long long int>stt;
set<long long int>::iterator set_it;
map<long long int,long long int>mp;
//initialy map er all index er value zero thake;
//map er jonno this pointer(->) use korte hoy
//akta value dakhar jonno staristics pointer(*) use  korte hoy
// one more value print korar jonno this pointer(->) use korte hoy (must be)
map<string,int>::iterator map_it;
long long int a[20007];
long long int i,j,k,l,m,n,flag=0,cnt=0,sum=0,mx=0,mn=0;
string s1,s2;
int main()
{
    long long  int tc,a,b,d,e,s,w;
    //char c;



        cin>>s>>w;
        if(s<=w)
        {
            cout<<"unsafe"<<endl;
        }
        else
        {
            cout<<"safe"<<endl;
        }


    return 0;

}






Measured memory_bytes: 3624
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
const int h_mv[4] = {-1, +1, 0, 0};
const int w_mv[4] = {0, 0, -1, +1};

#define INF (100000000);
int maze[22][22];


void clear_maze()
{
	for (int h = 1; h <= 20; h++) {
		for (int w = 1; w <= 20; w++) {
			if (maze[h][w]!=-1) maze[h][w]=INF;
		}
	}
}


int main(void) {
	int H, W;
	cin >> H >> W;
	for (int h = 0; h <= H+1; h++) {
		maze[h][0] = maze[h][W+1] = -1;
	}
	for (int w = 0; w <= W+1; w++) {
		maze[0][w] = maze[H+1][w] = -1;
	}
	for (int h = 1; h <= H; h++) {
		for (int w = 1; w <= W; w++) {
			char c;
			cin >> c;
			if (c=='#') {
				maze[h][w] = -1;
			} else {
				maze[h][w] = INF;
			}
		}
	}

	int ans = 0;
	// スタート地点を決める
	for (int h = 1; h <= H; h++) {
		for (int w = 1; w <= W; w++) {
			if (maze[h][w]!=-1) {
				// 計算
				clear_maze();
				maze[h][w] = 0;
				queue <pair<int, int>> pos;
				pos.push(make_pair(h, w));
				while (pos.size() > 0) {
					pair <int, int> check = pos.front();
					pos.pop();
					int th = check.first;
					int tw = check.second;
					int steps = maze[th][tw];
					for (int i = 0; i < 4; i++) {
						int nh = th+h_mv[i];
						int nw = tw+w_mv[i];
						if ((maze[nh][nw]!=-1) && (maze[nh][nw] > steps+1)) {
							maze[nh][nw] = steps+1;
							pos.push(make_pair(nh, nw));
							ans = max(ans, steps+1);
						}
					}
				}
			}
		}
	}
	cout << ans << endl;
  return 0;
}


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

int n, m, x;

int main() {
  cin >> n >> m >> x;
  int cost[n + 1] = {};
  for (int i = 0; i < m; ++i) {
    int a; cin >> a;
    cost[a] = 1;
  }
  
  int cost_to_0 = 0;
  int cost_to_n = 0;
  for (int i = 0; i <= n; ++i) {
    if (i < x) cost_to_0 += cost[i];
    else cost_to_n += cost[i];
  }
  cout << min(cost_to_0, cost_to_n) << endl;
  
  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
a = []
for i in range(N):
    listed_a = list(map(int, input().split()))
    listed_a.pop(0)
    a.append(set(listed_a))


seki = a[0]
for i in range(N-1):
    seki = seki & a[i+1]
    
print(len(seki))


Measured memory_bytes: 3060
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

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

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      x: i64,
      aa: [i64; n],
    }
    let mut aa = aa;
    let mut ans = 0;
    for i in 0..n-1 {
        let mut a = aa[i];
        let mut b = aa[i+1];
        if a + b > x {
            b = b - ((a + b) - x);
            b = max(0, b);
        }
        if b == 0 && a > x {
            a = x;
        }

        // debug!(x, aa[i], aa[i+1], a, b);

        ans += aa[i] - a;
        ans += aa[i+1] - b;
        aa[i] = a;
        aa[i+1] = b;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()
template <int MOD>
class ModInt {
  long long x;

 public:
  ModInt(long long v = 0) : x(v % MOD) {
    if (x < 0) x += MOD;
  }

  ModInt& operator+=(const ModInt& r) {
    x += r.x;
    if (x >= MOD) x -= MOD;
    return *this;
  }

  ModInt& operator-=(const ModInt& r) {
    x -= r.x;
    if (x < 0) x += MOD;
    return *this;
  }
  ModInt& operator*=(const ModInt& r) {
    x = (x * r.x) % MOD;
    return *this;
  }
  ModInt& operator/=(const ModInt& r) {
    *this *= r.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt& r) const { return ModInt(*this) += r; }
  ModInt operator-(const ModInt& r) const { return ModInt(*this) -= r; }
  ModInt operator*(const ModInt& r) const { return ModInt(*this) *= r; }
  ModInt operator/(const ModInt& r) const { return ModInt(*this) /= r; }
  bool operator==(const ModInt& r) const { return x == r.x; }
  bool operator!=(const ModInt& r) const { return x != r.x; }

  ModInt inverse() const {
    long long a = x, b = MOD, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt<MOD> pow(long long n) const {
    ModInt ret(1), mul(x);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream& operator<<(ostream& os, const ModInt& x) { return os << x.x; }

  friend istream& operator>>(istream& is, ModInt& x) { return is >> x.x; }

  int getMod() { return MOD; }
};

using mint = ModInt<1000000007>;

string K;
int D;

int main() {
  cin >> K >> D;
  int N = K.size();

  vector<vector<vector<mint>>> dp(N + 1,
                                  vector<vector<mint>>(D, vector<mint>(2, 0)));
  dp[0][0][1] = 1;

  rep(i, N) {
    int m = K[i] - '0';
    rep(j, D) {
      dp[i + 1][j][1] = dp[i][(j - m + 10 * D) % D][1];
      rep(l, 10) {
        dp[i + 1][j][0] += dp[i][(j - l + 10 * D) % D][0];
        if (l < m) dp[i + 1][j][0] += dp[i][(j - l + 10 * D) % D][1];
      }
    }
  }

  cout << dp[N][0][0] + dp[N][0][1] - 1 << endl;

  return 0;
}


Measured memory_bytes: 55296
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    int n,k; cin >> n >> k;
    int t = 1;
    rep(i,n) t = t * 2;
    if(k >= t){cout << -1 << endl; return 0;}
    else if(n==1&&k==1){cout << -1 << endl; return 0;}
    vector<int> v(t);
    int xo = 0;
    if(k==0){
        for(int i=0;i<t;i++) cout << i << " " << i << " ";
    }
    else {
        cout << 0 << " ";
        cout << k << " ";
        cout << 0 << " ";
        for(int i=1;i<t;i++){
            if(i!=k){
                cout << i << " ";
                xo ^= i;
            }
            
        }
        cout << k << " ";
        for(int i=t-1;i>=1;i--){
            if(i!=k) cout << i << " ";
        }
    }
    cout << endl;
    //cout << xo << endl;
    return 0;   
}

Measured memory_bytes: 2304
abk=input().rstrip().split(" ")
a=int(abk[0])
b=int(abk[1])
k=int(abk[2])
if k<=a:
    takahashi=a-k
    aoki=b
elif k>a and k<=b+a:
    takahashi=0
    aoki=a+b-k
elif k>a+b:
    aoki=0
    takahashi=0
print(takahashi, end=" ")
print(aoki)

Measured memory_bytes: 3064
function main(input){
  input = input.split('\n');
  var N = input[0];
  var H = input[1].split(' ').map(parseFloat);
  var curNum = 0;
  var result = 0;
  var count = 0;
  
  for(var i = 0;i < N - 1;){
    curNum = H[i];
    count = 0;

    loop:for(var j = 1;i + j < N;j++){
      if(curNum >= H[i + j]){
        count++;
        curNum = H[i + j];
        if(i + j === N - 1){
          i += j;
        }
      }else{
        i += j;
        break loop;
      }
    }
    if(result < count){
      result = count;
    }
  }
  console.log(result);
}
main(require('fs').readFileSync('/dev/stdin','utf8'));

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

main(){
  int tcase; cin >> tcase;
  int s, t;
  
  for ( int i = 0; i < tcase; i++ ){
    cin >> s >> t;
    vector<int> v;
    if ( s < t ){
      for ( int i = s; i <= t; i++ ) v.push_back(i);
    } else if ( s > t ){
      if ( s <= 5 ){
	for ( int i = s; i >= t; i-- ) v.push_back(i);
      } else if ( s >= 6 ){
	for ( int i = s; i <= 9; i++ ) v.push_back(i);
	if ( t <= 5 ){
	  for ( int i = 5; i >= t; i-- ) v.push_back(i);
	} else if ( t >= 6 ){
	  for ( int i = 5; i >= 0; i-- ) v.push_back(i);
	  for ( int i = 1; i <= t; i++ ) v.push_back(i);
	}
      }
    }
    for ( int i = 0; i < v.size(); i++ ){
      if ( i ) cout << " ";
      cout << v[i];
    }
    cout << endl;
  }
}

Measured memory_bytes: 0