akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<int,P> PP;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 200010
#define D 10
int a[N], b[N];
PP p[2][N];
int main(){
	int n, m;
	scanf("%d%d",&n,&m);
	rep(i, m) scanf("%d%d",a+i,b+i);
	rep(i, m){
		a[i+m] = --b[i];
		b[i+m] = --a[i];
	}
	int q;
	scanf("%d", &q);
	vector<PP> x[D+1];
	rep(i, q){
		int v, d, c;
		scanf("%d%d%d",&v,&d,&c); v--;
		x[d].push_back(PP(i+1, P(c, v)));
	}
	for(int i = D; i >= 0; i--){
		for(auto &&y: x[i]){
			int v = y.snd.snd;
			if(p[0][v].fst>y.fst) continue;
			p[0][v] = PP(y.fst, P(y.snd.fst, i));
		}
		if(i==0) break;
		memcpy(p[1], p[0], sizeof(p[0]));
		rep(k, 2*m){
			int u = a[k], v = b[k];
			if(p[1][u].snd.snd!=i) continue;
			if(p[1][u].fst<=p[0][v].fst) continue;
			p[0][v] = PP(p[1][u].fst, P(p[1][u].snd.fst, p[1][u].snd.snd-1));
		}
	}
	rep(i, n) printf("%d\n", p[0][i].snd.fst);
	return 0;
}


Measured memory_bytes: 8000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(void){
    int n; cin >> n;
    vector<string> A(n);
    set<string> se;
    bool flg=true;
    for(int i=0; i<n; i++){
        cin >> A[i];
        se.insert(A[i]);
    }

    if(A.size()!=se.size()) flg=false;
    for(int i=0; i<n-1; i++){
        if(A[i][A[i].size()-1]!=A[i+1][0]) flg=false;
    }

    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

ll LCM(ll x, ll y) {
    return x / GCD(x, y) * y;
}

ll wazu = 1000000007;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (wazu - inv(wazu % x) * (wazu / x)) % wazu;
        if (a >= 0) { return a; }
        else { return wazu + a; }
    }
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

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

    deque<int> deq;

    int x = 0;

    deq.push_back(x);

    rep(i, N) {
        if (S[i] == 'I') {
            ++x;
            deq.push_back(x);
        }
        else if (S[i]=='D') {
            --x;
            deq.push_back(x);
        }
        else {
            deq.push_back(x);
        }
    }

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

    cout << deq[N] << endl;

}

Measured memory_bytes: 256
N = int(input())
s = input().split()
X = []
for i in range(N):
    X.append(int(s[i]))
sortedX = sorted(X)

mid = int((len(X))/2)
#print(sortedX)
#print(mid)
#print(sortedX[mid])
for i in range(N):
   # print(X[i])
    if X[i] < sortedX[mid]:
        print(sortedX[mid])
        #print("small")
    else:
        print(sortedX[mid-1])
        #print("big")

Measured memory_bytes: 29504
#include <bits/stdc++.h>
#define rep(i, n) for (long long i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> p;
typedef long long ll;
const int inf = 1000000007;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
    a[i]--;
  }
  ll sid = 0;
  vector<ll> sumi(n, -1);
  ll beg = 0;
  ll t = 0;
  sumi[0] = 0;
  // cout << beg << ", ";
  for (ll i = 1; i < n; i++) {
    beg = a[beg];
    // cout << beg << ", ";
    if (sumi[beg] == -1) {
      sumi[beg] = i;
    } else {
      t = i - sumi[beg];
      sid = sumi[beg];
      break;
    }
  }
  // cout << endl;
  // cout << sid << ", " << t << endl;
  ll ans = 0;
  if (k <= sid) {
    rep(i, k) { ans = a[ans]; }
    cout << ans + 1 << endl;
    return 0;
  }
  ll id = (k - sid) % t;
  rep(i, sid + id) { ans = a[ans]; }
  cout << ans + 1 << endl;
  return 0;
}

Measured memory_bytes: 6392
"use strict";
 
function main(arg) {
    arg = arg.split("\n")[0].split(" ");
    const D = arg[0];
    const N = arg[1] == "100" ? "101" : arg[1];
    let zeros = [];
    
    if(parseInt(N) === 0) {
        console.log(0);
        return;
    }
    
    for(let i=0; i<D; i++) {
        zeros.push("00");
    }
    
    console.log(N + zeros.join(""));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main()
{
	int n,k,s;
	cin>>n>>k>>s;
	for(int i=1;i<=k;i++) cout<<s<<" ";
	for(int i=k+1;i<=n;i++) 
	{
		if(s==1e9) cout<<1<<" "; 
		else cout<<s+1<<" ";
	}
	cout<<endl;
	return 0;
} 

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

int main()
{
  int N, Y; cin >> N >> Y;
  int a = -1, b = -1, c = -1;
  rep(x, N)
  {
    rep(y, N)
    {
      int z = N-x-y;
      int sum = 10000*x + 5000*y + 1000*z;
      if(sum == Y && z >= 0)
      {
        a = x; b = y; c = z;
      }
    }
  }
  cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 256
from collections import deque
s=input().split()
q=deque([])
for i in range(len(s)):
    if s[i]=="+":
        a=q.pop()
        b=q.pop()
        calc=b+"+"+a
        q.append(str(eval(calc)))
    elif s[i]=='-':
        a=q.pop()
        b=q.pop()
        calc=b+"-"+a
        q.append(str(eval(calc)))
    elif s[i]=='*':
        a=q.pop()
        b=q.pop()
        calc=b+"*"+a
        q.append(str(eval(calc)))
    else:
        q.append(s[i])
print(*q)


Measured memory_bytes: 5976
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn vec<T, F: FnMut(usize) -> T>(n: usize, mut f: F) -> Vec<T> {
    (0..n).map(|i| f(i)).collect()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let a: Vec<usize> = vec(n, |_| scan(tokens));
    let s = a.iter().fold(0, |x, &y| x ^ y);
    let t = a.iter().fold(0, |x, &y| x | y);
    let u = t ^ s;
    let mut b = vec(n, |i| a[i] & !s);
    let mut j = 0;
    for i in (0..60).rev() {
        let bit = 1 << i;
        if bit & u != 0 {
            let mut k = j;
            while k < n && b[k] & bit == 0 {
                k += 1;
            }
            if k == n {
                continue;
            }
            b.swap(j, k);
            for k in 0..n {
                if k != j && b[k] & bit != 0 {
                    b[k] ^= b[j];
                }
            }
            j += 1;
        }
    }
    let v = b.iter().fold(0, |x, &y| x ^ y);
    println!("{}", s + 2 * v);
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X;
    cin >> X;
    if (X >= 30)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")

#include <cstdio>
#include <stdint.h>
#include <algorithm>
#include <functional>

#ifdef _MSC_VER
//#include <__msvc_all_public_headers.hpp>
#define getchar_unlocked getchar
#define putchar_unlocked putchar
#endif // VS

#define long long long
using namespace std;

void read(uint32_t& x)
{
	x = 0;
	int k;
	while (true)
	{
		k = getchar_unlocked();
		if (k < '0')	break;
		x = x * 10 + k - '0';
	}
}

void sread(int32_t& x)
{
	bool flag;
	x = 0;
	int k = getchar_unlocked();
	if (flag = (k == '-')) k = getchar_unlocked();

	while (true)
	{
		if (k < '0')	break;
		x = x * 10 + k - '0';
		k = getchar_unlocked();
	}
	if (flag) x *= -1;
}

void sprint(int64_t x) {
	if (x == 0) {
		putchar_unlocked('0');
		return;
	}
	if (x < 0) {
		putchar_unlocked('-');
		x *= -1;
	}
	int s = 0;
	char f[15];
	while (x) {
		f[s++] = x % 10;
		x /= 10;
	}
	while (s--)
		putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}

int32_t a[200000];
int main() {
	uint32_t n;
	read(n);
	for (size_t i = 0; i < n; i++) sread(a[i]);
	int64_t res;
	if (n & 1) {
		//Odd
		int64_t sum = 0;
		for (size_t i = 0; i < n - 1; i += 2) sum += a[i];
		res = sum;
		int64_t tailDiff = 0, tailDiffMax = 0;
		for (int i = n - 3; i >= 0; i -= 2)
		{
			sum -= a[i]; sum += a[i + 1];
			tailDiff += a[i + 2]; tailDiff -= a[i + 1];
			tailDiffMax = max(tailDiffMax, tailDiff);
			res = max(res, sum + tailDiffMax);
		}
	}
	else {
		//Even
		int64_t sum = 0;
		for (size_t i = 0; i < n; i += 2) sum += a[i];
		res = sum;
		for (int i = n - 1; i >= 0; i -= 2)
		{
			sum += a[i]; sum -= a[i - 1];
			res = max(res, sum);
		}
	}
	sprint(res);
}


Measured memory_bytes: 2276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	int n,k,q;
	cin >> n >> k >> q;
	vector<int> x(n,0);
	rep(i,q){
		int tmp;
		cin >> tmp;
		x[--tmp]++;
	}
	rep(i,n){
		if(k - q + x[i] > 0){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,j,k) for(int i=j;i<k;i++)
#define FORD(i,j,k) for(int i=j;i>=k;i--)
#define ll long long
#define ull unsigned long long int
#define ld long double
//Make sure no overflow problems
#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define mp make_pair
#define endl '\n'
#define x first
#define y second
#define VAR(i,n) __typeof(n) i = (n)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();i++)
#define FORDEACH(i,c) for( VAR(i,(c).rbegin()),i!=(c).rend();i++)
#define REP(i,n) FOR(i,0,n)
#define mod 1000000007
#define MEM(a, b) memset(a, (b), sizeof(a))
#define addmod(a,b,mod) (a%mod + b%mod)%mod
#define submod(a,b,mod) (a%mod - b%mod + mod)%mod
//const long long INFLL = (ll)INF * (ll)INF;
const ld EPS = 10e-9;
const int MAX = 1e6;


int main(){
    ios_base:: sync_with_stdio(0); 
    cin.tie(0);
    
    ll n, k;
    cin >> n >> k;
    cout << min(n%k, k - n%k);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 100001
#define B 100
#define dpb push_back
#define fi first
#define se second
typedef pair<int, int> P;
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e18;
//__gcd(a,b), __builtin_popcount(a);

int w, h, n, y, x, ay, ax;
ll res = INF;
int a[MAX], b[MAX];
pair<int,int> p[MAX];

ll solve(int m1, int m2){
	ll ans = 0, ma = 0, p1, p2;
	for(int i = 0;i < n;i++){
		ll t1 = abs(p[i].fi-a[m1]);
		ll t2 = abs(p[i].se-b[m2]);
		ans += t1*2;
		ans += t2*2;
		ma = max(ma, t1+t2);
	}
	ans -= ma;
	if(res > ans){
		res = ans;
		ax = a[m1];
		ay = b[m2];
	}
	return ans;
}

int main(){
	ll ans = 0;
	scanf("%d%d%d", &w, &h, &n);
	rep(i,n){
		scanf("%d%d", &a[i], &b[i]);
		p[i].fi = a[i];
		p[i].se = b[i];
	}
	sort(a, a+n);
	sort(b, b+n);
	
	solve(n/2-1, n/2-1);
	solve(n/2-1, n/2);
	solve(n/2, n/2-1);
	solve(n/2, n/2);
	
	printf("%lld\n%d %d\n", res, ax, ay);
	//printf("%d\n", n/2);
	return 0;
}



Measured memory_bytes: 4840
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func strSprit(str string) []string {
	cols := strings.Split(str, " ")
	return cols
}

func parseInt(str string) int {
	n, _ := strconv.Atoi(str)
	return n
}

func intSprit(str string) []int {
	strs := strSprit(str)
	cols := make([]int, len(strs))
	for i, v := range strs {
		cols[i] = parseInt(v)
	}
	return cols
}

func bitCount(n uint) int {

	x := uint64(n)

	const m = 1<<64 - 1
	const m0 = 0x5555555555555555
	const m1 = 0x3333333333333333
	const m2 = 0x0f0f0f0f0f0f0f0f

	x = x>>1&(m0&m) + x&(m0&m)
	x = x>>2&(m1&m) + x&(m1&m)
	x = (x>>4 + x) & (m2 & m)
	x += x >> 8
	x += x >> 16
	x += x >> 32

	return int(x) & (1<<7 - 1)
}

func bitExist(n, i int) bool {
	return ((n >> uint(i)) & 1) == 1
}

func setBit(d, n int) int {
	t := 1 << uint(n)
	return d | t
}

func intAbs(n int) int {
	return int(math.Abs(float64(n)))
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////

func main() {
	line := nextLine()
	spl := intSprit(line)

	N := spl[0]
	M := spl[1]
	C := spl[2]

	b := intSprit(nextLine())

	c := 0
	for i := 0; i < N; i++ {
		sum := C

		as := intSprit(nextLine())
		for j := 0; j < M; j++ {
			sum += as[j] * b[j]
		}
		if sum > 0 {
			c++
		}
	}
	fmt.Println(c)
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(){
  int g[1001][1001]={{0}};//要素を0で初期化
  int n,a,b,c;
  cin >> n;
  // for (int i = 0; i < n; ++i)
  // {
  //   for (int j = 0; j < n; ++j)
  //   {
  //     g[i][j]=0;
  //   }
  // }
  for (int i = 0; i < n; ++i)
  {
    cin >> a >> b ;
    for (int i = 0; i < b; ++i)
    {
      cin >> c;
      g[a-1][c-1]=1;/* code */
    }
  }
  for (int i = 0; i < n; ++i)
  {
     for (int j = 0; j < n; ++j)
     {
      if (j==n-1)
      {
        cout << g[i][j] << endl;
      }else{
        cout << g[i][j] <<" ";
      }
     }
  }

}

Measured memory_bytes: 5080
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int n;
		int y;
		try (Scanner scanner = new Scanner(System.in)) {
			n = scanner.nextInt();
			y = scanner.nextInt();
		}

		int a = y / 10000;
		int b = y % 10000 >= 5000 ? 1 : 0;
		int c = y % 10000 >= 5000 ? y % 10000 / 1000 - 5 : y % 10000 / 1000;

		if (n > y / 1000) {
			Main.printFailed();
			return;
		}
		if (n < a + b + c) {
			Main.printFailed();
			return;
		}

		while (true) {
			if (n >= a + b + c + 9 && a > 0) {
				a -= 1;
				c += 10;
			} else if (n >= a + b + c + 4 && b > 0) {
				b -= 1;
				c += 5;
			} else if (n >= a + b + c + 1 && a > 0) {
				a -= 1;
				b += 2;
			} else if (n == a + b + c) {
				Main.printSuccseeded(a, b, c);
				break;
			} else {
				Main.printFailed();
				break;
			}
		}
	}

	public static void printFailed() {
		System.out.println("-1 -1 -1");
	}

	public static void printSuccseeded(int a, int b, int c) {
		System.out.println(a + " " + b + " " + c);
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int d[200],l[200];
int main()
{
	std::ios::sync_with_stdio(false);	
	int x;
	int n;
	cin>>n>>x;
	d[1]=0;
	for(int i=1;i<=n;i++)cin>>l[i];
	int ans;
	for(int i=2;i<=n+1;i++)
	{
		d[i]+=d[i-1]+l[i-1];
		if(d[i]<=x)
		{
			ans=i;
		}
		else break;
	}
	cout<<ans;
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    for(int i=0;i<s.size()-1;i++){
        if(s.substr(i,2)=="AC"){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}

Measured memory_bytes: 256
s=input()
l=len(s)
list_s=list(s)
ans=""
if(s[l-1]!="s"):
    list_s.append("s")
elif(s[l-1]=="s"):
    list_s.append("es")

for i in range(0,len(list_s)):
    ans+=list_s[i]

print(ans)

Measured memory_bytes: 9096
k,x = map(int,input().split())
ans = []
for i in range(2*k-1):
    if x -k + i +1  < -1000000:
        continue
    elif x -k + i + 1 > 1000000:
        continue
    else:
        ans.append(x-k+i+1)
print(*ans)

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
	int a, b, c,d,e;

	// 整数の入力
	scanf("%d",&a);
	scanf("%d", &b);
	scanf("%d", &e);
	
	c = a-b;
	d = c%e;
	
	printf("%d", d);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <map>

using namespace std;

int main() {
  map<int ,int> m;

  int n;
  cin >> n;
  for(int i = 0; i < n; i++) {
    int a;
    cin >> a;
    map<int, int>::iterator it = m.find(a);
    if(it != m.end()) {
      if(it->second == 0) {
        it->second = 1;
      }else {
        it->second = 0;
      }
    }else {
      m[a]++;
    }
  }

  int total = 0;
  map<int, int>::iterator it = m.begin();
  for(; it != m.end(); ++it) {
    total += it->second;
  }

  cout << total << endl;
}


Measured memory_bytes: 4992
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

int[][10^^5*2] T;
long[10^^5*2] C;

void main()
{
    auto nq = readln.split.to!(int[]);
    auto N = nq[0];
    auto Q = nq[1];
    foreach (i; 0..N-1) {
        auto ab = readln.split.to!(int[]);
        auto a = ab[0] - 1;
        auto b = ab[1] - 1;
        T[a] ~= b;
        T[b] ~= a;
    }
    foreach (_; 0..Q) {
        auto px = readln.split.to!(int[]);
        auto P = px[0] - 1;
        long X = px[1];
        C[P] += X;
    }

    void walk(int i, int p) {
        foreach (j; T[i]) if (j != p) {
            C[j] += C[i];
            walk(j, i);
        }
    }
    walk(0, -1);

    writeln(C[0..N].to!(string[]).join(" "));
}

Measured memory_bytes: 47612
/* 
    Author : Jeff Ahn
    Mon 22 Jun 2020 05:21:35 AM PDT 
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define all(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define uint unsigned long long
#define endl '\n'


struct UnionFind {

  vector<int> id;
  vector<int> sz;
  UnionFind(int n) {
    id.resize(n); sz.resize(n, 1);
    for (int i = 0; i < n; i++) id[i] = i;
  }

  int Find(int u) {
    return (id[u] == u) ? u : id[u] = Find(id[u]);
  }

  bool Uni(int u, int v) {
    u = Find(u);
    v = Find(v);
    if (u == v) return false;
    id[v] = u;
    sz[u] += sz[v];
    return true;
  }

  int Size(int u) {
    u = Find(u);
    return sz[u];
  }

};

const int mxn = 1e5+10;
int a[mxn], b[mxn], c[mxn], d[mxn];

signed main() {
  fastio;
  int n, m, k;
  cin >> n >> m >> k;
  UnionFind dsu(n);

  rep(i, m) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    dsu.Uni(a[i], b[i]);
  }
  rep(i, k) {
    cin >> c[i] >> d[i];
    c[i]--; d[i]--;
  }

  vector<int> res(n);
  rep(i, n) {
    res[i] = dsu.Size(i) - 1;
  }

  rep(i, m) {
    int aa = a[i], bb = b[i];
    res[aa]--;
    res[bb]--;
  }
  rep(i, k) {
    int cc = c[i], dd = d[i];
    if (dsu.Find(cc) != dsu.Find(dd)) continue;
    res[cc]--;
    res[dd]--;
  }
  for (auto r : res) cout << r << " ";
}


Measured memory_bytes: 10020
#include<iostream>
#include<cstdio>
using namespace std;
const int mod=1e9+7;
int main(){
    int n,m;cin>>n>>m;
        if(n<m) swap(n,m);
        if(n-m>1){
            cout<<0;
            return 0;
        }
        int ans=1;
        for(int i=2;i<=n;i++) ans=1LL*ans*i%mod;
        for(int i=2;i<=m;i++) ans=1LL*ans*i%mod;
        if(n==m) ans=ans*2%mod;
        cout<<ans;
}


Measured memory_bytes: 256
// type a
//a...いけそう
//b...自信がない
//c...お試し
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
// ===============================================================
//using系
#pragma region header
using namespace std;
using lint = long long;
using ld = long double;
using ulint = unsigned long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr lint mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#define INF (lint)10000000000000000;
#define mod (int)1000000007
#pragma endregion



int main() {
	lint n, k, s; cin >> n >> k >> s;
	if (s >= (int)pow(10, 9)) {
		for (int i = 0; i < n; i++) {
			if (i < k) cout << s;
			else cout << s - 1;
			if (i == n - 1) { cout << endl; break; }
			else cout << ' ';
		}
	}
	else {
		for (int i = 0; i < n; i++) {
			if (i < k) cout << s;
			else cout << s + 1;
			if (i == n - 1) { cout << endl; break; }
			else cout << ' ';
		}
	}

	return 0;
}

Measured memory_bytes: 3612
// $%U%$ $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	string s;
	cin>>s;
	for(auto i:s){
		cout<<'x';
	}
	cout<<endl;
	return 0;
}



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

int main(){
    ll A, B, C;
    cin >> A >> B >> C;
    if(A%2==0 || B%2==0 || C%2==0){
        cout << 0 << endl;
    }else{
        cout << min(A*B, min(B*C, C*A)) << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
typedef long long int ll;
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EFOR(i,a,b) for (int i=(a);i<=(b);i++)
const ll MOD = (10*10*10*10*10*10*10*10*10+7);

    char A,T;

int main(){
    scanf("%c %c",&A,&T);
    if(A=='H'){
        if(T=='H'){cout<<'H';return 0;}
        else{cout<<'D';return 0;}
    }else{
        if(T=='D'){cout<<'H';return 0;}
        else{cout<<'D';return 0;}
    }



    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    ll W,H,x,y;
    cin>>W>>H>>x>>y;
    cout<<W*H/2.0<<" ";
    if(W%2==0&&H%2==0&&W/2==x&&H/2==y)cout<<1<<endl;
    else cout<<0<<endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    ll a;
    string s;
    cin >> a >> s;
    ll b = 0;
    b += 100 * (s[0]-'0');
    if (s.length() >=3) {
        b += 10 * (s[2]-'0');
    }
    if (s.length() >=4) {
        b += (s[3]-'0');
    }
    //cerr << b << endl;
    cout << (a * b)/100 << endl;
}


Measured memory_bytes: 3624
from itertools import product

def main():
    n,a,b,c = map(int, input().split())
    targetl = [a,b,c]
    targetl.sort()
    ll = []
    for _ in range(n):
        l = int(input())
        ll.append(l)

    ans = 10**9
    ite = product(range(4),repeat=n)
    ite = list(ite)
    for it in ite:
        bamboosl = [ [],[],[] ]
        cost = -30
        for i,v in enumerate(it):
            if v != 3:
                bamboosl[v].append(ll[i])
                cost += 10

        continue_f = False    
        for bamboos in bamboosl:
            if not bamboos: continue_f = True
        if continue_f: continue

        longs = []
        for bamboos in bamboosl:
            curr_l = sum(bamboos)
            longs.append(curr_l)
        longs.sort()

        for v1,v2 in zip(targetl,longs):
            cost += abs(v1-v2)
            
        ans = min(ans,cost)

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 83572
#include <iostream>

using namespace std;

#define MAX_N 40
#define MAX_AB 10

const int INF = 1000000;

// 入力
int N, Ma, Mb;
int a[MAX_N], b[MAX_N], c[MAX_N];

int dp[MAX_N + 1][MAX_N * MAX_AB + 1][MAX_N * MAX_AB + 1];

int main(void) {
    cin >> N >> Ma >> Mb;
    for (int i = 0; i < N; ++i) {
        cin >> a[i] >> b[i] >> c[i];
    }

    for (int i = 0; i <= N; ++i) {
        for (int ca = 0; ca <= MAX_N * MAX_AB; ++ca) {
            for (int cb = 0; cb <= MAX_N * MAX_AB; ++cb) {
                dp[i][ca][cb] = INF;
            }
        }
    }

    dp[0][0][0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int ca = 0; ca <= MAX_N * MAX_AB; ++ca) {
            for (int cb = 0; cb <= MAX_N * MAX_AB; ++cb) {
                if (dp[i][ca][cb] == INF) continue;
                dp[i + 1][ca][cb] = min(dp[i + 1][ca][cb], dp[i][ca][cb]);
                dp[i + 1][ca + a[i]][cb + b[i]] = min(dp[i + 1][ca + a[i]][cb + b[i]], dp[i][ca][cb] + c[i]);
            }
        }
    }

    int ans = INF;
    for (int ca = 1; ca <= MAX_N * MAX_AB; ++ca) {
        for (int cb = 1; cb <= MAX_N * MAX_AB; ++cb) {
            if (ca * Mb == cb * Ma) ans = min(ans, dp[N][ca][cb]);
        }
    }

    if (ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 25984
from collections import defaultdict
from itertools import product
import sys
import math
import bisect

sys.setrecursionlimit(200000)
input = sys.stdin.readline


def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A


def solve(N, A):
    # x: i-A[i]の列
    X = [i-A[i] for i in range(N)]
    # y: i+A[i]の列
    Y = [i+A[i] for i in range(N)]
    z = defaultdict(int)
    for y in Y:
        z[y] += 1
    return sum([z[x] for x in X])


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    print("{}".format(outputs))


Measured memory_bytes: 66228
n=int(input())
a=[0]*n
b=[0]*n
ba=[0]*n
for i in range(n):
    a[i],b[i]=map(int,input().split())
    ba[i]=[b[i],a[i]]
ba.sort()
t=0
for i in range(n):
    if ba[i][0]<ba[i][1]+t:
        print("No")
        break
    t+=ba[i][1]
else:
    print("Yes")

Measured memory_bytes: 38800
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<31-1;
const int MOD = 1000000007;

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

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

void solve(void){
    char string[4];
    rep(3, i) {
        char x[4]; cin >> x;
        string[i] = x[i];
    }
    cout << string << '\n';
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  bool a,b,c;
  a = b = c = false;
  for(int i = 0;i < 3;i++){
   if(s[i] == 'a') a = true;
   else if(s[i] == 'b') b = true;
   else if(s[i] == 'c') c = true;
  }
  if(a == true && b == true && c == true) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,j,c;
    cin>>n;
    k=0;
    if(n%1000!=0)
    {
        k=1000-(n%1000);
        cout<<k<<endl;
    }
    else cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 3528
n, m = map(int, input().split())
hights = list(map(int, input().split()))
lis = [0] * n

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if hights[b] > hights[a]:
        lis[a] = 1
    elif hights[a] > hights[b]:
        lis[b] = 1
    else:
        lis[a] = lis[b] = 1

count =0
for p in range(n):
    if lis[p] == 0:
        count += 1
        
print(count)

Measured memory_bytes: 19956
#include<bits/stdc++.h>
#define endl enjoy_codeforces
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    lint n;std::cin>>n;
    std::vector<lint>a(n+1);
    for(lint i=1;i<=n;i++){
        lint x;std::cin>>x;
        a.at(i)=a.at(i-1)+x;
    }
    std::sort(a.begin(),a.end());
    lint ans=0;
    for(lint i=0,j=1;j<=n+1;j++){
        if(j==n+1||a.at(j-1)!=a.at(j)){
            ans+=(j-i)*(j-i-1)/2;
            i=j;
        }
    }
    std::cout<<ans<<'\n';
}


Measured memory_bytes: 1792
//   PIGMEISTER™   //

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

#define ll long long
#define ull unsigned long long
#define sidha(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define ulta(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define sab(a) a.begin(),a.end()
#define bas(a) a.rbegin(),a.rend()
#define modinv(x) powah(x,mod-2)
#define ncr(n,r) (((fact[n]*modinv(fact[n-r]))%mod*modinv(fact[r]))%mod)
#define factorial fact.pb(1);sidha(i,1,MAX)fact.pb((fact[i-1]*i)%mod)
#define test ll _;cin>>_;while(_--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod (ll)1000000007
//#define mod (ll)998244353
#define MAX 100005

int main()
{
    jaldi;
    
    ll n, m;
    cin >> n >> m;
    ll a[m], sum = 0;
    sidha (i, 0, m) cin >> a[i], sum += a[i];
    if (sum > n) cout << -1;
    else cout << n-sum;
    
    return 0;
}


Measured memory_bytes: 3664
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *p;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
 
 
}
 
Node treeSearch(Node u, int k){
  Node x;
  x=u;
 
  while(x!=NIL && k!=x->key){
    if(k < x->key)x=x->left;
    else x=x->right;
  }
 
  return x;
 
}
 
Node treeSuccessor(Node x){
 
 
}
 
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
 
 
 
}
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x!=NIL){
    y=x;
    if(z->key < x->key)x=x->left;
    else x=x->right;
  }
  z->p=y;
 
  if(y==NIL)root=z;
  else if(z->key < y->key)y->left=z;
  else y->right=z;
 
}
 
void inorder(Node u){
  if (u==NIL)return;
 
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
 
}
void preorder(Node u){
if (u==NIL)return;
 
 printf(" %d",u->key);
 preorder(u->left);
 preorder(u->right);
 
}
 
 
int main(){
  int n, i, x;
  char com[20];
  Node t;
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
       t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
 
  return 0;
}

Measured memory_bytes: 19364
#include <bits/stdc++.h>
#include<cstdio>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
ll mod = 2e18;
map<ll, ll> ma;
void de(ll n) {
	for (int i = 2; i <= sqrt(n); i++) {
		while (n != i) {
			if (n%i == 0) {
				ma[i]++;
				n /= i;
			}
			else {
				break;
			}
		}
	}
	ma[n]++;
}
void solve() {
	ll a, b;
	cin >> a >> b;
	cout << a*b << endl;
	return;
	ll n;
	cin >> n;
	if (n == 1) {
		cout << 0 << endl;
		return;
	}
	de(n);
	ll ans = 0;
	for (auto m : ma) {
		//cout << m.first << endl;
		//cout << m.second << endl;
		ans += (int)(sqrt(1 + 8 * m.second) - 1) / 2;
	}
	cout << ans << endl;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}







Measured memory_bytes: 3672
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  string S;
  cin>>S;
  
  vector<pair<int,int>> A;
  int a=1,b=0;
  FOR(i,1,S.size()){
    if(S.at(i-1)=='L' && S.at(i)=='R'){
      A.push_back(make_pair(a,b));
      a=0;
      b=0;
    } 
    if(S.at(i)=='R') a++;
    if(S.at(i)=='L') b++;
    if(i==S.size()-1) A.push_back(make_pair(a,b));
  }
  
  vector<int> B;
  REP(i,A.size()){
    for(int j=1; j<A[i].first; j++) B.push_back(0);
    int p=(A[i].first+1)/2+A[i].second/2;
    B.push_back(p);
    B.push_back(A[i].first+A[i].second-p);
    for(int j=1; j<A[i].second; j++) B.push_back(0);
  }
  
  REP(i,B.size()) cout<<B.at(i)<<" ";
  cout<<endl;
}


Measured memory_bytes: 1592
using System;

public class Problem_A
{
  public static void Main(string[] args)
  {
    var a = int.Parse(Console.ReadLine());
    var b = int.Parse(Console.ReadLine());
    var c = int.Parse(Console.ReadLine());
    var d = int.Parse(Console.ReadLine());
    Console.WriteLine($"{Math.Min(a, b) + Math.Min(c, d)}");
  }
}

Measured memory_bytes: 13140
#include <stdio.h>

int main()
{
  int A[100], flag = 1, j, N, sort, i = 0, n = 0;

  scanf("%d", &N);
  for(j = 0;j < N;j++){
     scanf("%d", &A[j]);
  }
  
  while(flag){
    flag = 0;
    for(j = N - 1;j >= i + 1;j--){
      if(A[j] < A[j-1]){
	sort = A[j];
	A[j] = A[j-1];
	A[j-1] = sort;
	n++;
        flag = 1;
      }
    }
      	i++;
  }
  for(j = 0;j < N;j++){
    if(j) printf(" ");
    printf("%d",A[j]);
  }
  printf("\n%d\n",n);

  return 0;
}
	



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

int main() {
    ll A, B;
    cin >> A >> B;

    if((A+B)%2 == 0){
        cout << (A + B)/2 << endl;
    }
    else cout << "IMPOSSIBLE" << endl;
}


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

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

    int n, k;
    cin >> n >> k;
    int ans = 0;
    while (n--) {
        int h;
        cin >> h;
        if (h >= k)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(x) cout<<x<<endl

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

//constant
//--------------------------------------------
const double PI = acos(-1.0);
const LL MOD = 1e9 + 7;
const ULL INF = 1e18;
const int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };

//function
//--------------------------------------------
LL gcd(LL, LL);
bool isEven(LL);
void coutY();
void coutN();
LL ave(LL, LL);

int main() {
	int a, b; cin >> a >> b;
	cout << ceil(((double)a + (double)b) / 2);
}

LL gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}
bool isEven(LL a) {
	return !((bool)(a % 2));
}
void coutY() {
	cout << "Yes" << endl;
	return;
}
void coutN() {
	cout << "No" << endl;
	return;
}
LL ave(LL a, LL b) {
	return (a + b) / 2;
}

Measured memory_bytes: 384
/**********************************************
 *Author*        :XzzF
 *Created Time*  : 2018/7/7 15:00:32
 *Ended  Time*  : 2018/7/7 15:02:46
*********************************************/

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 200000;

int n;
LL A[MaxN + 5], B[MaxN + 5];

int main()
{
	while(scanf("%d", &n) != EOF)
	{
		for(int i = 1; i <= n; i++) {
			scanf("%lld", &A[i]);
			B[i] = A[i] - i;
		}
		sort(B + 1, B + n + 1);
		int tmp = B[(n + 1) >> 1];
		LL ans = 0LL;
		for(int i = 1; i <= n; i++)
			ans += abs(A[i] - (tmp + i));
		printf("%lld\n", ans);
	}
    return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
using namespace std;

int main(){
    int N;
    int B[200000];
    cin >> N;
    for(int i = 0; i < N - 1; i++){
        cin >> B[i];
    }
    int A[200000];
    A[0] = B[0];
    for(int i = 1; i < N - 1; i++){
        A[i] = min(B[i - 1] , B[i]);
    }
    A[N - 1] = B[N - 2];
    long long ans = 0;
    for(int i = 0; i < N; i++){
        ans += A[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

int main() {
    ll N;
    auto rate = make_vec_nd((ll)0, 3, 2);
    cin >> N;
    for (int i = 0; i < 2; i++) {
        for (int m = 0; m < 3; m++) {
            ll money;
            cin >> money;
            rate[m][i] = money;
        }
    }
    int cnt = 0;
    while (cnt < 2) {
        vector<int> used_metal;
        for (int m = 0; m < 3; m++) {
            if (rate[m][0] < rate[m][1]) {
                used_metal.push_back(m);
            }
        }
        if (used_metal.size() == 1) {
            int m0 = used_metal[0];
            ll use_m0_cnt = N / rate[m0][0];
            N += use_m0_cnt * (rate[m0][1] - rate[m0][0]);
        } else if (used_metal.size() == 2) {
            int m0 = used_metal[0];
            int m1 = used_metal[1];
            ll max_N = numeric_limits<ll>::min();
            for (ll use_m0_cnt = 0; use_m0_cnt * rate[m0][0] <= N; use_m0_cnt++) {
                ll rest = N - use_m0_cnt * rate[m0][0];
                ll use_m1_cnt = rest / rate[m1][0];
                ll N_case = N;
                N_case += use_m0_cnt * (rate[m0][1] - rate[m0][0]);
                N_case += use_m1_cnt * (rate[m1][1] - rate[m1][0]);
                max_N = max(N_case, max_N);
            }
            N = max_N;
        } else if (used_metal.size() == 3) {
            int m0 = used_metal[0];
            int m1 = used_metal[1];
            int m2 = used_metal[2];
            ll max_N = numeric_limits<ll>::min();
            for (ll use_m0_cnt = 0; use_m0_cnt * rate[m0][0] <= N; use_m0_cnt++) {
                for (ll use_m1_cnt = 0; use_m0_cnt * rate[m0][0] + use_m1_cnt * rate[m1][0] <= N; use_m1_cnt++) {
                    ll rest = N - (use_m0_cnt * rate[m0][0] + use_m1_cnt * rate[m1][0]);
                    ll use_m2_cnt = rest / rate[m2][0];
                    ll N_case = N;
                    N_case += use_m0_cnt * (rate[m0][1] - rate[m0][0]);
                    N_case += use_m1_cnt * (rate[m1][1] - rate[m1][0]);
                    N_case += use_m2_cnt * (rate[m2][1] - rate[m2][0]);
                    max_N = max(N_case, max_N);
                }
            }
            N = max_N;
        }
        for (int m = 0; m < 3; m++) {
            swap(rate[m][0], rate[m][1]);
        }
        cnt++;
    }
    cout << N << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	string S;
	cin >> S;
	if (S.length() == 3) {
		cout << S[2] << S[1] << S[0] << endl;
		return 0;
	}
	cout << S << endl;
	return 0;
}

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

#define fast ios_base::sync_with_stdio(false); cin.tie(nullptr); cin.tie(nullptr);
#define int long long
#define endl '\n'

using namespace std;

int32_t main() {
	fast
	int k;
	cin >> k;

	double val = ((double)(k * 25) / 26) + 1;
	int len = ceil(log(val) / log(26));
	k -= (pow(26, len) - 26) / 25;

	string ans;
	for (int i = 1; i <= len; i++) {
		for (int j = 1; j <= 26; j++) {
			if ((j) * pow(26, len - i) >= k) {
				ans += (char)(j - 1 + 'a');
				k -=  ((j - 1) * pow(26, len - i));
				break;
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//~ using namespace __gnu_pbds; 
#define mp make_pair
#define endl '\n'
typedef long long ll;
 
const int INF=1e9+5;
const ll lim=(ll)3e16;
const int N=2e5+5;
const int mod=1e9+7;	
const ll oo=1e18+5;

//~ typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
	vector<int> a(3);
	for(int& x:a) cin>>x;
	sort(a.begin(),a.end());
	do{
		if(a[0]==a[1]&&a[1]!=a[2]) return cout<<"Yes",0;
		//~ for(int x:a) cout<<x<<" ";
		//~ cout<<endl;
	}
	while(next_permutation(a.begin(),a.end()));
	cout<<"No";
	return 0;	
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int count = 0;
		for(int i = 0; i <3; i++)
		{
		    if(S.charAt(i) == S.charAt(i+1))
		    {
		        count = 1;
		        break;
		    }
		}
		if(count == 1)
		{
		    System.out.println("Bad");
		}
		else
		{
		    System.out.println("Good");
		}
	}
}


Measured memory_bytes: 22868
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int vis [1000009];
int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1 ; i<=n; i++)
    {
        if(((n-i)!=i)&&vis[n-i]==0)
        {
            ans++;
            vis[i]=1;
        }
        else if(vis[n-i])
            break;
    }
    if(n==1)
        cout <<"0" << endl;
    else
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
 
int main(){

  int N;
  cin >> N;
  
  int cnt = 0;
 
  for(int i = 0;i < N;i++){
  char s;
    cin >> s;
    if(s == 'Y') cnt++;
  }
  
  if(cnt) cout << "Four" << endl;
  else cout << "Three" << endl;
   
  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
int main() {
    int n;
    cin >> n;
    vector<int> t(n), a(n);
    for(int i = 0; i < n; i++) {
        cin >> t[i];
    }
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    if(a[0] != t.back()) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> h(n, -1), lb(n, 1);
    h[0] = t[0];
    for(int i = 1; i < n; i++) {
        if(t[i] != t[i - 1]) {
            h[i] = t[i];
        } else {
            lb[i] = t[i];
        }
    }
    if(h.back() != -1 && h.back() != a.back()) {
        cout << 0 << endl;
        return 0;
    }
    for(int i = n - 2; i >= 0; i--) {
        if(a[i] != a[i + 1]) {
            if(h[i] != -1 && h[i] != a[i]) {
                cout << 0 << endl;
                return 0;
            }
            if(h[i] == a[i]) {
                continue;
            }
            if(a[i] > lb[i]) {
                cout << 0 << endl;
                return 0;
            }
            lb[i] = 1;
        } else {
            lb[i] = min(lb[i], a[i]);
        }
    }
    ll ans = 1;
    lb.back() = 1;
    for(int i = 0; i < n; i++) {
        // cout << lb[i] << endl;
        ans *= lb[i];
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792