akhauriyash/Code-Regression huggingface dataset:
import math
N,M = map(int,input().split())
if N < 2:
    ans1 = 0
else:
    ans1 = math.factorial(N)//((math.factorial(N-2))*2)
if M < 2:
    ans2 = 0
else:
    ans2 = math.factorial(M)//((math.factorial(M-2))*2)
print(ans1+ans2)

Measured memory_bytes: 38384
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;

#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


int main() {
    int N , Z , W;
    cin >> N >> Z >> W;
    vector<int> a(N);
    REP(i,0,N) cin >> a[i];
    if(N > 2) {
        cout << max(abs(W - a[N - 1]), abs(a[N - 1] - a[N - 2])) << endl;
    }
    if(N == 1){
//        cout << max(abs(Z - a[0]),abs(W - a[0])) << endl;
        cout << abs(W - a[0]) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

fun main(args: Array<String>) {
  val cin = Scanner(System.`in`)
  var ct = 1

  for (i in 0..4) {
    val a = cin.nextInt()
    if (a == 0) {
      println(ct)
    }
    ct++
  }


  cin.close()
}

Measured memory_bytes: 36368
use std::collections::HashSet;

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

fn main() {
    let n = scan!(usize);
    let mut routes = vec![];
    if n % 2 == 0 {
        for i in 1..n + 1 {
            for j in 1..n + 1 {
                if i != j && j != n - i + 1 {
                    if i < j {
                        routes.push((i, j));
                    } else {
                        routes.push((j, i));
                    }
                }
            }
        }
    } else {
        for i in 1..n + 1 {
            for j in 1..n + 1 {
                if i != j && j != n - i {
                    if i < j {
                        routes.push((i, j));
                    } else {
                        routes.push((j, i));
                    }
                }
            }
        }
    }

    let uniq: HashSet<(usize, usize)> = routes.into_iter().collect();
    println!("{}", uniq.len());
    for u in uniq {
        println!("{} {}", u.0, u.1);
    }
}


Measured memory_bytes: 4352
n=input()
L=len(n)
N=int(n)
if L==1:
    print(N)
elif L==2:
    print(9)
elif L==3:
    print(9+N-100+1)
elif L==4:
    print(9+900)
elif L==5:
    print(9+900+N-10000+1)
else:
    print(9+900+90000)

Measured memory_bytes: 3060
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int m = max({a, b, c});
    if (m == a + b + c - m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;

void add(int &a, int b) {
    a += b;
    while(a >= MOD)
        a -= MOD;
    while(a < 0)
        a += MOD;
}

int main() {
    int n, k; cin >> n >> k;
    vector<int> a(n, 0);

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

    vector<vector<int>> dp(n + 1, vector<int> (k + 1, 0));
    vector<vector<int>> part(n + 1, vector<int> (k + 1, 0));
    
    auto getSum = [&] (int lf, int rt, auto& part) {
        int ans = part[rt];
        if (lf >= 1)
            add(ans, - part[lf - 1]);
        return ans;
    };

    for (int kid = 0; kid <= n; kid += 1) {
        dp[kid][0] = 1;
        part[kid][0] = 1;
        
        if (kid == 0) {
            part[kid] = vector<int> (k + 1, 1);
            continue;
        }

        for (int sum = 1; sum <= k; sum += 1) {
            int lf = max(0, sum - a[kid - 1]);
            int rt = sum;

            dp[kid][sum] = getSum(lf, rt, part[kid - 1]);
            part[kid][sum] = dp[kid][sum];
            add(part[kid][sum], part[kid][sum - 1]);
        }
    }

    int ans = dp[n][k];

    cout << ans << "\n";
}

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

int main () {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int count = 0;
  for (int i = 0; i <= A; i++) {
    for (int j = 0; j <= B; j++) {
      for (int k = 0; k <= C; k++) {
        int res;
        res = 500 * i + 100 * j + 50 * k;
        if (res == X) count++;
      }
    }
  }

  cout << count << endl;
}

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

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N; 
  cin >> N;

  vector<int> A(N);
  REP(i, N) cin >> A[i];
  sort(ALL(A));

  int ans = 1;
  REP(i, N){
    if(__builtin_mul_overflow(ans, A[i], &ans)){
      cout << -1 << "\n";
      return 0;
    }
  }

  if(ans > 1000000000000000000) cout << -1 << "\n";
  else cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 3976
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio (false) ;cin.tie(NULL);
#define tc  int t;cin>>t;for(int i=0;i<t;i++)
#define ll long long int
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define um(a,b) unordered_map<a,b>
#define vv(a) vector<a>
#define pp(a,b) pair<a,b>
ll power(ll a,ll b,ll mod){  ll ans=1;  while(b>0){
  if(b&1){ ans=(ans*a)%mod;} a=(a*a)%mod;  b=b/2; } return ans;}

int main(){
FIO
 string s,t;
 cin>>s>>t;
 int n=s.length();
 int m=t.length();
 int ans=INT_MAX;
 for(int i=0;i<=n-m;i++){
        int k=i;
    int count=0;
    for(int j=0;j<m;j++){
        if(s[k]!=t[j])
            count++;
        k++;
    }
    ans=min(ans,count);
 }
 cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 50


int main(){

	ll K;
	scanf("%lld",&K);


	ll table[SIZE];

	for(ll i = 0; i < SIZE; i++){

		table[i] = i+(K/50);
	}


	ll count = 50*(K/50);

	ll rest = K-count;

	for(ll loop = 0; loop < rest; loop++){

		table[loop] += 50;
		for(ll i = 0; i < SIZE; i++){
			if(i == loop)continue;

			table[i]--;
		}
	}

	printf("50\n");
	printf("%lld",table[0]);

	for(int i = 1; i < SIZE; i++){

		printf(" %lld",table[i]);
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 3828
n = gets.to_i
ary = gets.split.map(&:to_i)
state = 0  #1 -> 増加関数, 0 -> 開始直後, -1 -> 減少関数
num = ary.first
count = 1
for i in 1 .. n-1
	if state == 0
		if ary[i] > num
			state = 1
		elsif ary[i] < num
			state = -1
		end
	elsif state == 1
		if ary[i] < num
			state = 0
			count += 1
		end
	else #state == -1
		if ary[i] > num
			state = 0
			count += 1
		end
	end
	num = ary[i]
end

puts count

Measured memory_bytes: 8452
import sys
def I(): return int(sys.stdin.readline().rstrip())


N = I()
A = [0] + [I() for _ in range(N)]
s = sum(A)
mod = 998244353

dp1 = [[0]*(s+1) for _ in range(N+1)]  # dp[i][j] = a1~aiを塗った時に、赤で塗った和をjにする方法数
dp1[0][0] = 1
for i in range(1,N+1):
    a = A[i]
    for j in range(s+1):
        if j >= a:
            dp1[i][j] = dp1[i-1][j]*2 + dp1[i-1][j-a]
        else:
            dp1[i][j] = dp1[i-1][j]*2
        dp1[i][j] %= mod

dp2 = [[0]*(s//2+1) for _ in range(N+1)]  # dp[i][j] = a1~aiの中からいくつか選んで、和をjにする方法数
dp2[0][0] = 1
for i in range(1,N+1):
    a = A[i]
    for j in range(s//2+1):
        if j >= a:
            dp2[i][j] = dp2[i-1][j] + dp2[i-1][j-a]
        else:
            dp2[i][j] = dp2[i-1][j]
        dp2[i][j] %= mod

a = sum(dp1[N][i] for i in range((s+1)//2,s+1))
a %= mod
if s % 2 == 0:
    a -= dp2[N][s//2]

ans = pow(3,N,mod)-a*3
ans %= mod
print(ans)


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


int main(){
  int a,b;
  cin>>a>>b;
  if(a>9||b>9){
    cout<<-1<<endl;
  }
  else{
    cout<<a*b<<endl;
  }

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
char s[100];
int len,vis[100],p[100];
int main() {
    scanf("%s",s);
    len=strlen(s);
    for (int i=0;i<len;i++)
	vis[s[i]-97]=1;
    if (len<26) {
	int k=0;
	while (vis[k]) k++;
	printf("%s",s);
	putchar(k+97);
	putchar('\n');
	return 0;
    }
    for (int i=1;i<=len;i++) p[i]=s[i-1]-96;
    if (next_permutation(p+1,p+len+1)) {
	for (int i=1;i<=len;i++) {
	    putchar(p[i]+96);	    
	    if (p[i]+96>s[i-1]) break;
	}
	putchar('\n');
    }
    else printf("-1\n");
    return 0;
}


Measured memory_bytes: 256
n = int(input())
al =  list(map(int, input().split()))

new_al = []
for i,a in enumerate(al):
    new_al.append(a-i-1)

new_al.sort()
if n%2 == 0:
    med = (new_al[n//2] + new_al[n//2-1])/2
else:
    med = new_al[n//2]

ans = 0
for a in new_al:
    ans += abs(a-med)

print(int(ans))

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

DIVIDER = 998244353
bit_pow = []
tmp = DIVIDER - 2
while tmp > 0:
    bit_pow.append(tmp % 2)
    tmp >>= 1
N_pow = len(bit_pow)

def myinv(arg):
    global DIVIDER
    ret = 1
    arg_pow = arg
    for i in range(N_pow):
        if bit_pow[i] > 0:
            # print("###", i, arg_pow)
            ret = (ret * arg_pow) % DIVIDER
        arg_pow = (arg_pow * arg_pow) % DIVIDER
    #
    # print("##", arg, '->', ret)
    return ret

def mydiv(a, b):
    b_inv = myinv(b)
    # print("##", a, (b, b_inv))
    ret = (a * b_inv) % DIVIDER
    return ret

tab_comb = [1]
tmp = 1
for i in range(N - 1):
    tmp = (tmp * (N - 1 - i)) % DIVIDER
    tmp = mydiv(tmp, (i + 1))
    tab_comb.append(tmp)
# print("#", tab_comb)

tab_Mpow = [1]
tmp = 1
for i in range(N - 1):
    tmp = (tmp * (M - 1)) % DIVIDER
    tab_Mpow.append(tmp)
# print("#", tab_Mpow)

ans = 0
for i in range(K + 1):
    ans_tmp = M
    ans_tmp = (ans_tmp * tab_comb[i]) % DIVIDER
    ans_tmp = (ans_tmp * tab_Mpow[N - 1 - i]) % DIVIDER
    # print("#", i, ans_tmp)
    ans = (ans + ans_tmp) % DIVIDER

print(ans)

Measured memory_bytes: 24740
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>

using namespace std;

int main() {
  string s;
  cin >> s;
  
  if(s[0] == s[1]) cout << "Bad" << endl;
  else if(s[1] == s[2]) cout << "Bad" << endl;
  else if(s[2] == s[3]) cout << "Bad" << endl;
  else cout << "Good" << endl;
  
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
    IOS();
    string s;
    cin >> s;
    if (s.back() == 's') s += "es";
    else s+='s';
    cout << s << endl;
}


Measured memory_bytes: 3660
#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h> 
 
using namespace std;
 
#define len(x) (int)((x).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define vi vector<int> 
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<int, int>
#define beg begin
 
#ifdef LOCAL
    #define dbg(x) cerr << #x << " = " << x << endl;
#else 
    #define dbg(x)
#endif 
 
template<class T> istream& operator>>(istream &str, vector<T> &a) {
	for (auto &i : a) {
		str >> i; 
	}
	return str;
}
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);                                       
    freopen("output.txt", "w", stdout);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(10);
    solve();    
}
 
const int INF = 1e18, MAXN = 2e5 + 10, MOD = 998244353;
int n, m, ans = 0;
vector<pii> g[MAXN];
int used[MAXN];
set<int> se1, se2;

void dfs(int v, int phl) {
	used[v] = 1;
	se1.insert(v), se2.insert(phl);

	for (auto it : g[v]) {
		int u = it.x, hl = it.y;
		if (!used[u]) {
			dfs(u, hl);
		}	
	}
}

void solve() {
	cin >> n >> m;
	vi a(n);
	cin >> a;

	for (int i = 0; i < n; ++i) {
		a[i]--;
	}

	for (int i = 0; i < m; ++i) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		g[v].pb({u, a[u]});
		g[u].pb({v, a[v]});
	}

	for (int v = 0; v < n; ++v) {
		if (!used[v]) {
			se1.clear(), se2.clear();
			dfs(v, a[v]);

			for (auto it : se1) {
				if (se2.count(it)) {
					ans++;
				}
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 24064
// OURL: https://atcoder.jp/contests/abc125/tasks/abc125_b
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }

template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res;}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >>n;
  auto vs = make_v<int>(n);
  auto cs = make_v<int>(n);
  REP(i,n) {
    cin >> vs[i];
  }
  REP(i,n) {
    cin >> cs[i];
  }
  int ans = 0;
  REP(i,n) {
    if (vs[i] - cs[i] > 0) {
      ans += vs[i] - cs[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
using System;

namespace ABC126
{
	class Program
	{
		static void Main(String[] args)
		{
			// 入力
			String S = Console.ReadLine();
			// 計算
			// 文字列分割
			int top = int.Parse(S.Substring(0, 2));
			int buttom = int.Parse(S.Substring(2, 2));
			// top,buttomがそれぞれ月になれるかを調べる
			Boolean topMonth = (top >= 1 && top <= 12);
			Boolean buttomMonth = (buttom >= 1 && buttom <= 12);
			// 出力
			if (topMonth && buttomMonth)
			{
				Console.WriteLine("AMBIGUOUS");
			}
			else if (!topMonth && buttomMonth)
			{
				Console.WriteLine("YYMM");
			}
			else if (topMonth && !buttomMonth)
			{
				Console.WriteLine("MMYY");
			}
			else
			{
				Console.WriteLine("NA");
			}
		}
	}

}

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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF 1e9

struct Edge {
    int to, cost;
};

struct P {
    int town, cost;

    bool operator >(const P& p) const {
        return cost > p.cost;
    }
};

int G[21];

int main() {
    int town_n, road_n;
    cin >> town_n >> road_n;

    vector<vector<Edge>> E(town_n+1);
    REP(i, road_n) {
        int a, b, c, d;
        char delim;
        cin >> a >> delim >> b >> delim >> c >> delim >> d;
        E[a].push_back({b, c});
        E[b].push_back({a, d});
    }
    int start, goal, money, hashira;
    char delim;
    cin >> start >> delim >> goal >> delim >> money >> delim >> hashira;

    int cost1 = 0, cost2 = 0;

    fill_n((int *)G, 21, INF);
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({start, 0});
    G[start] = 0;
    while (!que.empty()) {
        P p = que.top(); que.pop();
        if (p.town == goal) {
            cost1 = p.cost;
            break;
        }
        for (Edge& e : E[p.town]) {
            int next_cost = p.cost + e.cost;
            if (G[e.to] > next_cost) {
                G[e.to] = next_cost;
                que.push({e.to, next_cost});
            }
        }
    }
    fill_n((int *)G, 21, INF);
    while (!que.empty()) que.pop();
    que.push({goal, 0});
    G[goal] = 0;
    while (!que.empty()) {
        P p = que.top(); que.pop();
        if (p.town == start) {
            cost2 = p.cost;
            break;
        }
        for (Edge& e : E[p.town]) {
            int next_cost = p.cost + e.cost;
            if (G[e.to] > next_cost) {
                G[e.to] = next_cost;
                que.push({e.to, next_cost});
            }
        }
    }
    cout << (money - hashira - cost1 - cost2) << endl;
}

Measured memory_bytes: 1216
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from math import pi,atan
    a,b,x=map(int,input().split())
    if(2*x<=a*a*b):
        # b*b/tany*1/2*a=x
        # tany=a*b*b/(2*x)
        print(atan(a*b*b/(2*x))*180/pi)
    else:
        # (b+(b-a*tany))*1/2*a*a=x
        # 2*b-a*tany=2*x/(a*a)
        # tany=(2*(b-x/(a*a)))/a
        print(atan((2*(b-x/(a*a)))/a)*180/pi)
resolve()

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

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

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

const int maxn=1e5+10;

int n;

int a[maxn];
int f[maxn];
int tot;

int main(){
	scanf("%d",&n);
	for(register int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	tot++;
	f[tot]=a[1];
	for(register int i=2;i<=n;i++){
		if(a[i]<=f[tot])
			f[++tot]=a[i];
		else{
			int l=1,r=tot,mid;
			while(l<r){
				int mid=(l+r)>>1;
				if(a[i]>f[mid])
					r=mid;
				else
					l=mid+1;
			}
			f[l]=a[i];
		}
	}
	printf("%d\n",tot);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	vector<long long> a(n), base;
	for(auto & e : a) cin >> e;
	long long all = 0;
	for(auto & e : a) all ^= e;
	for(auto & e : a) e &= ~all;
	for(auto e : a){
		for(auto b : base) e = min(e, e ^ b);
		if(e){
			base.push_back(e);
		}
	}
      sort(base.rbegin(), base.rend());
	long long up = 0;
	for(auto b : base) up = max(up, up ^ b);
	cout << all + 2 * up << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<atcoder/dsu>
using namespace std;
using namespace atcoder;
int main(){
    int n, q;
    cin >> n >> q;
    dsu d(n);
    for(int i = 0; i < q; i++){
        int s, t, u;
        cin >> s >> t >> u;
        if(s == 0)
            d.merge(t, u);
        else{
            if(d.same(t, u))
                cout << 1 << endl;
            else 
                cout << 0 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3980
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    a,b,c = map(int, input().split())
    if a%2 == 1 and b%2 == 1 and c%2 == 1:
        print(min(a*b, b*c, c*a))
    else:
        print(0)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define ld long double
#define MOD 1000000007
#define u128 __int128
#define ff first
#define ss second
#define INTMAX 1000000009
#define N 100050

ll bmexp(ll a, ll b)
{
	ll res = 1;
	while(b)
	{
		if(b & 1)
			res = res * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return res;
}

ll gcd(ll a, ll b)
{
	if(b == 0)
		return a;
	return gcd(b, a % b);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll w, h, x, y;
	cout.precision(10);
	cin >> w >> h >> x >> y;
	double ans = (double)w * (double)h;
	ans /= 2;
	int f = 0;
	if(w % 2 == 0 && h % 2 == 0 && x == w / 2 && y == h / 2)
		f = 1;
	cout <<fixed << ans << " " << f << "\n";
	return 0;	
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	for (int i=1;i<=5;i++) {
		int x = sc.nextInt();
		if (x==0) {
			System.out.println(i);
			break;
		}
	}
	sc.close();}}

Measured memory_bytes: 35704
import sys
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

N = INT()
A = LIST()

A.sort(reverse=1)
que = [-A[0]]
ans = 0
for i in range(1, N):
    cur = -heappop(que)
    ans += cur
    heappush(que, -A[i])
    heappush(que, -A[i])
print(ans)


Measured memory_bytes: 101800
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] strArgs) throws Exception {
		BufferedReader br = null;

		try {
			br = new BufferedReader(new InputStreamReader(System.in));

			String[] values = readValues(br);

			int kaishi = toInt(values[0]) * 60 + toInt(values[1]);
			int shuryo = toInt(values[2]) * 60 + toInt(values[3]);
			int benkyo = toInt(values[4]);

			System.out.println(shuryo - benkyo - kaishi);

		} finally {
			br.close();
		}
	}

	private static String[] readValues(BufferedReader br) throws IOException {
		return br.readLine().split("\\s");
	}

	private static int toInt(String str) {
		return Integer.parseInt(str);
	}
}


Measured memory_bytes: 33952
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;

int main()
{
   string S;
   cin >> S;
   int flag1, flag2;
   int a=(S[0]-'0')*10+(S[1]-'0');
   int b=(S[2]-'0')*10+(S[3]-'0');
   if(0<a && a<=12) flag1=1;
   else flag1=0;

   if(0<b && b<=12) flag2=1;
   else flag2=0;

   if(flag1==0 && flag2==1) cout << "YYMM";
   else if(flag1==1 && flag2==0) cout << "MMYY";
   else if(flag1==1 && flag2==1) cout << "AMBIGUOUS";
   else cout << "NA";
   



    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for(int i=0; i<3; i++) {
            String s = sc.next();
            String[] sp = s.split("");
            System.out.print(sp[i]);
        }
        System.out.println();
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int n, k, ans = 0;
	cin >> n >> k;
	int arr[n];
	for (auto &i : arr)cin >> i;
	sort(arr, arr + n);
	for (int i = 0; i < k; i++) ans += arr[i];
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3652
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(r, &n)

	var a int
	memberNum := make([]int, n+1)
	for i := 0; i < n-1; i++ {
		fmt.Fscan(r, &a)
		memberNum[a]++
	}

	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	for i := 1; i <= n; i++ {
		fmt.Fprintln(w, memberNum[i])
	}
}

// Union-Find
type unionFind struct {
	d []int
}

func newUnionFind(n int) *unionFind {
	uf := new(unionFind)
	uf.d = make([]int, n)
	for i := 0; i < n; i++ {
		uf.d[i] = -1
	}
	return uf
}

func (uf *unionFind) find(x int) int {
	if uf.d[x] < 0 {
		return x
	}
	uf.d[x] = uf.find(uf.d[x])
	return uf.d[x]
}

func (uf *unionFind) unite(x, y int) bool {
	rootX := uf.find(x)
	rootY := uf.find(y)
	if rootX == rootY {
		return false
	}

	if uf.d[rootX] < uf.d[rootY] {
		uf.d[rootX] += uf.d[rootY]
		uf.d[rootY] = rootX
	} else {
		uf.d[rootY] += uf.d[rootX]
		uf.d[rootX] = rootY
	}

	return true
}

func (uf *unionFind) same(x, y int) bool {
	return uf.find(x) == uf.find(y)
}

func (uf *unionFind) size(x int) int {
	return -uf.d[uf.find(x)]
}

// mod combination
func modpow(a, n, mod int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % mod
		}
		a = a * a % mod
		n = n / 2
	}
	return res
}

func modcomb(n, a, mod int) int {
	x := 1
	y := 1
	for i := 0; i < a; i++ {
		x = x * (n - i)
		x %= mod
		y = y * (i + 1)
		y %= mod
	}
	return x * modpow(y, mod-2, mod) % mod
}

func modfactorial(n, mod int) int {
	result := 1
	for i := 1; i <= n; i++ {
		result = (result * i) % mod
	}
	return result
}

// Utility

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func primeFactor(x int) map[int]int {
	res := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			res[i]++
			x = x / i
		}
	}
	if x != 1 {
		res[x] = 1
	}
	return res
}

func divisor(x int) []int {
	res := make([]int, 0)
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			res = append(res, i)
			if i != x/i {
				res = append(res, x/i)
			}
		}
	}
	return res
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}

func reverseString(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

// Queue ...
type Queue []int

// pop ...
func (q *Queue) empty() bool {
	return len(*q) == 0
}

// push ...
func (q *Queue) push(i int) {
	*q = append(*q, i)
}

// pop ...
func (q *Queue) pop() (int, bool) {
	if q.empty() {
		return 0, false
	} else {
		res := (*q)[0]
		*q = (*q)[1:]
		return res, true
	}
}

// Stack ...
type Stack []int

// pop ...
func (s *Stack) empty() bool {
	return len(*s) == 0
}

// push ...
func (s *Stack) push(i int) {
	*s = append(*s, i)
}

// pop ...
func (s *Stack) pop() (int, bool) {
	if s.empty() {
		return 0, false
	} else {
		index := len(*s) - 1
		res := (*s)[index]
		*s = (*s)[:index]
		return res, true
	}
}


Measured memory_bytes: 5916
#include<stdio.h>
int main(void){
  int n;
  scanf("%d",&n);
  int p[n];
  int cnt=0;
  for(int i=0;i<n;i++){
    scanf("%d",&p[i]);
  }
  for(int i=1;i<n-1;i++){
    if(p[i+1]>p[i-1]){
      if((p[i+1]>p[i])&&(p[i]>p[i-1])){
        cnt++;
      }
    }else if(p[i+1]<p[i-1]){
      if((p[i-1]>p[i])&&(p[i]>p[i+1])){
        cnt++;
      }
    }
  }
  printf("%d",cnt);
  return 0;
}


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

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define sum(x) accumulate(all(x),0)
#define gll greater<ll>()


void solve(){
 ll d;
  cin >> d;
  vll c(26);
  rep(i,0,26) cin >> c[i];  
  
 vvll s(d,vll(26));
  rep(i,0,d){
    rep(j,0,26) cin >> s[i][j]; 
  }
  
  vll t(d);
  rep(i,0,d) t[i]=(i%26);
  
  vector<set<ll>> v(26);
  rep(j,0,26){
    v[j].insert(-1);
    v[j].insert(d);
  }
  
  ll ans=0;
  rep(i,0,d){
    ans+=s[i][t[i]];
    v[t[i]].insert(i);
    rep(j,0,26) ans-=c[j]*(i-*v[j].rbegin());
  }
  
  
  
  rep(k,0,1000){
      rep(i,0,d){
        rep(j,1,26){
        ll cost=ans;
      auto prev=v[t[i]].find(i);
      auto next=prev;    
      prev--;
      next++;
      cost=cost-c[t[i]]*(i-*prev)*(*next-i);
        v[t[i]].erase(i);  
      t[i]=(t[i]+j)%26;
      
      v[t[i]].insert(i);
      prev=v[t[i]].find(i);
      next=prev;
      prev--;
      next++;
      cost=cost+c[t[i]]*(i-*prev)*(*next-i);
      
      if(cost>ans) {
        ans=cost;
      }
      else {
        v[t[i]].erase(i);
        t[i]=(t[i]-j+26)%26; 
        v[t[i]].insert(i);  
      }
      }
      }
      }
  
  rep(i,0,d) cout << t[i]+1 << endl;

  
}

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

Measured memory_bytes: 3768
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    string s; cin >> s;
    string t; cin >> t;
    map <char, vector<int>> s_chars;
    REP(i, s.size()){
        char c = s[i];
        s_chars[c].push_back(i);
    }
    map <char, vector<int>> t_chars;
    REP(i, t.size()){
        char c = t[i];
        t_chars[c].push_back(i);
    }
    int cur_idx = -1;
    ll rep = 0;
    ll idx;
    for(auto c: t){
        if (s_chars[c].size() == 0){
           cout << -1 << endl;
           return 0;
        }
        if (lower_bound(s_chars[c].begin(), s_chars[c].end(), cur_idx+1) != s_chars[c].end()){
            idx = *(lower_bound(s_chars[c].begin(), s_chars[c].end(), cur_idx+1));
            cur_idx = idx;
        } else {
            idx = s_chars[c][0];
            rep++;
            cur_idx = idx;
        }
    }
    cout << rep*s.size() + idx + 1 << endl;
    return 0;
}

Measured memory_bytes: 1724
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main() {

    int a, b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b;


    return 0;
}






Measured memory_bytes: 888
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
string str;
int  main()
{
    cin>>str;
    ll ans=0;
    for(int i=1;i<str.size();i++)
    {
        if(str[i]==str[i-1])
        {
            ans++;
            if(str[i]=='1') str[i]='0';
            else str[i]='1';
        }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
const int inf=1000000001;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;
static const int N=100;

int n;
vii m(N,vi(N));
vi d(N,inf);

void dijkstra();

int main(){
	int i,j;
	cin>>n;
	int u,k,v,c;
	loop(i,0,n){
		loop(j,0,n){
			m[i][j]=inf;
		}
	}
	loop(i,0,n){
		cin>>u>>k;
		loop(j,0,k){
			cin>>v>>c;
			m[u][v]=c;
		}
	}
	dijkstra();
	loop(i,0,n){
		cout<<i<<" "<<d[i]<<endl;
	}
}

void dijkstra(){
	int i;
	d[0]=0;
	vi color(n,WHITE);
	color[0]=BLACK;
	int u=0,v;
	while(1){
		int minv=inf;
		loop(i,0,n){
			if(color[i]!=BLACK){
				d[i]=min(d[i],d[u]+m[u][i]);
				if(minv>d[i]){
					minv=d[i];
					v=i;
				}
			}
		}
		if(minv==inf){
			break;
		}
		color[v]=BLACK;
		u=v;
	}
	
}

Measured memory_bytes: 3148
#include<stdio.h>
int main()
{
    int n,i=0,sum=0,p;
    int a[n];
    scanf("%d",&n);
    
    while(i<n)
	{
        scanf("%d",&a[i]);
        i++;
	}
    for(int j=0;j<n;j++)
    {
        for(int k=j+1;k<n;k++)
        {
            p=a[j]*a[k];
            sum+=p;
        }

    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 128
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
		String str = bfr.readLine();
		String[] wa = str.split(" ");
		int N = Integer.parseInt(wa[0]);
		int a = Integer.parseInt(wa[1]);
		int b = Integer.parseInt(wa[2]);
		int sum = 0;
		for(int i=1; i<=N; i++) {
			int tmpSum = 0;
			int num = i;
			while(num != 0) {
				tmpSum += num %10;
				num /= 10;
			}
			if(tmpSum >= a && tmpSum <= b) {
				sum += i;
			}
		}
		System.out.println(sum);
	}
}

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

int main(void) {
	auto N = 0;
	std::cin >> N;
	int temp = 0;
	int* iarray = new int[N];
	for (size_t i = 0; i < N; i++) {
		std::cin >> temp;
		iarray[temp - 1] = i + 1;
	}
	for (size_t i = 0; i < N; i++) {
		std::cout << iarray[i] << " ";
	}
	std::cout << std::endl;
	return 0;
}

Measured memory_bytes: 1280
import java.util.*;

public class Main {

    long A;
    long B;

    Main(long A,long B){
        this.A=A;
        this.B=B;
    }

    public long getA() {
        return A;
    }

    public long getB() {
        return B;
    }

    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        long N=sc.nextInt();
        long M=sc.nextLong();
        List<Main> datalist=new ArrayList<Main>();
        long A=0;
        long B=0;
        for(int i=0;i<N;i++){
            A=sc.nextLong();
            B=sc.nextLong();
            Main main2=new Main(A,B);
            datalist.add(main2);
        }
        long sum=0;
        Collections.sort(datalist, new Comparator<Main>() {
            public int compare(Main a, Main b) {
                return (int)(a.A-b.A);
            }
        });
        for(int i=0;i<datalist.size();i++){
            Main m=(Main)datalist.get(i);
            if(M-m.getB()<=0){
                sum+=m.getA()*M;
                break;

            }else{
                sum+=m.getA()*m.getB();
                M-=m.getB();
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 87844
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

int main() {
	ll a = 0, gu = 0, ki = 0,n = 0;
	std::cin >> a;
	gu = a / 2;
	if (a % 2 == 0) {
		ki = a / 2;
	}
	else {
		ki = a / 2 + 1;
	}
	std::cout << gu * ki << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
//#include <unordered_map>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
ll mod=1000000007;
//ll mod=67280421310721;
//ll mod=998244353;
ll INF=1e18;
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
			re%=mod;
		}
		a=(a*a);
		a%=mod;
		b>>=1;
	}
	return re;
}
vector<int> ans;
vector<int> a1,a2;
int co;
int dep[100005];
bool st[100005];
int wuf;
int k;
void dfs(int i,int j,vector<int> gra[],int d)
{
	if(dep[i]==0)
	{
		st[i]=1;
		dep[i]=d;
		FOR(k,0,gra[i].size())
		{
			if(gra[i][k]!=j)
			dfs(gra[i][k],i,gra,d+1);
			if(wuf!=0)
			{
				if(wuf<d)
				ans.pb(i);
				break;
			}
		}
		st[i]=0;
	}
	else
	{
//		cout<<i<<' '<<d<<' '<<dep[i]<<' '<<k<<'\n';
		if((d-dep[i])<=k && st[i]==1)
		{
			wuf=dep[i];
			ans.pb(i);
		}
	}
	return;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
//	cin>>test;
	while(test--)
	{
		int x,y;
		cin>>x>>y;
		if((y%2)==0 && y>=(2*x) && y<=(4*x))
		{
			cout<<"Yes";
		}
		else
		cout<<"No";
	}
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
int main()
{
  string s,t;cin >> s >> t;
  rep(i,s.size()) {
    if(s[i] != t[i]) {
      cout << "No" << "\n";
      return 0;
    }
  }
  cout << "Yes" << "\n";
  return 0;
}


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

using namespace std; 
const int mod=1e9+7;

int main()
{


     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
   
    int t=1;
    while(t--)
    {
     int a,b;
     cin>>a>>b;
     long long int ans=0;
     long long int first=0,second=0;
     for(int i=1;i<=a+1;i++)
     {
        first+=i-1;
        second+=a-i+1;
        if(i>=b)
        ans+=second-first+1;

        ans%=mod;
     } 

      cout<<ans<<endl;

     }

return 0;

}

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

int main()
{
  int n;
  int ans = 10000000;
  cin >> n;
  vector<int> a(n);

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

  for (int i = -100; i <= 100; i++)
  {
    int buf = 0;
    for (int j = 0; j < n; j++)
    {
      buf += pow((i + a.at(j)), 2.0);
    }
    ans = min(ans, buf);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3556