akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  string s;
  cin >> s;
  ll n = SZ(s);
  auto isKaibun = [&](string t) {
    ll m = SZ(t);
    REP(i, m) {
      if (t[i] == t[m - 1 - i]) {
        continue;
      }
      return false;
    }
    return true;
  };
  if (isKaibun(s) && isKaibun(s.substr(0, (n - 1) / 2)) &&
      isKaibun(s.substr((n + 1) / 2, (n - 1) / 2))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

mod util {
    #[allow(dead_code)]
    pub fn chmin<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x > y && {
            *x = y;
            true
        }
    }

    #[allow(dead_code)]
    pub fn chmax<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x < y && {
            *x = y;
            true
        }
    }

    /// 整数除算切り上げ
    #[allow(dead_code)]
    pub fn roundup(a: i64, b: i64) -> i64 {
        (a + b - 1) / b
    }

    #[allow(dead_code)]
    pub fn ctoi(c: char) -> i64 {
        c as i64 - 48
    }
}

#[allow(unused_imports)]
use util::*;

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input! {
        a:i64,b:i64
    }

    let ans = if a >= 10 || b >= 10 { -1 } else { a * b };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) x.begin(),x.end()

#define INF (int)1e9 //10^9:∞
#define LLINF (long long)1e12
#define MOD (int)1e9+7 //10^9+7:合同式の法
#define PI 3.141592653589

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int> >
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int> >
#define VPII vector<pair<int,int> >

#define INT ll

using namespace std;
/*........................................Define functions.........................................*/


/*....................................Define global variables .....................................*/


bool is_integer( double x ){
  return std::floor(x)==x;
}


/*.........................................kemkemG0................................................*/
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);


	int N, D;
	cin >> N >> D;
	VVI v(N, VI(D));
	REP(i, N)REP(j, D) {
		cin >>v[i][j];
	}
	int ans=0;
	FOR(i,0,N-2)FOR(j,i+1,N-1){
		int dd=0;
		REP(k,D){dd+= (v[i][k]-v[j][k])*(v[i][k]-v[j][k]); }
		sqrt(dd);
		if(is_integer(sqrt(dd)))ans++;
	}
	cout<<ans<<endl;






	return 0;
}




Measured memory_bytes: 3676
A,B,C,D=list(input())

F=["+","-"]

for x in range(2):
    for y in range(2):
        for z in range(2):
            if eval(A+F[x]+B+F[y]+C+F[z]+D)==7:
                print(A+F[x]+B+F[y]+C+F[z]+D+"=7")
                exit()


Measured memory_bytes: 3060
import sys
def input():
    return sys.stdin.readline()[:-1]
n,m = map(int,input().split())
ab = []
for i in range(m):
     ab.append(list(map(int,input().split())))
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def Find_Root(self,x):
        if self.root[x]<0:return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if x == y:
            return
        elif self.rnk[x] > self.rnk[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rnk[x] == self.rnk[y]:
                self.rnk[y] += 1
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
land = UnionFind(n)
all = int(n*(n-1)/2)
lis = [all]
for i in range(m-1):
    [a,b] = ab[-1-i]
    if land.Find_Root(a) != land.Find_Root(b):
        all -= land.Count(a)*land.Count(b)
    land.Unite(a,b)
    lis.append(all)
#print(lis)
for i in range(m):
    print(lis[-1-i])


Measured memory_bytes: 109276
#include<bits/stdc++.h>
#define int long long
using namespace std;
 
bool prime[1000009];
 
void era(){
    prime[0]=1;
    prime[1]=1;
    for(int i=2;i<1000009;i++){
        if(!prime[i]){
            for(int j=i+i;j<1000009;j+=i) prime[j]=1;
        }
    }
}
 
int dp[100009];
 
signed main(){
    era();
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    if(!prime[a[0]])dp[0]=1;
    for(int i=0;i<n-1;i++){
        if(!prime[a[i]]&&!prime[a[i+1]]&&a[i]<a[i+1])dp[i+1]+=dp[i];
        if(i<n-2&&!prime[a[i]]&&!prime[a[i+2]]&&a[i]<a[i+2])dp[i+2]+=dp[i];
        dp[i+1]%=1000000007;
        dp[i+2]%=1000000007;
    }
    cout<<(dp[n-1]+dp[n-2])%1000000007<<endl;
}


Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int N;
    vi W;
    cin >> N;
    W.resize(N);
    int a = 0;
    int b = 0;
    REP(i, N)
    {
        cin >> W[i];
        b += W[i];
    }

    int ans = INF;
    FOR(i, 0, N)
    {
        a += W[i];
        b -= W[i];
        ans = min(ans, abs(a - b));
    }
    cout << ans << endl;

    // system("pause");
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
using namespace std;
int main() {
    int n_int;
    std::string n;
    cin >> n_int;
    n=std::to_string(n_int);
    int size = n.size() - 1;
    std::string out = "hon";
    if(n[size] == '0'){out = "pon";}
    else if(n[size] == '1'){out = "pon";}
    else if(n[size] == '6'){out = "pon";}
    else if(n[size] == '8'){out = "pon";}
    else if(n[size] == '3'){out = "bon";}
    cout << out << "\n";

}


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

#ifdef DONLINE_JUDGE
//freopen("a.in", "r", stdin);
//freopen("a.out","w",stdout); // console output is better (in most cases)
#else
// add i/o method of specific testing system
#endif

using namespace std;

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

    int a, b;
    cin >> a >> b;
    cout << fixed << setprecision(5);
    cout << a / b << " " << a % b << " " << a / (double)b << endl;

    return 0;
}


Measured memory_bytes: 3284
"use strict";
const main = input => {
  input = input[0].split(' ').map(val => parseInt(val, 10));
  const l = input[0], r = input[1];
  // console.log(l, r);
  const ll = l%2019, rr = r%2019;
  let num = 2018;
  if (r-l >= 2018) {
    console.log(0);
  } else {
    for(let i=ll; i<rr; i++) {
      for(let j=i+1; j<=rr; j++) {
        num = Math.min(num, (i*j)%2019);
      }
    }
    console.log(num);
  }  
};
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

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

using namespace std;

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

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

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

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    string S;
    std::cin >> S;

    vector<vector<ll>> dp(S.size() + 1, vector<ll>(13, 0));

    dp[0][0] = 1;
    REP(i, S.size()) {
        REP(j, 10) {
            if(S[i] != '?' && S[i] - '0' != j) {
                continue;
            }
            REP(k, 13) {
                dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
            }
        }
        REP(j, 13) {
            dp[i + 1][j] %= MOD;
        }
    }

    std::cout << dp[S.size()][5] << std::endl;

    return 0;
}


Measured memory_bytes: 13648
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    ll A,B;cin>>A>>B;
    if(B<=1)cout<<0<<"\n";
    else{
        ll E=0;
        E+=A;
        ll cnt=1;
        while(E<B){
            E+=A-1;
            cnt++;
        }
        cout<<cnt<<"\n";
    }
}

Measured memory_bytes: 256
def C_Bridge(N, M, E):
    """
    N:頂点の数
    M:辺の数
    E:辺で結ばれる頂点の組
    """
    def dfs(v):
        # 現在の頂点を訪問済にする
        visited[v] = True
        for v2 in range(N):
            # 現在の頂点と次の頂点に辺がない。スキップ
            if adjacent[v][v2] == False:
                continue
            # 次の頂点が訪問済。スキップ
            if visited[v2] == True:
                continue
            dfs(v2)

    # 隣接行列の構成
    adjacent = [[0 for _ in range(N)] for _ in range(N)]
    a = [0 for _ in range(M)]
    b = [0 for _ in range(M)]  # a[i],b[i]がi番目の辺を表す
    for i in range(M):
        a[i] = E[i][0] - 1
        b[i] = E[i][1] - 1
        adjacent[a[i]][b[i]] = True
        adjacent[b[i]][a[i]] = True

    # 各辺が橋であるか？
    # グラフから辺を取り除いて、グラフが連結かを判定
    ans = 0
    visited = [False for _ in range(N)]
    for i in range(M):
        # 辺を取り除く
        adjacent[a[i]][b[i]] = False
        adjacent[b[i]][a[i]] = False

        # すべての辺を未訪問にする
        for j in range(N):
            visited[j] = False
        # 頂点0からDFS
        dfs(0)

        bridge = False
        for j in range(N):
            # すべての頂点が訪問済(訪問できた)なら連結、そうでなければ非連結
            if visited[j] == False:
                bridge = True
        if bridge:
            ans += 1
        adjacent[a[i]][b[i]] = True
        adjacent[b[i]][a[i]] = True
    return ans

N,M = [int(i) for i in input().split()]
E = [[int(i) for i in input().split()] for j in range(M)]
print(C_Bridge(N, M, E))

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
long long a[100000], b[100000];
long long ans[100000] = {0}, ans1 = 0;
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
	}
	for (int j = n - 1; j >= 0; j--){
		if ((a[j] + ans1) % b[j] == 0) {
			continue;
		}
		ans[j] = b[j] - (a[j] + ans1) % b[j];
		ans1 += ans[j];
	}
	cout << ans1 << endl;
}

Measured memory_bytes: 2560
#include<iostream>
#include<set>
#include<string>
using namespace std;
#define rep(i, j) for(int i = 0; i < j; i++)

int main(){
	int N, M; cin >>N;
	int openFlg = 0;
	set<string> s;
	rep(i, N){
		string tmp; cin >>tmp;
		s.insert(tmp);
	}
	cin >>M;
	rep(i, M){
		string tmp; cin >>tmp;
		if(s.find(tmp) != s.end()){
			openFlg = (openFlg + 1) % 2;
			if(openFlg == 1) cout <<"Opened by ";
			else cout <<"Closed by ";
			cout <<tmp <<endl;
		} else{
			cout <<"Unknown " <<tmp <<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

template <typename T>
struct BIT {
    int n;
    vector<T> data;
    BIT(int n) : n(n + 1), data(n + 1, 0) {}
    void add(int i, T x) {
        for (int j = i; j < n; j += (j & -j)) {
            data[j] += x;
        }
    }
    T sum(int i) {
        T s(0);
        for (int j = i; j > 0; j -= (j & -j)) {
            s += data[j];
        }
        return s;
    }
};

int n, q;
int c[500001];
int d[500001];  // 既に出た同じ色の球で最も右の位置（ないなら0）
vector<pair<int, int>> query;

int main() {
    cin >> n >> q;
    reps(i, n) cin >> c[i];
    rep(i, q) {
        int l, r;
        cin >> l >> r;
        query.push_back(make_pair(r, l));
    }
    auto query_sorted = query;
    sort(all(query_sorted));
    int seen = 1;
    BIT<int> bit(n);
    map<pair<int, int>, int> ans;
    for (const auto& p : query_sorted) {
        while (p.first >= seen) {
            if (d[c[seen]] != 0) {
                bit.add(d[c[seen]], -1);
            }
            d[c[seen]] = seen;
            bit.add(d[c[seen]], 1);
            seen++;
        }
        ans[p] = bit.sum(p.first) - ((p.second != 1) ? bit.sum(p.second - 1) : 0);
        ans[p] = bit.sum(p.first) - bit.sum(p.second - 1);
    }
    rep(i, q) { cout << ans[query[i]] << endl; }
    return 0;
}

Measured memory_bytes: 48732
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
typedef std::uniform_int_distribution<> randint;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}

u32 P, Ha;
u64 power(u64 a, int b) {
	u64 ans=1;
	for(; b; a=a*a%P, b/=2) if(b&1) ans=ans*a%P;
	return ans;
}

const int N=250010, K=6;

struct Linear {
	u32 a[K], b[K];
	Linear operator()(const Linear &f) {
		Linear g;
		for(int i=0; i<K; ++i) g.a[i]=(u64)a[i]*f.a[i]%P;
		for(int i=0; i<K; ++i) g.b[i]=((u64)a[i]*f.b[i]+b[i])%P;
		return g;
	}
	bool operator==(const Linear &o) {
		return memcmp(b, o.b, sizeof(b))==0;
	}
	u32 hash() {
		u32 sum=0;
		for(int i=0; i<K; ++i) sum=(sum*65536llu+b[i])%Ha;
		return sum;
	}
};
int n, head[20000000], next[N], size[N];
u32 x[K];
char s[N];
Linear f[N], pink[N];
std::random_device randev;
std::mt19937 gen(randev());
bool is_prime(int n) {
	if(n==1) return false;
	for(int i=2; (s64)i*i<=n; ++i) if(n%i==0) return false;
	return true;
}
int main() {
	s64 ans=0;
	assert(scanf("%d%s", &n, s)==2);
	do {
		P=randint(9e7, 11e7)(gen);
	} while(!is_prime(P));
	do {
		Ha=randint(1e7, 2e7)(gen);
	} while(!is_prime(Ha));
	for(int i=0; i<K; ++i) x[i]=randint(1, P-1)(gen);
	for(int i=0; i<n; ++i) {
		if(s[i]=='+') for(int j=0; j<K; ++j) f[i].a[j]=1, f[i].b[j]=1;
		if(s[i]=='-') for(int j=0; j<K; ++j) f[i].a[j]=1, f[i].b[j]=P-1;
		if(s[i]=='>') for(int j=0; j<K; ++j) f[i].a[j]=x[j];
		if(s[i]=='<') for(int j=0; j<K; ++j) f[i].a[j]=power(x[j], P-2);
	}
	for(int j=0; j<K; ++j) pink[0].a[j]=1;
	for(int i=0; i<n; ++i) pink[i+1]=pink[i](f[i]);
	for(int i=n, j; i>=1; --i) {
		u32 key=pink[i].hash();
		for(j=head[key]; j; j=next[j])
			if(pink[j]==pink[i]) {
				++size[j];
				break;
			}
		if(j==0) {
			next[i]=head[key];
			head[key]=i;
			size[i]=1;
		}
		Linear f=pink[i-1](pink[n]);
		for(int j=head[f.hash()]; j; j=next[j])
			if(f==pink[j]) {
				ans+=size[j];
				break;
			}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 103936
// atcoder/abc046/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, k;
  while (cin >> n >> k) {
    lli x = k;
    for (int i = 0; i < n - 1; ++i) {
      x *= k - 1;
    }
    cout << x << endl;
  }

  return 0;
}


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

int main(){
    ll n;
    cin >> n;
    vector<int> ns(n);
    rep(i, n){
        cin >> ns.at(i);
    }
    sort(ns.begin(), ns.end());
    int sum = 0;
    rep(i, n-1) if(ns.at(i) == ns.at(i+1)) sum++;
    int k = 0;
    int max = 0;
    rep(i, ns.size()-1){
        if(ns.at(i) == ns.at(i+1)){
            k += 1;
            if(max < k){
                max = k;
            }
        }else{
            k = 0;
        }
    }
/*    if(sum == 1) max = 1;
    if(sum - max*2 < 0){
        n += (sum - max*2);
    }
    cout << sum << endl;
    cout << max << endl;
*/    cout << n - sum - sum%2 << endl;
    return 0;
}

Measured memory_bytes: 640
"""
Kruskal
"""
from heapq import heappop, heappush

v_num, e_num = map(int, input().split())
pair_lst = [i for i in range(v_num)]
que = []
for _ in range(e_num):
  s, t, w = map(int, input().split())
  heappush(que, (w, s, t))

def find(x):
  if x == pair_lst[x]:
    return x
  else:
    tmp = find(pair_lst[x])
    pair_lst[x] = tmp
    return tmp

length_sum = 0
while que:
  w, s, t = heappop(que)
  root_s = find(s)
  root_t = find(t)
  if root_s != root_t:
    pair_lst[root_s] = root_t
    length_sum += w

print(length_sum)


Measured memory_bytes: 23256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;

	int mat[100][100] = {};
	int b[100] = {};
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> mat[i][j];
		}
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}

	int c[100] = {};
	for (int i = 0; i < n; i++) {
		int sum = 0;
		for (int j = 0; j < m; j++) {
			sum += mat[i][j] * b[j];
		}
		c[i] = sum;
	}

	for (int i = 0; i < n; i++) {
		cout << c[i] << endl;
	}

	return 0;
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

ll dp[310][310][310];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<ll> h(n + 1, 0);
    for (int i = 1; i <= n; i++)
    {
        cin >> h[i];
    }
    for (int i = 0; i < 310; i++)
    {
        for (int j = 0; j < 310; j++)
        {
            for (int l = 0; l < 310; l++)
            {
                dp[i][j][l] = LLINF;
            }
        }
    }
    dp[0][0][0] = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <= i; j++)
        {
            for (int l = 0; l <= k; l++)
            {
                chmin(dp[i + 1][j][l+1], dp[i][j][l]);
                chmin(dp[i + 1][i + 1][l], dp[i][j][l] + max(0LL, h[i + 1] - h[j]));
            }
        }
    }
    ll ans = LLINF;
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= k; j++)
        {
            chmin(ans, dp[n][i][j]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 233088
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Solver{
public:
    static const int MAXD=11;
    int A,B;
    int d[MAXD][MAXD];
    int f[MAXD*MAXD][MAXD*MAXD];
    void solve(){
        cin>>A>>B;
        for(int x=1;x<=A;x++){
            for(int y=1;y<=B;y++)
                cin>>d[x][y];
        }
        for(int x=1;x<=A;x++){
            for(int y=1;y<=B;y++){
                for(int a=0;a<=100;a++){
                    for(int b=0;b<=100;b++){
                        f[a][b]=max(f[a][b],d[x][y]-x*a-y*b);
                    }
                }
            }
        }
        for(int x=1;x<=A;x++){
            for(int y=1;y<=B;y++){
                int mmin=1e9;
                for(int a=0;a<=100;a++){
                    for(int b=0;b<=100;b++){
                        mmin=min(mmin,x*a+y*b+f[a][b]);
                    }
                }
                if(mmin!=d[x][y]){
                    cout<<"Impossible\n";
                    return;
                }
            }
        }
        cout<<"Possible\n";
        cout<<300<<" "<<101*101+298<<"\n";
        for(int u=1;u<150;u++){
            cout<<u<<" "<<u+1<<" "<<'X'<<"\n";
        }
        for(int u=151;u<300;u++){
            cout<<u<<" "<<u+1<<" "<<'Y'<<"\n";
        }
        for(int u=0;u<=100;u++){
            for(int v=0;v<=100;v++){
                cout<<u+1<<" "<<300-v<<"  "<<f[u][v]<<"\n";
            }
        }
        cout<<1<<" "<<300;
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->solve();
}

Measured memory_bytes: 384
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <deque>
#include <vector>
#include <string>
#include <bitset>
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF 1000000007
#define endl "\n"
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP_R(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define ALL(v) (v).begin(),(v).end()
#define SIZ(x) ((int)(x).size())
typedef long long int lli;
using namespace std;

int mul10(int);

int main()
{
  vector<int> a(5);

  int min_ind = 0;
  
  REP(i,5)
    {
      cin >> a[i];

      if( a[i] % 10 != 0 and a[i] - (a[i] / 10) * 10 < a[min_ind] - (a[min_ind] / 10) * 10 )
	{
	  min_ind = i;
	  
	}
    }
  int sm = 0;
  
  

  REP(i,5)
    {
      if( i != min_ind )
	{
	  sm += mul10(a[i]);
	}
      else
	{
	  sm += a[i];
	  
	}
    }
  cout << sm << endl;
  
}

int mul10( int n )
{
  if( n % 10 == 0)
    {
      return n;
    }
  else
    {
      return ( ( n / 10 ) + 1 ) * 10;
      
    }  
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long n,minv=1e12+7;
	cin>>n;
	for (long long i=1;i*i<=n;i++)
	{
		if (n%i==0)
		{
			long long a=i,b=n/i;
			long long move=(a-1)+(b-1);
			if (move<minv)  minv=move;
		}
	}
	cout<<minv<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ull = uint64_t;
using ll = int64_t;
using ld = long double;

const int N = 30228;

int a[N], b[N];
int ac, bc;

int l[N];
int r[N];

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20);
    int n;
    string s, t;
    cin >> n >> s >> t;
    for (int i = 1; i < n; ++i) {
        if (s[i] != s[i - 1]) {
            a[ac++] = i;
        }

        if (t[i] != t[i - 1]) {
            b[bc++] = i;
        }
    }

    int ans = N * N;

    bool eq = s[0] == t[0];
    for (int i = -n - 1; i <= n + 1; ++i) {
        if ((i % 2 == 0) != eq) {
            continue;
        }

        int lc = 0, rc = 0;

        if (i > 0) {
            fill(l, l + i, 0);
            lc = i;
        } else {
            fill(r, r + (-i), 0);
            rc = -i;
        }

        copy(a, a + ac, l + lc);
        copy(b, b + bc, r + rc);
        lc += ac;
        rc += bc;
        while (lc < rc) {
            l[lc++] = n;
        }

        while (rc < lc) {
            r[rc++] = n;
        }

        int cur = 0;
        for (int j = 0; j < lc; ++j) {
            cur += abs(l[j] - r[j]);
        }

        ans = min(ans, cur);
    }

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



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define MAX 100001
#define inf 1e9
using namespace std;

int n,pw;
double vw[MAX],pf[MAX],vf[MAX],th[MAX];

double f(double W){
  double cost=W*pw;

  for(int i=0;i<n;i++){
    if(W*vw[i]>th[i])continue;
    double sum1=th[i]-W*vw[i];
    double sum2=sum1/(double)vf[i];
    cost+=sum2*pf[i];
  }
  return cost;
}

int main()
{
  while(1){
    cin>>n>>pw;
    if(n==0)break;
    for(int i=0;i<n;i++)cin>>vw[i]>>pf[i]>>vf[i]>>th[i];

    double l=0,r=inf;
    for(int i=0;i<200;i++){
      double m1=(l*2.0+r)/3.0;
      double m2=(l+r*2.0)/3.0;
      double res1=f(m1);
      double res2=f(m2);
      if(res1<res2)r=m2;
      else l=m1;
    }
    printf("%.4f\n",f(l));
  }
  return 0;
}

Measured memory_bytes: 4376
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
    int x;
    cin>>x;
    int target=x%100,cnt=0;
    while (target>=5){
        target-=5;
        cnt++;
    }
    while (target>=4){
        target-=4;
        cnt++;
    }
    while (target>=3){
        target-=3;
        cnt++;
    }
    while (target>=2){
        target-=2;
        cnt++;
    }
    while (target>=1){
        target-=1;
        cnt++;
    }
    if (cnt<=(int)(x/100)) cout<<1<<endl;
    else cout<<0<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){

  int a, b;
  cin >> a >> b;
  if (a <= b){
    cout << a << endl;
  }
  else {
    cout << a - 1 << 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 s = sc.nextInt();
        
        Map<Integer,Boolean> map = new HashMap<>(1000_000);
        map.put(s, true);
        for (int i = 2; i <= 1000000; i++) {
        	s = f(s);
        	if (map.containsKey(s)) {
        		System.out.println(i);
        		break;
        	} else {
        		map.put(s, true);
        	}
        }
    }
    
    static int f(int s) {
    	if (s % 2 == 0) {
    		return s /2;
    	} else {
    		return 3*s+1;
    	}
    }
}

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

int main() {
  string s;
  int q;
  cin >> s >> q;
  bool rev = false;
  stack<string> st;
  queue<string> qu;
  for (int i = 0; i < q; i++){
    int t;
    cin >> t;
    if (t == 1) { rev = !rev;}
    if (t == 2) { 
      int f;
      cin >> f;
      string c;
      cin >> c;
      if (!rev) {
        if (1==f){
          st.push(c);
        } else {
          qu.push(c);
        }
      } else {
        if (1==f){
          qu.push(c);
        } else {
          st.push(c);
        }
      }
    }
  }
  if (!rev){
    while(!st.empty()) {
      cout << st.top();
      st.pop();
    }
    cout << s;
    while(!qu.empty()) {
      cout << qu.front();
      qu.pop();
    }
  } else {
    string f, l;
    while(!qu.empty()) {
      f += qu.front();
      qu.pop();
    }
    reverse(f.begin(), f.end());
    cout << f;
    reverse(s.begin(), s.end());
    cout << s;
    while(!st.empty()) {
      l += st.top();
      st.pop();
    }
    reverse(l.begin(), l.end());
    cout << l;
  }
}

Measured memory_bytes: 10140
c=[0]*26
while 1:
        try:
                t=list(raw_input().lower())
                for i in range(len(t)):
                        if 0<=ord(t[i])-ord("a")<=25:
                                c[ord(t[i])-ord("a")]+=1
        except EOFError:
                break
for i in range(26):
        print chr(ord("a")+i),":",c[i]

Measured memory_bytes: 4244
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    i = 0
    j = 0
    flg = 0
    while 4 * i <= n:
        j = 0
        while 4 * i + 7 * j <= n:
            if 4 * i + 7 * j == n:
                flg = 1
                break
            j += 1
        if flg:
            pass
        i += 1

    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B, C;
	cin >> A >> B >> C;

	if (A == B && B == C) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

using namespace std;

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

int data[100];
inline int root(int x) {
  return data[x] < 0 ? x : data[x] = root(data[x]);
}
typedef pair<int, pair<int, int> > edges;

int const INF = 1<<29;

int main() {
  
  int N, M;
  while(cin >> N >> M && (N|M)) {
    vector<edges> es;
    rep(i, M) {
      int a, b, c;
      cin >> a >> b >> c; a--, b--;
      es.push_back(make_pair(c, make_pair(a, b)));
    }
    sort(es.begin(), es.end());
    int ret = INF;
    
    for(; (int)es.size() >= N-1;) {
      memset(data, -1, sizeof data);
      int last = -1;
      int s = 0;
      rep(i, es.size()) {
	int u = root(es[i].second.first), v = root(es[i].second.second);
	if(u != v) {
	  data[u] += data[v]; data[v] = u;
	  last = i;
	  s++;
	  if(s == N-1) break;
	}
      }
      rep(i, N) REP(j, i+1, N) {
	int u = root(i), v = root(j);
	if(u != v) { goto exit; }
      }
      ret = min(ret, es[last].first-es[0].first);
      es.erase(es.begin());
    }
    
  exit:;
    cout << (ret < INF ? ret : -1) << endl;
    
  }
  
  return 0;
}

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

#define MAX 36

int main(){
  char a[MAX][3],b[MAX][3],str[3];
  int n,i,j,c[MAX],d[MAX],tmp,mini,ok = 1;

  scanf("%d" ,&n);
  for(i = 0 ; i < n ; i++){
    scanf("%s" ,a[i]);
    strcpy(b[i],a[i]);
    c[i] = d[i] = a[i][1]-'0';
  }

  for(i = 0 ; i < n ; i++){
    for(j = n-1 ; j > i ; j--){
      if(c[j] < c[j-1]){
	tmp = c[j];
	c[j] = c[j-1];
	c[j-1] = tmp;

	strcpy(str,a[j]);
	strcpy(a[j],a[j-1]);
	strcpy(a[j-1],str);
      }
    }
  }  

  for(i = 0 ; i < n ; i++){
    if(i != n-1){
      printf("%s " ,a[i]);
    }else{
      printf("%s\n" ,a[i]);
      puts("Stable");
    }
  }

  for(i = 0 ; i < n-1 ; i++){
    mini = i;
    for(j = i+1 ; j < n ; j++){
      if(d[j] < d[mini]){
	mini = j;
      }
    }
    
    if(mini != i){
      tmp = d[i];
      d[i] = d[mini];
      d[mini] = tmp;

      strcpy(str,b[i]);
      strcpy(b[i],b[mini]);
      strcpy(b[mini],str);
    }
  }

  for(i = 0 ; i < n ; i++){
    if(strcmp(a[i],b[i])){
      ok = 0;
    }
    if(i != n-1){
      printf("%s " ,b[i]);
    }else{
      printf("%s\n" ,b[i]);
    }
  }

  if(ok){
    puts("Stable");
  }else{
    puts("Not stable");
  }

  return 0;
}

Measured memory_bytes: 620
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let input = read_vec::<usize>();
    let (_n, m) = (input[0], input[1]);
    let mut aa = read_vec::<usize>();
    aa.sort();
    let mut bc = vec![];
    for _ in 0..m {
        let input = read_vec::<usize>();
        bc.push(input);
    }

    bc.sort_by(|x, y| y[1].cmp(&x[1]));


    let mut index = 0;
    for (b, c) in bc.iter().map(|x| (x[0], x[1])) {
        for _ in 0..b {
            if index >= aa.len() {
                break;
            }
            if aa[index] < c {
                aa[index] = c;
                index += 1;
            } else {
                break;
            }
        }
    }


    let ans = aa.iter().sum::<usize>();
    println!("{}", ans);

}

Measured memory_bytes: 12540
n,m = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(m)]
z = 10**(n-1) if n!=1 else 0
for i in range(z,10**n):
    f = 1
    si = str(i)
    for s,c in l:
        if si[s-1] != str(c):
            f = 0
            break
    if f:
        print(i)
        exit()
print(-1)

Measured memory_bytes: 3064
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
const int MAXN=5e5+10;
const double eps=1e-8;
const int MOD=1000000007;
using namespace std;
typedef  long long ll;
int main()
{
    int n,d;
    cin>>n>>d;
    if(n%(2*d+1)==0)
        cout<<n/(2*d+1)<<endl;
    else
        cout<<n/(2*d+1)+1<<endl;
    return 0;
}



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

#define llint long long int

using namespace std;

int main(){
    int N;
    llint K;

    cin >> N >> K;

    vector<int> A(N + 1);

    for(int i = 1; i <= N; i ++){
        cin >> A[i];
    }
    vector<llint> totyaku(N + 1, 0);

    llint i = 1;
    int current = 1;

    for(i = 1; i <= N + 1 && i <= K; i ++){
        current = A[current];

        if(totyaku[current] > 0){
            break;
        }
        totyaku[current] = i;
    }
    if(i == K){
        cout << current << endl;
    }else{
        llint n = (K - totyaku[current]) / (i - totyaku[current]);

        for(llint j = totyaku[current] + n * (i - totyaku[current]) + 1; j <= K; j ++){
            current = A[current];
        }
        cout << current << endl;
    }
}

Measured memory_bytes: 5636
N, Q = map(int, input().split())
value = [0]*(N+1)
ab_list = []
for i in range(N-1):
  a, b = map(int, input().split())
  ab_list.append([a, b])
ab_list.sort(key=lambda x:x[0])
for i in range(Q):
  p, q = map(int, input().split())
  value[p] += q
for a, b in ab_list:
  value[b] += value[a]
print(' '.join(map(str, value[1:])))

Measured memory_bytes: 63592
#include<bits/stdc++.h>
using namespace std;
void minabs(long long int ,long long int);

int main(){
  long long int n;
  cin>>n;
  long long int k;
    cin>>k;
  minabs(n,k);
  
return 0;  
}
void minabs(long long int n ,long long int k){
  
  n = (n%k);
  
  while(n >= abs(n-k)){
     n = abs(n-k);
  }
  cout<< n <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <utility>
#define ull unsigned long long int
#define ll long long int 
#define pb push_back
#define mp make_pair
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector <int>
#define vl vector <long long int>
#define vc vector <char>
#define clr(a) memset(a,0,sizeof(a))
using namespace std;
int main()
{

	ll a,b,c,i,j,k;

	cin>>a;

	ll arr[a];ll cost[a];

	for(i=0;i<a;i++)
		cin>>arr[i];

	cost[0] = 0;
	cost[1] = abs(arr[1]-arr[0]);

	for(i=2;i<a;i++)
	{
		cost[i] = min(cost[i-1]+abs(arr[i]-arr[i-1]),cost[i-2]+abs(arr[i]-arr[i-2]));
	}

	cout<<cost[a-1]<<endl;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(),(x).end()
#define pushb push_back()
#define popb pop_back()
#define makep make_pair
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
int main(){
    vector<vector<vector<vector<int>>>> c(4,vector<vector<vector<int>>>(4,vector<vector<int>>(4,vector<int>(4,0))));
    int n;cin>>n;
    ll def=pow(10,9)+7;
    if(n==3){
        cout<<61<<endl;
        return 0;
    }
    int l=4;
    rep(i,4){
        rep(j,4){
            rep(n,4){
                rep(m,4){
                    c[i][j][n][m]=1;
                }
            }
        }
    }
    rep(i,4){
        c[0][1][2][i]=0;
        c[1][0][2][i]=0;
        c[0][2][1][i]=0;
        c[0][1][i][2]=0;
        c[i][0][1][2]=0;
        c[0][i][1][2]=0;
        c[i][1][0][2]=0;
        c[i][0][2][1]=0;
    }
    rep(k,5,n+1){
        vector<vector<vector<vector<int>>>> c2(4,vector<vector<vector<int>>>(4,vector<vector<int>>(4,vector<int>(4,0))));
        rep(i,4){
            rep(j,4){
                rep(n,4){
                    rep(m,4){
                        rep(p,4){
                            c2[j][n][m][p]+=c[i][j][n][m];
                            c2[j][n][m][p]%=def;
                        }
                    }
                }
            }
        }
        c=c2;
        rep(i,4){
            c[0][1][2][i]=0;
            c[1][0][2][i]=0;
            c[0][2][1][i]=0;
            c[0][1][i][2]=0;
            c[i][0][1][2]=0;
            c[0][i][1][2]=0;
            c[i][1][0][2]=0;
            c[i][0][2][1]=0;
        }
    }
    ll ans=0;
    rep(i,4){
        rep(j,4){
            rep(n,4){
                rep(m,4){
                    ans+=c[i][j][n][m];
                    ans%=def;
                }
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <queue>
using namespace std;

int main(void){
	priority_queue<int> p;
	int n;
	char str[20];
	while(scanf("%s",str),str[2]!='d'){
		if(str[2]=='s'){
			scanf("%d",&n);
			p.push(n);
		}else{
			printf("%d\n",p.top());
			p.pop();
		}
	}
	return 0;
}

Measured memory_bytes: 5792
#include <stdio.h>
#include <string.h>
int main()
{
    int a, s, j, n;
    char x[1001];
    while (1)
    {
        int sum = 0;
        scanf("%s", x);
        if (strcmp(x, "0") == 0)
        {
            break;
        }
        for (int i = 0; x[i] != '\0'; i++)
        {
            n = x[i] - '0';
            sum = n + sum;
        }
        printf("%d\n", sum);
    }
    return (0);
}




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

int main() {
    string s; //string型で受け取って後で数字に変換する
    cin >> s; //入力(sの長さは1~10)
    int l = s.size() - 1; //sの数字の間に入れられる+の個数の限界値
    long long ans = 0; //本当の答え。最後に出力する
    if (l == 0) { //一桁の時は
        ans = s[0] - '0'; //入力された数字を
        cout << ans << endl; //出力して
        return 0; //終了する
    }
    //以下、二桁以上の場合
    for (int bit = 0; bit < (1<<l); bit++) { //フラグが立っている場所に+を配置すると考える
        long long tempAns = s[0] - '0';
        for (int i = 0; i<l; i++) { //i番目のフラグが立っているか確かめるためのループ
            if (!(bit & (1<<i))) { //i番目のフラグが立っていない場合
                tempAns = tempAns * 10 + s[i+1] - '0'; //10倍してi+1番目の数を足す
            }
            else { //i番目のフラグが立っている場合
                ans += tempAns;
                tempAns = s[i+1] - '0';
            }
        }
        ans += tempAns; //最後までループが回ったらtempAnsが足されずに終わっているので足す
    }
    cout << ans << endl; //合計を出力
    return 0;
}

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

#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[n]; rep(i,n){ gets(x[i]);}
#define ll long long
typedef pair<int, int> P;

int main(){
  int N;
  cin >> N;
  ll a[N], in, ans = 0;
  rep(i, N){
    cin >> in;
    a[i] = in-(i+1);
  }
  sort(a, a+N);
  ll mid = a[N/2];
  rep(i, N){
    ans += abs(a[i] - mid);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
from collections import Counter

n = int(input())
d = map(int, input().split())
m = int(input())
t = map(int, input().split())

dc, tc = Counter(d), Counter(t)
ans = "YES"
for p in tc.keys():
    if tc[p] > dc[p]:
        ans = "NO"

print(ans)


Measured memory_bytes: 67680
use std::collections::HashMap;

fn main() {
    proconio::input! {
        n: usize,
        x: String,
    }

    let bp = x.match_indices('1').count() as u64;
    let p = if bp == 1 { vec![2, 1] } else { vec![bp + 1, bp - 1] };

    let xr: Vec<char> = x.chars().rev().collect();

    let mut pows = vec![vec![1, 1]; n];
    let mut xv = if xr[0] == '1' { vec![1; 2] } else { vec![0; 2] };
    for i in 1..n {
        for j in 0..=1 {
            pows[i][j] = (pows[i - 1][j] * 2) % p[j];
            if xr[i] == '1' {
                xv[j] += pows[i][j];
                xv[j] %= p[j];
            }
        }
    }

    let mut dic = HashMap::new();
    for i in (0..n).rev() {
        if bp == 1 && xr[i] == '1' {
            println!("0");
        } else {
            let xi = if xr[i] == '0' {
                (xv[0] + pows[i][0]) % p[0]
            } else {
                let p = if xv[1] >= pows[i][1] { 0 } else { p[1] };
                xv[1] + p - pows[i][1]
            };
            println!("{}", 1 + pop_pop_count(xi, &mut dic));
        }
    }
}

fn pop_pop_count(sv: u64, dic: &mut HashMap<u64, u64>) -> u64 {
    let mut r = 0;
    let mut v = sv;
    while v > 0 {
        if let Some(dr) = dic.get(&v) {
            v = 0;
            r += dr;
        } else {
            v %= v.count_ones() as u64;
            r += 1;
        }
    }
    dic.insert(sv, r);
    r
}


Measured memory_bytes: 14716
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    long A, B, C;
    scan(A, B, C);
    bool b = C <= A + B;
    writeln(b ? "Yes" : "No");
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  String A = sc.next();
  String B = sc.next();
  String C = sc.next();
  if(A.charAt(A.length() -1) == B.charAt(0) && B.charAt(B.length() -1) == C.charAt(0))
    System.out.println("YES");
  else System.out.println("NO");
}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
   int p=n-1;
   int k=m-1;
   int s1=(p*(p+1))/2;
   int s2=(k*(k+1))/2;
   cout<<s1+s2<<endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b; cin >> a >> b;
    if (a % b == 0) {
        cout << -1 << endl;
    }
    else {
        cout << a << endl;
    }
}


Measured memory_bytes: 764