akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <tuple>
#include <functional>
#include <cmath>
#include <complex>

using namespace std;
#define PI       3.14159265358979323846
#define MOD 1000000007

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef complex<double> P;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;

char board[55][55];
int cost[55][55];
int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };

int main() {
	int h, w;
	scanf("%d%d", &h, &w);
	memset(board, '#', sizeof(board));
	memset(cost, 0x7f, sizeof(cost));
	cost[1][1] = 0;
	REP(i, h)scanf("%s", &board[i + 1][1]);
	int ret = h*w-1;
	FOR(i, 1, h + 1) {
		FOR(j, 1, w + 1) {
			if (board[i][j] == '#')ret--;
		}
	}
	deque<PII> q;
	q.push_front(MP(1, 1));
	while (!q.empty()) {
		PII tmp = q.back();
		int x = tmp.first;
		int y = tmp.second;
		q.pop_back();
		REP(i, 4) {
			int nx = tmp.first + dx[i];
			int ny = tmp.second + dy[i];
			if (board[ny][nx] == '.') {
				if (cost[ny][nx] > cost[y][x] + 1) {
					cost[ny][nx] = cost[y][x] + 1;
					q.push_front(MP(nx, ny));
				}
			}
		}
	}
	if (cost[h][w] > 1000000) {
		cout << -1 << endl;
		return 0;
	}
	ret -= cost[h][w];
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	ll LIMIT = 1e18;
	int N; cin >> N;
	vector<ll> A(N);
	REP(i, N) {
		ll a; cin >> a;
		if (a == 0) {
			cout << 0 << endl;
			return;
		}
		A[i] = a;
	}
	ll res = 1;
	for (ll v : A) {
		if (res > LIMIT / v) {
			cout << -1 << endl;
			return;
		}
		res *= v;
	}
	cout << res << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define COUT(x) cout<<x<<"\n"

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = lcm(a, v[i]);} return a;}


void Main()
{
	ll N;
	ll res=0;
	string sres;
	cin>>N;
	VI A(N),B(N);
	REP(i, N) cin >> A[i];
	B=A;
	SORT(B);
	ll min=B[(N-1)/2];
	ll max=B[(N+1)/2];
	REP(i,N){
		if(A[i]>=max) res=min;
		else res=max;
		COUT(res);
	}
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


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

int main(void){
    int n;
    cin >> n;
    vector<pair<int,int>> a(n);

    for(int i = 0;i < n;i++){
        cin >> a[i].first;
        a[i].second = i+1; 
    }

    sort(a.begin(),a.end());
    
    for(int i = 0;i < n;i++){
        cout << a[i].second;
        if(i != n-1){
            cout << " ";
        }
    }
    cout << endl;
}

Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <functional>
#include <math.h>
using namespace std;
int main(){
  int n;
  int b,f,r,v;
  int a[13][11]={0};
  cin >> n;
  for(int i=1;i<=n;i++){
    cin >> b >> f >> r >> v;
    a[3*(b-1)+f][r]=a[3*(b-1)+f][r]+v;
  }
  for(int i=1;i<=4;i++){
    for(int k=1;k<=3;k++){
      for(int j=1;j<=10;j++){
	cout << ' ' << a[3*(i-1)+k][j];
      }
      if(k!=3)cout << "\n";
    }
    cout <<"\n";
    if(i!=4){
      for(int i=0;i<20;i++){
	cout << '#';
      }
      cout << "\n";
    }
  }
  return 0;
}



Measured memory_bytes: 3088
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

// array pointer = *a, num of element = n, key key
int lower_bound(int *a, int n, int key){
    int ng, mid, ok;
    ng = -1, ok = n-1;
    while (abs(ok - ng) > 1){
        mid = (ok + ng) / 2;
        if (key <= a[mid]){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    if (a[ok] >= key)return ok;
    return n;
}

//greatest common divisor
unsigned long gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}

unsigned long lcm(unsigned long x, unsigned long y){
    unsigned long g = gcd(x, y);
    return x*y/g;

}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}




/*unsigned long long pascal[100][100] = {0};
void make_pascal(void){
    for (int i = 0; i < 100; i++){
        pascal[i][0] = 1;
    }
    pascal[1][1] = 1;
    for (int i = 2; i < 100; i++){
        for (int j = 1; j < 100; j++){
           pascal[i][j] = (pascal[i-1][j-1]+pascal[i-1][j]) % mod;
        }
    }
}*/
long long mod = 1000000007;

//x ^ n
long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % mod;
        x = x * x % mod;
    }
    return res;
}

/*int struct_ascending_compare(const void *p, const void *q) {
    return ((structname*)p)->member - ((strcutname*)q)->member;
}*/

char field[4][4];

int main(void){
    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++){
            scanf(" %c", &field[i][j]);
        }
    }

    printf("%c%c%c\n", field[0][0], field[1][1], field[2][2]);
    

    return 0;
}


Measured memory_bytes: 128
from math import gcd
K = int(input())
ans = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        a_b_gcd = gcd(a, b)
        for c in range(1, K+1):
            ans += gcd(a_b_gcd, c)
print(ans)

Measured memory_bytes: 9180
/*  よろしくお願いします
    LEARNING DP:    Digit Sum

    CONSTRAINT:

    WHAT WHE SHOULD CARE ABOUT:

    IF WE KNOW:

    PRE DP:

    TIME COMPLEXITY:

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

#define DB(_x)      cout << #_x << " is " << (_x) << "\n";
#define fs          first
#define sc          second
#define pb          push_back
//#define IOFILE

using LL = long long;
using LD = long double;
using VI = vector<int>;
using PI = pair<int,int>;
const int mod = 1e9 + 7;

// BEG: GLOBAL VARIABLES
    string s;
    int d;
    int dp[10001][101][2];
// END: GLOBAL VARIABLES

LL DFS(int idx, int su, int flag){
    if (idx == (int)s.size()) return su == 0;
    if (dp[idx][su][flag] != -1) return dp[idx][su][flag];
    LL cnt = 0, en;
    if (flag == 1) en = s[idx] - '0';
    else en = 9;
    for (int i=0; i<=en; ++i){
        int flagflag = flag;
        if (i < en) flagflag = 0;
        cnt += DFS(idx+1,(su+i)%d,flagflag);
        if (cnt >= mod) cnt %= mod;
    }
    return dp[idx][su][flag] = cnt;
}

void Excalibur(){
    while (cin >> s >> d){
        memset(dp,-1,sizeof(dp));
        cout << (DFS(0,0,1) - 1 + mod) % mod<< "\n";
    }
}

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

#ifdef  IOFILE
    freopen("INPUT.in", "r", stdin);
    freopen("OUTPUT.out", "w", stdout);
#endif

Excalibur();
return 0;}


Measured memory_bytes: 9088
#include <iostream>
#include <cstdio>
#include <cstring>
#define rg register
#define LL long long
using namespace std;
const int MAXN=5000;
int N,M,C,ans;
int a[MAXN],b[MAXN];

int main(){
	scanf("%d%d%d",&N,&M,&C);
	
	for(rg int i=1;i<=M;i++)
		scanf("%d",&b[i]);
	
	while(N--){
		int tmp=0;
		for(rg int j=1;j<=M;j++)
			scanf("%d",&a[j]),tmp+=b[j]*a[j];
		if(tmp+C>0) ans++;
	}
	
	printf("%d\n",ans);
	
	return 0;
}


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

void solve(int64_t N)
{
    N--;
    string res = "";
    while (true)
    {
        char c = N % 26;
        res += c + 'a';
        N -= 26;
        if (N < 0)
            break;
        N /= 26;
    }
    reverse(res.begin(), res.end());
    cout << res << endl;
}

int main()
{
    int64_t N;
    cin >> N;
    solve(N);
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
 
#include<deque>
#define pi 3.141592653589793238
#include<chrono>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        ll n;
        cin >> n;
        vector<ll> v(n);
        for(i = 0; i < n; i++){
            cin >> v[i];
        }
        ll ans = 0;
        for(i = 1 ; i < n; i++){
            if(v[i] < v[i - 1]){
                //v[i] = v[i - 1];
                ans += (v[i - 1] - v[i]);
                v[i] = v[i - 1];
            }
        }
        cout << ans;
    }
    return 0;
}

Measured memory_bytes: 4724
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

a,b,h = inputILs(3)

print(((a+b)*h)//2)


Measured memory_bytes: 63980
#include<iostream>
using namespace std;
int main(){
        int a,b;
        scanf("%d %d",&a,&b);
        if(a>b){
                printf("a > b\n");
        }else if(a<b){
                printf("a < b\n");
        }else{
                printf("a == b\n");
        }
        return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define PI 3.141592653589793
int main(void)
{
  int a,b,x;
  scanf("%d%d%d",&a,&b,&x);

  long double fa,fb,fx;
  fa = (long double)a;
  fb = (long double)b;
  fx = (long double)x;

  long double rad;

  // 場合分けが必要.
  if(2*x <= a*a*b) {
    rad = atan(fa*fb*fb/(2.0*fx));
    printf("%Lf\n",rad*180.0/PI);
  } else {
    rad = atan(((fb-fx/(fa*fa))*2.0)/fa);
    printf("%Lf\n",rad*180.0/PI);
  }
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<stack>
#include<string>
using namespace std ;

int main(){
	
	string s ;
	
	while( getline( cin , s ) ){
		if( s[0] == '.' ) break ;
		
		stack<int> st ;
		int t = 0 ;
		
		for( int i=0 ; i<s.size() ; i++ ){
			if( s[i] == '(' ) st.push(1) ;
			if( s[i] == '[' ) st.push(2) ;
			
			if( s[i] == ')' ){
				if( st.size() > 0 && st.top() == 1 ){
					st.pop() ;
				}
				else t = 1 ;
			}
			if( s[i] == ']' ){
				if( st.size() > 0 && st.top() == 2 ){
					st.pop() ;
				}
				else t = 1 ;
			}
			
			if( t == 1 ) break ;
		}
		
		if( t == 1 || st.size() > 0 ) cout << "no" << endl ;
		else cout << "yes" << endl ;
	}
	
return 0;
}

Measured memory_bytes: 1172
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void BubbleSort(char (*A)[3],int n);
void SelectionSort(char (*A)[3],int n);
int  judge(char (*A)[3],char (*B)[3],int n);
int main(){
  int n,i;
  char A[36][3],B[36][3],C[36][3];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s ",A[i]);
  }
  for(i=0;i<n;i++){
    strcpy(B[i],A[i]);
    strcpy(C[i],A[i]);
  }
  BubbleSort(B,n);
  judge(A,B,n);
  SelectionSort(C,n);
  judge(A,C,n);
  return 0;
}
void BubbleSort(char (*B)[3],int n){
  int i,j;
  char c[3];
  for(i=0;i<n;i++){
    for(j=n-1;i<j;j--){
      if(B[j][1]<B[j-1][1]){
      	strcpy(c,B[j]);
	strcpy(B[j],B[j-1]);
	strcpy(B[j-1],c);
      }
    }
  }
  printf("%s",B[0]);
  for(i=1;i<n;i++){
    printf(" %s",B[i]);
  }
  printf("\n");
}
void SelectionSort(char (*C)[3],int n){
  int i,j,minj;
  char c[3];
  for(i=0;i<n;i++){
    minj=i;
    for(j=i+1;j<n;j++){
      if(C[j][1]<C[minj][1]){
	minj=j;
      }
    }
    strcpy(c,C[i]);
    strcpy(C[i],C[minj]);
    strcpy(C[minj],c);
  }
  printf("%s",C[0]);
  for(i=1;i<n;i++){
    printf(" %s",C[i]);
	}
	printf("\n");
}
int judge(char (*A)[3],char (*B)[3],int n){
  int i,j,k,minj,flag=0;
  char c[2][3];
  for(i=0;i<n-1;i++){
    for(j=i+1;j<n;j++){
      //printf("A[%d][1]:%c A[%d][1]:%c\n",i,A[i][1],j,A[j][1]);
      if(A[i][1]==A[j][1]){
	//printf("A[%d][1]:%c == A[%d][1]:%c\n",i,A[i][1],j,A[j][1]);
	strcpy(c[0],A[i]);
	strcpy(c[1],A[j]);
	for(k=0;k<n-1;k++){
	  // printf("c[0]:%s B[%d]:%s\n",c[0],j,B[k]);
	  if(c[0][1]==B[k][1]&&c[0][0]==B[k][0]){
	    //printf("c[0]:%s == B[%d]:%s\n",c[0],j,B[k]);
	    if(c[1][1]!=B[k+1][1]||c[1][0]!=B[k+1][0]){
	      //printf("c[1][1]:%c !=B[%d][1]:%c || c[1][0]:%c !=B[%d][1]:%c\n"  ,c[1][1],k+1,B[k+1][1],c[1][0],k+1,B[k+1][0]);
	      //printf("flag=1\n");
	      flag=1;
	    }
	  }
	}
	break;
      }
    }
  }
  if(flag==1){
    printf("Not stable\n");
  }
  if(flag==0){
    printf("Stable\n");
    }
}



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

int main(void){
    int x, y, s;
    while(cin >> x >> y >> s && x) {
        int ans = 0;
        for(int i=1; i<s; ++i) {
            for(int j=1; ; ++j) {
                int p = i*(100+x)/100 + j*(100+x)/100;
                if(p > s) break;
                if(p == s) {
                    ans = max(ans, i*(100+y)/100 + j*(100+y)/100);
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
int x,y,ans=2147483647;
int main()
{
	cin>>x>>y;
	if(x==y){puts("0");return 0;}
	if(y>x)ans=min(y-x,abs(y+x)+1);
	else ans=min(abs(x+y)+1,2+abs(x-y));
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
odd, even = [], []
for i, elem in enumerate(a):
    if i % 2 == 0:
        odd.append(elem)
    else:
        even.append(elem)
if n % 2 == 0:
    print(" ".join(map(str, even[::-1])), end=" ")
    print(" ".join(map(str, odd)))
else:
    print(" ".join(map(str, odd[::-1])), end=" ")
    print(" ".join(map(str, even)))

Measured memory_bytes: 26020
# -*- coding: utf-8 -*-
"""
Created on Sun May 17 19:16:09 2020

@author: Kanaru Sato
"""
import itertools

n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))

nums = [i+1 for i in range(n)]

count = 0
for perm in itertools.permutations(nums):
    count += 1
    if p == perm:
        pcount = count
    if q == perm:
        qcount = count

print(abs(pcount-qcount))

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

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

  if(a + b == c || b + c == a || c + a == b){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int w,h,x,y;
  scanf("%d%d%d%d",&w,&h,&x,&y);
  double answer = (double) w * (double) h / 2.0;
  int flag = 0;
  if(2 * x == w && 2 * y == h) flag = 1;
  printf("%lf %d\n",answer,flag);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <iostream>
#include <functional>
#include <cmath>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
  int a,b;
  std::cin >> a;
  std::cin >> b;
  if ((a*b)%2) {
    printf("Odd\n");
  }else{
    printf("Even\n");
  }

	return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, k) = (v[0], v[1]);
    let mut ans = k;
    for _ in 1..n {
        ans *= k - 1;
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,w;
  cin >> n >> w;
  pair<long long,long long>p[n];
  for(long long  i = 0; i < n;i++)
  {
    cin >> p[i].first;
    cin >> p[i].second;
  }
  long long dp[n][w+1];
  for(long long i =0; i<= w;i++)
  {
    dp[0][i] = 0;
    if(i >= p[0].first)
      dp[0][i] = p[0].second;
  }
  for(long long i = 1; i < n;i++)
  {
    for(long long j = 0; j <= w;j++)
    {
      if(j >= p[i].first)
        dp[i][j] = max(dp[i-1][j], p[i].second + dp[i-1][j - p[i].first]);
      else
        dp[i][j] = dp[i-1][j];
    }
  }
  cout << dp[n-1][w] << endl;
}

Measured memory_bytes: 78336
#include<stdio.h>
typedef long long int lli;
int main() {
  int n;
  scanf("%d", &n);
  int count=0;
  int temp=0;
  while(n--){
      int a,b;
      scanf("%d %d", &a, &b);
      if(a==b){
          temp++;
      }
      else{
          temp=0;
      }
      if(temp>count){
          count=temp;
      }
  }
  
  if(count>=3){
      printf("Yes\n");
  }
  else{
      printf("No\n");
  }

  return 0;
}



Measured memory_bytes: 1664
#include<stdio.h>
#include<string.h>

#define m 1046527
#define NIL (-1)
#define L 14

char H[m][L];
int getChar(char ch) {
	if ( ch == 'A' ) return 1;
	else if ( ch == 'C' ) return 2;
	else if ( ch == 'G' ) return 3;
	else if ( ch == 'T' ) return 4;
	else return 0;
} 

long long getKey(char str[]){
	long long sum = 0, p = 1, i;
	for ( i = 0; i < strlen(str); i++){
		sum += p*(getChar(str[i]));
		p *= 5;
	}
	return sum;
}

int h1(int key){
	return key % m;
}
int h2(int key){
	return 1 + (key % (m - 1));
}

int find(char str[]){
	long long key, i, h;
	key = getKey(str);
	for ( i = 0; ;i++ ) {
		h = (h1(key) + i * h2(key)) % m;
		if ( strcmp(H[h],str) == 0 ) return 1;
		else if (strlen(H[h]) == 0 ) return 0;
	}
	return 0;
}

int insert(char str[]) {
	long long key, i, h;
	key = getKey(str);
	for ( i = 0; ; i++ ) {
		h = (h1(key) + i * h2(key)) % m;
		if ( strcmp(H[h],str) == 0 ) return 1;
		else if ( strlen(H[h]) == 0 ) {
			strcpy(H[h], str);
			return 0;
		}
	}
	return 0;
}

int main() {
	int i, n, h;
	char str[L], com[9];
	for ( i = 0; i < m; i++ ) H[i][0] = '\0';
	scanf("%d", &n);
	for ( i = 0; i < n; i++ ) {
		scanf("%s %s", com, str);
		if ( com[0] == 'i') {
			insert(str);
		} else {
			if ( find(str) ) {
				printf ("yes\n"); 
			} else {
				printf("no\n");
			}
		}
	}
	return 0;
}


Measured memory_bytes: 17068
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(2);
  
using namespace std;
 
const ll inf = 1e17;
const ll N = 1e6+10;
const ll bits = 30;
const ll mod = 1e9+7;
const ld pi = 3.14159265358979323846;

 
 
int main(){
    FASTIO;

    ll w,h,n,ans=inf,blk;

    cin>>h>>w>>n;

    for(ll a=0;a<=h;a++){
        for(ll b=0;b<=w;b++){
            blk = a*w + b*h - a*b;
            if(blk>=n){
                ans= min(ans,a+b);
            }
        }
    }

    cout<<ans<<"\n";


    
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(c) (c).begin(),(c).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const int INF = 1e9 + 10;

int A, B, C, K;

int main() {
    cin >> A >> B >> C >> K;
    if (K <= A) {
        cout << K << endl;
        return 0;
    }
    if ( K <= A + B) {
        cout << A << endl;
        return 0;
    }
    if (K <= A + B + C) {
        cout << A - (K - A - B) << endl;
        return 0;
    }
    cout << A - C << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, K; cin >> N >> K;
    vector<ll> v(N);
    for (int i = 0; i < N; i++) cin >> v[i];
    ll maxV = 0;
    for (int l = 0; l <= K; l++) {
        for (int r = 0; r <= K; r++) {
            int outNum = l + r;
            if (outNum > min(N,K)) continue;
            int rest = K - outNum;
            vector<int> hand;
            hand.insert(hand.end(), v.begin(), v.begin() + l);
            hand.insert(hand.end(), v.rbegin(), v.rbegin() + r);
            sort(hand.begin(), hand.end());
            ll tmp = 0;
            for (int i = 0; i < outNum; i++) {
                if (i < rest && hand[i] < 0) continue;
                tmp += hand[i];
            }
            maxV = max(tmp, maxV);
        }
    }
    cout << maxV << '\n';
}


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

int main(){
	int N, X;
	cin >> N >> X;
	vector<int> L(N);
	int D = 0;
	for (int i = 1;i <= N;++i) {
		if (D > X) {
			cout << i - 1 << endl;
			return 0;
		}
		cin >> L.at(i - 1);
		D += L.at(i - 1);
	}
	cout << (D > X ? N : N + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#ifdef __LOCAL
  #define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define intmax numeric_limits<int>::max()
#define llmax numeric_limits<ll>::max()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;
const ll lnf=1ll<<60;

vector<vector<int> > g;
vector<vector<int> > grp;

void dfs(int v,int p=-1,int color=0){
  grp[color].push_back(v);
  for(auto nv:g[v]){
    if(nv==p) continue;
    dfs(nv,v,1-color);
  }
}

int main(){
  int n; cin >> n;
  g.resize(n);
  grp.resize(2);
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(0);

  queue<int> one;
  queue<int> two;
  queue<int> thr;
  rep1(i,n){
    if(i%3==1) one.push(i);
    if(i%3==2) two.push(i);
    if(i%3==0) thr.push(i);
  }

  int A=grp[0].size();
  int B=grp[1].size();
  if(A>B){
    swap(A,B);
    swap(grp[0],grp[1]);
  }

  vector<int> ans(n,0);
  if(one.size()<=A){
    int ONE=one.size();
    rep(i,ONE){
      ans[grp[0][i]]=one.front();
      one.pop();
    }
    for(int i=ONE;i<A;i++){
      ans[grp[0][i]]=thr.front();
      thr.pop();
    }
    rep(i,n)if(ans[i]==0){
      if(thr.size()){
        ans[i]=thr.front();
        thr.pop();
        continue;
      }
      if(two.size()){
        ans[i]=two.front();
        two.pop();
        continue;
      }
    }
  }
  else{
    rep(i,A){
      ans[grp[0][i]]=thr.front();
      thr.pop();
    }
    rep(i,n)if(ans[i]==0){
      if(one.size()){
        ans[i]=one.front();
        one.pop();
        continue;
      }
      if(two.size()){
        ans[i]=two.front();
        two.pop();
        continue;
      }
      if(thr.size()){
        ans[i]=thr.front();
        thr.pop();
        continue;
      }
    }
  }

  for(auto p:ans) cout << p << " ";
  cout << endl;

}

Measured memory_bytes: 22880
#include <iostream>
using namespace std;
  
int main(void) {
  int card_count, gate_count, c_start=1, c_end, all_count=0;
  
  cin >> card_count;
  cin >> gate_count;
  c_end = card_count;
  
//  cout << "card_count:" << card_count << ", gate_count:" << gate_count << "\n";
  
  for(int l=0; l < gate_count; l++) {
    int s, e;
    cin >> s;
    cin >> e;
    
//    cout << "#gate:" << l+1 << "\n";
    
    if(c_start < s) {
      c_start = s;
//      cout << " c_start:" << s << "\n";
    }
    
    if(c_end > e) {
      c_end = e;
//      cout << " c_end:" << e << "\n";
    }
  }
  
  for(int n=c_start-1; n <= c_end-1; n++) {
    all_count++;
  }
  
  cout << all_count << "\n";
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

struct uftree {
    int n, *par, *rank, *size;
    uftree(int N) : n(N) {
        par = new int[(size_t)N];
        rank = new int[(size_t)N];
        size = new int[(size_t)N];
        for (int i = 0; i < N; i++) {
            par[i]  = i;
            rank[i] = 0;
            size[i] = 1;
        }
    }
    int root(int x) {
        if (par[x] == x)
            return x;
        else {
            int r         = root(par[x]);
            size[x]       = size[par[x]];
            return par[x] = r;
        }
    }
    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (rank[x] > rank[y])
            par[y] = x;
        else {
            par[x] = y;
            if (rank[x] == rank[y]) rank[y]++;
        }
        size[x] += size[y];
        size[y] = size[x];
    }
    int get_size(int x) {
        root(x);
        return size[x];
    }
    bool same(int x, int y) { return root(x) == root(y); }

    // 集合の数をカウントする関数
    // 1..nのつもりでやってる場合も0をカウントしちゃうので注意
    int count_sets() {
        int cnt = 0;
        bool used[n];
        fill(used, used+n, false);
        for (int i=0; i<n; i++) {
            if (used[root(i)]) continue;
            cnt++;
            used[root(i)] = true;
        }
        return cnt;
    }
};

using P = pair<ll, ll>;
#define fi first
#define se second

int main() {
    int n;
    cin >> n;
    P a[n], b[n];
    for (int i=0; i<n; i++) {
        cin >> a[i].fi;
        a[i].se = i;
    }
    for (int i=0; i<n; i++) {
        cin >> b[i].fi;
        b[i].se = i;
    }
    sort(a, a+n);
    sort(b, b+n);
    bool yes = false;
    uftree uft(n);
    for (int i=0; i<n; i++) {
        auto lb = partition_point(a, a+n, [&](P ai) {
            return ai.fi <= b[i].fi;
        });
        int j = lb - a - 1;
        if (j < i) {
            cout << "No" << '\n';
            return 0;
        }
        else if (j > i || (i < n-1 && uft.same(a[j].se, b[i].se))) {
            yes = true;
        }
        uft.unite(a[j].se, b[i].se);
    }
    cout << (yes ? "Yes" : "No") << '\n';
    return 0;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;
 
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

signed main()
{
  int n; cin>>n;
  vi a(n);
  rep(i,n) cin>>a[i];
  int ans=0;
  rep(i,n){
    ans+=a[i]-1;
  }
  cout<<ans<<endl;
}


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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    double err = 1000000;
    int N;
    cin >> N;
    double T, A;
    cin >> T >> A;
    int p = -1;
    REP(i, N) {
        double h;
        cin >> h;
        double e = abs(A - (T - h*0.006));
        if(e < err) {
            err = e;
            p = i;
        }
    }
    cout << p + 1 << endl;
    return 0;
}



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

using namespace std;
using ll = long long;

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (auto& x : a) {
        cin >> x;
    }

    vector<ll> dp(n), dpeven(n);
    dp[0] = 0;
    dp[1] = max(a[0], a[1]);
    dpeven[0] = a[0];
    dpeven[1] = max(a[0], a[1]);
    for (int i = 2; i < n; ++i) {
        if (i % 2 == 0) {
            dpeven[i] = a[i] + dpeven[i - 2];
            dp[i] = max(a[i] + dp[i - 2], dp[i - 1]);
        } else {
            dpeven[i] = max(a[i] + dpeven[i - 2], a[i - 1] + dpeven[i - 3]);
            dp[i] = max(a[i] + dp[i - 2], a[i - 1] + dpeven[i - 3]);
        }
    }
    cout << dp[n - 1];
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);

    solve();
}


Measured memory_bytes: 7948
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int fib_t[45] = {0};

int fib(int i){
    if (i <= 1) return 1;
    if (fib_t[i] != 0) return fib_t[i];
    int nacci;
    nacci = fib(i-1) + fib(i-2);
    fib_t[i] = nacci;
    
    return nacci;
}

int main(){
    int i;
    cin >> i;
    cout << fib(i) << endl;
    
    return 0;
}

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

int a[4];

bool dfs(int i, int x){
    if(i == 3){
        return x == 7;
    }
    if(dfs(i + 1, x + a[i + 1])){
        return true;
    }
    if(dfs(i + 1, x - a[i + 1])){
        return true;
    }
    return false;
}

string dfs2(string s, int x){
    int i = s.size();
    if(i == 3){
        return s;
    }
    if(dfs(i + 1, x + a[i + 1])){
        s.push_back('+');
        return dfs2(s, x + a[i + 1]);
    }
    if(dfs(i + 1, x - a[i + 1])){
        s.push_back('-');
        return dfs2(s, x - a[i + 1]);
    }
    return "";
}

int main(){
    string s;
    cin >> s;
    for(int i = 0; i < 4; i++){
        a[i] = s[i] - '0';
    }
    string ans = dfs2("", a[0]);
    for(int i = 0; i < 3; i++){
        cout << a[i] << ans[i];
    }
    cout << a[3] << "=7" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int x = 0;

		// 整数の入力
		String val = sc.next();

		val = val.substring(0, val.length()-8);
		System.out.println(val);

		sc.close();
	}

}


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

int main() {
  
  int a,b;
  cin >> a >> b;
  
  string s1=to_string(a);
  string s2=to_string(b);
  string A,B;
  
  for(int i = 0;i<b;i++) {
    A+=s1;
  }
  for(int i = 0;i<a;i++) {
    B+=s2;
  }
  
  if(a<=b) {
    cout << A <<endl;
  }
  
  else {
    cout << B <<endl;
  }
  return 0;
}


Measured memory_bytes: 256
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 205
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)

using namespace std;

inline void inp( int &n ) { 
	n=0;    int ch=getcx();int sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

inline void inp1( LL &n ) { 
	n=0;    LL ch=getcx();LL sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}
int g[MAX][MAX];
void pre() {
	for(int i=1;i<MAX;i++) {
		for(int j=1;j<MAX;j++) {
			g[i][j] = __gcd(i, j);
		}
	}
}

int main() {
	pre();
	int k, a, b, c;
	cin>>k;
	LL sum = 0;
	for(a=1;a<=k;a++) {
		for(b=1;b<=k;b++) {
			for(c=1;c<=k;c++) {
				sum += g[a][g[b][c]];
			}
		}
	}

	cout<<sum<<endl;
    return 0;
}



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

using namespace std;

int main(){
  int n; cin >> n;
  int m; cin >> m;
  if(m == 1){
    if(n == 1){
      cout << n << "\n";
      cout << 1 << "\n";
      cout << n << "\n";
      return 0;
    }
    cout << n << "\n";
    cout << 2 << "\n";
    cout << "1 " << n-1 << "\n";
    return 0;
  }
  vector<int> odds;
  vector<int> evens;
  for(int i=0;i<m;i++){
    int t; cin >> t;
    if(t % 2 == 0){
      evens.push_back(t);
    }
    else{
      odds.push_back(t);
    }
  }

  if(n % 2 == 0){
    if(odds.size() > 2){
      cout << "Impossible\n";
      return 0;
    }
    if(odds.size() == 2){
      evens.push_back(odds[0]);
      reverse(evens.begin(), evens.end());
      evens.push_back(odds[1]);
    }

    for(int i=0;i<evens.size();i++){
      if(i != 0) cout << " ";
      cout << evens[i];
    }cout << "\n";

    evens[0]++;
    evens[evens.size()-1]--;
    if(evens.back() == 0) evens.pop_back();

    cout << evens.size() << "\n";
    
    for(int i=0;i<evens.size();i++){
      if(i != 0) cout << " ";
      cout << evens[i];
    }cout << "\n";
  }
  else{
    if(odds.size() > 1){
      cout << "Impossible\n";
      return 0;
    }
    evens.push_back(odds[0]);
    for(int i=0;i<evens.size();i++){
      if(i != 0) cout << " ";
      cout << evens[i];
    }cout << "\n";

    cout << evens.size() << "\n";

    evens[0]--;
    evens[evens.size()-1]++;
    
    for(int i=0;i<evens.size();i++){
      if(i != 0) cout << " ";
      cout << evens[i];
    }cout << "\n";
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long LL;
const int maxn=111111;
int A[maxn];
bool vis[maxn];
int main()
{
	int N;scanf("%d",&N);
	for(int i=0;i<N;++i) scanf("%d",A+i);
	LL Ans=0;
	for(int i=1;i<N;++i)
	{
		LL ans=0;
		for(int j=0,k=N-1;j<N-1-i&&!vis[j]&&!vis[k]&&j!=k;j+=i,k-=i)
		{
			vis[j]=vis[k]=true;
			ans+=(A[j]+A[k]);
			Ans=max(Ans,ans);
//			printf("%d %d %d %lld\n",i,j,k,ans);
		}
		for(int j=0,k=N-1;j<N-1-i&&vis[j]&&vis[k];j+=i,k-=i) vis[j]=vis[k]=false;
	}
	printf("%lld",Ans);
	return 0;
}

Measured memory_bytes: 768
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
	int a,b;
	for(;;){
		scanf("%d%d",&a,&b);
		if(a==0&&b==0) break;
		if(a<b) swap(a,b);
		int i;
		for(i=0;b!=0;i++){
			int t=a;
			a=b;
			b=t%b;
		}
		printf("%d %d\n",a,i);
	}
}

Measured memory_bytes: 1028
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <stdlib.h>
#include <math.h>
using namespace std;

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

	vector<int> p(N);
	vector<int> sorted(N);

	for (int i = 0; i < N; i++)
	{
		cin >> p[i];
		sorted[i] = p[i];
	}

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

	int cnt = 0;
	int prev = 0;
	vector<int> list;
	for (int i = 0; i < N; i++)
	{
		if (sorted[i] != p[i])
		{
			cnt++;
			list.push_back(i);
		}
	}
	
	if (cnt == 0)
	{
		cout << "YES" << endl;
		return 0;
	}

	if (cnt != 2)
	{
		cout << "NO" << endl;
		return 0;
	}


	int a = p[list[0]];
	int b = p[list[1]];

	p[list[0]] = b;
	p[list[1]] = a;

	cnt = 0;
	for (int i = 0; i < N; i++)
	{
		if (sorted[i] != p[i])
		{
			cnt++;
		}
	}

	string ans = "NO";
	if (cnt == 0)
	{
		ans = "YES";
	}


	cout << ans << endl;

	return 0;

}

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

int main() {
    int n;cin>>n;
    int a[n];
    int ans[100000+1]={0};
    for(int i=0;i<n;i++){
        cin>>a[i];
        ans[a[i]]++;
    }
    ll sum=0;
    for(int i=0;i<100000+1;i++){
        if(ans[i]>1)sum+=ans[i]-1;
    }
    if(sum%2==0)cout<<n-sum<<endl;
    else cout<<n-sum-1<<endl;
}

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

int main(void){
  vector < vector <int> > square;
  square.resize(14);
  for(int i=0; (int)i<square.size(); i++){
    square[i].resize(14);
  }
  for(int i=0; i<(int)square.size(); i++){
    for(int j=0; j<(int)square[i].size(); j++){
      square[i][j] =0;
    }
  }

  int x, y, size;
  int min=0, max=0;
  char c;

  while( cin >> x >> c >> y >> c >> size ){
    x+=2;
    y+=2;
    if(size>=1 && size<=3){
      square[y][x]++;
      square[y][x-1]++;
      square[y-1][x]++;
      square[y+1][x]++;
      square[y][x+1]++;
    }
    if(size==2 || size==3){
      square[y-1][x-1]++;
      square[y+1][x-1]++;
      square[y-1][x+1]++;
      square[y+1][x+1]++;
    }
    if(size==3){
      square[y][x-2]++;
      square[y-2][x]++;
      square[y+2][x]++;
      square[y][x+2]++;
    }
  }

  for(int i=2; (int)i<square.size()-2; i++){
    for(int j=2; (int)j<square.size()-2; j++){
      if( square[i][j]==0 ){
        min++;
      }else if(max < square[i][j]){
        max=square[i][j];
      }
    }
  }

  cout << min << endl << max << endl;
  return 0;
}

Measured memory_bytes: 1200
#include<iostream>
using namespace std; 
int main (){
  int n,i,a[110],temp,count=0,j;
  while(1){
    count=0;
    cin >> n;
    if(n==0)break;
    for(i=0;i<n;i++){
      cin >> a[i];
    }
    for(i=0;i<n;i++){
      for(j=n-1;j>i;j--){
	if(a[j-1]>a[j]){
	  temp=a[j];
	  a[j]=a[j-1];
	  a[j-1]=temp;
	  count++;
	}
      }
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int count(string s1, string s2) {
	int n = s1.size();
	int m = s2.size();
	map<char, int> map, ch;
	for (int i=0; i<n; i++) {
		map[s1[i]] = 1;
	}
	int c = 0;
	for (int i=0; i<m; i++) {
		if (map[s2[i]] == 1 && ch[s2[i]] == 0) {
			c++;
			ch[s2[i]] = 1;
		}
	}
	return c;
}
int main () {
	int n;
	string s1, s2, s;
	cin >> n;
	cin >> s;
	int ans = 0;
	for (int i=1; i<n; i++) {
		s1 = s.substr(0, i);
		s2 = s.substr(i, n-i+1);
		ans = max(ans, count(s1, s2));
	}
	cout << ans;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> num(N);
  
  for(int i=0; i<N; i++){
    cin >> num.at(i);
  }
  
  sort(num.begin(), num.end());
  reverse(num.begin(), num.end());
  
  int A=0, B=0;
  
  for(int i=0; i<N; i++){
    if(i%2==0) A += num.at(i);
    else B += num.at(i);
  }
  
  cout << A-B << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>

using namespace std;

void solve(int n, vector<int> a) {
    int oo = 0;
    for (int i = 0; i < n; i++) {
        if (a[i]%2 == 0) {
            oo++;
        }
    }
    std::cout << (int)(pow(3, n) - pow(2, oo)) << std::endl;
}

int main() {
    struct timeval start,end;
    long long span;
    int n;

    gettimeofday(&start,NULL);

    std::cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    solve(n, a);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())

if n <= 111:
    print(111)
elif n <= 222:
    print(222)
elif n <= 333:
    print(333)
elif n <= 444:
    print(444)
elif n <= 555:
    print(555)
elif n <= 666:
    print(666)
elif n <= 777:
    print(777)
elif n <= 888:
    print(888)
elif n <= 999:
    print(999)


Measured memory_bytes: 38384
n, *h = map(int, open(0).read().split())
h += 0,
a = b = 0
while sum(h):
    if h[b] > 0: a += 1
    else: b = (b+1)%(n+1); continue
    while h[b] >0:
        h[b] -= 1
        b += 1
print(a)

Measured memory_bytes: 2940
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
int MOD = 1000000007;

int main() {
	double a, b, C; cin >> a >> b >> C;
	C *= M_PI / 180;
	double S = 0.5 * a * b * sin(C);
	double c = sqrt(a * a + b * b - 2 * a * b * cos(C));
	double L = a + b + c;
	double h = 2 * S / a;
	printf("%f %f %f\n", S, L, h);
}

Measured memory_bytes: 1232