akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int h, w, n;
bool fall(vector<string> &v) {

	bool ret = false;
	REP(i, w) {
		while (1) {
			bool updated = false;
			RREP(j, h - 1) {
				if (v[j + 1][i] == '.'&&v[j][i] != '.') {
					swap(v[j + 1][i], v[j][i]);
					updated = true;
					ret = true;
				}
			}
			if (!updated)break;
		}
	}
	return ret;
}
void erase(vector<string> &v) {
	vector<vector<bool>> b(h, vector<bool>(w, false));
	REP(i, w) {
		REP(j, h) {
			char c = v[j][i];
			int flag = 1;
			if (i <= w - n) {

				REP(k, n) {
					if (v[j][i + k] != c)flag = 0;
				}
				if (flag) {
					REP(k, n)b[j][i + k] = true;
				}
			}
			flag = 1;
			if (j <= h - n) {
				REP(k, n) {
					if (v[j + k][i] != c)flag = 0;
				}
				if (flag) {
					REP(k, n)b[j + k][i] = true;
				}
			}
		}
	}
	REP(i, w) {
		REP(j, h) {
			if (b[j][i])v[j][i] = '.';
		}
	}
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> h >> w >> n;
	vector<string> v(h);
	REP(i, h)cin >> v[i];
	auto tmp = v;
	int flag = 0;
	REP(i, w - 1) {
		REP(j, h) {

			tmp = v;

			swap(tmp[j][i], tmp[j][i + 1]);
			if (tmp == v)continue;
			fall(tmp);
			while (1) {
				erase(tmp);

				if (!fall(tmp))break;
			}

			int cnt = 0;
			REP(s, w) {
				REP(t, h) {
					if (tmp[t][s] == '.')cnt++;
				}
			}
			if (cnt == h*w)flag = 1;
		}
	}

	if (flag)cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 3188
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
import math


def solve(m, p, xs):
    total_prize = sum(xs) * (100 - p)
    number_of_winners = xs[m - 1]
    if not number_of_winners:
        return 0
    else:
        return math.floor(total_prize / number_of_winners)


if __name__ == "__main__":
    while True:
        n, m, p = map(int, input().split())
        if n == 0 and m == 0 and p == 0:
            break
        xs = array.array("H", (int(input()) for i in range(n)))
        print(solve(m, p, xs))

Measured memory_bytes: 7764
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin>>n;
	vector<int> p(n); rep(i,n) cin>>p[i];
	bool ans=false;
	bool flgg=true;
	for(int i=1;i<=n;i++){
		if(p[i-1]!=i){
			flgg=false;
			break;
		}
	}
	if(flgg) ans=true;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			vector<int> pp=p;
			swap(pp[i],pp[j]);
			bool flg=true;
			for(int i=1;i<=n;i++){
				if(pp[i-1]!=i){
					flg=false;
					break;
				}
			}
			if(flg){
				ans=true;
			}
		}
	}
	cout<<(ans?"YES":"NO")<<endl;
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

// https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/all/GRL_3_C

fn main() {
    let (_N, _M): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let (_A, _B): (Vec<usize>, Vec<usize>) = {
        let (mut _A, mut _B) = (vec![], vec![]);
        for _ in 0.._M {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            _A.push(iter.next().unwrap().parse().unwrap());
            _B.push(iter.next().unwrap().parse().unwrap());
        }
        (_A, _B)
    };
    let Q: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let (u, v): (Vec<usize>, Vec<usize>) = {
        let (mut u, mut v) = (vec![], vec![]);
        for _ in 0..Q {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            u.push(iter.next().unwrap().parse().unwrap());
            v.push(iter.next().unwrap().parse().unwrap());
        }
        (u, v)
    };
    // snip
    let _G = {
        let mut _G = vec![std::collections::HashSet::new(); _N + 1];
        for i in 0.._M { _G[_A[i]].insert(_B[i]); }
        _G
    };
    // snip

    let (V, E) = (_N, _M);
    let (s, t) = (_A, _B);
    let G = _G;
    fn f(i: usize, G: &Vec<std::collections::HashSet<usize>>, order: &mut Vec<usize>, reachable: &mut Vec<bool>) {
        if reachable[i] {
            reachable[i] = false;
            for &j in &G[i] { f(j, G, order, reachable); }
            order.push(i);
        }
    }
    let mut order = vec![];
    let mut reachable = vec![true; V];
    for i in 0..V { f(i, &G, &mut order, &mut reachable); }
    let G_inv = {
        let mut G_inv = vec![std::collections::HashSet::new(); V];
        for i in 0..E { G_inv[t[i]].insert(s[i]); }
        G_inv
    };
    fn g(i: usize, k: usize, G_inv: &Vec<std::collections::HashSet<usize>>, scc: &mut Vec<usize>) {
        if scc[i] == 0 {
            scc[i] = k;
            for &j in &G_inv[i] { g(j, k, G_inv, scc); }
        }
    }
    let mut scc = vec![0; V];
    for (k, &i) in order.iter().rev().enumerate() { g(i, k + 1, &G_inv, &mut scc); }
    //println!("{:?}", order);
    //println!("{:?}", scc);
    let ans = (0..Q)
        .map(|i| if scc[u[i]] == scc[v[i]] { 1.to_string() } else { 0.to_string() })
        .collect::<Vec<_>>()
        .join("\n");

    println!("{}", ans);
}


Measured memory_bytes: 23544
#include<cstdio>
int main() {
	int s,k,a,b,c,u=0;
	scanf("%d%d",&k,&s);
	for(a=0;a<=k;a++){
		for(b=0;b<=k;b++){
			c=s-a-b;
			if(c<=k&&a<=k&&b<=k&&c>=0)
			++u;
		}
	}
	printf("%d\n",u);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>

#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}

ll gcd(ll a, ll b) {
  if (a == 0 || b == 0) return a + b;
  if (b > a) return gcd(b, a);
  return gcd(b, a % b);
}

int main(void) {

  string s;
  cin >> s;
  reverse(s.begin(), s.end());

  int a[200100], b[200100];
  a[0] = b[0] = 0;
  int n = s.size();
  int k = 1, l = 1;
  rep(i, n) {
    a[i + 1] = (a[i] + k*int(s[i]-'0')) % 3;
    k *= 10; k %= 3;
    b[i + 1] = (b[i] + l*int(s[i]-'0')) % 673;
    l *= 10; l %= 673;
  }
  /*rep(i, n + 1) {
    cout << a[i] << " " << b[i] << endl;
    }*/

  pair<int, int> v[200100];
  rep(i, n + 1) v[i].first = a[i], v[i].second = b[i];

  map<pair<int,int>, int> m;
  rep(i, n + 1) {
    m[v[i]]++;
  }
  //cout << endl;

  ll ans = 0;
  ll x;
  rep(i, n + 1) {
    x = m[v[i]];
    /*if (x > 1) {
      cout << v[i].first << " " << v[i].second << endl;
      }*/
    m[v[i]] = 0;
    ans += x*(x-1LL)/2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 6844
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    ll n;
    cin >> n;
    vector<ll>a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    ll ans = 0;
    ll ans2 = 0;
    if(n%2==1){
        int p = n/2;
        ans += abs(a[p]-a[n-1]);
        ans += abs(a[n-1]-a[0]);
        for(int i=1;i<n/2;i++){
            ans += abs(a[n-1-i]-a[i-1]);
            ans += abs(a[i]-a[n-1-i]);
        }
        ans2 += abs(a[p]-a[0]);
        ans2 += abs(a[n-1]-a[0]);
        for(int i=1;i<n/2;i++){
            ans2 += abs(a[n-i]-a[i]);
            ans2 += abs(a[i]-a[n-1-i]);
        }
        
        cout << max(ans,ans2) << endl;
    }else{
        int p = n/2-1;
        ans += abs(a[p]-a[n-1]);
        for(int i=1;i<n/2;i++){
            ans += abs(a[n-i]-a[i-1]);
            ans += abs(a[i-1]-a[n-1-i]);
        }
        p = n/2;
        ans2 += abs(a[p]-a[0]);
        for(int i=1;i<n/2;i++){
            ans2 += abs(a[n-i]-a[i-1]);
            ans2 += abs(a[i]-a[n-i]);
        }
        cout << max(ans,ans2) << endl;
    }
    return 0;
}

Measured memory_bytes: 1656
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
if n <= 9 or n % 2 == 1:
  print(0)
  quit()
r = n // 10

for j in range(1, 25):
  r += n // ((5 ** j) * 10)

print(r)

Measured memory_bytes: 2940
package main

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

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

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

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

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

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

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

	abc := make([]int, 3)

	abc[0] = getNextInt(scanner)
	abc[1] = getNextInt(scanner)
	abc[2] = getNextInt(scanner)

	ans := 0

	sort.Ints(abc)

	if abc[2]%2 != abc[0]%2 || abc[2]%2 != abc[1]%2 {
		ans += ((abc[2]+1)*2 - (abc[0] + abc[1] + 1)) >> 1
		if abc[0]%2 != abc[1]%2 {
			ans++
		}
	} else {
		ans += (abc[2]*2 - (abc[0] + abc[1])) >> 1
	}

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


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

typedef struct edge_t{
	int from;
	int to;
	int heavy;
}edge;

int main(void) {
	int n,i,k,from,to,heavy,hantei,nedge=0,dis[10000];
	edge *edges, *p;

	edges = malloc(sizeof(edge)*500000);

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%d",&from);
    scanf("%d",&k);
		while (k--) {
			scanf("%d",&to);
			scanf("%d",&heavy);
			p = &edges[nedge++];
			p->from = from;
			p->to = to;
			p->heavy = heavy;
		}
		dis[i] = INT_MAX;
	}
	dis[0] = 0;
	hantei = 1;
	while (hantei) {
		hantei = 0;
		for (i = 0; i < nedge; i++) {
			from = edges[i].from;
			to = edges[i].to;
		  heavy = edges[i].heavy;
			if (dis[from] < INT_MAX && dis[to] > heavy + dis[from]) {
				dis[to] = heavy + dis[from];
				hantei = 1;
			}
		}
	}

	for (i = 0; i < n; i++) {
		printf("%d %d\n", i, dis[i]);
	}
	return 0;
}



Measured memory_bytes: 7568
#include <stdio.h>
#include <string>
#include <algorithm>
#include <map>
#include <iostream>
using namespace std;

int main() {
	int N, M;
	string s[110], t[110];
	map<string, int> n;
	cin >> N;
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		n[s]++;
	}
	cin >> M;
	for (int i = 0; i < M; i++) {
		string s;
		cin >> s;
		n[s]--;
	}
	int ans = 0;
	for (auto i : n)ans = max(ans, i.second);

	cout << ans << endl;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

long long gcd( long long m, long long n ){
    if ( n == 0) return m;
    return gcd(n,m%n);
  }//最大公約数

  long long lcm( long long m, long long n ){
  // 引数に０がある場合は０を返す
  if ( ( 0 == m ) || ( 0 == n ) ) return 0;

  return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//最小公倍数

int main(){

  ll n;
  cin >> n;
  VLL a(n);
  rep(i,n) cin >> a[i];
  ll lcmNum = a[0];
  rep(i,n) lcmNum = lcm(lcmNum,a[i]);
  ll sum = 0;
  rep(i,n) sum += lcmNum/a[i];
  printf("%0.10lf\n",lcmNum/(double)sum );
  return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> vec(m);
  for (int i = 0; i < m; i++) {
    cin >> vec.at(i);
  }
  
  int sum = 0;
  for (int i = 0; i < m; i++) {
    sum += vec.at(i);
  }
  
  if (n - sum >= 0) {
    cout << n - sum << endl;
  }
  
  else {
    cout << "-1" << endl;
  }
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>  
using namespace std;  
#define INF 0x3f3f3f3f  
typedef long long ll;  
const int N = 1e5 + 10;  
typedef pair<int, int> pii; 
#define V second
#define W first

int main()  
{  
  //  freopen("in.txt", "r", stdin);
   	int x, y;
   	while (~scanf("%d%d", &x, &y))
   	{
   		for (int i = -1; i <= y; i++)
   			putchar('#');
   		puts("");
   		char s[133];
   		for (int i = 0; i < x; i++)
   		{
   			scanf("%s", s);
	   		printf("#%s#\n", s);
   		}
   			for (int i = -1; i <= y; i++)
   			putchar('#');
   		puts("");  	
   	}

   return 0;  
}  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX=2303;
const ll mod=1e9+7;
const int inf=(1<<30);
string s;
ll ans,a[MX],n;
int main(){
    cin>>s;
    n=s.size();
    for(int i=0;i<n;i++){
        a[s[i]]++;
    }
    ans=(n*(n-1))/2;
    ans++;
    for(int i='a';i<='z';i++){
        ll x=a[i];
        x*=(x-1);
        x/=2;
        ans-=x;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
map<int,int>t;
int main()
{
	int n,a,cnt=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		cnt+=t[a]*-2+1;
		t[a]==0?t[a]=1:t[a]=0;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define NMAX 100000
#define INF 1e+6
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
int n;
int d[110];
int main(){
  scan(n);
  rep(i,n)scan(d[i]);
  sort(d,d+n);
  int ans=1;
  rep(i,n-1){
    if(d[i]!=d[i+1]){
      ans++;
    }
  }
  prin(ans);
  
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long a = in.nextLong();
        long b = in.nextLong();
        long c = in.nextLong();
        long x = in.nextLong();
        long y = in.nextLong();
        long min_price = Long.MAX_VALUE;
        if (x < y) {
            long tmp = x;
            x = y;
            y = tmp;
            tmp = a;
            a = b;
            b = tmp;
        }
        for (long ab_num = 0; ab_num <= x * 2; ab_num += 2) {
            long a_remaining = x - ab_num / 2;
            long b_remaining = y - ab_num / 2;
            b_remaining = Math.max(0, b_remaining);
            min_price = Math.min(min_price, ab_num * c + a_remaining * a + b_remaining * b);
        }
        System.out.println(min_price);
    }
}


Measured memory_bytes: 21972
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int S = sc.nextInt();
    int ans = 0;
    for(int i = 0;i <= K;i++){
      for(int j = 0;j <= K;j++){
        if(S - (i + j) >= 0 && S - (i + j) <= K){
            ans++;
        }
      }
    }
    System.out.println(ans);

  }
}


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

#define max(a,b) (a)>(b)?(a):(b)

int main(){
    int n;
    cin>>n;
    string  s[n+1];
    s[n]="";
    for(int i=0;i<n;i++){
	cin>>s[i];
	
	
	sort(s[i].begin(),s[i].end());
    }
    sort(s,s+n);
    long long ans=0,c=0;
    for(int i =0;i<n;i++){
	if(s[i+1]==s[i]) { c++;}
	else {
	    ans+=c*(c+1)/2;
	    c=0;
	 
	}
    }
    
    cout<<ans<<endl;
    
}

Measured memory_bytes: 7296
N,K=map(int,input().split())
A=list(map(int,input().split()))
flag=0
B=[0]*10
for i in range(len(A)):
    B[A[i]]+=1
for i in range(N,100000):
    flag = 0
    k = str(i)
    for j in range(len(k)):
        if B[int(k[j])]==1:
            flag=1
    if flag==0:
        print(k)
        exit(0)


Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;

int main()
{
	int a,b,c;
	int z[105];
	scanf("%d%d",&a,&b);
	double d=0;
	for(int i=0;i<a;i++)
	{scanf("%d",&z[i]);
	d+=z[i];}
	d/=4;
	d/=b;c=0;
	for(int i=0;i<a;i++)
	{
		if(z[i]>=d)c++;
	}
	if(c>=b)printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 128
//by Top1
#include <bits/stdc++.h>
     
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
 
const int inf = (1e9) + 1;
const int mod = 1e9 + 7;
const int maxn = 3e3 + 111;
     
using namespace std;

int n, q;
ld dp[maxn][maxn], p[maxn], ans;
                           
void solve(){
	cin >> n;  

	for (int i = 1; i <= n; i++)
		cin >> p[i];

	dp[0][0] = 1;

	for (int i = 1; i <= n; i++){
		dp[i][0] = dp[i - 1][0] * (1 - p[i]);
		for (int j = 1; j <= i; j++){
			dp[i][j] = dp[i - 1][j - 1] * p[i] + (1 - p[i]) * dp[i - 1][j];
		}
	}

	int k = n / 2 + ((n + 1) % 2);

	for (int i = n, j = 0; i > j; i--, j++)
		ans += dp[n][i];

	cout << fixed << setprecision(9) << ans;
}

main(){
    boost;
	    
	q = 1;

	while (q--){
		solve();
	}
}

Measured memory_bytes: 145920
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
int main() {
    /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int dp[n];
    dp[n-1]=0; dp[n-2]=abs(a[n-1]-a[n-2]);
    for(int i=n-3;i>=0;i--){
        dp[i]=min(abs(a[i+1]-a[i])+dp[i+1],abs(a[i+2]-a[i])+dp[i+2]);
    }
    cout<<dp[0];
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int l;
	cin>>l;
	double n = l/3.0;
	cout<<fixed<<setprecision(10)<<n*n*n<<endl;
	return 0;
}


Measured memory_bytes: 384
import itertools
import math
n = int(input())
x = []
y = []
p = []
for i in range(n):
    src = list(map(int, input().split()))
    x.append(src[0])
    y.append(src[1])
    p.append(str(i))

length = 0
for i in itertools.permutations(p):
    for j in range(n - 1):
        pos0 = int(i[j])
        pos1 = int(i[j + 1])
        length += math.sqrt((x[pos1] - x[pos0]) ** 2 +
                            (y[pos1] - y[pos0]) ** 2)
ans = length / math.factorial(n)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include<set>
#define ll long long 
#include <string>
#define pb push_back
#define mp make_pair
# define pi 3.14159265358979323846
#define mod 1000000007
using namespace std;
int main()
{  

    ll int x,k,d;
    cin>>x>>k>>d;
    ll int c=x/d;
    c=abs(c);
    if (k<c)
    {
    	if (x<0)
    	{
    		ll int ans=x+k*d;
    		ans=abs(ans);
    		cout<<ans<<endl;
		}
		else
		{
			ll int ans=abs(x-k*d);
			cout<<ans<<endl;
		}
	}
	else
	{
		ll int r=k-c;
		if (x>0)
		{
			if (r%2==0)
			{
				ll int ans=x%d;
				cout<<ans<<endl;
				
			}
			else
			{
				ll int ans=x%d;
				ans=ans-d;
				ans=abs(ans);
				cout<<ans<<endl;
				
			}
			
		}
		else
		{
			if (r%2==0)
			{
				ll int ans=x%d;
				ans=abs(ans);
				cout<<ans<<endl;
				
				
			}
			else
			{
				ll int ans=x%d;
				ans=ans+d;
				cout<<ans<<endl;
				
			}
		}
	}
}

	
		
	
	
	
	



Measured memory_bytes: 3624
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        int n = sc.nextInt(), m = sc.nextInt(), l = sc.nextInt();
                        long[][] A = new long[n][m];
                        long[][] B = new long[m][l];
                        for (int i = 0; i < n; i++) {
                                for (int j = 0; j < m; j++) {
                                        A[i][j] = sc.nextLong();
                                }
                        }
                        for (int i = 0; i < m; i++) {
                                for (int j = 0; j < l; j++) {
                                        B[i][j] = sc.nextLong();
                                }
                        }
                        for (int i = 0; i < n; i++) {
                                for (int j = 0; j < l; j++) {
                                        long num = 0;
                                        for (int k = 0; k < m; k++) {
                                                num += A[i][k] * B[k][j];
                                        }
                                        System.out.print(num);
                                        if (j != l - 1) {
                                                System.out.print(" ");
                                        } else {
                                                System.out.print("\n");
                                        }
                                }
                        }
                }
        }
}

Measured memory_bytes: 55428
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
int main(void){
    int n,q;string s;cin>>n>>s>>q;
    vector<set<int>> is(26);
    rep(i,n) is[s[i]-'a'].insert(i);
    rep(qi,q){
        int ty;cin>>ty;
        if(ty==1){
            int i;char r;cin>>i>>r;i--;
            is[s[i]-'a'].erase(i);
            s[i]=r;
            is[s[i]-'a'].insert(i);
        }else{
            int l,r;cin>>l>>r;l--;r--;
            int res=0;
            rep(i,26){
                auto itr= is[i].lower_bound(l);
                if(itr!=is[i].end()&&*itr<=r)res++;
            }
            cout<<res<<endl;
        }
    }
}


Measured memory_bytes: 24196
#include<stdio.h>
int main()
{
  int a,b,i,j;
  while(1)
       {
  scanf("%d%d",&a,&b);
  if(a==0&&b==0){break;}
 
  for(i=1;i<=a;i++)
    {
      for(j=1;j<=b;j++)
    {
      if(j%2==1)
        {
          if(i%2==1)printf("#");
          else printf(".");
        }
      else
        {
              if(i%2==1)printf(".");
          else printf("#");
        }
    }
      printf("\n");
    }
  printf("\n");
     
       }
  return 0;
}



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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    ll count = 0;
    string S1, S2;
    ll prev;
    cin >> N;
    cin >> S1;
    cin >> S2;
    rep(i, N) {
        if(S1[i] == S2[i]) {
            if(i == 0) {
                count = 3;
            } else {
                if(prev) count *= 2;
            }
            prev = 1;
        } else {
            if(i == 0) {
                count = 6;
            } else {
                if(prev) count *= 2;
                else count *= 3;
            }
            i++;
            prev = 0;
        }
        count %= MOD;
    }
    cout << count << endl;
    return 0;
}


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

int main(){
  int n, y;
  cin >> n >> y;
  int price;
  for ( int i = 0; i <= n; i++){
    for ( int j = 0; j <= n-i; j++){
      price = 10000 * i + 5000 * j + 1000 * (n - i - j);
      if ( price == y){
        cout << i << " " << j << " " << n - i - j << endl;
        return 0;
      }
    }
  }

  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	S = IS()
	S = list(map(int, "".join(S)))
	a = []
	def dfs(i, res, ans):
		if i==len(S)-1:
			if res==7:
				ans += "=7"
				a.append(ans)
		else:
			dfs(i+1, res + S[i+1], ans+"+"+str(S[i+1]))
			dfs(i+1, res - S[i+1], ans+"-"+str(S[i+1]))
	dfs(0,S[0],str(S[0]))
	print(a[0])

if __name__ == '__main__':
	main()

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

struct SCC{
    int N;
    vector<bool> used;
    vector<int> vs;
    vector<int> cmp;

    void dfs(int v, const vector<int> G[]){
        used[v] = true;
        for(auto u : G[v]){
            if(!used[u]) dfs(u, G);
        }
        vs.push_back(v);
    }

    void rdfs(int v, int k, const vector<vector<int>>& rG){
        used[v] = true;
        cmp[v] = k;
        for(auto u : rG[v]){
            if(!used[u]) rdfs(u, k, rG);
        }
    }

    SCC(int N, const vector<int> G[]):N(N){
        vector<vector<int>> rG(N);
        for(int i=0; i<N; i++) for(int j : G[i]) rG[j].push_back(i);
        used.resize(N);
        fill(used.begin(), used.end(), false);
        for(int v=0; v<N; v++){
            if(!used[v]) dfs(v, G);
        }

        fill(used.begin(), used.end(), false);
        cmp.resize(N);
        int k = 0;
        for(int i = vs.size()-1; i>=0; i--){
            if(!used[vs[i]]) rdfs(vs[i], k++, rG);
        }
    }

    int dump_graph(const vector<int> G[], vector<int> edges2[]){
        for(int i=0; i<N; i++){
            for(auto j : G[i]){
                if(cmp[i] != cmp[j]){
                    edges2[cmp[i]].push_back(cmp[j]);
                }
            }
        }
        return *max_element(cmp.begin(), cmp.end()) + 1;
    }
};

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> edges[301];
    for(int i=0; i<M; i++){
        int a, b;
        cin >> a >> b;
        edges[a].push_back(b);
    }
    SCC scc(N+1, edges);
    for(int i=1; i<=N; i++){
        vector<int> ans;
        for(int j=1; j<=N; j++) if(scc.cmp[i] == scc.cmp[j]) ans.push_back(j);
        for(int j=0; j<ans.size(); j++) cout << ans[j] << " \n"[j==ans.size()-1];
    }
}



Measured memory_bytes: 4148
#include <algorithm>
#include <array>
#include <cassert>
#include <iostream>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
// #include <queue>
// #include <map>

using namespace std;

namespace atcoder {

namespace {

[[gnu::unused]] bool check()
{
  return false;
}

template<typename T>
vector<T> getN(istream& in)
{
  size_t N;
  in >> N;
  vector<T> seq;
  for (auto i = 0u; i < N; ++i) {
    T x;
    in >> x;
    seq.push_back(x);
  }
  return seq;
}

template<typename T>
long count(const vector<T>& input)
{
  const auto N = input.size();
  assert(N >= 3);
  T a = input[0];
  T b = input[1];
  T c = 0;

  long count = 0;
  for (auto i = 2u; i < N; ++i, a = b, b = c) {
    c = input[i];
    if ((a < b && b < c) || (c < b && b < a)) ++count;
  }
  return count;
}

long solve(istream& in)
{
  auto input = getN<long>(in);
  assert(3 <= input.size() && input.size() <= 20);
  return count(input);
}

void test()
{
  {
    constexpr auto str = R"(
5
1 3 5 4 2
)";
    stringstream in{str};
    assert(solve(in) == 2);
  }

  {
    constexpr auto str = R"(
  9
  9 6 3 2 5 8 7 4 1
  )";
    stringstream in{str};
    assert(solve(in) == 5);
  }
}

} // namespace

} // namespace atcoder

////////////////////////////////////////////////////////////////
int main()
{
  using namespace atcoder;

  // test();
  cout << solve(cin);
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

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

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, X := sc.nextInt(), sc.nextInt()
	var A, P [51]int
	A[0] = 1
	P[0] = 1
	for i := 1; i <= 50; i++ {
		A[i] = 2*A[i-1] + 3
		P[i] = 2*P[i-1] + 1
	}
	var solve func(n, x int) int
	solve = func(n, x int) int {
		if n == 0 {
			return 1
		} else if x == 1 {
			return 0
		}
		if 1 < x && x <= A[n-1]+1 {
			return solve(n-1, x-1)
		} else if x == A[n-1]+2 {
			return P[n-1] + 1
		} else if A[n-1]+2 < x && x <= 2*A[n-1]+2 {
			return P[n-1] + 1 + solve(n-1, x-A[n-1]-2)
		} else {
			return P[n]
		}
	}

	fmt.Fprintln(wtr, solve(N, X))
}


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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;


using Matrix = vector<vector<number>>;

void warshall_floyd(int V, Matrix &g) {
    rep(k, V) {
        rep(i, V) {
            rep(j, V) {
                if (g[i][k] == INF || g[k][j] == INF) continue;
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }
}

int main() {
    int V, E; cin >> V >> E;
    Matrix G(V, vector<number>(V, INF));
    rep(i, V) G[i][i] = 0;
    rep(i, E) {
        int s, t; ll d;
        cin >> s >> t >> d;
        G[s][t] = d;
    }

    warshall_floyd(V, G);

    rep(i, V) {
        if (G[i][i] < 0) {
            cout << "NEGATIVE CYCLE" << endl;
            return 0;
        }
    }

    rep(i, V) {
        rep(j, V) {
            if (j > 0) cout << " ";
            if (G[i][j] == INF) cout << "INF";
            else cout << G[i][j] ;
        }
        cout << endl;
    }

}


Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5+5 , M = 1e9+7, OO = 0x3f3f3f3f;
typedef long long ll;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
const double Pii = 3.14159265359;
ll n, x, k;
ll a[N], b[N];

int main()
{
    FIO
    vector<ll> pos, neg;
    bool z=0;
    cin >> n >> k;
    for(int i=0; i<n; ++i)
    {
        cin >> x;
        if(x > 0) pos.push_back(x);
        else if(x < 0) neg.push_back(-x);
        else z=1;
    }

    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());

    int psz = pos.size(), nsz = neg.size();
    ll ans = 1;
    ll tk = 0;
    bool ok = 1;

    if(psz+((nsz/2)*2) >= k && !(psz == 0 && k%2 == 1))
    {
        int p1 = psz-1, p2 = nsz-1;
        if(k%2 == 1)
        {
            ans*=pos[p1--];
            ans%=M;
            tk++;
        }
        while(tk < k)
        {
            if(p2 > 0 && p1 > 0)
            {
                if(pos[p1]*pos[p1-1] > neg[p2]*neg[p2-1])
                {
                    ans*=pos[p1--];
                    ans%=M;
                    ans*=pos[p1--];
                    ans%=M;
                    tk+=2;
                }
                else
                {
                    ans*=neg[p2--];
                    ans%=M;
                    ans*=neg[p2--];
                    ans%=M;
                    tk+=2;
                }
            }
            else if(p1 > 0)
            {
                ans*=pos[p1--];
                ans%=M;
                ans*=pos[p1--];
                ans%=M;
                tk+=2;
            }
            else
            {
                ans*=neg[p2--];
                ans%=M;
                ans*=neg[p2--];
                ans%=M;
                tk+=2;
            }
        }
    }
    else if(z) ans = 0;
    else
    {
        int p1 = 0, p2 = 0;
        while(tk < k)
        {
            if(p1 < psz && p2 < nsz)
            {
                if(pos[p1] < -neg[p2])
                {
                    ans*=pos[p1++];
                    ans %= M;
                }
                else
                {
                    ans*= neg[p2++];
                    ans %= M;
                }
            }
            else if(p1 < psz)
            {
                ans*=pos[p1++];
                ans %= M;
            }
            else
            {
                ans*= neg[p2++];
                ans %= M;
            }
            tk++;
        }
        ok = 0;
    }
    if(ok) cout << ans << endl;
    else cout << ((M-ans)+M)%M << endl;
    return 0;
}


Measured memory_bytes: 5544
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
	int n;
	cin >> n;
	string a;
	cin >> a;
	a=' '+a;
	int k;
	cin >> k;
	for(int i=1;i<=n;i++)
		if(a[i]!=a[k]) a[i]='*';
	cout << a.substr(1); 
	return 0;
}

Measured memory_bytes: 256
/*　　　　　　　{:i:i:|i:i:/l/l--　 　 　--l/li:i:i|i:i:i:i}
　　　　　　 　 {:rx|:i:i ィi芥ミ 　 　 .ィi芥ミｉ:ｉ|ﾍ:i:i:}
.　　　 　 　 　 ｛ﾏ|ｉ:  {::’:} 　 　 　{:‘::} :ｉ:i:|〉｝:/
　　 　 　 　 　 乂|:i:| ｀¨¨¨¨´ 　 　　｀¨¨¨´  :i:ｉ:|ｼ/
　 　 　 　 　 　 ﾉ:|:i|　　　　　　′　　　 　   |:i:i:|ﾂ
　　　　　　　　/:/|:i:| ､　　　 　_ _ 　　　　  |:i:i:|
　 　 　　 　 /:/ .|:i:|/ ＼　　　 　 　     ｨ〔|:i:/
　　 　 　  　 〈;/ く刈＿ 个 　   -   　＜}　./|/_〉
　　     　　 r-っ'~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ|___
　　 　     /／ニつ　　　　　　 ､　　　　　　　ノﾆﾆ　＼
.　　　     |　　ニ⊃ 　./　/　 ──   /　/　　..⊆ﾆﾆ　　:|
.　　　     |　　丁´　 /|￣|￣  ─‐ /|￣|￣ 　 .￣|丁 　|
.　　　     |　　ﾉ.  　 |￣|￣  ─‐  |￣|￣ 　 　.|八 　|
.　　　     |　　||. 　 |￣|￣ |￣| |￣|￣ 　   .|　|
.　 　 　   |  　||   　￣￣￣　￣ 　￣￣￣　　  .|　|  |
.　 　 　  　    ||＿＿＿＿＿＿＿＿＿＿＿＿______|__　　 ',
　 　      ,′　 | ７ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ}  ,′
.　　     {　　　|/　}ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ{/ 　 　
*///讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐。
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>

using namespace std;

#define rep(a) _rep(0,int(a))
#define repj(a) for(int j=0;j<int(a);j++)
#define _rep(a,b) for(int i=int(a);i<int(b);i++)
#define ll long long
#define fst first
#define snd second
#define pf(b) printf("%.12f\n",(double)b)
#define _GLIBCXX_DEBUG
const double pai = 3.1415926535897;
#define _cos(n) cos(n*pai/180)

//factorial(練習)　階乗
int fact(int n) {
	int a = 1;
	for (int i = 1;i <= n;i++) a *= i;
	return a;
}
int sa(int n, int m) {      //差！
	if (n < m)return m - n;
	else return n - m;
}

int a[3],j,ans;
signed main() {
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	rep(3) {
		ans+=sa(a[i] , a[j] );
		j = i;
	}
	cout << ans << endl;
}

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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
    int n;
    vector<int> p,q;
	cin >> n;
    fori(n){
        int hoge;cin>>hoge;
        p.push_back(hoge);
    }
    fori(n){
        int hoge;cin>>hoge;
        q.push_back(hoge);
    }
    
    if(p==q){
        cout<<0;return 0;
    }

    int count=-1;
    vector<int> a(n);
    fori(n)a[i]=i+1;
    do{
        if(a==p||a==q){
            if(count!=-1){
                cout<<count;
                return 0;
            }else{
                count=0;
            }
        }
        if(count!=-1){
            ++count;
        }
    }while(next_permutation(a.begin(),a.end()));

    cout<<count;

	return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque, defaultdict
import copy
import bisect
sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import product, permutations,combinations
import fractions
from operator import itemgetter

import sys
def input():
	return sys.stdin.readline().strip()

N, M, L = list(map(int, input().split()))

graph = [[] for _ in range(N)]

for i in range(M):
	A, B, C = list(map(int, input().split()))
	if C <= L:
		graph[A - 1].append((B - 1, C))
		graph[B - 1].append((A - 1, C))

num_matrix = [[0]*N for i in range(N)]


for start in range(N):
	dist = [(1000000, 0)]*N
	que = []
	heapq.heappush(que, (0, 0, start))
	dist[start] = (0, 0)
	while len(que) > 0:

		node = heapq.heappop(que)
		#print(start, que, node)
		if node[0] == dist[node[2]][0] and node[1] == dist[node[2]][1]:
			#print(1)
			for edge in graph[node[2]]:
				#print(edge)
				#print(edge[1] + dist[node[2]][1] )
				if edge[1] + dist[node[2]][1] > L:
					next_dist = (dist[node[2]][0] + 1, edge[1], edge[0])
				else:
					next_dist = (dist[node[2]][0], dist[node[2]][1] + edge[1], edge[0])
				if dist[edge[0]][0] > next_dist[0]:
					dist[next_dist[2]] = (next_dist[0], next_dist[1])
					heapq.heappush(que, next_dist)
				elif dist[edge[0]][0] == next_dist[0] and dist[edge[0]][1] > next_dist[1]:
					heapq.heappush(que, next_dist)
					dist[next_dist[2]] = (next_dist[0], next_dist[1])
	for i in range(N):
		num_matrix[start][i] = dist[i][0]

#print(num_matrix)

Q = int(input())
for q in range(Q):
	s, t = list(map(int, input().split()))
	if num_matrix[t - 1][s - 1] < 1000:
		print(num_matrix[t - 1][s - 1])
	else:
		print(-1)

Measured memory_bytes: 115544
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define endl "\n"
#define inf 1000000007
//#define for(i, a, b) for(int i=a; i<b; i++)
int dp[1000001] = {0};

void solve(){
  int n;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++) cin>>arr[i];
  if(is_sorted(arr, arr+n)){
    cout<<"Yes";
    return;
  }
  for(int i=1;i<n;i++){
    if(arr[i]<arr[i-1]){
		arr[i]++;
    }
  }
  if(is_sorted(arr, arr+n)){
    cout<<"Yes";
    return;
  }
  else{
	cout<<"No";
  }
}
signed main(){	
	#ifdef _DEBUG
		freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
 
}

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

int numbers[4];
bool continueFlag = false;

int rec(const string &opes, int result, int count)
{
    if (!continueFlag)
    {
        if (count == 4)
        {
            if (result == 7)
            {
                cout << numbers[0];
                for (int i = 1; i < 4; i++)
                {
                    cout << opes[i - 1] << numbers[i];
                }
                cout << "=7";
                continueFlag = true;
            }
        }
        else
        {
            rec(opes + "+", result + numbers[count], count + 1);
            rec(opes + "-", result - numbers[count], count + 1);
        }
    }
}

int main()
{
    string geter;
    cin >> geter;
    for(int i = 0;i < 4;i++)
    {
        numbers[i] = (int)geter[i] - (int)'0';
    }
    rec("",numbers[0],1);
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n, m;
    cin >> n >> m;

    vector<vector<int>> graph(n);
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    int N = 1 << n;

    vector<vector<long long>> dp(N, vector<long long>(n, 0));
    dp[1][0] = 1;

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < n; ++j) {
            if (dp[i][j] == 0) {
                continue;
            }

            for (auto nj : graph[j]) {
                if ((i >> nj) & 1) {
                    continue;
                }
                int ni = i | (1 << nj);
                dp[ni][nj] += dp[i][j];
            }
        }
    }

    long long res = 0;
    for (int i = 0; i < n; ++i) {
        res += dp[N - 1][i];
    }

    cout << res << '\n';

    return 0;
}

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

#define REP(i,s,n) for(int (i)=s; (i)<(int)(n);(i)++)
#define RIT(it,c) for(__typeof(c.begin()) it = c.begin();it!=c.end();it++)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x).size()
#define MSET(m,v) memset(m,v,sizeof(m))


using namespace std;


typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<LL> vL;
typedef vector<bool> vb;
typedef pair<int,vi> iv;
typedef pair<LL,LL> pLL; 



int main(){
	int x,t;
	
	cin>>x>>t;
	cout<<max(x-t,0)<<endl;
	return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << (x) << "\n"
using namespace std;
using point = pair< int,int >;
using ll = long long;

int main() {
    int p, m, c;

    cin >> p >> m >> c;

    OUT(p + m + c);

    return 0;
}


Measured memory_bytes: 3100
N = int(input())
S = input()
alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
s = [i for i in S]

for i in range(len(S)):
  index = alp.index(S[i])
  ans_index = (index + N + 1) % 26
  s[i] = alp[ans_index - 1]

ans = ""
for i in s:
  ans += i
print(ans)

Measured memory_bytes: 3064