akhauriyash/Code-Regression huggingface dataset:
N,K = map(int,input().split())
count = []

d = []
A = []

count = []
ans = 0

for i in range(K*2):
  if i % 2 == 0:
    d.append(int(input()))
  else:
    tmp = list(map(int,input().split()))
    for j in range(1,N+1):
      if j in tmp:
        count.append(j)

for k in range(1,N+1):
  if k not in count:
    ans = ans + 1

print(ans)

Measured memory_bytes: 9140
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

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

    int prev_t = 0, x = 0, y = 0;
    for (int i = 0; i < N; i++) {
        int t, t_x, t_y;
        cin >> t >> t_x >> t_y;

        int m_t = t - prev_t;
        int m_x = abs(t_x - x);
        int m_y = abs(t_y - y);
        if (m_x > m_t || m_y > m_t || (m_t - (m_x + m_y)) & 1) {
            cout << "No" << endl;
            return 0;
        }
        prev_t = t;
        x = t_x;
        y = t_y;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_6_C&lang=jp

#define MAX 100005

struct Card {
    char suit;
    int value;
};

int N;
Card A[MAX];
Card B[MAX];

static void merge(int l, int mid, int r) {
    int n1 = mid - l;
    int n2 = r - mid;
    Card L[100005];
    Card R[100005];
    REP(i, n1) L[i] = B[l+i];
    REP(i, n2) R[i] = B[mid+i];
    L[n1].value = R[n2].value = INF;
    int i = 0; int j = 0;
    for (int k = l; k < r; k++) {
        if (L[i].value <= R[j].value) {
            B[k] = L[i++];
        } else {
            B[k] = R[j++];
        }
    }
}

static void mergeSort(int l, int r) {
    if (l+1 < r) {
        int mid = (l+r)/2;
        mergeSort(l, mid);
        mergeSort(mid, r);
        merge(l, mid, r);
    }
}

static int par(int l, int r) {
    int v = A[r].value;
    int j = l - 1;
    for (int i = l; i < r; i++) {
        if (A[i].value <= v) {
            j++;
            swap(A[j], A[i]);
        }
    }
    swap(A[r], A[j+1]);
    return j+1;
}

static void quick(int l, int r) {
    if (l < r) {
        int q = par(l, r);
        quick(l, q-1);
        quick(q+1, r);
    }
}

int main() {
    cin >> N;
    REP(i, N) {
        char n; cin >> n;
        int a; cin >> a;
        A[i] = {n, a};
        B[i] = {n, a};
    }
    mergeSort(0, N);
    quick(0, N-1);

    bool stable = true;
    REP(i, N) if (A[i].suit != B[i].suit) stable = false;
    cout << (stable?"Stable":"Not stable") << "\n";
    REP(i, N) {
        printf("%c %d\n", A[i].suit, A[i].value);
    }

    return 0;
}


Measured memory_bytes: 5472
/*
* Created by: WeirdBugsButOkay
*/

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define ff first
#define ss second

using namespace std;

void solve()
{
    ll k, n;
    cin >> n >> k;
    ll inf = 1000000007;
    ll a[n];
    for(ll i = 0; i < n; i++)
        cin >> a[i];
    vector <ll> neg, pos;
    for(ll i = 0; i < n; i++)
        if(a[i] < 0)
            neg.push_back(a[i]);
        else pos.push_back(a[i]);
    sort(neg.begin(), neg.end());
    sort(pos.rbegin(), pos.rend());
    if(pos.size() == 0 && k % 2 == 1)
    {
        ll ans = 1;
        reverse(neg.begin(), neg.end());
        for(ll i = 0; i < k; i++)
            ans = (ans * (-neg[i])) % inf;
        ans = (inf - ans) % inf;
        cout << ans << endl;
        return;
    }
    if(n == k)
    {
        ll ans = 1;
        bool neg = 0;
        for(ll i = 0; i < n; i++)
        {
            ans = (ans * abs(a[i])) % inf;
            neg ^= (a[i] < 0);
        }
        if(neg)
            ans = (inf - ans) % inf;
        cout << ans << endl;
        return;
    }
    ll cnt = max(0ll, k - (ll)pos.size());
    if(cnt % 2 == 1)
        cnt++;
    ll rc = k - cnt;
    //cout << cnt << " " << rc << endl;
    while(cnt + 1 < (ll)neg.size() && cnt + 1 < k)
    {
        ll np = neg[cnt] * neg[cnt + 1];
        ll pp = pos[rc - 1] * pos[rc - 2];
        if(pp >= np)
            break;
        else
        {
            rc -= 2;
            cnt += 2;
        }
    }
    ll ans = 1;
    for(ll i = 0; i < rc; i++)
        ans = (ans * pos[i]) % inf;
    for(ll i = 0; i < cnt; i++)
        ans = (ans * (-neg[i])) % inf;
    cout << ans << endl;
}

int main()
{
    int q = 1;
    //scanf("%d", &q);
    for(int i = 1; i <= q; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 6928
n=int(input())
a=list(map(int,input().split()))
a_sort=a.sort(reverse=True)
point_a=0
point_b=0
for i in range(0,n,2):
    point_a+=a[i]
for i in range(1,n,2):
    point_b+=a[i]
print(point_a-point_b)

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  ll n;cin>>n;

  ll a[n+10];rep(i,0,n)cin>>a[i];

  int count=0;

  rep(i,0,n){
    if(a[i]==count+1){
      count++;
    }
  }
  if(count==0)out(-1);
  else out(n-count);




  return 0;
}


Measured memory_bytes: 1792
package main

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

var (
	weights = [101]int{}
	values  = [101]int{}
	m       = [100001]int{}
)

func main() {
	sc := NewScanner(os.Stdin)
	n, maxWeight := sc.Int(), sc.Int()

	for i := 1; i <= n; i++ {
		weights[i] = sc.Int()
		values[i] = sc.Int()
	}

	for i := range m[1:] {
		m[i+1] = MaxInt
	}

	for i := range weights {
		w, v := weights[i], values[i]
		if w == 0 && v == 0 {
			continue
		}

		for j := len(m) - 1; j >= v; j-- {
			min := Min(m[j], m[j-v]+w)
			if min > maxWeight {
				continue
			}
			m[j] = min
		}
	}

	maxValue := 0
	for i, w := range m {
		if w != MaxInt && i > maxValue {
			maxValue = i
		}
	}
	fmt.Println(maxValue)
}

// generated by https://github.com/murosan/gollect

const MaxInt int = 2147483647

func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func BytesToInt(b []byte) (n int) {
	var i int
	negative := b[0] == 45
	if negative {
		i++
	}
	for ; i < len(b); i++ {
		n = n*10 + int(b[i]-'0')
	}
	if negative {
		return -n
	}
	return
}

type Scanner struct{ *bufio.Scanner }

func NewScanner(r io.Reader) *Scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	return &Scanner{Scanner: s}
}

func (s *Scanner) Bytes() []byte { s.Scan(); return s.Scanner.Bytes() }

func (s *Scanner) Int() int { return BytesToInt(s.Bytes()) }


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

class Mountain {
public:
	int mountain[10];
	void get();
	void sort(int yama[10]);
	void show();
};

void Mountain::get() {
	for (int i = 0; i < 10; i++) {
		cin >> mountain[i];
	}
}

void Mountain::sort(int yama[10]) {
	int work;
	for (int i = 0; i < 9; i++) {
		for (int j = 0; j < 9; j++) {
			if (yama[j] < yama[j + 1]) {
				work = yama[j];
				yama[j] = yama[j + 1];
				yama[j + 1] = work;
			}
		}
	}
}

void Mountain::show() {
	for (int i = 0; i < 3; i++) {
		cout << mountain[i] << endl;
	}
}

int main() {
	Mountain mou;
	mou.get();
	mou.sort(mou.mountain);
	mou.show();
}


Measured memory_bytes: 1160
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int n = sc.nextInt();
        int[] points = new int[n];
        for(int i = 0; i < n; i++) {
          points[i] = sc.nextInt();
        }
        Arrays.sort(points);
        int ans = 0;
        for(int i = 0; i < n - 1; i++) {
          ans += points[i + 1] - points[i];
        }
    
		// 出力
		System.out.println(ans);
	}
}

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

int n, a[N], A[N];

signed main(){

  cin>>n;

  for(int i=1;i<=n;i++) cin>>a[i];
  
  for(int i=1;i<=n;i++) A[i] = A[i-1] + a[i];
  
  int ans1 = 0, ans2 = 0, add = 0;
  
  for(int i=1;i<=n;i++){
    
    if( i%2==1 ){ // +
      if( A[i] + add <= 0 ){
	ans1 += abs(1 - (A[i] + add));
	add += 1 - (A[i] + add);
      }
    }
    else{ // -
      if( A[i] + add >= 0 ){
	ans1 += abs((A[i] + add) - (-1));
	add -= (A[i] + add) - (-1);
      }
    }
    
  }
  
  add = 0;
  
  for(int i=1;i<=n;i++){
    
    if( i%2==0 ){ // +
      if( A[i] + add <= 0 ){
	ans2 += abs(1 - (A[i] + add));
	add += 1 - (A[i] + add);
      }
    }
    else{ // -
      if( A[i] + add >= 0 ){
	ans2 += abs((A[i] + add) - (-1));
	add -= (A[i] + add) - (-1);
      }
    }
    
  }
  
  cout<<min(ans1, ans2)<<endl;
  
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef int ut;
typedef complex<int> cli;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr> PQ;
const int SIZE=5+2*1e5;
const LL INF=1<<30;
class UnionFind{
 
	vector<int> unions,talls,sents,dists,sizes;
	int size;
public:
	UnionFind(){}
	UnionFind(int size):size(size){
		init();
	}
	void init(){
	 	unions=vector<int>(size);
	 	talls=vector<int>(size);
	 	sents=vector<int>(size);
	 	dists=vector<int>(size);
	 	sizes=vector<int>(size);
		FOR(i,0,size){
			unions[i]=i;
			sents[i]=0;
			sizes[i]=1;
//			ns[i].PB(pr(0,1));
			talls[i]=1;
		}
	}
	int find(int x,int t=0){
		if(unions[x]==x || sents[x]>t) return x;
		return find(unions[x],t);
 
	}
	int minisize(int x){
		if(x==unions[x]) return sizes[x];
		return minisize(find(x));
	}
	bool isFriend(int a,int b,int t=0){
		return find(a,t)==find(b,t);	
	}
	void unite(int a,int b,int t=0){
		if(isFriend(a,b,t)) return;
		a=find(a,t);
		b=find(b,t);
		if(talls[a]<talls[b]) unite(b,a,t);
		else{
 			sizes[a]+=sizes[b];
			sents[b]=t;
			talls[a]=max(talls[a],talls[b]+1);
			unions[b]=a;
			dists[b]=1;
//			ns[a].PB(pr(t,ns[b].back().second+ns[a].back().second));
		}
	}
};
map<pr,int> mpi;
int main(){
	UnionFind roads,trains;
	int N,K,L,p,q;
	cin.tie(0);
	cin >> N >> K >> L;
	roads=UnionFind(N+1);
	trains=UnionFind(N+1);
	REP(i,K){
		cin >> p >> q;
		roads.unite(p,q);
	}
	REP(i,L){
		cin >> p >> q;
		trains.unite(p,q);
	}
	FOR(i,1,N+1){
		mpi[pr(roads.find(i),trains.find(i))]=mpi[pr(roads.find(i),trains.find(i))]+1;
	}
	FOR(i,1,N+1){
		if(i==N) cout << mpi[pr(roads.find(i),trains.find(i))] << endl;
		else cout << mpi[pr(roads.find(i),trains.find(i))] << " ";
	}
	
	return 0;
}

Measured memory_bytes: 19584
n,m,l=gets.split.map(&:to_i)
a=Array.new(n){ gets.split.map(&:to_i) }
b=Array.new(m){ gets.split.map(&:to_i) }
c=Array.new(n){ Array.new(l) }
n.times do |i|
  l.times do |j|
    c[i][j]=a[i].zip(b.transpose[j]).map{|a,b|a*b}.reduce(:+)
  end
end
puts c.map{|l|l*' '}


Measured memory_bytes: 14612
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>

using namespace std;

int main() {
	int A, P; cin >> A >> P;
	P += A * 3;
	cout << P / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())
if(a > b) :
  a, b = b, a
  if(b > c) :
    b, c = c, b
    if(a > b) :
      a, b = b, a
    else :
      pass
  else :
    pass
  print(a, b, c)
else :
  if(b > c) :
    b, c = c, b
    if(a > b) :
      a, b = b, a
    else :
      pass
  else :
    pass
  print(a, b, c)

  



Measured memory_bytes: 5596
#include<iostream>
#include<string>
using namespace std;
int main() {
	int a, b;
	string s;
	bool ok = true;
	cin >> a >> b >> s;
	for (int i = 0; i < a + b + 1; i++) {
		if (i == a) {if (s[i] != '-')ok = false;}
		else {if (s[i] < '0' || '9' < s[i])ok = false;}
	}
	if (ok) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    6月で水色になるぞ〜!!!
*/

// from std...
use std::cmp::{
    max, min,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, Integer};
use num_rational::Rational;
use num_traits::{one, zero, One, Zero};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

pub const MOD: usize = 1000000007;
pub const MAX: usize = 1usize << 63usize;
pub const MIN: i64 = i64::MIN;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 'A' as u8;

/// 配列に含まれる要素(T: Ord + Copy)別にその個数を数えて
/// `BTreeMap<T, usize>`の形にして返す
pub fn unique_count<T: Ord + Copy>(v: &[T]) -> BTreeMap<T, usize> {
    let mut map = BTreeMap::new();
    for e in v {
        let h = map.entry(*e).or_insert(0);
        *h += 1;
    }
    map
}

// code...
// #[fastout]
fn main() {
    input! {
        n: usize,
        a: [i64; n],
        q: usize,
        op: [(i64, i64); q]
    }

    let mut uc = unique_count(&a);
    let mut cur = a.iter().sum::<i64>();

    for (a, b) in op {
        let m = b - a;
        let f = *uc.get(&a).unwrap_or(&0);
        cur += m * f as i64;
        let h = uc.entry(b).or_insert(0);
        *h += f;
        let h = uc.entry(a).or_insert(0);
        *h = 0;

        println!("{}", cur);
    }
}


Measured memory_bytes: 8892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC targett("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(ll i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 4e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time"<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//______________________________________________________________________________
int main()
{
       speed;
       int n;
       cin>>n;
       ll a[n];
       arrin(a,n);
       ll ans = 0;
       fri(i,0,n){
              fri(j,i+1,n){
                     fri(k,j+1,n){
                            set<int>s;
                            s.insert(a[i]);
                            s.insert(a[j]);
                            s.insert(a[k]);
                            if(s.size()<3){continue;}
                            if((a[i]+a[j])<=a[k]){continue;}
                            if((a[i]+a[k])<=a[j]){continue;}
                            if((a[j]+a[k])<=a[i]){continue;}
                            ans++;
                     }
              }
       }
       cout<<ans<<endl;
}


Measured memory_bytes: 3640
#include<iostream>
int main() {
	int n,nsum=0;
	for (int i = 0; i < 4; i += 1) {
		std::cin >> n;
		nsum += n;
	}
	std::cout <<nsum/60 << std::endl;
	std::cout <<nsum%60 << std::endl;
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
int main() {
    ll n, k, s;
    cin >> n >> k >> s;
    ll m = 1000000000LL;
    if(k == 0) {
        if(s != m) {
            for(int i = 0; i < n; i++) {
                cout << m << " ";
            }
            cout << endl;
        } else {
            for(int i = 0; i < n; i++) {
                cout << 1 << " ";
            }
            cout << endl;
        }
        return 0;
    }
    if(k == n) {
        for(int i = 0; i < n; i++) {
            cout << s << " ";
        }
        cout << endl;
        return 0;
    }
    if(1 < s && s < m) {
        for(int i = 0; i < k + 1; i++) {
            if(i % 2 == 0) {
                cout << 1 << " ";
            } else {
                cout << s - 1 << " ";
            }
        }
        for(int i = k + 1; i < n; i++) {
            cout << m << " ";
        }
        cout << endl;
    } else {
        for(int i = 0; i < k; i++) {
            cout << s << " ";
        }
        for(int i = k; i < n; i++) {
            cout << m - s + 1 << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280
/**************************
  * Writer : Leo101
  * Problem : 
  * Tags : 
**************************/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#define File(s) freopen(#s".in", "r", stdin); freopen(#s".out", "w", stdout)
#define gi get_int()
int get_int()
{
	int x = 0, y = 1; char ch = getchar();
	while ((ch < '0' || ch > '9') && ch != '-')
		ch = getchar();
	if (ch == '-') y = -1,ch = getchar();
	while (ch <= '9' && ch >= '0') {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * y;
}

int main()
{

	std :: string Str;
	std :: cin >> Str;

	int Len = Str.size(), Ans = 0;
	if (Len == 0) {
		printf("0");
		return 0;
	}
	std :: stack<int> Stack;
	Stack.push(Str[0] - '0');
	for (int i = 1; i < Len; i++) {
		int Now = Str[i] - '0';
		if (Stack.empty()) Stack.push(Now);
		else if (Now != Stack.top()) {
			Stack.pop();
			Ans += 2;
		} else {
			Stack.push(Now);
		}
	}

	printf("%d", Ans);

	return 0;
}



Measured memory_bytes: 768
# include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, INF = 1e9 + 100;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	map < string, bool > mp;
	cin >> n;
	while(n --){
		string s;
		cin >> s;
		mp[s] = 1;
	}
	cout << mp.size() << '\n';
}

Measured memory_bytes: 19196
def I(): return int(input())
def LI(): return list(map(int,input().split()))
##################################################
N = I()
H = LI()
for i in range(N):
    if i==0:
        H[i] -= 1
        continue
    if i==N-1:
        if H[i-1]<=H[i]:
            continue
    if H[i-1]<=H[i]-1<=H[i+1]:
        H[i] -= 1
        continue
    if H[i-1]<=H[i]<=H[i+1]:
        continue
    print('No')
    break
else:
    print('Yes')


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

using namespace std;

long long pref[int(2e5 + 544)];

int main () { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0);
	int n, k;
	long long a, p = 0, ans = 0;
	map <long long, long long> mp;
	mp[0] = 1;
	cin >> n >> k;
	for (int i = 1 ; i <= n ; ++ i) {
		cin >> a;
		p += a - 1;
		ans += mp[p % k];
		if (i - k + 1 >= 0) {
			mp[pref[i - k + 1] % k]--;
		}
		mp[p % k]++;
		pref[i] = p;
	}
	cout << ans * (k != 1);
}

Measured memory_bytes: 14336
def disp(s, L):
    return
    print(s + " =")
    for x in L:
        print(*x)
    print()

N = int(input())
S = [int(a) for a in input().split()]
T = [int(a) for a in input().split()]
U = [int(a) for a in input().split()]
V = [int(a) for a in input().split()]
X = [[0] * N for _ in range(N)]
m = (1 << 64) - 1

for i in range(N):
    for j in range(N):
        if not S[i]:
            X[i][j] |= U[i]
        if not T[j]:
            X[i][j] |= V[j]
        X[i][j] |= U[i] & V[j]


disp("X", X)
###
A1 = [[m] * N for _ in range(N)]
A2 = [[m] * N for _ in range(N)]
for i in range(N-1)[::-1]:
    for j in range(N):
        A2[i][j] = A2[i+1][j] & X[i+1][j]

for i in range(N):
    a = 0
    for j in range(N):
        a |= X[i][j]
    for j in range(N):
        if i:
            A1[i][j] = A1[i-1][j] & X[i-1][j]
        if S[i] and not T[j]:
            X[i][j] |= U[i] & ~(A1[i][j] & A2[i][j]) & ~a
        
        a |= X[i][j]
        
disp("X", X)
disp("A1", A1)
disp("A2", A2)
###
if False:
    for i in range(N):
        if not S[i]: continue
        A = [m] * N
        for j in range(N-1)[::-1]:
            A[j] = A[j+1] & X[i][j+1]
        a = m
        for j in range(N):
            if not T[j]:
                X[i][j] |= U[i] & ~(a & A[j])
            a &= X[i][j]
###
A1 = [[m] * N for _ in range(N)]
A2 = [[m] * N for _ in range(N)]
for j in range(N-1)[::-1]:
    for i in range(N):
        A2[i][j] = A2[i][j+1] & X[i][j+1]

for j in range(N):
    a = 0
    for i in range(N):
        a |= X[i][j]
    for i in range(N):
        if j:
            A1[i][j] = A1[i][j-1] & X[i][j-1]
        if T[j] and not S[i]:
            X[i][j] |= V[j] & ~(A1[i][j] & A2[i][j]) & ~a
        
        a |= X[i][j]


disp("X", X)
disp("A1", A1)
disp("A2", A2)
###
if False:
    for j in range(N):
        if not T[j]: continue
        A = [m] * N
        for i in range(N-1)[::-1]:
            A[i] = A[i+1] & X[i+1][j]
        a = m
        for i in range(N):
            if not S[i]:
                X[i][j] |= V[j] & ~(a & A[i])
            a &= X[i][j]
###
for i in range(N):
    if S[i] == 0:
        s = m
        for j in range(N):
            s &= X[i][j]
        if s != U[i]:
            print(-1)
            exit()
    else:
        s = 0
        for j in range(N):
            s |= X[i][j]
        if s != U[i]:
            print(-1)
            exit()

for j in range(N):
    if T[j] == 0:
        s = m
        for i in range(N):
            s &= X[i][j]
        if s != V[j]:
            print(-1)
            exit()
    else:
        s = 0
        for i in range(N):
            s |= X[i][j]
        if s != V[j]:
            print(-1)
            exit()

for x in X:
    print(*x)

disp("X", X)
disp("A1", A1)
disp("A2", A2)


Measured memory_bytes: 189716
#include<stdio.h>
#include<math.h>

int main(void)
{
	long long int a,b,c=1,i=2,count=1;
	
	scanf("%lld%lld",&a,&b);
	
	while(c!=0){
		c=a%b;
		a=b;
		b=c;
	}
	
	while(i*i<=a){
		if(a%i==0){
			count++;
			while(a%i==0)
				a/=i;
		}
		i++;
	}
	
	if(a>1)
		count++;
	
	printf("%lld",count);
	
	return 0;
}
		
			

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

string S;
vector<char> v;
 
signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> S;
    S += 'A';
    rep(i, S.size()-1) if (S[i]!=S[i+1]) v.pb(S[i]);
    cout << v.size()-1 << endl;
}

Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <string>

using namespace std;

void fill(vector< vector<int> >& table, int i, int j, int w, int h, int e){
    if(i < 0 || j < 0) return;
    if(i >= h || j >= w) return;
    for(int k=-1; k <= 1; ++k){
        for(int l=-1; l <= 1; ++l){
            if(i+k < 0 || j+l < 0) continue;
            if(i+k >= h || j+l >= w) continue;
            if(table[i+k][j+l] == 1) {
                table[i+k][j+l] = e;
                fill(table, i+k, j+l, w, h, e);
            }
        }
    }
    return;
}

int main(){
    while(true){
        int w, h;
        int cnt = 1;
        cin >> w;
        cin >> h;
        if(w == 0 && h == 0) break;
        vector< vector<int> > table(h, vector <int>(w));
        for(int i=0; i<h; ++i){
            for(int j=0; j<w; ++j){
                cin >> table[i][j];
            }
        }
        for(int i=0; i<h; ++i){
            for(int j=0; j<w; ++j){
                int e = table[i][j];
                if(e == 0) continue;
                else if(e == 1) {
                    cnt++; e = cnt; table[i][j] = e;
                    fill(table, i, j, w, h, e);
                }
            }
        }
        /*
        for(int i=0; i<h; ++i){
            for(int j=0; j<w; ++j){
                cout << table[i][j] << " ";
            }
            cout << endl;
        }*/
        cout << (cnt-1) << endl;
    }
}

Measured memory_bytes: 1484
#include<bits/stdc++.h>
using namespace std;
#define int long long
map<int,int> dp[1<<12];
int m,n;
string s[200];
int dfs(int b,int r){
  if(dp[b].count(r)) return dp[b][r];
  int res=m;
  int cnt=0;
  for(int i=0;i<n;i++){
    int f=1;
    for(int j=0;j<m;j++)
      if(b>>j&1) f&=((s[i][j]=='1')==(r>>j&1));
    cnt+=f;
  }
  if(cnt<=1) return 0;
  for(int i=0;i<m;i++)
    if(!(b>>i&1)) res=min(res,max(dfs(b+(1<<i),r+(1<<i)),
				  dfs(b+(1<<i),r))+1);
  return dp[b][r]=res;
}
signed main(){
  while(cin>>m>>n,m||n){
    for(int i=0;i<n;i++) cin>>s[i];
    for(int i=0;i<(1<<m);i++) dp[i].clear();
    cout<<dfs(0,0)<<endl;
  }
  return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N, K, H[333];
pll AB[3030];
ll i, j, k;
ll dp[333][333][333];

int main(){
    scanf("%lld%lld", &N,&K);
    fornum(i,0,N){
        scanf("%lld", &H[i+1]);
    }
    fornum(i,0,N+3){
        fornum(j,0,N+3){
            fornum(k,0,K+3){
                dp[i][j][k] = 1e15;
            }
        }
    }
    dp[0][0][K] = 0;
    fornum(i,0,N){
        fornum(j,0,i+1){
            fornum(k,0,K+1){
                if(k>0){
                    dp[i + 1][j][k - 1] = min(dp[i + 1][j][k - 1], dp[i][j][k]);
                }
                if(H[j]<H[i+1]){
                    dp[i + 1][i + 1][k] = min(dp[i + 1][i + 1][k], dp[i][j][k] + H[i+1] - H[j]);
                }else{
                    dp[i + 1][i + 1][k] = min(dp[i + 1][i + 1][k], dp[i][j][k]);
                }
            }
        }
    }
    ll ans = 1e15;
    fornum(i,0,N+1){
        fornum(j,0,K+1){
            ans = min(dp[N][i][j], ans);
        }
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 264320
n, l =list(map(int, input().split()))
arr = []
arr2 = []
for k in range(1, n+1):
  arr.append(abs(l + k - 1))
for k in range(1, n+1):
  arr2.append(l + k - 1)
arr2.pop(arr.index(min(arr)))
print(sum(arr2))

Measured memory_bytes: 9180
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <climits>
#include <iomanip>
#define endl "\n"
#define debug(x) cout << #x << " : " << x << endl;
#define debug2(x, y) cout << #x << " : " << x  << ", " << #y << " : " << y << endl;
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0);
typedef long long ll;
using namespace std;

int main()
{
	FASTIO
	
	ll n, m, k;
	cin >> n >> m >> k;
	vector <ll> A(n, 0);
	vector <ll> B(m, 0);
	for(ll i = 0; i < n; i ++)
	{
		cin >> A[i];
		if(i != 0)
			A[i] += A[i - 1];
	}

	for(ll i = 0; i < m; i ++)
	{
		cin >> B[i];
		if(i != 0)
			B[i] += B[i - 1];
	}

	ll curr = 0;
	auto it = upper_bound(B.begin(), B.end(), k);
	ll maxm = it - B.begin();

	for(ll i = 0; i < n; i ++)
	{
		curr = A[i];
		if(curr > k)
			break;
		auto it = upper_bound(B.begin(), B.end(), k - curr);
		ll index = it - B.begin();
		maxm = max(maxm, index + i + 1);	
	}

	cout << maxm << endl;
}

Measured memory_bytes: 6368
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int AX = 2e5+66;
int a[AX];

int main(){
	int n;
	scanf("%d",&n);
	for( int i = 0 ; i < n ; i++ ){
		scanf("%d",&a[i]);
	}
	LL res = 0;
	LL sum = 0;
	int r = 0;
	for( int i = 0 ; i < n ; i++ ){
		while( ( sum ^ a[r] ) == ( sum + a[r] ) && r < n ){
			sum += a[r];
			r++;
		}
		res += r - i ;
		sum ^= a[i];
	}
	printf("%lld\n",res);
	return 0 ;
}

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

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

    int cnt = 0;
    int max = 0;
    for (int i = 0; i < 3; i++)
    {
        if (S.at(i) == 'R')
        {
            cnt++;
        }
        else
        {
            if (cnt > max)
            {
                max = cnt;
            }
            cnt = 0;
        }
    }

    if (cnt > max)
    {
        max = cnt;
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 3620
import heapq

N,M=map(int,input().split())

A=list(map(int, input().split()))

for i in  range (0,len(A)):
    A[i]*=(-1)

heapq.heapify(A)

def chaep(n):
    n=int(n/2)
    return  n
i=0
while(i<M):
    tmp=heapq.heappop(A)
    tmp=chaep(tmp)
    heapq.heappush(A,tmp)
    i+=1

print(-sum(A))

Measured memory_bytes: 72556
N, Q = map(int,input().split())
S = input()
cnt = [0]
for i in range(len(S)-1):
    cnt.append(cnt[-1])
    if S[i] == 'A' and S[i+1] == 'C':
        cnt[-1] += 1
cnt = [0] + cnt

for _ in range(Q):
    l, r = map(int,input().split())
    ans = cnt[r] - cnt[l-1]
    if 2 <= l and (S[l-2] == 'A' and S[l-1] == 'C'):
        ans -= 1
    print(ans)

Measured memory_bytes: 55244
#include <bits/stdc++.h>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;

int main() {
   int year,month,day;
   char c1,c2;
   cin>>year>>c1>>month>>c2>>day;
   if(month<=4){
      cout<<"Heisei"<<endl;
   }else{
      cout<<"TBD"<<endl;
   }

}


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

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

    vector<int> A(N);
    for (size_t i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    for (size_t i = 0; i < N; i++)
    {
        if (A[i] % 2 == 0)
        {
            if ((A[i] % 3 == 0) || (A[i] % 5 == 0))
            {
                continue;
            }
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
package main

import (
"fmt"
)

func main() {
	var N int
	fmt.Scanf("%d\n", &N)

	ns := fmt.Sprint(N)

	ok := false
	for _, s := range []rune(ns) {
		if string(s) == "7" {
			ok = true
		}
	}
	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 1816
from collections import defaultdict

N = int(input())
S = [input() for _ in range(N)]
D = defaultdict(lambda: 0)
for s in S:
    D[s] += 1
d_max = max(D.values())
T = []
for k, v in D.items():
    if v == d_max:
        T.append(k)
T.sort()
print(*T, sep="\n")


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

using namespace std;

struct Graph {
    struct Edge {
        int u, v;
        int cost;
        Edge(int _u, int _v, int _cost) : u(_u), v(_v), cost(_cost) {}
    };
    int n, m;
    bool is_digraph;
    vector<vector<int>> g;
    vector<Edge> e;

    Graph(int _n) : n(_n), m(0) {
        assert(n >= 1);
        g.resize(n);
        set_di(false);
    }
    Graph(int _n, int _m, bool _di=false) : n(_n) {
        assert(n >= 1);
        g.resize(n);
        e.reserve(_m);
        m = 0;
        set_di(_di);
        input(_m);
    }
    void set_di(bool _di) {
        is_digraph = _di;
    }
    inline void add(int u, int v, int cost=1) {
        assert(0 <= u && u < n);
        assert(0 <= v && v < n);
        if (is_digraph) {
            //outdeg[u]++; indeg[v]++;
            g[u].emplace_back(m);

        } else {
            //deg[u]++; deg[v]++;
            g[u].emplace_back(m);
            g[v].emplace_back(m);
        }
        e.emplace_back(u, v, cost);
        m++;
    }
    void input(int _m) {
        int u, v, c;
        for (int i = 0; i < _m; i++) {
            cin >> u >> v >> c;
            u--; v--; // input 1-based
            add(u, v, c);
        }
    }
    template <typename T=int>
    vector<T> bellman_ford(int s, int normal);
};

// single source shortest path
// allow negative, but not -cycle
template <typename T>
vector<T> Graph::bellman_ford(int s, int normal) {
    const int INF = 0x3f3f3f3f;
    vector<T> d(n, INF);
    d[s] = 0;
    // if detect, add another round
    for (int i = 0; i < n-normal; i++) {
        // add flag early stop for constant optimization
        for (auto& k: e) {
            if (d[k.u] < INF && d[k.v] > d[k.u] + k.cost)
                d[k.v] = d[k.u] + k.cost;
        }
    }
    return d;
}

void solve() {
    int n, m, p;
    cin >> n >> m >> p;
    Graph g(n); g.set_di(true);
    for (int i = 0; i < m; i++) {
        int x, y, c;
        cin >> x >> y >> c;
        x--; y--;
        g.add(x,y,p-c);
    }
    auto d = g.bellman_ford<int>(0, 1);
    auto f = g.bellman_ford<int>(0, -n);
    int res = d[n-1] == f[n-1] ? max(0, -d[n-1]) : -1;
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 512
class UnionFind :
    def __init__(self, size) :
        self.parent = list(range(size))
        self.height = [0] * size
        self.size = [1] * size
        self.component = size

    def root(self, index) :
        if self.parent[index] == index :  # 根の場合
            return index
        rootIndex = self.root(self.parent[index])  # 葉の場合親の根を取得
        self.parent[index] = rootIndex  # 親の付け直し
        return rootIndex

    def union(self, index1, index2) :  # 結合
        root1 = self.root(index1)
        root2 = self.root(index2)

        if root1 == root2 :  # 連結されている場合
            return

        self.component -= 1  # 連結成分を減らす

        if self.height[root1] < self.height[root2] :
            self.parent[root1] = root2  # root2に結合
            self.size[root2] += self.size[root1]
        else :
            self.parent[root2] = root1  # root1に結合
            self.size[root1] += self.size[root2]
            if self.height[root1] == self.height[root2] :
                self.height[root1] += 1
        return

    def isSameRoot(self, index1, index2) :
        return self.root(index1) == self.root(index2)

    def sizeOfSameRoot(self, index) :
        return self.size[self.root(index)]

    def getComponent(self) :
        return self.component

N, M = map(int, input().split())

edges = [tuple(map(lambda a: int(a) - 1, input().split())) for _ in range(M)]

def isBride(i):
    tree = UnionFind(N)
    for j, (a, b) in enumerate(edges):
        if i == j:
            continue
        tree.union(a, b)
    return tree.getComponent() > 1

print(len([0 for i in range(M) if isBride(i)]))


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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		char[] s = sc.next().toCharArray();

		boolean[] a = new boolean[26];

		for (char e : s) {
			if (a[e - 'a']) {
				pr.println("no");
				return;
			}
			a[e - 'a'] = true;
		}

		pr.println("yes");
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main()
{
  double a,b,h,m;
  cin >> a >> b >> h >> m;
  double my = b*sin(M_PI/2.0-M_PI*m/30.0);
  double mx = b*cos(M_PI/2.0-M_PI*m/30.0);
  double hy = a*sin(M_PI/2.0-M_PI*m/360.0-M_PI*h/6.0);
  double hx = a*cos(M_PI/2.0-M_PI*m/360.0-M_PI*h/6.0);
  double x = pow(mx-hx,2);
  double y = pow(my-hy,2);
  cout <<fixed << setprecision(20)<< pow(x+y,0.5) << endl;
}


Measured memory_bytes: 4292
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
#define MAXN (int)(2e5+233)
long long sum[MAXN];
long long ans=(long long)1e17;
int main()
{
	int n;
	scanf("%d",&n);
	long long a;
	for (int i=1;i<=n;i++)
	{
		scanf("%lld",&a);
		sum[i]=sum[i-1]+a;
	}
	for (int i=1;i<n;i++) ans=min(ans,max(sum[n]-sum[i],sum[i])-min(sum[n]-sum[i],sum[i]));
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
S = input()
S12 = int(S[:2])
S34 = int(S[2:])

if 1 <= S12 <= 12 and 1 <= S34 <= 12:
    print("AMBIGUOUS")
elif (S12 <= 0 or S12 >= 13) and (S34 <= 0 or S34 >= 13):
    print("NA")
elif 1 <= S12 <= 12 and (S34 <= 0 or S34 >= 13):
    print("MMYY")
elif (S12 <= 0 or S12 >= 13) and 1 <= S34 <= 12:
    print("YYMM")
else:
    print("WOW")




Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  int n, m;
  cin >> n >> m;
  vector<vector<int>> v(100001);
  rep(i, 0, n) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
  }

  priority_queue<int> pq;
  ll ans = 0;
  rep(i, 1, m + 1) {
    rep(j, 0, v[i].size()) pq.push(v[i][j]);
    if (pq.empty())
      continue;
    ans += pq.top();
    pq.pop();
  }

  cout << ans << endl;
}


Measured memory_bytes: 5632
#include<cstdio>
using namespace std;
typedef long long ll;
int n,a[305][305];
bool b[305][305];
int main(){
	//freopen("b.in","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			scanf("%d",&a[i][j]);
		}
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			if(i!=j){
				for(int k=1;k<=n;++k){
					if(k!=i && k!=j){
						if(a[i][k]+a[k][j]==a[i][j]){
							b[i][j]=b[j][i]=1;
						}
						if(a[i][k]+a[k][j]<a[i][j]){
							puts("-1");
							return 0;
						}
					}
				}
			}
		}
	}
	ll ans=0;
	for(int i=1;i<=n;++i){
		for(int j=i+1;j<=n;++j){
			if(b[i][j]!=1){
				ans+=(ll)a[i][j];
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <string>
#include <numeric>
#include <unistd.h>

typedef long long ll;
using namespace std;

int main(){
	int a,b,c,d,e,f;
	cin >> a >>b >>c >>d;
	e=c-a;
	f=d-b;
	cout<<c-f<<" "<<d+e<<" "<<a-f<<" "<<b+e<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
using namespace std;
int h, w, cnt;
char map[105][105];
int mark[105][105];
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
void DFS(int x, int y, char target)
{
    mark[x][y] = cnt;

    for(int i = 0; i < 4; i++)
    {
        int tx = x + dx[i];
        int ty = y + dy[i];

        if(tx >= 0 && tx < h && ty >= 0 && ty < w && !mark[tx][ty] && map[tx][ty] == target)
            DFS(tx, ty, target);
    }

    return;
}
int main(void)
{
    while(scanf("%d%d", &h, &w) != EOF)
    {
        if(h == 0 && w == 0)
            break;

        for(int i = 0; i < h; i++)
            scanf("%s", map[i]);

        cnt = 0;
        memset(mark, 0, sizeof(mark));

        for(int i = 0; i < h; i++)
            for(int j = 0; j < w; j++)
        {
            if(!mark[i][j])
            {
                cnt++;
                DFS(i, j, map[i][j]);
            }
        }

        printf("%d\n", cnt);
    }

	return 0;
}



Measured memory_bytes: 3588
n=int(input())
li=[input() for i in range(n)]
ans=[0,0,0,0]
for i in range(n):
    if li[i]=="AC":
        ans[0]+=1
    elif li[i]=="WA":
        ans[1]+=1
    elif li[i]=="TLE":
        ans[2]+=1
    elif li[i]=="RE":
        ans[3]+=1
print("AC x " + str(ans[0]))
print("WA x "+ str(ans[1]))
print("TLE x "+str(ans[2]))
print("RE x "+str(ans[3]))

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

struct UnionFind{
    vector<int> par; // par[i]:iの親の番号
    
    UnionFind(int N) : par(N) {
        for(int i=0; i<N; i++) par[i] = i;
    }
    
    int root(int x){ // xが属する木の根
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    
    void unite(int x, int y){ // xとyの木を併合
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] = ry;
    }
    
    bool same(int x, int y){ // xとyが同じ木に属するかどうか
        return root(x) == root(y);
    }
};

int main(void){
    int N,M; cin >> N >> M;
    VI p(N), id2num(N);
    REP(i,N){
        cin >> p[i]; p[i]--;
        id2num[p[i]] = i;
    }
    UnionFind uf(N);
    REP(i,M){
        int x,y; cin >> x >> y;
        x--; y--;
        uf.unite(x,y);
    }
    int ans = 0;
    REP(i,N){
        if(i == p[i]) ans++;
        else if(uf.same(i,id2num[i])) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
/* B - Mix Juice */

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

int main(){
  int N, K, tmp, ans = 0;
  vector<int> p(1000);
  cin >> N >> K;
  for(int i = 0; i < N; i++){
    cin >> tmp;
    if(i == 0) p.at(i) = tmp;
    for(int j = 0; j < i; j++){
      if(p.at(j) > tmp){
        for(int k = i; k > j; k--){
          p.at(k) = p.at(k - 1);
        }
        p.at(j) = tmp;
        break;
      }
      if(j == i - 1) p.at(i) = tmp;
    }
  }
  for(int i = 0; i < K; i++){
    ans += p.at(i);
  }
  cout << ans << endl;
}


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

using namespace std;

int g[102][102];
int d[102], f[102];
int t = 0, n;

int dfs(int x){
    t++;
    //cout<<x<<" s: "<<t<<endl;
    for(int i=1; i<=n; i++){
        if(d[x] == 0) d[x] = t;
       
        if(g[x][i] == 1 && f[i] == 0){
            g[x][i] = 0;
            if(d[i] == 0){
                dfs(i);
                t++;
            }   
        }
        
        if(i == n && f[x] == 0){
            //   cout<<x<<" e: "<<t+1<<endl;
            f[x] = t+1;
        }
    }
    return 0;        
  
}

int main(){
    cin >> n;

    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            g[i][j] = 0;
        }
        d[i] = 0;
        f[i] = 0;
    }
    
    int u,k;
    for(int i=0; i<n; i++){
        cin>>u>>k;
        for(int j=0; j<k; j++){
            int v;
            cin>>v;
            g[u][v] = 1;
        }
    }

    for(int i=1; i<=n; i++){
        if(f[i]==0){
            dfs(i);
            t++;
        }
    }

    for(int i=1; i<=n; i++){
        cout<< i << " " << d[i] << " " << f[i] <<endl;
    }
    
    return 0;
}

Measured memory_bytes: 1200
from heapq import heappop, heappush, heapify

N = int(input())
A = list(map(int, input().split()))

L = A[:N]
heapify(L)
sumL = [sum(A[:N])]

for i in range(N):
    x = heappop(L)
    if x < A[N + i]:
        sumL.append(sumL[-1] - x + A[N + i])
        heappush(L, A[N + i])
    else:
        sumL.append(sumL[-1])
        heappush(L, x)

R = list(map(lambda x: -x, A[2 * N:]))
heapify(R)
sumR = [sum(A[2 * N:])]

for i in range(N):
    x = -heappop(R)
    if x > A[2 * N - 1 - i]:
        sumR.append(sumR[-1] - x + A[2 * N - 1 - i])
        heappush(R, -A[2 * N - 1 - i])
    else:
        sumR.append(sumR[-1])
        heappush(R, -x)

res = -10**18

for i in range(N + 1):
    res = max(res, sumL[i] - sumR[-1 - i])

print(res)

Measured memory_bytes: 122896
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 998244353
  #define N 200005
  #define INF 1000000000000
  #define eps 1e-6



int32_t main()
{



    int n,k;
    cin >> n >> k;


    vector<int> v;

    for(int i = 1; i <= n; i++)
    {
      int x;
      cin >> x;
      v.PB(x);
    }

    sort(all(v));


    int ans = 1e9;


    for(int i = k; i <=n; i++)
    {
      ans = min(ans,v[i-1]-v[i-k]);
    }

    cout << ans;
    return 0;
}

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

int main(){
  	int s,s1,s2,s3;
	cin >> s;
  	s1 = s/100;
  	s2 = (s%100)/10;
    s3 = (s%100)%10;
  	cout << s1+s2+s3 << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

n = int(input())
ans = n
for i in range(1,n):
    u,v = map(int,input().split())
    if v < u:
        u,v = v,u
    ans += i*(n-i+1) - u*(n-v+1)
print(ans)


Measured memory_bytes: 9188