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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 200007;

int n;
int a[MAXN];
int fa[MAXN];
int dsu[MAXN];
int c0[MAXN], c1[MAXN];

void init ();
void input ();
void work ();

int getfa ( int now )
{
	return dsu[now] ? ( dsu[now] = getfa ( dsu[now] ) ) : now;
}

struct cmp
{
	bool operator () ( int i, int j )
	{
		LL vl = SC ( LL, c0[i] ) * c1[j], vr = SC ( LL, c1[i] ) * c0[j];
		return ( vl ^ vr ) ? ( vl > vr ) : ( i < j );
	}
};



int main()
{
	init();
	input();
	work();
}



void init ()
{
	// Init Everything Here
	
	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method
	
	scanf ( "%d", &n );
	lpi ( i, 2, n ) scanf ( "%d", &fa[i] );
	lpi ( i, 1, n ) scanf ( "%d", &a[i] );
}

void work ()
{
	// main work
	
	lpi ( i, 1, n ) ++ ( a[i] ? c1[i] : c0[i] );
	
	set < int, cmp > s;
	lpi ( i, 2, n ) s.insert ( i );
	
	LL ans = 0;
	int now, nf;
	lp ( _t, 1, n ){
		now = *s.begin ();
		s.erase ( now );
		nf = getfa ( fa[now] );
//		cerr << now << " " << nf << endl;
		if ( nf ^ 1 ) s.erase ( nf );
		ans += SC ( LL, c1[nf] ) * c0[now];
		c0[nf] += c0[now], c1[nf] += c1[now];
		dsu[now] = nf;
		if ( nf ^ 1 ) s.insert ( nf );
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 15104
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n'; cout << fixed << setprecision(10);

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	if (s == "AAA" || s == "BBB")cout << "No";
	else cout << "Yes";
}

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

int main(void)
{
  int n;
  cin >> n;
  int cnt = 0;
  for(int i = 104; i <= n; i++)
  {
    int sum = 0;
    if(i % 2 == 1)
    {
      for(int j = 1; j <= i ; j++)
      {
        if(i % j == 0)
        {
          sum++;
        }
      }
      if(sum == 8)
      {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
[n, a, b] = map(int, input().split())

def somesum(x):
    return sum([int(v) for v in str(int(x))])

res = 0
for i in range(n):
    w = somesum(i + 1)
    if a <= w <= b:
        res += (i + 1)

print(res)

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
using namespace std;

ll a, b, n;
int main() {
	cin >> a >> b >> n;
	ll x = b-1;
	if(x > n) x = n;
	cout << floor(a*x/b) - a*floor(x/b) << endl;
	return 0;
}


Measured memory_bytes: 3260
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    static int N;
    static int M;
    static int[][] graph;
    static int INF = Integer.MAX_VALUE;

    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();
        M = scanner.nextInt();

        graph = new int[N][N];
        for(int i = 0; i < N; i++) {
            for(int j = 0; j < N; j++) {
                graph[i][j] = INF;
            }
        }

        for(int i = 0; i < M; i++) {
            int from = scanner.nextInt() - 1;
            int to = scanner.nextInt() - 1;

            graph[from][to] = to;
            graph[to][from] = from;
        }

        scanner.close();

        HashSet<Integer> passed = new HashSet<>();
        passed.add(0);
        System.out.println(dfs(0, passed));
    }

    static int dfs(int i, HashSet<Integer> passed) {
        if(N <= passed.size()) return 1;

        int ret = 0;
        for(int to: graph[i]) {
            if(to != INF && !passed.contains(to)) {
                passed.add(to);
                ret += dfs(to, passed);
                passed.remove(to);
            }
        }

        return ret;
    }
}


Measured memory_bytes: 21844
N = int(input())
H = list(map(int, input().split()))
 
for i in range(N-1, 0, -1):
    if H[i-1] - H[i] == 1:
        H[i-1] -= 1
    elif H[i-1] - H[i] > 1:
        flag = False
        print('No')
        break
else:
    print('Yes')

    

Measured memory_bytes: 14396
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scanln(&n)

	cards := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &cards[i])
	}
	// fmt.Println(n, cards)

	sort.IntSlice(cards).Sort()
	// fmt.Println(cards)

	alicePoint := 0
	bobPoint := 0
	i := n - 1
	for i >= 0 {
		alicePoint += cards[i]
		i--
		if i >= 0 {
			bobPoint += cards[i]
			i--
		}
	}

	fmt.Println(alicePoint - bobPoint)
}


Measured memory_bytes: 512
#include <cstdio>
#include <vector>

using namespace std;

vector <int> v[100000];

int main() {
    int n, m, c = 0, i, j;
    
    scanf("%d %d", &n, &m);
    
    for (i = 0; i < m; i++) {
        int a, b;
        
        scanf("%d %d", &a, &b);
        
        a--;
        b--;
        
        v[a].push_back(b);
        v[b].push_back(a);
    }
    
    for (i = 0; i < n; i++) {
        if (v[i].size() % 2 == 1) {
            puts("No");
            return 0;
        }
    }
    
    for (i = 0; i < n; i++) {
        if (v[i].size() >= 6) {
            puts("Yes");
            return 0;
        } else if (v[i].size() == 4) {
            c++;
        }
    }
    
    if (c >= 3) {
        puts("Yes");
        return 0;
    } else if (c <= 1) {
        puts("No");
        return 0;
    }
    
    for (i = 0; i < n; i++) {
        int x, y;
        
        if (v[i].size() != 2) continue;
        
        x = v[i][0];
        y = v[i][1];
        
        if (x == y) {
            puts("Yes");
            return 0;
        }
        
        for (j = 0; j < v[x].size(); j++) {
            if (v[x][j] == i) v[x].erase(v[x].begin() + j);
        }
        
        for (j = 0; j < v[y].size(); j++) {
            if (v[y][j] == i) v[y].erase(v[y].begin() + j);
        }
        
        v[i].clear();
        v[x].push_back(y);
        v[y].push_back(x);
    }
    
    puts("No");
    
    return 0;
}


Measured memory_bytes: 5760
n=int(input())
P=list(map(float,input().split()))

dp=[[0]*(n+1) for _ in range(n+1)]
dp[0][0]=1
for i in range(1,n+1):
    p=P[i-1]
    for j in range(n+1):
        if j==0:
            dp[i][j]=dp[i-1][j]*(1-p)
        else:
            dp[i][j]=dp[i-1][j-1]*p+dp[i-1][j]*(1-p)

print(sum(dp[n][n//2+1:]))


Measured memory_bytes: 259464
w,h,n = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(n)]
xmin = 0
ymin = 0
xmax = w
ymax = h
for i in range(n):
    if l[i][2] == 1:
        xmin = max([xmin,l[i][0]])
    elif l[i][2] == 2:
        xmax = min([xmax,l[i][0]])
    elif l[i][2] == 3:
        ymin = max([ymin,l[i][1]])
    elif l[i][2] == 4:
        ymax = min([ymax,l[i][1]])
if xmax <= xmin or ymax <= ymin:
    print(0)
else:
    print((xmax - xmin) * (ymax - ymin))

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  // ll N; cin >> N;
  ll N, K; cin >> N >> K;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  // string s; cin >> s;
  vector<ll> a(N); rep(i, N) cin >> a[i];
  map<ll,ll> lmap;
  rep(i, N) {
    lmap[a[i]] ++;
  }
  vector<pair<ll,ll>> vpll;
  for(auto itr : lmap) {
    vpll.push_back({itr.second, itr.first});
  }
  sort(vpll.begin(), vpll.end());

  
  ll l = (ll)vpll.size() - K;
  ll ans = 0;
  rep(i, l) {
    ans += vpll[i].first;
  }
  


  cout << ans << endl;

}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 21348
#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);

    vector<P> v(5);
    for(int i = 0; i < 5; ++i) {
        cin >> v[i].F;
        v[i].S = 10 - (v[i].F % 10);
        if(v[i].S == 10) v[i].S = 0;
        swap(v[i].F, v[i].S);
    }
    sort(all(v));
    int res = 0;
    for(int i = 0; i < 5; ++i) {
        swap(v[i].F, v[i].S);
        res += v[i].F + v[i].S;


    }
    cout << res - v[4].S << endl;
    return 0;
}



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

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a<=b){
        if(d<=c){
            std::cout << a+d << std::endl;
        }
        else {
            std::cout << a+c << std::endl;
        }
    }
    else{
        if(c<=d){
            std::cout << b+c << std::endl;
        }
        else{
            std::cout << b+d << std::endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3608
#!/usr/bin/env python3
n, k, c = map(int, input().split())
s = input()

if c == 0:
    if s.count("o") == k:
        for i in range(n):
            if s[i] == "o":
                print(i + 1)
    exit()

left = []
i = 0
while i < n:
    if s[i] == "o":
        left.append(i)
        i += c
    i += 1

right = []
i = n - 1
while i >= 0:
    if s[i] == "o":
        right.append(i)
        i -= c
    i -= 1
right.reverse()
for i in range(len(left)):
    if left[i] == right[i]:
        print(left[i] + 1)


Measured memory_bytes: 5584
#include <stdio.h>
#define DATA_NUM (10)

int main(void)
{
  int mountains[DATA_NUM];
  int i, j, tmp;

  for(i=0; i<DATA_NUM; i++)
		  scanf("%d\n", &mountains[i]);

  for(i=0; i<DATA_NUM-1;i++)
  {
		  for(j=DATA_NUM-1; j>i; j--)
		  {
		    if(mountains[j-1] > mountains[j]) 	  
			{
			  tmp = mountains[j];
			  mountains[j] = mountains[j-1];
			  mountains[j-1] = tmp;
			}
		  }
  } 			  

  printf("%d\n%d\n%d\n",mountains[DATA_NUM-1]
		 ,mountains[DATA_NUM-2],mountains[DATA_NUM-3]);

  return 0;		
}

Measured memory_bytes: 604
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

#define N 100000

int a[N][2];
int v[N];

bool fnl(int p, int q) {
    return a[p][1] < a[q][1];
}

bool fnr(int p, int q) {
    return a[p][0] > a[q][0];
}

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

    int n = gi();
    memset(v, 0, sizeof(v));
    list<int> l, r;
    for (int i = 0; i < n; i++) {
        a[i][0] = gi();
        a[i][1] = gi();
        l.push_back(i);
        r.push_back(i);
    }

    l.sort(fnl);
    r.sort(fnr);

    ll res = 0;
    int c = 0;
    list<int>::iterator itl = l.begin(), itr = r.begin();
    for (int i = 0; i < n; i++) {
        while (v[*itl])
            itl++;
        while (v[*itr])
            itr++;

        int d1 = c - a[*itl][1];
        int d2 = a[*itr][0] - c;

        if (d1 < 0 && d2 < 0) {
            v[*itl] = 1;
        } else if (d1 > d2) {
            v[*itl] = 1;
            res += d1;
            c = a[*itl][1];
        } else {
            v[*itr] = 1;
            res += d2;
            c = a[*itr][0];
        }
    }

    res += (c < 0 ? -c : c);

    itl = l.begin();
    itr = r.begin();
    if (a[*itl][1] <= 0 && a[*itr][0] >= 0) {
        memset(v, 0, sizeof(v));
        ll res2 = 0;
        if (-a[*itl][1] < a[*itr][0]) {
            c = a[*itl][1];
            res2 = -c;
            v[*itl] = 1;
        } else {
            c = a[*itr][0];
            res2 = c;
            v[*itr] = 1;
        }

        for (int i = 1; i < n; i++) {
            while (v[*itl])
                itl++;
            while (v[*itr])
                itr++;

            int d1 = c - a[*itl][1];
            int d2 = a[*itr][0] - c;

            if (d1 < 0 && d2 < 0) {
                v[*itl] = 1;
            } else if (d1 > d2) {
                v[*itl] = 1;
                res2 += d1;
                c = a[*itl][1];
            } else {
                v[*itr] = 1;
                res2 += d2;
                c = a[*itr][0];
            }
        }

        res2 += (c < 0 ? -c : c);

        res = MAX(res, res2);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 9728
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }


int main(){
    int n, l;
    cin >> n >> l;
    vector <int> v;
    for(int i = 1; i <= n; i++){
        v.push_back(l + i - 1);
    }
    int sum = accumulate(all(v), 0);
    int res = 0;
    int mn = mod;
    for(int i = 0; i < n; i++){
        int sum1 = 0;
        for(int j = 0; j < n; j++){
            if(i == j)
                continue;
            sum1 += v[j];
        }   
        if(abs(sum1 - sum) < mn){
            mn = abs(sum1 - sum);
            res = sum1;
        }
    }
    cout << res;
}

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

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

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

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

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

ll gcd(ll a,ll b){
	if(a<b){
		swap(a,b);
	}

	while(ll r=(a%b)){
		a = b;
		b = r;
	}
	return b;
}

// ユークリッドの互除法により最小公倍数を求める min(a,b)>=1である必要がある
ll lcm(ll a,ll b){
	return a*b/gcd(a,b);
}

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

	int A=in(),B=in();
	out(lcm(A,B));
	return 0;
}

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

int a[100009];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, k; cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	int ans = 2000000000;
	for (int i = 0; i < n - k + 1; i++)
		ans = min(ans, a[i + k - 1] - a[i]);
	cout << ans << '\n';
	return 0;
}

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

using namespace std;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000

//#define DEBUG

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

int main()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, mmax = 0, res = 0;
	cin >> n;
	lp(i, n){
		int num;
		cin >> num;
		if(num >= mmax){
			++res;
			mmax = num;
		}
	}
	cout << res;
	return 0;
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a.at(i);
    int now = 0, cnt = 0;
    rep(i, N) a.at(i)--;

    while (1){
        if(now==1){
            cout << cnt << endl;
            break;
        }
        if(cnt>=N){
            cout << "-1" << endl;
            break;
        }
        cnt++;
        now = a.at(now);
    }

    return 0;
}


Measured memory_bytes: 640
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())
d = a1*t1+a2*t2-b1*t1-b2*t2
de = -a1*t1+b1*t1
if d == 0:
    print('infinity')
else:
    if a1<b1:
        if d < 0:
            print(0)
        else:
            if de%d == 0:
                print(2*(de//d))
            else:
                print(2*(de//d)+1)
    else:
        if d > 0:
            print(0)
        else:
            de = -de
            d = -d
            if de%d == 0:
                print(2*(de//d))
            else:
                print(2*(de//d)+1)



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

    int main() {
        int N;
        cin >>N;

		int vec[N-1];
    	for (int i = 0; i < (N - 1); i++) {
    		cin >> vec[i];
    	}

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

    	for (int i = 0; i < (N - 1); i++) {
    		result[vec[i]-1]++;
    	}

        for (int i = 0; i < N; i++) {
    	    cout << result[i] << endl;
    	}
    }

Measured memory_bytes: 5196
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>

using namespace std;
typedef long long ll;

int main(){

	ll n;
	cin >> n;

	vector<ll> p(n);
	for(ll i=0; i<n; i++){
		ll j;
		cin >> j;
		p[j-1]=i;
	}

	multiset<ll> st;

	st.insert(-1);
	st.insert(-1);
	st.insert(n);
	st.insert(n);

	ll v0,v1,v2,v3;

	ll r=0;

	for(ll i=n-1;0<=i;i--){
		ll j=p[i];
		auto it=st.lower_bound(j);
		it--;it--;
		//cout << j << endl;
		//for(auto sti: st) cout<<sti<<" ";
		//cout << *it << endl;
		v0=*it;
		it++; v1=*it;
		it++; v2=*it;
		it++; v3=*it;
		//cout << ":" << v0 << " " << v1 << " " << v2 << " " << v3 << endl;
		r+=(i+1)*(v1-v0)*(v2-j)+(i+1)*(j-v1)*(v3-v2);
		st.insert(j);

	}



	cout << r << endl;

	return 0;

}


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

const int N = 100010;
const int M = 20;

int vis[N][M], col[N], n, m, q, v[N], d[N], c[N];
std::vector <int> e[N];

void paint(int u, int dis, int color){
	if (vis[u][dis]){
		return;
	}
	vis[u][dis] = true;
	if (!dis){
		col[u] = color;
		return;
	}
	paint(u, dis - 1, color);
	for (auto v : e[u]){
		paint(v, dis - 1, color);
	}
}

int main(){
	scanf("%d%d", &n, &m);
	for (int i = 0, u, v; i < m; ++ i){
		scanf("%d%d", &u, &v);
		e[u].push_back(v);
		e[v].push_back(u);
	}
	scanf("%d", &q);
	for (int i = 0; i < q; ++ i){
		scanf("%d%d%d", &v[i], &d[i], &c[i]);
	}
	for (int i = q - 1; ~i; -- i){
		paint(v[i], d[i], c[i]);
	}
	for (int i = 1; i <= n; ++ i){
		printf("%d\n", col[i]);
	}
	return 0;
}

Measured memory_bytes: 15864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i+=2){
        int x = i;
        int cnt = 0;
        for(int j = 1; j*j <= x; j++){
            if(x % j == 0){
                cnt++;
                if(j != x / j)
                    cnt++;
            }
        }
        if(cnt == 8)
            ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[6] = {0,1,0,-1,1,-1};
const int vy[6] = {1,0,-1,0,1,1};



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

    int a,b,c,d,e;
    rep(i,5){
        int x;
        cin >> x;
        if(x == 0) {
            cout << i+1 << endl;
            return 0;
        }
    }

    cout << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
//#define int ll
//#define endl '\n'

// use unique(x) - removec consecutive items, returns vec.begin() + number of items
// for vector: sort(all(vec)); vec.erase(unique(all(vec)), vec.end());
// use iota(all(vec), 0) for filling a vector with 0,1,2...
// use fill(all(vec), 1) for filling a vector with 1,1,1...
// use rotate(vec.begin(), vec.begin() + 1, vec.end()) to rotate a vector | middle arg becomes first
// print number in binary -> cout << bitset<20>(n);

main(){
	cin.tie(0);cin.sync_with_stdio(0);
	string s;cin>>s;
	int n=s.size();
	if(s[n-1]=='s')cout<<s<<"es"<<endl;
	else cout<<s<<'s'<<endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>

using namespace std;

int main() {
  string n;
  cin >> n;
  if(n[0] == n[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3564
#include <stdio.h>

#define MAXH 500001

void maxHeapify(int *, int, int);
void buildMaxHeap(int *, int);

int main()
{
  int i, H;
  int A[MAXH];

  scanf("%d",&H);

  for(i = 1; i <= H; i++) {
    scanf("%d",&A[i]);
  }

  buildMaxHeap(A,H);

  for(i = 1; i <= H; i++) {
    printf(" %d",A[i]);
  }
  printf("\n");

  return 0;
}

void maxHeapify(int *A, int i, int H)
{
  int l, r, largest, tmp;

  l = i*2;
  r = i*2 + 1;

  if(l <= H && A[l] > A[i]) largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest]) largest = r;

  if(largest != i) {
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(A, largest, H);
  }
}

void buildMaxHeap(int *A, int H)
{
  int i;
  
  for(i = H/2; i >= 1; i--) {
    maxHeapify(A, i, H);
  }
}



Measured memory_bytes: 3672
#include "bits/stdc++.h"
 
#define ll long long 
#define rep(i,n) for(int i=0;i<n;i++)
#define MX 100005
 
using namespace std;
 
int main(){
    string s;
    ll k;
    cin>>s;
    cin>>k;
  	
    if(s.length()==1){
        if(k%2==0)cout<<k/2<<endl;
        else cout<<(k-1)/2<<endl;
      return 0;
    }
    int a=0; 
    rep(i,s.length()){
        if(s[i]==s[i+1]){
            a++;
            i++;
        }
    }
    if(s[0]==s[s.length()-1]){
        int b=0,c=0;
        int i=0;
        while(i<s.length()&&s[i]==s[0]){
            i++;
            b++;
        }
        i=s.length()-1;
        while(i>-1&&s[i]==s[s.length()-1]){
            i--;
            c++;
        }
      if(b==s.length()){
            k=s.length()*k;
            ll ans=(k%2==0)?k/2:(k-1)/2;
            cout<<ans;
            return 0;
        }
        if(b%2==1&&c%2==1){
            cout<<a*k+k-1<<endl;
          
            return 0;}
    }
    cout<<a*k<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n;
   cin>>n;
   int a[n];
   rep(i,0,n)cin>>a[i];
   multiset<int>s;
   for(int i=0;i<n;i++)
   {
       s.insert(a[i]);
       auto it=s.lower_bound(a[i]);
       if(it!=s.begin())
       {
           it--;
           s.erase(it);
       }
   }
   cout<<s.size()<<endl;
}


Measured memory_bytes: 5760
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	n <- readInt
	s <- getLine
	print $ length $ group $ sort $ do
		t <- map ( printf "%03d" ) [ 0 .. 999 :: Int ]
		guard $ match s t
		return t

match _ [] = True
match [] _ = False
match (s:ss) (t:tt)
	| s == t = match ss tt
	| otherwise = match ss (t:tt)	

Measured memory_bytes: 4860
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(short i = 0; i < n; i++)


int main() {
    bool f[3] = {};
    string s;
    
    cin >> s;
    
    f[s[0] - 'a'] = true;
    f[s[1] - 'a'] = true;
    f[s[2] - 'a'] = true;
    
    if(f[0] && f[1] && f[2]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n, k; cin >> n >> k;
  vector<int> a(n), b(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n; i++) cin >> b[i];

  sort(a.rbegin(),a.rend());
  sort(b.begin(),b.end());

  int ans = 0;
  auto f = [&](int mid){
    int cnt = 0;
    for(int i = 0; i < n; i++){
      if(a[i] * b[i] > mid) cnt += a[i] - mid/b[i];
    }
    return cnt <= k;
  };

  int left = -1,right = 1LL << 60;
  while(right - left > 1){
    int mid = (left + right) / 2;
    (f(mid) ? right : left) = mid;
  }
  cout << right << endl;

  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define int long long
using namespace std;
main()
{
	//freopen("input.txt","rt",stdin);
	string s;
	cin>>s;
	int n = s.length();
	int j = n-1;
	int count = 0;
	for(int i=0;i<n/2;i++)
	{
		if(s[i] != s[j])
		{
			count++;
		}
		j--;
	}
	cout<<count<<endl;
}

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

map<long long int, long long int> prime_factor(long long int n) {
    map<long long int, long long int> ret;
    for (long long int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1) ret[n] = 1;
    return ret;
}

int main() {
    ll N;
    cin >> N;

    //      map<ll, ll> prime;
    ll output = 0;
    //      for (int i = 1; i < N + 1; i++) {
    //          prime = prime_factor(i);
    //          ll count = 1;
    //          for (auto num : prime) {
    //              count *= num.second + 1;
    //          }
    //          // cout << i << " " << count << endl;
    //          output += i * count;
    //      }

    // ll count;
    // for (int i = 1; i < N + 1; i++) {
    //     count = 0;
    //     for (int j = 1; j < i + 1; j++) {
    //         if (i % j == 0) {
    //             output += i;
    //             count++;
    //             cout << i << endl;
    //         }
    //     }
    //     cout << i << " " << count * i << endl;
    // }

    output = 0;
    for (int i = 1; i < N + 1; i++) {
        ll max = N - N % i;
        output += (i + max) * max / (2 * i);
    }

    cout << output << endl;

    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

void solve(){
    string s;
    cin>>s;
    int n = s.length();
    ll sum = 0;
    for(int i =0;i<n;i++){
        sum+=(s[i]-'0');
        sum%=9;
    }
    if(sum%9==0)
    cout<<"Yes\n";
    else
    {
        cout<<"No\n";
    }
    
    // cout<<(sum%9==0)?"Yes" : "No";
}
int main(){
    IOS;
    int tt;
    tt = 1;
    // cin>>tt;
    while(tt--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3768
import java.util.*;
import java.math.*;
import java.lang.*;

public class Main {

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

    String k = n.substring(n.length()-1,n.length());

    if (k.equals("2") || k.equals("4") || k.equals("5") || k.equals("7") || k.equals("9")) {
      System.out.println("hon");
    } else if (k.equals("0") || k.equals("1") || k.equals("6") || k.equals("8")) {
      System.out.println("pon");
    } else {
      System.out.println("bon");
    }

  }

}


Measured memory_bytes: 35828
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	ll n, a[5];

	cin>>n;

	ll min_a=1e18;
	rep(i, 5){
		cin>>a[i];
		min_a=min(min_a, a[i]);
	}
	cout<<4+(ll)ceil((double)n/(double)min_a)<<endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	long long n,m,l;
	long long f1=0,f2=0;
	string s,t;
	cin>>n>>m>>s>>t;
	long long sign=1;
	long long a,b,q;
	a=max(n,m);b=min(n,m);
	q=a%b;
	while(q!=0){
		a=b;
		b=q;
		q=a%b;
	}
	long long n1=n,m1=m;
	n1/=b;m1/=b;
	int l1=0,l2=0;
	while(l1<n&&l2<m)
	{
		f1=l1*m+1;
		f2=l2*n+1;
		if(f1<f2) l1++;
		else if(f1>f2) l2++;
		else
		{
			if(s[l1]!=t[l2])
			{
				sign=0;
				break;
			}
			l1++;
			l2++;
		}
	}
	
	if(sign==1)
		cout<<n1*m1*b;
	else
		cout<<-1;
	return 0;
}



Measured memory_bytes: 512
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int x, y, z;

int main(int argc, char const* argv[])
{
    cin >> x >> y >> z;
    int ans = 0;
    while((y + z) * ans <= x - z){
        ans++;
    }
    cout << ans - 1 << endl;
    return 0;
}


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


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

	int a, b;
	char ans = 'x';
	cin >> a >> b;
	if (a + b == 15)
		ans = '+';
	else if (a * b == 15)
		ans = '*';
	else
		ans = 'x';
		
	cout << ans;
	return 0;
}

/*
2
8
3 4 1 6 5 3 5 5
10
0 1 5 6 8 8 8 9 12 15
*/



Measured memory_bytes: 256
N,M=map(int,input().split())
H=list(map(int,input().split()))
rec=[1]*N
count=[]
for i in range(M):
    a,b=map(int,input().split())
    if H[a-1]>H[b-1]:
        rec[a-1]*=1
        rec[b-1]*=0
    elif H[a-1]==H[b-1]:
        rec[a-1]*=0
        rec[b-1]*=0
    else:
        rec[a-1]*=0
        rec[b-1]*=1
print(sum(rec))



        

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

//create arrays outside of main()
int N = 10;
int heights[100000] = {};

int main() {
    
    int n;
    cin >> n;

    for(int i=0; i<n; i++){
        cin >> heights[i];
    }

    int steps = 0;
    int largest = 0;

    for(int i=0; i<n-1; i++){
        if(heights[i]>=heights[i+1]){
            steps = steps + 1;
            if(steps >= largest){
                largest = steps;
            }
        } else {
            steps = 0;
        }
    }

    cout << largest;

    return 0;
}

Measured memory_bytes: 640
S = input()
K = int(input())

# 全部同じ場合
if len(set(list(S))) == 1:
    print(len(S) * K // 2)
    exit()

focus_c = S[0]
consecutive_s = S[0]
focus_s_array = []
for s in S[1:]:
    if s == focus_c:
        consecutive_s += s
    else:
        focus_s_array.append(consecutive_s)
        focus_c = s
        consecutive_s = s
else:
    focus_s_array.append(consecutive_s)


cost = 0
for fsa in focus_s_array:
    cost += len(fsa) // 2
ans = cost * K

if (focus_s_array[0][0] == focus_s_array[-1][0]) and ((len(focus_s_array[0]) + len(focus_s_array[-1])) % 2 == 0):
    ans += K - 1

print(ans)


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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  string s, t;
  cin >> s >> t;

  for (int i = 0; i < s.size(); i++) {
    string tmp = "";
    for (int j = 0; j < s.size(); j++) {
      int idx = (i + j) % s.size();
      tmp += s[idx];
    }
    if (tmp == t) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main(void)
{
	int N,A,B,ans=0;

	cin >> N >> A >> B;

	if(N*A<=B)
	{
		ans=N*A;

		cout << ans;

	}

	else
	{
		cout << B;

	}
	cout << endl;
}


Measured memory_bytes: 256
n=gets.to_i - 1
a=[1,1,1,0]
b=[1,1,1,0]
def mul a,b
  [a[0]*b[0]+a[1]*b[2], a[0]*b[1]+a[1]*b[3], a[2]*b[0]+a[3]*b[2], a[2]*b[1]+a[3]*b[3]]
end

while n>0
  if n & 1 == 1
    b = mul a,b
  end
  a = mul a,a
  n >>= 1
end
puts b[0]

Measured memory_bytes: 8712
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int A,B,C,D;
    cin >>A>>B>>C>>D;
    if(A+B>C+D){
        cout<<"Left"<<endl;
    }
    if(A+B==C+D){
        cout<<"Balanced"<<endl;
    }
    if(A+B<C+D){
        cout<<"Right"<<endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string.h>
#include <cstdlib>
#include <vector>
#include <string>
#include <bitset>
#include <math.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
 
typedef long long ll;
typedef long double ld;
 
const ll MOD = 1e9 + 7, INF = 1e18 + 1;
 
using namespace std;

int m, n;

vector <int> v[2];

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

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

		scanf ("%d", &a);

		v[a & 1].push_back (a);
	}

	if (v[1].size () > 2) cout << "Impossible";
	else 
	{
		if (v[1].size ()) cout << v[1][0] << ' ';

		for (auto a : v[0])
			printf ("%d ", a);

		if (v[1].size () > 1) cout << v[1][1];

		cout << endl;

		if (!v[0].size ())
		{
			if (v[1].size () == 1) 
			{
				if (v[1][0] == 1) printf ("1\n%d\n", v[1][0]);
				else printf ("2\n%d 1\n", v[1][0] - 1);
			}
			else 
			{
				if (v[1][0] == 1) printf ("1\n%d\n", v[1][1] + 1);
				else printf ("2\n%d %d\n", v[1][0] - 1, v[1][1] + 1);
			}	
		}
		else if (v[0].size () == 1)
		{
			if (v[1].size () == 0) printf ("2\n1 %d\n", v[0][0] - 1);
			else if (v[1].size () == 1) 
			{
				if (v[1][0] == 1) printf ("1\n%d\n", v[0][0] + 1);
				else printf ("2\n%d %d\n", v[1][0] - 1, v[0][0] + 1);
			}
			else 
			{
				if (v[1][0] == 1) printf ("2\n%d %d\n", v[0][0], v[1][1] + 1);
				else printf ("3\n%d %d %d\n", v[1][0] - 1, v[0][0], v[1][1] + 1);
			}
		}
		else
		{
			cout << n - (v[1].size () && v[1][0] == 1 ? 1 : 0) << endl;

			if (v[1].size ())
			{
				if (v[1][0] > 1) cout << v[1][0] - 1 << ' ';
				cout << v[0][0] << ' ';
			}
			else cout << v[0][0] - 1 << ' ';

			for (int i = 1; i < v[0].size () - 1; i++)
				printf ("%d ", v[0][i]);

			if (v[1].size () > 1)
			{
				cout << v[0].back () << ' ';
				cout << v[1][1] + 1 << ' ';
			}
			else cout << v[0].back () + 1 << ' ';
		}
	}
}

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

using namespace std;

using int64 = long long;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << 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) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

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

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int edit_distance(const string &S, const string &T) {
  const int N = (int) S.size(), M = (int) T.size();
  vector< vector< int > > dp(N + 1, vector< int >(M + 1, N + M));
  for(int i = 0; i <= N; i++) dp[i][0] = i;
  for(int i = 0; i <= M; i++) dp[0][i] = i;
  for(int i = 1; i <= N; i++) {
    for(int j = 1; j <= M; j++) {
      dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1);
      dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
      dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + (S[i - 1] != T[j - 1]));
    }
  }
  return dp[N][M];
}

int main() {
  string S, T;
  cin >> S >> T;
  cout << edit_distance(S, T) << endl;
}




Measured memory_bytes: 6848
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

int h[205][205], a[205][205][100];
int dice[6][6][4] = {
  {{-1, -1, -1, -1}, {2, 4, 5, 3}, {3, 2, 4, 5}, {4, 5, 3, 2}, {5, 3, 2, 4}, {-1, -1, -1, -1}}
  ,{{1, 3, 6, 4}, {-1, -1, -1, -1}, {3, 6, 4, 1}, {4, 1, 3, 6}, {-1, -1, -1, -1}, {6, 4, 1, 3}}
  ,{{1, 5, 6, 2}, {2, 1, 5, 6}, {-1,-1,-1,-1}, {-1,-1,-1,-1}, {5, 6, 2, 1}, {6, 2, 1, 5}}
  ,{{1, 2, 6, 5}, {2, 6, 5, 1}, {-1,-1,-1,-1}, {-1,-1,-1,-1}, {5, 1, 2, 6}, {6, 5, 1, 2}}
  ,{{1, 4, 6, 3}, {-1,-1,-1,-1}, {3, 1, 4, 6}, {4, 6, 3, 1}, {-1,-1,-1,-1}, {6, 3, 1, 4}}
  ,{{-1,-1,-1,-1}, {2, 3, 5, 4}, {3, 5, 4, 2}, {4, 2, 3, 5}, {5, 4, 2, 3}, {-1,-1,-1,-1}}};
signed main(void)
{
  while(true) {
    int n;
    cin >> n;
    if(!n) break;
    REP(i, 205) REP(j, 205) {
      h[i][j] = 0;
      REP(k, 100) a[i][j][k] = 0;
    }
    REP(i, n) {
      //cout << i << endl;
      int t, f;
      cin >> t >> f;
      int x = 100, y = 100;
      while(true) {
        int th = h[y][x];
        int ans = -1, dir = -1;
        //cout << "x:" << x << " y:" << y << " th:" << th << " t:" << t << " f:" << f << endl;
        //4???????????????????????????????¢??????????
        REP(j, 4) {
          //cout << dice[t-1][f-1][j] << endl;
          //????????????????????????th????????????????????¨??????
          if(h[y+dy[j]][x+dx[j]] >= th) continue;
          //????????????????????????????????¢???4~6??§????????¨??????
          if(4 <= dice[t-1][f-1][j] && dice[t-1][f-1][j] <= 6) {
            if(dice[t-1][f-1][j] > ans) {
              ans = dice[t-1][f-1][j];
              dir = j;
            }
          }
        }
        //cout << "ans:" << ans << " dir:" << dir << endl;
        //dir??????????????¨???
        if(dir == -1) {
          a[y][x][h[y][x]] = t;
          h[y][x]++;
          break;
        } else {
          y += dy[dir];
          x += dx[dir];
          if(dir == 1 || dir == 3) {
            t = 7-ans;
          } else if(dir == 0){
            f = t;
            t = 7-ans;
          } else {
            f = 7-t;
            t = 7-ans;
          }
        }
      }
    }
    //cout << "end" << endl;
    int cnt[7] = {};
    REP(i, 205) REP(j, 205){
      if(h[i][j] != 0) cnt[a[i][j][h[i][j]-1]]++;
    }
    FOR(i, 1, 7) {
      cout << cnt[i];
      if(i != 6) cout << " ";
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 19652
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    long long a;
    string b;
    cin>>a>>b;
    
    long long c=0,mul=100;
    for(int i=0;i<b.size();i++){
        if('0'<=b[i] && b[i]<='9'){
            c+=int(b[i]-'0')*mul;
            mul/=10;
        }
    }
    cout<<(a*c)/100<<"\n";
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    return 0;
}

Measured memory_bytes: 3656