akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

template<class T>
struct SegmentTree {
	using F = function<T(T, T)>;
	const T init;
	const F f;
	int sz;
	vector<T> seg;
	SegmentTree(int n, const T init, const F f) :
		init(init),
		f(f)
		{
			sz = 1;
			while(sz < n) sz <<= 1;
			seg.resize(sz << 1, init);
		}
	void update(int id) {
		while(id >>= 1) {
			seg[id] = f(seg[2 * id], seg[2 * id + 1]);
		}
	}
	void replace(int id, T x){
		id += sz;
		seg[id] = x;
		update(id);
	}
	// [l,r)
	T get(int l, int r){
		T L = init, R = init;
		for(l += sz, r += sz; l < r; l >>= 1, r>>= 1) {
			if(l & 1) L = f(L, seg[l++]);
			if(r & 1) R = f(seg[--r], R);
		}
		return f(L, R);
	}
	void debug(){
		int i = 1;
		for(int r = 2; r <= 2 * sz; r <<= 1) {
			while(i < r) {
				cout << seg[i++] << " ";
			}
			cout << "\n";
		}
	}
};


int main() {
	int n, k; cin >> n >> k;
	int p[n]; rep(i,n) cin >> p[i];
	SegmentTree<int> seg(n, 0, [](int a, int b){return a + b;});
	int sum = 0;
	int anspre = 0;
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		if(i < k) {
			int tmp = seg.get(p[i], n);
			sum += tmp;
			seg.replace(p[i], 1);
			if(i == k - 1) {
				if(sum == 0) anspre = 1;
				else ++ans;
			}
			continue;
		} else {
			bool flg = false;
			int tmp = seg.get(0, p[i - k]);
			sum -= tmp;
			if(tmp > 0) flg = true;
			seg.replace(p[i - k], 0);
			int tmp1 = seg.get(p[i], n);
			sum += tmp1;
			if(tmp1 > 0) flg = true;
			seg.replace(p[i], 1);
			if(sum == 0) anspre = 1;
			else if(flg) ++ans;
		}
		// cerr << sum << endl;
	}
	cout << ans + anspre << endl;
	return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;


int main() {
	int a, b; cin >> a >> b;
	int c = b - a;
	cout << (c * c + c) / 2 - b << "\n";

	return 0;
}

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

int main() {
    int S;
    cin >> S;
    if(S % 10 == (S / 10) % 10 || (S / 100) % 10 == S / 1000 || (S / 10) % 10 == (S / 100) % 10) {
        cout << "Bad";
    } else {
        cout << "Good";
    }
    return 0;
}

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

int main() {
 int N, K;
  cin >> N >> K;
  
  vector<int> vec(N), num(N + 1);
  for(int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
   for(int i = 0; i <= N; i++) {
     num.at(i) = 0;
   }
  
  for(int i = 0; i < N; i++) {
  num.at(vec.at(i))++;
  }
  
  int count = 0;
  for(int i = 1; i <= N; i++) {
    if(num.at(i) != 0) {
      count++;
    }
  }
  
  sort(num.begin(), num.end());
  reverse(num.begin(), num.end());
  
  int res = 0;
  if(K >= count) {
    cout << 0 << endl;
  }
    else {
  for(int i = 0; i < N - K; i++) {
    res += num.at(K + i);
  }
    cout << res << endl;
    }
  
  
    
}
    

Measured memory_bytes: 1792
# include <bits/stdc++.h>
using namespace std;
int main ()
{
	int n;
	cin>>n;
	if (n==1)
	  printf ("Hello World\n");
	if (n==2)
	  {
	  	int A,B;
	  	cin>>A>>B;
	  	printf ("%d\n",A+B);
	  }
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(final String[] args){
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        int K = sc.nextInt();
        sc.close();

        int L = N.length();
        int[][] dp0 = new int[L + 1][K + 1];
        int[][] dp1 = new int[L + 1][K + 1];
        dp1[0][0] = 1;

        for (int i = 0; i < L; i++) {
            int d = N.charAt(i) - '0';
            for (int j = 0; j < K + 1; j++) {
                if (d == 0) {
                    dp1[i + 1][j] += dp1[i][j];
                } else {
                    if (j < K) {
                        dp1[i + 1][j + 1] += dp1[i][j];
                        dp0[i + 1][j + 1] += dp1[i][j] * (d - 1);
                    }
                    dp0[i + 1][j] += dp1[i][j];
                }

                if (j < K) {
                    dp0[i + 1][j + 1] += dp0[i][j] * 9;
                }
                dp0[i + 1][j] += dp0[i][j];
            }
        }

        long ans = dp0[L][K] + dp1[L][K];
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,a,b,ans = 0,i,ng = -10000000000;cin >> n;
  vector<pair<long long,long long>> l(n);
  for(i=0;i<n;i++){
    cin >> a >> b;
    l[i].first = a+b;l[i].second = a-b;
  }
  sort(l.begin(),l.end());
  for(i=0;i<n;i++){
    if(l[i].second >= ng){
      ans++;ng = l[i].first;
    }
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 1792
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define ll long long
    #define int long long
    #define pb push_back
    #define For(i,n) for(ll  i=0;i<n;i++)
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;clock_t clk = clock();
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define mod 1000000007
    #define ld long double
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define fi first
    #define se second
    #define pii pair<ll,ll>
    #define what_is(x) cerr << #x << " is " << x << endl;
    #define time cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';
    const double pi=3.14159265358979323846264;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;

/**********************************************************************************************************************/



signed main()/*question galat mat padhna yr*/
{
    fast;   
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans=0;
    swap(b,c);
    ans=min(a,k);
    k=max(k-a,(ll)0);
    k=max((ll)0,k-c);
    ans-=(k);
    cout<<ans<<endl;
}   

Measured memory_bytes: 3572
#include <stdio.h>
#include <string.h>
int main(void){
	char s[200001],t[200001],c[26]={0},d[26]={0};
	scanf("%s %s",s,t);
	long long len = strlen(s),i,j;
	for(i=0;i<len;i++){
		c[(int)(s[i])-97]++;
		d[(int)(t[i])-97]++;
	}
	for(i=0;i<26;i++){
		int num = c[i];
		for(j=0;j<26;j++){
			if(d[j]==num){
				d[j]=0;
				break;
			}
		}
		if(j==26){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  vector<long long> S(N + 1, 0);
  for (int i = 0; i < N; i++){
    S[i + 1] = S[i] + a[i];
  }
  vector<long long> sum;
  for (int i = 0; i <= N; i++){
    for (int j = i + 1; j <= N; j++){
      sum.push_back(S[j] - S[i]);
    }
  }
  long long ans = 0;
  for (int i = 50; i >= 0; i--){
    int cnt = 0;
    int M = sum.size();
    for (int j = 0; j < M; j++){
      if (sum[j] >> i & 1){
        cnt++;
      }
    }
    if (cnt >= K){
      ans += (long long) 1 << i;
      vector<long long> sum2;
      for (int j = 0; j < M; j++){
        if (sum[j] >> i & 1){
          sum2.push_back(sum[j]);
        }
      }
      swap(sum, sum2);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 8976
#include <bits/stdc++.h>
#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 SORT(v) sort(v.begin(), v.end())
#define REVERSE(v)  reverse(v.begin(), v.end())
using namespace std;

int main() {
  string S;
  cin>>S;
  if(S.size() == 2) cout<<S<<endl;
  else cout<<S[2]<<S[1]<<S[0]<<endl;
  return 0;
}

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

ll N, M, K;
const int MAX = 200010;
ll A[MAX], B[MAX];

int main() {
    cin >> N >> M >> K;
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < M; i++) cin >> B[i];
    
    vector<ll> sum_B(M);
    sum_B[0] = B[0];
    for (int i = 1; i < M; i++) {
        sum_B[i] = sum_B[i-1] + B[i];
    }

    int ans = 0;
    ll sum_A = 0;
    int tmp = upper_bound(sum_B.begin(), sum_B.end(), K-sum_A) - sum_B.begin();
    ans = max(ans, tmp);
    for (int i = 0; i < N; i++) {
        sum_A += A[i];
        if (sum_A <= K) {
            int tmp2 = upper_bound(sum_B.begin(), sum_B.end(), K-sum_A) - sum_B.begin();
            ans = max(ans, tmp2 +i+1);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7972
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <cstring>
#include <iomanip>
using namespace std;

#define double long double
#define int long long
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << '\n';
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
template <typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; };
template <typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; };

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}

signed main() {
	int n, k;
	cin >> n >> k;
	cout << min(n % k, (k - n % k) % k) << '\n';
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define repp(i,j,k) for(int i=j;i>=k;i--)
#define llrep(i,j,k) for(long long int i=j;i<(long long int)k;i++)
#define Sort(x) sort(x.begin(),x.end()); 
#define vi vector<int>
#define vvi vector<vector<int>> 
#define ll long long
int mod=1e9+7;
const int INF = 100000000;

using namespace std;

void p(int x) {
	cout << x << endl;
}

void pp(string s) {
	cout << s << endl;
}




int main(void) {
	int a, b;
	cin >> a >> b;
	if (a <= 0 && b >= 0) cout << "Zero" << endl;
	if (a > 0 && b > 0) cout << "Positive" << endl;

	if (a < 0 && b < 0) {
		if ((b - a) % 2 == 0) cout << "Negative" << endl;
		else cout << "Positive" << endl;
	}

	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    string s; cin >> s;
    if (n % 2 == 1){
        cout << "No" << endl;
        return 0;
    }
    ll half = n/2;
    REP(i, half){
        if (s[i] != s[i+half]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

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

    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    if (k < a) {
        out(k);
    } else if (k <= a + b) {
        out(a);
    } else {
        out(a - (k - (a + b)));
    }

    return 0;
}


Measured memory_bytes: 3648
#include<cstdio>
#include<complex>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
#include<iostream>

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define fs first
#define sc second

using namespace std;

typedef pair<double,int> Pd;
typedef complex<double> P;
typedef pair<P,P> L;

const double PI = acos(-1);

double dot(P x,P y){return real(conj(x)*y);}
double cross(P x,P y){return imag(conj(x)*y);}

P rotate(P v,double s){
  return P(real(v)*cos(s) - imag(v)*sin(s), real(v)*sin(s) + imag(v)*cos(s) );
}

int ccw(P a,P b,P c){
  b -= a; c -= a;
  if(cross(b,c)>EPS)return 1;
  if(cross(b,c)<-EPS)return -1;
  if(dot(b,c)<-EPS)return 2;
  if(abs(b)<abs(c))return -2;
  return 0;
}

bool is_cp(L a,L b){
  if(ccw(a.fs,a.sc,b.fs)*ccw(a.fs,a.sc,b.sc)<=0)
    if(ccw(b.fs,b.sc,a.fs)*ccw(b.fs,b.sc,a.sc)<=0)return true;
  return false;
}

double seg_p_dis(L a,P x){
  if(dot(a.sc-a.fs,x-a.fs)<EPS)return abs(x-a.fs);
  if(dot(a.fs-a.sc,x-a.sc)<EPS)return abs(x-a.sc);
  return abs(cross(a.sc-a.fs,x-a.fs))/abs(a.sc-a.fs);
}

double seg_seg_dis(L a,L b){
  double res = 1e10;
  res = min(res,seg_p_dis(a,b.fs));
  res = min(res,seg_p_dis(a,b.sc));
  res = min(res,seg_p_dis(b,a.fs));
  res = min(res,seg_p_dis(b,a.sc));
  return res;
}

int n,m,l;
double xi[110],yi[110],ai[110],ri[110];
vector<Pd> g[110];
L s[110][5];
double d[110];

void make_star(int x){
  P p[5];
  P tmp = P(0.0,ri[x]);
  p[0] = rotate(tmp,ai[x]*PI/180);
  for(int i=1;i<5;i++)p[i] = rotate(p[i-1],72*PI/180);
  for(int i=0;i<5;i++)p[i] += P(xi[x],yi[x]);
  for(int i=0;i<5;i++)s[x][i] = L(p[i],p[(i+2)%5]);
}
 
void make_graph(void){
  for(int i=0;i<n;i++)make_star(i);
  
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      bool f = false;
      for(int k1=0;k1<5;k1++){
	for(int k2=0;k2<5;k2++){
	  f |= is_cp(s[i][k1],s[j][k2]);
	  if(f)break;
	}
      }
      if(f){
	g[i].push_back(Pd(0.0,j));
	g[j].push_back(Pd(0.0,i));
      }else{
	double dis = 1e10;
	for(int k1=0;k1<5;k1++){
	  for(int k2=0;k2<5;k2++){
	    dis = min(dis,seg_seg_dis(s[i][k1],s[j][k2]));
	  }
	}	
	g[i].push_back(Pd(dis,j));
	g[j].push_back(Pd(dis,i));
      }
    }
  }
}

int main(){
  while(scanf("%d%d%d",&n,&m,&l), (n||m||l)){
    for(int i=0;i<n;i++)scanf("%lf%lf%lf%lf",&xi[i],&yi[i],&ai[i],&ri[i]);

    for(int i=0;i<n;i++)g[i].clear();
    make_graph();

    for(int i=0;i<n;i++)d[i] = 1e10; d[m-1] = 0.0;
    priority_queue<Pd,vector<Pd>,greater<Pd> >q;
    q.push(Pd(0.0,m-1));

    while(q.size()){
      Pd p = q.top(); q.pop();
      double cost = p.fs;
      int pos = p.sc;

      if(pos == l-1)break;

      for(int i=0;i<g[pos].size();i++){
	double dis = cost + g[pos][i].fs;
	int next = g[pos][i].sc;
	if(dis+EPS < d[next]){
	  d[next] = dis;
	  q.push(Pd(dis,next));
	}
      }
    }

    printf("%.10lf\n",d[l-1]);
  }
}

Measured memory_bytes: 1200
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int n,i,j,low,mid,heigh,num=0;
    cin >> n;
    int a[n],compare[n];
    for(i=0;i<n;i++)
        cin >> a[i];
    for(i=0;i<n;i++)
    {
        if(i == 0)
            compare[i] = a[i];
        else    {
                    if(compare[num] < a[i])
                    {
                        compare[num+1] = a[i];
                        num++;
                    }
                    else    if(compare[num] > a[i])
                            {
                                low = 0;
                                heigh = num;
                                while(low <= heigh)
                                {
                                    mid = (low + heigh)/2;
                                    if(compare[mid]==a[i])
                                    {
                                        low = mid;
                                        break;
                                    }
                                    if(compare[mid]>a[i])
                                        heigh = mid-1;
                                    else    low = mid +1;
                                }
                                compare[low] = a[i];
                            }
                            /*{
                                for(j=0;j<=num;j++)
                                    if(compare[j]>=a[i])
                                    {
                                        compare[j] = a[i];
                                        break;
                                    }
                            }*/
                }
    }
    //for(i=0;i<=num;i++)
    //    cout << compare[i];
    //cout << ' ' <<endl;
    cout << num+1 << endl;
    return 0;
}



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


int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  ll ans=0;
  ll r,g,b;
  r=0;
  g=0;
  b=0;
  for(int i=0;i<n;++i){
    if(s[i]=='R') r++;
    if(s[i]=='G') g++;
    if(s[i]=='B') b++;
  }
  ans=r*g*b;
  //cout << dp[n-1][0] << dp[n-1][1] << dp[n-1][2] << endl;
  for(int i=0;i<n;++i){
    for(int j=i+1;j<n;++j){
      if(s[i]==s[j]) continue;
      int k=2*j-i;
      if(k>=n || s[i]==s[k] || s[k]==s[j]) continue;
      ans--;
    }
  }

  cout << ans << endl;
  return 0;
}


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

int main() {
    string s;
    cin >> s;
    int ans = 0;
    if(s[0] == '1') ans ++;
    if(s[1] == '1') ans ++; 
    if(s[2] == '1') ans ++;
    cout << ans << endl;

    return 0;
}

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

typedef long long ll;

#define sz(v) (int)v.size()

void PLAY() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(10);
}

const int MAX = 1e6 + 5;
ll  a[MAX];
ll gcd(ll a, ll b) {
	if (b == 0)
		return a;
	return gcd(b, a % b);
}

set<int> primeFactors(int n) {
    set<int> primes;
    while (n % 2 == 0) {
        primes.insert(2);
        n /= 2;
    }

    for (ll i = 3; i * i <= n; i += 2) {
        while (n % i == 0) {
			primes.insert(i);
            n /= i;
        }
    }

	if (n > 2)
		primes.insert(n);
	return primes;
}

int main() {
	PLAY();

	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	
	int cnt = 0;
	set<int> st;

	for (int i = 1; i <= n; i++) {
		set<int> primes = primeFactors(a[i]);
		st.insert(primes.begin(), primes.end());
		cnt += sz(primes);
	}
	if (cnt == sz(st)) {
		cout << "pairwise coprime" << endl;
	}
	else {
		ll g = a[1];
		for (int i = 2; i <= n; i++)
			g = gcd(g, a[i]);
		if (g == 1)
			cout << "setwise coprime" << endl;
		else
			cout << "not coprime" << endl;
	}

	return 0;
}


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

int main() {

  int H, W;
  cin >> H >> W;

  vector<vector<char>> table(H,vector<char>(W));
  vector<bool> x(W,false);
  bool isblack = false;

  for (int i = 0; i < H; i++){
    isblack = false;
    for(int j = 0; j < W; j++){
      cin >> table.at(i).at(j);
      //yokocheck
      if (table.at(i).at(j) == '#'){
        isblack = true;
        x.at(j) = true;
      }
    }
    if (isblack == false){
      H--;
      i--;
    }
  }

  for (int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if (x.at(j) == true){
        cout << table.at(i).at(j);
      }
      if (j == W-1) {
        cout << endl;
      }
    }
  }
//
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
using namespace std;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }

int main() {
    int N; cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];

    long long res = A[0];
    for (int i = 0; i < N; ++i) {
        res = GCD(res, A[i]);
    }
    cout << res << endl;
}

Measured memory_bytes: 4056
from collections import defaultdict as dd
while True:
    n=input()
    if n==0:break
    dic,L=dd(dict),[]
    for i in range(n):
        L+=raw_input().split()
    k=raw_input()
    for i in L:
        if i not in dic[i[0]]:
            dic[i[0]][i]=-1
        else:
            dic[i[0]][i]-=1
    if k not in dic:
        print "NA"
    else:
        print " ".join(i[1] for i in sorted([(j,i) for i,j in dic[k].items()])[\
:5])

Measured memory_bytes: 4708
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	k, _ := strconv.Atoi(sc.Text())

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	a := make([]int, n)

	for i := 0; i < n; i++ {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}

	max := 0
	for i := 1; i < n; i++ {
		if a[i]-a[i-1] > max {
			max = a[i] - a[i-1]
		}
	}

	l1 := a[n-1] - a[0]
	l2 := k - max
	if l1 > l2 {
		fmt.Println(l2)
	} else {
		fmt.Println(l1)
	}
}


Measured memory_bytes: 3840
n, p = map(int, input().split())
s = list(map(int, list(input())))[::-1]

if 10%p==0:
    result = 0
    for i in range(n):
        if s[i]%p==0:
            result += n-i
else:
    r = [0 for _ in range(p)]
    r[0] = 1
    t = 0
    ten = 1
    for i in s:
        t = (t+i*ten)%p
        ten = (ten*10)%p
        r[t] += 1
    result = 0
    for i in r:
        result += i*(i-1)//2
print(result)

Measured memory_bytes: 6564
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define loop(i,n) rep(i,0,n)
using namespace std;
using ll = long long;
//dp[i][j]={鍵1,...,iを用いて宝箱j(bitsetで管理)を開けるための費用の最小値}
constexpr int n_max = 12, m_max = 1000;
int dp[m_max+1][1<<n_max];
constexpr int infty = 1e9;
int main(){
    int n,m;
    cin >> n >> m;
    loop(i,1+m){
        loop(j,1<<n){
            dp[i][j]=infty;
        }
    }
    dp[0][0]=0;
    rep(i,1,1+m){
        int a,b,key=0;
        cin >> a >> b;
        loop(j,b){
            int c;
            cin >> c;
            key|=(1<<(c-1));
        }
        loop(j,1<<n)dp[i][j]=dp[i-1][j];
        loop(j,1<<n){
            dp[i][j|key]=min(dp[i][j|key],min(dp[i-1][j|key],dp[i-1][j]+a));
        }
    }
    if(dp[m][(1<<n)-1]==infty)cout << -1 << endl;
    else cout << dp[m][(1<<n)-1] << endl;
    return 0;
}

Measured memory_bytes: 16256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static final int MOD = 1_000_000_007;

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

        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[M];
        for (int i = 0; i < M; i++) {
            a[i] = sc.nextInt();
        }

        System.out.println(solveDP(N, M, a));
    }

    public static int solve(int N, int M, int[] a) {
        if (N == 1) return 1;

        int[] nlist = new int[N + 1];
        int aidx = 0;

        nlist[0] = 1;
        if (M != 0 && a[0] == 1) {
            nlist[1] = 0;
            aidx = 1;
        } else {
            nlist[1] = 1;
        }

        for (int i = 2; i <= N; i++) {
            if (aidx < M && a[aidx] == i) {
                nlist[i] = 0;
                aidx++;
            } else {
                nlist[i] = (nlist[i - 1] + nlist[i - 2]) % MOD;
            }
        }

        return nlist[N];
    }

    /**
     * 解説に従い，よりDPっぽく解く
     * @param N
     * @param M
     * @param a
     * @return
     */
    public static int solveDP(int N, int M, int[] a) {
        boolean[] valid = new boolean[N+1];
        int[] dp = new int[N+1];

        Arrays.fill(valid, true);
        for (int i=0; i<M; i++) {
            valid[a[i]] = false;
        }
        dp[0] = 1;
        for (int cur=0; cur<N; cur++) {
            for (int next=cur+1; next<=Math.min(N, cur+2); next++) {
                if (valid[next]) {
                    dp[next] += dp[cur];
                    dp[next] %= MOD;
                }
            }
        }

        return dp[N];
    }
}

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

int main (){
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i=0; i<N; i++){
        cin >> vec.at(i);
    }
    sort(vec.begin(),vec.end());
    vec.erase(unique(vec.begin(),vec.end()), vec.end());
    cout << vec.size() << endl;

}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  string x,y;
  cin >> x >> y;
  if(x.size()!=y.size()){ cout << "Alice" << endl; return 0; }
  int sz=x.size();
  for(int i=0; i<sz-1; i++){
    if(x[i]==y[i]){continue;}
    cout << "Alice" << endl; return 0;
  }
  if(abs((int)(x[sz-1]-y[sz-1]))<=1){ cout << "Brown" << endl; return 0; }
  cout << "Alice" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<iomanip>
#include<stack>

using namespace std;

#define debug(x) cout<< #x <<" : "<< x << endl;
#define repi(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) repi(i, 0, n)
#define int long long

const int INF = (1<<30);
const int MOD = (int)1e9 + 7;

signed main(){
    int n;
    cin>>n;
    int a[200000];
    int mn=INF;
    int ans=0;
    stack<int> s;
    rep(i,n){
        cin>>a[i];
        if(!s.empty() ){
            while(s.top() > a[i]){
                s.pop();
                ans++;
                if(s.empty()) break;
            }
        }
        if(s.empty() ) s.push(a[i]);
        else if(s.top() != a[i]) s.push(a[i]);
    }
    ans+=s.size();
    cout<<ans<<endl;
  
    return 0;
}



Measured memory_bytes: 5984
import java.util.Scanner;

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

    while (in.hasNext()) {
      int N = in.nextInt();
      int M = in.nextInt();
      String S = in.next();
      String T = in.next();
      int gcdNM = gcd(N, M);
      long lcmNM = ((long)N / gcd(N, M)) * M;
      int stepS = M / gcdNM;
      int stepT = N / gcdNM;
      int curS = 0;
      int curT = 0;
      boolean isExisted = true;

      while (curS < S.length() && curT < T.length()) {
        int idxXS = curS * stepS + 1;
        int idxXT = curT * stepT + 1;

        if (idxXS == idxXT) {
          if (S.charAt(curS) != T.charAt(curT)) {
            isExisted = false;
            break;
          } else {
            ++curS;
            ++curT;
          }
        } else if (idxXS < idxXT) {
          ++curS;
        } else if (idxXT < idxXS) {
          ++curT;
        }
      }
      
      if (isExisted) {
        System.out.println(lcmNM);
      } else {
        System.out.println(-1);
      }
    }
  }

  public static int gcd (int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
  }
}


Measured memory_bytes: 26324
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD (int64_t)1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} // input vector

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

string S; cin >> S;

rep(_, 0, S.size()) cout << 'x';
cout << "\n";

return 0;
}
// 書いて考える．場合分け．情報整理．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



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

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

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

    vector<int> A(n, 0);
    for(int i = 0; i < k; i++){
        int d;
        cin >> d;
        for(int j = 0; j < d; j++){
            int a;
            cin >> a;
            A[a - 1]++;
        }
    }

    int ans = 0;
    for(int i = 0; i < n; i++){
        if(A[i] == 0) ans++;
    }

    cout << ans << endl;

    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String str[] = br.readLine().split(" ");
            char x = str[0].charAt(0);
            char y = str[1].charAt(0);
            if (x > y) {
                System.out.println(">");
            } else if (x < y) {
                System.out.println("<");
            } else {
                System.out.println("=");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 21204
#include <stdio.h>
int main()
{
	int a=0,b=0,c=0,d=0,e=0;
	int j[10];
	int tmp=0;
	int k=0;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&e);
	scanf("%d",&k);
	
	
	for(int i=0;i<10;i++)
	{
		j[i]=0;
	}
	
	tmp=a-b;
	if(tmp<0)
	{
		tmp=-tmp;
	}
	
	if(tmp<=k)
	{
		j[0]=1;
	}
	
	
	tmp=a-c;
	if(tmp<0)
	{
		tmp=-tmp;
	}
	
	if(tmp<=k)
	{
		j[1]=1;
	}
	
	tmp=a-d;
	if(tmp<0)
	{
		tmp=-tmp;
	}
	
	if(tmp<=k)
	{
		j[2]=1;
	}
	
	tmp=a-e;
	if(tmp<0)
	{
		tmp=-tmp;
	}
	
	if(tmp<=k)
	{
		j[3]=1;
	}
	
	tmp=b-c;
	if(tmp<0)
	{
		tmp=-tmp;
	}
	
	if(tmp<=k)
	{
		j[4]=1;
	}
	
	tmp=b-d;
	if(tmp<0)
	{
		tmp=-tmp;
	}
	
	if(tmp<=k)
	{
		j[5]=1;
	}
	
	tmp=b-e;
	if(tmp<0)
	{
		tmp=-tmp;
	}
	
	if(tmp<=k)
	{
		j[6]=1;
	}
	
	tmp=c-d;
	if(tmp<0)
	{
		tmp=-tmp;
	}
	
	if(tmp<=k)
	{
		j[7]=1;
	}
	
	tmp=c-e;
	if(tmp<0)
	{
		tmp=-tmp;
	}
	
	if(tmp<=k)
	{
		j[8]=1;
	}
	
	tmp=d-e;
	if(tmp<0)
	{
		tmp=-tmp;
	}
	
	if(tmp<=k)
	{
		j[9]=1;
	}
	
	if(j[0]==1&&j[1]==1&&j[2]==1&&j[3]==1&&j[4]==1&&j[5]==1&&j[6]==1&j[7]==1&&j[8]==1&&j[9]==1)
	{
		printf("Yay!");
	}
	
	else
	{
		printf(":(");
	}
	
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int i = 0;
    long long A = 0, result = 1;
    int B_int = 0, B_dec = 0;
    string B_txt;

    int N = 0;
    
    cin >> A;
    cin >> B_txt;

    B_int = 0; i = 0;
    while (B_txt[i] != '.')
    {
        B_int *= 10;
        B_int += B_txt[i] - '0';
        i++;
    }
    

    B_dec = (B_txt[i + 1] - '0') * 10 + (B_txt[i + 2] - '0');

    //cout << A << " " << B_int << " " << B_dec << "\n";

    result = A * B_int + ((A * B_dec) / 100);

    cout << result;

    
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
typedef long long ll;
#define MOD 1000000007
ll gcd(ll a,ll b){if (b == 0)return a;return gcd(b, a % b);} 
#define cases int t;cin>>t;while(t--) 
ll power(ll x,ll y,ll p){ll res=1;x=x%p;if(x==0)return 0;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res%MOD;}  


int main(){
	ll n,k;
	cin>>n>>k;
	ll ans = 0;
	for(ll c=k;c<=n+1;c++){
		ll mi = (c*(c-1))/2;
		ll ma = (n*(n+1))/2;
		ma -= ((n-c)*(n-c+1))/2;
		ans += (ma-mi+1);
		//cout<<ma-mi+1<<endl;
		ans %=MOD;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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 int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, ma, mb; 
  cin >> N >> ma >> mb;

  vector<int> A(N), B(N), C(N);
  REP(i, N) cin >> A[i] >> B[i] >> C[i];

  int MAX = 500;
  int dp[N+1][MAX][MAX];
  REP(i, N+1) REP(j, MAX) REP(k, MAX) dp[i][j][k] = INF;
  dp[0][0][0] = 0;

  REP(i, N) REP(j, MAX) REP(k, MAX){
    chmin(dp[i+1][j][k], dp[i][j][k]);
    if(j+A[i] < MAX && k+A[i] < MAX){
      chmin(dp[i+1][j+A[i]][k+B[i]], dp[i][j][k]+C[i]);
    }
  }

  int ans = INF;
  int i = 1;
  while(i*ma < MAX && i*mb < MAX){
    chmin(ans, dp[N][i*ma][i*mb]);
    i++;
  }

  if(ans == INF) ans = -1;
  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 80384
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<string>

using namespace std;
const int INF = 1<<30;
typedef long long int ll;

int main(){
	int n;cin>>n;
	int sum=0;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	double min_diff=100000.0, index;
	for(int i=0;i<n;i++){
		double diff=double(sum)/double(n)-double(a[i]);
        if(diff<0)diff*=-1.0;
		if(min_diff>diff){min_diff=diff;index=i;}
	}
	cout << index << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int r=0,w=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='R')
		r++;
		else
		w++;
	}
	int cnt=0;
		for(int i=0;i<r;i++)
		{
			if(s[i]=='W')
			cnt++;
		}
		cout<<cnt<<endl;
		return 0;
	
}
	


Measured memory_bytes: 3736
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=(1<<9)+5,M=100005;
int n,m,Q;
int v[N*N],w[N*N];
long long f[N][M];
bool book[N*N];
long long ans;
void dfs(int u,long long ret,long long sum)
{
	if(ret<0) return;
	if(u<=(1<<9))
	{
		ans=max(ans,sum+f[u][ret]);
		return;
	}
	book[u]=true;
	dfs(u/2,ret-w[u],sum+v[u]);
	book[u]=false;
	dfs(u/2,ret,sum);
	return;
}
void solve()
{
	int u,L;
	scanf("%d%d",&u,&L);
	ans=0;
	dfs(u,L,0);
	printf("%lld\n",ans);
	return;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&v[i],&w[i]);
	m=100000;
	for(int i=1;i<=min(1<<9,n);i++)
	{
		int p=i/2;
		for(int j=0;j<=m;j++)
			if(j>=w[i]) f[i][j]=max(f[p][j],f[p][j-w[i]]+v[i]);
			else f[i][j]=f[p][j];
	}
	scanf("%d",&Q);
	while(Q--)
		solve();
	return 0;
}

Measured memory_bytes: 406080
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
#include <bitset>
using namespace std;
#define N (1000000000+7)
//#define N 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> Q;

const int inf = (int)1e9;

ll A(ll x){
    if(x>=0)return x;
    else return -x;
}
 
ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}
 
 
unsigned long long popcount(unsigned long long x) {
  x = ((x & 0xaaaaaaaaaaaaaaaaUL) >> 1) +
      (x & 0x5555555555555555UL);
  x = ((x & 0xccccccccccccccccUL) >> 2) +
      (x & 0x3333333333333333UL);
  x = ((x & 0xf0f0f0f0f0f0f0f0UL) >> 4) +
      (x & 0x0f0f0f0f0f0f0f0fUL);
  x = ((x & 0xff00ff00ff00ff00UL) >> 8) +
      (x & 0x00ff00ff00ff00ffUL);
  x = ((x & 0xffff0000ffff0000UL) >> 16) +
      (x & 0x0000ffff0000ffffUL);
  x = ((x & 0xffffffff00000000UL) >> 32) +
      (x & 0x00000000ffffffffUL);
  return x;
}


 

int main(void){
    int n,k;
    cin>>n>>k;
    vector<ll>s,t,a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]<0)t.push_back(a[i]);
        else s.push_back(a[i]);
    }
    int S = s.size();
    int T = t.size();
    bool ok = false;
    if(S>0){
        if(n==k)ok = (T%2==0);
        else ok = true;
    }
    else{
        ok = (k%2==0);
    }
    ll ans = 1;
    if(!ok){
        sort(a.begin(),a.end(),[](ll x,ll y){
            return abs(x)<abs(y);
        });
        for(int i=0;i<k;i++){
            ans=(ans*a[i])%N;
            ans = (ans+N)%N;
        }
        cout<<ans<<endl;
    }
    else{
        sort(s.begin(),s.end());
        sort(t.rbegin(),t.rend());
        if(k%2==1){
            ans = (ans*s.back())%N;
            s.pop_back();
        }
        vector<ll>p;
        while(s.size()>=2){
            ll x = s.back();s.pop_back();
            x = x*s.back();s.pop_back();
            p.push_back(x);
        }
        while(t.size()>=2){
            ll x = t.back();t.pop_back();
            x = (x*t.back());t.pop_back();
            p.push_back(x);
        }
        sort(p.rbegin(),p.rend());
        for(int i=0;i<k/2;i++){
            ans = (ans*(p[i]%N))%N;
            ans = (ans+N)%N;
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 8148
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <stdio.h>

#define MAX 1000000

using namespace std;

int main()
{
	double x1,y1,x2,y2,x3,y3,xp,yp,z1,z2,z3;
	int n;

	while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>xp>>yp)
	{

		z1=(x2-x1)*(yp-y1)-(y2-y1)*(xp-x1);
		z2=(x3-x2)*(yp-y2)-(y3-y2)*(xp-x2);
		z3=(x1-x3)*(yp-y3)-(y1-y3)*(xp-x3);

		
		if((z1>0&&z2>0&&z3>0)||(z1<0&&z2<0&&z3<0)) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}

	return 0;
}

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

#define int long long

int l, r, ans = 2019, mod = 2019;

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> l >> r;
	if (r - l >= mod)
		return cout << 0 << endl, 0;
	
	for (int i = l; i <= r; i++)
		for (int j = i + 1; j <= r; j++)
			ans = min(ans, (i * j) % mod);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    vector<int> a(n);
    vector<int64_t> b(n + 1);
    b[0] = 0;
    rep(i, n)
    {
        cin >> a[i];
        b[i + 1] = b[i] + a[i];
    }

    vector<vector<int64_t>> dp(n, vector<int64_t>(n));
    rep(r, n) rirep(l, r)
    {
        if (l == r) {
            dp[l][r] = 0;
        } else {
            dp[l][r] = numeric_limits<int64_t>::max();
            for (int i = l; i < r; i++) {
                dp[l][r] = min(dp[l][r], dp[l][i] + dp[i + 1][r]);
            }
            dp[l][r] += b[r + 1] - b[l];
        }
    }

    cout << dp[0][n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1536
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] a = new int[10][10];
        for (int i = 1; i <= n; i++) {
            String s = String.valueOf(i);
            int x = Integer.parseInt(s.substring(0,1));
            int y = Integer.parseInt(s.substring(s.length()-1,s.length()));
            a[x][y]++;
        }
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            String s = String.valueOf(i);
            int x = Integer.parseInt(s.substring(0,1));
            int y = Integer.parseInt(s.substring(s.length()-1,s.length()));
            ans += a[y][x];
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 43664
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <iomanip>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)
#define ld long double
#define ll long long

using namespace std;

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;


int main(){
  string S;
  cin >> S;
  int c[200010];
  int cnt=0;
  for(int i=0;i<S.size();i++){
    if(S[i]=='B'){
      c[i]=-1;
      cnt++;
    }else{
      c[i]=0;
    }
  }
  ll ans=0;
  for(int i=S.size()-1;cnt!=0;i--){
    ans+=i;
    cnt--;
  }
  for(int i=0;i<S.size();i++){
    if(c[i]==-1){
      ans-=i;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1412
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const int INF = 1e9;
inline int read(){
	int X = 0,w = 0 ;
	char ch = 0;
	while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
	while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
	return w ? -X : X;
}

int a[100005];
int b[100005];
int c[100005];
int dp[100005][3];
int main() 
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	dp[1][0]=a[1];
	dp[1][1]=b[1];
	dp[1][2]=c[1];
	for(int i=1;i<n;i++)
	{
		dp[i+1][0]=max(dp[i+1][0],max(dp[i][1]+a[i+1],dp[i][2]+a[i+1]));
		dp[i+1][1]=max(dp[i+1][1],max(dp[i][0],dp[i][2])+b[i+1]);
		dp[i+1][2]=max(dp[i+1][2],max(dp[i][0],dp[i][1])+c[i+1]);
	}
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
    return 0;
}

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

int g(int N, int x) {
  int tmp = 1;
  while (tmp * x <= N) tmp *= x;
  return N - tmp;
}

int f(int N, int c) {
  if (N == 0) return c;
  int ret = N + c, tmp;
  tmp = g(N, 6);
  if (0 <= tmp) {
    ret = min(ret, f(tmp, c+1));
  }
  tmp = g(N, 9);
  if (0 <= tmp) {
    ret = min(ret, f(tmp, c+1));
  }
  return ret;
}

int main() {
  int N;
  cin >> N;
  cout << f(N, 0) << endl;
}

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

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

int main(void){
	long long  h;
	scanf("%lld",&h);
	long long a = 2;
	while(a <= h){
		a = a*2;
	}
	printf("%lld\n",a-1);
    return 0; 
}


Measured memory_bytes: 128
s = input()
t = input()
ans = []
if len(t)>len(s):
  print("UNRESTORABLE")
else:
  for i in range(len(s)-len(t)+1):
    st = ""
    for j in range(len(t)):
      if s[j+i]=="?" or s[j+i]==t[j]:
        st+=t[j]
      else:
        break
    if len(st)==len(t):
      st = s[:i]+st+s[i+len(t):]
      ans.append(st.replace("?", "a"))
  if len(ans):
    print(sorted(ans)[0])
  else:
    print("UNRESTORABLE")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


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

    if(n%2==0){
        printf("%.10f\n",(double)1.0/2.0);
    }else{
        printf("%.10f\n",(double)((double)(n/2)+1.0)/(double)n);
    }
    return 0;

}


Measured memory_bytes: 256
// 22
/****************************************************
https://searleser97.gitlab.io/algorithms/template.cpp
****************************************************/

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fors(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fors(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define forrs(_, x, n, s) for (int _ = x; _ > n; _ -= s)
#define forrn(_, x, n) forrs(_, x, n, 1)
#define rrep(_, n) forrn(_, n - 1, -1)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define cerr(s) cerr << "\033[48;5;196m\033[38;5;15m" << s << "\033[0m"
// typedef __int128_t lli;
typedef long long int li;
typedef long double ld;
// 12
const int inf = 1e9 + 10;
void _main(int tc) {
  int n, k;
  cin >> n >> k;
  assert(n >= 2);
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  vector<int> mem(n, inf);
  mem[n - 1] = 0;
  mem[n - 2] = abs(h[n - 2] - h[n - 1]);

  function<int(int)> fcost = [&](int i) -> int {
    if (mem[i] != inf) return mem[i];
    forn(j, i + 1, (i + 1) + min(k, n - 1 - i)) {
      mem[i] = min(mem[i], abs(h[i] - h[j]) + fcost(j));
    }
    return mem[i];
  };
  cout << fcost(0) << endl;

  // rrep(i, n - 2) {
  //   forn(j, i + 1, (i + 1) + min(k, n - 1 - i)) {
  //     mem[i] = min(mem[i], abs(h[i] - h[j]) + mem[j]);
  //   }
  // }
  // cout << mem[0] << endl;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0);
  return 0;
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 10368