akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}

#[allow(unused_macros)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn valid(c1: char, c2: char) -> bool {
    c1 == c2
}

fn main() {
    let s = read!(String);
    let t = read!(String);
    let sc = s.chars().collect::<Vec<_>>();
    let tc = t.chars().collect::<Vec<_>>();

    let mut map = HashMap::new();
    let mut imap = HashMap::new();

    for i in 0..sc.len() {
        let s = sc[i];
        let t = tc[i];
        match map.get(&s) {
            Some(&val) => {
                if !valid(val, t) {
                    println!("No");
                    return;
                }
            }
            None => {
                map.insert(s, t);
            }
        };

        match imap.get(&t) {
            Some(&val) => {
                if !valid(val, s) {
                    println!("No");
                    return;
                }
            }
            None => {
                imap.insert(t, s);
            }
        };
    }
    println!("Yes");
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;

typedef long long       ll;
typedef long double     ld;

typedef vector<int>     vi;
typedef vector<bool>    vb;
typedef vector<ll>      vll;
typedef vector<vi>      vvi;
typedef vector<vll>     vvll;
typedef vector<string>  vs;

typedef pair<int, int>  pii;
typedef pair<ll, int>   pli;
typedef pair<ll, ll>    pll;
typedef vector< pii >   vpi;
typedef vector< pll >   vpll;

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

#define pb           push_back
#define mod          1000000007
#define INF          1e17
#define mini         INT_MIN
#define maxo         INT_MAX
#define eb           emplace_back
#define ff           first
#define ss           second
#define re           return 
#define endl         "\n" 

#define all(c)       c.begin(),c.end()
#define be           begin()
#define en           end()
#define sz(x)        (ll)x.size()
#define mem(a,val)   memset(a,val,sizeof(a))
#define mk(x,y)      make_pair(x,y)
#define mid(l,r)     ((l)+((r)-(l))/2) 

#define fo(i,a,b)    for(ll i = (ll)(a); i <= (ll)(b); i++)
#define rf(i,a,b)    for(ll i = (ll)(a); i >= (ll)(b); i--)
#define read(a,n)    for(int i=0;i<n;i++)cin>>a[i];
#define show(a,n)    for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl;
#define p2(n)        (1LL << (n))
#define deb(x) cout <<#x << " = " << x << " | " << "LINE: "<<__LINE__<< endl;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void add(ll &x, ll y){ x += y; if(x>=mod) x %= mod; if(x<0) x = x%mod + mod; }

//============== *** START OF CODE ***




void solve()
{
    int ans = 0 ;
    int n; rd(n);
    ll side[n+1]; read((side+1),n);
    map<int,int> cnt;
    fo(i,1,n)cnt[side[i]]++;
    int j=1;
    for(auto x:cnt){
        side[j++]=x.ff;
    }
 

    n = j-1;
    fo(i,1,n){
        fo(j,i+1,n){
            fo(k,j+1,n){
                if(side[i]+side[j]>side[k] and side[i]+side[k]>side[j] and side[k]+side[j]>side[i])ans+=cnt[side[i]]*cnt[side[j]]*cnt[side[k]];
            }
        }
    }   
    cout<<ans<<endl;
    
}


void prep(){}

//=============== *** END OF CODE ***

int main(){
    speedio; cout<<fixed<<setprecision(12);

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

    prep();
    int t = 1;
    // cin >> t;
    while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 3656
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 29 20:56:18 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

#N = int(input())
a,b,c,d = map(int,input().split())
#A = list(map(int,input().split()))

if (c-1) // b <= (a-1) // d:
    ans = 'Yes'
else:
    ans = 'No'
print(ans)


Measured memory_bytes: 9032
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define speed() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    speed();
    string s; cin >> s;
    if (s.at(0) != 'A') {
        cout << "WA";
        exit(0);
    }
    int n = s.size(), cnt = 0;
    rep(i, 2, n-1) {
        if (s.at(i) == 'C') cnt++;
        else if (isupper(s.at(i))) {
            cout << "WA";
            exit(0);
        }
    }
    if (isupper(s.at(1)) || isupper(s.at(n-1))) {
        cout << "WA";
        exit(0);
    }
    (cnt == 1) ? cout << "AC" : cout << "WA";
    return 0;
}

Measured memory_bytes: 256
//in the name of ALLAH
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
 ll n,l,u,c;
 cin>>n;
 int a[n];
 for(int i=0;i<n-1;i++)
 {
     cin>>a[i];
 }
 sort(a,a+n-1);
 for(int i=1;i<=n;i++)
 {
     l=lower_bound(a,a+n-1,i)-a;
     if(l==n-1 || a[l]!=i)
        c=0;
     else
     {
         u=upper_bound(a,a+n-1,i)-a;
         c=u-l;
     }
     cout<<c<<endl;
 }
}




Measured memory_bytes: 4420
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
#define lcm(x, y) ((x) * (y) / __gcd((x), (y)))
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define debug(x) cout << #x << " : " << x << endl
#define part cout << "----------------------------------\n";
#include <iostream>
#define fastinput                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

LL POW(LL x, LL y)
{
    LL ans = 1;
    LL base = x;
    while (y)
    {
        if (y & 1)
        {
            ans *= base;
        }
        base = base * base;
        y = y >> 1;
    }
    return ans;
}

int main()
{
    fastinput;
    LL n,i,j,k,t,temp,tc,a,b;
    string s1,s2;
    cin>>s1>>s2;
    LL len=s1.length();
    LL cnt=0;
    for(i=0;i<len;i++)
    {
        if(s1[i]!=s2[i])
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;

    return 0;
}



Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    ll k;
    cin >> k;
    ll a[n];
    REP(i,n){
        cin >> a[i];
    }
    vector<vector<ll>> dp(50 + 1, vector<ll>(2, -1));
    dp[50][0] = 0;
    for(int i = 49; i >= 0; i--){
        ll mask = 1LL << i;
        ll one = 0, zero = 0;
        for(int i = 0; i < n; i++){
            if(a[i] & mask) one++;
            else zero++;
        }
        if(dp[i + 1][1] != -1) dp[i][1] = max(dp[i][1], dp[i + 1][1] + mask * max(one, zero));
        if(dp[i + 1][0] != -1){
            if(k & mask){
                dp[i][1] = max(dp[i][1], dp[i + 1][0] + mask * one);
                dp[i][0] = max(dp[i][0], dp[i + 1][0] + mask * zero);
            }else{
                dp[i][0] = max(dp[i][0], dp[i + 1][0] + mask * one);
            }
        }
    }
    cout << max(dp[0][0], dp[0][1]) << endl;
    return 0;
}

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

class Main{
		public static void main(String args[]) throws IOException{
			ArrayList<String> line_list = new ArrayList<String>();

			Scanner scan = new Scanner(System.in);
			
			int low,line;
			
			low = Integer.parseInt(scan.next());
			line = Integer.parseInt(scan.next());
			
			for(int i=0;i<line;i++){
				String str1 = scan.next();
				String str2 = ","+String.valueOf(i);
				str1 = str1+str2;
				line_list.add(str1);
			}			
			
			int now,priority,list_n,list_a,list_p;
			ArrayList<Integer> res = new ArrayList<Integer>();
			
			for(int i=0;i<low;i++){
				res.add(0);
			}
			
			for(int i=1;i<=low;i++){
				priority = -1;
				now = i;
				for(int j=0;j<line_list.size();j++){
					String[] strAry = line_list.get(j).split(",");
					list_n = Integer.parseInt(strAry[0]);
					list_a = Integer.parseInt(strAry[1]);
					list_p = Integer.parseInt(strAry[2]);
					if(now == list_n && priority < list_p){
						now = list_a;
						priority = list_p;
						j = 0;
					}
					if(now == list_a && priority < list_p){
						now = list_n;
						priority = list_p;
						j = 0;
					}
					else if(priority == (line - 1)){break;}
				}
				res.set(now-1,i);
			}
			
			for(int i=0;i<res.size();i++){
					System.out.println(res.get(i));
			}
			
	}
}

Measured memory_bytes: 12000
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll cnt[5];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	string s;
	memset(cnt, 0, sizeof(cnt));
	rep(i,n){
		cin >> s;
		if(s[0] == 'M') cnt[0]++;
		if(s[0] == 'A') cnt[1]++;
		if(s[0] == 'R') cnt[2]++;
		if(s[0] == 'C') cnt[3]++;
		if(s[0] == 'H') cnt[4]++;
	}
	ll ans = 0;
	for(int i = 0; i < 3; i++){
		for(int j = i+1; j < 4; j++){
			for(int k = j+1; k < 5; k++){
				ans += cnt[i] * cnt[j] * cnt[k];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << "\n"
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
constexpr int NMAX = 50001;
constexpr int INF = (1<<29);
int main() {
	int n, m; cin >> n >> m;
	vi C(21); rep(i, 1, m + 1) cin >> C[i];
	vi T(NMAX, INF);
	T[0] = 0;
	rep(i, 1, m + 1) {
		rep(j, 0, n - C[i] + 1) {
			if(T[j + C[i]] > T[j] + 1) T[j + C[i]] = T[j] + 1;
		}
	}
	P(T[n]);
	return 0;
}

Measured memory_bytes: 3172
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	t := getNextInt(scanner)
	a := float32(getNextInt(scanner))

	min := float32(1 << 30)
	ans := 0
	for i := 0; i < n; i++ {
		h := getNextInt(scanner)
		diff := a - avg(t, h)
		if diff < 0 {
			diff = -diff
		}
		if min > diff {
			min = diff
			ans = i
		}

	}

	fmt.Fprintln(writer, ans+1)
	writer.Flush()
}

func avg(t, h int) float32 {
	return float32(t) - 0.006*float32(h)
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N, M;
string A[60];
string B[60];

bool match(int x, int y) {
  for (auto i = 0; i < M; ++i) {
    for (auto j = 0; j < M; ++j) {
      if (A[i+x][j+y] != B[i][j]) return false;
    }
  }
  return true;
}

int main () {
  cin >> N >> M;
  for (auto i = 0; i < N; ++i) {
    cin >> A[i];
  }
  for (auto i = 0; i < M; ++i) {
    cin >> B[i];
  }
  for (auto i = 0; i <= N-M; ++i) {
    for (auto j = 0; j <= N-M; ++j) {
      if (match(i, j)) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
#define w1 first
#define w2 second
#define ls (x<<1)
#define rs (x<<1|1)
#define pb push_back
#define mid ((l+r)>>1)
#define SZ(x) ((x).size())
#define All(x) (x).begin(),(x).end()
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
const int maxn=1e5+5;
int cnt=0,n,m;
vector<int>A,B;
int a[maxn];
int main(){
	read(n);read(m);
	rep(i,1,m){
		read(a[i]);
		if(a[i]&1)cnt++;
	}
	if(cnt>2)puts("Impossible");
	else{
		rep(i,1,m)if(a[i]&1){
			A.pb(a[i]);
			break;
		}
		rep(i,1,m)if(!(a[i]&1))A.pb(a[i]);
		if(cnt==2){
			per(i,m,1)if(a[i]&1){
				A.pb(a[i]);
				break;
			}
		}
		rep(i,1,m)printf("%d ",A[i-1]);puts("");
		if(A[0]!=1)B.pb(A[0]-1);
		rep(i,2,m-1)B.pb(A[i-1]);
		if(m>1)B.pb(A[m-1]+1);
		else B.pb(1);
		printf("%d\n",SZ(B));
		rep2(i,0,SZ(B))printf("%d ",B[i]);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std;

int main() {
	#ifdef kvutxdy
	freopen("C:/Users/khanh/OneDrive/RoadtoPurple/Code/Codeforces/input.in", "r", stdin);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	string s;
	cin>>s;
	int n=s.size(),res=0;
	for(int i=0;i<n;++i) 
		if(i%2==0&&s[i]=='p') --res;
		else if((i&1)&&s[i]=='g') ++res;
	cout<<res; 
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_abs(const _T& a) {
	//	usage:  tp_abs<type name>(a);
	return ((a < 0) ? (a * -1) : a);
}

static const ULLONG UL_HUGE_DIVIDER = 1000000007LLU;
static const LLONG LL_HUGE_DIVIDER = 1000000007LL;

//static void ABC111D_RobotArms();
static void ABC110A_MaximizeTheFormula();

#if 1
int main()
{
	//ABC111D_RobotArms();
	ABC110A_MaximizeTheFormula();
	fflush(stdout);
	return 0;
}
#endif

static void ABC110A_MaximizeTheFormula()
{
	int panel[4] = { 0 };
	scanf(" %d %d %d", &panel[0], &panel[1], &panel[2]);

	std::sort(panel, panel + 3);
	printf("%d\n", (panel[2] * 10) + panel[1] + panel[0]);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,n;
  cin >> N;
  n = N%10;
  if(n==2||n==4||n==5||n==7||n==9){
    cout << "hon";
  }
  else if(n==0||n==1||n==6||n==8){
    cout << "pon";
  }
  else if(n==3){
    cout << "bon";
  }
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;

int main(){
    char a[10][10];
    scanf("%s%s%s", a[0], a[1], a[2]);
    printf("%c%c%c\n", a[0][0], a[1][1], a[2][2]);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		
		while(true) {
			int n=in.nextInt();
			if(n==0)break;
			List<String> odrs=new ArrayList<>();
			for(int i=0;i<n;i++)odrs.add(in.next());
			System.out.println(solve(odrs));
		}
	}
	
	static int solve(List<String> data) {
		int cnt=0;
		boolean LS=false,l=false,r=false;
		
		for(int i=0;i<data.size();i++) {
			switch (data.get(i)) {
			case "lu":
				l=true;
				break;
				
			case "ld":
				l=false;
				break;
				
			case "ru":
				r=true;
				break;
				
			case "rd":
				r=false;
				break;
			}
			
			if(!LS && (l && r)) {
				cnt++;
				LS=true;
			}
			else if(LS &&(!l && !r)) {
				cnt++;
				LS=false;
			}
		}
		return cnt;
	}
}



Measured memory_bytes: 37176
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin >> N;
  int X = 999;
  for ( int i = 0 ; i<N.size()-2 ; i++) {
    int D;
    D =  753 - (100*(N[i]-'0') + 10*(N[i+1]-'0') + N[i+2]-'0');
    if (D < 0 ) {
      D *= -1;
    }
    if ( D <= X ) {
      X = D;
    }
  }
  cout << X << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int t, l, r;
    scanf("%d", &t);
    int ans = 0;
    while(t--) {
        scanf("%d%d", &l, &r);
        ans += r - l + 1;
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
class UnionFind{
  vector<int> node;
 public:
  UnionFind(int n):node(n){
    for(int i = 0;i < n;i++){
      node[i] = i;
    }
  }
  int root(int x){
    if(x == node[x])return x;
    return root(node[x]);
  }
  void merge(int x,int y){
    node[root(x)] = root(y);
  }
};
struct edge{
  int x,y,w;
};
bool operator<(edge e1,edge e2){
  return e1.w < e2.w;
}
int main(){
  int n;
  cin >> n;
  vector<edge> edges;
  UnionFind u(n);
  for(int i = 0;i < n;i++){
    for(int j = 0;j < n;j++){
      int x;
      cin >> x;
      if(x >= 0){
        edges.push_back({i,j,x});
      }
    }
  }
  int weight = 0;
  sort(edges.begin(),edges.end());
  for(auto &e:edges){
    if(u.root(e.x) == u.root(e.y))continue;
    u.merge(e.x,e.y);
    weight += e.w;
  }
  cout << weight << endl;
}

Measured memory_bytes: 1344
// AGC004_A
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)

typedef long long ll;

const ll MOD7 = 1000000007;  // 1 000 000 007
const ll MOD9 = 1000000009;  // 1 000 000 009

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

    // input
    ll A, B, C;
    vector<ll> vec(3);
    REP(i, 3) cin >> vec[i];
    
    // calculation
    sort(vec.begin(), vec.end());
    ll volume = vec[0]*vec[1]*vec[2];
    if (volume%2 == 0) {
        cout << 0 << "\n";
    } else {
        ll vol_big = ((vec[2]+2-1)/2)*vec[1]*vec[0];
        ll vol_small = (vec[2]/2)*vec[1]*vec[0];
        cout << vol_big - vol_small << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <algorithm>

using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	const int MAX_VALUES = 101;
	bitset<MAX_VALUES> bits;
	bitset<MAX_VALUES> reversed;
	bits.flip();
	reversed.flip();
	int x, n, t;
	cin >> x >> n;
	if (n == 0) {
		cout << x;
		exit(0);
	}
	for (int i = 0; i < n; i++) {
		cin >> t;
		bits._Unchecked_reset(t);
		reversed._Unchecked_reset(MAX_VALUES - 1 - t);
	}
	if (bits[x]) {
		cout << x;
		exit(0);
	}
	int rV = bits._Find_next(x);
	int lV = MAX_VALUES - 1 - reversed._Find_next(MAX_VALUES - 1 - x);
	int d1 = abs(rV - x);
	int d2 = abs(lV - x);
	if (d1 < d2) {
		cout << rV;
	} else if (d2 < d1) {
		cout << lV;
	} else {
		cout << min(rV, lV);
	}
	return 0;
}

Measured memory_bytes: 3616
n,k = map(int,input().split())
a = [int(i) for i in input().split()]

dct = {}
for i in range(n):
    if a[i] not in dct:
        dct[a[i]] = 1
    else:
        dct[a[i]] += 1

l = len(dct)
if l <= k:
    ans = 0
else:
    na = sorted([int(dct[key]) for key in dct])
    ans = sum(na[:l-k])

print(ans)

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

bool a[21][21];
int n;
long long tb[21][1<<21];

long long dp(int i, int mask){
	if(i == n){
		return 1;
	}
	
	if(tb[i][mask] != -1) return tb[i][mask];
	
	long long total = 0;
	for(int j = 0; j < n; ++j){
		if(1<<j & mask) continue;
		if(a[i][j])
			total = (total + dp(i+1, mask | 1<<j))%1000000007;
	}
	
	return tb[i][mask] = total;
}

int main(){
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);
	memset(tb, -1, sizeof(tb));
	
	cin >> n;
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < n; ++j){
			cin >> a[i][j];
		}
	}
	
	cout << dp(0,0) << endl;
	
	return 0;
}

Measured memory_bytes: 344320
#define _USE_MATH_DEFINES
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
typedef long long int LL;
typedef pair<int,int> P;


int main() {
	LL a,b;
	cin >> a >> b;
	if((a+b)%2==0) {
		cout << (a+b)/2 << endl;
	} else {
		cout << "IMPOSSIBLE" << endl;
	}
	return 0;
}

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

int main(){ 
    int N;
    double ans=0;
    string x;
    cin>>N;
    double y[N];
    for(int i=0;i<N;i++){
        cin>>y[i]>>x;
        if(x=="BTC"){
            ans += y[i]*380000;
        }else{
            ans += y[i];
        }
    }
    printf("%lf",ans);
    return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	if ((tmp & ma0) ^ ma0) {
		int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
		tmp = tmp << dig & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += (72 - dig >> 3);
	}
	else {
		tmp = tmp & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += 8;
		if ((ct = *ci++) >= '0') {
			tmp = tmp * 10 + ct - '0';
			if (*ci++ == '0') {
				tmp = tmp * 10;
				ci++;
			}
		}
	}
	return tmp;
}

int A[200000];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N = getint();
	int saidai = 1;
	rep(i, N) {
		A[i] = getint();
		if (A[i] > saidai) saidai = A[i];
	}
	nth_element(A, A + N / 2, A + N);

	if (N % 2) {
		ll kotae = -A[N / 2] - saidai;
		for (int i = N / 2; i < N; i++) {
			kotae += 2 * A[i];
		}
		printf("%lld\n", kotae);
	}
	else {
		ll kotae = - saidai;
		for (int i = N / 2; i < N; i++) {
			kotae += 2 * A[i];
		}
		printf("%lld\n", kotae);
	}


	Would you please return 0;
}

Measured memory_bytes: 4676
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
			String str=scan.nextLine();
			char c[] =str.toCharArray();
			for(int i=0;i<str.length();i++) {
				if(Character.isLowerCase(c[i])) {
					c[i] =Character.toUpperCase(c[i]);
				}else{
					c[i] =Character.toLowerCase(c[i]);
				}
				System.out.print(c[i]);
			}
			
		System.out.printf("\n");
		scan.close();
}
}


Measured memory_bytes: 27004
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;

using namespace std;
using Graph = vector<vector<int>>;
Graph G;
const int AMAX = 100000;
/*int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}

int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}

*/
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N,M;
	cin >> N>>M;
	if (abs(N - M) >= 2)
	{
		cout << 0 << endl;
		return 0;
	}
	else
	{
		ll dog = 1;
		ll Monkey = 1;
		for (int i = 1; i <= N; i++)
		{
			dog *= i;
			dog %= mod;
		}
		for (int i = 1; i <= M; i++)
		{
			Monkey *= i;
			Monkey %= mod;
		}
		if (N == M)
		{
			cout << (2 * dog * Monkey) % mod<< endl;
		}
		else
		{
			cout << (dog * Monkey) % mod<< endl;
		}
		

	}
	

	return 0;

}

Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n;
  if (n == 1)
    cout << "1\n0\n";
  else if (n == 2)
    cout << "2\n0\n11\n";
  else {
    Cout(n - 1);
    cnt = 0;
    rep(i, n - 1) {
      cout << "1";
      rep(j, cnt) cout << "0";
      cout << "1\n";
      cnt++;
    }
  }
  return 0;
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> V;
llong mod = 1000000007;

#define _ cin.tie(0);ios::sync_with_stdio(false);
llong n;
int main(){ _;
  cin>>n;
  V a(n);
  REP(i,n) cin>>a[i];
  VSORT(a);
  llong check;
  int start;
  if(n%2==1){
    check=2;start=1;
  }else{
    check=1;start=0;
  }
  llong ans=1;
  while(start<n-1){
    if(a[start]!=a[start+1]){
      cout<<"0"<<endl;
      return 0;
    }
    start+=2;
    ans=(ans%mod)*(2%mod)%mod;
  }
  cout<<ans<<endl;
  

  return 0;
}


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

namespace ABC043A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;

            var word = Console.ReadLine().Split(' ');

            n = int.Parse(word[0]);
            int sum = 0;
            for(int i = 1; i <= n; i++)
            {
                sum += i;
            }
            Console.WriteLine(sum);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
#include<string.h>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<iostream>
#include<iomanip>
#include<utility>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define fi first
#define sec second
#define mp make_pair
#define pb push_back
#define rep(a,b,c) for(int a=1;a<=b;a+=c)
#define repp(a,b,c,d) for(int a=b;a<=c;a+=d)

const double PI=acos(-1);
const double EPS=1e-12;
const ll MOD=1e9+7;
const int INF=1<<30;


using namespace std;

ll dat[100005];

int main(){
	ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int in,t;
	ll res=1;
	cin>>in;
	dat[0]=3;
	rep(i,in,1){
		cin>>t;
		dat[t+1]++;
		res*=dat[t];
		dat[t]--;
		res%=MOD;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<double,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const LL INF=1<<30;


int main(){
    int k,t;
    cin >> k >> t;
    int a[t],maxi=0;;
    for(int i=0;i<t;i++){
        cin >> a[i];
        maxi=max(maxi,a[i]);
    }
    cout << max(0,2*maxi-k-1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#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 PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


map<char,int> m_min;

int main() {
  int N;
  scanf("%d", &N);
  string s;
  for (int i = 0; i < N; ++i) {
    cin >> s;
    map<char,int> m;
    int leng = SZ(s);
    FOR(j,0,leng-1){
      ++m[s[j]];
    }
    FOR(j,0,25){
      if(i==0){
        m_min[(char)('a'+j)] = m[(char)('a'+j)];
      }
      else{
        chmin(m_min[(char)('a'+j)],m[(char)('a'+j)]);
      }
    }
  }

  FOR(i,0,25){
    int rep = m_min[(char)('a'+i)];
    FOR(j,1,rep){
      cout << (char)('a'+i);
    }
  }



}



Measured memory_bytes: 256
def gcd(a,b): return b if a%b==0 else gcd(b,a%b)
def main():
    a,b,c,d = map(int,input().split())
    h = abs(b-d)
    w = abs(c-a)
    if h==0 or w==0 : return 0
    m = gcd(max(h,w),min(h,w))
    return h+w-m

print(main())


Measured memory_bytes: 3060
package main

import "fmt"

func divBy2(num int) (count int) {
	for count = 0; num%2 == 0; count++ {
		num /= 2
	}
	return count
}

func main() {
	var n int
	var a []int

	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var i int
		fmt.Scan(&i)
		a = append(a, i)
	}

	count := 0
	for _, v := range a {
		count += divBy2(v)
	}
	fmt.Println(count)
}


Measured memory_bytes: 1664
import java.util.*;
  public class Main {
      public static void main(String[] args){
          Scanner sc = new Scanner(System.in);
          int n = sc.nextInt();
          int a,b,c;
          a = sc.nextInt();
          b = sc.nextInt();
          c = sc.nextInt();
          int count = 0;
          if((a<b&&b<c)||(c<b&&b<a)){
          count ++;}
          for(int i=0;i<n-3;i++){
          a = b;
          b = c;
          c = sc.nextInt();
          if((a<b&&b<c)||(c<b&&b<a)){
          count ++;}
          }
          
          
          
          System.out.println(count);
          
          sc.close();
          }
          }

Measured memory_bytes: 23892
def f(k,L,p): 
  m = L
  while m%3 > 0:
    p += [[k+1,20,(m-1)*(3**k)]]
    m = m-1
  if m == 0:
    print(20,len(p))
    for l in p:
      print(" ".join([str(t) for t in l]))
    quit()
  for i in range(3):
    p += [[k+1,k+2,i*(3**k)]]
  m = m//3
  if m > 0:
    return f(k+1,m,p)




f(0,int(input()),[])

Measured memory_bytes: 3188
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <unordered_map>
#include <map>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

//main
int main(){
    struct info{
        int number;
        string name;
        int point;
    };
    int N;
    cin >> N;
    vector<info> information(N);
    rep(i,N){
        information[i].number = i+1;
        cin >> information[i].name >> information[i].point;
    }
    sort(ALL(information),[](const info &x,const info &y){return x.point > y.point;});
    stable_sort(ALL(information),[](const info &x,const info &y){return x.name < y.name;});
    rep(i,N) cout << information[i].number << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll>P;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll mod = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool fl = true;;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
string abc = "abcdefghijklmnopqrstuvwxyz";
struct edge { ll to, cost; };
struct edge1 { ll from, to, cost; };
double pai = 3.141592653589793;

int main() {
	int h, w, n;
	cin >> h >> w >> n;
	int c[1000][1000];
	int l = 0, k = 0;
	for (int i = 1;i <= n;i++) {
		int a;
		cin >> a;
		for (;a > 0;) {
			if (fl) {
				for (;l < w;l++) {
					c[k][l] = i;
					a--;
					if (l == w - 1) {
						k++;
						fl = false;
						break;
					}
					if (a == 0) {
						l++;
						break;
					}
				}
			}
			if (a == 0)break;
				if (!fl) {
					for (;l >= 0;l--) {
						c[k][l] = i;
						a--;
						if (l == 0) {
							k++;
							fl = true;
							break;
						}
						if (a == 0) {
							l--;
							break;
						}
					}
				}
				if (a == 0)break;
		}
	}
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			cout << c[i][j] << ' ';
		}
		cout << endl;
	}
	}

Measured memory_bytes: 2304
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
const vector<int> dy={-1,0,1,0},dx={0,-1,0,1};
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>void debag(const vector<T> &a){cerr<<"debag :";for(auto v:a)cerr<<v<<" ";cerr<<"\n";}
template<class T>void print(const vector<T> &a){for(auto v:a)cout<<v<<" ";cout<<"\n";}
int main(){
    int n;
    cin>>n;
    V<P> a(n);
    ll v=-inf,x=inf,y=-inf,z=inf;
    for(int i=0;i<n;i++){
        cin>>a[i].fi>>a[i].se;
        chmax(v,a[i].fi-a[i].se);
        chmin(x,a[i].fi-a[i].se);
        chmax(y,a[i].fi+a[i].se);
        chmin(z,a[i].fi+a[i].se);        
    }
    cout<<max(v-x,y-z)<<"\n";
}


Measured memory_bytes: 6372
#include <stdio.h>

int main() {
	int n, sum = 0, a, b;
	double t;

	scanf("%d %d %lf", &a, &b, &t);
	t += 0.5;

	for (n = a; n < t;n += a) {
		sum += b;
	}
	printf("%d\n", sum);

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){
    int a,b,c,d,e,f,h;

 
    scanf("%d", &a);
    scanf("%d", &b);
    
	c = a + b;
    d = a - b;
    e = a * b;
    h = (f = c,d,e);
    

	if((c>=d) && (c>=e)){
	
	f=c;	

	}

	
	if((d>=c) && (d>=e)){
	f=d;

	}

		
	if((e>=d) && (e>=c)){
	f=e;

}

	printf("%d",f);


	
	
	return 0 ;
	
}

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

int main(void)
{
	int id;

	while (scanf("%d", &id), id){
		char oct[16];
		int i;

		sprintf(oct, "%o", id);
		for (i = 0; i < strlen(oct); i++){
			printf("%c", "01235789"[oct[i] - '0']);
		}
		puts("");
	}

	return (0);
}

Measured memory_bytes: 624
#include<bits/stdc++.h>
using namespace std;
int m1,d1,m2,d2;
const int month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int main()
{
	scanf("%d%d%d%d",&m1,&d1,&m2,&d2);
	if(d1==month[m1])
		printf("%d\n",1);
	else
		printf("%d\n",0);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
arr = [i for i in range(0,N)]
for i in range(0,N):
    arr[i] = int(input())

arr.sort()
t=0
new=[]
for ii in arr:
    if t==0:
        new.append(ii)
        t+=1
        continue
    if arr[t-1]==ii:
        t+=1
        continue
    else:
        new.append(ii)
    t+=1
print(len(new))


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

int main() {
  string a,b,c;
  
  cin >> a;
  
  if((a.at(0)=='a')||(a.at(0)=='i')||(a.at(0)=='u')||(a.at(0)=='e')||(a.at(0)=='o'))
    cout << "vowel";
  else
    cout << "consonant";
  

}

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

public class Main {


	public static void main(String[] args) {
		Main ans = new Main();
		ans.solve();
	}

	private void solve() {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		String L = sc.nextLine();

		int N = S.length();
		int M = L.length();

		long [][] dp =  new long[N+1][M+1];


		for(int i=N-1;i>=0;i--){
			for(int j=M-1;j>=0;j--) {
				char a = S.charAt(i);
				char b = L.charAt(j);

				if (a==b) dp[i][j] = 1+ dp[i+1][j+1];
				else {
					dp[i][j] = Math.max(dp[i+1][j], dp[i][j+1]);
				}
			}
		}

		int i=0,j=0;
		while(i<N && j<M) {
			char a = S.charAt(i);
			char b = L.charAt(j);
			if (a==b) {
				System.out.printf("%c", S.charAt(i));
				i++;
				j++;
			} else {
				if (dp[i+1][j]>=dp[i][j+1]) i++;
				else j++;
			}
		}
	}
}

Measured memory_bytes: 110088
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

s = list(input())

for i, ch in enumerate(s):
    if(ch=='?'):
        s[i] = 'D'

print(''.join(s))

Measured memory_bytes: 78704
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

void solve(void)
{
  int N;cin>>N;
  int cnt = 0;
  for (int i = 0; i < N; i++)
  {
    int X;cin>>X;
    if(X%2 == 1)cnt++;

  }
  if(cnt%2 == 1)
  {
    cout<<"NO"<<endl;
  }
  else
  {
    cout<<"YES"<<endl;
  }
  
  
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}


Measured memory_bytes: 256
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int K, X;
    cin >> K >> X;

    for (int i = X - K + 1; i <= X + K - 1; i++) {
        cout << i << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a1 = new int[N];
        int[] a2 = new int[N];
        for(int i=0; i<N; i++){
          a1[i] = sc.nextInt();
        }
        for(int i=0; i<N; i++){
          a2[i] = sc.nextInt();
        }
        int max = 0;
        int total = 0;
        for(int i=0; i<N; i++){
          for(int z=0; z<=i; z++) total += a1[z];
          for(int j=i; j<N; j++) total += a2[j];
          if(max < total) max = total;
          total = 0;
        }
        System.out.print(max);
        
}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;
typedef vector<map<lli,lli>> graph;

int n;
vll s;
lli sum;
mat dp;

int main(){
	cin >> n;
	s = vll(n);
	for(lli i = 0;i < n;i++)
		cin >> s[i];
	sum = accumulate(s.begin(), s.end(),0);
	dp = mat(n+1,vll(sum+1));
	dp[0][0] = 1;
	for(lli i = 0;i < n;i++){
		for(lli j = 0;j <= sum-s[i];j++){
			dp[i+1][j] |= dp[i][j];
			dp[i+1][j+s[i]] |= dp[i][j];
		}
	}
	for(lli i = sum;i >= 0;i--){
		if(dp[n][i] && i%10){
			cout << i << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 8192
import java.util.*;
import static java.lang.Math.*;
class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		Deque<String[]> que = new LinkedList<String[]>();
		while(in.hasNext()) {
			que.push(in.nextLine().split(","));
		}
		System.out.println(solve(que));
	}
	static String solve(Deque<String[]> que) {
		String now = "A";
		while(!que.isEmpty()) {
			String[] pair = que.pollLast();
			now = now.equals(pair[0])?pair[1]:now.equals(pair[1])?pair[0]:now;
		}
		return now;
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	int x,t;
	int ans=0;
	
	cin>>x>>t;
	if(x>t)
	{
		ans=x-t;
	}else{
		ans=0;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (a, b, c, d) = readLine()!!.split(" ").map { it.toLong() }

    val gcd = calcGcd(c, d)

    val bX = b - (b / c) - (b / d) + (b / ((c * d) / gcd))

    val aX = (a - 1) - ((a - 1) / c) - ((a - 1) / d) + ((a - 1) / ((c * d) / gcd))

    println(bX - aX)
}

fun calcGcd(c: Long, d: Long): Long {
    return if (d == 0.toLong()) {
        c
    } else {
        calcGcd(d, c % d)
    }
}


Measured memory_bytes: 37920