akhauriyash/Code-Regression huggingface dataset:
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )
import Data.List

cReadLn :: IO Int
cReadLn = fst . fromJust . C.readInt <$> C.getLine

getParms :: IO [Int]
getParms = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  c1@[c11,c12,c13] <- getParms
  c2@[c21,c22,c23] <- getParms
  c3@[c31,c32,c33] <- getParms
  putStrLn $ if f c1 c2 c3 
               then "Yes"
               else "No"

f :: [Int] -> [Int] -> [Int] -> Bool
f c1 c2 c3 = let c = [c1,c2,c3] in
  yoko c && tate c

yoko :: [[Int]] -> Bool
yoko [c1@[c11,c12,c13], c2@[c21,c22,c23], c3@[c31,c32,c33]]
  = (all (==c11-c21) $ zipWith (-) c1 c2) &&
    (all (==c21-c31) $ zipWith (-) c2 c3) &&
    (all (==c31-c11) $ zipWith (-) c3 c1) 

tate = yoko . transpose

Measured memory_bytes: 380
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
x = I()
if x == 0:
    print(1)
else:
    print(0)


Measured memory_bytes: 74436
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    int Q; cin >> Q;
    vector<vector<int>> G(N);
    vector<ll> cnt(N);
    for(int i = 0; i < N-1;i++){
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for(int i = 0; i < Q;i++){
        int p,x; cin >> p >> x;
        p--;
        cnt[p] += x;
    }
    
    function<void(int,int,ll)> rec = [&](int n,int pre,ll c){
        cnt[n] += c;
        for(auto next:G[n]){
            if(next == pre) continue;
            rec(next,n,cnt[n]);
        }
    };
    rec(0,-1,0);
    res = cnt;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<vector<ll>>() << endl;
    return 0;
}


Measured memory_bytes: 29952
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
using namespace std;
const int mod=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    ll a,b,n;
    cin >> n >> a >> b;
    if(a>b)swap(a,b);
    ll sa = b-a;
    ll ans1,ans2,ans;
    if(sa%2 == 0)ans = sa/2;
    else{
        ans1 = min(b-1,n-a);
        if((a-1)<(n-b)){
            ans2 = a-1 + 1;
            sa = (b-a-1);
            ans2 += sa/2;
        }else{
            ans2 = n-b + 1;
            sa = n-(a +n-b+1);
            ans2 += sa/2;
        }
        ans = min(ans1,ans2);
    }

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

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

int H, W;

int main() {
  cin >> H >> W;

  vector<vector<char>> grid(H + 2, vector<char>(W + 2, '#'));
  rep(i, H) rep(j, W) cin >> grid[i + 1][j + 1];

  vector<set<int>> row(H), col(W);

  rep(i, H) rep(j, W + 2) if (grid[i + 1][j] == '#') row[i].insert(j);
  rep(j, W) rep(i, H + 2) if (grid[i][j + 1] == '#') col[j].insert(i);

  int ans = 0;
  rep(i, H) rep(j, W) {
    if (grid[i + 1][j + 1] == '#') continue;

    int c = 0;
    auto it = row[i].upper_bound(j + 1);
    c += (*it) - (*prev(it)) - 1;
    it = col[j].upper_bound(i + 1);
    c += (*it) - (*prev(it)) - 1;
    c -= 1;
    ans = max(ans, c);
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

typedef long long int ll;
typedef long double ld;

vector<int> dp(100010, INT_MAX);
int arr[100010];
int n, k;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> arr[i];
	}
	
//	for(int i = 0; i < n; i++) cout << "dp = " << dp[i] << endl;
	
	dp[0] = 0;
	
	for(int i = 0; i < n; i++){
		for(int j = 1; j <= k; j++){
			if(i + j < n){
				dp[i + j] = min(dp[i + j], dp[i] + abs(arr[i + j] - arr[i]));
			}
		}
	}
	
	cout << dp[n - 1] << endl;
	 
	return 0;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>                                                                               
using namespace std;                                                                                   
#define ll long long                                                                                   
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)                                                
#define rep(i,n) REP(i,0,n)                                                                            
const int inf = 1e9+7;                                                                                 
const ll longinf = 1LL<<60;                                                                            
const ll mod = 1e9+7;                                                                                  
                                                                                                       
int main() {                                                                                           
  int n;                                                                                               
  cin >> n;                                                                                            
  vector<int> P(n);                                                                                    
  rep(i, n)                                                                                            
    cin >> P[i];                                                                                       
  int ans = 0;                                                                                         
  REP(i, 1, n-1) {                                                                                     
    if((P[i] - P[i-1]) * (P[i] - P[i+1]) < 0)                                                          
      ans++;                                                                                           
  }                                                                                                    
  cout << ans << endl;                                                                                 
  return 0;                                                                                            
}       

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    int n;
    cin >> n;
    int ans = 0;
    int x = n/500;
    n-=x*500;
    ans+=1000*x;

    int y = n/5;
    ans += 5*y;

    cout << ans << endl;
}

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

long long N;
string S;
int P;

long long solve(){
    if(P==2||P==5){
        long long res=0;
        for(int i=0;i<N;i++) if((S[N-i-1]-'0')%P==0) res+=N-i;
        return res;
    }
    vector<long long> val(P, 0);
    long long tenfactor=1;
    long long cur=0;
    val[cur]++;

    for(int i=0;i<N;i++){
        cur=(cur+(S[N-i-1]-'0')*tenfactor)%P;
        tenfactor=(tenfactor*10)%P;
        val[cur]++;
    }
    long long res=0;
    for(int p=0;p<P;p++) res+=val[p]*(val[p]-1)/2;
    return res;
}

int main(){
    cin >> N >> P >> S;
    cout << solve() << endl;
}


Measured memory_bytes: 640
import java.util.HashSet;
import java.util.Scanner;
import java.util.stream.IntStream;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt(), w = sc.nextInt();

        char[][] map = new char[h][w];
        for (int i = 0; i < h; i++) {
            map[i] = sc.next().toCharArray();
        }

        HashSet<Integer> yset = new HashSet<>(), xset = new HashSet<>();
        IntStream.range(0, h).forEach(yset::add);
        IntStream.range(0, w).forEach(xset::add);

        outer:
        for (int y = 0; y < h; y++) {
            for (int x = 0; x < w; x++) {
                if (map[y][x] != '.') {
                    continue outer;
                }
            }
            yset.remove(y);
        }
        outer:
        for (int x = 0; x < w; x++) {
            for (int y = 0; y < h; y++) {
                if (map[y][x] != '.') {
                    continue outer;
                }
            }
            xset.remove(x);
        }
        yset.forEach(y -> {
            xset.forEach(x -> System.out.print(map[y][x]));
            System.out.println();
        });
    }
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

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

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int solve(int n,string s)
{
	vi a(2*n);
	rep(i,2*n) a[i]=s[i]=='B';

	int cur=0;
	ll res=1;
	rep(i,2*n){
		if((cur+a[i])%2){ // open
			cur++;
		}
		else{ // close
			(res*=cur)%=MOD;
			cur--;
			if(cur<0)
				return 0;
		}
	}
	if(cur)
		return 0;
	rep(i,n)
		(res*=(i+1))%=MOD;
	return res;
}

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n;cin>>n&&n;){
		string s; cin>>s;
		cout<<solve(n,s)<<endl;
	}
}


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

int N;
vector<double> v;

int solve();
// int buf(vector<int> vs);

int main(){
  cin >> N;
  v = vector<double>(N);
  for(int i=0; i<N; i++){
    cin >> v.at(i);
  }
  solve();
}

int solve(){
  for(int i=0; i< N-1; i++){
    // buf(v);
    sort(v.begin(), v.end());
    v.push_back((v.at(0) + v.at(1))/2.0);

    v.erase(v.begin() +0);
    if(v.size() >1){
      v.erase(v.begin() +0);
    }
  }
  // cout << v.size() <<endl;
  cout << v.at(0) << endl;
  return 0;
}
//
// int buf(vector<int> vs){
//   for(int i =0; i< vs.size(); i++){
//     cout << v.at(i)<< " ";
//   }
//   cout << endl;
//   return 0;
// }


Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#pragma GCC target("popcnt,abm,mmx,tune=native")

#include <bits/stdc++.h>

#define ll int64_t

#define fi first

#define se second

#define pb push_back

#define sqr(x) (ll)(x)*(x)

#define inf LLONG_MAX

#define mod 1000000007

using namespace std;

string s;

main()
{
    [=]()
    {
        ios_base :: sync_with_stdio(false);

        cin.tie(nullptr);
    }();

    cin >> s;

    map < string, string > a;

    a["Sunny"]="Cloudy";

    a["Cloudy"]="Rainy";

    a["Rainy"]="Sunny";

    cout << a[s];
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 100005



struct Info{
	bool operator<(const struct Info &arg) const{

		return A < arg.A;
	}
	int A,B;
};

struct Data{

	int L,R;
};

struct Edge{
	Edge(int arg_to,int arg_index){
		to = arg_to;
		index = arg_index;
	}
	int to,index;
};


int N,M;
int parent[SIZE],height[SIZE];
int diff[SIZE];
bool visited[SIZE];
Info info[SIZE];
Data data[2*SIZE];
vector<int> ANS;
vector<Edge> G[SIZE];


int getParent(int id){
	if(parent[id] == id)return id;
	else{
		return parent[id] = getParent(parent[id]);
	}
}

bool isSame(int a, int b){
	return getParent(a) == getParent(b);
}

void unite(int a,int b){
	int a_parent = getParent(a);
	int b_parent = getParent(b);

	if(a_parent == b_parent)return;	//元々同じグループ

	if(height[a_parent] > height[b_parent]){ //高い方に吸収する
		parent[b_parent] = a_parent;
	}else{
		if(height[a_parent] == height[b_parent])height[b_parent]++;
		parent[a_parent] = b_parent;
	}
}

void dfs(int node_id){

	visited[node_id] = true;

	for(int i = 0; i < G[node_id].size(); i++){

		int next = G[node_id][i].to;
		if(visited[next])continue;
		dfs(next);

		if(diff[next] == 1){

			diff[next] = 0;
			diff[node_id] = 1-diff[node_id];
			ANS.push_back(G[node_id][i].index);
		}
	}
}


int main(){

	scanf("%d %d",&N,&M);
	vector<int> V;

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

		scanf("%d %d",&info[i].A,&info[i].B);
		V.push_back(info[i].A);
	}

	info[N].A = BIG_NUM;
	info[N].B = 0;

	V.push_back(BIG_NUM);

	sort(info,info+N);
	sort(V.begin(),V.end());

	diff[0] = info[0].B;
	for(int i = 1; i <= N; i++){

		diff[i] = abs(info[i].B-info[i-1].B);
	}

	for(int i = 0; i <= N; i++){
		parent[i] = i;
		height[i] = 0;
	}

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

		scanf("%d %d",&data[i].L,&data[i].R);
		data[i].L = lower_bound(V.begin(),V.end(),data[i].L)-V.begin();
		data[i].R = lower_bound(V.begin(),V.end(),data[i].R+1)-V.begin();

		if(!isSame(data[i].L, data[i].R)){
			unite(data[i].L,data[i].R);
			G[data[i].L].push_back(Edge(data[i].R,i));
			G[data[i].R].push_back(Edge(data[i].L,i));
		}
	}

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

		visited[i] = false;
	}

	for(int i = 0; i <= N; i++){
		if(i == getParent(i)){
			dfs(i);
			if(diff[i] == 1){
				printf("-1\n");
				return 0;
			}
		}
	}

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

	printf("%lld\n",ANS.size());
	if(ANS.size() == 0){

		return 0;
	}

	printf("%d",ANS[0]+1);

	for(int i = 1; i < ANS.size(); i++){

		printf(" %d",ANS[i]+1);
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 11000
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    string s;cin >> s;
    ll n = s.size();
    ll ans = 0, cnt = 0;
    rep(i,n){
        if(s[i] == 'W'){ans += i-cnt;cnt++;}
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.*

fun <T> calcPermutationList(sortedList: Array<T>): List<List<T>> {
    val permutationList = mutableListOf<List<T>>()
    val queue = ArrayDeque<List<T>>().apply { addLast(listOf()) }
//    val queue = mutableListOf<List<T>>(listOf())
    while (queue.isNotEmpty()) {
        val p = queue.removeFirst()

        if (p.size == sortedList.size) {
            permutationList.add(p)
        } else {
            sortedList.filterNot { p.contains(it) }
                .forEach { queue.addLast(p + it) }
        }
    }

    return permutationList
}

fun main(args: Array<String>) {
    val n = readInteger()
    val p = readIntegerList()
    val q = readIntegerList()

    calcPermutationList((1..n).toList().toTypedArray())
        .let { it.indexOf(p) - it.indexOf(q) }
        .let(Math::abs)
        .let(::println)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 49744
N, M = map(int, input().split())
A = []
for _ in range(N):
    KA = list(map(int, input().split()))
    A.append(KA[1:])
ans = [0]*M
for a in A:
    for i in a:
        ans[i-1] += 1
print(ans.count(N))

Measured memory_bytes: 9164
W, H, x, y = [int(i) for i in input().split()]

square = W * H / 2

center_x = W / 2
center_y = H / 2

unique_flag = False

if center_x == x and center_y == y:
    unique_flag = True
    
if unique_flag:
    print(square, 1)
else :
    print(square, 0)
    

Measured memory_bytes: 2940
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define mp make_pair

using namespace std;

typedef long long int64;
typedef vector<int> vi;
typedef pair<int, int> ii;

class taskd {
 public:
  void solveOne(istream &in, ostream &out) {

  }

  void solve(std::istream &in, std::ostream &out) {
    int n;
    int64 m;
    in >> n;
    in >> m;
    int64 MODULO = m;
    vector<int64> invs(2 * n + 2);
    invs[1] = 1;
    for (int i = 2; i < invs.size(); ++i) {
      invs[i] = ((MODULO - (MODULO / i) * invs[MODULO % i] % MODULO) % MODULO);
    }
    vector<int64> facts(invs.size());
    vector<int64> invfacts(invs.size());
    facts[0] = 1;
    invfacts[0] = 1;
    for (int i = 1; i < facts.size(); ++i) {
      facts[i] = (facts[i - 1] * i % MODULO);
      invfacts[i] = (invfacts[i - 1] * invs[i] % MODULO);
    }
    int right = (n - 1) / 2;
    int left = right + 1;
    int middle = n - right - left;
    vector<int> delta(n + 1);
    for (int am = 0; am <= n; ++am) {
      delta[am] = max(0, am - right - middle) - min(am, right);
    }
    sort(delta.begin(), delta.end());
    reverse(delta.begin(), delta.end());
    vector<vector<int>> ways(n);
    ways[n - 1].push_back(0);
    ways[n - 1].push_back(1);
    int max = n - 1;
    for (int x : delta) {
      for (int old = ways.size() - 1; old > 0; --old) {
        int minb = std::max(0, -old * x);
        for (int oldb = minb; oldb < ways[old].size(); ++oldb) {
          int w = ways[old][oldb];
          int nv = old - 1;
          int nb = oldb + x;
          if (nb + nv * x >= 0) {
            if (ways[nv].size() <= nb)
              ways[nv].resize(nb + 1);
            ways[nv][nb] += w;
            if (ways[nv][nb] >= MODULO) {
              ways[nv][nb] -= MODULO;
            }
          }
        }
      }
      while ((n - max) + x * max < 0) --max;
      ways.resize(max + 1);
    }
    int64 res = 0;
    for (int i = 1; i < ways[0].size(); ++i) {
      res += ways[0][i];
    }
    res %= MODULO;
    out << res << endl;
  }
};


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  taskd solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 65008
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int d[3] = {-1,0,1};
int main(){
    int n,k;cin>>n>>k;
    int sum = 0;
    rep(i,n){
        int x;cin>>x;
        sum += 2*min(k-x,x);
    }
    cout<<sum;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    int n;
    cin>>n;
    int m=0;
    int INF= 1000000001;
    int ph=INF;
    int ans=0;
    rep(i,n){
        if(i==0){
            cin>>ph;
        }
        else{
            int h;
            cin>>h;
            if(ph>=h){
                m++;
            }
            else{
                if(ans<m)ans=m;
                m=0; 
            }
            ph=h; 
        }
        
    }
	if(ans<m)ans=m;
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    
    public static void main(String... args) {
        Scanner scanner = new Scanner(System.in);
        
        while (true) {
            String input = scanner.nextLine();
            
            if ("0 0".equals(input)) {
                break;
            }
            String[] numbers = input.split(" ");
            
            int h = Integer.parseInt(numbers[0]);
            int w = Integer.parseInt(numbers[1]);
            
            for (int i=0; i<h; i++) {
                for (int j=0; j<w; j++) {
                    if (j == 0 || j == w-1) {
                        System.out.print("#");
                    } else {
                        if (i == 0 || i == h-1) {
                            System.out.print("#");
                        } else {
                            System.out.print(".");
                        }
                    }
                }
                System.out.println("");
            }
            System.out.println("");
        }
    }
}


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

using namespace std;

int main()
{
	int n, m, k;
	cin >> n >> m >> k;
	
	vector<int> A(n), B(m);
	
	vector<long long> a(n + 1), b(m + 1);
	
	for(int i = 0; i < n; i++) {
		cin >> A[i];
		a[i + 1] = a[i] + A[i];
	}
	
	for(int i = 0; i < m; i++) {
		cin >> B[i];
		b[i + 1] = b[i] + B[i];
	}
	
	int books = 0, j = m;
	
	for(int i = 0; i <= n; i++) {
		if(a[i] > k) break;
		
		while(b[j] > k - a[i]) j -= 1;
		
		books = max(books, i + j);
	}
  cout << books;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << endl;
	return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main()
{
	string s;
	cin >> s;
	int n = s.size();
	bool flag1 = false;
	bool flag2 = false;
	bool flag3 = false;
	string s1 = "";
	for (int i = n - 1; 0 <= i; i--) {
		s1 += s[i];
	}
	if (s == s1) flag1 = true;


	string s2 = "";
	for (int i = 0; i < (n - 1) / 2; i++) {
		s2 += s[i];
	}
	string s2_reverse = "";
	for (int i = (n - 1) / 2 - 1; 0 <= i; i--) {
		s2_reverse += s[i];
	}
	if (s2 == s2_reverse) flag2 = true;

	string s3 = "";
	for (int i = (n + 3) / 2 - 1; i < n; i++) {
		s3 += s[i];
	}
	string s3_reverse = "";
	for (int i = n - 1; (n + 3) / 2 - 1 <= i; i--) {
		s3_reverse += s[i];
	}
	if (s3 == s3_reverse) flag3 = true;

	if (flag1 && flag2 && flag3) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
typedef long long ll;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
    int n;
    vector<ll> a;
    cin >> n;
    rep(i, n){
        int t; cin >> t; a.push_back(t);
    }

    mint csum(0);
    mint mut(1);
    rep(i, n){
        csum += (mint)1 / (mint)(i+1);
        mut *= i + 1;
    }

    mint ans(0);
    rep(i, n){
        mint part(0);
        if (i != 0){
            csum += (mint)1 / (mint)(i + 1);
            csum -= (mint)1 / (mint)(n - (i - 1));
        }
        part = csum * a[i];
        part *= mut;
        //cout << i << " "<< csum.x << " "<< part.x << endl;
        ans += part;
    }
    //ans *= mut;

    cout << ans.x << endl;
}

Measured memory_bytes: 1400
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  ll a,b;
  cin >> a >> b;
  cout << a*b - a-b+1<<endl;
}


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

inline int read() {
	int x = 0, f = 1; char ch = getchar();
	while(ch > '9' || ch < '0') { if(ch == '-') f = -1; ch = getchar(); }
	do x = x * 10 + ch - 48, ch = getchar(); while(ch >= '0' && ch <= '9');
	return x * f;
}

int b[200001];

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


Measured memory_bytes: 4540
t=input()
for i in range(t):
    up,dw=0,0
    n=input()
    b=map(int,raw_input().split())
    for j in range(n-1):
        if   b[j]<b[j+1]: up=max(up,b[j+1]-b[j])
        elif b[j]>b[j+1]: dw=max(dw,b[j]-b[j+1])
    print up,dw

Measured memory_bytes: 4244
#1-5-A
n=int(input())
a=list(map(int,input().split()) )
q=int(input())
m=list(map(int,input().split()) )

s=[0]
for i in a:
    s.extend([i+j for j in s])
for i in m:
    if i in s:
        print("yes")
    else:
        print("no")


Measured memory_bytes: 51452
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()

    return

#B
def B():
    n = I()

    return

#C
def C():
    n = I()

    return

#D
def D():
    n = I()

    return
#E
def E():
    n = I()
    a = LI()
    ans = 0
    s = 1
    while s:
        b = [a[i]//n for i in range(n)]
        s = sum(b)
        a = [(a[i]%n+s-b[i]) for i in range(n)]
        ans += s
        
    print(ans)
    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    E()


Measured memory_bytes: 40816
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;

public class Main
{
  public static long d[] = new long[123456];
  public static HashMap<Integer, ArrayList<Integer>> h = new HashMap<>();
  public static HashMap<Integer, ArrayList<Long>> hd = new HashMap<>();

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

    int n = Integer.parseInt(r.readLine());


    for(int i = 0; i <= n; i++)
    {
      h.put(i, new ArrayList<Integer>());
      hd.put(i, new ArrayList<Long>());
    }

    for(int i = 0; i < n - 1; i++)
    {
      String s = r.readLine();
      String sl[] = s.split(" ");
      int a = Integer.parseInt(sl[0]);
      int b = Integer.parseInt(sl[1]);
      long c = Long.parseLong(sl[2]);

      h.get(a).add(b);
      h.get(b).add(a);
      hd.get(a).add(c);
      hd.get(b).add(c);
    }

    String s = r.readLine();
    String sl[] = s.split(" ");
    int q = Integer.parseInt(sl[0]);
    int k = Integer.parseInt(sl[1]);

    search(k, 999999, 0);
    
    for(int i = 0; i < q; i++)
    {
      s = r.readLine();
      sl = s.split(" ");
      int x = Integer.parseInt(sl[0]);
      int y = Integer.parseInt(sl[1]);
      System.out.println(d[x] + d[y]);
    }

  }

  public static void search(int src, int proh, long offset)
  {
    ArrayList<Integer> a = h.get(src);
    ArrayList<Long> ad = hd.get(src);
    d[src] = offset;
    int an = a.size();
    for(int i = 0; i < an; i++)
    {
      int z = a.get(i);
      if(z == proh)
      {
        continue;
      }
      long v = ad.get(i);
      search(z, src, offset + v);
    }
  }

}

Measured memory_bytes: 174440
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    int a[n],b[n];
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    sort(a,a+n);
    sort(b,b+n);
    if(n%2==1){
        cout << b[n/2] - a[n/2] + 1<< endl;
    }else{
        int l = a[n/2-1] + a[n/2];
        int u = b[n/2-1] + b[n/2];
        cout << u - l + 1 << endl;
    }
}

Measured memory_bytes: 5160
#include <bits/stdc++.h>
        using namespace std;
        #define ll long long int
        #define pb push_back
        #define mk make_pair
        #define ft first
        #define sc second
        #define ppb pop_back
        #define sz size
        #define forn(i,a,n) for(i=a;i<n;i++)
        #define M 998244353 
        #define inf 2e18

        bool check(ll n,ll k){
            while(n%k==0){
                n=n/k;
            }
            return n%k==1;
        }
        
        int main() {
 
     
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        
        ll n;
        cin>>n;
        ll x=n-1;
        set<ll> s;
        for(ll i=2;i*i<=x;i++){
            if(x%i==0){
                s.insert(i); 
                s.insert(x/i);
            }
        }
        s.insert(x);
        for(ll i=2;i*i<=n;i++){
            if(check(n,i)){
                s.insert(i);
            }
            if(check(n,n/i)){
                s.insert(n/i);
            }
        }
        s.insert(n);
        s.erase(1);
        // for(auto i:s)cout<<i<<" ";
        cout<<s.size(); 


        return 0;
    }

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

aset = set(a)
if 1 not in aset:
    print(-1)
else:
    nex = 1
    counter = 0
    for i in range(N):
        if a[i] == nex:
            nex += 1
        else:
            counter += 1
    print(counter)

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

#define int long long

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

int A, B, C, X;

signed main() {
    cin >> A >> B >> C >> X;
    int ans = 0;
    for (int i = 0; i <= A; i++) {
        for (int j = 0; j <= B; j++) {
            for (int k = 0; k <= C; k++) {
                if (500 * i + 100 * j + 50 * k == X) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define int long long 

using namespace std;

void solve()
{
	int n,sum=0,temp;
	cin>>n;
	std::vector<int> v(n);
	for(int i=0;i<n;i++)
		cin >>v[i];
	for(int i =1;i<n;++i){
		if(v[i]<v[i-1]){
			sum+=v[i-1]-v[i];
			v[i]=v[i-1];
		}
	}
	cout << sum << endl;
}


int32_t main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	
	//int t;cin >> t;while(t--)
		solve();

	return 0;
}

Measured memory_bytes: 4840
/*{{{*/
#define HOME
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define F first
#define S second

template<class T> void _R(T &_x) { cin >> _x; }
void _R(int &_x) { scanf("%d", &_x); }
void _R(int64_t &_x) { scanf("%" SCNd64, &_x); }
void _R(double &_x) { scanf("%lf", &_x); }
void _R(char &_x) { scanf(" %c", &_x); }
void _R(char *_x) { scanf("%s", _x); }
template<class T, class U> void _R(pair<T, U> &_x) {_R(_x.F); _R(_x.S);}
void R() {}
template<class T, class... U> void R(T &_head, U &... _tail) { _R(_head); R(_tail...); }

template<class T> void _W(const T &_x) { cout << _x; }
void _W(const int &_x) { printf("%d", _x); }
void _W(const int64_t &_x) { printf("%" PRId64, _x); }
void _W(const double &_x) { printf("%.16f", _x); }
void _W(const char &_x) { putchar(_x); }
void _W(const char *_x) { printf("%s", _x); }
template<class T, class U> void _W(const pair<T, U> &_x) {_W(_x.F); putchar(' '); _W(_x.S);}
template<class T> void _W(const vector<T> &_x) { for (auto i = _x.begin(); i != _x.end(); _W(*i++)) if (i != _x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &_head, const U &... _tail) { _W(_head); putchar(sizeof...(_tail) ? ' ' : '\n'); W(_tail...); }

template<class T, class... U> void DB(const T &_head, const U &... _tail) {
#ifdef HOME
    W('#', _head, _tail...);
#endif
}

#define SZ(x) int((x).size())
#define ALL(x) (x).begin(), (x).end()
#define RAN(x,n) (x).begin(), (x).begin()+(n)
#define UNIQUE(x) {sort(ALL(x)); (x).erase(unique(ALL(x)), (x).end());}

#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
//#define ITER(i,t) for (auto i = t.begin(); i != t.end(); ++i)
#define IT3(i,st,ed) for (auto i = (st); i != (ed); ++i)
#define IT2(i,range) IT3(i,range)

#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define MS(X, v) memset((X), (v), sizeof((X)))

template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

typedef int64_t ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

inline int LG (const unsigned int &_x) { return 31-__builtin_clz(_x); } // floor: LG(x), ceil: LG(x-1)+1
/*}}}*/

int n;
vi a, b, d;

int main(){
	R(n);
	a = b = d = vi(n);
	FOR(i, n) R(a[i]);
	FOR(i, n) R(b[i]);

	FOR(i, n) d[i] = b[i]-a[i];
	sort(ALL(d));

	ll s = 0;
    int p = n-1, i = 0;
    for(; i<n && p>=0; ++i){
        if(d[i] >= 0 || d[p] < 2) break;
        while(d[i] < 0){
			if(d[p] < 2) break;
			int t = min(d[p]/2, -d[i]);
			d[p] -= 2*t, d[i] += t;
			if(d[p] < 2) --p;
			//DB(d);
        }
        if(d[i] < 0) break;
    }
    if(i<n && d[i]>=0) W("Yes");
    else W("No");

    return 0;
}


Measured memory_bytes: 384
n = int(input())
fl = []
for _ in range(n):
   f = list(map(int,input().split()))
   fl.append(f)
pl = []
for _ in range(n):
   p = list(map(int,input().split()))
   pl.append(p)

ans = -float("inf")
n = 10  # すき間の個数
for i in range(2 ** n):
   if i == 0:
      continue
   bit = [0] * n
   for j in range(n):
       if ((i >> j) & 1):
           bit[j] = 1
   tmp = 0
   for idx,f in enumerate(fl):
      point = 0
      for j in range(n):
         if f[j] == 1 and bit[j] == 1:
            point += 1
      tmp += pl[idx][point] 
   ans = max(ans, tmp)
print(ans)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;

int D, E;

signed main()
{
    while (true) {
        cin >> D >> E;
        if (D == 0 && E == 0) break;

        double minSa = 1e15;
        for (int x=0; x<=D; x++) {
            int y = D - x;
            minSa = min(minSa, abs(sqrt(x*x + y*y) - E));
        }

        printf("%.10lf\n", minSa);
    }
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define mod 1000000007
#define pb emplace_back
#define mp make_pair
#define fi first
#define sec second
typedef long long ll;
typedef long double  ld;
#define pii pair<ll,ll> 
#define vi vector< ll > 
#define vvi vector< vi > 
#define vpi vector< pii > 
#define vvpi vector< vpi > 
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define test(t) ll t;cin>>t;while(t--)
#define mem(a,b) memset(a,b,sizeof(a))
#define inn freopen("input.txt", "r", stdin)
#define outt freopen("output.txt", "w", stdout)
#define all(arr) arr.begin(),arr.end()
#define fr(i,n) for(ll i=0;i<(n);++i)
#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b)))
#ifndef ONLINE_JUDGE
#define debarr(a,n)cerr<<#a<<":";for(int i=0;i<n;i++)cerr<<a[i]<<" ";cerr<<endl;
#define debmat(mat,row,col)cerr<<#mat<<":\n";for(int i=0;i<row;i++){for(int j=0;j<col;j++)cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...)dbs(#__VA_ARGS__,__VA_ARGS__)
template<class S,class T>ostream &operator<<(ostream &os,const pair<S,T> &p){return os<<"("<<p.first<<","<<p.second<<")";}
template<class T>ostream &operator<<(ostream &os,const vector<T> &p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const set<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const multiset<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class S,class T>ostream &operator<<(ostream &os,const map<S,T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>void dbs(string str,T t){cerr<<str<<":"<<t<<"\n";}
template<class T,class...S>void dbs(string str,T t,S... s){int idx=str.find(',');cerr<<str.substr(0,idx)<<":"<<t<<",";dbs(str.substr(idx+1),s...);}
#else
#define pr(...){}
#define debarr(a,n){}
#define debmat(mat,row,col){}
#endif
ll power(ll x,ll y){ll res = 1;while(y){if(y&1) res = (res*x)%mod;y=y/2,x=(x*x)%mod;}return res%mod;}
signed main()
{
    fast;
    ll n;
    cin>>n;
    ll arr[n][n];
    ll dp[1<<n];
    fr(i,n)fr(j,n)cin>>arr[i][j];
    fr(i,1<<n){
      vi temp;
      fr(j,n){
        if(i&(1<<j))
          temp.pb(j);
      }
      dp[i]=0;
      for(auto v:temp)for(auto u:temp)dp[i]+=arr[u][v];
        dp[i]/=2;
    }
    rep(i,1,(1<<n)-1){
      for(ll j=i;j>0;j=i&(j-1)){
        dp[i]=max(dp[i],dp[i^j]+dp[j]);
      }
    }
    cout<<dp[(1<<n)-1];
    
}


Measured memory_bytes: 768
#include <stdio.h>

void swap(int *i, int *j)
{
	*i += *j;
	*j = *i - *j;
	*i -= *j;
}

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

int main(void)
{
	int a, b;
	long int lcd, gcd; /*gcd = 最大公約数、lcd = 最小公倍数*/
	
	while (scanf("%d %d", &a, &b) != EOF){
		if (a < b){
			swap(&a, &b);
		}
		gcd = search(a, b);
		lcd = a / gcd * b;
		
		printf("%d %d\n", gcd, lcd);
	}
	
	return (0);
}

Measured memory_bytes: 596
a=input()
if a=="a":
  print("b")
if a=="b":
  print("c")
if a=="c":
  print("d")
if a=="d":
  print("e")
if a=="e":
  print("f")
if a=="f":
  print("g")
if a=="g":
  print("h")
if a=="h":
  print("i")
if a=="i":
  print("j")
if a=="j":
  print("k")
if a=="k":
  print("l")
if a=="l":
  print("m")
if a=="m":
  print("n")
if a=="n":
  print("o")
if a=="o":
  print("p")
if a=="p":
  print("q")
if a=="q":
  print("r")
if a=="r":
  print("s")
if a=="s":
  print("t")
if a=="t":
  print("u")
if a=="u":
  print("v")
if a=="v":
  print("w")
if a=="w":
  print("x")
if a=="x":
  print("y")
if a=="y":
  print("z")

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
long long sum[200005];
int main()
{
    long long mod=1000000007;
    long long n;cin>>n;long long a[n];long long sum=0;
    for(long long i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
        sum=sum%mod;

    }

    long long pum=sum;long long rum=0;
    for(long long i=0;i<n-1;i++)
    {
        //cout<<sum[n-1]<<" "<<sum[i]<<" "<<a[i]<<endl;

       pum=pum-a[i];
       if(pum<0)
        pum+=mod;
       rum+=(a[i]*pum);
       rum=rum%mod;

    }
    cout<<rum;

}


Measured memory_bytes: 5128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MAX = 1e5;
main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N; int a[N];
    vector<ll> cnt(MAX+1, 0);
    ll sum = 0;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        cnt[a[i]]++;
        sum += a[i];
    }
    int Q; cin >> Q;
    while(Q--){
        ll b, c; cin >> b >> c;
        if(cnt[b]){
            sum -= cnt[b]*b;
            sum += cnt[b]*c;
            cnt[c] += cnt[b];
            cnt[b] = 0;
        }
        cout << sum << "\n";
    }
}


Measured memory_bytes: 4500
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#define DEBUG(x) std::cout << '>' << #x << ':' << x << '\n';
#define PRINTVEC(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i] << ' '; std::cout << '\n';
#define PRINTPAIR(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i].first << ' ' << x[i].second << '\n'; std::cout << '\n';
#define PRINTSET(x) for (auto it = x.begin(); it != x.end(); it++) { std::cout << *it << ' '; } std::cout << '\n';
#define io std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);   
const int INF = 1<<29;
typedef long long ll;
using namespace std;


int main()
{
	io;
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);  
    #endif

    int n = 5;
    vector<int> v(n);
    for (int &it : v) cin >> it;
    for (int i = 0; i < n; ++i) {
        if (v[i] == 0) cout << i+1 << endl;
    }   

    #ifndef ONLINE_JUDGE   
    //std::cout << '\n' << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    #endif
    return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>

using namespace std;
string st,st1,st2;
long long p,pp,ppp;
int main()
{
	cin>>st>>st1;
	ppp=st1.size();
	pp=st.size();
	p=max(st.size(),st1.size());
	for(int i=0;i<p;i++)
	{
		if(i<pp)
		st2+=st[i];
		if(i<ppp)
		st2+=st1[i];
	}
	cout<<st2<<endl;
	return 0;
}

Measured memory_bytes: 256
import kotlin.math.*

fun main() {
    val N = readLine()!!.toInt()
    val x = readLine()!!.split(" ").map { it.toInt() }
    var ans=0
    for (i in 0..N-1 step 2){
        if(x[i]%2 == 1){
            ans++
        }
    }
    print(ans)
}

Measured memory_bytes: 36800