akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>					//always include all files then we don't need to worry
using namespace std;					//then we don't need to worry about header files		

#define ll long long					//these are called macros(i.e. short notations)
#define ld long double					// ll -> (long long) and ld ->(long double)


int main()
{
	
	// if a1*a2*.....*an = p then if we divide p by all a1 then at the end p=1
	// if we divide x (x < p) by all a1,a2,a3.............an then at the end x=0
	// if we divide x (x > p) by all a1,a2,a3.............an then at the end x>=1
	ll n;
	cin>>n;
	ll res=1e18, ans=1, x;
	for(int i=0;i<n;i++){
		cin>>x;
		if(x==0){
			// array contains 0 hence product of all elements = 0
			res=1;
			ans=0;
			break;
		}
		res /= x;
		ans *= x;
	}
	if(res==0)ans=-1;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3596
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll n; cin >> n;
  ll ans = 0;
  vector<ll> a(n), b(n);
  rep(i, n) {
    ll ai, bi; cin >> ai >> bi;
    a[i] = ai; b[i] = bi;
  }
  for (int i = n - 1; i >= 0; i--) {
    a[i] += ans;
    ll p = 0;
    if (a[i] % b[i] != 0) p = b[i] - (a[i] % b[i]);
    ans += p;
  }
  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 2552
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){

    ll N,K;
    cin >> N >> K;
    
    vector<ll> V(N);
    rep(i,0,N)cin >> V[i];
    

    ll maxi = 0;
    rep(i,0,41){
        
        ll bit = 0;
        rep(j,0,41){
            if(!(K & (1LL << j)))continue;
            int cnt = 0;
            rep(k,0,N){
                if(V[k] & (1LL << j))cnt++;
            }
            if(cnt * 2 < N)bit += 1LL << j;
        }
        ll sum = 0;
        rep(j,0,N)sum += bit ^ V[j];
        maxi = max(maxi, sum);
        
        ll bidx = -1;
        bool find = 0;
        rep(j,0,42){
            if(K & (1LL << j)){
                if(find){
                    bidx = j;
                    break;
                } 
            }else{
                find = 1;
            }
        }
        if(bidx == -1)continue;
        ll mask = (1LL << (bidx)) - 1;
        K = (K - (1LL << bidx)) | mask;
        /*
        cout << bitset<16>(digit) << endl;
        cout << bitset<16>(mask) << endl;
        cout << bitset<16>(K) << endl;
        cout << endl;
        */
    }
    cout << maxi << endl;
}

Measured memory_bytes: 1152
<?php
// Try AtCoder
// author: Leonardone @ NEETSDKASU

function gets() { return trim(fgets(STDIN)); }
function getVals() { return explode(' ', gets()); }
function getInts() { return array_map(intval, getVals()); }

$N = intval(gets());
$xs = getInts();

$tb = array_fill(0, 100003, 0);

foreach ($xs as $x) {
    for ($i = $x; $i <= $x+2; $i++) {
        $tb[$i]++;
    }
}

sort($tb);

echo $tb[100002], PHP_EOL;

Measured memory_bytes: 35372
#include <bits/stdc++.h>
using namespace std;
int arr[11];
int n;
int solve(int idx,long long curSum)
{
    if(idx == n)
        return !(curSum % 2);
   // cout << idx << endl;
    int C1 = 0;
    for(int i = arr[idx]-1;i <= arr[idx]+1;i++)
        C1 += solve(idx + 1,curSum * i * 1LL);
    return C1;
}
int main()
{

    cin >> n;
    for(int i = 0;i < n;i++)
        cin >> arr[i];
    cout << solve(0,1);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a;
  cin>>a;
  int n[a+1];
  for(int i=0;i<a;i++)
  cin>>n[i];
  int dp[a+1]={0};
  dp[0]=0;
  dp[1]=abs(n[1]-n[0]);
  for(int i=2;i<a;i++)
  {
      dp[i]=min(dp[i-2]+abs(n[i]-n[i-2]),dp[i-1]+abs(n[i]-n[i-1]));
  }
  cout<<dp[a-1];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = INT32_MAX;
const long long int Mod = 1000000007;
const long long int mod = 100000;//10^5
using ll = long long int; //long long int は64bit
using ci = const int; using vi = vector<int>; using Vi = vector<long long int>; using pii = pair<int,int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
//       cin.tie(0);ios::sync_with_stdio(false);
void cinit(){cin.tie(0);ios::sync_with_stdio(false);}
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////

ll s;
int ma[1000001]={0};

ll cal(ll n){
	if(n%2==0)return n/2;
	else return 3*n+1;
}

int main(){
	cin>>s;
	ll now=s;
	Vi v;ll ans = 0;ll j=1;
	ma[now]++;
	while(1){
		j++;
		now = cal(now);
		if(ma[now]>0){
			ans = j;
			break;
		}
		ma[now]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val temp=readLine()!!.split(" ")
    val a = temp[0].toInt()
    val b = temp[1].toInt()
    val bg= if(a>b)a else b
    val sm= if(a>b)b else a
    val bg_s = if(a>b)"." else "#"
    val sm_s = if(a>b)"#" else "."

    val arr = Array(100,{i: Int -> Array(100,{sm_s})})
    var count=0
    for(i in 1..97 step 4){
        for(j in 1..97 step 4){
            if(count>=bg){
                break
            }
            for(k in i-1..i+1) {
                for(l in j-1..j+1) {
                    arr[k][l]=bg_s
                }
            }
            if(count<sm-1){
                arr[i][j]= sm_s
            }
            count++
        }
    }
    println("100 100")
    for(i in 0 until 100){
        for(j in 0 until 100){
            print(arr[i][j])
        }
        if(i<99)println()
    }
}

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

#define reg register
#define pr std::pair<int, int>
#define fi first
#define se second
#define FIN(s) freopen(s, "r", stdin)
#define FOUT(s) freopen(s, "w", stdout)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define lep(i, l, r) for (int i = l; i < r; ++i)
#define irep(i, r, l) for (int i = r; i >= l; --i)
#define ilep(i, r, l) for (int i = r; i > l; --i)
#define Rep(i, n) rep(i, 1, n)
#define Lep(i, n) lep(i, 1, n)
#define IRep(i, n) irep(i, n, 1)
#define ILep(i, n) ilep(i, n, 1)
typedef long long ll;
typedef long double ld;

namespace modular {
    const int MOD = 1000000007;
    inline int add(int x, int y) { return (x += y) >= MOD ? x -= MOD : x; }
    inline void inc(int &x, int y) { (x += y) >= MOD ? x -= MOD : 0; }
    inline int mul(int x, int y) { return 1LL * x * y % MOD; }
    inline int qpow(int x, int y) {
        int ans = 1;
        for (; y; y >>= 1, x = mul(x, x))
            if (y & 1) ans = mul(ans, x);
        return ans;
    }
};  // namespace modular

namespace Base {
    template <typename Tp>
    inline Tp input() {
        Tp x = 0, y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-') y = -1;
            c = getchar();
        }
        if (c == EOF) return 0;
        while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getchar();
        return x *= y;
    }
    template <typename Tp>
    inline void read(Tp &x) {
        x = input<Tp>();
    }
    template <typename Tp>
    inline void chmax(Tp &x, Tp y) {
        x < y ? x = y : 0;
    }
    template <typename Tp>
    inline void chmin(Tp &x, Tp y) {
        x > y ? x = y : 0;
    }
};  // namespace Base
using namespace Base;
/*----------------------------------------------------------------------------*/

#define MAX_N 507

int N;
ll f[MAX_N][MAX_N], s1[MAX_N][MAX_N], s2[MAX_N][MAX_N];

inline ll calc(int k, int j, int i) {
    return s2[j + 1][i] + s1[N][j] - s1[N][k] - s1[i][j] + s1[i][k];
}

int main() {
    read(N);
    Rep(i, N) Rep(j, N) if (i != j) read(s1[i][j]);
    Rep(j, N) IRep(i, j) s2[i][j] =
        s2[i + 1][j] + s2[i][j - 1] - s2[i + 1][j - 1] + s1[i][j];
    Rep(i, N) Rep(j, N) s1[i][j] +=
        s1[i - 1][j] + s1[i][j - 1] - s1[i - 1][j - 1];
    ll ans = 1e17;
    Lep(i, N) {
        f[i][0] = calc(0, 0, i);
        chmin(ans, f[i][0] + calc(0, i, N));
        Lep(j, i) {
            f[i][j] = 1e17;
            lep(k, 0, j) { chmin(f[i][j], f[j][k] + calc(k, j, i)); }
            chmin(ans, f[i][j] + calc(j, i, N));
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 6272
from itertools import product

N, K = map(int, input().split())
x, y = [None] * N, [None] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())

xary = sorted(x)
yary = sorted(y)

ans = float('inf')
for i, j, k, l in product(range(N), repeat=4):
    if i >= j or k >= l:
        continue
    x1, x2 = xary[i], xary[j]
    y1, y2 = yary[k], yary[l]
    cnt = 0
    for xx, yy in zip(x, y):
        if x1 <= xx <= x2 and y1 <= yy <= y2:
            cnt += 1
    if cnt >= K:
        s = abs(x1 - x2) * abs(y1 - y2)
        ans = min(ans, s)
print(ans)



Measured memory_bytes: 52324
#include <iostream>
using namespace std;
int main() {
    string s; cin >> s;
    int dp[2][200200] = {};
    dp[1][0] = 1;
    for (int i = 1; i < s.size(); i++) {
        if (i == 1) dp[0][i] = 1;
        else if (i == 2) dp[0][i] = 2;
        else if (s[i-3] != s[i-1] || s[i-2] != s[i])
            dp[0][i] = 1 + max(dp[0][i-2], dp[1][i-2]);
        else dp[0][i] = 1 + dp[1][i-2];
        if (s[i-1] != s[i]) dp[1][i] = 1 + max(dp[0][i-1], dp[1][i-1]);
        else dp[1][i] = 1 + dp[0][i-1];
    }
    cout << max(dp[0][s.size()-1], dp[1][s.size()-1]) << endl;
}


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

int main() {
    while(1) {
        int H, W;
        cin >> H >> W;
        if (H == 0 && W == 0) {
            break;
        }
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if ((i+j) % 2 == 0) {
                    cout << '#';
                } else {
                    cout << '.';
                }
            }
            cout << '\n';
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3076
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

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; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

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

signed main(void) {
    int h, w; cin >> h >> w;
    vector<string> s(h); vin(s);
    int wall = 0;
    rfor(v, s) rfor(c, v) if(c == '#') wall++;
    queue<pint> que;
    vvint d(h, vint(w, INT_MAX)); d[0][0] = 0;
    que.push(pint(0, 0));
    while(que.size()) {
        pint p = que.front(); que.pop();
        //if(p == pint(h - 1, w - 1)) break;
        rep(i, 4) {
            int nx = p.first + dx[i], ny = p.second + dy[i];
            if(0 <= nx && nx < h && 0 <= ny && ny < w && 
                    s[nx][ny] == '.' && d[nx][ny] == INT_MAX) 
            {
                que.push(pint(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
    if(d[h - 1][w - 1] == INT_MAX) {
        print(-1);
        return 0;
    }
    int ans = h * w - d[h - 1][w - 1] - 1 - wall;
    print(ans);

    return 0;
}



Measured memory_bytes: 256
X = int(input())
k = list(range(0,100000))
k5 = []
for i in k:
    k5.append(i**5)
for j in k5:
    if X + j in k5:
        print(k[k5.index(X+j)],k[k5.index(j)])
        exit()
    elif X - j in k5:
        print(k[k5.index(X-j)],-k[k5.index(j)])
        exit()

Measured memory_bytes: 18420
#include <stdio.h>

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

  scanf("%d %d %d", &a, &b, &c);

  if(a > b)
  {
    temp = b;
    b = a;
    a = temp;
  }

  if(b > c)
  {
    temp = c;
    c = b;
    b = temp;
  }

  if(a > b)
  {
    temp = b;
    b = a;
    a = temp;
  }
  
  printf("%d %d %d\n", a, b, c);
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
char str[10];
bool jay1,jay2;
int main(){
	scanf("%s",&str);
	for (register int i=0; i<3; ++i) 
	{
		if (str[i]=='A') jay1=true;
		if (str[i]=='B') jay2=true;
	}	
	if (!jay1 || !jay2) puts("No");
	else puts("Yes"); 
return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = 10**9


def main():
    N = int(input())
    A = list(map(int, input().split()))

    if N == 0:
        if A[0] == 1:
            print(1)
            return
        else:
            print(-1)
            return
    elif A[0] != 0:
        print(-1)
        return

    # 利用可能頂点をメモ
    available = [0]*(N+1)
    available[0] = 1
    for i in range(1, N+1):
        available[i] = available[i-1]*2-A[i]
    # print(available)

    ans = 0
    # 後ろから見ていく
    for i in range(N, 0, -1):
        # print(A[i])
        if A[i] <= available[i-1]:
            # 独立型
            ans += A[i]
            A[i-1] += A[i]
        elif A[i] <= 2*available[i-1]:
            ans += A[i]
            A[i-1] += available[i-1]
        else:
            print(-1)
            return
    print(ans+1)
    return


if __name__ == '__main__':
    main()


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

int main(){
	
	int N, A, B;
	cin >>N;
	
	if(N==1){
		
		cout <<"Hello World" <<endl;
		
	}
	else{
		
		cin >>A >>B;
		cout <<A+B <<endl;
		
	}
	
	
}



Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)

int two(ll x){
  ll count = 0;
  while (x %2==0)
  {
    x /= 2;
    count++;
  }
  return count;
}

int main()
{
  int n;cin>>n;
  ll a[n + 10];
  rep(i, n) cin >> a[i];
  ll ans = 0;
  rep(i,n){
    if(a[i]%2==0)ans+=two(a[i]);
  }
  cout << ans<< endl;
  return 0;
}


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

int main(){
    int n;
    while(cin >> n, n){
        vector<int> b(n), x(n), y(n);
        for(int i = 0; i < n; i++)  cin >> b[i] >> x[i] >> y[i];
        int m;
        cin >> m;
        while(m-- > 0){
            int s, g;
            cin >> s >> g;
            vector<double> dp(n, DBL_MAX);
            vector<int> back(n, -1);
            priority_queue<pair<double, pair<int, int>>> pq;
            int sind, gind;
            for(int i = 0; i < n; i++){
                if(b[i] == s)   sind = i;
                if(b[i] == g)   gind = i;
            }
            pq.push({-0, {sind, -1}});
            while(!pq.empty()){
                auto p = pq.top();  pq.pop();
                double cost = -p.first;
                int pos = p.second.first, par = p.second.second;
                if(dp[pos] <= cost) continue;
                dp[pos] = cost;
                back[pos] = par;
                if(pos == gind) break;
                for(int j = 0; j < n; j++){
                    double dist = sqrt(pow(x[j]-x[pos], 2.0)+pow(y[j]-y[pos], 2.0));
                    if(dist > 50.0) continue;
                    if(dp[j] > cost + dist){
                        pq.push({-(cost+dist), {j, pos}});
                    }
                }
            }
            if(dp[gind] == DBL_MAX){
                cout << "NA" << endl;
                continue;
            }
            vector<int> ans;
            while(gind != -1){
                ans.push_back(b[gind]);
                gind = back[gind];
            }
            reverse(ans.begin(), ans.end());
            for(int i = 0; i < ans.size(); i++){
                cout << ans[i] << " \n"[i+1==ans.size()];
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3068
#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define range(i,a,b) for(int i=a; i<(int)(b); i++)
#define rep(i,b) range(i,0,b)

typedef int Capacity;
struct Edge {
    int src, dst;
    Capacity cap;
    Edge(int src_, int dst_, int cap_) :
        src(src_), dst(dst_), cap(cap_) { }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<int> Array;
typedef vector<Array> Matrix;

int const inf = 1e9;

template<class Capacity = int> struct FordFulkerson {
    typedef vector<vector<Capacity>> Matrix;
    size_t n;
    int t;
    Matrix cap, flow;
    vector<bool> vis;
    Capacity res;
    vector<vector<int>> g;
    FordFulkerson(const int s, const int t, const Graph &graph) :
        n(graph.size()), t(t), cap(n, Array(n)), flow(n, Array(n)), res(0), g(n) {
        rep(i,n)rep(j,graph[i].size()){
            int u = graph[i][j].src, v = graph[i][j].dst;
            cap[u][v] = flow[u][v] = graph[i][j].cap;
        }
        rep(i,n)rep(j,n) if(cap[i][j]) g[i].emplace_back(j), g[j].emplace_back(i);
        Capacity f = -1;
        while(f) vis.assign(n, false), res += (f = augment(s,inf));
        rep(i,n)rep(j,n) flow[i][j] -= cap[i][j];
    }
    Capacity augment(const int u, const Capacity lim){
        vis[u] = true;
        if(u == t) return lim;
        Capacity f;
        for(const int &v : g[u]){
            if(vis[v] || cap[u][v] == 0) continue;
            f = augment(v, min(lim, cap[u][v])), cap[u][v] -= f, cap[v][u] += f;
            if(f) return f;
        }
        return 0;
    }
};

int main(){
    int N,M;
    cin >> N >> M;
    Graph g(N);
    rep(i,M){
        int a,b,c;
        cin >> a >> b >> c;
        g[a].emplace_back(a,b,c);
    }
    cout << FordFulkerson<int>(0,N-1,g).res << endl;
}

Measured memory_bytes: 1348
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (a) - 1; (i) >= (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
const ll inf = 1e9;

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

int main(){
    ll h,w;
    cin >> h >> w;
    ll g[h][w];
    rep0(i, h)rep0(j, w)cin >> g[i][j];
    vector<pair<pair<ll, ll>, pair<ll, ll>>> ans(h * w + 1);
    ll cnt = 0;
    rep0(i, h){
        rep0(j, w){
            if(g[i][j] % 2 && (i != h - 1 || j != w - 1)){
                if(j == w - 1){
                    ans[cnt] = make_pair(make_pair(i, j), make_pair(i + 1, j));
                    --g[i][j];
                    ++g[i + 1][j];
                    ++cnt;
                }else{
                    ans[cnt] = make_pair(make_pair(i, j), make_pair(i, j + 1));
                    --g[i][j];
                    ++g[i][j + 1];
                    ++cnt;
                }
            }
        }
        ++i;
        if(i >= h)break;
        rrep0(j, w){
            if(g[i][j] % 2 && (i != h - 1 || j != 0)){
                if(j == 0){
                    ans[cnt] = make_pair(make_pair(i, j), make_pair(i + 1, j));
                    --g[i][j];
                    ++g[i + 1][j];
                    ++cnt;
                }else{
                    ans[cnt] = make_pair(make_pair(i, j), make_pair(i, j - 1));
                    --g[i][j];
                    ++g[i][j - 1];
                    ++cnt;
                }
            }
        }
    }
    pf(cnt);
    rep0(i, cnt)printf("%lld %lld %lld %lld\n",ans[i].first.first + 1,ans[i].first.second + 1,ans[i].second.first + 1,ans[i].second.second + 1);
    return 0;
}


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

const int MOD = 1000000007;
using Data = pair<long long, vector<ll> >;

int main() {
  ll n;
  cin >> n;
  vector<ll>vec(n);
  vector<ll>s(n+1);
  vector<ll>ans;
  ll sum = 0;
  s[0]=0;
  rep(i,n){
    cin >> vec[i];
    s[i+1]=s[i]+vec[i];
  }
  sort(s.begin(),s.end());
  ll num = 0;
  rep(i,n){
    if(s[i]==s[i+1]) num++;
    else{
      ans.push_back(num);
      num=0;
    }
    if(i==n-1) ans.push_back(num);
  }

  rep(i,ans.size())sum+=ans[i]*(ans[i]+1)/2;
  
  cout << sum << endl;
  return 0;
 
}

Measured memory_bytes: 5492
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(int)(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) ((flag)?1:0)
#define YN(flag) cout<<(flag?"YES":"NO")<<endl;
#define Yn(flag) cout<<(flag?"Yes":"No")<<endl;
#define yn(flag) cout<<(flag?"yes":"no")<<endl;
#define Cout(v) cout<<(v)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

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

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ===================

// Template End =========================

int main(void){
  int a,b,c; cin>>a>>b;
  Cout(b%a==0?b+a:b-a);
}












Measured memory_bytes: 256
from heapq import heappush, heappop, heapify

obj = input().strip().split(' ')
N, M = map(int, obj)

obj = input().strip().split(' ')
val_list = [-1 * item for item in list(map(int, obj))]

heapify(val_list)

for _ in range(M):
    val = (-1) * ((heappop(val_list) * (-1)) // 2)
    heappush(val_list, val)

print(-1 * sum(val_list))


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll INF=1LL<<60;
const int MOD=1e9+7;
const int N=1e6;

vector<bool> check(N+1, 0);
vi cnt(N+1);

void exist(int a){
    if(check[a]){
        cnt[a]++;
        return;
    }
    check[a]=true;
    for(int i=1; i<=(N/a); i++){
        cnt[a*i]++;
    }
}

int main(){
    int n; cin >> n;
    vi A(n);
    for(int i=0; i<n; i++){
        cin >> A[i];
        exist(A[i]);
    }
    int res=0;
    for(int i=0; i<n; i++){
        if(cnt[A[i]] == 1) res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 8012
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << endl;
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << "";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define wh while
#define ve vector
#define mp make_pair
#define tp tuple
#define mt make_tuple
#define pb push_back
#define pof pop_front
#define pob pop_back
#define pf push_front
#define fr front
#define ft first
#define sc second
#define tos to_string
#define len length
#define rt return
#define br break
#define con continue
#define lcm(n, m) (n * m / __gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m) - 1;i>=(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) n.begin(), n.end()
#define allr(n) n.rbegin(), n.rend()
#define sp(n) cout << fixed << setprecision(n)
#define pi 3.14159265358979323846
#define inf 1000000007
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

ve<int> dx = {0, 0, 1, -1}, dy = {1, -1, 0, 0};

int main() {
  int a;
  rep(i, 5){
    ci(a);
    if(a == 0){
      co(i + 1);
    }
  }
}


Measured memory_bytes: 3628
use std::io::{stdin, BufRead};

fn bisect(x: &[i32], a: i32) -> usize {
    let mut lo = 0;
    let mut hi = x.len();
    while lo < hi {
        let mid = (lo + hi) / 2;
        if a < x[mid] {
            hi = mid;
        } else {
            lo = mid + 1;
        }
    }
    lo
}

fn main() {
    let stdin = stdin();
    let cin = stdin.lock();
    let mut lines = cin.lines();
    let n = {
        let line = lines.next().unwrap().unwrap();
        line.parse::<usize>().unwrap()
    };
    let mut xx = Vec::new();
    xx.push({
        let line = lines.next().unwrap().unwrap();
        -line.parse::<i32>().unwrap()
    });
    for _ in 0..n - 1 {
        let a = {
            let line = lines.next().unwrap().unwrap();
            -line.parse::<i32>().unwrap()
        };
        if a >= *xx.last().unwrap() {
            xx.push(a);
        } else {
            let mut i = bisect(&xx, a);
            if i == xx.len() {
                i -= 1;
            }
            xx[i] = a;
        }
    }
    println!("{}", xx.len());
}

Measured memory_bytes: 4352
# -*- coding: utf-8 -*-
"""
Created on Sun May 10 17:43:29 2020

@author: shinba
"""

n = int(input())
s = input()
t = input()

l = 0
for i in range(n):
    if s[i:] == t[:n-i]: 
         l = n-i
         break

print(2*n-l)
    


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
	cin>>n;
	for(int i=n;i>=2;i--)
	{
		if(i==64 || i==32 || i==16 || i==8 || i==4 || i==2)
		{
			cout<<i;
			return 0;
		}
			
	}
	cout<<1;
}

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

int main() {
    // input
    string S;
    cin >> S;

    // solve
    int ans = 0;
    for (int i = 0; i < S.length(); ++i) {
        if (S[i] == '1') ans++;
    }

    // output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>

using namespace std;

int L[100];

int main()
{
    int N, i, j, k, ways;

    scanf("%d", &N);
    for(i = 0; i < N; ++i)
        scanf("%d", &L[i]);

    ways = 0;
    for(i = 0; i < N - 2; ++i)
        for(j = i + 1; j < N - 1; ++j)
            for(k = j + 1; k < N; ++k)
                if(L[i] != L[j] && L[i] != L[k] && L[j] != L[k])
                    if(L[i] + L[j] > L[k] && L[i] + L[k] > L[j] && L[j] + L[k] > L[i])
                        ++ways;
    printf("%d", ways);

    return 0;
}


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

int main(){
	int a[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
	int x,y;cin >> x >> y;

	if(a[x] == a[y]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    string S; cin >> S;

    ll cnt_one = 0, cnt_zero = 0;
    for (auto c : S) {
        if (c == '1') ++cnt_one;
        else ++cnt_zero;
    }
    cout << min(cnt_one, cnt_zero) * 2 << endl;
}

Measured memory_bytes: 512
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	b := make([]int, n)
	// 3 [3 1 2]
	// 5 [5 3 1 2 4]
	// 6 [6 4 2 1 3 5]
	w := n
	f := true
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	for i := 0; i < n; i++ {
		b[i] = a[w-1]
		if f {
			w -= 2
		} else {
			w += 2
		}
		if w <= 0 {
			f = false
			if w == 0 {
				w = 1
			} else {
				w = 2
			}
		}
	}
	fmt.Printf("%d", b[0])
	for i := 1; i < n; i++ {
		fmt.Printf(" %d", b[i])
	}
	fmt.Println("")
}

Measured memory_bytes: 11552
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        int N = int.Parse(Console.ReadLine());
        string[] str = Console.ReadLine().Split(' ');
        long p = int.Parse(str[0]);
        for(int i=1;i<N;i++){
            p = p*int.Parse(str[i])/gcd(p,int.Parse(str[i]));
        }
        sb.Append(p+"\n");
    }
    long gcd(long N,long M){
        if(M == 0){
            return N;
        }
        else{
            return gcd(M,N%M);
        }
    }
}

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

using namespace std;

using ll = long long;

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

    int n, k;
    cin >> n >> k;

    map<int, int> cnt;
    for (int i = 0, a; i < n; ++i) {
        cin >> a;
        ++cnt[a];
    }

    if ((int)cnt.size() <= k) cout << "0\n";
    else {
        vector<int> item(cnt.size());

        int idx = 0;
        for (auto it : cnt)
            item[idx++] = it.second;

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

        int res = cnt.size() - k, sum = 0;
        for (idx = 0; idx < (int)item.size() && 0 < res--; ++idx)
            sum += item[idx];

        cout << sum << endl;
    }

    return 0;
}


Measured memory_bytes: 10368
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    C = Counter(A)

    total = 0
    for n in C.values():
        total += n * (n - 1) // 2

    ans = [0] * N
    for i, a in enumerate(A):
        ans[i] = total - C[a] + 1

    print('\n'.join(map(str, ans)))
    return


if __name__ == '__main__':
    main()


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

using namespace std;
using ll=long long;

#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cll ll t;cin>>t;while(t--)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pii pair<int,int>
#define vint vector<int>

ll mod=1e9+7;

int main(){
    faster;

    int n;
    cin>>n;

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

    int res=1;
    int last=p[0];
    for(int i=1;i<n;i++){
        if(p[i]<=last){
            last=p[i];
            res++;
        }
    }
    
    cout<<res<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

signed main(){
  int n,q;
  while(cin>>n>>q,n){
    map<int,int> mp;
    REP(i,n){
      int m;
      cin>>m;
      REP(j,m){
        int a;
        cin>>a;
        mp[a]++;
      }
    }
    int maxi=0;
    int ans=INF;
    for(auto x:mp){
      if(x.SC>maxi){
        maxi=x.SC;
        ans=x.FR;
      }else if(x.SC==maxi){
        ans=min(ans,x.FR);
      }
    }
    cout<<(maxi>=q?ans:0)<<endl;
  }
  return 0;
}



Measured memory_bytes: 3020
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
ll n, m, v, p;
bool check(ll mid, vector<ll> a){

    //cout << mid << endl;
    ll tmp = a[mid] + m;
    if(n - mid <= v){
        ll vote = 0;
        vote += (n - mid) * m;
        vote += (p - 1) * m;
        for(ll i = p - 1; i < mid; i++){
            if(a[i] > tmp) return false;
            vote += min(m, tmp - a[i]);
        }
        if(vote >= m * v){
            return true;
        } else {
            return false;
        }
    } else {
        a[mid] += m;
        for(ll i = n - v + 1; i < n; i++){
            a[i] += m;
        }
    }




    sort(all(a), greater<ll>());

    ll last = a[p - 1];

    //cout << mid << ":" << tmp << " " << last << endl;

    if(tmp >= last){
        return true;
    } else {
        return false;
    }
}
int main(void){

    cin >> n >> m >> v >> p;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    sort(all(a), greater<ll>());
    // rep(i, n){
    //     cout << a[i] << " ";
    // }
    // cout << endl;

    ll ok = 0;
    ll ng = n;

    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if(check(mid, a)){
            ok = mid;
        } else {
            ng = mid;
        }
    }

    cout << ok + 1 << endl;


}


Measured memory_bytes: 4820
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
  cin>>n>>k;
  bool* dp=new bool[k+1];
  int* A=new int[n]; 
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  for(int i=0;i<k+1;i++){
    dp[i]=false;
  	if(i==0)
      dp[i]=false;
    else{
    	for(int j=0;j<n;j++){
          	if(i>=A[j])
        		dp[i]=dp[i]||!dp[i-A[j]];
        }
    }
  }
  if(dp[k])
    cout<<"First"<<endl;
  else
    cout<<"Second"<<endl;
}


Measured memory_bytes: 3708
r1,c1,r2,c2=map(int,input().split())
r2+=1
c2+=1
N=2*(10**6)+2
mod=10**9+7
fac=[1]*(N+2)
inv=[1]*(N+2)
t=1
for i in range(1,N+2):
    t*=i
    t%=mod
    fac[i]=t
t=pow(fac[N+1],mod-2,mod)
for i in range(N+1,0,-1):
    inv[i]=t
    t*=i
    t%=mod
def comb(n,r):
    return fac[n]*inv[n-r]*inv[r]%mod
print((comb(r2+c2,c2)-comb(r2+c1,c1)-comb(r1+c2,c2)+comb(r1+c1,c1))%mod)

Measured memory_bytes: 71524
#include <bits/stdc++.h>
//#include <unordered_map>
#define M ((ll)1e12)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pi acos(-1)
typedef long long ll;
using namespace std;
set<int> s;set<pair<int,int>> s1;int n,m;int visited[100001]={0};

void solve(){
       int x,y;
       int s=0;
       cin>>x>>y;
       if(x==1&&y==1)
       s=400000;
       if(x==1)
       s+=300000;
       else if(x==2)
       s+=200000;
       else if(x==3)
       s+=100000;
       if(y==1)
       s+=300000;
       else if(y==2)
       s+=200000;
       else if(y==3)
       s+=100000;
       cout<<s<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int t,n[1000],count=0;
    scanf("%d",&t);
    for(int i=0; i<t; i++)
    {
        scanf("%d",&n[i]);
    }
    for(int j=0; j<t-2; j++)
    {
        if(n[j]>n[j+1] && n[j+1]>n[j+2])
            count++;
        if(n[j]<n[j+1] && n[j+1]<n[j+2])
            count++;
    }
    printf("%d\n",count);
}

Measured memory_bytes: 128
n, m = map(int, input().split())
x = []
for i in range(2**n):
    x.append(format(i, '011b'))
y = []
for _ in range(m):
    _, *s = map(int, input().split())
    y.append(s)
p = list(map(int, input().split()))
ans = 0
for i in range(2**n):
    f = 0
    for j in range(m):
        cnt = 0
        for k in y[j]:
            cnt += int(x[i][k - n - 1])
        if cnt % 2 == p[j]:
            f += 1
    if f == m:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
#define rep(i, a, b) for (int i = (a); i < (b); ++i)

int main()
{
  int n, max;
  cin >> n;
  vector<string> v(n), ans;
  map<string, int> mp1;
  rep(i, 0, n)
  {
    cin >> v[i];
  }
  rep(i, 0, n)
  {
    auto itr1 = mp1.find(v[i]);
    if (itr1 != mp1.end())
    {
      mp1[v[i]] += 1;
    }
    else
    {
      mp1[v[i]] = 1;
    }
  }
  max = 0;
  for (const auto x : mp1)
  {
    if (x.second == max)
    {
      ans.push_back(x.first);
    }
    else if (x.second > max)
    {
      max = x.second;
      ans.clear();
      ans.shrink_to_fit();
      ans.push_back(x.first);
    }
  }
  rep(i, 0, ans.size()) { cout << ans[i] << endl; }
  return 0;
}


Measured memory_bytes: 28404
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <cmath>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	int K, X; cin >> K >> X;

	int left = max(-1000000, X - K + 1);
	int right = min(1000000, X + K - 1);

	for (int i = left; i <= right; i++) cout << i << " ";
	cout << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 200001;

int n, fen[N];
vector <int> a;

void update(int ind, int val){
    ind++;
    while(ind <= 2 * n + 5){
        fen[ind] += val;
        ind += ind & -ind;
    }
}
int query(int ind){
    ind++;
    int ret = 0;
    while(ind >= 1){
        ret += fen[ind];
        ind -= ind & -ind;
    }
    return ret;
}
bool check(int m){
    vector <int> s;
    s.push_back(0);
    int cur = 0;
    for(int i = 0 ; i < n ; i++){
        cur += (a[i] >= m);
        s.push_back(2 * cur - (i + 1));
    }
    ll ret = 0;
    for(int i = 0 ; i < n + 1 ; i++){
        ret += query(s[i] + n);
        update(s[i] + n, 1);
    }
    for(auto &i : s){
        update(i + n, -1);
    }
    return 2 * ret >= 1LL * n * (n + 1) / 2;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    a.resize(n);
    for(auto &i : a) cin >> i;
    int l = 1, r = 1e9;
    while(l <= r){
        int mid = (l + r) / 2;
        if(check(mid)) l = mid + 1;
        else r = mid - 1;
    }
    cout << r << endl;
}


Measured memory_bytes: 2348
#include <cstdio>
#include <algorithm>

#define fin stdin
#define fout stdout

int a[100009];

int main(){
    int n;
    fscanf(fin, "%d", &n);

    for(int i = 1; i <= n; i ++)
        fscanf(fin, "%d", &a[i]);

    long long ans = 0;
    for(int i = 1; i <= n; i ++){
        ans += a[i] / 2;
        if(i < n && a[i] % 2 && a[i + 1] > 0)
            ans ++, a[i + 1] --;
    }

    fprintf(fout, "%lld\n", ans);

    return 0;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();

        if (N % 2 == 0) {
            System.out.println(N);
        } else {
            System.out.println(N * 2);
        }
    }
}


Measured memory_bytes: 23892
n = gets.to_i
a = [gets.chomp]
res = ""
(1..(n-1)).each do |i|
  tmp = gets.chomp
  if (a.include?(tmp)) || (a[i-1].chars.last != tmp.chars.first)
    res = 'No'
    break
  else
    a[i] = tmp
  end
end
res = 'Yes' if res != 'No'
puts res

Measured memory_bytes: 1788