akhauriyash/Code-Regression huggingface dataset:
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define SZ(a) int(a.size())
#define ALL(x) (x).begin(),(x).end()
#define trav(a,x) for (auto& a: x)
#define LOG(FMT...) fprintf(stderr, FMT)
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; cin>>___T; for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
const double PI = acos(-1.0);
constexpr int maxn = 1e6+10;
constexpr int INF = 0x3f3f3f3f;
constexpr int mod = 1e9+7;
constexpr int Erica = 998244353;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr ull base=2333, P_1=19260811, P_2=999998639;
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
template<class T>inline void umin(T &x, T y) {x = x > y ? y : x;}
template<class T>inline void umax(T &x, T y) {x = x < y ? y : x;}
template<class T>inline void dec(T &x, T y) {x -= y; if(x < 0) x += mod;}
template<class T>inline void add(T &x, T y) {x += y; if(x >= mod) x -= mod;}
int x, n , p[maxn], vis[maxn];
int main()
{
    cin >> x >> n;
    for(int i = 1; i <= n; i++){
        cin >> p[i]; vis[p[i]] = 1;
    }
    int l = x, r = x, ans = 0;
    while(1){
        if(vis[l]) l--;
        else {
            ans = l; break;
        }
        if(vis[r]) r++;
        else{
            ans = r;
            break;
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3180
#define rep(i,n)for(i=0;i<n;i++)
W,H,m,c[10][10];DP[51][10][10][10][10];CalcO(o,x,y){c[x][y]>0?o+=c[x][y],o>m?o=m:0:0;return o>0?o:0;}CalcF(f,x,y){return c[x][y]<0?f+c[x][y]:f;}Walk(x,y,l,r,o,f){int*p=&DP[o][y][x][l][r];f>*p?*p=f:0;}Dig(x,y,l,r,o,f){Walk(x,y,l,r,CalcO(o-1,x,y),CalcF(f,x,y));}main(){int*p,x,y,g,d,v,f,o,l,r,f0;for(;scanf("%d%d%d%d%d",&W,&H,&f0,&m,&o)*W;memset(DP,!printf(f?"%d\n":"NA\n",f0-f),sizeof(*DP)*2)){rep(y,H)rep(x,W)scanf("%d",&c[x][y]);f0++;if(o>1)rep(x,W)DP[CalcO(o-1,x,0)][0][x][x][x]=CalcF(f0,x,0);rep(y,H-1)rep(g,W)for(o=m;o>1;o--)rep(d,2)rep(l,W-g)rep(v,g+1)if(r=l+g,p=&DP[o][y][x=d?l+v:r-v][l][r],f=*p){*p=0;Dig(x,y+1,x,x,o,f);x?x>l?Walk(x-1,y,l,r,o-1,f):Dig(x-1,y,x-1,r,o,f):0;x<W-1?x<r?Walk(x+1,y,l,r,o-1,f):Dig(x+1,y,l,x+1,o,f):0;}f=0;rep(x,W)rep(o,m)p=&DP[o+1][H-1][x][x][x],*p>f?f=*p:0,*p=0;}}

Measured memory_bytes: 0
p=*0..gets.to_i
f=->a{a!=p[a]?p[a]=f[p[a]]:a}
p$<.map(&:split).transpose.sum([]){|a|i=0
(x,i),*y=a.map{[_1.to_i,i+=1]}.sort
y.map{[-x+x=_1,i,i=_2]}}.sort.sum{(a=f[_2])!=(b=f[_3])?(p[b]=a
_1):0}

Measured memory_bytes: 54264
macro_rules! scan_sub {
    ( $itr:ident, $t:ty ) => {
        let mut buf = String::new();
        let $itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
    };
}

macro_rules! scan {
    ( $x:ident; Vec<$t:ty> ) => {
        scan_sub!(itr, $t);
        let $x = itr.collect::<Vec<_>>();
    };
    ( $( $x:ident ),*; $t:ty ) => {
        scan_sub!(itr, $t);
        let mut itr = itr;
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

fn main() {
    scan!(x; i64);

    'main: for i in 1..1000 {
        let i5 = i * i * i * i * i;
        for j in -1000..1000 {
            if i5 - (j * j * j * j * j) == x {
                println!("{} {}", i, j);
                break 'main;
            }
        }
    }
}


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

int check(int n, int d[10]){
	int ret;
	int m;

	m = n;

	while(m > 0){
		if(d[m%10] != 0){
			return 1;
		}
		m /= 10;
	}

	return 0;
}


int main(void){
	int n,m,k;
	int d[10] = {};
	int i,b;

	scanf("%d %d",&n,&k);

	for(i=0;i<k;i++){
		scanf("%d",&b);
		d[b]++;
	}

	for(i=n;i<200000;i++){
		if(check(i,d)==0){
			break;	
		}
	}

	printf("%d\n",i);

	return 0;
}






/*

int main(void){
	int n,m,k;
	int d[10] = {};
	int b;
	int i;
	int r;
	int x;
	int y;
	int f;
	int min;
	int minv;
	int ret;
	scanf("%d %d",&n,&k);

	for(i=0;i<k;i++){
		scanf("%d",&b);
		d[b]++;
	}

	for(i=0;i<10;i++){
		if(d[i] == 0){
			min = i;
			break;
		}
	}

	for(i=1;i<10;i++){
		if(d[i] == 0){
			minv = i;
			break;
		}
	}



	m = n;
	r = 0;
	while(m > 0){
		r++;
		m/= 10;
	}

	r--;
	f = 1;
	ret = 0;
	while(r >= 0){
		x = pow(10.0,r);
		y = ( n / x ) % 10;
		if( f == 1){
			if(d[y] > 0){
				f = 0;
				for(i = y + 1 ; i <10 ; i++){
					if(d[i] == 0){
						ret += x * i;
						break;
					}
				}
				if( i == 10){
					ret += x * minv * 10;
					ret += x * min;
				}
			}else{
				ret += x * y;
			}

		}else{
			ret += x * min;
		}
		r--;
	}





	printf("%d\n",ret);



	return 0;
}

*/

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

typedef ostringstream OSS; typedef istringstream ISS;
typedef long long LL;
typedef pair<int, int> PII;  typedef pair<LL, LL> PLL;
typedef vector<int>    VI;   typedef vector<VI>   VVI;   typedef vector<VVI>   VVVI;
typedef vector<LL>     VLL;  typedef vector<VLL>  VVLL;  typedef vector<VVLL>  VVVLL;
typedef vector<double> VD;   typedef vector<VD>   VVD;   typedef vector<VVD>   VVVD;
typedef vector<string> VS;   typedef vector<VS>   VVS;   typedef vector<VVS>   VVVS;
typedef vector<bool>   VB;   typedef vector<VB>   VVB;   typedef vector<VVB>   VVVB;
typedef vector<PII>    VPII; typedef vector<VPII> VVPII; typedef vector<VVPII> VVVPII;
typedef vector<PLL>    VPLL; typedef vector<VPLL> VVPLL; typedef vector<VVPLL> VVVPLL;

typedef unsigned int  UI;
typedef vector<UI>    VUI;
typedef vector<VUI>   VVUI;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define MAXUD(orig, target) orig = max(orig, target)
#define MINUD(orig, target) orig = min(orig, target)
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a)   { OSS oss; oss << a; return oss.str(); };

template<typename T=int> inline void dump(vector<T> vs, bool ent=false) { rep(i, vs.size()) cout << vs[i] << (i+1==vs.size() ? '\n' : ' '); if (ent) cout << endl; }
template<typename T = int> inline void dump(vector<vector<T>> vs, bool ent = false) { rep(i, vs.size()) dump<T>(vs[i]); if (ent) cout << endl; }

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int    DX[] = {1,  0, -1, 0};
const int    DY[] = {0, -1,  0, 1};
const double EPS  = 1e-12;
// const double PI   = acos(-1.0);
// lambda: [](T1 x)->T2{return y;}
// simple lambda: [](T x){return x;}

int solve(int N) {
    VVB tb(N, VB(N));
    rep(i, N) {
//        tb[i][i] = true;

        int m;
        cin >> m;
        rep(j, m) {
            int p;
            cin >> p;
            tb[i][p - 1] = true;
        }
    }

    int K;
    cin >> K;
    VI ls(K);
    rep(i, K) {
        cin >> ls[i];
        --ls[i];
    }

    int ans = -1;
    
    rep(i, N) {
        bool all_known = true;

        for (auto j : ls) {
            all_known &= tb[i][j];
        }

        if (all_known) {
            if (ans == -1) ans = i + 1;
            else return -1;
        }
    }
    
    return ans;
}

int main(void) {
    int N;
    while (cin >> N, N) cout << solve(N) << endl;

    return 0;
}

Measured memory_bytes: 3160
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

vector<string> split_naive(const string &s, char delim) {
	vector<string> elems;
	string item;
	for(char ch:s){
		if(ch==delim){
			if(!item.empty()) elems.push_back(item);
			item.clear();
		}
		else{
			item += ch;
		}
	}
	if(!item.empty()) elems.push_back(item);
	return elems;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	char str[64];
	bool next=false;
	map<int,int> M,N;
	while(cin.getline(str,sizeof(str))){
		if(!strcmp(str,"")){
			next = true;
			continue;
		}
		
		auto T = split_naive(str,',');
		int c;
		sscanf(T[0].c_str(),"%d",&c);
		if(!next){
			M[c]++;
		}
		else N[c]++;
	}

	vector<pair<int,int>> P;
	for(auto& x:M){
		if(N[x.first]){
			P.emplace_back(x.first,x.second+N[x.first]);
		}
	}
	sort(ALL(P),PAIRCOMP(first,<));

	for(auto& x:P){
		out(x.first,x.second);
	}

	return 0;
}


Measured memory_bytes: 3280
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

vector<ll> seg,lazy;
ll RN;

void segeval(ll k) {
	if (k >= 2 * RN)return;
	if (lazy[k] == 1e18)return;
	if (seg[k] > lazy[k]) {
		seg[k] = lazy[k];
		if (k < RN) {
			lazy[2 * k] = min(lazy[2 * k], lazy[k]);
			lazy[2 * k + 1] = min(lazy[2 * k + 1], lazy[k]);
		}
		lazy[k] = 1e18;
	}
	else {
		if (k < RN) {
			lazy[2 * k] = min(lazy[2 * k], lazy[k]);
			lazy[2 * k + 1] = min(lazy[2 * k + 1], lazy[k]);
		}
		lazy[k] = 1e18;
	}
}

void segset(ll a, ll b, ll x, ll k = 1, ll l = 0, ll r = RN-1) {
	if (b < l || r < a)return;
	segeval(k);
	if (a <= l && r <= b) {
		lazy[k] = min(lazy[k], x);
		segeval(k);
		return;
	}
	else {
		segset(a, b, x, 2 * k, l, (l + r) / 2);
		segset(a, b, x, 2 * k + 1, (l + r) / 2 + 1, r);
		seg[k] = min(seg[2 * k], seg[2 * k + 1]);
		return;
	}
}

ll segget(ll a, ll b, ll k = 1, ll l = 0, ll r = RN - 1) {
	segeval(k);
	if (b < l || r < a)return 1e18;
	else if (a <= l && r <= b)return seg[k];
	else {
		return min(
			segget(a, b, 2 * k, l, (l + r) / 2),
			segget(a, b, 2 * k + 1, (l + r) / 2 + 1, r)
		);
	}
}

struct edge {
	ll a, b;
	ll c;
};
vector<edge> edges;

int main() {
	ll N, M;
	cin >> N >> M;
	RN = 1;
	while (RN < N)RN *= 2;
	seg.resize(RN*2,1e18);
	lazy.resize(RN * 2, 1e18);
	segset(0, 0, 0);
	edges.resize(M);
	for (ll m = 0; m < M; m++) {
		cin >> edges[m].a >> edges[m].b >> edges[m].c;
		edges[m].a--;
		edges[m].b--;
	}
	sort(edges.begin(), edges.end(), [](edge a, edge b) {
		if (a.b != b.b)return a.b < b.b;
		if (a.c != b.c)return a.c > b.c;
		return a.a < b.a;
	});
	ll top = 0;
	for (ll m = 0; m < M; m++) {
		ll cur = segget(edges[m].a, top);
		segset(edges[m].a, edges[m].b, cur + edges[m].c);
		top = edges[m].b;
	}
	ll ans = segget(N - 1, N - 1);
	if (ans == 1e18)cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6656
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n,m) = get!(usize, usize);
    let sc  = get!(usize, usize; m);

    if n==1 {
        let mut res = None;
        for (_, c) in sc {
            if let Some(val) = res {
                if val != c {
                    println!("-1");
                    return;
                }
            } else {
                res = Some(c);
            }
        }
        if res.is_none(){
            println!("0");
            return;
        }
        println!("{}", res.unwrap());
        return;
    }

    for i in 10usize.pow((n-1) as u32)..10usize.pow(n as u32) {
        let mut flag  = false;
        for &(s,c) in &sc {
            if i/10usize.pow((n-s) as  u32)%10 != c {
                flag = true;
                break;
            }
        }
        if flag {
            continue;
        }
        println!("{}", i);
        return;
    }
    println!("-1");
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int  pathed[10]= {0};
double sum(0.0);
int N,x[10],y[10];

void dfs(int now,double cost){
  bool all_pathed = true;
  pathed[now] = 1;
  for (int i(0);i<N;i++){
    if (pathed[i] == 0){
      double cost_now = cost + sqrt((double)(x[now]-x[i])*(x[now]-x[i]) + (y[now]-y[i])*(y[now]-y[i]));
      dfs(i,cost_now);
      all_pathed = false;
    } 
  }
  if (all_pathed == true) {
    sum+=cost;
    //cout << now <<" "<< cost << endl;
  }
  pathed[now]=0;
}

int main(){
  cin>>N;
  for (int i(0);i<N;i++) cin>>x[i]>>y[i];
  for (int i(0);i<N;i++){
    dfs(i,0);
  }
  int t(1);
  for (int i(1);i<=N;i++) t*=i;
  //cout << t << endl;
  cout << setprecision(10) << sum/t << endl;
  return 0;
}



Measured memory_bytes: 256
n, m = map(int, input().split())
s = list(map(int, input().split()))
t = list(map(int, input().split()))
dp = [[0] * (m + 1) for _ in range(n + 1)]
sum = [[0] * (m + 1) for _ in range(n + 1)]
MOD = 10 ** 9 + 7

ans = 0
for i in range(n):
  for j in range(m):
    if s[i] == t[j]:
      dp[i + 1][j + 1] = (sum[i][j] + 1) % MOD
    else:
      dp[i + 1][j + 1] = 0
    sum[i + 1][j + 1] = (sum[i][j + 1] + sum[i + 1][j] 
                       - sum[i][j] + dp[i + 1][j + 1]) % MOD
    ans += dp[i + 1][j + 1]
    ans %= MOD
print((ans + 1) % MOD)


Measured memory_bytes: 134380
s = int(input())

lst = [s]

i = 1
while True:
    if s % 2 == 0:
        s = s // 2
    else:
        s = 3 * s + 1
    i += 1
    if s in lst:
        print(i)
        break
    else:
        lst.append(s)


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

int main() {
    int l, r;
    cin >> l >> r;

    r = min(r, l + 4038);

    int ans = INT_MAX;
    for (int i = l; i < r; i++) {
        for (int j = i+1; j <= r; j++) {
            ans = min(((i%2019)*(j%2019)) % 2019, ans);
        }
    }

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

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    vector<int> X(N);
    for (int i=0; i<N; i++)
        cin >> X[i];
    ll ans = 0;
    for (int i=1; i<N; i++)
        ans += min((X[i]-X[i-1])*A, B);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n,m,i,j,k,a,b,c;
double str[10][2],ans[45000];
int main()
{
    scanf("%lld",&n);
    for(i=0; i<n; i++)
    {
        scanf("%lf%lf",&str[i][0],&str[i][1]);
    }
    j=0;
    for(i=0; i<n; i++)
    {
        k=0;
        while(1)
        {
            if(k!=i)
                ans[j++]=sqrt((str[i][0]-str[k][0])*(str[i][0]-str[k][0])+(str[i][1]-str[k][1])*(str[i][1]-str[k][1]));
            k++;
            if(k>=n)
                break;
        }
    }
    double ss=0;
    for(i=0; i<j; i++)
    {
        ss+=ans[i];
    }
    printf("%.10lf",ss/n);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    char[] s = sc.next().toCharArray();
    StringBuilder sb = new StringBuilder();
    int count = 0;
    for(int i=0;i<n;i++){
      if(s[i]=='('){
        sb.append('(');
        count++;
      }else if(count > 0){
        count--;
        sb.append(')');
      }else{
        sb.insert(0,'(');
        sb.append(')');
      }
    }
    for(int i=0;i<count;i++){
      sb.append(')');
    }
    System.out.println(sb.toString());
  }
}

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

int main(void){
	int n, k;
	cin >> n >> k;
	vector<int> a(200020, 0);
	for(int i = 0; i < n; ++i){
		int tmp;
		cin >> tmp;
		a[tmp]++;
	}
	sort(a.rbegin(), a.rend());
	int sum = 0;
	while(true){
		if(a[k] == 0) break;
		sum += a[k];
		k++;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1024
array_index = gets(chomp:true).to_i
  array = gets(chomp:true).split.map(&:to_i)

  rep_count = 0

  for loop_num in 0...array_index

    rigth_ope_index = array_index - 1
    left_cmp_index = rigth_ope_index - 1

    while left_cmp_index >= loop_num 

      if array[left_cmp_index] > array[rigth_ope_index]

        temp_elem = array[rigth_ope_index]

        array[rigth_ope_index] = array[left_cmp_index]
        array[left_cmp_index] = temp_elem

        rep_count += 1
      end

      left_cmp_index -= 1
      rigth_ope_index -= 1
    end

  end

  puts array.join(" ")
  puts rep_count



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

int64_t f(int64_t A, int64_t B, int64_t x) {
    return A * x / B - A * (x / B);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int64_t A, B, N;
    cin >> A >> B >> N;
    int64_t ans = f(A, B, N);
    int64_t cand = N / B * B - 1;
    if (cand >= 0) {
        ans = max(ans, f(A, B, cand));
    }
    cout << ans << endl;
    return 0;
}

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

char lowcmp[26]="abcdefghijklmnopqrstuvwxyz";
char upcmp[26]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int utoi(char C){return C-'A';}
int ntoi(char C){return C-'0';}

int main(void){
    char s[5];
    scanf("%s",s);
    bool yymm=true,mmyy=true;
    if (ntoi(s[0])>1){
        mmyy=false;
    } else if (ntoi(s[0])==1 && ntoi(s[1])>2) {
        mmyy=false;
    }
    
    if (ntoi(s[2])>1){
        yymm=false;
    } else if (ntoi(s[2])==1 && ntoi(s[3])>2) {
        yymm=false;
    }
    
    if (ntoi(s[0])==0 && ntoi(s[1])==0){
        mmyy=false;
    }
    
    if (ntoi(s[2])==0 && ntoi(s[3])==0){
        yymm=false;
    }
    
    if (yymm==true && mmyy==true){
        printf("AMBIGUOUS\n");
    } else if (yymm==false && mmyy==true){
        printf("MMYY\n");
    } else if (yymm==true && mmyy==false){
        printf("YYMM\n");
    } else {
        printf("NA\n");
    }
    
    
    
    
    
    return 0 ;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using vec = vector<ll>;

int main() {
    ll N, M, A, B, count = 0;
    cin >> N >> M;
    vec H(N);
    vector<bool> ans(N);
    REP(i, N) {
        ans[i] = true;
        cin >> H[i];
    }

    REP(i, M) {
        cin >> A >> B;
        if(H[A-1] > H[B-1]) {
            ans[B-1] = false;
        } else if(H[A - 1] == H[B - 1]) {
            ans[A - 1] = false;
            ans[B - 1] = false;
        } else {
            ans[A - 1] = false;
        }
    }

    REP(i, N) {
        if(ans[i] == true)
            count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 4052
#include <iostream>
using namespace std;
int main(){
	int m,nmin,nmax;
	while(cin>>m>>nmin>>nmax){
		if(m==0&&nmin==0&&nmax==0) break;
		int p[m];
		for(int i=0;i<m;i++){
			cin>>p[i];
		}
		int g[nmax-nmin+1],gmax=0,nn;
		for(int i=0;i<=nmax-nmin;i++){
			g[i]=p[nmin+i-1]-p[nmin+i];
			if(g[i]>=gmax){
				gmax=g[i];
				nn=nmin+i;
			}
		}
		cout<<nn<<endl;
	}
    return 0;
}

Measured memory_bytes: 1160
n = int(input())
s = sorted([int(input()) for _ in range(n)])
s_m = sum(s)
if s_m % 10 != 0:
  print(s_m)
else:
  for i in s:
    ans = s_m - i
    if ans % 10 != 0:
      print(ans)
      exit()
  print(0)

Measured memory_bytes: 3060
a,b=map(int,input().split())
a-=1
fa=0
fb=0
if a%4==0:
  fa=a
elif a%4==1:
  fa=1
elif a%4==2:
  fa=a+1
if b%4==0:
  fb=b
elif b%4==1:
  fb=1
elif b%4==2:
  fb=b+1
print(fa^fb)

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;
#define debug(x) cerr << #x << ": " << (x) << "\n";

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

class ORD {
  public:
  int l, r;
  ORD() {}
  ORD(int l, int r): l(l), r(r) {}
  bool operator < (const ORD &ord) const {
    if (r == ord.r) {
      return l < ord.l;
    } else {
      return r < ord.r;
    }
  }
};

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

  int n, m;
  cin >> n >> m;
  vector<ORD> ords(m);
  rep(i, 0, m) {
    cin >> ords[i].l >> ords[i].r;
  }

  sort(All(ords));

  int ans = 0;
  set<int> cut;
  rep(i, 0, m) {
    auto ord = ords[i];
    int r = ord.r;
    int l = ord.l;
    auto it_c = cut.upper_bound(l);
    if (it_c == cut.end()) {
      cut.insert(r);
      ans++;
    } else if (*it_c <= l) {
      cut.insert(r);
      ans++;
    }
  }

  // cout << (int)cut.size() << endl;
  cout << ans << endl;

  return 0;
};


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

// 1 << 3 : int "3" change to bit "100"
// rep(pattern, 1 << N) if (pattern & (1 << x)) cnt++

int main(){
    int N;
    cin >> N;
    vector<int> d;
    rep(i,N){
        int tmp;
        cin >> tmp;
        d.push_back(tmp);
    }

    sort(d.begin(), d.end());

    int thr1 = d[N/2-1];
    int thr2 = d[N/2];
    
    cout << thr2 - thr1;
    

    return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>
#define MAX_N 50
ll dp[MAX_N + 1][MAX_N + 1];

ll combi(int n, int r)
{
       if(n==r) return dp[n][r] = 1;
       if(r==0) return dp[n][r] = 1;
       if(r==1) return dp[n][r] = n;
       if(dp[n][r]) return dp[n][r];
       return dp[n][r] = combi(n-1,r) + combi(n-1,r-1);
}
int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int N, P;  cin >> N >> P;
	int even_count = 0, odd_count = 0;
	REP(i , N){
			int A;  cin >> A;
			if(A % 2 == 0)  even_count++;
			else            odd_count++;
	}

	ll keep1 = 0, keep2 = 0;
	if(P == 1){
		//奇数の袋から奇数個、偶数の袋から適当個選ぶ
		for(int i = 1 ; i <= odd_count ; i += 2)
			keep1 += combi(odd_count,i);
	}else{
		//奇数の袋から偶数個、偶数の袋から適当個選ぶ
		for(int i = 0 ; i <= odd_count; i += 2)
			keep1 += combi(odd_count,i);
	}
  	for(int i = 0 ; i <= even_count ; i++)
		keep2 += combi(even_count,i);

	cout << keep1 * keep2 << endl;

	return 0;
}


Measured memory_bytes: 256
from itertools import *

N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))

x=[i for i in range(1,N+1)]
X=list(permutations(x,N))
a,b=0,0

for index,i in enumerate(X):
    i=list(i)
    a= index+1 if i==P else a
    b= index+1 if i==Q else b
print(abs(a-b))


Measured memory_bytes: 8052
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	int n;
	cin >> n;
	
	vector<int> p(n);
	
	int ans = 0;
	int mn = n + 5;
	
	for(int i = 0; i < n; i++){
		cin >> p[i];
		mn = min(mn, p[i]);
		if(p[i] <= mn)
			ans++;
	}
	
	cout << ans << endl;

	return 0;
}


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

#define ll long long int
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0);
#define eb(x) emplace_back(x)

bool is_pallin(string s,ll i,ll j)
{
    string temp;
    for(int k=i;k<=j;k++)
    {
        temp.push_back(s[k]);
    }

    string temp2=temp;
    reverse(temp.begin(),temp.end());

    if(temp==temp2)
        return true;
    else
        return false;


}


int main()
{
	FASTIO;

	string s;
	 cin>>s;
	 const int n=s.length();

	 bool a=is_pallin(s,0,n-1);
     bool b= is_pallin(s,0,((n-1)/2)-1);
     bool c= is_pallin(s,n+3/2-1,n-1);

     if(a && b && c)
        cout<<"Yes\n";
     else
        cout<<"No\n";

	return 0;
}













Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using lint = long long;
#define low lower_bound
#define upp upper_bound
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define Rep(i, n) for (int i = int(n); i >= 0; --i)
#define all(vec) (vec).begin(), (vec).end()
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

struct edge { lint to, cost; };
using P = pair<lint, lint>;
using D = pair<double, double>;
//const lint mod = 998244353LL;
const lint mod = 1000000007LL;
const lint inf = 3e18;

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

lint modpow(lint x, lint n) {
	lint ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

lint fact[1000000];
void f_init(lint n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (lint i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

lint comb(lint n, lint r) {
	if (n < r) return 0;
	if (n == r) return 1;
	lint ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

lint nck[1010][1010];
void comb(lint n) {
	rep(i, n + 1) {
		rep(j, i + 1) {
			if (j == 0 || i == j) nck[i][j] = 1;
			else nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
		}
	}
}

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

lint lcm(lint a, lint b) { return a / gcd(a, b) * b; }

bool pri(lint p) {
	for (lint i = 2LL; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1LL;
}

map<lint, lint> factring(lint n) {
	map<lint, lint>ans;
	for (lint i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

double dis(D a, D b) { return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second)); }

int n;
D d[10];
double ans;
vector<int>v;
int main() {
	cin >> n;
	f_init(10);
	rep(i, n) {
		cin >> d[i].first >> d[i].second;
		v.emplace_back(i);
	}
	rep(i, n - 1) ans += dis(d[i], d[i + 1]);
	while (next_permutation(all(v))) {
		rep(i, n - 1) ans += dis(d[v[i]], d[v[i + 1]]);
	}
	printf("%.10lf\n", ans / (double)fact[n]);
}

Measured memory_bytes: 2304
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int numCount[] = new int[101];
		String inputData = br.readLine();
		int value = 0;

		while (inputData != null) {
			numCount[Integer.parseInt(inputData)] += 1;
			inputData = br.readLine();
		}

		for (int i = 1; i <= 100; i++) {
			if (numCount[i] > value) {
				value = numCount[i];
			}
		}

		for (int i = 1; i <= 100; i++) {
			if (numCount[i] == value) {
				System.out.println(i);
			}
		}

	}

}

Measured memory_bytes: 24244
#include <stdio.h>

int main() {
    int i, k, v,scan,an;
    int MAX_V = 999999;
    int count[MAX_V+1];
    int prime[MAX_V+1];
    for(i = 2; i <= MAX_V; i++) {
        prime[i] = 1;
    }
    for(i = 2; i*i <= MAX_V; i++) {
        if(prime[i]) {
            for(k = 2 * i; k <= MAX_V; k += i) {
                prime[k] = 0;   
            } 
        }
    }
    count[2]=0;
    for(i=2;i<=MAX_V;i++){
        count[i+1]= count[i]+prime[i];
    }
    while(scanf("%d",&scan)!= EOF){
        printf("%d\n",count[scan+1]);
    }
    return 0; 
}

Measured memory_bytes: 8836
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    FOR(i,n,1000){
        if(i % 111 == 0){
            PUTS(i);
            break;
        }
    }
}

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

u64 lcm(u64 a, u64 b) { return (a / gcd(a, b)) * b; }

int main() {
  cout << setprecision(15);
  u64 N, K;
  cin >> N >> K;
  u64 res = 0;
  while (N > 0) {
    N /= K;
    ++res;
  }
  cout << res << endl;
  return 0;
}

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

using namespace std;

int main() {
  string str;
  cin >> str;
  int num = 0;
  for (int i = 0; i < 3; i++) {
    if (str[i] == 'o') { num++; }
  }
  cout << 700 + 100 * num << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <valarray>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>

using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < n; ++i)
    if (s[i] == 'R')
      cnt++;
  if (cnt > n - cnt)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


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

typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
typedef vector<vector<lli> > vvi;
typedef vector<ii> vii;

#define EB emplace_back
#define PB push_back
#define MP make_pair
#define FF first
#define SS second

const int mod = 1e9 +7;
lli a[16][16], n, dp[131072];

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=0; i<n; i++)
		for(int j=0; j<n; j++)
			cin>>a[i][j];
	for(int m=1; m<(1LL<<n); m++)
	{
		for(int i=0; i<n; i++)
		{
			if((m>>i)&1)
			{
				for(int j=i; j<n; j++)
					if((m>>j)&1) dp[m]+=a[i][j];
			}
		} 
		for (int s=m; s; s=(s-1)&m)
			dp[m] = max(dp[m], dp[s]+dp[m^s]);
	}
	cout << dp[(1LL<<n)-1];
}

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

int main() {
	vector<int> r;
	string d[7]={"Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"};
	while (true)
	{
		int m,d;
		cin >> m >> d;
		if (m==0)break;
		if (m<3){m+=12;d-=2;}
		r.push_back((5+d+(13*(m+1))/5)%7);
	}
	for (int i=0; i<r.size(); i++)
	{
		cout << d[r[i]] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main()
{
	int i,n,s[1024],p[1024],q[1024],r[1024],Q,R,P,C,m;
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		for(i=0;i<n;i++){
			scanf("%d%d%d%d",&s[i],&p[i],&q[i],&r[i]);
		}
		scanf("%d%d%d%d",&P,&Q,&R,&C);
		m=1;
		for(i=0;i<n;i++){
			if(p[i]<=P&&q[i]<=Q&&r[i]<=R&&4*p[i]+9*q[i]+4*r[i]<=C){
				printf("%d\n",s[i]);
				m=0;
			}
		}
		if(m){
			printf("NA\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2736
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
Ｐ以上のループがあるかどうか
ゴールまでの途中と、ゴールしてからと。

ベルマンフォード法なるもの。
ＤＰは負には使えない、ワーシャルフロイドは3乗。

*/
ll N,M,P,oo=1e9;
vector<vector<pair<ll,ll>>> V(2510);
vector<bool> is_parent(2510);
vector<ll> S(2510, -oo);

void dfs(ll n){
  is_parent[n]=true;
  for(auto v: V[n]){
    ll v1=v.first, v2=v.second;
    if(S[v1]<min(oo, S[n]+v2)){
      S[v1]=(is_parent[v1] || S[n]==oo)?oo: S[n]+v2;
      dfs(v1);
    }
  }
  is_parent[n]=false;
};

int main(){
  S[1]=0;
  cin>>N>>M>>P;
  for(ll i=0; i<M; i++){
    ll a,b,c; cin>>a>>b>>c;
    V[a].push_back({b,c-P});
  }
  dfs(1);
  cout<<(S[N]==oo? -1: max(0LL,S[N]))<<endl;
}

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

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

    if(t.length() < p.length()) return 0;
    
    for(int i = 0; i <= t.length()-p.length(); i++){
        int j;
        for(j = 0; j < p.length(); j++){
            if(t[i+j] != p[j])  break;
        }
        if(j == p.length()) cout << i << endl;
    }


    return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    ll n; cin >> n;
    // 合計と暫定の最大値をともに0で初期化する
    ll sum = 0, mx = 0;
    rep(i, n) {
        // 入力を受け取って合計と最大値を更新する
        ll a; cin >> a;
        mx = max(mx, a);
        sum += a;
    }
    ll ans = sum - mx / 2;
    cout << ans << endl;
}


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

using namespace std;
 
#define MD 1000000007
typedef long long int ll;

ll gcd(ll a,ll b){
    ll res;
    if(a==0||b==0){
        cout<<"Error"<<endl;
        return 0;
    }
    while((res=a%b)!=0){    
        a=b;
        b=res;
    }
    return b;
}

int main(){
    ll N,X;
    cin>>N>>X;
    vector<ll> v(N+1);
    v[0]=X;
    for(ll i=1;i<N+1;i++){
        cin>>v[i];
    }
    
    sort(v.begin(),v.end());
    
    ll ans=v[1]-v[0];
    for(ll i=1;i<N;i++){
        ans=gcd(ans,v[i+1]-v[i]);
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl

int h[114];
int Ans=0;

int kukan(int l,int r){
    if(l==r){
        Ans+=h[l];
        h[l]=0;
        return 0;
    }
    if(l>r){
        return 0;
    }
    int e=INF;
    for(int i=l;i<=r;i++){
        e=min(e,h[i]);
    }
    Ans+=e;
    for(int i=l;i<=r;i++){
        h[i]-=e;
    }
    for(int i=l;i<=r;i++){
        if(h[i]==0){
            kukan(l,i-1);
            kukan(i+1,r);
            break;
        }
    }
    return 0;
    
}


signed main(){
    int N;
    cin >> N;
    REP(i,N){cin >> h[i];}
    kukan(0,N-1);
    cout << Ans << endl;
    
    return 0;
}

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

template <class T>
inline void read(T &x) {
    x = 0;
    int f = 0;
    char ch = getchar();
    while (!isdigit(ch))    { f |= ch == '-'; ch = getchar(); }
    while (isdigit(ch))     { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
    x = f ? -x : x;
    return;
}

int a[200010];
int n, x;

int main() {
    read(n);
    for (int i = 1; i < n; ++i) {
        read(x);
        ++a[x];
    }
    for (int i = 1; i <= n; ++i)    printf("%d\n", a[i]);
    return 0;
}

Measured memory_bytes: 4544
#include <cstdio>
#define max(a,b)(a>=b?a:b)
bool osenbei[10][10000];
int r,c,s,cnt,res,ans;
int i,j,k;
int main() {
	while(scanf("%d %d",&r,&c),r) {
		for(i=0;i<r;i++)for(j=0;j<c;j++) {
			scanf("%d",&s);
			osenbei[i][j]=s;
		}
		ans=0;
		for(i=0;i<(1<<r);i++) {
			for(j=0;j<r;j++)if(i&(1<<j))
				for(k=0;k<c;k++)osenbei[j][k]=!osenbei[j][k];
			res=0;
			for(j=0;j<c;j++) {
				cnt=0;
				for(k=0;k<r;k++)cnt+=osenbei[k][j];
				res+=max(cnt,r-cnt);
			}
			ans=max(ans,res);
			for(j=0;j<r;j++)if(i&(1<<j))
				for(k=0;k<c;k++)osenbei[j][k]=!osenbei[j][k];
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1124
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(){
	int i, n, c;
	int count[500] = {0};
	while((c = getchar()) != EOF){
		if(isupper(c)) c = tolower(c);
		count[c]++;
	}
	for(c = 'a';c <= 'z';c++){
		printf("%c : %d\n", c, count[c]);
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fr first
#define sc second
#define pb push_back
#define mp make_pair
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define mod 1000000007
int n,m,k,x,y,z,t,mat[505][505],b,s=0;
void push(int &ii,int &jj)
{if(jj>1){if(mat[ii][jj-1]&1){jj--;return;}}
if(ii>1){if(mat[ii-1][jj]&1){ii--;return;}}
if(jj<m){if(mat[ii][jj+1]&1){jj++;return;}}
if(ii<n)ii++;
else if(jj<m)jj++;
else if(jj>1)jj--;
else if(ii>1)ii--;}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
vector<pii> vec;
cin>>n>>m;
forr(i,1,n+1)
forr(j,1,m+1)
cin>>mat[i][j];
forr(i,1,n+1)
forr(j,1,m+1)
{x=i;y=j;
if(mat[i][j]&1){
push(x,y);
if(x!=i || y!=j)
{mat[i][j]=0;
mat[x][y]=(mat[x][y]+1)%2;
vec.pb(mp(i,j));
vec.pb(mp(x,y));}}}
cout<<vec.size()/2<<endl;
for(int i=0;i<vec.size();i+=2)
cout<<vec[i].fr<<" "<<vec[i].sc<<" "<<vec[i+1].fr<<" "<<vec[i+1].sc<<endl;

return 0;
}


Measured memory_bytes: 5232
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;


int main(){
    string n;
    cin >> n;
    ll ans = 0;
    ll l = n.size();
    rep(i,l){
        ans += n[i]-'0';
    }
    if(ans%9==0)cout<<"Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int N; cin >> N;
	int ans = 0, t = 0;
	for (int i = 0; i < N; ++i) {
		int x; cin >> x;
		t += x;
		ans -= x * x;
	}
	ans = (ans + t * t) / 2;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256