akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
#include <bitset>
#include <string>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define all(x) (x).begin(),(x).end()
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)


ll modpow(ll x, ll n) {
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        ll h = modpow(x, n / 2);
        return h * h % MOD;
    } else {
        return x * modpow(x, n - 1) % MOD;
    }
}

int gcd(int a,int b)  {
	if (a%b==0)  return(b);
	else return(gcd(b,a%b));
}

int vector_finder(vector<int> vec, int number) {
  auto itr = find(vec.begin(), vec.end(), number);
  size_t index = distance(vec.begin(), itr);
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
    int A, B, C, D; cin >> A >> B >> C >> D;
    cout << min(A,B)+min(C,D) << endl;
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        ans += i - 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
from heapq import heappop, heappush

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

counted = set()
h = [(-(A[0] + B[0] + C[0]), 0, 0, 0)]
for _ in range(K):
    s, i, j, k = heappop(h)
    print(-s)
    if X > i + 1 and (i + 1, j, k) not in counted:
        heappush(h, (-(A[i + 1] + B[j] + C[k]), i + 1, j, k))
        counted.add((i + 1, j, k))
    if Y > j + 1 and (i, j + 1, k) not in counted:
        heappush(h, (-(A[i] + B[j + 1] + C[k]), i, j + 1, k))
        counted.add((i, j + 1, k))
    if Z > k + 1 and (i, j, k + 1) not in counted:
        heappush(h, (-(A[i] + B[j] + C[k + 1]), i, j, k + 1))
        counted.add((i, j, k + 1))


Measured memory_bytes: 4976
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

struct UnionFind{
  vector<int> par;
  UnionFind(int N):par(N){
    REP(i,N)par[i]=i;
  }
  int root(int x){
    if(par[x]==x)return x;
    return par[x]=root(par[x]);
  }
  void unite(int x,int y){
    int rx=root(x);
    int ry=root(y);
    if(rx==ry)return;
    par[rx]=ry;
  }
};

int main(){
  int N,M;
  cin>>N>>M;
  UnionFind tree(N);
  REP(i,M){
    int A,B;
    cin>>A>>B;
    A--;B--;
    tree.unite(A,B);
  }
  int C[N];
  REP(i,N)C[i]=0;
  REP(i,N)C[tree.root(i)]++;
  int ans=1;
  REP(i,N)ans=max(ans,C[i]);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 11100
def main():
    n = int(input())
    h = input().split()
    h = [int(n) for n in h]
    max = 0
    now = 0
    i = 0
    for i in range(n-1):
        if h[i] >= h[i+1]:
            now += 1
        else:
            if now >= max:
                max = now
            now=0
        if now >= max:
            max = now
    print(max)

if __name__ == "__main__":
    main()



Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
int N, M, x;
int main() {
	cin >> N >> M;
	int ret = N;
	for(int i = 0; i < M; i++) {
		cin >> x;
		ret = __gcd(ret, __gcd(x, N));
	}
	if(ret != 1) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cerr <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}


using namespace std;

int main() {
	make(n);
	int T = 0, X = 0, Y = 0;
	bool ans = true;
	FOR(i,0,n) {
		make3(t, x, y);
		int d = abs(X-x) + abs(Y-y);
		if (d > (t-T)) ans = false;
		if (d%2 != (t-T)%2) ans = false;
		T = t; X = x; Y = y;
	}
	if (ans) printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 256
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool in_range(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool in_range(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//

struct Edge {
	int to, i;
};

int N;
vector< vector< Edge > > adj;
int ans[100005];

void dfs(int v, int p, int c) {
	int nc = 1;
	for (const Edge& e : adj[v]) {
		if (e.to == p) continue;
		if (nc == c) ++nc;
		dfs(e.to, v, nc);
		ans[e.i] = nc;
		++nc;
	}
}

int main() {
	cin >> N;
	memset(ans, 0, sizeof(ans));
	
	adj.assign(N, vector< Edge >());
	for (int i=0; i<N-1; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		adj[a].push_back(Edge{b, i});
		adj[b].push_back(Edge{a, i});
	}
	
	dfs(0, -1, 0);
	
	int K = *max_element(ans, ans + N - 1);
	cout << K << endl;
	for (int i=0; i<N-1; ++i) cout << ans[i] << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 8448
from itertools import groupby, accumulate, product, permutations, combinations
def solve():
    ans = 0
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    A = [0]+list(accumulate(A))
    B = [0]+list(accumulate(B))
    b = M
    for a in range(N+1):
        if A[a]>K:
            break
        while A[a]+B[b]>K:
            b -= 1
        ans = max(a+b,ans)
    return ans
print(solve())

Measured memory_bytes: 41844
<?php
$s = rtrim(fgets(STDIN));
$t = rtrim(fgets(STDIN));
for($i=0; $i<strlen($s); $i++)
{
	$spart[$i] = $s[$i];
}
for($i=0; $i<strlen($t); $i++)
{
	$tpart[$i] = $t[$i];
}

sort($spart);
rsort($tpart);

$stop = "";
$tbottom = "";
for($i=0; $i<strlen($s); $i++)
{
	$stop .= $spart[$i];
}
for($i=0; $i<strlen($t); $i++)
{
	$tbottom .= $tpart[$i];
}

$beforeArray = array($stop, $tbottom);
$afterArray = array($stop, $tbottom);
sort($afterArray);

if($s==$t)
{
	echo("No");
}
elseif($beforeArray[0] == $afterArray[0])
{
	echo("Yes");
}
else
{
	echo("No");
}

Measured memory_bytes: 3576
#[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, 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")
    };
}

fn main() {
    input! {
        x: usize,
        y: usize,
        z: usize,
        k: usize,
        mut a: [usize; x],
        mut b: [usize; y],
        mut c: [usize; z],
    }
    a.sort_by(|a, b| b.cmp(a));
    b.sort_by(|a, b| b.cmp(a));
    c.sort_by(|a, b| b.cmp(a));

    let mut v = Vec::new();

    for ii in 0..x {
        for ij in 0..y {
            if ii * ij > k {
                break;
            }
            for ik in 0..z {
                if ii * ij * ik > k {
                    break;
                }
                v.push(a[ii] + b[ij] + c[ik]);
            }
        }
    }
    v.sort_by(|x, y| y.cmp(x));

    for i in 0..k {
        println!("{}", v[i]);
    }
}


Measured memory_bytes: 36088
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const gojo=(a:number,b:number):number=>{if(a%b===0)return b;return gojo(b,a%b)};
const main=()=>{
  let s=ts()
  let q1=false,q2=false,q3=true
  if(s[0]=='A')q1=true
  let c=0
  for(let i=1;i<s.length;i++){
    if(i>=2&&i<=s.length-2&&s[i]=='C')c++
    else if(s[i] === s[i].toUpperCase())q3=false
  }
  if(c===1)q2=true
  to(q1&&q2&&q3?'AC':'WA')
}
main()

Measured memory_bytes: 7372
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  string N;
  cin >> N;
  if(N[0]=='9' || N[1]=='9') print("Yes");
  else print("No");
}


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

using namespace std;

bool search(char a[101][101], bool vis[101][101], int s, int t)
{
	if(vis[s][t]){
		return true;
	}
	vis[s][t] = true;
	
	if(a[s][t] == '>'){
		return search(a, vis, s, t+1);
	}
	if(a[s][t] == '^'){
		return search(a, vis, s-1, t);
	}
	if(a[s][t] == '<'){
		return search(a, vis, s, t-1);
	}
	if(a[s][t] == 'v'){
		return search(a, vis, s+1, t);
	}
	
	cout << t << " " << s << endl;
	return false;
}

int main()
{
	int h, w;
	bool vis[101][101];
	char a[101][101];
	
	while(1){
		cin >> h >> w;
		if(h == 0 && w == 0){
			break;
		}
		fill(&vis[0][0], &vis[h][w], false);
		
		for(int i = 0; i < h; i++){
			cin >> a[i];
		}
		
		if(search(a, vis, 0, 0)){
			cout << "LOOP" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
using namespace std;
const int maxn=2e6+5;
typedef long long ll;
const ll mod=191981019260817247;
ll base=233;
ll pw[maxn],ha[maxn];
inline ll mul(ll a,ll b){
	ll k=(ll)((long double)a*b/mod);
	ll r=a*b-mod*k;
	if (r<0) r+=mod;
	if (r>=mod) r-=mod;
	return r;
}
inline ll geth(int l,int r){
	return (ha[r]-mul(pw[r-l+1],ha[l-1])+mod)%mod;
}
vector<int> adj[maxn];
int d[maxn];
int n,m,len;
char s[maxn],t[maxn];
int id[maxn];
queue<int> q;
int main(){
	scanf("%s",s+1);
	scanf("%s",t+1);
	n=strlen(s+1);
	m=strlen(t+1);
	len=n;
	while(len<m+n){
		for (int i=1;i<=n;i++){
			s[++len]=s[i];
		}
	}
	pw[0]=1;
	for (int i=1;i<=len;i++){
		pw[i]=mul(pw[i-1],base);
		ha[i]=(mul(ha[i-1],base)+s[i])%mod;
	}
	ll hat=0;
	for (int i=1;i<=m;i++){
		hat=(mul(hat,base)+t[i])%mod;
	}
	for (int i=1;i<=n;i++){
		int r=i+m-1;
		if (hat==geth(i,r)){
			int tp=r%n+1;
			adj[i].push_back(tp);
			id[tp]++;
		}
	}
	for (int i=1;i<=n;i++){
		if (id[i]==0){
			q.push(i);
		}
	}
	while(!q.empty()){
		int u=q.front();
		q.pop();
		for (int i=0;i<adj[u].size();i++){
			int v=adj[u][i];
			id[v]--;
			d[v]=max(d[u]+1,d[v]);
			if (id[v]==0){
				q.push(v);
			}
		}
	}
	int ans=0;
	for (int i=1;i<=n;i++){
		ans=max(ans,d[i]);
		if (id[i]!=0){
			cout<<"-1"<<endl;
			return 0;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 93444
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <map>
#include <limits>
using namespace std;
typedef long long ll;

float inf = std::numeric_limits<float>::infinity();
ll mod = 1e9+7;

/* 二次元配列の宣言
  vector<vector<int>> tb;
  tb.resize(H);
  for (size_t i = 0; i < H; i++) {
    tb[i].resize(W);
  }
*/
/*
  A.resize(N);
  for (int i = 0; i < N; i++) {scanf("%d",&A[i]);}
*/

int main(void) {
  ll x,ans;
  cin >> x;
  ans = x/11 * 2;
  if (1<=x%11 && x%11<=6){
    ans += 1;
  }else if(7<=x%11){
    ans += 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var h = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();
            var max = h[0];
            var result = "Yes";
            for (var i = 1; i < h.Length; i++)
            {
                var hi = h[i];
                if (hi < max - 1)
                {
                    result = "No";
                    break;
                }

                if (hi > max) max = hi;
            }

            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 39728
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=998244353;
ll n,m;
const int MAX_N=2000000;
ll fact[MAX_N], invfact[MAX_N];
ll extgcd(ll a, ll b, ll& x, ll&y){
    ll d=a;
    if(b!=0){
        d=extgcd(b, a%b, y, x);
        y-=(a/b)*x;
    }
    else {
        x=1; y=0;
    }
    return d;
}

ll mod_inverse(ll a, ll m=MOD){
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}
ll comb(ll a, ll b){
    if(a<b) return 0;
    return fact[a]*invfact[b]%MOD*invfact[a-b]%MOD;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m;
    ll ans=0;
    fact[0]=1;
    invfact[0]=1;
    rep(i,1,MAX_N){
        fact[i]=fact[i-1]*i%MOD;
        invfact[i]=mod_inverse(fact[i]);
    }
    rep(i,0,m+1){
        if(3*m%2==i%2){
            ans+=comb((3*m-i)/2+n-1, n-1)*comb(n,i)%MOD;
            if(i) ans-=comb((m-i)/2+n-1, n-1)*comb(n-1,i-1)%MOD*n%MOD;
            ans-=comb((m-i)/2+n-2, n-1)*comb(n-1,i)%MOD*n%MOD;
            ans%=MOD;
        }
    }
    cout <<(ans+MOD)%MOD<<"\n";
}

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

typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned int ui;

int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    
    ios_base::sync_with_stdio(false);  
    cin.tie(NULL);

    int n=0;
    cin>>n;
    string s;
    cin>>s;
    if(s.size()<=n)
    	cout<<s<<endl;
    else
    {
    	for(int i=0; i<n; i++)
    	{
    		cout<<s[i];
    	}
  		cout<<"..."<<endl;
    }
}

Measured memory_bytes: 3588
N = int(input())
a = list(map(int, input().split()))

X = [0] * (N // 2) + a[N//2:]
#print(X)

for i in range(N//2):
    idx = -(i + N//2 + 1 + N % 2)
    step = N + idx + 1
    #print(idx, step)
    #print(X[idx:N+1:step])
    X[idx] = X[idx] if sum(X[idx:N+1:step]) % 2 == a[idx] else 1 - X[idx]

#print(X)

count = 0
s = ""
for i in range(N):
    if X[i] == 1:
        count += 1
        s += str(i+1) + " "

print(count)
print(s)

Measured memory_bytes: 9784
fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val h = sc.nextInt()
    val w = sc.nextInt()

    data class Pos(val x: Int, val y: Int)

    val a = sc.asSequence().take(h).map { line -> line.toCharArray().map { if (it == '#') -1 else 0 }.toIntArray() }.toList()
    val q: java.util.Queue<Pair<Pos, Int>> = java.util.LinkedList<Pair<Pos, Int>>()

    fun op(p: Pos, d: Int) {
        if (!(p.x in 0 until w && p.y in 0 until h && a[p.y][p.x] != -1)) {
            return
        }
        if (a[p.y][p.x] > 0) {
            return
        }
        a[p.y][p.x] = d
        q.add(Pos(p.x + 1, p.y) to d + 1)
        q.add(Pos(p.x - 1, p.y) to d + 1)
        q.add(Pos(p.x, p.y + 1) to d + 1)
        q.add(Pos(p.x, p.y - 1) to d + 1)
    }

    q.add(Pos(0, 0) to 1)
    while (q.isNotEmpty()) {
        val (p, d) = q.poll()
        op(p, d)
    }

    val e = a[h - 1][w - 1]
    if (e == 0) {
        println(-1)
        return
    }
    val walls = a.map { line -> line.filter { it == -1 }.sum() }.sum()
    println(h * w + walls - e)
}


Measured memory_bytes: 33516
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():

    N = I()
    A = LI()
    mod = 10 ** 9 + 7
    sum_ = 0
    D = []
    for i in range(N):
        a = A[i]
        sum_ += a
        D.append(a ** 2)
    ans = (sum_ ** 2 - sum(D)) // 2
    print(ans % mod)










if __name__ == "__main__":
    main()

Measured memory_bytes: 100752
#include <iostream>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <algorithm>

using namespace std;

typedef long long signed int ll;

constexpr ll NIL = -20000000000;

int n,z[100][100];
set <int> t;

int main() {
    cin >> n;
    for(int i = 0;i < n;i++) {
        for(int j = 0;j < n;j++) {
            cin >> z[i][j];
            if(z[i][j] == -1) z[i][j] = 100000;
        }
    }
    int res = 0;
    t.insert(0);
    while(t.size() != n) {
        int me = 100000;int mi = -1;
        for(auto e:t) {
            for(int i = 0;i < n;i++) {
                if(me > z[e][i] && t.find(i) == t.end()) {
                    me = z[e][i];
                    mi = i;
                }
            }
        }
        res += me;
        t.insert(mi);
    }
    cout << res << endl;
}



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

int main(){
    int a,b;
    cin>>a>>b;
    if(a==1<b){
    cout<<"Alice"<<endl;
    }
    else if(b==1<a){
    cout<<"Bob"<<endl;
    }
    else if(a>b){
    cout<<"Alice"<<endl;
    }
    else if(b>a){
    cout<<"Bob"<<endl;
    }
    else{
        cout<<"Draw"<<endl;

    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 1e5 + 10;

// 3 5 7
// 0 1 2
int num[12], cnt;

pair<int, int> xx(int x) {
    int ans = 0, f = 0;
    cnt = 0;
    while(x) {
        int c = x % 3; x /= 3;
        if (!c) { f |= 1; num[cnt++] = 3; }
        if (c == 1) { f |= 2; num[cnt++] = 5; }
        if (c == 2) { f |= 4; num[cnt++] = 7; }
    }
    for(int i = cnt - 1; ~i; --i) ans = ans * 10 + num[i];
    return make_pair(ans, f);
}

int main() {
    ios::sync_with_stdio(0);
    int n, ans = 0;
    cin >> n;
    // for(int i = 0; ; i++) {
    //     pair<int, int> c = xx(i);
    //     cout << c.first << " " << c.second << endl;
    //     if(c.first > n) break;
    //     if(c.second == 7) ans += 1;
    // }
    // cout << ans << endl;
    unordered_set<ll> p, q;
    p.insert(3);
    p.insert(5);
    p.insert(7);
    ll k = 1;
    while(1) {
        int f = 1;
        q = p;
        k *= 10;
        //cout << k << *q.begin() << endl;
        while(!q.empty()) {
            int num = *q.begin(); q.erase(num);
            //cout << num << endl;
            p.insert(3 * k + num);
            p.insert(5 * k + num);
            p.insert(7 * k + num);
            if(7 * k + num > n) f = 0;
        } 
        if(!f) break;
    }
    for(auto c: p) {
        int cnt = 0, cc = c;
        if(c > n) continue;
        while(c) {
            int k = c % 10; c /= 10;
            if(k == 3) cnt |= 1;
            if(k == 5) cnt |= 2;
            if(k == 7) cnt |= 4;
            if(!k) cnt |= 8;
        }
        //if(cnt == 7) cout << cc << endl;
        ans += cnt == 7;
    }
    cout << ans << endl;
}

Measured memory_bytes: 35112
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
const int INF = 1<<29;
int n,c;
int f[20][20001];
int dist[20][100][100];
int G[100][100];
int cost[100];
bool used[100];

typedef pair<int,int> E;

void setcost(int cp,vector<int> x,vector<int> r){
  f[cp][0] = 0;
  x.push_back(20000);
  int curx = 1;
  for(int i=0;i<x.size();++i){
    for(int j=curx;j<=x[i];++j)
      f[cp][j] = f[cp][j-1]+r[i];
    curx = x[i]+1;
  }
}

int dijkstra(int s,int g){
  priority_queue<E, vector<E>, greater<E> > Q;
  for(int i=0;i<n;++i)
    cost[i]=INF, used[i]=false;

  Q.push(E(0,s));
  while(!Q.empty()){
    E e = Q.top(); Q.pop();
    int d = e.first;
    int t = e.second;
    if(used[t]) continue;
    used[t] = true;
    cost[t] = min(cost[t],d);
    for(int i=0;i<n;++i){
      if(cost[i]<=d+G[t][i]) continue;
      Q.push(E(d+G[t][i],i));
    }
  }
  return cost[g];
}

int main(){
  int m,s,g;
  while(cin>>n>>m>>c>>s>>g,n){
    s--;g--;
    for(int k=0;k<c;++k)
      for(int i=0;i<n;++i)
	for(int j=0;j<n;++j)
	  dist[k][i][j] = INF;
    for(int i=0;i<n;++i)
      for(int j=0;j<n;++j)
	G[i][j] = INF;

    while(m--){
      int x,y,d,cp;
      cin>>x>>y>>d>>cp;
      x--;y--;cp--;
      dist[cp][x][y] = dist[cp][y][x] = min(dist[cp][x][y],d);
    }
    vector<int> crvnum(c);
    for(int i=0;i<c;++i) cin>>crvnum[i];
    for(int i=0;i<c;++i){
      vector<int> x,r;
      for(int j=0;j<crvnum[i]-1;++j){
	int a; cin>>a;
	x.push_back(a);
      }
      for(int j=0;j<crvnum[i];++j){
	int a;cin>>a;
	r.push_back(a);
      }
      setcost(i,x,r);
    }
    
    for(int cp=0;cp<c;++cp)
      for(int k=0;k<n;++k)
	for(int i=0;i<n;++i)
	  for(int j=0;j<n;++j)
	    dist[cp][i][j] = min(dist[cp][i][j], dist[cp][i][k]+dist[cp][k][j]);
    
    for(int cp=0;cp<c;++cp)
      for(int i=0;i<n;++i)
	dist[cp][i][i] = 0;
    
    for(int i=0;i<n;++i)
      for(int j=0;j<n;++j)
	for(int cp=0;cp<c;++cp)
	  if(dist[cp][i][j]<=20000)
	    G[i][j] = min(G[i][j], f[cp][dist[cp][i][j]]);
    int ans = dijkstra(s,g);
    if(ans==INF) ans = -1;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define mem(x, y) memset(x, y, sizeof(x))
#define pii pair<int, int>
#define pli pair<LL, int>
#define mkp make_pair
const int N = 105;
const int M = 10005;
int n;
bool f[M];

int main()
{
    scanf("%d", &n);
    f[0] = 1;
    for(int i = 0; i < n; i++) {
        int x; scanf("%d", &x);
        for(int j = M - 1; j >= 0; j--) {
            if(f[j] && j + x < M) f[j + x] = 1;
        }
    }
    for(int i = M - 1; i >= 0; i--) if(f[i] && i % 10) {
        printf("%d\n", i);
        return 0;
    }
    puts("0");
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
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;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;
//|\_
//g++ -std=c++1z temp.cpp
//./a.out



int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
    int i,n,t;
    list<int> li;
    vector<int> v;
    cin>>n;
    rep(i,n){
        cin>>t;
        li.push_back(t);
    }
    auto it=li.rbegin();
    auto itr=li.begin();
    t=li.size();
    int bt;
    while(t>0){
        t=li.size();
        bt=t;
        itr=li.begin();
        for(it=li.rbegin();it!=li.rend();it++){
            // cout<<*it<<"  "<<t<<endl;
            if(t==*it){
                v.push_back(*it);
                advance(itr,t-1);
                li.erase(itr);
                break;
            }
            t--;
            if(t<0){
                cout<<-1<<endl;
                return 0;
            }
        }
        
        t=li.size();
        if(bt==t){
            cout<<-1<<endl;
            return 0;
        }
    }
    
    for(i=v.size()-1;i>=0;i--){
        cout<<v[i]<<endl;
    }
//////////////////////////////////////////////////////
return 0;}










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

int main(){
  int n;
  while(cin>>n){
    int last = -1;
    for(int i=0;i<10 && (1<<i) <= n;i++){
      if(( (1<<i) & n )>>i == 0x1){
	if(last !=-1){
	  cout<<last<<" ";
	}
	last = (1<<i);
      }
    }
    if(last != -1)
      cout<<last;
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
while gets
  n, m = $_.split.map(&:to_i)
  dp = 3.times.map{ [-1] * (m + 1) }
  3.times{ |i| dp[i][0] = 0 }
  n.times do
    gets
    l = gets.split.map(&:to_i)
    3.times do |i|
      (m - l[0] + 1).times do |j|
        if dp[i][j] != -1
          dp[i][j + l[0]] = dp[i][j] + l[i + 1] if dp[i][j + l[0]] < dp[i][j] + l[i + 1]
        end
      end
    end
  end
  p dp.flatten.max
end

Measured memory_bytes: 9308
package main

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

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buff, bufio.MaxScanTokenSize*1024)
	log.SetFlags(log.Lshortfile)
}

func main() {
	N := nextInt()
	var cnt [10][10]int
	for i := 1; i < N+1; i++ {
		s := strconv.Itoa(i)
		btm := int(s[len(s)-1] - '0')
		top := int(s[0] - '0')
		cnt[top][btm]++
	}
	ans := 0
	for i := 0; i < 10; i++ {
		for j := 0; j < 10; j++ {
			ans += cnt[i][j] * cnt[j][i]
		}
	}
	fmt.Println(ans)
}

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

func nextFloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextInts(n int) (r []int) {
	r = make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 1920
package main

import (
   "fmt"
)

func solution(n int, s []string) []string {
   var ac, wa, tle, re int
   for _, t := range s {
        switch t {
        case "AC":
                ac++
        case "WA":
                wa++
        case "TLE":
                tle++
        case "RE":
                re++
        }
   }
   return []string{fmt.Sprintf("AC x %v", ac), fmt.Sprintf("WA x %v", wa), fmt.Sprintf("TLE x %v", tle), fmt.Sprintf("RE x %v", re)}
}

func main() {
   var n int
   fmt.Scan(&n)
   s := make([]string, n)
   for i := range s {
        fmt.Scan(&s[i])
   }
   for _, t := range solution(n, s) {
        fmt.Println(t)
   }
}

Measured memory_bytes: 6852
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast", "unroll-loops")
using namespace std;
#define ll long long
#define int ll
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<int, int>
#define endl '\n'
//#define TOAD
#ifdef TOAD
#define bug(x) cerr<<__LINE__<<": "<<#x<<" is "<<x<<endl
#define IOS()
#else
#define bug(...)
#define IOS() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#endif
const ll inf = 1ll<<60;
const int iinf=2147483647;
const ll mod = 1e9+7;
const ll maxn=5e3;
ll pw(ll x, ll p){
    ll ret=1;
    while (p>0){
        if (p&1){
            ret*=x;
            ret%=mod;
        }
        x*=x;
        x%=mod;
        p>>=1;
    }
    return ret;
}
ll inv(ll x){
    return pw(x, mod-2);
}
int n; 
vector<string> ans;
void bt(string cur, int siz, char mx){
    if (siz>=n-1){
        ans.pb(cur);
        return;
    }
    for (char i='a';i<=mx+1; i++){
        char nw;
        if (i>mx) nw=i;
        else nw=mx;

        bt(cur+i, siz+1, nw);
    }
    


}
signed main(){
    IOS()
    cin>>n;
    bt("a", 0, 'a');
    REP(i,SZ(ans)){
        cout<<ans[i]<<endl;
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

// mod. m での a の逆元 a^{-1} を計算する
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;

    rep(i,k){
        ll ans = 1;
        //k個のボールをj箇所にいれる。
        ll j = i+1;
        //j=1,2,3....k
        //場所はn-k+1 C j
        //配置は k C j-1

        rep(x,j){
            ans *= (n-k+1-x);
            ans %= MOD;
            ans *= modinv(j-x,MOD);
            ans %= MOD;
        }
        //k個のボールをjつに分割するために、
        rep(y,j-1){
            ans *= (k-1-y);
            ans %= MOD;
            ans *= modinv(j-1-y,MOD);
            ans %= MOD;
        }
        cout<<ans<<endl;
    }
    return  0;

}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 922337203685477580LL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

struct UnionFind {
  vector<int> par; // 親を指すvector,-par[親]は木のサイズ
  UnionFind(int n):par(n, -1) {} // uniteで親を埋め込んでいく必要あり
  int root(int x) { // 親をたどる&データの整理
    if(par[x] < 0) return x;
    return par[x] = root(par[x]);
  }
  bool unite(int x, int y) { // データの結合
    x = root(x);
    y = root(y);
    if(x == y) return false;
    if(par[x] > par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }
  bool same(int x, int y) {return root(x) == root(y);} // 所属判定
  int size(int x) {return -par[root(x)];} // 木のサイズ
};

//head

int n, m;
int ama;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  UnionFind uft(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    uft.unite(a, b);
  }
  rep(i, n) if(uft.root(i) == i) chmax(ama, uft.size(i));
  cout << ama << endl;
}

Measured memory_bytes: 3976
#include<stdio.h>

int main()
{
	int a,b;
	char op;
	int ans[1000];
	int i=0,count=0;
	
	while(1){
		scanf("%d %c %d",&a,&op,&b);
		
		if(op == '?') break;
		
		switch(op){
			case '+':
				ans[i] = a + b;
				break;
			case '-':
				ans[i] = a - b;
				break;
			case '*' :
				ans[i] = a * b;
				break;
			case '/' :
				ans[i] = a / b;
				break;
			default:
				break;
		}
		count++;
		i++;
	}
	
	for(i=0;i<count;i++) printf("%d\n",ans[i]);
				
	return 0;
}
		



Measured memory_bytes: 2100
#include <stdio.h>

int main() {
    float x1, y1, x2, y2, x3, y3, xp, yp, z1, z2, z3;
    while ( scanf("%f %f %f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp) != EOF ) {
        z1 = (x2 - x1) * (yp - y2) - (y2 - y1) * (xp - x2);
        z2 = (x3 - x2) * (yp - y3) - (y3 - y2) * (xp - x3);
        z3 = (x1 - x3) * (yp - y1) - (y1 - y3) * (xp - x1);

        if ( (z1 > 0 && z2 > 0 && z3 > 0) || (z1 < 0 && z2 < 0 && z3 < 0) )
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 2020
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
typedef long long lint;
const int N=2e5+5;
int n;
struct data{
	int x,y;
	friend bool operator < (const data &a,const data &b){
		return a.x==b.x?a.y<b.y:a.x<b.x;
	}
}dt[N];

namespace utils{
	inline int nxi(FILE *fd=stdin){
		int x=0;
		char c;
		while(((c=fgetc(fd))>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=fgetc(fd));
		while(x=x*10-48+c,(c=fgetc(fd))>='0'&&c<='9');
		return f?-x:x;
	}

	template <class T>
	inline void apx(T &x,const T y){
		x<y?x=y:0;
	}

	template <class T>
	inline void apn(T &x,const T y){
		x>y?x=y:0;
	}
}
using namespace utils;

lint s1(){
	int n1,x1,n2,x2;
	n1=x1=dt[1].x;
	n2=x2=dt[1].y;
	for(int i=2; i<=n; ++i){
		apn(n1,dt[i].x),apx(x1,dt[i].x);
		apn(n2,dt[i].y),apx(x2,dt[i].y);
	}
	return (lint)(x1-n1)*(x2-n2);
}

lint s2(){
	int xr=0;
	for(int i=1; i<=n; ++i){
		apx(xr,dt[i].y);
	}
	const int wgt=xr-dt[1].x;
	int len=2e9,npos=2e9,xpos=0;
	for(int i=1; i<n; ++i){
		apn(npos,dt[i].y);
		apx(xpos,dt[i].y);
		int l=std::min(npos,dt[i+1].x);
		int r=std::max(xpos,dt[n].x);
		apn(len,r-l);
	}
	return (lint)len*wgt;
}

int main(){
	n=nxi();
	for(int i=1; i<=n; ++i){
		dt[i].x=nxi(),dt[i].y=nxi();
		if(dt[i].x>dt[i].y){
			std::swap(dt[i].x,dt[i].y);
		}
	}
	std::sort(dt+1,dt+n+1);
	printf("%lld\n",std::min(s1(),s2()));
	return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <iomanip>

using namespace std;

#define N 310
#define A 3

int main() {
  int32_t n;
  cin >> n;

  auto cnt = new int32_t[A];
  for (int32_t i = 0; i < A; ++i) {
    cnt[i] = 0;
  }
  for (int32_t i = 0; i < n; ++i) {
    int32_t a;
    cin >> a;
    cnt[a-1] += 1;
  }

  auto dp = new long double[N][N][N];
  dp[0][0][0] = 0.0;
  for (int32_t i = 0; i <= n; ++i)
    for (int32_t j = 0; j <= n - i; ++j)
      for (int32_t k = 0; k <= n - i - j; ++k) {
        auto sum = i + j + k;
        if (sum == 0) continue;
        dp[i][j][k] = (long double)n / sum;
        long double p = 0.0;
        if (i > 0) {
          dp[i][j][k] += ((long double) i / sum) * dp[i-1][j+1][k];
        }
        if (j > 0) {
          dp[i][j][k] += ((long double) j / sum) * dp[i][j-1][k+1];
        }
        if (k > 0) {
          dp[i][j][k] += ((long double) k / sum) * dp[i][j][k-1];
        }
      }

  cout << fixed << setprecision(10) << dp[cnt[2]][cnt[1]][cnt[0]] << endl;
}


Measured memory_bytes: 452224
#include <iostream>

int main(void){
    
    std::string days[6] = {"MON","TUE","WED","THU","FRI","SAT"};
    int sunDayIndex = 7;
    
    std::string inputDay;
    std::cin >> inputDay;
    
    
    if(inputDay == "SUN") {
        std::cout << 7 << std::endl;
    } else {
        
        for(int i = 0; i < 6; ++i) {
            if(days[i] == inputDay) {
                
                std::cout << (7 - (i+1)) << std::endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        if (a < 10 && b < 10) {
            System.out.println(a * b);
        } else {
            System.out.println(-1);
        }
    }
}


Measured memory_bytes: 23636
import sys
sys.setrecursionlimit(1000000000)
N=int(input())
ABC=[]
for _ in range(N):
    ABC.append(list(map(int,input().split())))
from functools import lru_cache
@lru_cache(maxsize=None)
def dynam(n):
    if n>1:
        a=max(dynam(n-1)[1]+ABC[n-1][0],
              dynam(n-1)[2]+ABC[n-1][0])
        b=max(dynam(n-1)[0]+ABC[n-1][1],
              dynam(n-1)[2]+ABC[n-1][1])
        c=max(dynam(n-1)[0]+ABC[n-1][2],
              dynam(n-1)[1]+ABC[n-1][2])
        return (a,b,c)
    return tuple(ABC[0])
print(max(dynam(N)))

Measured memory_bytes: 155656
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n,m;
    cin>>n>>m;
    vector<string>a(n),b(m);
    rep(i,n)cin>>a[i];
    rep(i,m)cin>>b[i];
    int n1=a[0].size(),n2=b[0].size();
    bool ans=false;
    for(int i=0; i<=n-m; ++i){
        for(int j=0; j<=n1-n2; ++j){
            bool ok=true;
            for(int k=0; k<m; ++k){
                for(int l=0; l<n2; ++l){
                    if(a[i+k][j+l]!=b[k][l])ok=false;
                }
            }
            if(ok==true)ans=true;
        }
    }
    cout<<(ans==true?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
/*
100 6
1 1
2 3
3 9
4 27
5 81
6 243
*/
#include <bits/stdc++.h>
using namespace std;
void print() { cout << '\n'; } template<class T, class ...U> void print(T x, U ...y) { cout << x << ' '; print(y...); }
typedef long long ll; const int N = 2e5 + 5, M = 1e9 + 7; typedef vector<int> vi; typedef vector<vi> vii; void Main();
int main(int argc, char **argv) {
  ios::sync_with_stdio(0), cin.tie(0); cout << setprecision(10) << fixed;
  #ifdef Zmm
  freopen((string(*(argv)).substr(2, string(*(argv)).size() - 6) + string(".cpp")).c_str(), "r", stdin); string x; cin >> x;
  #endif
  Main();
}

// struct node {
//   int a, b;
//   bool operator<(const node &c) const { return a * c.b < c.a * b; }
// } a[N];
int a[N], b[N], dp[N];
void Main() {
  int h, n;
  cin >> h >> n;
  for (int i = 1; i <= n; i++) cin >> a[i] >> b[i];
  for (int i = 1; i <= h; i++) dp[i] = 0x3f3f3f3f;
  // sort(a, a + n);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= h; j++) {
      dp[j] = min(dp[max(j - a[i], 0)] + b[i], dp[j]);
    }
  }
  cout << dp[h] << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
using namespace std;
using Int = long long;

int main()
{
    int N, K; cin >> N >> K;
    vector<Int> S(N+1);
    S[0] = 0;
    for (int i = 1; i <= N; i++) {
        int a; cin >> a;
        S[i] = S[i-1] + a;
    }
    vector<Int> beauty;
    for (int l = 1; l <= N; l++) {
        for (int r = l; r <= N; r++) {
            beauty.push_back(S[r] - S[l-1]);
        }
    }
    for (int i = 62; i >= 0; i--) {
        Int bit = (Int)1 << i;
        int c = 0;
        for (Int b : beauty) {
            if (b & bit) c++;
        }
        if (c < K) continue;
        vector<Int> bs;
        bs.reserve(c);
        for (Int b : beauty) {
            if (b & bit) bs.push_back(b);
        }
        beauty.swap(bs);
    }
    Int ans = beauty[0];
    for (Int b : beauty) {
        ans &= b;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6388
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<(b)?(a=b,1):0)
#define chmin(a,b) (a>(b)?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int main() {
  int n;
  while(cin >> n) {
    ll ans = 0;
    bool f = 1;
    REP(i,n) {
      char p;
      int a;
      cin >> p >> a;
      if (p == '(') ans += a;
      else ans -= a;
      if (ans < 0) f = 0;
    }
    if (ans) f = 0;
    cout << (f?"YES":"NO") <<endl;
  }
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
const int64_t MOD = 1000000007;

int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> p(N);
  int64_t sum=0,x=0;
  
  for(int64_t i=0;i<N;i++){
    cin >> p.at(i);
  }
  
  for(int64_t i=N-1;i>0;i--){
    x+=p.at(i) % MOD;
    x%= MOD;
    sum += x * p.at(i-1) % MOD;
  }
  
  sum %= MOD;
  cout << sum << endl;
}

Measured memory_bytes: 4844
#include <stdio.h>

int main(void) {

        int Height, Width, n;

        

        while(1) {

            scanf("%d%d", &Height, &Width);

            

            //どちらも0の場合、処理を終了する

            if((Height == 0) && (Width == 0)) {

                break;

            }

            

            n = 0;

            for(int i = 0; i < Height; i++) {

                n = ++n % 2;

                for(int j = 0; j < Width; j++) {

                        //nと同じ場合、"."を出力

                    if(j % 2 == n) {

                        printf(".");

                    }

                    //"#"を出力

                    else {

                        printf("#");

                    }

                }

                printf("\n");

            }

            printf("\n");

        }

        return 0;

}


Measured memory_bytes: 2132