akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <map>
#include <deque>
#include <queue>
#include <tuple>
using namespace std;

#define prec(i) cout << fixed << setprecision(i)

void outPut_YN(bool isYes) {
	if (isYes)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

const long long MOD = 1000000007;

long long fact(long long k) {
	long long sum = 1;
	for (long long i = 2; i <= k; i++)
		sum *= i;

	return sum;
}

long long fact_mod(long long k) {
	long long sum = 1;
	for (long long i = 2; i <= k; i++)
		sum = (sum * i) % MOD;

	return sum;
}

int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}

long long pow_mod(int a, int b) {
	long long ans = 1;
	for (int i = 0; i < b; i++)
		ans = (ans * a) % MOD;

	return ans;
}

long long powll(long long a, long long  b) {
	long long ans = 1;
	for (long long i = 0; i < b; i++)
		ans = ans * a;

	return ans;
}

long long modinv(long long a) {

	long long b = MOD, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= MOD;
	if (u < 0) u += MOD;

	return u;
}

long long _gcd(long long a, long long b)
{
	if (a < b)
		swap(a, b);

	if (a % b == 0)
		return b;
	else
		return _gcd(b, a % b);
}

long long _lcm(long long a, long long b)
{
	return (((a * b) % MOD) * modinv(_gcd(a, b))) % MOD;
}

long long ncr(long long n, long long r) {
	long long sum = 1;
	for (long long i = r + 1; i <= n; i++)
		sum *= i;

	return sum;
}



int main()
{

	long long n, k;
	cin >> n >> k;

	vector<long long> p(n), c(n), loop(n);
	
	for(int i = 0; i < n; i++)
		cin >> p[i];
	for (int i = 0; i < n; i++)
		cin >> c[i];

	vector<vector<long long>> pts(n);

	for (int i = 0; i < n; i++) {
		pts[i] = vector<long long>(n);
		int j = 0, pos = i;
		do{
			pos = p[pos] - 1;
			if(j == 0)
				pts[i][j] = c[pos];
			else
				pts[i][j] = pts[i][j - 1] + c[pos];
			j++;
		} while (pos != i);
		loop[i] = j;
	}

	long long max = -1000000000000000000;
	for (int i = 0; i < n; i++) {
		if (loop[i] >= k) {
			loop[i] = k;
		}
		else {
			long long loopPts = pts[i][loop[i] - 1];
			if (loopPts > 0) {
				long long loopCnt = k / loop[i];
				long long loopEndPos = k % loop[i];
				for (int j = 0; j < loopEndPos; j++)
					pts[i][j] += loopPts * loopCnt;

				for (int j = loopEndPos; j < loop[i]; j++)
					pts[i][j] += loopPts * (loopCnt - 1);
			}
		}
		long long _max = pts[i][0];
		for (int j = 1; j < loop[i]; j++) {
			if (pts[i][j] > _max)
				_max = pts[i][j];
		}
		if (_max > max)
			max = _max;
		
	}

	cout << max << endl;

	return 0;
}

Measured memory_bytes: 199248
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll K;
    cin >> K;
    ll now=0,keta=1;
    ll cnt=0;
    while(cnt<1e7){
        cnt++;
        now+=7*keta;
        if(now%K==0){
            cout << cnt << endl;
            return 0;
        }
        keta*=10;
        keta%=K;
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
#define itn int
bool dbg = false;
string S;
void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> S;
    itn ans = 0;
    if (S == "SUN")
        ans = 7;
    else if (S == "MON") {
        ans = 6;
    } else if (S == "TUE")
        ans = 5;
    else if (S == "WED")
        ans = 4;
    else if (S == "THU")
        ans = 3;
    else if (S == "FRI")
        ans = 2;
    else if (S == "SAT")
        ans = 1;
    cout << ans << endl;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
long int n,i,j,ans,mans=0,max=-1,r;
long int d[100001];
for(i=0;i<100001;i++)d[i]=0;
cin>>n;
if(n==1){cout<<1;return 0;}
for(i=0;i<n;i++)
{
cin>>r;
d[r]++;
if(r>max)max=r;
}
for(i=0;i<=max;i++)
{
ans=0;
if(i>0)ans+=d[i-1];
ans+=d[i];
if(i<max)ans+=d[i+1];
if(ans>mans)mans=ans;
}
cout<<mans;
return 0;
}


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

int main(){
	long long int h,w;
	cin>>h>>w;
	long long int ans=0;
	ans=h*w;
	if((h*w)%2==1) ans=ans+1;
	if(h==1 || w==1){
		 cout<<1;
	}else{
		cout<<ans/2;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  vector<int>a(m);
  vector<int>b(m);
  for(int i=0;i<m;i++)
  {
    int B;
    cin>>a[i]>>B;
    for(int j=0;j<B;j++)
    {
      int t;
      cin>>t;
      b[i]|=(1<<(t-1));
    }
  }
  //for(int i=0;i<m;i++)cout<<b[i]<<endl;
  vector<int>d(1<<n,1000000000);
  d[0]=0;
  for(int i=0;i<m;i++)
  {
    for(int j=0;j<(1<<n);j++)
    {
      if(d[j|b[i]]>(d[j]+a[i]))
        d[j|b[i]]=d[j]+a[i];
    }
  }
  if(d[(1<<n)-1]==1000000000)cout<<-1<<endl;
  else cout<<d[(1<<n)-1]<<endl;
                        
  return 0;
 }
   
    

Measured memory_bytes: 3632
import Data.List
import Data.Char
import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as BS8

main :: IO ()
main = do
    n <- fst . fromJust . BS8.readInt <$> BS8.getLine
    p <- unfoldr (BS8.readInt . BS8.dropWhile isSpace) <$> BS8.getLine
    q <- unfoldr (BS8.readInt . BS8.dropWhile isSpace) <$> BS8.getLine
    
    let l = sort $ permutations [1..n]

    print $ abs $ (fromJust $ elemIndex p l) - (fromJust $ elemIndex q l)


Measured memory_bytes: 21116
#include<iostream>
#include<algorithm>
#include<vector>
#include<climits>
using namespace std;
static const int MAX=100;
static const long long INFTY = (1LL<<32);
typedef long long ll;
ll amari=1000000007;
int n;

int main()
{
  cin >> n;
  string s1;
  string s2;
  cin >> s1;
  cin >> s2;
  ll ans=0;
  bool tate=false;
  for(int i=0;i<n;)
    {
      if(s1[i]==s2[i])
	{
	  if(i==0) ans+=3;
	  else if(tate==true) ans*=2;
	  tate=true;
	  i++;
	  ans%=amari;
	}
      else
	{
	  if(i==0) ans+=6;
	  else if(tate==false) ans*=3;
	  else ans*=2;
	  tate=false;
	  i+=2;
	  ans%=amari;
	}
    }
  cout << ans%amari << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool is_square(int n)
{
    for (int i = 0; i <= n; i++)
    {
        if (i * i == n)
        {
            return true;
        }
    }
    return false;
}

int main()
{
    string s;
    ll k;
    cin >> s >> k;
    ll first_not1 = 1000000000000000000;
    int num = 0;
    for (size_t i = 0; i < s.length(); i++)
    {
        if (s[i] != '1')
        {
            first_not1 = i;
            num = s[i] - '0';
            break;
        }
    }
    if (k <= first_not1)
    {
        cout << 1 << endl;
    }
    else
    {
        cout << num << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc131/tasks/abc131_d
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize,
        jobs: [(i64, i64); n]
    };

    let mut now = 0;
    let mut jobs = jobs;
    jobs.sort_by_key(|k| k.1);

    let mut ok = true;
    for (time,till) in jobs {
        if now+time > till {
            ok = false;
            break;
        }
        now += time;
    }
    println!("{}", ifv!(ok, "Yes", "No"));
}


Measured memory_bytes: 13560
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		int[] dp = new int[394];
		Arrays.fill(dp, -1);
		dp[0] = 0;
		for (int i = 0; i < N; ++i) {
			int s = sc.nextInt();
			int l = sc.nextInt();
			int p = sc.nextInt();
			for (int j = 0; j < dp.length - s; ++j) {
				if (dp[j] == -1) continue;
				for (int k = s; k <= l && j + k < dp.length; ++k) {
					dp[j + k] = Math.max(dp[j + k], dp[j] + p);
				}
			}
		}
		int M = sc.nextInt();
		int[] ans = new int[M];
		for (int i = 0; i < M; ++i) {
			ans[i] = dp[sc.nextInt()];
			if (ans[i] == -1) {
				System.out.println(-1);
				return;
			}
		}
		for (int i = 0; i < M; ++i) {
			System.out.println(ans[i]);
		}
	}
}

Measured memory_bytes: 24164
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;
typedef long long int lli;



int main(void)
{
	string S; cin >> S;
	char ans = '1';
	lli K; cin >> K;
	rep(i, 0, K) {
		if (i >= S.size())break;
		if (S[i] != '1') { 
			ans = S[i];
			break;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

type pair struct {
	fi int
	se int
}

var data [3][30]int
var d [][]int
var c [][]int

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	//予備
	n := iScan()
	C := iScan()
	d := make([][]int, C)
	c := make([][]int, n)
	for i := 0; i < C; i++ {
		d[i] = make([]int, C)
		for j := 0; j < C; j++ {
			d[i][j] = iScan()
		}
	}
	for i := 0; i < n; i++ {
		c[i] = make([]int, n)
		for j := 0; j < n; j++ {
			c[i][j] = iScan()
			data[(i+j)%3][c[i][j]-1]++
		}
	}
	min1 := -1
	//c1をあまり0の時の色,c2をあまり１の時の色
	for c1 := 0; c1 < C; c1++ {
		for c2 := 0; c2 < C; c2++ {
			for c3 := 0; c3 < C; c3++ {
				start := 0
				if c1 == c2 || c2 == c3 || c1 == c3 {
					continue
				} else {
					for i := 0; i < C; i++ {
						start += data[0][i] * d[i][c1]
					}
					for i := 0; i < C; i++ {
						start += data[1][i] * d[i][c2]
					}
					for i := 0; i < C; i++ {
						start += data[2][i] * d[i][c3]
					}
					if min1 == -1 {
						min1 = start
					}
					if min1 > start {
						min1 = start
					}
				}
			}
		}
	}
	fmt.Println(min1)
}


Measured memory_bytes: 4392
#include <algorithm>
//#include <atcoder/fenwicktree>
#include "atcoder/all"
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using namespace atcoder;

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) fixed << setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, Q;
  cin >> N >> Q;
  vl A(N);
  REP(i, N) cin >> A[i];
  fenwick_tree<ll> fw(N);
  REP(i, N) { fw.add(i, A[i]); }
  REP(i, Q) {
    ll t = 0;
    cin >> t;
    ll x1, x2;
    cin >> x1 >> x2;
    if (t == 0)
      fw.add(x1, x2);
    else
      cout << fw.sum(x1, x2) << endl;
  }

  return 0;
}


Measured memory_bytes: 12160
/* #region template */
#![allow(unused_imports)]
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, stdout, Bytes, Read, Stdin, StdinLock, Stdout, StdoutLock, Write};
use std::iter::{repeat, repeat_with};
use std::mem::swap;
use std::str::FromStr;
#[allow(dead_code)]
struct Io<'a> {
    reader: Bytes<StdinLock<'a>>,
    writer: StdoutLock<'a>,
    in_buf: [u8; BUF_SIZE],
}
#[allow(dead_code)]
impl<'a> Io<'a> {
    fn new(stdin: &'a Stdin, stdout: &'a Stdout) -> Io<'a> {
        Io {
            reader: stdin.lock().bytes(),
            writer: stdout.lock(),
            in_buf: [0; BUF_SIZE],
        }
    }
    fn r<T: FromStr>(&mut self) -> T {
        let mut count = 0;
        loop {
            match self.reader.next() {
                Some(Ok(b' ')) | Some(Ok(b'\n')) => break,
                Some(Ok(c)) => self.in_buf[count] = c,
                _ => panic!(),
            }
            count += 1;
        }

        let s = unsafe { std::str::from_utf8_unchecked(&self.in_buf[0..count]) };
        s.parse().unwrap_or_else(|_| panic!())
    }
    fn ru(&mut self) -> usize {
        self.r()
    }
    fn iter<'b, T>(&'b mut self) -> IoIter<'a, 'b, T> {
        IoIter::new(self)
    }
    fn c<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        self.iter().take(n).collect()
    }
    fn cu(&mut self, n: usize) -> Vec<usize> {
        self.c(n)
    }
    fn w<T: std::fmt::Display>(&mut self, v: T) {
        writeln!(self.writer, "{}", v).unwrap();
    }
    fn wn<T: std::fmt::Display>(&mut self, v: T) {
        write!(self.writer, "{}", v).unwrap();
    }
}
#[allow(dead_code)]
struct IoIter<'a: 'b, 'b, T> {
    io: &'b mut Io<'a>,
    m: std::marker::PhantomData<T>,
}
#[allow(dead_code)]
impl<'a: 'b, 'b, T> IoIter<'a, 'b, T> {
    fn new(io: &'b mut Io<'a>) -> IoIter<'a, 'b, T> {
        IoIter {
            io,
            m: std::marker::PhantomData,
        }
    }
}
impl<'a, 'b, T: FromStr> Iterator for IoIter<'a, 'b, T> {
    type Item = T;
    fn next(&mut self) -> Option<Self::Item> {
        Some(self.io.r())
    }
}
fn main() {
    let stdin = stdin();
    let stdout = stdout();
    let mut io = Io::new(&stdin, &stdout);
    unsafe {
        solve(&mut io);
    }
}
/* #endregion */

const BUF_SIZE: usize = 1024;

unsafe fn solve(io: &mut Io) {
    let n = io.r();

    let mut t = HashMap::<isize, isize>::new();
    let mut count = 0;
    for i in 1..=n {
        let ai: isize = io.r();
        if let Some(v) = t.get(&(i - ai)) {
            count += v;
        }

        let k = ai + i;
        if let Some(v) = t.get_mut(&k) {
            *v += 1;
        } else {
            t.insert(k, 1);
        }
    }

    io.w(count);
}


Measured memory_bytes: 8700
#include<iostream>
#include<vector>
#include<algorithm>

int main(void){
    int n;
    std::cin >> n;

    std::vector<int> v(n);
    for(int i = 0; i < n; i++){
        std::cin >> v.at(i);
    }

    std::sort(v.begin(), v.end());

    double temp = v.at(0);

    for(int i = 1; i < n; i++){
        temp = (temp + v.at(i)) / 2.0;
    }

    printf("%lf\n",temp);
    return 0;
}

Measured memory_bytes: 256
import sys
INF = float('inf')
n = int(input())
adja_matrix = [[int(i) for i in line.split()] for line in sys.stdin.read().splitlines()]
condition = ['INIT'] * n
distance = [INF] * n
p = [0] * n
distance[0] = 0
p[0] = -1

while True:
    mincost = INF
    for i in range(n):
        if condition[i] != 'FINISH' and distance[i] < mincost:
            mincost = distance[i]
            u = i

    if mincost == INF:
        break

    condition[u] = 'FINISH'

    for v in range(n):
        if condition[v] != 'FINISH' and adja_matrix[u][v] != -1:
            if adja_matrix[u][v] < distance[v]:
                distance[v] = adja_matrix[u][v]
                p[v] = u
                condition[v] = 'CHECK'

sum = 0
for i in range(n):
    if p[i] != -1:
        sum += adja_matrix[i][p[i]]

print(sum)


Measured memory_bytes: 5980
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  string s="";
  cin >> n;
  while(1){
    if(n==0){
      if(s==""){
        cout << 0 << endl;
      }else{
        cout << s << endl;
      }
      return 0;
    }
    if(n%(-2)==0){
      s.insert(0,"0");
      n/=(-2);
    }else if(n%(-2)==1){
      s.insert(0,"1");
      n/=(-2);
    }else{
      s.insert(0,"1");
      n/=(-2);
      n++;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

#include <sstream>
#include <fstream>
#include <cmath>
#include <vector>


using namespace std;


void check( string s ){
	
	cout << s << endl;
}

int main( int argc , char ** argv ){
	
	string S;
	cin >> S;

	//check(S);

	cout << S.substr(0 , 4);
	cout << " ";
	cout << S.substr(4);
	cout << endl;
	
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)

const ll MOD = 1000000007;

using namespace std;

ll a[100005];

int main()
{
	int n;
	cin >> n;
	ll max = 0;
	REP(i, n)
	{
		cin >> a[i];
		max = std::max(max, a[i]);
	}

	ll c = 0;
	REP(i, n)
	{
		if (i == max)continue;
		if (abs(c - max / 2) > abs(a[i] - max / 2)) {
			c = a[i];
		}
	}

	cout << max << " " << c;
	return 0;
}

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

namespace AtCoder_20190707_1
{    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            if (s.Contains("RRR"))
            {
                Console.WriteLine("3");
            }
            else if (s.Contains("RR"))
            {
                Console.WriteLine("2");
            }
            else if (s.Contains("R"))
            {
                Console.WriteLine("1");
            }
            else
            {
                Console.WriteLine("0");
            }
        }
    }
}

Measured memory_bytes: 25796
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int digit_sum(int n) {
  int sum=n%10;
  while(n!=0) {
    n/=10;
    sum+=n%10;
  }
  return sum;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}

int main() {
  string s;
  cin >> s;
  int n = s.length();
  int x=(n-1)/2;
  for(x;x>=0;x--) {
    bool flg=true;
    REP(i,x) {
      if(s[i]!=s[i+x]) flg=false;
    }
    if(flg) {
      cout << 2*x << endl;
      return 0;
    }
  }
  cout << "0" << endl;
  return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) (int)((a).size())
typedef long long ll;
typedef pair<int,int> PI;

int main(int argc, char *argv[])
{
  int d,n,b;
  cin >> d >> n >> b;
  vector<PI> obj;
  rep(i,n){
    int p,h;
    cin >> p >> h;
    obj.pb(mp(p,h));
  }
  
  double ans = 1e30;

  for(int k = 1; k <= b+1; ++k){
    //if(d%k > 0) continue;
    
    {
      bool ok = 1;
      double haba = d*1./k;
      rep(j,n) ok &= obj[j].F * k % d != 0;
      if(!ok) continue;
    }
    
    
    double low = 0,up = 1e18;
    
    rep(bi_loop,1000){
      double vy = (low+up)/2;
      double vx = d/2./k/vy;
      bool ok = 1;
      double haba = d*1./k;
      
      rep(i,n){
        double x = fmod(obj[i].F, haba);
        double y = -(1./2/vx/vx)*x*x+(vy/vx)*x;
        ok &=  y >= obj[i].S;
      }
      if(!ok){
        low = vy;
        continue;
      }

      up = vy;
    }
    
    //cout << low << " " << up << endl;
    
    double L = d/2./k;
    
    if(L > low*low)
      {
      /*
        vy = sqrt(L);
       */
      double vy = sqrt(L);
      double vx = d/2./k/vy;
      double tans = sqrt(vx*vx+vy*vy);
      ans = min(ans, tans);
    }
    else
      {
      double vy = low;
      double vx = d/2./k/vy;
      double tans = sqrt(vx*vx+vy*vy);      
      ans = min(ans,tans);
    }
  }


  printf("%.18f\n", ans);
  //cout << ans << endl;
  
  return 0;
}

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

int get(int n){
  int sum_n = pow(10,n)-1;
  int sum_n1 = pow(10,n-1)-1;
  return sum_n-sum_n1;
}        
    
int main(){
  int N;
  cin >>N;
  string N_str = to_string(N);
  int n = N_str.size();
 // cout <<n<<endl;
  int sum =0;
  for(int i=1;i<n;i++){
    if(i%2 ==1){
      sum += get(i);
    }
  }
  if (n%2 ==1){
    sum += N - (pow(10,n-1)-1);
  }
  cout <<sum<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
void __dump(long long x){cerr << x;}
void __dump(long double x){cerr << fixed << setprecision(3) << x;}
void __dump(int x){cerr << x;}
void __dump(char x){cerr << '\'' << x << '\'';}
void __dump(const string &x){cerr << '"' << x << '"';}
void __dump(const char *x){cerr << '"' << x << '"';}
void __dump(bool x){cerr << (x ? "true" : "false");}
void _dump(){cerr << "\n";}
template <typename T, typename U> void __dump(const pair<T, U> &x){cerr << '{'; __dump(x.first); cerr << ','; __dump(x.second); cerr << '}';}
template <typename T> void __dump(const T& x){int f=0; cerr << '{'; for(auto&i:x) cerr << (f++ ? "," : ""), __dump(i); cerr << "}";}
template <typename T, typename ... U> void _dump(T t, U ... u){__dump(t); if(sizeof...(u)) cerr << ", "; _dump(u...);}
#define dump(x ...) cerr  <<  "|| "  <<  # x  <<  " = ", _dump(x) 
//#define int long long
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define size(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define ln '\n'
#define __ ' '
#define LL long long
#define LD long double
#define pii pair<int,int>
const int INF = 2e9;
const int NN = 12;
int n,m;
string grid[NN+1];

string getCol(int c){
	string res;
	for(int i=1; i<=n; ++i) res += grid[i][c-1];
	// dump(c, res);
	return res;
}

bool checkCols(){
	// for(int i=1; i<=n; ++i) dump(grid[i]);
	// dump(ln);
	set<string> cols;
	map<string, int> colsOcc;
	for(int c=1; c<=m; ++c) ++colsOcc[getCol(c)];
	for(auto ele: colsOcc) cols.insert(ele.first);

	bool foundPalind = false;
	while(!cols.empty()){
		string cur = *cols.begin();
		--colsOcc[cur];
		if(!colsOcc[cur]) cols.erase(cur);
		
		string rev = cur;
		reverse(all(rev));
		if(cols.count(rev)){
			--colsOcc[rev];
			if(!colsOcc[rev]) cols.erase(rev);
			continue;
		}

		if(!(m&1)) return false;
		if(!(cur == rev)) return false;
		if(foundPalind) return false;
		foundPalind = true;
	}

	return true;
}

bool possible(int i){
	int j = n-i+1;
	if(i >= j){
		if(checkCols()) return true;
		if(i == j){
			for(int k=1; k<=n; ++k){
				swap(grid[k], grid[i]);
				if(checkCols()) return true;
				swap(grid[k], grid[i]);
			}
		}
		return false;
	}

	for(int k = i+1; k<=j; ++k){
		// choosing pair(i,k)
		swap(grid[k], grid[j]);
		if(possible(i+1)) return true;
		swap(grid[k], grid[j]);
	}
	return false;
}

int32_t main(){ FAST;
	cin >> n >> m;
	for(int i=1; i<=n; ++i) cin >> grid[i];

	if(possible(1)) cout << "YES" << ln;
	else cout << "NO" << ln;
}

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

signed main(void){
  
  int A,B; cin >> A >> B;
  
  
  for(int i = 1; i <= 1000; i++){
    
    double res = i;
    int r1 = (int)(res*0.08);
    int r2 = (int)(res*0.10);
    
    if( r1 == A && r2 == B ){ 
      
      cout << i << endl; return 0;
    }
  }
  
  
  cout << "-1" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

int main() {
  while(1){
    int N,M;
    cin>>N>>M;
    if(!N)break;
    int r;
    cin>>r;
    vector<vector<short>> v(M,vector<short>(1300));
    REP(i,r){
      int t,n,m,s;
      cin>>t>>n>>m>>s;
      --m;
      if(s) ++v[m][t];
      else --v[m][t];
    }
    vector<vector<short>> sum(M,vector<short>(1301));
    REP(i,M) partial_sum(begin(v[i]),end(v[i]),begin(sum[i]));
    int q;
    cin>>q;
    REP(i,q){
      int ts,te,m;
      cin>>ts>>te>>m;
      --m;
      int tu=0;
      for(int j=ts;j<te;++j){
        if(sum[m][j])
          ++tu;
      }
      cout<<tu<<endl;
    }
  }
  return 0;
}

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


int main(){
  
  int N, X, i, Sum = 0, D = 0, L;
  cin >> N >> X;
 
  for (i = 0; i < N; i++){
    
    cin >> L;
    D += L;
    if(D > X){
      cout << i + 1 << endl;
      return 0;
    }
  }
  cout << N + 1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  long double a, b, x;
  long double t, pie;
  pie = 2.0 * (long double)asin(1.0);
  cin >> a >> b >> x;
  if (a * a * b < 2 * x) {
    t = (long double)atan2(2 * b - ((2 * x) / (a * a)), a);
    t = t * 180.0 / pie;
  } else {
    t = (long double)atan2((2 * x) / (a * b), b);
    t = 90.0 - (t * 180.0 / pie);
  }
  cout << t << endl;
}

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

using namespace std;

#define pi 3.1415926535898

int main()
{
    long long ass, tc, a, ans=0; cin >> ass >> tc;

    for(int i = 0; i < tc; i++)
    {
        cin >> a;
        ans += a;
    }

    if(ans > ass) cout << "-1" << endl;
    else cout << ass-ans << endl;

    return 0;
}


Measured memory_bytes: 3624
A, B, C= map(int, input().split())

from collections import deque
loop = set()
l = deque([(A*i)%B for i in range(1, 150)])
for i in range(150):
    pop = l.popleft()
    if pop == C:
        print("YES")
        break
    if pop in loop:
        print("NO")
        break
    else:
        loop.add(pop)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main() {
    string s;
    cin >> s;
    ll k;
    cin >> k;

    if(s.size()==1){
        cout << s << endl;
        return 0;
    }
    int p=0;
    while(s[p] == '1'){p++;}
    if(k<=p){
        cout << s[0] << endl;
    }else{
        cout << s[p] << endl;
    }
    return 0;
}


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

int get(int n){
    string ans;
    cout << n << endl;
    cin >> ans;
    if(ans == "Male"){
        return 1;
    }else if(ans == "Female"){
        return 2;
    }else if(ans == "Vacant"){
        return 0;
    }
}

int main(){
    int N;  cin >> N;
    vector<int> seat(N, -1);
    int l = 0, r = N-1;
    if(seat[l] == -1){
        seat[l] = get(l);
        if(seat[l] == 0){
            cout << l << endl;
            return 0;
        }
    }
    if(seat[r] == -1){
        seat[r] = get(r);
        if(seat[r] == 0){
            cout << r << endl;
            return 0;
        }
    }

    while(true){
        int m = (l+r)/2;
        if(seat[m] == -1){
            seat[m] = get(m);
            if(seat[m] == 0){
                cout << m << endl;
                return 0;
            }
        }
        if((m-l)%2 == 1 && seat[m] == seat[l]){
            r = m;
        }
        if((m-l)%2 == 0 && seat[m] != seat[l]){
            r = m;
        }
        if((r-m)%2 == 1 && seat[m] == seat[r]){
            l = m;
        }
        if((r-m)%2 == 0 && seat[m] != seat[r]){
            l = m;
        }
    }
}


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

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

int main()
{
    string N;
    cin >> N;
    if(N[0] == N[1] && N[1] == N[2] || N[1] == N[2] && N[2] == N[3]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

void solve(long long N) {
    if (N % 2 == 0) {
        cout << N << endl;
    } else {
        cout << 2 * N << endl;
    }
}

int main() {
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3668
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define F(i,a,n) for(int i=a; i<n; i++)

int compare(const void *b1, const void *b2){
  return strcmp((const char**)b1,(const char**)b2);
}

int main(){
  int n;
  scanf("%d",&n);
  char s[n][20];
  int count=0;
  F(i,0,n){
    scanf("%s",s[i]);
  }
  qsort(s,n,sizeof(*s),compare);
  F(i,0,n-1){
    if(strcmp(s[i],s[i+1])==0) count++;
  }
  printf("%d\n",n-count);
  
  return 0;
}

Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define trace(x)     cerr<<#x<<":"<<x<<endl;
#define trace2(x,y) cerr<<#x<<":"<<x<<"|"<<#y<<":"<<y<<endl;
#define trace3(x,y,z) cerr<<#x<<":"<<x<<"|"<<#y<<":"<<y<<"|"<<#z<<":"<<z<<endl;
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

int main() {
	fast_io;
	ll n;
	cin >> n;
	vl a(n + 1);
	ll ans = 0;
	for(int i=1;i<=n;i++)cin>>a[i];
	for (int i = 1; i <= n; i++) {
		ll csum = 0;
		if(a[i]>0){
			for(int j=i;j<=n;j++){
				if(a[j] == 0){
					break;
				}
				csum += a[j];
				i++;
			}
		}
		ans = ans + (csum/2);
	}
	
	cout << ans;
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
	int n, num[120];
	long long int dp[120][30] = {0};
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> num[i];
	}

	dp[0][num[0]] = 1;
	for (int i = 0; i < n-2; i++){
		for (int j = 0; j <= 20 ; j++){
			if (j + num[i+1] <= 20){
				dp[i+1][j + num[i+1]] += dp[i][j];
			}
			if (j - num[i+1] >= 0){
				dp[i+1][j - num[i+1]] += dp[i][j];
			}
		}
	}
	/*for (int i = 0; i <= 20; i++){
		for (int j = 0; j < n; j++){
			cout << dp[j][i] << " ";
		}
		cout << endl;
	}*/
	cout << dp[n-2][num[n-1]] << '\n';

	return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	switch (n) {
	case 22:cout << "Christmas Eve Eve Eve" << endl; break;
	case 23:cout << "Christmas Eve Eve" << endl; break;
	case 24:cout << "Christmas Eve" << endl; break;
	case 25:cout << "Christmas" << endl; break;
	}
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

const (
	i int = iota
	o
	t
	j
	l
)

func main() {
	as := scanInts(7)
	im := as[i] % 2
	jm := as[j] % 2
	lm := as[l] % 2

	ans := as[o] + as[i]-im + as[j]-jm + as[l]-lm
	if im+jm+lm == 2 && as[i]!=0 && as[j]!=0 && as[l]!=0{
		ans += 1
	}
	if im+jm+lm == 3 {
		ans += 3
	}
	fmt.Println(ans)
}

func scanInts(length int64) []int64 {
	ints := make([]int64, length)
	for i := range iter(0, length) {
		var x int64
		_, _ = fmt.Scan(&x)
		ints[i] = x
	}
	return ints
}

func iter(l int64, r int64) chan int64 {
	var i int64 = l
	c := make(chan int64)
	run := func() {
		for i < r {
			c <- i
			i += 1
		}
		close(c)
	}
	go run()
	return c
}

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

int main() {
    string s;
    long long k;
    cin >> s >> k;
    long long a = 0, b = 0, n = s.size();
    char now = s[0];
    for (int i = 0; i < n; i++) {
        if (s[i] == now) a++;
        else break;
    } 
    now = s[n-1];
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == now) b++;
        else break;
    }
    long long ans;
    if (a == n) {
        ans = a * k / 2;
    } else {
        now = s[0];
        int sum = 0, cnt = 0;
        for (int i = 0; i < n; i++) {
            if (s[i] != now) {
                now = s[i];
                sum += (cnt / 2);
                cnt = 1;
            } else {
                cnt++;
                if (i == n - 1) {
                    sum += (cnt / 2);
                }
            }
        }
        if (s[0] == s[n-1]) ans = sum * k - (a/2 + b/2 - (a+b) / 2) * (k-1);
        else ans = sum * k;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
isSimilarWithCoffee :: String -> Maybe Bool
isSimilarWithCoffee str =
    Just
        $  safelyPickChar 2 str
        == safelyPickChar 3 str
        && safelyPickChar 4 str
        == safelyPickChar 5 str

safelyPickChar :: Int -> String -> Maybe Char
safelyPickChar x str | x < 0          = Nothing
                     | length str < x = Nothing
                     | otherwise      = Just $ str !! x

main = do
    s <- getLine
    case isSimilarWithCoffee s of
        Nothing   -> putStrLn "Yes"
        Just bool -> case bool of
            True  -> putStrLn "Yes"
            False -> putStrLn "No"



Measured memory_bytes: 380
#include<iostream>
using namespace std;
#include<vector>
struct UF{
	int n;
	vector<int>parent,size;
	UF(int n_=0):n(n_),parent(n_),size(n_,1)
	{
		for(int i=0;i<n_;i++)parent[i]=i;
	}
	int find(int a){return parent[a]!=a?parent[a]=find(parent[a]):a;}
	bool same(int a,int b){return find(a)==find(b);}
	bool unite(int a,int b)
	{
		a=find(a),b=find(b);
		if(a==b)return false;
		if(size[a]<size[b])
		{
			parent[a]=b;
			size[b]+=size[a];
		}
		else
		{
			parent[b]=a;
			size[a]+=size[b];
		}
		return true;
	}
	int operator[](int a){return size[find(a)];}
};
int A[1<<17],B[1<<17];
long ans[1<<17];
main()
{
	int N,M;
	cin>>N>>M;
	long now=(long)N*(N-1)/2;
	for(int i=0;i<M;i++)cin>>A[i]>>B[i];
	UF uf(N+1);
	for(int i=M;i--;)
	{
		ans[i]=now;
		if(!uf.same(A[i],B[i]))
		{
			now-=(long)uf[A[i]]*uf[B[i]];
			uf.unite(A[i],B[i]);
		}
	}
	for(int i=0;i<M;i++)cout<<ans[i]<<endl;
}


Measured memory_bytes: 3712
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>

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

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)

void debug_out() {}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif

int run(istream& in, ostream& out) {
    ll N, M;
    in >> N >> M;
    ll ans = 0;

    // solution here

    out << (N == M  ? "Yes" : "No") << endl;
    return 0;
}

int main() {
    return run(cin, cout);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a1,b1,c1;
int n,m,x,y,gqt[2006811],a[811],b[811],i,j,sum,sumend,ans;
int main()
{

    cin>>a1>>b1;
    if(a1[0]==b1[2]&&a1[1]==b1[1]&&a1[2]==b1[0])
	    cout<<"YES"<<endl;
    else 
	    cout<<"NO"<<endl;
	    
	return 0;
}

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


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

    int n; cin >> n;

    int res = 0;
    while (n--)
    {
        int v; cin >> v;
        res += (v & 1);
    }

    cout << ((res & 1)? "NO" : "YES") << '\n';
}

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

using namespace std;

typedef long long               ll;
typedef unsigned long long      ull;
typedef vector<int>             vi;
typedef vector<ll>              vll;
typedef pair<ll,ll>             pairll;
typedef map<ll,ll>              mapll ;
typedef map<char,ll>            mapch;
typedef map<string,ll>          mapstr;

#define si(a) scanf("%d", &a)
#define sll(a) scanf("%lld",&a)
#define sii(a,b) scanf("%d %d", &a,&b)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pt(a) printf("%d",a)
#define pll(a) printf("%lld",a)
#define ps printf(" ")
#define nln printf("\n")
#define pi acos(-1)
#define spc " "
#define nl "\n"
#define rep(i,W) for(int i = 0; i < W; i++)
#define rep1(i,W) for(int i = 1; i <= W; i++)

ll N, K;
vector<ll> arr;

void input(){
    cin >> N >> K;
    rep(i,N)
    {
        ll in;
        sll(in); arr.pb(in);
    }
}

void solve(){
    ll x = N-1;
    ll y = ceil((double)x/(K-1));
    cout << y << "\n";
}

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





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

string n;
bitset<3> ans;
int main(){
    cin >> n;
    int sz = n.size();

    for(int bit=0; bit <(1 << sz-1); bit++){
        bitset<3> e(bit);
        int tmp=n.at(0)-'0';
        for(int i = 0; i < 3; i++){
            if(e.test(i)){
                tmp -= n.at(i+1) - '0';
            }else{
                tmp += n.at(i+1) - '0';
            }
        }
        if(tmp == 7) ans = e;
    }

    cout << n.at(0);
    for(int i = 0; i < 3; i++){
        if(ans.test(i)) cout << '-' << n.at(i+1);
        else cout << '+' << n.at(i+1);
    }
    cout << "=7" << endl;
}

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

const int N=100010;
bool bad[N];
int h[N];

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;i++) {
        scanf("%d",&h[i]);
    }
    for (int i=1;i<=m;i++) {
        int x,y;
        scanf("%d%d",&x,&y);
        if (h[x]<=h[y]) bad[x]=true;
        if (h[y]<=h[x]) bad[y]=true;
    }
    int ans=0;
    for (int i=1;i<=n;i++) {
        ans+=(!bad[i]);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 4304
#include<iostream>
#include<cstdio>
using namespace std;
bool mark[10005];
void creat()
{
	int i,j,k;
	for(i=0;i<10005;i++)mark[i] = 0;
	for(i=2;i<10005;i++)
	{
		if(mark[i] == 0)
		{
			for(j=2*i;j<10005;j+=i)
			{
				mark[j] = 1;
			}
		}
	}
	mark[0]=mark[1] = 1;
	//for(i=0;i<10;i++)if(mark[i]==0)cout<<i<<' ';cout<<endl;
}
int main()
{
	int i,j,k,n;
	creat();
	int sum = 0;
	while(scanf("%d",&n)!=EOF)
	{
		sum = 0;
		for(i=1;i<=n;i++)
		{
			if(mark[i]==0&&mark[n+1-i]==0)sum++;
		}
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int

const ll INF = 1e10L + 5;

int main() {

	FASTIO; 

    int n,W;
    cin>>n>>W;

	vector<int> val(n);
    vector<int> wts(n);

    int total_val = 0;

    for(int i = 0;i<n;i++)
    {
        cin>>wts[i]>>val[i];

        total_val += val[i];
    }

    // max_ans or max_val can be total_val depending upon W

    // dp[i] Will store min wts to be added so that combined val is i
    vector<ll> dp(total_val+1,INF);

    // IMP - Base case val = 0 with weight added 0
    dp[0] = 0;

    for(int i = n-1;i>=0;i--)
    {
        for(int cur_val = total_val;cur_val>=0;cur_val--)
        {
            if(val[i] <= cur_val)
            {
                dp[cur_val] = min(dp[cur_val],wts[i] + dp[cur_val - val[i]]);
            }      
        }
    }  

    // for(auto ele : dp) cout<<ele<<" "; cout<<endl;

    ll ans = 0;

    for(int i = total_val;i>=0;i--)
    {
        if(dp[i] <= W)
        {
            ans = i;
            break;
        }
    }

    cout<<ans;


}


Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {
	var n, m, k int
	fmt.Scan(&n, &m, &k)
	for x := 0; x <= m; x++ {
	    for y := 0; y <= n; y++ {
	        if n * x + m * y - x * y * 2 == k {
	            fmt.Print("Yes")
	            return
	        }
	    }
	}
	fmt.Print("No")
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

#define MAXV 100000000

int N, M, X;
int C[12];
int A[12][12];
bool state[12];

ll search(int cur)
{
    if (cur == N) {
        ll u[M];
        ll cost = 0;
        REP(i, M) u[i] = 0;
        REP(i, N) {
            if (state[i]) {
                cost += C[i];
                REP(j, M) {
                    u[j] += A[i][j];
                }
            }
        }
        bool f = true;
        REP(i, M) {
            if (u[i] < X) {
                f = false;
                break;
            }
        }
        if (f) return cost;
        else return -1;
    }
    else {
        state[cur] = true;
        ll s1 = search(cur + 1);
        state[cur] = false;
        ll s2 = search(cur + 1);
        if (s1 == -1 && s2 == -1) {
            return -1;
        }
        else if (s1 == -1 && s2 != -1) {
            return s2;
        }
        else if (s1 != -1 && s2 == -1) {
            return s1;
        }
        else {
            return min(s1, s2);
        }
    }
}



int main(int argc, char **argv)
{
    cin >> N >> M >> X;
    REP(i, N) {
        cin >> C[i];
        REP(j, M) {
            cin >> A[i][j];
        }
    }

    cout << search(0) << endl;

    return 0;
}



Measured memory_bytes: 3636
sx, sy, tx, ty = map(int, input().split())

ans = ''

# 1回目の現在点から目的点への移動
cnt_ud = abs(ty-sy)
cnt_rl = abs(sx-tx)
ans += 'U'*cnt_ud+'R'*cnt_rl

# 1回目の目的点から現在点への移動
ans += 'D'*cnt_ud+'L'*cnt_rl

# 2回目の現在点から目的点への移動
ans += 'L'+'U'*(cnt_ud+1)+'R'*(cnt_rl+1)+'D'

# 2回目の目的点から現在点への移動
ans += 'R'+'D'*(cnt_ud+1)+'L'*(cnt_rl+1)+'U'

print(ans)


Measured memory_bytes: 3060