akhauriyash/Code-Regression huggingface dataset:
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

ll binPowMod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1LL) res = res * a % m;
        a = a * a % m;
        b >>= 1LL;
    }
    return res;
}

ll inv(ll u) {
    return binPowMod(u, MODBASE-2, MODBASE);
}

ll add(ll a, ll b) {
    return (a + b) % MODBASE;
}

ll mul(ll a, ll b) {
    return a * b % MODBASE;
}

ll sub(ll a, ll b) {
    return (a - b + MODBASE) % MODBASE;
}

int n, s[MAXN];
ll res[MAXN], allWhite[MAXN];
vector<int> a[MAXN];

void dfs(int u, int p) {
    s[u] = 1;
    FOR(i,0,SZ(a[u])-1) {
        int v = a[u][i];
        if (v == p) continue;
        dfs(v, u);
        s[u] += s[v];
    }
    if (SZ(a[u]) == 1) return;
    ll inv2 = inv(2);
    res[u] = inv2;
    ll prod = inv2;
    FOR(i,0,SZ(a[u])-1) {
        int v = a[u][i];
        int sz = (v == p) ? (n - s[u]) : s[v];
        allWhite[v] = binPowMod(inv2, sz, MODBASE);
        prod = mul(prod, allWhite[v]);
    }
    res[u] = sub(res[u], prod);
    FOR(i,0,SZ(a[u])-1) {
        int v = a[u][i];
        ll e = mul(prod, inv(allWhite[v]));
        e = mul(e, sub(1, allWhite[v])); // have black
        res[u] = sub(res[u], e);
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n-1) {
        int u, v;
        cin >> u >> v;
        a[u].emplace_back(v);
        a[v].emplace_back(u);
    }
    dfs(1, 0);
    ll kq = 0;
    FOR(i,1,n) kq = add(kq, res[i]);
    cout << kq;
    return 0;
}


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

using namespace std;

const int MAXN = 55;
const int INF = 1 << 30;

typedef long long ll;

vector<int> G[MAXN];

ll m[MAXN], val[MAXN], f[MAXN * MAXN * MAXN];

ll n, p, X, D, ans = 0;

struct State
{
	ll x, y, z;
};

State operator *(const State &a, ll x)
{
	return (State){a.x * x, a.y * x, 0};
}

State operator +(const State &a, const State &b)
{
	return (State){a.x + b.x, a.y + b.y, 0};	
}

bool operator <(const State &a, const State &b)
{
	return (a.y * b.x > a.x * b.y);
}

vector<State> d, d2;

void dfs(int u, int p = 0)
{
	val[u] = 1;
	for (auto v : G[u])
	{
		dfs(v, u);
		m[u] += m[v], val[u] += val[v];
	}
	d.push_back((State){m[u], val[u], (u != 1 ? min(D, X / m[u]) : X / m[u])});
}

inline void dmin(ll &x, ll y)
{
	if (x == -1 || x > y)
		x = y;
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n >> X >> D;
	cin >> m[1];
	for (int i = 2; i <= n; i++)
	{
		cin >> m[i] >> p;	
		G[p].emplace_back(i);
	}
	dfs(1);
	sort(d.begin(), d.end());
	int Y = 0;
	for (auto &x : d)
	{
		ll z = min(50ll, x.z);
		x.z -= z;
		Y += z * x.y;
		State cur = (State){x.x, x.y, 0};
		for (int i = 1; i <= z; z -= i, i <<= 1, cur = cur * 2)
			d2.push_back(cur);
		if (z != 0)
			d2.push_back((State){x.x, x.y, 0} * z);
	}
	memset(f, -1, sizeof(f));
	f[0] = 0;
	for (int i = 0; i < d2.size(); i++)
		for (int j = Y; j >= d2[i].y; j--)
			if (f[j - d2[i].y] != -1)
				dmin(f[j], f[j - d2[i].y] + d2[i].x);
	for (int i = 0; i <= Y; i++)
	{
		if (f[i] != -1 && f[i] <= X)
		{
			ll cur = X - f[i], res = i;
			for (int j = 0; j < n; j++)
			{
				ll z = min(d[j].z, cur / d[j].x);
				res += d[j].y * z;
				cur -= d[j].x * z;
			}
			if (res > ans)
				ans = res;
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  ll n, x;
  cin >> n >> x;
  vector<ll> s(n + 1), p(n + 1);
  s[0] = p[0] = 1;
  for (int i = 1; i <= n; i++) {
    s[i] = 2 * s[i - 1] + 3;
    p[i] = 2 * p[i - 1] + 1;
  }
  ll r = 0;
  while (x > 0) {
    if (x >= s[n]) {
      r += p[n];
      x -= s[n];
      if (x > 0) {
        r++;
        x--;
      }
    } else if (x < s[n]) {
      n--;
      x--;
    }
  }
  cout << r << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <cstdlib> 
#include <string.h>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <ctime>
#include <algorithm>
#include <cmath>
#define PI 3.1415926535897932384626433832795l
#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define deci(n) cout<<fixed<<setprecision(n);
#define F first
#define S second
#define mk make_pair
#define pb push_back
#define ALPHA 27
#define ll long long int
#define ld long double
#define mmset(arr, n) memset(arr, n, sizeof arr)
#define debug(x) cerr << '#' << ' ' << x << '\n'
#define len(s) s.length()
#define ForA(i,a,b) for(int i = a; i < b; i++)
#define ForA1(i,a,b) for(int i = b - 1; i >= a; i--)
#define ForB1(i,a,b) for(int i = b; i > a; i--)
#define ForB(i,a,b) for(int i = a; i <= b; i++)
#define INT_SIZE 18 
#define maxn 3010
#define Maxn 100010

using namespace std;

const ll INF = (ll)(8e18);
const ll MOD = 1000000007;

ll dp[maxn][maxn];

int main()
{
    IOS;      
    string s,t; cin >> s >> t;
    ForB(i,1,len(s)){
        ForB(j,1,len(t)){
            if(s[i - 1] == t[j - 1]) dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
            else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    string ans = "";
    ll l = len(s), r = len(t);
    while((l > 0 && r > 0) && (dp[len(s)][len(t)] > 0)){
        if(s[l - 1] == t[r - 1]){
            ans += s[l - 1];
            l--;
            r--;
        }else if(dp[l - 1][r] > dp[l][r - 1]) l--;
        else r--;  
    }
    reverse(ans.begin(), ans.end());
    cout << ans << '\n';
    #ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0 ;
}


Measured memory_bytes: 70784
#include <stdio.h>
#include <stdint.h>

#define STR_MAX    (100000)

#define FAST_TRIAL  (1)

int main(void)
{
    uint64_t n;
    uint64_t k;
    char s[STR_MAX+1];

    scanf("%ld %ld", &n, &k);
    scanf("%s", s);

    uint64_t ptr = 0;
    char curC;
    char nxtC;

    uint64_t serialNum[STR_MAX+2];
    uint64_t indx   = 0;
    uint64_t head1  = 0;
    uint64_t max    = 0;
    uint64_t cntK   = 0;
    uint64_t curSum = 0;

    curC = s[ptr++];
    /* serialNumは 1 の数 -> 0の数としたいので0ならindxを送る */
    if ( curC == '0' ) {
        indx++;
    }

#ifdef FAST_TRIAL

#endif

    while ( curC != '\0' ) {
        /* nxtCを得る */
        nxtC = s[ptr++];

        serialNum[indx]++;

        uint64_t dbgIndx = indx;

        /* どうやら次は別の文字のようだ */
        if ( curC !=  nxtC ) {
            curSum += serialNum[indx++];

            /* 0の連続が終わったときは昔の0を捨てる場合がある */
            if ( curC == '0' ) {
                /* 逆立ちできる人たちが増える */
                cntK++;

                /* 逆立ちできる人たちがK人より多いとき */
                if ( cntK > k ) {
                    /* 
                     * 1Grp -> 0Grp -> 1Grp -> 0Grp ... 1Grp -> NEW 0Grp
                     * となるので先頭の0Grpと1Grp分を引いて, 0Grpのheadを移動させる
                     */
                    curSum -= (serialNum[head1] + serialNum[head1+1]);
                    head1 += 2;
                }
            }

            /* ここまでで今回のserialNumによるcurSumが決定するので最大値更新 */
            max = ( curSum >= max ) ? curSum : max;
        }

//        printf("%c : cntK=%ld, curSum=%ld, serialNum=%ld, head1=%ld, max=%ld\n", curC, cntK, curSum, serialNum[dbgIndx], head1, max);

        curC = nxtC;
    }

    printf("%ld\n", max);

    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define FLOOR(x) ((int)floor(((double)x)))
#define CEIL(x) ((int)ceil(((double)x)))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


int N, M;
PII ab[100010];


int solve(){
	int ans = 1;
	int x = ab[0].se;
	rep(i, 1, M){
		int a = ab[i].fi;
		int b = ab[i].se;
		if(a < x && x <= b) continue;
		x = ab[i].se;
		ans++;
	}
	return ans;
}


signed main(){
	cin >> N >> M;
	rep(i, 0, M) cin >> ab[i].fi >> ab[i].se;

	sort(RNG(ab, M), [](PII p1, PII p2){ return p1.se < p2.se;  });

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String str = sc.next();

        String s1 = str.substring(0, 2);
        String s2 = str.substring(2, 4);

        int s1i = Integer.valueOf(s1);
        int s2i = Integer.valueOf(s2);

        boolean s1IsM = 0 < s1i && s1i < 13;
        boolean s2IsM = 0 < s2i && s2i < 13;

        String result;

        if (s1IsM && s2IsM) {
            result = "AMBIGUOUS";
        } else if (!s1IsM && s2IsM) {
            result = "YYMM";
        } else if (s1IsM) {
            result = "MMYY";
        } else {
            result = "NA";
        }

        System.out.println(result);
    }

}

Measured memory_bytes: 21716
#include<stdio.h>
#include<queue>
struct S{int x,y,n;S(int x,int y,int n):x(x),y(y),n(n){}};
int dx[]={1,1,0,0,-1,-1},
	dy[]={1,0,1,-1,0,-1};
int main()
{
	int x,y,n,t,r,i;
	while(scanf("%d%d",&t,&n),t)
	{
		int	m[136][136]={0};
		while(n--)
			scanf("%d%d",&x,&y),m[y+70][x+70]=1;
		scanf("%d%d",&x,&y);
		std::queue<S>q;
		q.push(S(x+70,y+70,r=0));
		while(!q.empty())
		{
			S s(q.front());q.pop();
			if(s.n>t||m[s.y][s.x]++)continue;
			++r;
			for(i=0;i<6;++i)q.push(S(s.x+dx[i],s.y+dy[i],s.n+1));
		}
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 0
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use proconio::fastout;
use proconio::input;
use proconio::marker::Chars;
//use proconio::marker::Usize1;
//use std::collections::HashSet;
// use std::cmp::*;
//use std::collections::VecDeque;

fn main() {
    input! {
       N:usize,A:usize,B:usize,S:Chars
    }
    let mut a = 0;
    let mut b = 0;
    for i in 0..N {
        match S[i] {
            'a' => {
                if a + b < A + B {
                    a += 1;
                    println!("Yes");
                } else {
                    println! {"No"};
                }
            }
            'b' => {
                if a + b < A + B && b < B {
                    b += 1;
                    println!("Yes")
                } else {
                    println! {"No"};
                }
            }
            'c' => {
                println! {"No"};
            }
            _ => (),
        }
    }
}


Measured memory_bytes: 2516
fun main(args: Array<String>) {
    val a = readLine()!!.toInt()
    val n = readLine()!!.split(" ").map(String::toInt).sortedDescending()
    var alice = 0
    var bob = 0
    for(i in 0 until a){
        if(i % 2 == 0){
            alice += n[i]
        }else{
            bob += n[i]
        }
    }
    println(alice - bob)
}


Measured memory_bytes: 37868
#include<iostream>
#include<string>
using namespace std;
int main(){
   string s;
   cin>>s;
   long int ans=0;
   long int num=0;
   for(int i=0;i<s.size();i++){
      if(s[i]=='W'){
         ans+=i-num;
         num++;
      }
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 644
#include<stdio.h>
#include<string>
#include<new>
using namespace std;

struct Node {
	int parent = -1, child[2];
};

void Preorder(Node*, int);
void Inorder(Node*, int);
void Postorder(Node*, int);

int main()
{
	int n, id, l, r;
	scanf("%d", &n);
	Node *nodes;
	nodes = new Node[n];
	for (int i = 0; i < n; i++)
	{
		scanf("%d%d%d", &id, &l, &r);
		nodes[id].child[0] = l;
		nodes[id].child[1] = r;
		nodes[l].parent = nodes[r].parent = id;
	}
	for (int i = 0; i < n; i++)
	{
		if (nodes[i].parent == -1)
		{
			printf("Preorder\n");
			Preorder(nodes, i);
			printf("\nInorder\n");
			Inorder(nodes, i);
			printf("\nPostorder\n");
			Postorder(nodes, i);
			printf("\n");
			break;
		}
	}

	delete[] nodes;
	return 0;
}

void Preorder(Node* nodes, int num)
{
	printf(" %d", num);
	for (int i = 0; i < 2; i++)
		if (nodes[num].child[i] != -1)
			Preorder(nodes, nodes[num].child[i]);
	return;
}

void Inorder(Node* nodes, int num)
{
	if (nodes[num].child[0] != -1)
		Inorder(nodes, nodes[num].child[0]);
	printf(" %d", num);
	if (nodes[num].child[1] != -1)
		Inorder(nodes, nodes[num].child[1]);
	return;
}

void Postorder(Node* nodes, int num)
{
	for (int i = 0; i < 2; i++)
		if (nodes[num].child[i] != -1)
			Postorder(nodes, nodes[num].child[i]);
	printf(" %d", num);
	return;
}


Measured memory_bytes: 2680
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

template<typename T>
void cout_vec(vector<T> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}

int main(){
    int N, K;
    cin >> N >> K;
    vector<ll> pos(1,0);
    vector<ll> neg(1,0);

    for(int i=0; i<N; i++){
        ll x;
        cin >> x;
        if(x>0){
            pos.push_back(x);
        }else if(x==0){
            K--;
        }else{
            neg.push_back(-x);
        }
    }
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());

    ll ans=MOD;
    for(int i=0; i<=K; i++){
        if(i<(int)pos.size() && K-i<(int)neg.size()){
            ans=min(ans,pos[i]*2+neg[K-i]);
        }
        if(i<(int)neg.size() && K-i<(int)pos.size()){
            ans=min(ans,neg[i]*2+pos[K-i]);
        }
    }
    //cout_vec(pos);
    //cout_vec(neg);
    cout << ans << endl;
}

Measured memory_bytes: 1656
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,p,j;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&e);
	if(a<=b && a<=c){
		p= a;
	} else if(b<=a && b<=c){
		p= b;
	}
	else{
		p= c;
	}
	if(d<e){
		j= d;
	}
	else{
		j= e;
	}
		printf("%d\n",p+j-50);
	return 0;
}



Measured memory_bytes: 2056
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i=0; i<N; i++){
    cin >> A[i];
  }
  int ma = A[0];
  long long sum = 0;
  for (int i=0; i<N; i++){
    ma = max(ma,A[i]);
    long long sub = ma - A[i];
    sum += sub;
  }
  cout << sum << endl;
}
   

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int x, y;
    cin >> x >> y;

    int xa, ya;
    if(x==2) xa = 3;
    else if(x==4||x==6||x==9||x==11) xa = 2;
    else xa = 1;
    if(y==2) ya = 3;
    else if(y==4||y==6||y==9||y==11) ya = 2;
    else ya = 1;

    if(xa==ya) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3604
// by https://atcoder.jp/contests/abc070/tasks/abc070_c
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var head = nextLine()
	var N, _ = strconv.Atoi(head)

	var A []int

	for i := 1; i <= N; i++ {
		var a = nextLine()
		var aa, _ = strconv.Atoi(a)
		A = append(A, aa)
	}
	x3 := MaxIntSlice(A)
	// fmt.Println("maxplace:" + strconv.Itoa(x3))

	x1 := maxInt(A)
	// fmt.Println("max:" + strconv.Itoa(x1))

	x2 := secondmaxInt(A)
	// fmt.Println("second:" + strconv.Itoa(x2))

	if x1 == x2 {
		for i := 0; i < N; i++ {
			fmt.Println(x1)
		}
	} else {
		for i := 0; i < x3; i++ {
			fmt.Println(x1)
		}
		fmt.Println(x2)
		for i := 0; i < N-x3-1; i++ {
			fmt.Println(x1)
		}
	}
}

func delete(s []int, i int) []int {
	x := append(s[:i], s[i+1:]...)
	return x
}

func maxInt(a []int) int {
	sort.Sort(sort.IntSlice(a))
	return a[len(a)-1]
}

func secondmaxInt(a []int) int {
	sort.Sort(sort.IntSlice(a))
	return a[len(a)-2]
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

// MinIntSlice is
func MaxIntSlice(v []int) (y int) {
	var m int
	// var y int
	if len(v) > 0 {
		m = v[0]
	}

	for i := 0; i < len(v); i++ {
		if v[i] > m {
			m = v[i]
			y = i
			// fmt.Println("y:" + strconv.Itoa(y))
			// fmt.Println("v[i]:" + strconv.Itoa(v[i]))
		}
	}
	// fmt.Println("m:" + strconv.Itoa(m))

	return
}


Measured memory_bytes: 8832
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int n, m, q;
int a[150], b[150], c[150], d[150];
int ans = 0;

void dfs(int it, vi cur, int lft){
	if(it == n){
		//check the score
		int sc = 0;
		rep(i, q){
			//check the score
			int sm = 0;
			repn(j, a[i] - 1, b[i] - 1) sm += cur[j];
			if(sm == c[i]) sc += d[i];
		}
		ans = max(ans, sc);
		return;
	}
	//put here the difference
	rep(i, lft + 1){
		vi cur1 = cur;
		cur1.pb(i);
		dfs(it + 1, cur1, lft - i);
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	cin >> n >> m >> q;
	rep(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];
	vi emp;
	dfs(0, emp, m - 1);
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3652
#include <iostream>
#define llint long long

using namespace std;

llint n;
llint a[3005];
llint memo[3005][3005][2];

llint calc(llint l, llint r, llint t)
{
	if(l > r) return 0;
	if(memo[l][r][t] != -1) return memo[l][r][t];
	
	if(t == 1){
		return memo[l][r][t] = max(calc(l+1, r, 0)+a[l], calc(l, r-1, 0)+a[r]);
	}
	else{
		return memo[l][r][t] = min(calc(l+1, r, 1)-a[l], calc(l, r-1, 1)-a[r]);
	}
}


int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			memo[i][j][0] = memo[i][j][1] = -1;
		}
	}
	
	cout << calc(1, n, 1) << endl;
	return 0;
}

Measured memory_bytes: 141312
#include <iostream>

using namespace std;

int m[51][51];
int w, h;
const int dx[] = {-1, 0, 1, -1, 1, -1, 0, 1};
const int dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};

void dfs(int x, int y)
{
    m[x][y] = 0;
    for (int i = 0; i < 8; i++) {
        int nx = x + dx[i];
        int ny = y + dy[i];
        
        if (nx < 0 || ny < 0 || nx >= h || ny >= w)
            continue;
        else if (m[nx][ny] == 1)
            dfs(nx, ny);
    }
}

int main()
{
    while (cin >> w >> h, w || h) {
        int isl = 0;

        for (int i = 0; i < h; i++)
            for (int j = 0; j < w; j++)
                cin >> m[i][j];

        for (int i = 0; i < h; i++) 
            for (int j = 0; j < w; j++)
                if (m[i][j] == 1) {
                    dfs(i, j);
                    isl++;
                }

        cout << isl << endl;
    }

    return 0;
}

Measured memory_bytes: 1240
n,m = gets.split.map &:to_i
ss = []

m.times{
	s,c = gets.split.map &:to_i
	if ss[s] == nil || ss[s] == c then
		ss[s] = c
	else
		puts '-1'
		exit
	end
}

if n != 1 && ss[1] == 0 then
	puts '-1'
else
	result = ''
	(1..n).each{ |i|
		if ss[i] == nil then
			if i == 1 && n != 1 then
				result += '1'
			else
				result += '0'
			end
		else
			result += ss[i].to_s
		end
	}
	puts result
end


Measured memory_bytes: 1788
#include<iostream>
#include <string>
using namespace std;
int a,ans[46];
int main(){
	cin>>a;
	ans[0]=1,ans[1]=2;
	for(int i=0;i<a;i++){
	ans[i+2]=ans[i+1]+ans[i];}
	cout<<ans[a-1]<<endl;
		    return 0;
	}


Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e18
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const ll MOD = 1e9 + 7;
const int MAX = 1e6+ 6;

ll tree[4*MAX];

void update(int node, int l, int r, int id,ll val) {
    
    if(l > id || r< id) return ;
    if(l == r) {
        tree[node] = val;
        return;
    }
    int mid = (l+r)/2;
    update(node<<1, l , mid, id, val);
    update(node<<1|1, mid+1, r, id, val);
    tree[node] = max(tree[node<<1], tree[node<<1|1]);
}

ll query(int node, int l, int r,int frm, int to) {
    
    if( l > to || r < frm || l > r) return 0;
    if(l >=frm && r<= to) return tree[node];
    int mid = (l+r)/2;
    ll q1 = query(node<<1, l, mid, frm, to);
    ll q2 = query(node<<1|1, mid+1 ,r ,frm, to);
    return max(q1, q2);
}


int main()
{
    int n;
    cin>>n;
    vector<ll>h(n+1), a(n+1), dp(n+1);
    for(int i =1; i <=n ; i++ ) cin>>h[i];
    for(int i =1; i <=n ; i++ ) cin>>a[i];
    
    for(int i =1; i <=n ; i++ ) {
        
        ll ret = query(1, 1, n, 1, h[i]-1);
        dp[i] = ret + a[i];
        update(1, 1, n, h[i], dp[i]);
    }
    cout<<query(1, 1, n, 1, n)<<'\n';
    return 0;
}

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

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

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


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

}






Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
  string s; cin>>s;
  int n = s.size();
  bool flag = true;
  int i = 1;
  while(flag && i<n){
    if(s[i]==s[i-1]){
      flag=false;
      // if(i!=1) cout << i-1 SP i+1 << endl;
      // else cout << i SP i+2 << endl;
      cout << i SP i+1 << endl;
      return 0;
    }
    i++;
  }
  i = 2;
  while(flag && i<n){
    if(s[i]==s[i-2]){
      flag=false;
      cout << i-1 SP i+1 << endl;
      return 0;
    }
    i++;
  }
  cout << -1 SP -1 << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

void solve()
{
    ll h,w;
    cin>>h>>w;
    vector<string>v(h);
    rep(i,0,h)
    {
        cin>>v[i];
    }
    ll dp[h][w];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    rep(i,0,h)
    {
        rep(j,0,w)
        {
            if(v[i][j]=='#')
                continue;
            if(i==0&&j==0)
                continue;
            if(i==0)
            {
                dp[i][j]+=dp[i][j-1];
                dp[i][j]%=hell;
            }
            else if(j==0)
            {
                dp[i][j]+=dp[i-1][j];
                dp[i][j]%=hell;   
            }
            else
            {
                dp[i][j]+=(dp[i][j-1]+dp[i-1][j])%hell;
                dp[i][j]%=hell;
            }
        }
    }
    cout<<dp[h-1][w-1]<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 12428
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
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; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll a, b;
    cin >> a >> b;
    cout << max({a+b, a-b, a*b}) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.LinkedHashSet;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    char[] c = new char[n];

    for (int i = 0; i < n; i++) {
      c[i] = sc.next().charAt(0);
    }

    LinkedHashSet<Character> lhs = new LinkedHashSet<Character>();

    for (int i = 0; i < n; i++) {
      lhs.add(c[i]);
    }

    Object[] newc = lhs.toArray();

    if (newc.length == 3) {
      System.out.println("Three");
    } else {
      System.out.println("Four");
    }

  }
}

Measured memory_bytes: 35616
n=int(input())
a=list(map(int,input().split()))
a.sort()
i=0
ans=0
while i < n:
    k=i
    index=i
    while a[k]-a[i]<= 2:
        k += 1
        if k == n:
            break
    while a[index] == a[i]:
        index += 1
        if index == n:
            break
    ans=max(k-i,ans)
    if index == n:
        break
    i=index
print(ans)

Measured memory_bytes: 84356
// Code By H~$~C
#include <bits/stdc++.h>
using namespace std;

int main() {
  string s;
  cin >> s;
  if (s.size() & 1) puts("No");
  else {
    bool flag = true;
    for (int i = 0; i < (int)s.size(); ++i)
      if (i & 1) flag &= (s[i] == 'i');
      else flag &= (s[i] == 'h');
    puts(flag ? "Yes" : "No");
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll 			long long int
#define vll 		vector<long long int>
#define vi  		vector<int>
#define vpi 		vector<pair<int,int>>
#define PR 		fixed<<setprecision(10)
#define set(x)		__builtin_popcount(x)
#define ffs(x) 		__builtin_ffs(x)
#define clz(x) 		__builtin_clz(x)
#define all(v) 		v.begin(),v.end()
#define PI 3.14159265358979323846264

int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    cout.tie(NULL);
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double angleh = (PI/(6.0))*(h+m/60.0);
    double anglem = (2.0*PI)*(h+m/60.0);
    //cout << angleh <<' '<<anglem <<'\n';
    cout << PR<< sqrt(a*a + b*b - 2*a*b*cos(angleh-anglem));
}



Measured memory_bytes: 4244
/*Stay true to yourself, yet always be open to learn. Work hard, and never give up on your dreams, 
even when nobody else believes they can come true but you. These are not cliches but real tools you 
need no matter what you do in life to stay focused on your path.
*/

 /*Pppppppp    UU      UU     CCCCCCCC    CCCCCCCC     HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pppppppp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pp          UU      UU     CC          CC           HH     HH     UU      UU
   pp          UUUUUUUUUU     CCCCCCCC    CCCCCCCC     HH     HH     UUUUUUUUUU
   */

#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int c=0;
    for(int i=1;i<n-1;i++)
    {
        if(min(a[i],a[i+1]) ==a[i])
        {
            if(min(a[i],a[i-1])==a[i-1])
            c++;
        }
        else
        if(min(a[i],a[i-1])==a[i])
        c++;
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    vector<vector<int>> X(N), Y(N);
    REP(i, N) {
        int a; cin >> a;
        REP(j, a) {
            int x, y; cin >> x >> y;
            --x;
            X[i].pb(x);
            Y[i].pb(y);
        }
    }

    int ans = 0;
    REP(i, 1 << N) {
        bool f = true;
        REP(j, N) {
            if ((i >> j) % 2 == 0) continue;
            REP(k, X[j].size()) {
                int x = X[j][k], y = Y[j][k];
                if ((i >> x) % 2 == y) continue;
                f = false;
                break;
            }
            if (!f) break;
        }

        if (!f) continue;

        ans = max(bcnt(i), ans);
    }

    print(ans);
    
}


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

using namespace std;
using ll=long long;

void solve() {
    int n, A,B;
    cin >> n >> A >> B;
    ll res = 0;
    int las; cin >> las;
    for (int _ = 1; _ < n; _++) {
        int x; cin >> x;
        if (1ll*(x-las)*A > B) res += B;
        else res += 1ll*(x-las)*A;
        las = x;
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

//		String Sx = "?f????";
//		String T = "f";
		String Sx = sc.nextLine();
		String T = sc.nextLine();

		String SxMatch;
		String SxRep;
		Pattern p;
		Matcher m;

		for (int i = Sx.length() - T.length(); i >= 0 ; i--) {
			// Tの長さ文のSxの文字列を生成
			SxMatch = Sx.substring(i, i + T.length());

			// 文字列?を正規表現[a-z]に置換する
			SxRep = SxMatch.replaceAll("\\?", "[a-z]");

			// 文字列の頭から順番に正規表現でパターンマッチングする
			p = Pattern.compile(SxRep);
			m = p.matcher(T);

			if (m.find()) {
				// 見つかった場合
				// マッチングした部分文字列についてはTで置換、残りの?についてはaで置換
				String forwardT = Sx.substring(0, i);
				String BehindT = Sx.substring(i+T.length(), Sx.length());
				String S = (forwardT + T + BehindT).replaceAll("\\?", "a");
				System.out.println(S);
				return;
			}
		}
		// 見つからなかった場合
		System.out.println("UNRESTORABLE");
	}

}

Measured memory_bytes: 21844
/*
 * wafuIroha.cpp
 *
 *  Created on: 2020/02/23
 *      Author: black
 */
#include <iostream>
using namespace std;

int main(){
	char a, b;
	cin >> a >> b;

	if (a == 'H'){
		if (b == 'H'){
			cout << "H" << endl;
		}
		else{
			cout << "D" << endl;
		}
	}
	else{
		if (b == 'H'){
			cout << "D" << endl;
		}
		else{
			cout << "H" << endl;
		}
	}


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n, m; cin >> n >> m;
	int ans = -1;
	for( int i = 1; i*i <= m; ++i ){
		if( m % i == 0 ){
			int j = m/i;
			if( j >= n ){
				ans = max( ans, i );
			}
			if( i >= n ){
				ans = max( ans, j );
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
    int n;
    cin>>n;
    cout<<(n+1)/2;   
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 3616
N = int(input())

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

A.sort()

s1 = 0
s2 = 0

at = -1
atc = 0

for a in A:
    if at == a:
        atc += 1

    else:
        if atc >= 4:
            s1 = at
            s2 = at
        elif atc >= 2:
            s2 = s1
            s1 = at
        
        at = a
        atc = 1

if atc >= 4:
    s1 = at
    s2 = at
elif atc >= 2:
    s2 = s1
    s1 = at

print(s1 * s2)


Measured memory_bytes: 20072
h, w = map(int, input().split())
mass = [input() for _ in range(h)]
for i in reversed(range(h)):
    if mass[i].count("#") == 0:
        mass = mass[:i] + mass[i+1:]

for i in reversed(range(w)):
    cnt = 0
    for row in mass:
        if row[i] == "#":
            cnt += 1
    if cnt == 0:
        for j, row in enumerate(mass):
            mass[j] = row[:i] + row[i+1:]

print("\n".join(mass))





Measured memory_bytes: 3064
#include<stdio.h>

#define INF 2001
#define N 100
int n,w[N][N];

int Prim(){

  int d[N],pi[N],color[N],mincost,u,i,v,sum=0,r=0,p;

  for(u=0;u<n;u++){

    d[u]=INF;
    pi[u]=NULL;
    color[u]=1;

  }

  d[r]=0;

  for(p=0;p<n;p++){

    mincost=INF;

    for(i=0;i<n;i++){
      if(color[i]!=0 && d[i]<mincost){
	mincost=d[i];
	u=i;
      }
    }


    for(v=0;v<n;v++){
      if(w[u][v]!=-1 && color[v]!=0 && w[u][v]<d[v]){
	pi[v]=u;
	d[v]=w[u][v];
      }
    }
    color[u] =0;
  }

  for(i=0;i<n;i++){

    sum+=d[i];

  }

  return sum;

}

int main(){

  int i,a,j;


  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){

      scanf("%d",&w[i][j]);

    

    }
  }

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


  return 0;

}

Measured memory_bytes: 636
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    
    ans = 0
    for i in range(1, N + 1):
        j = N // i
        ans += j * (j + 1) * i // 2
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 80064
#空セットを作り標準入力をする
num_list = set()
for _ in range(int(input())):
    a,b = map(int,input().split())
    
    #aが0のときはセットにbを加え要素数を出力する
    if a == 0:
        num_list.add(b)
        print(len(num_list))
        
    #aが1のときbがセットの中にあるなら1ないなら0を出力する
    elif a == 1:print(1 if b in num_list else 0)


Measured memory_bytes: 23360
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  string s,ss;
  cin>>s>>ss;
  for(int i=0;i<n;i++){
    bool fl=true;
    for(int j=i;j<n;j++){
    //  cout<<i<<" "<<j<<" "<<s[i]<<" "<<s[j-i]<<endl;
      if(s[j] != ss[j-i]){
	fl=false;
      }
    }
    if(fl){cout<<n+i<<endl;return 0;}
  }
  cout<<2*n<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <limits.h>

#define ll long long

using namespace std;

int abs(int n){
    if(n < 0){
        return -1 * n;
    }else return n;
}

int main(){

    int n;
    cin >> n;

    vector<int> w;
    int sum = 0;
    vector<int> w2;
    int ans = INT_MAX;

    for(int i = 0; i < n; i++){
        int tmp;
        cin >> tmp;
        w.push_back(tmp);
        sum += tmp;
        w2.push_back(sum);
    }

    for(int i = 0; i < n; i++){
        int s2;
        s2 = sum - w2[i];

        ans = min(ans, abs(s2 - w2[i]));
    }

    cout << ans << endl;





    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, N) for (int i = 0; i < (N); i++)
#define REP(i, a, N) for (int i = a; i < (N); i++)
#define rrep(i, N, k) for (int i = (N); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - (int)1e8;
const ll INFLL = numeric_limits<ll>::max() - (ll)1e17;

template< typename T >
struct edge {
    int src, to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    edge &operator=(const int &x) {
        to = x;
        return *this;
    }

    operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
pair< T, int > dfs(const WeightedGraph< T > &g, int idx, int par) {
    pair< T, int > ret(0, idx);
    for(auto &e : g[idx]) {
        if(e.to == par) continue;
        auto cost = dfs(g, e.to, idx);
        cost.first += e.cost;
        ret = max(ret, cost);
    }
    return ret;
}

template< typename T >
T tree_diameter(const WeightedGraph< T > &g) {
    auto p = dfs(g, 0, -1);
    auto q = dfs(g, p.second, -1);
    return (q.first);
}


int main() {
    int N;
    cin >> N;
    WeightedGraph<int> G(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        G[a].emplace_back(b, 1);
        G[b].emplace_back(a, 1);
    }
    cout << (tree_diameter(G) % 3 == 1 ? "Second" : "First") << endl;
}

Measured memory_bytes: 26752
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	for(int i=1;i<15000;i++)
		if(i*10/125==a&&i/10==b){
			cout<<i;
			return 0;
		}
	cout<<-1;
	return 0;
} 

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

int main()
{
	int n;
	cin >> n;
	vector<int> xv(n);
	vector<int> yv(n);
	vector<int> hv(n);
	for (int i = 0; i < n; ++i) {
		cin >> xv[i] >> yv[i] >> hv[i];
	}

	for (int i = 0; i <= 100; ++i) {
		for (int j = 0; j <= 100; ++j) {

			int ch = 0;
			for (int k = 0; k < n; ++k) {
				if (hv[k] == 0) {
					continue;
				}
				ch = hv[k] + abs(xv[k] - i) + abs(yv[k] - j);
				break;
			}
			
			int k = 0;
			for (; k < n; ++k) {
				int temp = max(0, ch - abs(xv[k] - i) - abs(yv[k] - j));
				if (hv[k] != temp) {
					break;
				}
			}

			if (k == n) {
				cout << i << " " << j << " " << ch << endl;
				return 0;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
function Main(input) {
  var N = parseInt(input[0], 10);
  var list = input.slice(1).map(a => parseInt(a, 10));

  var result = 0;

  for (var i = 0; i < list.length; i++) {
    var kurikaesi = 0;
    while (list[i] % 2 === 0) {
      // 偶数なら２で割る
      list[i] = list[i] / 2;
      kurikaesi++;
    }
    if (i === 0) {
      result = kurikaesi;
    } else if (result > kurikaesi) {
      result = kurikaesi;
    }
  }

  console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

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

int main() {
  char c;
  cin >> c;

  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 3596
n = int(input())
A = [int(i) for i in input().split()]
A2 = A.copy()

def gcd(x, y):
    while y != 0:
        x, y = y, x%y
    return x

def lcm(x, y):
    return x * y // gcd(x, y)

for i in range(n-1):
    A[i+1] = lcm(A[i], A[i+1])

ans = 0
for i in range(n):
    ans += (A[-1] - 1) % A2[i]
    
print(ans)

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef complex<ld> cd;

const ll mod = 1000000007;
ll dp[200005], sdp[200005];

int main(){

    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<setprecision(30);

    memset(dp, 0, sizeof(dp));
    memset(sdp, 0, sizeof(sdp));
    int n, x;
    cin>>n;
    vector<int> c;
    for(int i = 1; i <= n; i++){
    	cin>>x;
    	if(c.empty() || c.back() != x)c.push_back(x);
    }
    n = c.size();
    dp[0] = 1;
    for(int i = 1; i <= n; i++){
    	(sdp[c[i-1]] += dp[i-1]) %= mod;
    	dp[i] = sdp[c[i-1]];
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 4600
using System;
using System.Linq;

namespace ITP1_4_D_Min_Max_and_Sum
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var input = Console.ReadLine().Split( ' ' ).Select( long.Parse );
            Console.WriteLine( "{0} {1} {2}", input.Min(), input.Max(), input.Sum() );
        }
    }
}

Measured memory_bytes: 6712