akhauriyash/Code-Regression huggingface dataset:
#include <iostream> 
#include <vector>
#include <cmath>
#include <string>
#include <sstream>
#include <algorithm>
#include <queue>
#include <stack>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <cctype>
#include <climits>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;

using ll = long long int;

#define mp(a,b) make_pair(a,b)

const int MOD = 1000 * 1000 * 1000 + 7;

bool res() {
	string s;
	cin >> s;
	if (!cin) return false;

	if (s[0] == s[1] && s[1] == s[2]) cout << "No\n";
	else cout << "Yes\n";

	return true;
}

int main() {
	while (res()) {}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a[100];
  cin>>n;
  for(int i=0;i<n;++i) cin>>a[i];
  int min=a[0],sum=a[0];
  for(int i=1;i<n;++i){
    sum+=a[i];
    if(sum/(i+1)<min) min=sum/(i+1);
  }
  cout<<min<<endl;
  return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	long long int N,A,B; 
	cin >> N >> A >> B;
  	if(A % 2 == B % 2){
      	cout << (B-A)/2 << endl;
    }
    else{
      	long long int c=(A+B-1)/2;
      	long long int d=(2*N-A-B+1)/2;
      	if(c>d){
          c=d;
        }
    	cout << c << endl;
    }
}
    

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

int main() {
  int n;cin>>n;
  vector<tuple<string,int,int>> tpl(n+1);
  for(int i=1;i<=n;i++){
    string s;int p;cin>>s>>p;
    p=-p;
    tpl[i]=make_tuple(s,p,i);
  }
  sort(all(tpl));
  for(int i=1;i<=n;i++){
    cout<<get<2>(tpl[i])<<endl;
  }
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main()
{
  int H,W,h,w;
  cin>>H>>W>>h>>w;
  cout<< H*W-h*W-w*H+h*w <<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int sum = 0;
        int apple = 1000000;
        int n = Integer.parseInt(sc.next());
        int l = Integer.parseInt(sc.next());
        sc.close();
        for(int i=0;i<n;i++){
            sum+=l+i;
            if(Math.abs(apple) > Math.abs(l+i)){
                apple = l+i;
            }
        }
        System.out.println(sum-apple);
    }
}

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

int main() {
    int S;
    cin >> S;
    int A = S / 1000, B = S / 100 % 10, C = S / 10 % 10, D = S % 10;
    for(int i = 0; i < 2; i++) {
        for(int j = 0; j < 2; j++) {
            for(int x = 0; x < 2; x++) {
                int result = A;
                char tmp1, tmp2, tmp3;
                if(i % 2 == 0) {
                   result += B;  
                   tmp1 = '+';
                } else {
                    result -= B;
                    tmp1 ='-';
                }
                if(j % 2 == 0) {
                   result += C;
                   tmp2 = '+';  
                } else {
                    result -= C;
                    tmp2 = '-';
                }
                if(x % 2 == 0) {
                   result += D;
                   tmp3 = '+';  
                } else {
                   result -= D;
                   tmp3 = '-';
                }
                if(result == 7) {
                    printf("%d%c%d%c%d%c%d=7", A, tmp1, B, tmp2, C, tmp3, D);
                    return 0;
                }
            }
        }
    }
    return 0;
}

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



void solve(int testCase){

    ll a , b , c , d;
    scanf("%lld %lld %lld %lld" , &a , &b , &c , &d);

    cout << max({a * c , a * d , b * c , b * d});


}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


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

#[allow(dead_code)]
const MOD: usize = 1_000000000 + 7;

fn main() {
    let mut cin = Scanner::new();
    let n = cin.next_usize();
    let mut map = HashMap::new();
    for _ in 0..n {
        let v = cin.next_i64();
        let x = map.get(&v).unwrap_or(&0) + 1;
        map.insert(v, x);
    }
    println!("{}", map.iter().fold(0, |acc, (_,v)| acc + v % 2));
}


struct Scanner {
    reader: std::io::Stdin,
    tokens: std::collections::VecDeque<String>,
}

impl Scanner {
    fn new() -> Self {
        Scanner {
            reader: std::io::stdin(),
            tokens: std::collections::VecDeque::new(),
        }
    }

    fn next(&mut self) -> String {
        if self.tokens.is_empty() {
            let mut s = String::new();
            loop {
                self.reader.read_line(&mut s).ok();
                let s = s.trim();
                if s.len() != 0 {
                    for it in s.split_whitespace() {
                        self.tokens.push_back(it.into())
                    }
                    break;
                }
            }
        }
        self.tokens.pop_front().unwrap()
    }

    fn next_generics<T>(&mut self) -> T where
        T: std::str::FromStr + std::marker::Copy,
        <T as std::str::FromStr>::Err: std::fmt::Debug
    {
        self.next().parse().unwrap()
    }
    
    #[allow(dead_code)] fn next_i32(&mut self) -> i32 { self.next_generics::<i32>() }
    #[allow(dead_code)] fn next_i64(&mut self) -> i64 { self.next_generics::<i64>() }
    #[allow(dead_code)] fn next_u64(&mut self) -> u64 { self.next_generics::<u64>() }
    #[allow(dead_code)] fn next_usize(&mut self) -> usize { self.next_generics::<usize>() }
    #[allow(dead_code)] fn next_isize(&mut self) -> isize { self.next_generics::<isize>() }
}



Measured memory_bytes: 12540
#include<stdio.h>

char map[9][9];

void solve(int x,int y){
  int in;

  for(in=1;in<4;in++)
    if(x+in<8&&map[y][x+in]=='1'){
      map[y][x+in]='0';
      solve(x+in,y);
    }
  for(in=-1;in>-4;in--)
    if(x+in>-1&&map[y][x+in]=='1'){
      map[y][x+in]='0';
      solve(x+in,y);
    }
  for(in=1;in<4;in++)
    if(y+in<8&&map[y+in][x]=='1'){
      map[y+in][x]='0';
      solve(x,y+in);
    }
  for(in=-1;in>-4;in--)
    if(y+in>-1&&map[y+in][x]=='1'){
      map[y+in][x]='0';
      solve(x,y+in);
    }
}
int main(){
  int i,j,n,x,y;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<8;j++)
      scanf("%s",map[j]);
    scanf("%d",&x);
    scanf("%d",&y);
    map[y-1][x-1]='0';
    solve(x-1,y-1);
    printf("Data %d:\n",i+1);
    for(j=0;j<8;j++) printf("%s\n",map[j]);
  }
 return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3
import sys
import numpy as np

def solve(N: int, K: int, x: "List[int]"):
    x = np.array(x)
    score = 10**9
    x_s = sorted(x[x < 0], reverse=True)
    x_plus = x[x >= 0]
    x_len_plus = len(x_plus)
    x_len_minus = len(x_s)
    for right in range(min(K + 1, x_len_plus + 1)):
        left = min(K - right, x_len_minus)
        if right + left == K:
            if x_len_plus > 0:
                rpath = x_plus[right - 1]
            else:
                rpath = 0
            if x_len_minus > 0:
                lpath = abs(x_s[left - 1])
            else:
                lpath = 0
            score = min(score, rpath + lpath + min(rpath, lpath))

    print(score)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N, K = map(int, input().split())
    x = list(map(int, input().split()))
    solve(N, K, x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 23136
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>



int main(void) {
    char s[10];
    scanf("%s", s);
    if (strcmp(s, "ABC") == 0) {
        printf("ARC\n");
    }
    else {
        printf("ABC\n");
    }
    return 0;
}

Measured memory_bytes: 2060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+9;
struct edge{
    int to,next;
}edges[maxn<<1];
int head[maxn];
void addedge(int from,int to,int no){
    edges[no].to=to;
    edges[no].next=head[from];
    head[from]=no;
}
int n,m;
bool odd[maxn],eve[maxn];
void sol(int o){
    if(o>n){
        o-=n;
        odd[o]=1;
        for(int i=head[o];~i;i=edges[i].next){
            if(!eve[edges[i].to]){
                sol(edges[i].to);
            }
        }
    }
    else{
        eve[o]=1;
        for(int i=head[o];~i;i=edges[i].next){
            if(!odd[edges[i].to]){
                sol(edges[i].to+n);
            }
        }
    }
}
int main(){
    ios::sync_with_stdio(0);
    int e,f;
    while(cin>>n>>m){
        memset(head,-1,sizeof(head));
        memset(odd,0,sizeof(odd));
        memset(eve,0,sizeof(eve));
        for(int i=0;i<m;i++){
            cin>>e>>f;
            addedge(e,f,i<<1);
            addedge(f,e,i<<1|1);
        }
        sol(1);
        ll a=0,b=0;
        ll ans=n;
        ans*=(n-1);
        ans/=2;
        ans-=m;
        for(int i=1;i<=n;i++){
            if(odd[i]&&!eve[i])a++;
            if(!odd[i]&&eve[i])b++;
        }
        ans-=a*(a-1)/2;
        ans-=b*(b-1)/2;
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 3328
//2019.5.13 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-10
#define RG register
inline int read() {
    res s=0,ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline LL Read() {
    RG LL s=0;
    res ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
const int N=2e5+10;
namespace MAIN {
    int n,m,l,s,t,p;
    char S[N],T[N];
    inline void put(){
        puts("NO");exit(0);
    }
    inline void MAIN(){
        n=read(),m=read(),l=read(),s=read(),t=read(),scanf("%s%s",S+1,T+1);
        p=t;
        for(res i=1;i<=l;i++){
            if(S[i]=='R')p++;
            if(p>m)put();
            if(T[i]=='L'&&p>1)p--;
        }
        p=t;
        for(res i=1;i<=l;i++){
            if(S[i]=='L')p--;
            if(p<1)put();
            if(T[i]=='R'&&p<m)p++;
        }
        p=s;
        for(res i=1;i<=l;i++){
            if(S[i]=='D')p++;
            if(p>n)put();
            if(T[i]=='U'&&p>1)p--;
        }
        p=s;
        for(res i=1;i<=l;i++){
            if(S[i]=='U')p--;
            if(p<1)put();
            if(T[i]=='D'&&p<n)p++;
        }
        puts("YES");
    }
}
int main() {
//    srand((unsigned)time(NULL));
//    freopen("graph.in","r",stdin);
//    freopen("graph.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 640
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

mini = float('inf')
res = 0

for i in range(len(H)):
    spot = T - H[i] * 0.006
    if abs(spot - A) < mini:
        mini = abs(spot - A)
        res = i+1

print(res)

Measured memory_bytes: 9212
#include<iostream>
#include<cmath>
#include<bitset>
#include<cstdlib>
#include<cstdio>
#include<vector>
using namespace std;
typedef long long ll;

int main()
{

  int N;
  cin >> N;
  while(N-- > 0)
    {
      ll s;
      cin >> hex >> s;

      bool c = (s>>31)&1?true:false;


      ll a,b,t;
      char *e;
      a = b = s;
      t = strtol("7fffffff",&e,16);
   
      a &= t;
      a >>= 7;
      t = strtol("0000007f",&e,16);
      b &= t;
      bitset<7> dou(b);
      ll new_b = 0;
      vector<ll> val(7);
      val[6] = 5000000;
      for(int i=5;i>=0;i--)
	  val[i] = val[i+1]*0.5;


      for(int i = 6;i>=0;i--)
	{
	  if(dou[i])
	    new_b += val[i];
	}
      if(c)
    cout << "-";
      cout << a;
      cout << ".";
      if(!new_b)
    cout << 0 << endl;
      else
    {
      cout << string(6-(int)log10(new_b),'0');
      while(new_b/10*10 == new_b)
        new_b /= 10;
      cout << new_b << endl;
    }
    }
  return 0;
}

Measured memory_bytes: 1268
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;

int v[100], dp[50][50][100];

int f(int i, int j, int k) {
	if (k == 0 || i > j)
		return 0;
	if (dp[i][j][k] != -1)
		return dp[i][j][k];
	int ans = 0;
	if (k > 0) {
		ans = max(v[i] + f(i + 1, j, k - 1), ans);
		ans = max(v[j] + f(i, j - 1, k - 1), ans);
	}
	if (k > 1) {
		ans = max(f(i + 1, j, k - 2), ans);
		ans = max(f(i, j - 1, k - 2), ans);
	}
	return dp[i][j][k] = ans;
}

int main() {
	int n, k; cin >> n >> k;
	for (int i = 0; i < n; i++) cin >> v[i];
	memset(dp, -1, sizeof(int) * 250000);
	cout << f(0, n - 1, k) << endl;

	return 0;
}

Measured memory_bytes: 1280
si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
lmsi = lambda: list(map(str, input().split()))
smii = lambda: sorted(map(int, input().split()))

# ----------

N, x = mii()
A = lmii()

ans = 0
for i in range(1, N):
    if A[i] + A[i-1] > x:
        need = A[i] + A[i-1] - x
        ans += need
        if A[i] >= need:
            A[i] -= need
        else:
            A[i-1] = need - A[i]
            A[i] = 0

print(ans)




Measured memory_bytes: 14276
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int k;

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

int main() {
	int a,b;
	while(cin>>a>>b,a){
		k=0;
		if(a>b){cout<<gcd(a,b);cout<<" "<<k<<endl;}
		else{cout<<gcd(b,a);cout<<" "<<k<<endl;}
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
#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 rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    ll N;
    cin >> N;
    VI dp(110000);
    dp[0]=0;
    for(int n=1; n<=100000; n++){
        dp[n]=INF;
        int power=1;
        while(power<=n){
            dp[n]=min(dp[n],dp[n-power]+1);
            power*=6;
        }
        power=1;
        while(power<=n){
            dp[n]=min(dp[n],dp[n-power]+1);
            power*=9;
        }
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
vector<int> G[100010];

int dfs(int v, int p = -1) {
	int res = 0;
	rep(i, 0, G[v].size()) {
		int n = G[v][i];
		if(n == p) continue;
		res ^= (dfs(n, v) + 1);
	}
	return res;
}

void solve() {
	cin >> N;
	rep(i, 0, N - 1) {
		int a, b;
		cin >> a >> b; a--; b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	if(dfs(0)) cout << "Alice\n";
	else cout << "Bob\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

int main() {
  int P, Q, R;
  cin >> P >> Q >> R;
  int M = max(max(P, Q), R);
  int S = P + Q + R;
  cout << S - M << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}";
  return o;
}


ll const mod = 1e9+7;

int main() {
  int N;
  cin >> N;
  vector<vector<int>> A(N,vector<int>(N));
  rep(i,N) rep(j,N) cin >> A[i][j];
  vector<vector<ll>> dp(N+1,vector<ll>(1<<N,0));
  // cout << dp << endl;
  dp[0][0]=1;
  rep2(i,1,N+1) {
    rep(j,1<<N) {
      if (__builtin_popcount(j)==i) {
        // cout << bitset<4>(j) << endl;
        rep(k,N) if (A[i-1][k]) {
          dp[i][j] += dp[i-1][j&~(1<<k)];
          dp[i][j]%=mod;
        }
      }
    }
  }
  cout << dp[N][(1<<N)-1]%mod << endl;
}

Measured memory_bytes: 377216
#include <atcoder/all>
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
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);
}
/*-------------------------------------------*/

int n, k;
char ans[99][99];

const ll INF = 1 << 30;

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

    memset(ans, '.', sizeof(ans));

    cin >> n >> k;
    atcoder::mcf_graph<int, ll> graph(2 * n + 2);
    int S = 2 * n, T = 2 * n + 1;
    rep(i, n) rep(j, n) {
        int cost;
        cin >> cost;
        graph.add_edge(i, n + j, 1, INF - cost);
    }
    rep(i, n) graph.add_edge(S, i, k, 0);
    rep(j, n) graph.add_edge(n + j, T, k, 0);

    auto graph2 = graph;

    int flow = 0;
    ll cost = 0;
    for(auto p : graph2.slope(S, T)) {
        ll tmp = INF * p.first - p.second;
        if(chmax(cost, tmp)) flow = p.first;
    }
    graph.flow(S, T, flow);

    for(auto &&e : graph.edges())
        if(e.from != S && e.to != T && e.flow == 1) ans[e.from][e.to - n] = 'X';

    cout << cost << "\n";
    rep(i, n) rep(j, n) cout << ans[i][j] << (j + 1 == n ? "\n" : "");

    return 0;
}

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

using namespace std;

#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long                           //del this if TLE or MLE
#define ll long long
#define pr pair<int,int>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fow(i,a,b,c) for(int i=a;i<=b;i+=c)
#define bck(i,a,b,c) for(int i=a;i>=b;i-=c)
#define F first
#define S second
#define loop int tests;cin>>tests;while(tests--)

const int N=405;
const int inf=1e18;

int dp[N][N],a[N],pre[N];

int DP(int i,int j)
{
	if(i==j) 
		return 0;
	if(i+1==j) 
		return a[i]+a[j];
	if(dp[i][j]!=0)
		return dp[i][j];
	int Min=inf;
	for(int k=i;k<=j-1;k++)
	{
		int x=DP(i,k)+DP(k+1,j)+pre[k]-pre[i-1]+pre[j]-pre[k];
		if(x<Min) 
			Min=x;
	}
	return dp[i][j]=Min;
}

signed main()
{
	fastio;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) 
	{
		cin>>a[i];
		pre[i]=pre[i-1]+a[i];
 	}
	cout<<DP(1,n)<<'\n';
}



Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;

struct edge{ll from,to,cost;};
vector<vector<ll>> d;
vector<ll>flag;
ll res=1e13;
ll r;
vector<ll>rr;
vector<ll>s;
void dfs(int n,int depth)
{
  rep(i,r)//cout<<flag[i]<<" ";
  ////cout<<endl;
  if(depth==n)
  {
    ll tres=0;
    rep(i,r-1)
    {
      tres+=d[s[i+1]][s[i]];
    }
    chmin(res,tres);
    ////cout<<tres<<endl;
  }
  rep(i,n)
  {
    if(flag[i]==-1)
    {
      flag[i]=1;
      s[depth]=rr[i];
      dfs(n,depth+1);
      flag[i]=-1;
    }
  }

}

int  main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ////cout<<setprecision(10);
  ll n,m;
  cin>>n>>m>>r;
  rr=vector<ll>(r);
  rep(i,r){cin>>rr[i];rr[i]--;}
  d=vector<vector<ll>>(n,vector<ll>(n,1e16));
  rep(i,m)
  {
    ll a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    d[a][b]=c;
    d[b][a]=c;
  }
  rep(i,n)d[i][i]=0;
  rep(k,n)rep(i,n)rep(j,n)chmin(d[i][j],d[i][k]+d[k][j]);
  flag.resize(r);
  fill(all(flag),-1);
  s.resize(r);
  dfs(r,0);
  cout<<res<<endl;


  return 0;

}


Measured memory_bytes: 640
N = int(input())
p1, p2, p3, p4 = [[10**9, 10**9], [0, 0], [0, 10**9], [10**9, 0]]
ans = 0
for i in range(N):
    x, y = map(int, input().split())
    if p1[0] + p1[1] >= x + y:
        p1 = [x, y]
    if p2[0] + p2[1] <= x + y:
        p2 = [x, y]
    if p3[0] - p3[1] <= x - y:
        p3 = [x, y]
    if p4[0] - p4[1] >= x - y:
        p4 = [x, y]
P = [p1, p2, p3, p4]
for x1, y1 in P:
    for x2, y2 in P:
        ans = max(ans, abs(x1-x2)+abs(y1-y2))
print(ans)


Measured memory_bytes: 74152
#include<stdio.h>
int main()
{
    int a,b,c,sum;
    scanf("%d%d%d",&a,&b,&c);
    sum = a+b+c;
    if(sum>=22) printf("bust\n");

    else printf("win\n");

    return 0;
}
//UG02-49-18-012


Measured memory_bytes: 128
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using P = pair<int,int>;



int main() {
    int n,k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i,n) p[i]=0;
    int d;
    int a;
    rep(i,k){
        cin>>d;
        rep(j,d){
            cin >> a;
            --a;
            p[a]+=1;
        }
    }
    int ans=0;
    ans = count(p.begin(),p.end(),0);
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    string S;
    cin >> S;
    map<char,int> m;
    rep(i,4){
        m[S[i]]++;
    }
    string ans="Yes";
    for(auto p:m){
        if(p.second!=2) ans="No";
    }
    cout << ans << endl;


}


Measured memory_bytes: 256
// Tazoe

#include <iostream>
using namespace std;

int main()
{
while(true){
	int N, M;
	cin >> N >> M;
if(N==0&&M==0)  break;
	int S[1001];
	for(int i=1; i<=N; i++){
		cin >> S[i];
	}

	int D[1001];
	for(int i=1; i<=M; i++){
		cin >> D[i];
	}

	int P = 1;
	int I = 1;
	for(; I<=M; I++){
		P += D[I];
		if(P>=N)
			break;

		P += S[P];
		if(P>=N)
			break;
	}

	cout << I << '\n';
}
	return 0;
}

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

using int64 = long long;

int main()
{
    int N, M;
    std::cin >> N >> M;
    std::vector<int64> x(N), y(N), z(N);
    for (int i = 0; i < N; i++)
        std::cin >> x[i] >> y[i] >> z[i];

    int64 max = 0;
    for (int i = 0; i < 8; i++) {
        int sign_x = (i >> 2 & 1) ? 1 : -1;
        int sign_y = (i >> 1 & 1) ? 1 : -1;
        int sign_z = (i >> 0 & 1) ? 1 : -1;

        std::vector<int64> v;
        for (int j = 0; j < N; j++)
            v.emplace_back(x[j] * sign_x + y[j] * sign_y + z[j] * sign_z);

        std::sort(v.rbegin(), v.rend());
        int64 sum = 0;
        for (int j = 0; j < M; j++)
            sum += v[j];

        max = std::max(max, sum);
    }

    std::cout << max << std::endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)




#ifdef _MSC_VER
#include <intrin.h>

#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>



using namespace std;
//using namespace atcoder;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << endl
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-1]
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;
void Yes(bool cond) { cout << (cond ? "Yes" : "No") << '\n'; }
void YES(bool cond) { cout << (cond ? "YES" : "NO") << '\n'; }


void solve() {
	int N; cin >> N;
	vector<pii>v(N);
	REP(i, N) {
		int x, y; cin >> x >> y;
		v[i] = { x,y };
	}
	VSORT(v);
	pii mx, mn;
	mx = mn= { v[0].second,v[0].first};
	int ans = 0;
	REP(i, N) {
		int x = v[i].first, y = v[i].second;
		int res = abs(x - mx.second) + abs(y - mx.first);
		chmax(res, abs(x - mn.second) + abs(y - mn.first));
		chmax(ans, res);
		if (y - x > mx.first - mx.second)mx = { y,x };
		if (y + x < mn.first + mn.second)mn = { y,x };
	}
	print(ans);
}



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

	//int q;
	//cin >> q;
	//while (q--)
	solve();

}



Measured memory_bytes: 6376
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<queue>
const
int Mod=(int)1e9+7;
using namespace std;
int deg[100001],a[100001],num[100001],l[100001],d[100001];
bool vis[100001];
int Fact[100001],Inv[100001];
inline int Pow(int a,int x)
{
    int res=1;
    for(;x;x>>=1,a=a*1ll*a%Mod)
        if(x&1)res=a*1ll*res%Mod;
    return res;
}
queue<int>Q;
inline int C(int x,int y){return Fact[x]*1ll*Inv[y]%Mod*Inv[x-y]%Mod;}
#define x first
#define y second
#define mp make_pair
#define pb push_back

vector<pair<int,int> >Cir;

inline int pr(int n)
{
    return Fact[n<<1]*1ll*Inv[n]%Mod*Pow(Mod+1>>1,n)%Mod;
}
int main()
{
    Fact[0]=1;
    for(int i=1;i<=100000;i++)Fact[i]=Fact[i-1]*1ll*i%Mod;
    Inv[100000]=Pow(Fact[100000],Mod-2);
    for(int i=99999;~i;i--)Inv[i]=Inv[i+1]*(i+1ll)%Mod;
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",a+i),deg[a[i]]++;
    for(int i=1;i<=n;i++)if(deg[i]>2)return puts("0"),0;
    for(int i=1;i<=n;i++)if(!(d[i]=deg[i]))Q.push(i);
    while(!Q.empty())
    {
        int u=Q.front();Q.pop();
        vis[u]=1;
        if(!--d[a[u]])Q.push(a[u]);
    }
    for(int i=1;i<=n;i++)if(vis[i]&&deg[i]>1)return puts("0"),0;
    for(int i=1;i<=n;i++)if(vis[i]&&!deg[i])
    {
        int x=i,cnt=0;
        for(;vis[x];x=a[x])cnt++;
        l[x]=cnt;
    }
    int ans=1;
    for(int i=1;i<=n;i++)if(!vis[i])
    {
        int x=i,fl=0,tp=1,tot=0;
        for(;!vis[x];x=a[x])++tot,fl|=l[x],vis[x]=1;
        if(!fl){num[tot]++;continue;}
        Cir.clear();
        int p=1;x=i;
        do
        {
            if(l[x])Cir.pb(mp(l[x],p));
            x=a[x];p++;
        }while(x^i);
        Cir.pb(mp(Cir[0].x,Cir[0].y+tot));
        for(int j=1;j<Cir.size();j++)
            if(Cir[j].x>Cir[j].y-Cir[j-1].y)tp=0;
            else if(Cir[j].x^(Cir[j].y-Cir[j-1].y))tp=tp*2ll%Mod;
        ans=ans*1ll*tp%Mod;
    }
    
   // printf("%d\n",ans);
    for(int i=1;i<=n;i++)if(num[i])
    {
        int m=num[i],tp=0;
        for(int j=0;j<=m/2;j++)
        {
            int tp2=1ll*C(m,2*j)*pr(j)%Mod*Pow(i,j)%Mod;
            if(i>1&&(i&1))tp2=tp2*1ll*Pow(2,m-2*j)%Mod;
            tp=(tp+tp2)%Mod;
        }
        ans=ans*1ll*tp%Mod;
    }
    printf("%d\n",ans);
    return 0;
}


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

void Main() {
		int h, w;
	while (true) {
		cin >> h >> w;
		if (h == 0 && w == 0) {
			break;
		}
		bool isDot = false;
		for (int i = 0; i < h; i++) {
			isDot = (i % 2 != 0);
			for (int j = 0; j < w; j++) {
				if (isDot) {
				cout << '.';
				}
				else {
					cout << '#';
				}
				isDot = !isDot;
			}
			cout << endl;
		}
		cout << endl;
	}
}

int main() {
	std::cout << std::fixed << std::setprecision(15);
	Main();
}



Measured memory_bytes: 3088
#include <stdio.h>

typedef struct {
	int key, id;
} data;

typedef struct {
	data obj[250001];
	int size;
} min_heap;

void push(data x, min_heap* h)
{
	int i = ++(h->size);
	data tmp;
	h->obj[i] = x;
	while (i > 1) {
		if (h->obj[i].key < h->obj[i>>1].key) {
			tmp = h->obj[i>>1];
			h->obj[i>>1] = h->obj[i];
			h->obj[i] = tmp;
			i >>= 1;
		} else break;
	}
}

data pop(min_heap* h)
{
	int i = 1, j = 2;
	data output = h->obj[1], tmp;
	h->obj[1] = h->obj[(h->size)--];
	while (j <= h->size) {
		if (j < h->size && h->obj[j^1].key < h->obj[j].key) j ^= 1;
		if (h->obj[j].key < h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j = i << 1;
		} else break;
	}
	return output;
}

void add_BIT(int N, int BIT[], int i, int k)
{
	while (i <= N) {
		BIT[i] += k;
		i += (i & -i);
	}
}

int sum_BIT(int BIT[], int r)
{
	int sum = 0;
	while (r > 0) {
		sum += BIT[r];
		r -= (r & -r);
	}
	return sum;
}

int main()
{
	int i, H, W, A, B;
	scanf("%d %d", &H, &W);
	
	int j, k, s[200002], left[200002], right[200002], BIT[200001] = {}, L, R, M, tmp;
	data d;
	min_heap h;
	h.size = 0;
	for (i = 0; i <= W + 1; i++) {
		s[i] = i;
		left[i] = i - 1;
		right[i] = i + 1;
	}
	for (i = 1, d.key = 0; i <= W; i++) {
		d.id = i;
		push(d, &h);
		add_BIT(W, BIT, i, 1);
	}
	for (i = 1; i <= H; i++) {
		scanf("%d %d", &A, &B);
		tmp = sum_BIT(BIT, A - 1);
		if (sum_BIT(BIT, B) == tmp) {
			printf("%d\n", h.obj[1].key + i);
			continue;
		}
		
		L = A;
		R = B++;
		while (L < R) {
			M = (L + R) / 2;
			if (sum_BIT(BIT, M) > tmp) R = M;
			else L = M + 1;
		}
		
		left[B] = left[L];
		right[left[L]] = B;
		if (s[B] < 0) add_BIT(W, BIT, B, 1);
		for (j = L; j < B; j = right[j]) {
			s[B] = (s[j] > s[B])? s[j]: s[B];
			s[j] = -1;
			add_BIT(W, BIT, j, -1);
		}
		if (j != B) {
			left[j] = B;
			right[B] = j;
		}
		if (B <= W) {
			d.key = B - s[B];
			d.id = B;
			push(d, &h);
		}
		
		while (h.size > 0 && s[h.obj[1].id] < h.obj[1].id - h.obj[1].key) pop(&h);
		if (h.size > 0) printf("%d\n", h.obj[1].key + i);
		else break;
	}
	for (; i <= H; i++) printf("-1\n");
	fflush(stdout);
	return 0;
}


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

string word;
vector<int> As;

void for1(int i, int limit, int value)
{
  if(!(i<limit)){return;}
  if(i && word[i-1] == 'A' && word[i] == 'C'){value++;}
  As.push_back(value);
  for1(i+1, limit, value);
}

int main()
{
  int size, times, a, b;
  cin >> size >> times >> word;
  for1(0, size, 0);
  while(cin >> a >> b)
  {
    cout << (As[b-1] - As[a-1]) << endl;
  }
  return 0;
}

Measured memory_bytes: 1464
N,T = map(int,input().split(" "))
t = list(map(int,input().split(" ")))
scope = [[t[0],t[0]+T]]

for i in range(1,N):
	if t[i] < scope[-1][1]:
		scope[-1][1] = t[i] + T

	else:
		scope.append([t[i],t[i]+T])

total = 0
for begin,end in scope:
	total += (end - begin)

print(total)

	


Measured memory_bytes: 38896
import java.util.*;

class Main {
  static Scanner cin = new Scanner(System.in);
  public static void main(String[] args) {
   while (cin.hasNext()) {
     double n = cin.nextDouble(), ans = n;
     for (int i = 2; i <= 10; i++) {
       if (i % 2 == 0) {
         n *= 2;
         ans += n;
       } else {
         n /= 3;
         ans += n;
       }
     }
     System.out.println(ans);
   }
  }
}

Measured memory_bytes: 28128
#include <bits/stdc++.h>
using namespace std;
 long long int A[1000005],B[1000005],dp[100005][1],i,n,sum,say,a,b,c,d,e,f,mak,S,g,sum2,x,y,m,j,C[1000005],l,r;
 char s[1000005];
vector<int> v1,v2;

 

int main()
{	
 scanf("%lld",&S);
 n=(long long int) sqrt(S);
 l=n*(n+1)-S;
 r=(n+1)*(n+1)-S;
 m=min(l,r);
 printf("0 0 ");
 if(S==n*n){
	 
printf("%lld %lld %lld %lld",n,0,0,n);	 
 
	return 0; 
	 
 }
 if(l>=0){
printf("%lld %lld %lld %lld",n+1,1,l,n);	 
	return 0; 
	 
 }
 if(l<0){
	 
printf("%lld %lld %lld %lld",n+1,1,r,n+1);	 
 
	 
	 
	 
	return 0; 
 }
 
 //printf("%lld",n);

 
 

 
 
	return 0;
}

Measured memory_bytes: 2304
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int helth = scan.nextInt();
        int power = scan.nextInt();
        int sum = 0;
        for (int i = 0; i < power; i++) {
            sum = sum + scan.nextInt();
        }
        if(sum>=helth)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
    
}


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

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

Measured memory_bytes: 256
items = ['A', 'C', 'G', 'T']

def chkmax(a, b):
    return a if a > b else b

res = 0
cnt = 0
for c in list(input()):
    if c in items:
        cnt += 1
        res = chkmax(res, cnt)
    else:
        cnt = 0
print(res)



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

int main()
{
  int A, B;

  cin >> A >> B;

  if (A <= 5) {
    cout << 0 << endl;
  } else if (A <= 12) {
    cout << B / 2 << endl;
  } else {
    cout << B << endl;
  }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 20 09:37:56 2020

@author: NEC-PCuser
"""

N = int(input())

D = list(map(int, input().split()))


if D[0] != 0:
    print(0)
else:
    n_count = [0] * 100000
    for i in range(N):
        n_count[D[i]] += 1
        
    count = 1
    ans = 1
    for j in range(1, len(n_count)):
        count += n_count[j]
        if n_count[j] == 0:
            break
        else:
            ans = (ans * (n_count[j - 1] ** n_count[j])) % 998244353
    if (count != N):
        print(0)
    else:
        print(ans)
            

Measured memory_bytes: 20712
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, num[5];
    cin >> N;
    ll minnum = inf;
    REP(i, 0, 5) {
        cin >> num[i];
        minnum = min(minnum, num[i]);
    }
    ll ans = (N + minnum - 1) / minnum + 4;
    cout << ans << endl;
}


Measured memory_bytes: 256
module.exports=function(e){var r={};function n(t){if(r[t])return r[t].exports;var o=r[t]={i:t,l:!1,exports:{}};return e[t].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=r,n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,r){if(1&r&&(e=n(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(n.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)n.d(t,o,function(r){return e[r]}.bind(null,o));return t},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},n.p="",n(n.s=0)}([function(e,r,n){n(1)(n(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(e,r){e.exports=function(e){for(var r=Number(e[0]),n=e[1].split(" ").map(function(e){return Number(e)}),t=e[2].split(" ").map(function(e){return Number(e)}),o=new Array(r),u=0,i=0,f=0,l=0;l<r;l++)o[l]=n[l]-t[l],u+=o[l],o[l]<0&&(i-=o[l],f++);if(0!=f)if(u<0)console.log(-1);else{o.sort(function(e,r){return r-e});for(var c=f,a=0;a<r&&!(o[a]<=0)&&(c++,!(o[a]>i));a++)i-=o[a];console.log(c)}else console.log(0)}},function(e,r){e.exports=require("fs")}]);

Measured memory_bytes: 32208
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string a, b;
    cin >> a >> b;
    int m = a.length(), n = b.length();
    map<char, int> t;
    char small = 'z', big = 'a';
    for(int i = 0; i < m; i++) {
        if(a[i] < small)
            small = a[i];
    }
    for(int i = 0; i < n; i++) {
        if(b[i] > big)
            big = b[i];
        t[b[i]] += 1;
    }
    bool ok = false;
    if(m < n) {
        ok = true;
        for(int i = 0; i < m; i++) {
            if(!t.count(a[i]) || t[a[i]] == 0) {
                ok = false;
                break;
            }
            t[a[i]] -= 1;
        }
    }
    if(ok || small < big)
        cout << "Yes";
    else
        cout << "No";
}

Measured memory_bytes: 3620
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
TA = [LIST() for _ in range(N)]
vote_T = 1
vote_A = 1
for x, y in TA:
	n = max(-(-vote_T // x), -(-vote_A // y))
	vote_T = x * n
	vote_A = y * n
print(vote_A + vote_T)


Measured memory_bytes: 10048
import itertools
import copy as c
s=list(input())
S=[s[i//2] if i%2==0 else " " for i in range(len(s)*2-1) ]
Ssub=S
ans=0
T=[i for i in range(len(s)*2-1) if i%2==1]
for sss in range(len(s)):
  for ttt in list(itertools.combinations(T,sss)):
    for rrr in ttt:
      S[rrr]="+"
    S="".join(S).replace(" ","")
    ans+=eval("".join(S))
    S=c.deepcopy(Ssub)
#print(S,T)
print(ans)

Measured memory_bytes: 3568
#include<bits/stdc++.h>
#include<vector>
#define N 200005
using namespace std;
int n,f[N],a[N],w[N],lw,vis[N],vr[N],cnt;
vector<int> G[N];
void dfs(int t)
{
	int i;
	for(i=0;i<G[t].size();i++)
		if(!vis[G[t][i]]) dfs(G[t][i]);
	++cnt;
	for(i=0;i<G[t].size();i++)
		if(!vis[G[t][i]]) vr[a[G[t][i]]]=cnt;
	for(i=0;vr[i]==cnt;i++);
	a[t]=i;
}
int main()
{
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&f[i]);
	for(i=1;!vis[i];i=f[i]) vis[i]=1;
	memset(vis,0,sizeof(vis));
	for(;!vis[i];i=f[i]) vis[i]=1;
	for(i=1;i<=n;i++) if(vis[i]) w[++lw]=i;
	for(i=1;i<=n;i++) G[f[i]].push_back(i);
	for(i=1;i<=lw;i++) dfs(w[i]);
	for(i=2;i<=lw;i++)
		if(a[w[i]]!=a[w[i-1]]) break;
	if(i>lw&&(lw&1)) printf("IMPOSSIBLE");
	else printf("POSSIBLE");
	return 0;
}


Measured memory_bytes: 14080