akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

ll ppow(ll a,ll b){
	a%=MOD;
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}
class Fact{
	vector<ll>fact;
	vector<ll>inv;
public:
	Fact(){}
	Fact(int n){
		n=n*2+10;
		fact=inv=vector<ll>(n);
		fact[0]=inv[0]=1;
		for(int i=1;i<n;i++){
			fact[i]=(fact[i-1]*i)%MOD;
		}
		inv[n-1]=ppow(fact[n-1],MOD-2);
		for(int i=n-2;i>=0;i--){
			inv[i]=(inv[i+1]*(i+1))%MOD;
		}
	}
	ll get(int n){
		return fact[n];
	}
	ll get_inv(int n){
		return inv[n];
	}
	ll nPr(int n,int r){
		return fact[n]*inv[n-r]%MOD;
	}
	ll nCr(int n,int r){
		return nPr(n,r)*inv[r]%MOD;
	}
	ll nrP(int n,int r){
		return nPr(n+r,n);
	}
	ll nrC(int n,int r){
		return nCr(n+r,n);
	}
};
vector<int>E[300000];
int sz[300000];
ll dp1[300000],dp2[300000];

int n;

Fact fac(200000);

void dfs(int v,int p){
	sz[v]=1;
	dp1[v]=1;
	for(int u:E[v]){
		if(u==p)continue;
		dfs(u,v);
		sz[v]+=sz[u];
	}
	if(sz[v]==1)return;
	dp1[v]=fac.get(sz[v]-1);
	for(int u:E[v]){
		if(u==p)continue;
		(dp1[v]*=fac.get_inv(sz[u])*dp1[u]%MOD)%=MOD;
	}
}

void dfs2(int v,int p){
	if(p==-1){
		dp2[v]=dp1[v];
	}
	else{
		dp2[v]=fac.get(n-1);
		for(int u:E[v]){
			if(u==p){
				ll d=dp2[p]*fac.get(n-sz[v]-1)%MOD*fac.get_inv(n-1)%MOD*fac.get(sz[v])%MOD*ppow(dp1[v],MOD-2)%MOD;
				ll S=(n-sz[v]);
				(dp2[v]*=fac.get_inv(S)*d%MOD)%=MOD;
			}
			else{
				(dp2[v]*=fac.get_inv(sz[u])*dp1[u]%MOD)%=MOD;
			}
		}
	}
	for(int u:E[v]){
		if(u==p)continue;
		dfs2(u,v);
	}
}

int main(){
	cin>>n;
	rep(i,n-1){
		int a,b;scanf("%d%d",&a,&b);a--;b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	dfs(0,-1);
	dfs2(0,-1);
	rep(i,n){
		printf("%lld\n",dp2[i]);
	}
}

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

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

  vector<int> d(n);
  rep (i, n) cin >> d[i];

  int ans = 0;
  for (int i = 0; i < n; i ++) {
    for (int j = i + 1; j < n; j++) {
      ans += d[i] * d[j];
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// x^y≡x^(y%(p-1))mod p
// but there is a condition that x needs to be coprime to p
///assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
typedef long long int ll;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
#define  pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define tests() int test_cases ; cin >> test_cases ; while(test_cases--)
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define MAXN 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define sp " "
#define MS(x,y) fill_n(*x, sizeof x / sizeof **x, y);
#define mem(x,y) memset(x,y,sizeof(x));
#define INF 1000000000000000000
#define IO                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);
#define debug(x) cerr << (#x) << " is " << (x) << endl;

#ifndef ONLINE_JUDGE
#define cerr if(true)cerr
#endif

template<int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
static_assert(D >= 1, "Vector dimension must be greater than zero!");
template<typename... Args>
	Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
	}
};
template<typename T>
struct Vec<1, T> : public vector<T> {
	Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {
	}
};

ll power(ll x, ll y,ll p) 
{ 
    ll res = 1;     // Initialize result 
    x = x % p;
    if (y==0)return 1;
    if(x==0)return 0;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p;    
        y = y>>1; // y = y/2 
        x = (x*x) % p;  // Change x to x^2 
    } 
    return res; 
}
int gcd(int a, int b) { if (a == 0)return b;return gcd(b % a, a);} 

ll modinv(ll a,ll p){return power(a,p-2,p);}

int solve(){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if (k<=a)
    {
        cout<<k<<endl;
    }
    else if (k<=b+a)
    {
        cout<<a<<endl;
    }
    else if (k<=a+b+c)
    {
        ll sub = k-a-b;
        cout<<(a-sub)<<endl;
    }
    else cout<<a-c<<endl;
    return 0;
}
int main()
{
    IO;
    #ifndef ONLINE_JUDGE 
    freopen("input.txt", "r", stdin); 
    freopen("out.txt", "w", stdout); 
    #endif 
    int T=1;
	// cin >> T;
	f(c,0,T){
		solve();
	}
    return 0;
}// make_pair make_tuple  tuple<int,int,int> continue resize insert count size else true isValid second first

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll gcd(ll a, ll b) {
    if(a%b==0) return b;
    return gcd(b, a%b);
}
int main(void) {
    ll a, b, c, d; cin >> a >> b >> c >> d;
    ll cd = c/gcd(c,d)*d;
    ll x = b/c - a/c;
    if(a%c==0) x+=1;
    ll y = b/d - a/d;
    if(a%d==0) y+=1;
    ll z = b/cd - a/cd;
    if(a%cd==0) z+=1;
    cout << b-a-(x+y-z)+1;
}



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

template <class _T> inline bool chmax (_T& a,_T b){if(a<b){a=b;return true;}return false;}
template <class _T> inline bool chmin (_T& a,_T b){if(a>b){a=b;return true;}return false;}

const long long INF = 1LL << 60;


int main(void){
	string s;
	cin >> s;
	if(s[2]==s[3] && s[4]==s[5]) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}



Measured memory_bytes: 256
//package Practice_Problems;
import java.util.*;
import java.io.*;
public class Main
{
	static final int mod=(int)1e9+7;
	static final int inf=(int)1e9;
	static final long INF=(long)1e18;
	public static void main(String[] args)
	{
		FastScanner fs=new FastScanner();
		int n=fs.nextInt();
		LinkedHashMap<String, Integer> map = new LinkedHashMap<>();
		for(int i=1;i<=n;i++)
		{
			String s=fs.next();
			int time=fs.nextInt();
			map.put(s, time);
		}
		String after=fs.next();
		int sum=0;
		boolean ok=false;
		for(String s:map.keySet())
		{
			if(ok==true)
			{
				sum+=map.get(s);
			}
			else if(s.equalsIgnoreCase(after))
			{
				ok=true;
			}
			//System.out.println(ok);
		}
		System.out.println(sum);
	}
}
class FastScanner 
{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		public String next() 
		{
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		long pow(long x,long n)
		{
			long res=1;
			while(n>0)
			{
			   	if(n%2!=0)
			   	{
			   		res=(res*x);n--;
			   	}
			   	else
			   	{
			   		x=(x*x);n/=2;
			   	}
			}
			return res;
		}
		int gcd(int a,int b)
		{
			if(b==0)
			{
				return a;
			}
			return gcd(b,a%b);
		}
		long longgcd(long a,long b)
		{
			if(b==0)
			{
				return a;
			}
			return longgcd(b,a%b);
		}
		int[] sort(int arr[])
		{
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		char[] charsort(char arr[])
	        {
	    	ArrayList<Character> list = new ArrayList<>();
	    	for(char c:arr)list.add(c);
	    	Collections.sort(list);
	    	for(int i=0;i<list.size();i++)
	    	{
	    		arr[i]=list.get(i);
	    	}
	    	return arr;
	        }
		long[] longsort(long arr[])
		{
			ArrayList<Long> list = new ArrayList<Long>();
			for(long i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		public int nextInt() 
		{
			return Integer.parseInt(next());
		}
		public int[] readArray(int n)
		{
			int[] arr=new int[n];
			for (int i=0; i<n; i++) arr[i]=nextInt();
			return arr;
		}	
		public long nextLong()
		{
			return Long.parseLong(next());
		}
		public long[] longreadArray(int n) 
		{
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
}

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

using namespace std;

const int MAXN = 100005;

int n, m, sol;
int a[MAXN], br[MAXN];

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    a[1] = 1;
    cin >> n >> m;
    for (int i=1; i<=n; i++) {
        br[i] = 1;
    }
    for (int i=0; i<m; i++) {
        int x, y;
        cin >> x >> y;
        a[y] |= a[x];
        br[x]--; br[y]++;
        if (br[x] == 0) a[x] = 0;
    }
    for (int i=1; i<=n; i++) {
        sol += a[i];
    }
    cout << sol;
    return 0;
}


Measured memory_bytes: 1024
use std::io::{BufRead, Write};
use std::io;
use std::collections::HashSet;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut buf = String::new();
    input.read_line(&mut buf).unwrap();
    let n: usize = buf.trim_right().parse().unwrap();
    let deduped: HashSet<u8> = (0..n).map(|_| {
        buf.clear();
        input.read_line(&mut buf).unwrap();
        buf.trim_right().parse().unwrap()
    }).collect();
    writeln!(output, "{}", deduped.len()).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test(
            "4
10
8
8
6
",
            "3\n",
        );
    }

    #[test]
    fn case2() {
        test(
            "3
15
15
15
",
            "1\n",
        );
    }

    #[test]
    fn case3() {
        test(
            "7
50
30
50
100
50
80
30
",
            "4\n",
        );
    }
}

Measured memory_bytes: 4352
# -*- coding: utf-8 -*-
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

button = 1
for j in range(n):
    k = a[button - 1]
    if k == 2:
       print('{}'.format(j + 1))
       exit(0)
    button = k

print('-1')

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

int main() {
  int n,m;
  cin >> n >> m;
  
  vector<int> roads = vector<int>(n,0);
  
  for(int i=0; i<m; i++){
    int cityA, cityB;
    cin >> cityA >> cityB;
    
    roads[cityA-1]++;
    roads[cityB-1]++;
  }
  
  for(int i=0; i<n; i++) {
    cout << roads[i] << endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

  vector<int64_t> a(n);
  rep(i, n) {
    cin >> a[i];
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  int64_t result = 1;
  const int64_t INF = 1'000'000'000L * 1'000'000'000L;
  rep(i, n) {
    if (a[i] > INF / result) {
      cout << -1 << endl;
      return 0;
    } else {
      result *= a[i];
    }
  }
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a,b;
	cin>>a>>b;
	if(a==1)
		a=123123;
	if(b==1)
		b=123123;
	if(a>b)
		printf("Alice");
	if(a<b)
		printf("Bob");
	if(a==b)
		printf("Draw");
	return 0;
}

Measured memory_bytes: 384
/* ABC139-A
   Takatan */

#include<stdio.h>
int main(void){
    char forecast[4], weather[4];
    int count, i;
    count = 0;

    scanf( "%s\n%s" , forecast, weather);
    for(i=0; i < 3; i++){
        if(forecast[i]==weather[i]){
            count++;
        }
    }
    printf( "%d\n" , count);
    return 0;
}

Measured memory_bytes: 128
/**
     *    Coded by : lucky_21
     *               --------Lokesh Singh
    **/
     
    #include<bits/stdc++.h>
    using namespace std;
     
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/assoc_container.hpp>
    using namespace __gnu_pbds;
    template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
    #define     F           first
    #define     S           second
    #define     pb          push_back
    #define     lb          lower_bound
    #define     ub          upper_bound
    #define     pii         pair<int,int>
    #define     all(x)      x.begin(),x.end()
    #define     fix         fixed<<setprecision(10)
    #define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
    #define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
    #define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
     
    typedef double db;
    typedef long long ll;
     
    const int N=2e5+5;
    const int mod=1e9+7;
     
    int n;
    void solve(string s,char mx){
        if(s.size()==n){
            cout<<s<<'\n';
            return;
        }
        for(char c='a';c<=mx;c++){
            solve(s+c,(c==mx?mx+1:mx));
        }
    }
    signed main(){
        FastIO;
        cin>>n;
        solve("",'a');
        return 0;
    }

Measured memory_bytes: 1536
// E - Strings of Impurity
// Binary Search
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;

    vector<vector<int>> pos(26);

    // save all the appearances of s[idx]
    for(int idx = 0; idx < s.size(); ++idx)
        pos[s[idx] - 'a'].push_back(idx);

    long long ans = 0LL;
    int x = -1; // last match
    
    for(int idx = 0; idx < t.size(); ++idx) {
        int c = t[idx] - 'a';

        if(pos[c].empty()) {
            cout << -1 << endl;
            return 0;
        }

        // binary search for c
        // get the first appearance of c after the last match x
        int it = upper_bound(pos[c].begin(), pos[c].end(), x) - pos[c].begin();

        if(pos[c].size() == it) {
            // match was at the end
            ans += pos[c][0] - x + s.size();
            x = pos[c][0];
        } else {
            ans += pos[c][it] - x;
            x = pos[c][it];
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1216
#include<iostream>
#include <vector> // vector
using namespace std;
 
int main(){
  int N,M;
  cin>>N>>M;
  vector<int>date(M);
  long long sum=0;
  for(int i =0;i<M;i++){
    cin>>date.at(i);
    sum+=date.at(i);
  }
  if(N-sum>=0){
    cout<<N-sum<<endl;
  }
  else{
    cout<<-1<<endl;
  }
}

Measured memory_bytes: 3664
while True:
	try:
		p, q = map(int, input().split())
		m = p % q
		i = -1
		decs = ['']
		mods = [m]
		while m != 0:
			d, m = divmod(m * 10, q)
			decs.append(str(d))
			if m not in mods:
				mods.append(m)
			else:
				i = mods.index(m)
				break
		#
		if len(decs) == 0:
			print(0)
		else:
			print(''.join(decs))
			if m != 0 and i > -1:
				for j, dec in enumerate(decs):
					if j > i:
						decs[j] = '^' * len(decs[j])
					else:
						decs[j] = ' ' * len(decs[j])
				print(''.join(decs))
	except EOFError:
		break

Measured memory_bytes: 6724
from collections import OrderedDict

while True :
    n = int(input())
    if n == 0 : break
    
    box = OrderedDict()
    for _ in ([None]*n) :
        e, p, q = map(int, input().split())
        if e in box : box[e] += p * q
        else        : box[e]  = p * q
    
    check = 0
    for _ in box :
        if box[_] >= (10**6) :
            print(_)
            check = 1
    if check == 0 : print('NA')

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    bool ans = true;
    rep(i, n) {
        if (a[i] % 2 == 1) continue;
        if (a[i] % 3 != 0 and a[i] % 5 != 0) ans = false;
    }
    if (ans) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    return 0;
}



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

struct Node{
  int k;
  struct Node *r;
  struct Node *l;
  struct Node *p;
};

struct Node *root, *NIL;

void Insert(int);
void Inorder(struct Node *);
void Preorder(struct Node *);

int main(){
  int str1 = 0, str2 = 0;
  int i,n,key;
  char c1[10], c2[10]="insert", c3[10]="print";

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    scanf("%s",c1);
    
    if(strcmp(c1,c2) == 0) str1 = 1;
    if(strcmp(c1,c3) == 0) str2 = 1;
    
    if(str1 == 1){
      scanf("%d",&key);
      Insert(key);
      str1 = 0;
    }
    else if(str2 == 1){
      str2 = 0;
      Inorder(root);
      printf("\n");
      Preorder(root);
      printf("\n");
    }
  }

  return 0;
}

void Insert(int n){
struct  Node *parent = root;
struct  Node *q = NIL;
struct  Node *right;

 right = (struct Node *)malloc(sizeof(struct Node));
 right -> k = n;
 right -> l = NIL;
 right -> r = NIL;
 
 while(parent != NIL){
   q = parent;
   if(right->k < parent->k){
     parent = parent -> l;
   }
   else{
     parent = parent -> r;
   }
 }
 
 right -> p = q;
  if(q == NIL){
    root = right;
  }
  else{
    if(right->k < q->k){
      q -> l = right;
    }
    else{
      q -> r = right;
    }
  }
}

void Inorder(struct Node *x){
  if(x == NIL) return;
  Inorder(x -> l);
  printf(" %d",x -> k);
  Inorder(x -> r);
}

void Preorder(struct Node *x){
  if(x == NIL) return;
  printf(" %d",x -> k);
  Preorder(x -> l);
  Preorder(x -> r);
}




Measured memory_bytes: 25168
def roll(die, d):
    if d == "E":
        return [die[3], die[1], die[0], die[5], die[4], die[2]]
    if d == "N":
        return [die[1], die[5], die[2], die[3], die[0], die[4]]
    if d == "S":
        return [die[4], die[0], die[2], die[3], die[5], die[1]]
    if d == "W":
        return [die[2], die[1], die[5], die[0], die[4], die[3]]
    if d == "L":
        return [die[0], die[3], die[1], die[4], die[2], die[5]]
    if d == "R":
        return [die[0], die[2], die[4], die[1], die[3], die[5]]

while True:
    die = [1, 2, 3, 4, 5, 6]
    ans = 1
    n = int(input())
    if n == 0:
        break
    for _ in range(n):
        die = roll(die, input()[0])
        ans += die[0]
    print(ans)

Measured memory_bytes: 7748
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl
#define NL <<"\n"

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#include "../benri.h"
#else
#define out(args...)
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
const ll MOD=1e9+7; //998244353

const int nn=112345;
ll bit[nn+213];
ll sum(int i){ ++i;
	ll s=0;
	while(i>0){
		s+=bit[i];
		i-=i&-i;
	}
	return s;
}
void add(int i,ll x){ ++i;
	while(i<=nn){
		bit[i]+=x;
		i+=i&-i;
	}
}

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout<<fixed<<setprecision(0);
	int n,t;
	cin>>n>>t;
	vector<int> a(n);
	rep(i,n) cin>>a[i];
	ll inv=0;
	rep(i,n){
		inv+=i-sum(a[i]);
		add(a[i],1);
	}
	int ok=1;
	if(n==t){
		rep(i,n)if(a[i]%n!=(a[0]+i)%n) ok=0;
	}else{
		if(t%2 && inv%2) ok=0;
	}
	cout<<(ok?"Yes":"No")<<endl;
  return 0;
}



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

void swap(int &a, int &b){
	int temp;
	temp=a;
	a=b;
	b=temp;
}

int main() {
	int a,b,c;

	std::cin >>a>>b>>c;
	if(a>b) swap(a,b);
	if(a>c) swap(a,c);
	if(b>c) swap(b,c);
	std::cout << a << " " << b<<" "<<c <<std::endl;
	return 0;
}

Measured memory_bytes: 3024
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	h := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&h[i])
	}
	if n <= k {
		fmt.Println(0)
		return
	}

	sort.Sort(sort.Reverse(sort.IntSlice(h)))
	h = h[k:]

	count := 0
	for i := 0; i < len(h); i++ {
		count += h[i]
	}
	fmt.Println(count)
}


Measured memory_bytes: 5632
from collections import deque
R,C,ay,ax,by,bx = map(int,input().split())

MOD = INF = 10**9+7
dists = [[INF]*C for i in range(R)]
dists[ay][ax] = 0
ptns = [[0]*C for i in range(R)]
ptns[ay][ax] = 1
q = deque([(0,ax,ay)])
dxs = [1,0,-1,0]
dys = [0,1,0,-1]
ans_d = None
while q:
    d,x,y = q.popleft()
    if ans_d is not None and d > ans_d:
        break
    if (x,y) == (bx,by):
        ans_d = d
    if d > dists[y][x]: continue
    dists[y][x] = d
    for dx,dy in zip(dxs,dys):
        nx,ny = x+dx, y+dy
        if not(0 <= nx < C) or not(0 <= ny < R): continue
        if d+1 > dists[ny][nx]: continue
        if dists[ny][nx] == INF:
            q.append((d+1,nx,ny))
            dists[ny][nx] = d+1
        ptns[ny][nx] += ptns[y][x]
        ptns[ny][nx] %= MOD
    for nx,ny in ((x,0),(x,R-1),(0,y),(C-1,y)):
        if d+1 > dists[ny][nx]: continue
        if dists[ny][nx] == INF:
            q.append((d+1,nx,ny))
            dists[ny][nx] = d+1
        ptns[ny][nx] += ptns[y][x]
        ptns[ny][nx] %= MOD

print(ans_d, ptns[by][bx] % MOD)



Measured memory_bytes: 10772
#include<iostream>
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
	int N, T, S, M[3001]={}, maxM=0;
	cin >> N >> T >> S;
	if(S==0){
		for(int n=0; n<N; n++){
			int mise_fun, mise_time;
			cin >> mise_fun >> mise_time;
			for(int t=T; t>=mise_time; t--){
				int newM = M[t-mise_time] + mise_fun;
				
				if(M[t] < newM){
					M[t] = newM;
					if(maxM<newM)maxM = newM;
				}
			}
		}
	}
	else{
		for(int n=0; n<N; n++){
			int mise_fun, mise_time;
			cin >> mise_fun >> mise_time;
			for(int t=T; t>=mise_time; t--){
				if(t<=S || t >= S  + mise_time){
					int newM = M[t-mise_time] + mise_fun;
					if(M[t] < newM){
						M[t] = newM;
						if(maxM<newM)maxM = newM;
					}
				}
			}
		}
	}
	cout << maxM << endl;
	return 0;
}

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

int main() {
  int a, b;
  int flag = -1;
  cin >> a >> b;

  for (int i = 1; i <= 3000; i++) {
    if ((int(i * 0.08) == a) && (int(i * 0.1) == b)) {
      flag = i;
      // cout << i << endl;
      break;
    }
  }

  cout << flag << endl;
}


Measured memory_bytes: 256
def main():
    number_of_takoyakis = int(input())
    takoyaki_list = list(map(int,input().split()))
    cure_list = []
    for i in range(number_of_takoyakis):
        for j in range(number_of_takoyakis):
            if i != j:
                cure_list.append(caliculate_cure_point(takoyaki_list[i],takoyaki_list[j]))
    print(sum(cure_list)//2)

def caliculate_cure_point(takoyaki1,takoyaki2):
    return takoyaki1*takoyaki2

main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
template<int MOD> struct Fp {  
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<MOD>;

mint Combination(ll n,ll k){
	mint ans = 1;
	mint div = 1;
	for(ll i = 0; i < k; i++){
		ans *= n-i;
		div *= k-i;
	}
	ans /= div;
	return ans;
}

signed main(){
	//cout << fixed << setprecision(10);
	ll x,y; cin >> x >> y;
	if((x + y) % 3 != 0){
		cout << 0 << endl;
		return 0;
	}
	ll k = (x + y)/3;
	ll n = 2*k - x;
	ll m = k - n;
	if(n < 0 || m < 0){
		cout << 0 << endl;
		return 0;
	}
	cout << Combination(m+n,min(n,m)) <<endl;

	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int maxn=1e9+7;
const int maxx=1e7;
int a[maxx];
int main()
{
    int n;
    scanf("%d",&n);
    int c=0;
    for(int i=2;i<=n;i++)
         {
             int l=i;
             for(int j=2;j<=l;j++)
             {
                while(l%j==0)
                {
                    a[j]++;
                    l/=j;
                }
             }
//             if(l) a[l]++;

        }
        long long sum=1;
        for(int i=2;i<=n;i++)
        {
            if(a[i])
            {
                sum*=(1+a[i]);
                sum=sum%maxn;
            }
        }
        printf("%lld\n",sum);
        return 0;

}


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

int main(){
    int a;
    cin>>a;
    string s;
    cin>>s;
    if(a>=3200){
        cout<<s<<endl;
    }else{
        cout<<"red"<<endl;
    }
}

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

using namespace std;

#ifdef NeverBeRed
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second



int main()
{
	#ifdef TurnRed
		//freopen("a.in", "r", stdin);
		//freopen("a.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n, m, k;
	cin >> n >> m >> k;
	vector<string> a(n);
	for (auto &i : a)
		cin >> i;

	int ans = 1e9;
	for (int i = 0; i < 1<<(n-1); ++i)
	{
		vector<int> c;
		for (int j = 0; j < n-1; ++j)
			if (i >> j & 1)
				c.push_back(j+1);

		int cost = 0;
		c.push_back(n);
		vector<int> curr(c.size());
		for (int j = 0; j < m; ++j)
		{
			int l = 0;
			bool cut = false;
			for (auto &v : c)
			{
				int &cur = curr[&v-&c[0]];
				int add = 0;
				for (int z = l; z < v; ++z)
					add += a[z][j] == '1';
				if (add > k)
				{
					cost = 1e6;
					break;
				}
				if (cur + add > k)
					cut = true;
				l = v;
			}

			if (cost >= 1e6) break;
			cost += cut;

			l = 0;
			for (auto &v : c)
			{
				int &cur = curr[&v-&c[0]];
				int add = 0;
				for (int z = l; z < v; ++z)
					add += a[z][j] == '1';

				if (cut)
					cur = add;
				else
					cur += add;
				l = v;
			}
		}
		//if ((int)c.size()-1 + cost == 1) debug(i);
		ans = min(ans, (int)c.size()-1 + cost);
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    A, B, C, K = Scanner.map_int()
    ans = min(K, A)
    K -= ans
    t = min(K, B)
    K -= t
    ans -= min(K, C)
    print(ans)


def main():
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 10716
#include <stdio.h>

int main(void) {
 int a,b;
 char op; 
 for(int c=1;;c++){
   scanf("%d %c %d",&a,&op,&b);
   if(op=='?'){
   break;}
   else if(op=='+'){
   printf("%d\n",a+b);}
   else if(op=='-'){
   printf("%d\n",a-b);}
   else if(op=='*'){
   printf("%d\n",a*b);}
   else if(op=='/'){
   printf("%d\n",a/b);}
 }
 return 0;
}


Measured memory_bytes: 2048
#include <algorithm>
#include <cstdlib>
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
char S[10];
int main(int argc, char const *argv[])
{
    cin>>S;
    std::vector<int> v;
    char temp[3];
    for(int i=0;i+2<=sizeof(S)/sizeof(char)-1;i++){
        temp[0]=S[i];
        temp[1]=S[i+1];
        temp[2]=S[i+2];
        v.push_back(abs(atoi(temp)-753));
    }
    int min = *std::min_element(v.begin(), v.end());
    cout<<min<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int n, f[100][10], p[100][11], used[100];
ll ans = INT32_MIN;

ll check(int num) {
	for (int i = 0; i < n; i++)used[i] = 0;

	ll res = 0;
	for (int h = 0; h < 10; h++) {
		if ((num >> h)&1) {
			for (int i = 0; i < n; i++) {
				if (f[i][h] == 1)used[i]++;
			}
		}
	}
	//cout << "b" << endl;
	for (int i = 0; i < n; i++) {
		res += p[i][used[i]];
		//cout << "d" << endl;
	}

	return res;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> f[i][j];
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 11; j++) {
			cin >> p[i][j];
		}
	}

	for (int i = 1; i < (1 << 10); i++) {
		//cout << "a" << endl;
		ll c = check(i);
		//if(c == 0)cout << "check:" << c << " i:" << i << endl;
		ans = max(ans, c);
	}

	cout << ans << endl;
}

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

bool ok(string s){
    char x = s[0];
    for(int i = 1; i < s.length(); i++){
        x++;
        if(s[i] != x)   return false;
    }
    return true;
}

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

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

    int ans = -1;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            if(ok(to_string(a[i]*a[j])))    ans = max(ans, a[i]*a[j]);
        }
    }

    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3284
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n, m, L;
int card[2010];
int seq[100010];
ll sum[100010];
ll memo[2010][2010];

inline ll score(int l, int r) {
  l = card[l]; r = card[r];
  if (l > r) { swap(l, r); }
  return (sum[r + 1] - sum[l]) / L;
}

ll calc(int left, int right) {
  if (memo[left][right] != -1) { return memo[left][right]; }
  int index = max(left, right) + 1;
  if (index == n) {
    return score(left, right);
  }
  ll ret = 1LL << 60;
  ret = min(ret, calc(index, right) + score(left, index));
  ret = min(ret, calc(left, index) + score(right, index));
  return memo[left][right] = ret;
}

int main() {
  while (scanf("%d %d %d", &n, &m, &L) > 0) {
    MEMSET(memo, -1);
    MEMSET(sum, 0);
    REP(i, n) {
      int v = scanf("%d", &card[i]);
      card[i]--;
      assert(v == 1);
    }
    REP(i, m) {
      int v = scanf("%d", &seq[i]);
      assert(v == 1);
    }
    sum[0] = 0;
    REP(i, 100000) {
      sum[i + 1] = sum[i] + seq[i];
    }
    sort(card, card + n);
    reverse(card, card + n);
    ll ans = calc(0, 0);
    printf("%lld\n", ans);
  }
}

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

int main () {
  int a, b;
  cin >> a >> b;
  
  if (9>=a>=1 && 9>=b>=1) {
    cout << a * b << endl;
  }   
  else {
    cout << -1 << endl;
  }
 }


Measured memory_bytes: 3632
import Foundation


func readInt() -> [Int]{
    return readLine()!.split(separator: " ").map{Int($0)!}
}

func main() {
    let N = Int(readLine()!)!
    let S = ["❤️"] + Array(readLine()!)
    var r = 0
    var g = 0
    var b = 0
    
    for c in S {
        if c == "R" { r += 1 }
        if c == "G" { g += 1 }
        if c == "B" { b += 1 }
    }
        
    var ans = r * g * b

    for i in 1...(N-2) {
        for j in (i+1)...(N-1) {
            let x = j - i
            let k = j + x
            if k <= N && S[i] != S[j] && S[i] != S[k] && S[j] != S[k] {
                ans -= 1
            }
        }
    }
    
    print(ans)
}

main()


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

int main() {
  int a,b;
  cin >> a >> b;
  
  if (a <= 0 and b >= 0) {
    cout << "Zero" << endl;
  } else if (a > 0 and b > 0) {
    cout << "Positive" << endl;
  } else if (a < 0 and b < 0) {
    if ((abs(a - b) + 1) % 2) {
      cout << "Negative" << endl;
    } else {
      cout << "Positive" << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  int x;
  cin >> x;
  if(x < 1200) cout << "ABC" << endl;
  else cout << "ARC" << endl; 
  return 0;
}


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

using namespace std;

void fastio() {
	cin.tie(nullptr);
	cin.sync_with_stdio(false);
}

using LL = long long;
using LD = long double;

const LL MOD = 1e9+7;
const LL INF = LLONG_MAX;
const LL N = 1e6+1;

int main() {
	fastio();
	
	LL n;
	cin >> n;

	vector<LL> a(n);

	for(auto &e : a) {
		cin >> e;
	}

	
	vector<int> dis;
	dis.push_back(a[0]);

	for (int i = 1; i < n; ++i) {
		if (a[i] != a[i-1]) {
			dis.push_back(a[i]);
		}
	}

	int sz = dis.size();
	LL profit = 0, cur = 1000, st = cur/dis[0], price = dis[0];

	for (int i = 1; i < sz; ++i) {
		if (price < dis[i]) {
			// profit = (dis[i]-price)*st;
			// cur += profit;
			// st = (cur)/dis[i];
			// price = dis[i];
			LL j = i;
			while (j < sz && dis[j] > dis[j-1]) {
				j++;
			}
			if (j == sz) {
				profit = (dis[sz-1]-price)*st;
				cur += profit;
				break;
			}
			else {
				profit = (dis[j-1]-price)*st;
				cur += profit;
				st = cur/dis[j-1];
				price = dis[j-1];
				i = j-1;
			}
		}
		else {
			st = cur/dis[i];
			price = dis[i];
		}
	}

	cout << cur << "\n";

}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(0);

double fact(double n) {
  double ans = 1;

  for (size_t i = 1; i <= n; i++) {
    ans *= i;
  }
  return ans;
}


double dist(pair<double, double> p1, pair<double, double> p2) {

  double A = (p1.first - p2.first);
  A *= A;

  double B = (p1.second - p2.second);

  B *= B;

  A += B;

  return sqrt(A);



}
int main()
{

    int n;
    cin >> n;
    double arr[n];
    for (size_t i = 0; i < n; i++) {
      arr[i] = i;
    }

    pair<double, double> P[n];

    for (size_t i = 0; i < n; i++) {
       cin >> P[i].first >> P[i].second;
    }

    double sum = 0;

    do {

      double sum1 = 0;

      for (size_t i = 1; i < n; i++) {
         int A = arr[i - 1];
         int B = arr[i];

         sum1 += dist(P[A], P[B]);
      }

      sum += sum1;





    } while(next_permutation(arr, arr + n));

    //cout << fact(n) << "\n";

    cout << fixed << setprecision(7) << sum / fact(n);
}

// g++ -std=c++11


Measured memory_bytes: 256
#include <bits/stdc++.h>
using LL = long long;
const LL MOD = 1e9+9;
using namespace std;



int main(){
    int q;cin >> q;
    for(int i = 0;i < q;i++){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        int ans = (c-a+1)*(d-b+1);
        for(int j = a;j <= c;j++){
            for(int k = b;k <= d;k++){
                if(j%2 == 1 && k%2 == 0){
                    ans--;
                }
            }
        }
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";}
template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";}
template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<double,int>;
const ll M = 998244353;
void add(ll& x, ll y) {x+=y; x%=M;}
void chmax(ll& x, ll y) {if (x<y) x=y;}
vector<ll> sm(20005), inv(20005);
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}
void sm_build() {
	sm[0]=1;for(ll i=1;i<20005;i++) sm[i]=sm[i-1]*i%M;
	inv[20004]=mod_pow(sm[20004],M-2);for(ll i=20003;i>=0;i--) inv[i]=inv[i+1]*(i+1)%M;
}
ll ncr(ll n, ll r) {return sm[n] * inv[n-r] % M * inv[r] % M;}

int main() {
  int n; cin>>n;
  ll a[n]; for(int i=0;i<n;i++) cin>>a[i];

  ll dp[n]; fill(dp,dp+n,-LINF);
  for(int i=0;i<n;i++) {
    chmax(dp[i],a[i]);
    for(int j=i-2;j>=0;j-=2) {
      chmax(dp[i],dp[j]+a[i]);
    }
  }

  ll mx=-LINF, id=-1;
  for(int i=0;i<n;i++) {
    if (mx < dp[i]) {
      mx = dp[i], id=i;
    }
  }
  cout<<mx<<endl;
  vector<int> mv;

  for(int i=n-1;i>id;i--) {
    mv.push_back(i+1);
  }
  int ii = id;
  while(ii > 0) {
    int ix = -1;
    for(int j=ii;j>=0;j-=2) {
      if (dp[j] + a[ii] == dp[ii]) {
        ix = j;
        break;
      }
    }
    if (ix == -1) {
      for(int j=0;j<ii;j++) {
        mv.push_back(1);
      }
      ii = 0;
    } else {
      while(ii > ix) {
        mv.push_back((ii+ix)/2+1);
        ii-=2;
      }
    }
    //caut(ii);
  }

  cout<<mv.size()<<endl;
  for(int x : mv) {
    cout<<x<<endl;
  }
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	string a, b, c;
	cin >> a >> b >> c;

	cout << a[0] << b[0] << c[0];

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

# define MAX_N 1000010 // 10^6 + 10
class UnionFind{
    private:
        int par_[MAX_N];
        int rank_[MAX_N];
        int groups_;
    
    public:
        void init(int n){ // initializes the tree 
            for(int i=0; i<n; i++){
                par_[i] = i;
                rank_[i] = 0;
            }
            groups_ = n;
        } 
        int rootOf(int x){ // returns the root of x 
            if(par_[x] == x){
                return x;
            }
            else{
                return par_[x] = rootOf(par_[x]);
            }
        } 
        void unite(int x, int y){ // unites x and y 
            x = rootOf(x);
            y = rootOf(y);
            if(x == y) return;
            if(rank_[x] < rank_[y]){
                par_[x] = y;
                groups_--;
            }
            else{
                par_[y] = x;
                groups_--;
                if(rank_[x] == rank_[y]) rank_[x]++;
            }
        }
        bool isSameGroupe(int x, int y){ // whether x and y are united
            return rootOf(x) == rootOf(y);
        }
        int countGroups(){ // returns the number of groups
            return groups_;
        }
};

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

    UnionFind tree;
    tree.init(n);

    vector<int> x(m), y(m), z(m);
    for(int i=0; i<m; i++){
        cin >> x[i] >> y[i] >> z[i];
        tree.unite(x[i], y[i]);
    }

    int ans = tree.countGroups();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7680
H,W=[int(s) for s in input().split()]
ls=[[int(s) for s in input().split()] for i in range(H)]
ans=[]
#まず各列ごとに右に寄せる
for i in range(H):
  for j in range(W-1):
    if ls[i][j]%2==1:
      ans.append([i+1,j+1,i+1,j+2])
      ls[i][j+1]+=1
#一番右の列を下に寄せる
for i in range(H-1):
  if ls[i][W-1]%2==1:
    ans.append([i+1, W, i+2, W])
    ls[i+1][W-1]+=1
    
print(len(ans))
for e in ans:
  print(*e)
    

Measured memory_bytes: 30132
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    N = II()
    A = LMIIS()
    max_a = 0
    ans = 0
    for a in A:
        max_a = max(max_a,a)
        ans += max_a - a
    print(ans)


    
main()

Measured memory_bytes: 106076
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using ull=unsigned long long int;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
while(1){
  ll n,m,a;
  cin>>n>>m>>a;
  if(n==0&&m==0&&a==0)return 0;
  V<ll> ans(n,0);
  ans[a-1]=1;
  V<P> dat[1000];
  for(int i=0;i<m;i++){
    int d,e,f;
    cin>>d>>e>>f;
    dat[d-1].emplace_back(e-1,f-1);
  }
  for(int i=999;i>=0;i--){
    if(dat[i].size()==0)continue;
    for(int j=0;j<dat[i].size();j++){
      swap(ans[dat[i][j].fi],ans[dat[i][j].se]);
    }
  }
  for(int i=0;i<n;i++){
    if(ans[i]==1){
      cout<<i+1<<"\n";
      break;
    }
  }
}
}


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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n;
int a[100010];

int main() {
    cin >> n;
    a[0] = 0;
    rep(i,n) {
        cin >> a[i+1];
    }
    a[n+1] = 0;
    n++;
    ll sum = 0;
    rep(i,n) {
        sum += abs(a[i+1]-a[i]);
    }
    for (int i = 1; i < n; i++) {
        cout << sum - (abs(a[i+1]-a[i])+abs(a[i]-a[i-1])-abs(a[i+1]-a[i-1])) << endl;
    }
}
































Measured memory_bytes: 1664
function Main(input) {
  console.log((() => {
    return 30 <= parseInt(input) ? 'Yes' : 'No';
  })())
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29588