akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,k;
  cin >> n >> k;
  double p[k];
  mem(p);
  p[0]=1;
  REP(i,1,k) p[i]=p[i-1]/2;
  double ans=0;
  REP(i,1,n+1) {
    double q=1.0/n;
    ll x=i,c=0;
    while(x<k) {
      c++;
      x*=2;
    }
    ans+=q*p[c];
  }
  pd(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

using namespace std;

template<typename T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << "[";
  for (T &i: v) os << i << ",";
  os << "]";
  return os;
}

template<class TH> void _dbg(const char *sdbg, TH h){ cout<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cout<<*sdbg++;
  cout<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef __DJKIM613
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#endif

typedef pair<int, int> pii;
int N;
vector<pii> ans;
int main(void){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);

  cin >> N;
  if(N & 1){
    for(int i = 1 ; i <= N; i++){
      for(int j = i + 1; j <= N ; j++){
        if(N == i + j) continue;
        ans.push_back({i, j});
      }
    }
  }
  else{
    for(int i = 1 ; i <= N ; i++){
      for(int j = i + 1 ; j <= N ; j++){
        if(N + 1 == i + j) continue;
        ans.push_back({i, j});
      }
    }
  }

  cout << ans.size() << '\n';
  for(pii val : ans) cout << val.first << ' ' << val.second << '\n';
  return 0;
}

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

string S;
string S1;
string S2;
string rS1;
string rS2;
int N;

int main()
{
    cin >> S;
    N = S.size();
    S1 = S.substr(0, (N - 1)/2);
    S2 = S.substr((N + 3)/2 - 1);
    for(int i = S1.size() - 1; i >= 0; i--) rS1 += S1[i];
    for(int j = S2.size() - 1; j >= 0; j--) rS2 += S2[j];

    if(S1 != rS1) 
    {
        cout << "No" << endl;
    }
    else if(S2 != rS2)
    {
        cout << "No" << endl;
    }
    else if(S1 != rS2)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
    
    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	int n,k;
	char a[100];
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	a[k]+=32;
	for(int i=1;i<=n;i++)
		cout<<a[i];
}

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

class Dice{
    public:
    int val[6];

    Dice(int a[]){
        copy(a,a+6,val);
    }

    int side(){
        return val[2];
    }

    bool match(Dice other){
        bool res = true;
        rep(i,6) {
            if(other.val[i] != val[i]){
                res = false;
                break;
            }
        }
        return res; 
    }

    void move(char c){
        if(c == 'N') {
            int tmp = val[0];
            val[0] = val[1];
            val[1] = val[5];
            val[5] = val[4];
            val[4] = tmp;
        }
        if(c == 'W') {
            int tmp = val[1];
            val[1] = val[3];
            val[3] = val[4];
            val[4] = val[2];
            val[2] = tmp;
        }
        if(c == 'E') {
            int tmp = val[1];
            val[1] = val[2];
            val[2] = val[4];
            val[4] = val[3];
            val[3] = tmp;
        }
        if(c == 'S') {   
            int tmp = val[0];
            val[0] = val[4];
            val[4] = val[5];
            val[5] = val[1];
            val[1] = tmp;
        }
    }
};

int main() {
    string str = "WWWWNWWWWWSWWWWSSWWWWNWWWWWSWWWW";
    int a[6],b[6];
    rep(i,6) cin >> a[i];
    rep(i,6) cin >> b[i];
    Dice da(a);
    Dice db(b);
    for(auto &s : str){
        db.move(s);
        if(db.match(da)) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3200
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

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

  int l, r;
  cin >> l >> r;

  if (r - l + 1 >= 2019)
  {
    cout << 0 << endl;
  }
  else
  {
    long long ans = 2019;

    for (long long li = l; li <= r; li++)
    {
      for (long long ri = li + 1; ri <= r; ri++)
      {
        ans = min(li * ri % 2019, ans);
      }
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 888
import java.util.*;
public class Main {
	public static void main(String[] $) {
		var c = new Scanner(System.in);
		int m = 998244353, n = c.nextInt(), s = c.nextInt();
		int[] a = new int[n], d = new int[3001];
		Arrays.setAll(a, i -> Integer.parseInt(c.next()));
		d[0] = 2; d[a[0]] = 1;
		for (int i = 1; i < n; i++) {
			for (int j = s; j >= 0; j--) {
				d[j] <<= 1;
				if (d[j] >= m) d[j] -= m;
				if (j >= a[i]) {
					d[j] += d[j - a[i]];
					if (d[j] >= m) d[j] -= m;
				}
			}
		}
		System.out.print(d[s]);
	}
}

Measured memory_bytes: 40032
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef pair <int, int> pii;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
//  order_of_key (k) : Number of items strictly smaller than k .
//  find_by_order(k) : K-th element in a set (counting from zero).
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
//#define int ll

const int N = 2e5 + 5;
const int INF = 1e9 + 5;

ll h, ans, x = 1;

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> h;
	while(h) {
		ans += x;
		x *= 2;
		h /= 2;
	}
	cout << ans;
	return 0;
}
/*
	If you only do what you can do, 
	You will never be more than you are now!
*/

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(pos, len) for(int pos=0;pos<len;pos++)
#define repp(pos, len) for(int pos=1;pos<=len;pos++)

#define INF 987654321
#define IINF 2987654321987654321
#define MOD 998244353

inline void no() {
	printf("-1\n");
	exit(0);
}

const int MAXN = 1e5 + 50;
char s[MAXN];

int main() {
	scanf("%s", s+1);
	int n = strlen(s+1);

	if(s[n] == '1' || s[1] == '0') no();
	for(int i = 1; i <= n-1; i++)
		if(s[i] != s[n-i]) no();

	vector<int> v;
	v.push_back(n);
	for(int i = n/2; i >= 1; i--)
		if(s[i] == '1') v.push_back(i);

	int cur = 1, id = 1;
	for(int i = 0; i < (int)v.size()-1; i++) {
		int d = v[i] - v[i+1];
		rep(t, d) printf("%d %d\n", cur, ++id);
		cur = id;
	}
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
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; }
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); i++)
int cnt_digits(ll N){
 int digits=0;

 while(N>0){
 N/=10;
 digits++;
 }

 return digits;
 }
int main() {
  ll N;
  cin >> N;
  int ans=1e9;
  int cnt=0;
  int temp=0;
  for(ll i=1;i*i<=N;i++){
    if((N)%i==0){
      temp=max(cnt_digits(i),cnt_digits((N/i)));
      ans=min(ans,temp);
    }

  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
int main()
{
	#define int long long
	int n,k;
	cin >> n >> k;
	int a[n];
	for(int i = 0; i < n; i++)
	cin >> a[i];
	int ans = INT_MAX;
	for(int i = 0; i < n; i++)
	{
		if(i+k-1 >= n)
		break;
		int x = a[i+k-1];
		int y = a[i];
		if(y <= 0 && x >= 0)
		{
			int d = abs(y)+abs(x)+min(abs(x),abs(y));
			ans = min(ans,d);
		}
		else if(y >= 0 && x >= 0)
		{
			int d = abs(x);
			ans = min(ans,d);
		}
		else if(y <= 0 && x <= 0)
		{
			int d = abs(y);
			ans = min(ans,d);
			
		}
	}
	cout << ans << "\n";
	return 0;
}

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

typedef long long ll;
int main(){
    ll n,flag=1;
    cin >> n;
    vector<ll> t(n+1,0),x(n+1,0),y(n+1,0);
    for(int i=0;i<n;i++)cin >> t.at(i+1) >> x.at(i+1) >> y.at(i+1);
    for(int i=0;i<n;i++){
        if(t.at(i+1)-t.at(i)==1&&x.at(i+1)-x.at(i)==0&&y.at(i+1)-y.at(i)==0){
            flag=0;
            break;
        }
        else if(x.at(i+1)+y.at(i+1)-x.at(i)-y.at(i)<=t.at(i+1)-t.at(i)&&(t.at(i+1)-t.at(i)-(x.at(i+1)+y.at(i+1)-x.at(i)-y.at(i)))%2==0){
        }
        else{
            flag=0;
            break;
        }
    }
    cout << ((flag)?"Yes":"No") << endl;
}

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

int main() {
	bool flag = false;
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 0; i <= n; i++) {
		for(int j = 0; j <= m; j++) {
			int black = 0;
			black += i*m;
			black += j*(n - 2*i);
			if (black == k)flag = true;
		}
	}
	if (flag)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
 
int A[2000],n;
 
bool solve(int i,int m){
  if(i==n) return m==0;
  if( solve(i+1,m) ) return true;
  if( solve(i+1,m-A[i]) ) return true;
  return false;
 
}
 
int main(){
 
  int m,q;
  scanf("%d",&n);
  for(int i=0;i<n;i++)
    scanf("%d",&A[i]);
  scanf("%d",&m);
  for(int i=0;i<m;i++){
    scanf("%d",&q);
    if(solve(0,q)==true) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}


Measured memory_bytes: 2620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
//#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int N; cin >> N;
  vector<int> x(N), y(N), h(N);
  rep(i, N) cin >> x[i] >> y[i] >> h[i];

  
  rep(X, 101) rep(Y, 101) {
    int H = 0;
    int n = 0;
    while(H < 1) {
      if(h[n] > 0) H = abs(x[n]-X) + abs(y[n]-Y) + h[n];
      n++;
    }
    rep(i, N) {
      if(max(H - abs(x[i]-X) - abs(y[i]-Y) , 0) != h[i]) break;
      if(i == N-1) {
        cout << X << " " << Y << " " << H << endl;
        return 0;
      }
    }
  }

}


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

import sys
sys.setrecursionlimit(1000000)

N = 1
a = []

def sol(x, cnt) : 
    cnt+=1
    if a[x-1] == 2 :
        return cnt
    if cnt > N :
        return -1

    return sol(a[x-1], cnt)


if __name__ == '__main__' : 
    N = int(input())

    for i in range(N) : 
        a.append(int(input()))

    print( sol(1,0) )

Measured memory_bytes: 93004
#include <stdio.h>




int main(){

	int dice[6];
	int n, t, f, top, front, i, j;

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


	scanf( "%d", &n );

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

		scanf( "%d %d", &t, &f );

		for( i=0; i<6; i++ ){
			if( t == dice[i] ) top = i;
			if( f == dice[i] ) front = i;
		}

		if( top == 0 ){
			if( front == 1 ) printf( "%d\n", dice[2] );
			if( front == 2 ) printf( "%d\n", dice[4] );
			if( front == 4 ) printf( "%d\n", dice[3] );
			if( front == 3 ) printf( "%d\n", dice[1] );
		}

		if( top == 1 ){
			if( front == 5 ) printf( "%d\n", dice[2] );
			if( front == 2 ) printf( "%d\n", dice[0] );
			if( front == 0 ) printf( "%d\n", dice[3] );
			if( front == 3 ) printf( "%d\n", dice[5] );
		}

		if( top == 2 ){
			if( front == 5 ) printf( "%d\n", dice[4] );
			if( front == 4 ) printf( "%d\n", dice[0] );
			if( front == 0 ) printf( "%d\n", dice[1] );
			if( front == 1 ) printf( "%d\n", dice[5] );

		}

		if( top == 3 ){
			if( front == 5 ) printf( "%d\n", dice[1] );
			if( front == 1 ) printf( "%d\n", dice[0] );
			if( front == 0 ) printf( "%d\n", dice[4] );
			if( front == 4 ) printf( "%d\n", dice[5] );
		}

		if( top == 4 ){
			if( front == 5 ) printf( "%d\n", dice[3] );
			if( front == 3 ) printf( "%d\n", dice[0] );
			if( front == 0 ) printf( "%d\n", dice[2] );
			if( front == 2 ) printf( "%d\n", dice[5] );
		}

		if( top == 5 ){
			if( front == 1 ) printf( "%d\n", dice[3] );
			if( front == 2 ) printf( "%d\n", dice[1] );
			if( front == 4 ) printf( "%d\n", dice[2] );
			if( front == 3 ) printf( "%d\n", dice[4] );
		}


	}


	return 0;

}

Measured memory_bytes: 596
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  vector<int> v;
  for(int i=0;i<3;i++){
   int a;
  cin>>a;
  v.push_back(a);
}
sort(v.begin(),v.end());
cout<<v[2]-v[0];
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String args[]) throws IOException {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        String s = bufferedReader.readLine();
        int numberDigitTotal = 0;

        for(int i = 0; i < s.length(); i++)
        {
            numberDigitTotal += Integer.parseInt(s.substring(i,i + 1));
        }

        if(numberDigitTotal % 9 != 0)
        {
            System.out.println("No");
        }
        else
        {
           System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 46148
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
 
	Scanner sc  = new Scanner(System.in);
        
    int cnt = 0;

	int  i1 = 0 ,i2 = 0, i3 = 0;
	long L1 = 0, L2 = 0, L3 = 0;
	char ch;
	String str = "";
		

    String s1 = sc.next();
    char[] c1 = s1.toCharArray();

    if(c1[0]=='a'||c1[0]=='e'||c1[0]=='i'||c1[0]=='o'||c1[0]=='u')
    {System.out.print("vowel");}
    else{         System.out.print("consonant");
}
        System.out.println();
	}
        
}

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

using namespace std;
using namespace std::chrono;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
int mod=1000000007;
const int MX=0x3f3f3f3f;

	
int main() {
	IOS;
	ll x;
	cin>>x;
	ll i=0;
	ll tt=100;
	while(tt<x){
		tt+=(tt/100);
		i++;
	}
	cout<<i;
	return 0;
}

Measured memory_bytes: 3636
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	public static void main(String[]args){
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	long w=0,h=0;
	int d[]=new int[a];
	int e[]=new int[a];
	int count=0;
	for(int i=0;i<a;i++) {
		d[i]=scan.nextInt();
	}
	Arrays.sort(d);
	for(int i=0;i<a;i++) {
		e[i]=d[a-i-1];
	}
	for(int i=1;i<a;i++) {
		if(e[i]==e[i-1]) {
			i++;
			if(count==0) {
				w=e[i-1];
				count++;
			}
			else {
				h=e[i-1];
				break;
			}
		}
	}
	System.out.println(w*h);
	}
}

Measured memory_bytes: 50696
#include <iostream>
#include <cstdio>
#include <list>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
list<int> l;
int n,num;
char com[20];
void Delete(int num){
	for(list<int>::iterator it = l.begin();it != l.end();it++){
		if(*it == num){
			l.erase(it);
			break;
		}
	}
}
int main(int argc, char const *argv[])
{
	cin >> n;
	for(int i = 0;i < n;i++){
		scanf("%s",com);
		int len = strlen(com);
		if(len == 6){
			scanf("%d",&num);
			if(com[0] == 'i')	l.push_front(num);
			else	Delete(num);
		}
		else{
			if(com[6] == 'F')	l.pop_front();
			else	l.pop_back();
		}
	}
	for(list<int>::iterator it = l.begin();it != l.end();it++){
		if(it == l.begin()){
			printf("%d",*it);
			continue;
		}
		printf(" %d",*it);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 34412
#include<stdio.h>

int main(){

    int N, A, F, QA;
    scanf("%d", &N);
    scanf("%d", &A);

    F = 500;
    QA = N % F;

    if(QA <= A){
        printf("Yes");
    }
    else{
        printf("No");
    }

    return 0;
}


Measured memory_bytes: 128
n,m = gets.split.map(&:to_i)
a={}
m.times{|i|
  q,y = gets.split.map(&:to_i)
  a[q] = [] if !a[q]
  a[q] << [y, i]
}
ans = []
a.each{|p, v|
  v.sort!
  v.each.with_index{|item, j|
    ans << [item[1], p, j]
  }
}
ans.sort!
ans.each{|_,p,j|
  puts sprintf "%06d%06d", p, j+1
}

Measured memory_bytes: 40432
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int k;
    cin >> k;
    int ans = 1;
    int now = 7 % k;
    rep(i, 2 * k) {
        if (now) {
            now = (now * 10 + 7) % k;
            ans++;
        } else {
            cout << ans << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3588
N, M = map(int, input().split())

f = set()
t = set()

for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        f.add(b)
    elif a == N:
        t.add(b)
    if b == 1:
        f.add(a)
    elif b == N:
        t.add(a)

pos = "IMPOSSIBLE"

if f&t:
    pos = "POSSIBLE"

print(pos)

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

signed main(){
  
  int n;
  cin>>n;
  
  int p[4]={0};
  while(n--){
    string s;
    cin>>s;
    if(s[0]=='A')
      p[0]++;
    if(s[0]=='W')
      p[1]++;
    if(s[0]=='T')
      p[2]++;
    if(s[0]=='R')
      p[3]++;
  }
  
  for(int i=0;i<4;i++){
    if(i==0)
      cout<<"AC x "<<p[i]<<"\n";
    if(i==1)
      cout<<"WA x "<<p[i]<<"\n";
    if(i==2)
      cout<<"TLE x "<<p[i]<<"\n";
    if(i==3)
      cout<<"RE x "<<p[i]<<"\n";
  }
}

Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,k,p,ans[100],i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&k,&p);
		if(k%p==0){
			ans[i]=p;
		}
		else{
			ans[i]=k%p;
		}
	}
	for(i=0;i<n;i++){
		printf("%d\n",ans[i]);
	}
	return 0;
}



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

int main (void) {
  ios::sync_with_stdio(false);cin.tie(0);
  cout << fixed << setprecision(15);
  string s, t;
  cin >> s >> t;
  int ans = 0;
  int n = s.length();
  for (int i = 0; i < n; i++)
    if (s[i] != t[i]) ans++;
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 3760
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <limits>

using namespace std;

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

  int N;
  cin >> N;

  vector<unsigned> v(N);
  vector<vector<size_t>> dp(N+1, vector<size_t>(N+1, 0));
  vector<size_t> sums(N, 0); 

  for (int i = 0; i < N; ++i)
  {
    cin >> v[i];
    sums[i] = v[i] + (i > 0 ? sums[i-1] : 0); 
  }

  for (int R = 1; R <= v.size(); ++R)
  {
    for (int L = R-1; L >= 0; --L)
    {   
      if (L+1 >= R) continue;
      size_t res = numeric_limits<size_t>::max();
      for (int k = L+1; k < R; ++k)
      {   
        res = min(res, dp[L][k] + dp[k][R]);
      }   
      const size_t s = L > 0 ? sums[R-1] - sums[L-1] : sums[R-1];
      dp[L][R] = res + s;
    }   
  }

  std::cout << dp[0][N];

  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int N, C; cin >> N >> C;
    vector<int> imos(1e5+2);
    vector<vector<pair<int, int>>> vec(C);
    rep(i, N) {
        int s, t, c;
        cin >> s >> t >> c;
        vec[--c].push_back(make_pair(s, t));
    }
    rep(i, C) {
        bool flag = true;
        rep(j, vec[i].size()) {
            int s = vec[i][j].first, t = vec[i][j].second;
            if (flag) imos[s-1]++;
            if (j+1 >= vec[i].size()) {
                imos[t]--;
                continue;
            }
            if (vec[i][j+1].first == t) {
                flag = false;
                continue;
            }
            imos[t]--;
            flag = true;
        }
    }
    rep(i, imos.size()-1) imos[i+1] += imos[i];
    cout << min(C, vmax(imos)) << endl;
}


Measured memory_bytes: 4828
module ABC126

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public  :: task_B
  private :: extract_data
  private :: is_month
  private :: write_format

  ! variables for this <module>
  integer(INT32), private :: given_data
  integer(INT32), private :: data_first
  integer(INT32), private :: data_second

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_B

    ! STEP.01
    ! read out the given string
    read(unit=INPUT_UNIT, fmt='(I4)') given_data

    ! STEP.02
    ! convert the given string to two integers
    call extract_data

    ! STEP.03
    ! judge & output the format of the given data
    if ( is_month(data_first) )  then
      if ( is_month(data_second) ) then
        call write_format('AMBIGUOUS')
      else
        call write_format('MMYY')
      end if
    else
      if ( is_month(data_second) ) then
        call write_format('YYMM')
      else
        call write_format('NA')
      end if
    end if

    ! STEP.END
    return

  end subroutine task_B

  subroutine extract_data

    data_first  = given_data / 100_INT32
    data_second = mod(given_data, 100_INT32)

    return

  end subroutine extract_data

  pure function is_month (val) result(stat)

    ! arguments for this <function>
    integer(INT32), intent(in) :: val

    ! return value of this <function>
    logical :: stat

    stat = 1_INT32 .le. val .and. val .le. 12_INT32
    return

  end function is_month

  subroutine write_format (format)

    ! arguments for this <subroutine>
    character(len=*, kind=1), intent(in) :: format

    write(unit=OUTPUT_UNIT, fmt='(A)', advance='yes') format
    return

  end subroutine write_format

end module ABC126


program main

  ! <module>s to import
  use, non_intrinsic :: ABC126

  ! require all variables to be explicitly declared
  implicit none

  call task_B

end program main

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

using namespace std;


typedef long long ll;
ll mod=1e9+0LL;
ll MOD=1e18+0LL;
double pi=acos(-1);


int main()
{
    int cs=1;
    //scanf("%d",&cs);
    while(cs--)
    {
        int n,i;cin>>n;
        ll mul=1LL;
        ll arr[n];
        for(i=0;i<n;i++) {cin>>arr[i];
        if(arr[i]==0) mul=0;}
        if(!mul)
        {
            cout<<0;
            return 0;
        }
        long double power=0;
        for(i=0;i<n;i++)
        {
            power+=log10(arr[i]);
        }
        if(power>18.1)
        {
            cout<<-1;
            return 0;
        }
        for(i=0;i<n;i++)
        {
            mul*=arr[i];
        }
        if(mul>1000000000000000000)
        {
            cout<<-1;
            return 0;
        }
        cout<<mul;
    }
}


Measured memory_bytes: 4636
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define lc (o<<1)
#define rc (o<<1|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=200005;
int mn[N<<2],cnt[N<<2],tag[N<<2],a[N],c[N];
int n,m,x,y;

void app(int o,int v){
	mn[o]+=v,tag[o]+=v;
}
void down(int o){
	if(tag[o]) app(lc,tag[o]),app(rc,tag[o]),tag[o]=0;
}
void up(int o){
	mn[o]=min(mn[lc],mn[rc]),cnt[o]=0;
	if(mn[o]==mn[lc]) cnt[o]+=cnt[lc];
	if(mn[o]==mn[rc]) cnt[o]+=cnt[rc];
}
void build(int o,int l,int r){
	cnt[o]=r-l+1;
	if(l==r) return;
	build(ls),build(rs);
}
void upd(int o,int l,int r,int x,int y,int z){
	if(x>y) return;
	if(l==x&&y==r) return app(o,z);
	down(o);
	if(x<=mid) upd(ls,x,min(y,mid),z);
	if(mid<y) upd(rs,max(mid+1,x),y,z);
	up(o);
}
void add(int i,int op){
	upd(1,1,n,max(1,i-c[i]+1),i,op);
}

int main(){
	read(n),read(m);
	rep(i,1,n){
		read(a[i]);
		c[a[i]]++;
	}
	build(1,1,n);
	rep(i,1,n) add(i,1);
	rep(i,1,m){
		read(x),read(y);
		add(a[x],-1),add(y,-1);
		c[a[x]]--,c[y]++;
		add(a[x],1),add(y,1);
		a[x]=y;
		printf("%d\n",mn[1]==0?cnt[1]:0);
	}
	return 0;
}

Measured memory_bytes: 11520
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, M, A, B, C;
	string S, T;

	cin >> A >> B >> C;
	if (A == B || B == C || A == C) {
		if(A==B&&B==C)cout << "No" << endl;
		else cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

int main()
{
    int w, h, n;
    cin >> w >> h >> n;

    int i;
    int ans = w * h;
    int startX = 0;
    int startY = 0;
    int endX = w;
    int endY = h;
    for(i = 0; i < n; i ++)
    {
    	int x, y, a;
    	cin >> x >> y >> a;
    	x = max(x, startX);
    	x = min(endX, x);
    	y = min(endY, y);
    	y = max(y, startY);
    	if(a == 1)
    	{
    		ans = ans - (x - startX) * (endY - startY);
    		startX = x;
    	}
    	else if(a == 2)
    	{
    		ans = ans - (endX - x) * (endY - startY);
    		endX = x;
    	}
    	else if(a == 3)
    	{
    		ans = ans - (endX - startX) * (y - startY);
    		startY = y;
    	}
    	else if(a == 4)
    	{
    		ans = ans - (endY - y) * (endX - startX);
    		endY = y;
    	}
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>

using namespace std;

long long p;
long long j[65005];

int main()
{
    int n;
    long long sum;
    long long ans;

    scanf("%d", &n);
    while (n != 0) {
        sum = 0;
        ans = 0;
        for (int i = 0; i < n; i++) {
            scanf("%d", &p);
            sum += p;
        }
        for (int i = 0; i < n - 1; i++) {
            scanf("%d", &j[i]);
        }
        sort(j, j + n - 1, greater<int>());


        ans = sum * n;

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

            ans = max(ans, sum * n);
        }
        
        cout << ans << endl;
        
        scanf("%d", &n);
    }

    return 0;
}



Measured memory_bytes: 3716
// D - Dice in Line
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
int in(){int x;cin>>x;return x;}
int N,K;
vector<int> S(1);//累積和

int main(){
	cin>>N>>K;
	rp(i,0,N) S.push_back(S[i] + in()+1);
	int ans = 0;
	rp(i,0,N-K+1) ans = max(ans, S[i+K]-S[i]);
	printf("%.12f\n",ans/2.0);
}

Measured memory_bytes: 1400
/*⠄⢰⣧⣼⣯⠄⣸⣠⣶⣶⣦⣾⠄⠄⠄⠄⡀⠄⢀⣿⣿⠄⠄⠄⢸⡇⠄⠄
⠄⠄⠄⣾⣿⠿⠿⠶⠿⢿⣿⣿⣿⣿⣦⣤⣄⢀⡅⢠⣾⣛⡉⠄⠄⠄⠸⢀⣿⠄
⠄⠄⢀⡋⣡⣴⣶⣶⡀⠄⠄⠙⢿⣿⣿⣿⣿⣿⣴⣿⣿⣿⢃⣤⣄⣀⣥⣿⣿⠄
⠄⠄⢸⣇⠻⣿⣿⣿⣧⣀⢀⣠⡌⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠿⠿⣿⣿⣿⠄
⠄⢀⢸⣿⣷⣤⣤⣤⣬⣙⣛⢿⣿⣿⣿⣿⣿⣿⡿⣿⣿⡍⠄⠄⢀⣤⣄⠉⠋⣰
⠄⣼⣖⣿⣿⣿⣿⣿⣿⣿⣿⣿⢿⣿⣿⣿⣿⣿⢇⣿⣿⡷⠶⠶⢿⣿⣿⠇⢀⣤
⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣽⣿⣿⣿⡇⣿⣿⣿⣿⣿⣿⣷⣶⣥⣴⣿⡗
⢀⠈⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠄
⢸⣿⣦⣌⣛⣻⣿⣿⣧⠙⠛⠛⡭⠅⠒⠦⠭⣭⡻⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⠄
⠘⣿⣿⣿⣿⣿⣿⣿⣿⡆⠄⠄⠄⠄⠄⠄⠄⠄⠹⠈⢋⣽⣿⣿⣿⣿⣵⣾⠃⠄
⠄⠘⣿⣿⣿⣿⣿⣿⣿⣿⠄⣴⣿⣶⣄⠄⣴⣶⠄⢀⣾⣿⣿⣿⣿⣿⣿⠃⠄⠄
⠄⠄⠈⠻⣿⣿⣿⣿⣿⣿⡄⢻⣿⣿⣿⠄⣿⣿⡀⣾⣿⣿⣿⣿⣛⠛⠁⠄⠄⠄
⠄⠄⠄⠄⠈⠛⢿⣿⣿⣿⠁⠞⢿⣿⣿⡄⢿⣿⡇⣸⣿⣿⠿⠛⠁⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠉⠻⣿⣿⣾⣦⡙⠻⣷⣾⣿⠃⠿⠋⠁⠄⠄⠄⠄⠄⢀⣠⣴
⣿⣿⣿⣶⣶⣮⣥⣒⠲⢮⣝⡿⣿⣿⡆⣿⡿⠃⠄⠄⠄⠄⠄⠄⠄⣠⣴⣿*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int n;
ll arr[205];
string s;

ll bias[62];

void add_bias(ll i){
	rep(bit,0,62){
		if ((i&(1LL<<bit))==0) continue;
		
		if (bias[bit]==0){
			bias[bit]=i;
			return;
		}
		
		i^=bias[bit];
	}
}

bool check_bias(ll i){
	rep(bit,0,62){
		if ((i&(1LL<<bit))==0) continue;
		
		if (bias[bit]==0){
			return false;
		}
		
		i^=bias[bit];
	}
	
	return true;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int TC;
	cin>>TC;
	while (TC--){
		memset(bias,0,sizeof(bias));
		
		cin>>n;
		rep(x,0,n) cin>>arr[x];
		cin>>s;
		
		rep(x,n,0){
			if (s[x]=='0') add_bias(arr[x]);
			else if (!check_bias(arr[x])){
				cout<<1<<endl;
				goto _end;
			}
		}
		
		cout<<0<<endl;
		_end:;
	}
}


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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

int main() {

  Dictionary a;

  int x;
  string y;
  char comma;
  loop {
    cin >> x >> comma >> y;
    if (!cin) break;
    a[y]++;
  }

  cout << a["A"] << endl;
  cout << a["B"] << endl;
  cout << a["AB"] << endl;
  cout << a["O"] << endl;

  return 0;
}

Measured memory_bytes: 1220
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#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++)
const long long INF =  999999999;

int main(){
  string s;
  cin>>s;
  if(s.length()%2==1)cout<<"No"<<endl;
  else{
    bool flag=true;
    REP(i,s.length()/2){
      if(s[2*i]!='h' || s[2*i+1]!='i'){
        flag=false;
      }
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}


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

using namespace std;

int main() {

    int N, T;
    cin >> N >> T;

    int c[N + 1], t[N + 1];
    for (int i = 1; i <= N; i++) {
        cin >> c[i] >> t[i];
    }

    int ans = 1001;

    for (int i = 1; i <= N; i++) {
        if(t[i] <= T) {
            if (c[i] <= ans) {
                ans = c[i];
            }
        }
    }

    if (ans == 1001) {
        cout << "TLE" << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline int msbp(int x) {return 31-__builtin_clz(x);}
inline int msb(int x) {return 1 << msbp(x);}
typedef long long ll;
typedef pair<int, int> pii;
// const ll INF = 0x3f3f3f3f3f3f3f3fLL;
const int INF = 0x3f3f3f3f;
// const int INF = INT_MAX;
// const int nINF = INT_MIN;
// const ll INF = LLONG_MAX;
// const ll nINF = LLONG_MIN;

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

const int N = 2e5+10, M = 1e9+7;

ll mod(ll x) {return (x % M + M) % M;}
int add(ll a, ll b) {return mod(mod(a)+mod(b));}
int mult(ll a, ll b) {return mod(mod(a)*mod(b));}

int n, k, a[N], ans = 1;
vector<int> pos, neg;

signed main() {
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);
    cin >> n >> k;
    REP(i, n) cin >> a[i];
    REP(i, n) {
    	if(a[i] > 0) {
    		pos.push_back(a[i]);
    	} else {
    		neg.push_back(a[i]);
    	}
    }
    if(pos.size()) {
		// we have a choice on number of positive numbers.
		if(k & 1) {
			// choose the biggest positive number first
			sort(pos.begin(), pos.end());
			ans = pos.back();
			pos.pop_back();
			--k;
		}
		vector<ll> all;
		sort(pos.begin(), pos.end(), greater<int>());
		sort(neg.begin(), neg.end());
		for(int i = 0; i+1 < pos.size(); i += 2) all.push_back((ll)pos[i]*pos[i+1]);
		for(int i = 0; i+1 < neg.size(); i += 2) all.push_back((ll)neg[i]*neg[i+1]);
		if((pos.size() & 1) && (neg.size() & 1)) all.push_back((ll)pos.back()*neg.back());
		sort(all.begin(), all.end(), greater<ll>());
		REP(i, k/2) {
			ans = mult(ans, all[i]);
		}
		cout << ans << endl;
    } else {
    	sort(neg.begin(), neg.end());
    	if(k & 1) reverse(neg.begin(), neg.end());
        REP(i, k) ans = mult(ans, neg[i]);
    	cout << ans << endl;
    }

    return 0;
}

// Easy things to check:
// - LONG LONGS (WA)
// - const int N is correct (WA, RTE) CHECK IF IT SHOULD BE 2*N!!!!
// - .size()-k underflow (WA, RTE, TLE)
// - small n edge cases (WA)

// Rare mistakes made in the past:
// - division by 0 (WA)
// - negative arithmetic, ceiling division, modulo (WA)
// - setprecision (WA)
// - INF not big enough using ll (WA)
// - setting max to 0 instead of -INF/min to 0 instead of INF (WA)
// - outputting debug (WA)
// - allocating too much memory (locRTE, MLE)
// - stack size (locRTE)
// - round announcements (WA)
// - multiset::erase (WA)
// - forgetting to rename recursive call when copy/pasting recursive function (WA)
// - not clearing DS between test cases EVEN FOR INPUT (WA, RTE, TLE, MLE)


Measured memory_bytes: 6380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;
template<typename T> T factorial(T n){
    if(n==1) return 1;
    else return n*factorial(n-1)%MOD;
}
template<typename T> T Pow(T x, T n, T m){
    if(n == 0) return 1;
    if(n % 2 == 0) return Pow(x * x % m, n / 2, m);
    else return x * Pow(x, n - 1, m) % m;
}
template<typename T> T combination(T n, T k, T m){
    return factorial<T>(n) * Pow<T>(factorial(k), m-2, m) % m * Pow<T>(factorial(n-k), m-2, m) % m;
}
struct edge{
    int to; // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using graph = vector<vector<edge>>;
using Graph = vector<vector<int>>;

int main(){
    int n; cin >> n;
    bool seven = false;
    if((n / 100 == 7) || ((n % 100) / 10 == 7) || (n % 10 == 7)) seven = true;
    if(seven) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
   
#include <x86intrin.h>
#include <bits/stdc++.h>   
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, a[N];
multiset <int> s;

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n;
   for (int i = 1; i <= n; i ++) cin >> a[i];
   s.in (a[1]);
   for (int i = 2; i <= n; i ++) {
      if (*s.begin () >= a[i]) {
         s.in (a[i]);
      }
      else {
         int mn = *(-- s.lb (a[i]));
         s.erase (s.find (mn));
         s.in (a[i]);

      }
   }
   cout << sz (s);
}

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
                          

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

#define int ll
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, d;
  cin >> n >> d;
  int ans = 0;
  while (n--) {
    int x, y;
    cin >> x >> y;
    if (x * x + y * y <= d * d) {
      ans++;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3648
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N; int K; cin >> K;
    int ans = 0;
    while (N > 0) {
        ans++; N /= K;
    }
    cout << ans << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
string a, b;
 
int main() {
	cin>>a>>b;
	int x[30], y[30];
	memset(x, -1, sizeof(x));
	memset(y, -1, sizeof(y));
	for(int i = 0;i<a.length();i++){
		int u = a[i] - 'a';
		int v = b[i] - 'a';
		if(x[u] != -1 || y[v] != -1)
			if(x[u] != v || y[v] != u){
				cout<<"No";
				return 0;
			}
		x[u] = v, y[v] = u;
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 776
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
const long long MOD = 1e9 + 7;

template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N, 0), B(N, 0);
    rep(i, 1, N) { cin >> A[i]; }

    for(int i = N - 1; i > 0; i--) {
        B[A[i] - 1]++;
    }
    rep(i, N) { cout << B[i] << endl; }
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000000;
int main(){
  int N;
  long long A, B;
  cin >> N >> A >> B;
  vector<long long> h(N);
  for (int i = 0; i < N; i++){
    cin >> h[i];
  }
  int tv = INF;
  int fv = 0;
  while (tv - fv > 1){
    int mv = (tv + fv) / 2;
    vector<long long> h2 = h;
    for (int i = 0; i < N; i++){
      h2[i] -= B * mv;
    }
    long long cnt = 0;
    for (int i = 0; i < N; i++){
      if (h2[i] > 0){
        cnt += (h2[i] + (A - B) - 1) / (A - B);
      }
    }
    if (cnt <= mv){
      tv = mv;
    } else {
      fv = mv;
    }
  }
  cout << tv << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,m;
    cin >> n >> m;
    string s;
    cin >> s;
    reverse(all(s));
    vi can;
    rep(i,n+1) if(s[i] == '0') can.pb(i);
    vi ans;
    int now = 0;
    while(now < n) {
        int nx = *(upper_bound(all(can),now+m)-1);
        if(nx == now) {
            cout << -1 << endl;
            return 0;
        }
        ans.pb(nx-now);
        now = nx;
    }
    reverse(all(ans));
    rep(i,ans.size()) cout << ans[i] << (i == ans.size()-1 ? "\n" : " ");
}

Measured memory_bytes: 1480
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		String s=sc.next();
		char p=s.charAt(0);
		int count=0;
		int countk=1;
		for(int i=1; i<n; i++){
			if(p==s.charAt(i)){
				count++;
			}else{
				countk++;
				p=s.charAt(i);
			}
		}
		if(countk/2<=k){
			System.out.println(n-1);
		}else{
			System.out.println(count+k*2);
		}
		
	}
}


Measured memory_bytes: 23912