akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

ll modpow(ll a, ll x)
{
    ll res = 1;
    while(x > 0)
    {
        if(x & 1) res = res * a % MOD;
        a = a * a % MOD;
        x >>= 1;
    }
    return res;
}

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

    ll N; cin >> N;
    vl A(N); REP(i, N) cin >> A[i];
    vl count(N); REP(i, N) count[A[i]]++;

    bool ok = true;
    if(N % 2 == 1 && count[0] != 1) ok = false;
    if(N % 2 == 0 && count[0] != 0) ok = false;
    for(int i = N-1; i > 0; i -= 2) if(count[i] != 2) ok = false;

    ll n = 0;
    for(int i = N-1; i > 0; i -= 2) n++;

    if(!ok) cout << 0 << endl;
    else cout << modpow(2LL, n) << endl;
}

Measured memory_bytes: 4776
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<vector<int>> d(n, vector<int> (2));
	for (int i = 0;i < n;i++) {
		cin >> d[i][0] >> d[i][1];
	}

	int count = 0;
	for (int i = 0;i < n;i++) {
		if (d[i][0] == d[i][1]) {
			count++;
			if (count >= 3) {
				cout << "Yes" << endl;
				return 0;
			}
		}
		else {
			count = 0;
		}
	}

	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3632
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

from bisect import bisect_left, bisect_right  # 二分探索
from collections import deque  # 双方向キュー

def main_ok():
    N = i2n()
    A = ii2nn(N)
    B = [1]
    for a in A:
        t = bisect_right(B, -a)
        if t < len(B):
            B[t] = -a
        else:
            B.append(-a)
    print(len(B))

def main():
    N = i2n()
    A = ii2nn(N)
    B = deque()
    B.appendleft(-1)
    for a in A:
        t = bisect_left(B, a)
        if t > 0:
            B[t-1] = a
        else:
            B.appendleft(a)
    print(len(B))

main()


Measured memory_bytes: 54236
import itertools


def judge(bits):
    for n in range(N):
        if not bits[n]:
            continue
        for s in X[n]:
            x, y = s
            # y = 1 なのに「不親切」だったらダメ
            if (y == 1 and (not bits[x - 1])):
                return 0
            # y = 0 なのに「正直者」だったらダメ
            if (y == 0 and bits[x - 1]):
                return 0
    return sum(bits)


N = int(input())
A = []
X = []
for _ in range(N):
    n = int(input())
    A.append(n)
    X.append([list(map(int, input().split())) for i in range(n)])

ans = []
for bits in itertools.product([False, True], repeat=N):
    ans.append(judge(bits))

print(max(ans))


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

#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))
#define MOD 1000000007

using namespace std;

using ll = long long;
const ll MAX = LLONG_MAX;
const ll MIN = LLONG_MIN;

typedef stack<ll> llStack;
typedef queue<ll> llQueue;
typedef vector<ll> llVector;
typedef list<ll> llList;

typedef struct S{
  int a;
  int b;
} Object;

int main(){
  ll N, M;
  cin >> N >> M;
  ll H[N];
  for(int i=0;i<N;i++){
    cin >> H[i];
  }
  bool good[N];
  for(int i=0;i<N;i++){
    good[i] = true;
  }
  ll A[M], B[M];
  for(int i=0;i<M;i++){
    cin >> A[i] >> B[i];
    if(H[A[i]-1] <= H[B[i]-1]){
      good[A[i]-1] = false;
    }
    if(H[A[i]-1] >= H[B[i]-1]){
      good[B[i]-1] = false;
    }
  }
  
  ll ans = 0;
  for(int i=0;i<N;i++){
    if(good[i]){
      ans++;
    }
  }
    
  
  
  
  cout << ans << endl;
  
}

Measured memory_bytes: 6064
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;

int main(void){
 int l,r;
 long long int N,M,a;
 long long int ans=0;
 long long int sum=0;
 long long int A[100050]; 
 map<long long int,long long int> B;

 for(int i=0; i<=100020;i++)A[i]=0;

 cin>>N>>M;
 for(int i=0; i<N; i++){
  cin>>a;
  A[i+1]=(A[i]+a)%M;
 }

 for(int i=0; i<=N; i++){
  ans+=B[A[i]];
  B[A[i]]++;
 }
 std::cout<<ans<<std::endl; 
}

Measured memory_bytes: 4992
n = int(input())
l = {}
count = 0

for i in range(n):
    s = ''.join(sorted(input()))
    if i == 0:
        l[s] = 1
        continue

    # ハッシュを確認し、登場していればcountを+l[s]、していなければハッシュに追加する
    if s in l:
        count+=l[s]
        l[s] += 1
    else:
        l[s] = 1

print (count)

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  string s;cin>>s;
  ll n=s.size();
  ll k;cin>>k;
  rep(i,0,n-1){
    if(s[i]=='a')continue;
    ll next='z'-s[i]+1;
    if(next<=k){
      k-=next;
      s[i]='a';
    }
  }
  s[n-1]=(s[n-1]-'a'+k)%26+'a';
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 592
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////

int main(){fastio
    dd l;cin>>l;
    cout<<setprecision(20)<<powl(l/3.0,3.0)<<endl;
    
    return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int x, a, b;
    cin >> x >> a >> b;
    x -= a;
    x = x % b;
    cout << x << endl;
    return 0;
}



Measured memory_bytes: 256
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100000, MAX_M = 200000;
int N, M;
int p[MAX_M], q[MAX_M], c[MAX_M];
vector<int> station[MAX_N+1];
                            
struct edge { 
  int to, cost; 
  edge(int t, int c) : to(t), cost(c) {};
};
const int MAX_V = 2*MAX_M+MAX_N, INF = 10000000;
                            
int V;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s) {
  fill(d, d+V, INF);
  priority_queue<pii, vector<pii>, greater<pii> > pque;
  d[s] = 0;
  pque.push(pii(0, s));


  while (!pque.empty()) {
    pii p = pque.top(); pque.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (int i = 0; i < (int)G[v].size(); ++i) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost; 
        pque.push(pii(d[v]+ e.cost, e.to));
      }
    }
  }
}

int main() {
  cin >> N >> M;
  rep(i,M) cin >> p[i] >> q[i] >> c[i];

  for (int i = 0; i < M; ++i) {
    station[p[i]].pb(c[i]); station[q[i]].pb(c[i]);
  }

  map<pii, int> node;
  V = 0;
  for (int i = 1; i <= N; ++i) {
    sort(all(station[i]));
    station[i].erase(unique(all(station[i])), station[i].end());
    int out = node[pii(i, 0)] = V++;
    for (int k = 0; k < station[i].size(); ++k) {
      int sta = node[pii(i, station[i][k])] = V++;
      G[out].push_back(edge(sta, 1));
      G[sta].push_back(edge(out, 0));
    }
  }

  for (int i = 0; i < M; ++i) {
    int sta1 = node[pii(p[i], c[i])], sta2 = node[pii(q[i], c[i])];
    G[sta1].push_back(edge(sta2, 0));
    G[sta2].push_back(edge(sta1, 0));
  }

  int s = node[pii(1, 0)], g = node[pii(N, 0)];

  
  dijkstra(s);

  if (d[g] >= INF) cout << -1 << endl;
  else cout << d[g] << endl;


  return 0;
}


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

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

    long ans = min(n, m / 2);
    if (n >= m / 2) {
        cout << ans << endl;
    } else {
        m -= 2 * ans;
        ans += m / 4;
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
int main(){
std::vector<int> vec;
while(1){
int n;
int sum=0;
std::cin>>n;
if(n==0) break;
int a[n/4];
for(int i=0;i<n/4;i++){
std::cin>>a[i];
sum+=a[i];
}
vec.push_back(sum);
}
for(int i;i<vec.size();i++){
std::cout<<vec[i]<<std::endl;
}
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  for (int i = 1; i <= 5; i++) {
    int x;
    cin >> x;
    if (!x) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3644
#!/usr/bin/env python

import sys

n= int( sys.stdin.readline() )
w= [ int(x) for x in sys.stdin.readline().split() ]

s1= 0
s2= sum(w)
diff= -1
for i in range(n-1):
    wi = w[i]
    s1+= wi
    s2-= wi
    dtmp = abs(s2-s1)
    if diff<0 or diff>dtmp: diff= dtmp
#
print( diff )


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


int main(){
  ll n,k;
  cin >> n>> k;
  long double upd=0.0,dwd=n;
  int maxg=0;

    for(int i=1;i<=n;i++){
      int tw=1;
    while(1){
    if(i*tw>=k){maxg=max(maxg,tw);upd+=maxg/tw;break;}else{tw*=2;}
    }
  }
  printf("%.12Lf\n",upd/(dwd*maxg));
}

Measured memory_bytes: 256
import itertools

n, m = map(int, input().split())
count = 0
light = [0] * m
sw = [[] for _ in range(n)]

for i in range(m):
    k, *s = map(int, input().split())
    for j in range(k):
        sw[s[j] - 1].append(i)
p = list(map(int, input().split()))

for pattern in itertools.product([0, 1], repeat=n):
    flag = True
    check = [0] * m
    for checkSW in range(n):
        if pattern[checkSW] == 1:
            for c in sw[checkSW]:
                check[c] += 1
    for q in range(m):
        if check[q] % 2 != p[q]:
            flag = False
    if flag:
        count += 1


print(count)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define forn(i, n) for (long long i = 0; i < (long long)(n); ++i)
#define for1(i, n) for (long long i = 1; i <= (long long)(n); ++i)
#define fore(i, l, r) for (long long i = (long long)(l); i <= (long long)(r); ++i)
#define fordn(i, n) for (long long i = (long long)(n) - 1; i >= 0; --i)
#define ford1(i, n) for (long long i = (long long)(n); i >= 1; --i)
#define all(x) (x).begin(), (x).end()
#define PI 3.141592653589793
using namespace std;
using ll = long long;
using ld = long double;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    cout << n / 3 << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
imos = [0]*(n+1)
for i in range(m):
    a,b = map(int,input().split())
    imos[a-1] += 1
    imos[b] -=1
for i in range(n):
    imos[i+1] += imos[i]
print(imos.count(m))

Measured memory_bytes: 6900
#include <iostream>


using namespace std;


int main()
{
    int K, S;
    cin >> K >> S;


    int ans = 0;
    for( int x = 0; x <= K; ++x ){
        for( int y = 0; y <= K; ++y ){
            if( 0 <= S-x-y && S-x-y <= K ) ++ans;
        }
    }


    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N,M;
    cin >> N >> M;
    ll i,j;
    pair<ll,ll> p[N+M];
    ll A;
    for(i=0;i<N;i++){
        cin >> A;
        p[i]=make_pair(A,1);
    }
    ll B,C;
    for(i=0;i<M;i++){
        cin >> B >> C;
        p[N+i]=make_pair(C,B);
    }
    sort(p,p+N+M);
    j=0;
    i=N+M-1;
    ll ans=0;
    while(j<N){
        ans+=p[i].first*min(N-j,p[i].second);
        j+=p[i].second;
        i--;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3328
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n, p := intScanner(), intScanner()
	a, b := 0, 0
	for i := 0; i < n; i++ {
		if intScanner()%2 == 0 {
			a++
		} else {
			b++
		}
	}
	ans := 1
	for i := 0; i < a; i++ {
		ans *= 2
	}
	x := make([]int, b+1)
	x[0] = 1
	for i := 1; i <= b; i++ {
		x[i] = x[i-1] * (b - i + 1) / i
	}
	c := 0
	if p == 0 {
		for i := 0; i <= b; i += 2 {
			c += x[i]
		}
	} else {
		for i := 1; i <= b; i += 2 {
			c += x[i]
		}
	}
	fmt.Println(ans * c)
}


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

using namespace std;

int n, m, a[105], ans = 0, cnt;

void display(int l, int r) { for(int i = l; i <= r; i++) printf("%d ", a[i]); printf("\n"); }

int main() {
    cin >> n >> m;
    for(int i = 0; i < m; i++) cin >> a[i];
    if(n == 1) return printf("1\n1\n1\n"), 0;
    if(m == 1) return printf("%d \n2 \n%d 1\n", n, n - 1), 0;
    sort(a, a + m, [](int x, int y) { return (x & 1) > (y & 1); });
    if(a[2] & 1) return printf("Impossible\n"), 0;
    cnt = (a[0] & 1) + (a[1] & 1);
    a[m] = a[0];
    if(cnt == 2) { 
        if(m == 2) {
            printf("%d %d\n", a[0], a[1]);
            if(a[1] == 1) {
                printf("1\n");
                printf("%d\n", a[0] + 1);
            }
            else {
                printf("2\n");
                printf("%d %d\n", a[0] + 1, a[1] - 1);
            }
            return 0;
        }
        sort(a + 2, a + m);
        if(1) {
            display(1, m);
            if(a[1] == 1) {
                printf("%d \n", m - 1);
                for(int i = 2; i < m; i++) printf("%d ", a[i]); 
                printf("%d\n", a[m] + 1);   
            }
            else {
                printf("%d \n", m);
                printf("%d ", a[1] - 1);
                for(int i = 2; i < m; i++) printf("%d ", a[i]); 
                printf("%d\n", a[m] + 1);
            }
        }
    }
    else if(cnt == 1) {
        sort(a + 1, a + m);
        if(a[m - 1] - 2 == 0) {
            display(0, m - 1);
            m--;
            printf("%d \n", m + 1);
            printf("%d ", a[0] + 1);
            for(int i = 1; i < m; i++) printf("2 ");
            printf("1\n");
        }
        else {
            display(0, m - 1);
            m--;
            printf("%d \n", m + 2);
            printf("%d ", a[0] + 1);
            for(int i = 1; i < m; i++) printf("%d ", a[i]); 
            printf("1 ");
            printf("%d\n", a[m] - 2);
        }
    }
    else {
        sort(a + 1, a + m + 1);
        if(a[m] - 2 == 0) {
            display(1, m);
            printf("%d \n", m + 1);
            printf("1 ");
            for(int i = 1; i < m; i++) printf("2 "); 
            printf("1\n");
        }
        else {
            display(1, m);
            printf("%d \n", m + 2);
            printf("1 ");
            for(int i = 1; i < m; i++) printf("%d ", a[i]); 
            printf("1 ");
            printf("%d\n", a[m] - 2);
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int X;
    cin >> X;

    if (X >= 30) yes;
    else no;
    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc174/abc174_a && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc174/abc174_a && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc174/abc174_a && sh shellscripts/submit_cpp.sh
*/


Measured memory_bytes: 3636
import java.util.Scanner;

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

        int K = Integer.parseInt(sc.next());
        String S = sc.next();

        if (S.length() <= K) {
            System.out.println(S);
            return;
        }
        S = S.substring(0, K);
        System.out.println(S + "...");

    }
}


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, X, Y;
	cin >> n >> m >> X >> Y;
	vector<int> x(n);
	vector<int> y(m);
	rep(i, n) cin >> x[i];
	rep(i, m)cin >> y[i];
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	bool elf = false;
	for (int i = X + 1; i <= Y; ++i) {
		if (i > x[n - 1] && i <= y[0]) elf = true;
	}
	if (elf) cout << "No War" << endl;
	else cout << "War" << endl;
	return 0;
}

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

using namespace std;

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

  unordered_set<int> s;
  int n; cin>>n;
  bool ans = true;
  for (int i = 0; i < n; i++) {
    int a; cin>>a;
    if (s.count(a) == 1)
      ans = false;
    s.insert(a);
  }
  cout << (ans ? "YES" : "NO") << endl;

  return 0;
}


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

int main(void)
{
	while(1)
	{
		int num, action;
		cin>>num>>action;
		if(num == 0 && action == 0)
			break;

		vector<int> cards(num);
		for(int i= 0; i < num; i++)
			cards[i]= num-i;

		for(int i= 0; i < action; i++)
		{
			int startc, numc;
			cin>>startc>>numc;
			vector<int> res(num);

			for(int j= 0; j < numc; j++)
				res[j]= cards[startc-1+j];
			for(int j= 0; j < startc-1; j++)
				res[numc+j]= cards[j];
			for(int j= startc+numc-1; j < num; j++)
				res[j]= cards[j];
			for(int j= 0; j < num; j++)
				cards[j]= res[j];
		}
		cout<<cards[0]<<endl;
	}
}

Measured memory_bytes: 3100
#include <iostream>

using namespace std;

int main() {
    int N;
    while (cin >> N) {
        if (!N) { break; }

        int ans = 0, t = 0;

        for (int i = 1; i < N; i++) {
            t = i;
            for (int j = i+1; j < N; j++) {
                t += j;
                if (t == N) {
                    ans++;
                    break;
                }
                else if (t > N) {
                    break;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 2992
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

//***********************************
//mintを定義
//***********************************
const int mod = 1000000007;
struct mint {
  int x;
  mint(int x=0):x(x%mod){}   //メンバ変数xをx%modで初期化
  int get() const { return (int)x; }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;           //thisは暗黙的に左辺のポインタ
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
 
  //累乗
  mint mpow(int t) const {
    if (!t) return 1;
    mint a = mpow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  //除算
  mint minv() const {
    return mpow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.minv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
//標準出力
ostream& operator<<(ostream& st, const mint a) 
{ st << a.get(); return st; };
//--------------------------------------------------
 
//***********************************
//場合の数の計算
//***********************************
const int MAX = 200010;
mint fac[MAX], finv[MAX];
 
//前計算
inline void INIT_F(){
    fac[0] = finv[0] = 1;
    for(int i=1; i<MAX-1; i++) {
        fac[i] = (fac[i-1]*mint(i));
        finv[i] = (finv[i-1]/mint(i));
    }
}
 
//nCk
mint mcomb(int n, int k) {
    if(n<k || k<0) return 0;
    else return ((fac[n]*finv[k])*finv[n-k]);
}
 
//nHk
mint mhcomb(int n, int k) {
  return mcomb(n+k-1, k);
}
//--------------------------------------------------

signed main() {
    int N, K;
    cin >> N >> K;
    
    V(mint) sums(N+2, 0);
    rep(i, N+1) {
        sums[i+1] = sums[i]+i;
    }

    mint res = 0;
    for(int i=K; i<=N+1; i++) {
        res += (sums[N+1]-sums[N+1-i])-sums[i]+1;
        //cout << sums[N+1]-sums[N+1-i] << " " << res << endl;
    }

    cout << res << endl;

    return 0;
}

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

int main(){
  int a,b;
  cin>>a>>b;
  map<int,int> v1;
  for(int i=1;i<=1000;i++){
    if((int)(i*(0.08))==a)
       v1[i]=1;
  }
  for(int i=1;i<=1000;i++){
    if((int)(i*(0.1))==b){
      if(v1[i]==1){
        cout<<i;
        return 0;
      }
    }
  }
  cout<<-1;
}


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

int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    while(1){
        if(k==0)break;
        if(a>=b)b*=2,k--;
        else break;
    }
    while(1){
        if(k==0)break;
        if(b>=c)c*=2,k--;
        else break;
    }
    if(a<b&&b<c)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3624
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] arr = new int[100_001];
            int ans = 0;
            for (int i = 0; i < n; i++) {
                int x = in.nextInt();
                arr[x]++;
                if (x + 1 <= 100_000) arr[x + 1]++;
                if (x - 1 >= 0) arr[x - 1]++;
            }
            for (int i = 0; i < arr.length; i++) ans = Math.max(ans, arr[i]);
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 34024
using System;
using System.Collections.Generic;
using System.Linq;

namespace ALDS1_6_D
{
    class Program
    {
        static int MIN;
        static int n = 0;
        static bool[] vis = new bool[1001];
        static void Main(string[] args)
        {
            Console.ReadLine();
            var a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse).ToList();
            var b = new List<int>(a);
            b.Sort();
            MIN = b[0];
            for (int i = 0; i < a.Count; i++)
            {
                if (!vis[i])
                {
                    vis[i] = true;
                    Check(a[i], i, a, b, new List<int>() { i });
                }
            }
            Console.WriteLine(n);
        }

        static void Check(int target, int p, List<int> a, List<int> b, List<int> temp)
        {
            var pb = b.IndexOf(a[p]);
            if (pb == p) return;
            if (a[pb] == target)
            {
                var min = a[temp[0]];
                var mini = 0;
                for (int i = 1; i < temp.Count; i++)
                    if (a[temp[i]] < min)
                    {
                        min = a[temp[i]];
                        mini = temp[i];
                    }
                int sum = 0;
                foreach (var i in temp)
                {
                    vis[i] = true;
                    if (i != mini) sum += a[i] + min;
                }
                int sum2 = 0;
                foreach (var i in temp)
                {
                    sum2 += a[i] + MIN;
                }
                sum2 += min + MIN;
                n += sum < sum2 ? sum : sum2;
                return;
            }
            else temp.Add(pb);
            Check(target, pb, a, b, temp);
        }
    }
}

Measured memory_bytes: 10272
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 123456789012


#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)

template <class T>
class SegTree {
    int n;                       // 葉の数
    vector<T> data;              // データを格納するvector
    T def;                       // 初期値かつ単位元
    function<T(T, T)> operation; // 区間クエリで使う処理
    function<T(T, T)> update;    // 点更新で使う処理

    // 区間[a,b)の総和。ノードk=[l,r)に着目している。
    T _query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return def; // 交差しない
        if (a <= l && r <= b)
            return data[k]; // a,l,r,bの順で完全に含まれる
        else {
            T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子
            T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子
            return operation(c1, c2);
        }
    }

  public:
    // _n:必要サイズ, _def:初期値かつ単位元, _operation:クエリ関数,
    // _update:更新関数
    SegTree(size_t _n, T _def, function<T(T, T)> _operation,
            function<T(T, T)> _update)
        : def(_def), operation(_operation), update(_update) {
        n = 1;
        while (n < _n) {
            n *= 2;
        }
        data = vector<T>(2 * n - 1, def);
    }

    // 場所i(0-indexed)の値をxで更新
    void change(int i, T x) {
        i += n - 1;
        data[i] = update(data[i], x);
        while (i > 0) {
            i = (i - 1) / 2;
            data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }

    // [a, b)の区間クエリを実行
    T query(int a, int b) {
        return _query(a, b, 0, 0, n);
    }

    // 添字でアクセス
    T operator[](int i) {
        return data[i + n - 1];
    }
};

int main(){
    ll i,j;
	ll n,k;
	cin>>n>>k;
	ll p[n];

	SegTree<ll> st1(n,0,
				[](ll a,ll b){return max(a,b);},
				[](ll a,ll b){return b;});
	SegTree<ll> st2(n,n-1,
				[](ll a,ll b){return min(a,b);},
				[](ll a,ll b){return b;});

	for(i=0;i<n;i++){
		cin>>p[i];
		st1.change(i,p[i]);
		st2.change(i,p[i]);
	}

	ll z=1;
	vector<bool> f(n,0);
	int ans=0;
	for(i=1;i<n;i++){
		if(p[i]>p[i-1]) z++;
		else z=1;
		if(z>=k) {
			f[i-k+1]=1;
			if(ans==0) ans=1;
		}
	}

	ll te=0;
	while(te<=n-k){
		while(f[te]) {
			te++;
		}
		if(te>n-k) break;
 		bool flag=0;
		ll zu=1;
		ll te2=te;
		ans++;
		while(1){
			if(te+k+zu>n){
				flag=1;
				te2=te+zu;
				break;
			}
			if(st1.query(te+zu,te+k+zu)!=p[te+k+zu-1]) {
				te2=te+zu;
				flag=1;
				break;
			}
			if(st2.query(te+zu-1,te+k+zu-1)!=p[te+zu-1]) {
				te2=te+zu;
				flag=1;
				break;
			}
			zu++;
		}
		te=te2;
	}
	cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 12032
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <tuple>
using namespace std;

using int64 = long long;

#define repeat(i, n) for (auto i = decltype(n)(); (i) < (n); (i)++)

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

  int n;
  cin >> n;

  using State = tuple<int64, int64, int64>;

  vector<State> seq;
  repeat (i, n) {
    int64 a, b;
    cin >> a >> b;
    seq.emplace_back(a + b, a, b);
  }
  sort(seq.begin(), seq.end(), greater<State>());

  int64 asum = 0, bsum = 0;
  repeat (i, n) {
    int64 a, b;
    tie(ignore, a, b) = seq[i];

    if (i % 2 == 0) asum += a;
    else bsum += b;
  }
  cout << asum - bsum << endl;

  return 0;
}



Measured memory_bytes: 4852
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> ipair;
typedef tuple<int, int, int> ituple;

// const int INF = INT_MAX;
// const ll INF = LLONG_MAX;
// const int MOD = ((int)1e9 + 7);
// const ld EPS = (1e-10);
#define PI acosl(-1)
#define MAX_N (100000 + 2)

void exec(){
  int n, a, b;
  cin >> n >> a >> b;

  printf("%d %d\n", min(a, b), max((a + b) - n, 0));

}

void solve(){
  int t = 1;
  // scanf("%d", &t);
  for (int i = 0; i < t; i++){
    exec();
  }
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }
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;
}

#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;


typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int N, M;
    cin >> N >> M;

    int P[100000] ,Y[100000];
    vector<int> yd[100001];

    REP(i,M) {
        cin >> P[i] >> Y[i];
        yd[P[i]].emplace_back(Y[i]);
    }
    REP(i,N)sort(yd[i+1].begin() ,yd[i+1].end());
    REP(i,M)printf("%012lld\n",ll(P[i])*1000000+int(lower_bound(yd[P[i]].begin(),yd[P[i]].end(),Y[i]) - yd[P[i]].begin())+1);
    

    return 0;
}

Measured memory_bytes: 7808
X, N = [int(_) for _ in input().split()]
P = [int(_) for _ in input().split()]

d = 1000
ans = None
for i in range(-101, 201):
    if i in P:
        continue
    if abs(X-i) < d:
        d = abs(X-i) 
        ans = i
print(ans)


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

int main() {
  int N,s=0;
  cin>>N;
  bool flag=false;
  int a[N];
  for(int i=0;i<N;i++) cin>>a[i];
  while(true){
 	for(int i=0;i<N;i++){
    if(a[i]%2==0) a[i]/=2;
      else flag=true;
    }
  if(flag==true) break;
  s++;
  }
  cout<<s<<endl;
}

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (int i = j; i < (n); i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1e9;

int main(){

  int n;cin>>n;
  int a[n+10];
  a[0]=0;
  rep(i,0,n)cin>>a[i+1];
  a[n+1]=0;
  vector<int>v(n+10,0);

  int sum=0;
  rep(i,0,n+1){
    v[i]=abs(a[i+1]-a[i]);
    sum+=v[i];
  }

  rep(i,1,n+1){
    if((a[i-1]<a[i]&&a[i]<a[i+1])||(a[i-1]>a[i]&&a[i]>a[i+1])){
      out(sum);
    }else{
      out(sum-2*min(v[i-1],v[i]));
    }
  }

  return 0;
}


Measured memory_bytes: 2048
N, M = map(int, input().split())
G = [[] for _ in range(N)]
edges = []
for _ in range(M):
    a, b = map(int, input().split())
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)
    edges.append([a - 1, b - 1])

def dfs(u, seen, e):
    seen[u] = True
    for v in G[u]:
        if seen[v] == True:
            continue
        if [u, v] == e or [v, u] == e:
            continue
        dfs(v, seen, e)

ans = 0
for e in edges:
    seen = [False] * N
    dfs(e[0], seen, e)
    if seen[e[1]] == False:
        ans += 1

print(ans)

Measured memory_bytes: 40940
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (transpose, (\\))

main :: IO ()
main = do
  ass <- sequence . replicate 3 $ map unsafeTextToInt . T.words <$> T.getLine :: IO [[Int]]
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  bs <- sequence . replicate n $ unsafeTextToInt <$> T.getLine :: IO [Int]
  let
    rs = ass
    cs = transpose ass
    ds = [map (\i -> ass !! i !! i) [0..2], map (\i -> ass !! (2 - i) !! i) [0..2]]
  putStrLn $ if (any null . map (\\ bs) $ rs ++ cs ++ ds) then "Yes" else "No"

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


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

using namespace std;

int n=100010;
bool p[100010],p1[100010];
int num[100010];
int q,l,r;

int main(){
	int i,j;
	for (i=2;i<=n;i++)p[i]=1;
	for (i=2;i<=n;i++){
		if (p[i]){
			for (j=i+i;j<=n;j+=i){
				p[j]=0;
			}
		}
	}
	for (i=3;i<=n;i++)if (p[i] && p[(i+1)/2])p1[i]=1;
	for (i=2;i<=n;i++)num[i]=num[i-1]+p1[i];
	cin>>q;
	while (q--){
		cin>>l>>r;
		cout<<num[r]-num[l-1]<<endl;
	}
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int p=1000000007;
template<int mod>
struct ModInt{
	int x;

	ModInt() : x(0){}
	ModInt(long long y) : x(y>=0 ? y%mod : (mod-(-y)%mod)){}

	ModInt &operator+=(const ModInt &p){
		if((x+=p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator-=(const ModInt &p){
		if((x+=mod-p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator*=(const ModInt &p){
		x=(int)(1LL*x*p.x%mod);
		return *this;
	}
	ModInt &operator/=(const ModInt &p){
		*this*=p.inverse();
		return *this;
	}

	ModInt operator-() const{return ModInt(-x);}
	ModInt operator+(const ModInt &p) const{return ModInt (*this)+=p;}
	ModInt operator-(const ModInt &p) const{return ModInt (*this)-=p;}
	ModInt operator*(const ModInt &p) const{return ModInt (*this)*=p;}
	ModInt operator/(const ModInt &p) const{return ModInt (*this)/=p;}
	bool operator==(const ModInt &p) const{return x==p.x;}
	bool operator!=(const ModInt &p) const{return x!=p.x;}
	friend ostream &operator<<(ostream &os, const ModInt &p){return os<<p.x;}
	friend istream &operator>>(istream &is,ModInt &a){
		int t;
		is>>t;
		a=ModInt<mod>(t);
		return (is);
	}

	ModInt inverse() const{
		int a=x, b=mod, u=1, v=0, t;
		while(b>0){
			t=a/b;
			a-=t*b;
			swap(a,b);
			u-=t*v;
			swap(u,v);
		}
		return ModInt(u);
	}
	
	ModInt pow(int e) const{
		long long a=1,p=x;
		while(e>0){
			if(e%2==0){p=(p*p)%mod; e/=2;}
			else {a=(a*p)%mod; e--;}
		}
		return ModInt(a);
	}
};

using modint=ModInt<p>;

signed main(){
    string S; cin>>S;
    int N=S.size();
    vector<vector<modint>> dp(N+100,vector<modint>(13,0));
    dp[0][0]=1;
    for(int i=0;i<N;i++){
        for(int j=0;j<13;j++){
            if(S[i]=='?'){
                for(int k=0;k<=9;k++){
                    dp[i+1][(j*10+k)%13]+=dp[i][j];
                }
            }
            else {
                int t=S[i]-'0';
                dp[i+1][(j*10+t)%13]+=dp[i][j];
            }
        }
    }
    cout<<dp[N][5]<<endl;


}

Measured memory_bytes: 13696
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

int main()
{
    int a,b;
    cin >> a >> b;
    cout << (a + b + 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
H, W = map(int,input().split())

import numpy as np

matrix = np.empty((0, W), str)
for i in range(0, H):
    matrix = np.append(matrix, np.array([list(input())]), axis = 0)
matrix = matrix[:, np.any(matrix != ".", axis = 0)]
matrix = matrix[np.any(matrix == "#", axis = 1), :]
H, W = matrix.shape
for i in range(0, H):
    print(''.join(matrix[i, :]))

Measured memory_bytes: 12520
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>
#include <iomanip>

using namespace std;

#define ll long long
#define vi vector<int>
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pi 3.14159265359


ll gcd(ll a, ll b)
{
	ll c;
	while (a != 0) {
		c = a; a = b % a;  b = c;
	}
	return b;
}

int main() {
	string S;
	ll zero = 0;
	ll one = 0;
	cin >> S;
	REP(i, S.length()) {
		if (S[i] == '0') {
			zero++;
		}
		if (S[i] == '1') {
			one++;
		}
	}
	cout << min(zero, one) * 2;

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    double a[n];
    for(int i=0;i<n;i++)
       cin>>a[i];
    sort(a,a+n);
    double sum=0;
    for(int i=1; i<n; i++)
        a[i]=(a[i]+a[i-1])/2;;
    cout<<a[n-1]<<endl;

}


Measured memory_bytes: 3732
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<string>
#include<map>
#include<set>

#define INF 100000001
using namespace std;
typedef long long ll;
int h, w;
vector<vector<bool>> s;
bool hantei(int i, int j) {
	if (s[i][j] == false) {
		return true;
	}
	if (i > 0) {
		if (s[i - 1][j] == true) {
			return true;
		}
	}
	if (j > 0) {
		if (s[i][j - 1] == true) {
			return true;
		}
	}
	if (i + 1 < h) {
		if (s[i + 1][j] == true) {
			return true;
		}
	}
	if (j + 1 < h) {
		if (s[i][j + 1] == true) {
			return true;
		}
	}
	return false;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> h >> w;
	s = vector<vector<bool>>(h, vector<bool>(w, false));
	char str;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> str;
			if (str == '#') {
				s[i][j] = true;
			}
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (hantei(i, j) == false) {
				cout << "No";
				return 0;
			}
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
open Scanf
open Printf
open Char

let diagonal s1 s2 s3 = (escaped s1.[0]) ^ (escaped s2.[1]) ^ (escaped s3.[2])

let (s3 ,s2, s1) = (read_line (), read_line (), read_line ())
let () = printf "%s\n" @@ diagonal s1 s2 s3

Measured memory_bytes: 3480