akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include <algorithm>
#include<string.h>
#include <utility>
using namespace std;
int main(){
	int m;
	string in1,in2;
	int a[1000],b[1000],ans[1000];
	int f;
	int alen,blen,mlen;
	cin>>m;
	while(m--){
		for(int i=0;i<90;i++){
			a[i]=b[i]=ans[i]=0;
		}
		in1="";
		in2="";
		cin>>in1;
		cin>>in2;
		alen=in1.size();
		blen=in2.size();
		mlen=max(alen,blen);
		if(mlen>80){
			cout<<"overflow"<<endl;
			continue;
		}
		for(int i=0;i<alen;i++){
			a[alen-1-i]=in1[i]-'0';
		}
		for(int i=0;i<blen;i++){
			b[blen-1-i]=in2[i]-'0';
		}
		f=0;
		for(int i=0;i<mlen+1;i++){
			ans[i]=(a[i]+b[i]+f)%10;
			f=(a[i]+b[i]+f)/10;
		}
		if(ans[mlen]!=0){
			if(mlen>79){
				cout<<"overflow"<<endl;
				continue;
			}
			cout<<ans[mlen];
		}
		
		for(int i=0;i<mlen;i++){
			cout<<ans[mlen-1-i];
		}cout<<endl;
		
		
	}
	return 0;
}

Measured memory_bytes: 1216
//BUGSBUNNY
//IIT ROORKEE
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define vl vector<long long>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vb vector<bool>
#define pb push_back
#define pob pop_back
#define mp make_pair
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
#define mod 1000000007
// #define mod 163577857 
// #define mod 998244353
#define rep(i,n) for (ll i = 0; i < n; i++)
#define repp(i,a,b) for(ll i = a ; i<b ; i++)
#define reppr(i,a,b) for(ll i = a-1 ; i>=b ; i--)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " <<
#define setprec(x) cout << fixed << setprecision(x);
#define REVERSE(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()
 
//GCD and LCM
    int gcd (int a, int b) { return b ? gcd (b, a % b) : a; }
    int lcm (int a, int b) { return a / gcd(a, b) * b; }
 
//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }
 
//Modular Inverse
    int inverse(int a) 
    { 
       return powmod(a,mod-2); 
    }


void solve();
signed main()
{
    //-------------------------------------------------------------------------------   
        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
        clock_t clk = clock();
    //-------------------------------------------------------------------------------   
    //-------------------------------------------------------------------------------
        int t = 1;
        // cin >> t;       
        rep(i,t)
        {
            // cout << "Case #" << i+1 << ": ";
            solve();
        }
    //-------------------------------------------------------------------------------
        clk = clock() - clk;
        cerr << fixed << setprecision(12) << "Time: " << ((double)clk)/CLOCKS_PER_SEC;
    //-------------------------------------------------------------------------------
}

void solve()
{
    int n;
    cin >> n;
    int a[n];
    rep(i,n)
        cin >> a[i];
    map<int,int> diff,sum;
    int ans = 0;
    rep(i,n)
    {
        int sm = a[i] - i-1 ;
        int df = - (a[i] + i+1) ;
        ans += diff[sm];
        ans += sum[df];
        sum[sm]++;
        diff[df]++;
    }
    cout << ans << endl;
}   

Measured memory_bytes: 50760
import sys

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M, Q] = [long(input_raw[0]), long(input_raw[1]), long(input_raw[2])]
    table = [[0 for i in range(N+1)] for i in range(N+1)]
    
    for i in range(M):
        input_raw = read_func().strip().split()
        [L, R] = [long(input_raw[0]), long(input_raw[1])]
        table[L][R] += 1;

    for i in range(1, N+1):
        for j in range(2, N+1):
            table[i][j] += table[i][j - 1]
    for j in range(1, N+1):
        for i in range(N - 1, 0, -1):
            table[i][j] += table[i + 1][j]

    for i in range(Q):
        input_raw = read_func().strip().split()
        [p, q] = [long(input_raw[0]), long(input_raw[1])]
        print table[p][q]

if __name__ == '__main__':
    main()


Measured memory_bytes: 13128
n=int(input())
a=list(map(int,input().split()))
a=sorted(a,reverse=True)
for i in range(n-1):
    if a[i]==a[i+1]:
        a[i+1]=0
    elif a[i]!=a[i+1]:
        a[i]=0
a=sorted(a,reverse=True)
print(a[0]*a[1])  

Measured memory_bytes: 14252
#include "bits/stdc++.h"
using namespace std;
long long dp[45] , NoCond[45];
 
void PreProcess( long long Num ){
    int pos = 0;
 
    while( Num ){
        if( Num % 2LL == 1LL ) ++dp[pos];
        ++pos;
        Num = Num / 2LL;
    }
}
 
int MostSignificant( long long Num ){
    int pos = -1;
 
    while( Num ){
        ++pos;
        Num = Num / 2LL;
    }
 
    return pos;
}
 
void Func1( int N , int Left ){
    int i;
    long long Value;
    if( dp[0] > N - dp[0] ) NoCond[0] = dp[0];
    else NoCond[0] = N - dp[0];
 
    for( i = 1 ; i <= Left ; ++i ){
        Value = ( 1LL << i );
        if( dp[i] > N - dp[i] ) NoCond[i] = Value * dp[i];
        else NoCond[i] = Value * ( N - dp[i] );
        NoCond[i] += NoCond[i - 1];
    }
}
 
long long FindAns( int N , long long k , int Left ){
    int i;
    long long Value , Pre = 0;
 
    for( i = 39 ; i > Left ; --i ){
        Value = ( 1LL << i );
        Pre = Pre + ( Value * dp[i] );
    }
 
    long long Cur , Temp , Ans = 0LL;
 
    for( i = Left ; i >= 1 ; --i ){
        Value = ( 1LL << i );
        
        if( ( ( k >> i ) & 1LL ) == 1LL ){
            Temp = Value * dp[i];
            Temp = Pre + Temp + NoCond[i - 1];
            Ans = max( Ans , Temp );
            Cur = Pre + Value * ( N - dp[i] );
        }
        else Cur = Pre + Value * dp[i];
 
        Pre = Cur;
    }   
 
    if( ( k & 1LL ) == 0LL ){
        Cur = Pre + dp[0];
        Ans = max( Ans , Cur );
    }
    else Ans = max( Ans , Pre + NoCond[0] );
 
    return Ans;
}
 
int main(){
    int N , i;
    long long k , Num , Sum = 0;
    scanf( "%d%lld" , &N , &k );
 
    for( i = 1 ; i <= N ; ++i ){
        scanf( "%lld" , &Num );
        PreProcess( Num );
        Sum += Num;
    }
 
    int Left = MostSignificant( k );
 
    if( Left == -1 ){
        printf( "%lld\n" , Sum );
        return 0;
    }   

    Func1( N , Left ); 
    printf( "%lld\n" , FindAns( N , k , Left ) );
    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
problems = [False]*n
pen = [0]*n
for i in range(m):
    a,b = input().split()
    a = int(a)-1
    if not problems[a]:
        if b[0] == 'A':
            problems[a] = True
        else:
            pen[a] += 1
ngo = 0
ans = 0
for i in range(n):
    if problems[i]:
        ngo += pen[i]
        ans += 1
print(ans,ngo)

Measured memory_bytes: 4596
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int comp2(const void *a, const void *b){
	return (*(long*)a>*(long*)b)-(*(long*)a<*(long*)b);
}

int s[900000][2], S=0;
int ans[10];
int main(void){
	int h, w, n, i, j;
	scanf("%d%d%d", &h, &w, &n);
	for(i=0; i<n; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		for(j=0; j<9; j++){
			int y=a-j/3, x=b-j%3;
			if(0<y && 0<x && y<=h-2 && x<=w-2){
				s[S][0]=y;
				s[S][1]=x;
				S++;
			}
		}
	}
	qsort(s, S, sizeof(int)*2, comp2);
	long ans0=(long)(h-2)*(w-2);
	int now=1;
	for(i=1; i<S; i++){
		if(s[i][0]==s[i-1][0] && s[i][1]==s[i-1][1]){
			now++;
		}else{
			ans[now]++; ans0--;
			now=1;
		}
	}
	if(S>0){
		ans[now]++; ans0--;
	}
	printf("%ld\n", ans0);
	for(i=1; i<=9; i++){
		printf("%d\n", ans[i]);
	}
}


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

using namespace std;

void swap(int* a, int* b)
{
    int t = *a;
    *a = *b;
    *b = t;
}

int partition (int array[], int l, int r) {
    int pivot = array[r];
    int i = (l - 1);

    for (int j = l; j <= r - 1; j++) {
        if (array[j] <= pivot) {
            i++;
            swap(&array[i], &array[j]);
        }
    }
    swap(&array[i + 1], &array[r]);
    return (i + 1);
}

void quickSort(int array[], int l, int r){
    if(l < r){
        int pivot = partition(array, l ,r);
        quickSort(array, l, pivot - 1);
        quickSort(array, pivot + 1, r);
    }
}

int main(){
    int n,sum = 0;
    cin >> n;
    int d[n];
    for(int i = 0 ; i < n ; i++){
        cin >> d[i];
    }
    quickSort(d,0,sizeof(d)/sizeof(d[0]) - 1);
    for(int i = 0 ; i < n - 2 ; i++){
        for(int j = i + 1 ; j < n - 1 ; j++){
            for(int k = j + 1 ; k < n ; k++){
                if((d[i] < d[j] + d[k]) && (d[j] < d[i] + d[k]) && (d[k] < d[i] + d[j])){
                    sum += 1;
                }
                else break;
            }
        }
    }
    cout << sum << endl;
}

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

using namespace std;

typedef	vector<int>	vi;

int chain(vi py,int u,int l){
	int n=py.size(),rem=(u+1)+(n-l);
	if(u<0 || n<=l)	return rem;

	int color=py[u],cnt=0;
	for(;u>=0;u--,cnt++){
		if(py[u]!=color)	break;
	}
	for(;l<n;l++,cnt++){
		if(py[l]!=color)	break;
	}
	if(cnt>=4)	return chain(py,u,l);
	return rem;
}

int main(){
	for(int n;scanf("%d",&n),n;){
		vi py(n);
		for(int i=0;i<n;i++)	scanf("%d",&py[i]);

		int pymin=1<<30;
		for(int i=0;i<n;i++)for(int c=1;c<=3;c++){
			if(py[i]!=c){
				int tmp=py[i];
				py[i]=c;
				if(i>0 && py[i-1]==c)			pymin=min(pymin,chain(py,i-1,i));
				else if(i<n-1 && py[i+1]==c)	pymin=min(pymin,chain(py,i,i+1));
				py[i]=tmp;
			}
		}

		printf("%d\n",pymin);
	}

	return 0;
}

Measured memory_bytes: 21000
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef pair<int,int> P;
typedef long long ll;
const int INF = 1001001001;
const ll INFL = 1e17;
const int MOD = 1e9+7;


int main(){
    int h,w;
    cin >> h >> w;
    vector<string> s;
    rep(i,h){
        string t;
        cin >> t;
        s.push_back(t);
    }

    vector<int> dx{1,-1,0,0};
    vector<int> dy{0,0,1,-1};
    int ans = 0;
    rep(i,h)rep(j,w){
        if(s[i][j]=='#') continue;
        vector<vector<int>> dist(h,vector<int>(w,INF));
        queue<P> que;
        que.push({j,i});
        dist[i][j] = 0;
        while(!que.empty()){
            int x = que.front().first;
            int y = que.front().second;
            que.pop();
            rep(dir,4){
                int ix = x+dx[dir], iy = y+dy[dir];
                if(ix<0 || ix>=w || iy<0 || iy>=h) continue;
                if(s[iy][ix]=='#') continue;
                if(dist[iy][ix]!=INF) continue;
                dist[iy][ix] = dist[y][x]+1;
                que.push({ix,iy});
            }
        }
        rep(ii,h)rep(jj,w){
            if(dist[ii][jj]!=INF){
                ans = max(ans,dist[ii][jj]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <cstdio>

char s[510][510];
int wcR[510];

int main(){
  int N; scanf("%d", &N);
  for(int i = 0; i < N; i++) scanf("%s", s[i]);

  int cc = 0;

  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++) if(s[i][j] == '.') wcR[i]++;

    bool b = true;
    for(int j = 0; j < N; j++) if(s[j][i] == '.') b = false;
    if(b) cc++;
  }

  int ans = -1;

  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(s[j][i] == '#'){
        int v = wcR[i] + (wcR[j] == 0 ? N - cc - wcR[i] : N - cc);
        if(ans == -1 || v < ans) ans = v;
      }
      else if(wcR[j] < N){
        int v = 1 + wcR[i] + N - cc;
        if(ans == -1 || v < ans) ans = v;
      }
    }

    // if(wc != N){
      // int v = 2 * wc + N - cc; if(ans == -1 || v < ans) ans = v;
    // }
  }

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
	int n,a[100] = {0};
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	int sum = accumulate(a,a+n,0);
	int ave = (int)(round((double)sum / n));

	//cout << "ave = " << ave << endl;

	int sol = 0;

	for(int i = 0; i < n; i++)
	{
		sol += (ave-a[i]) * (ave-a[i]);
	}

	cout << sol << endl;

	return 0;
}

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

#ifdef DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

#ifdef __WIN32
#define LLFORMAT "I64"
#define Rand() ((rand() << 15) + rand())
#else
#define LLFORMAT "ll"
#define Rand() (rand())
#endif

using namespace std;

const int maxn = 2e5 + 10, Z = 1e5 + 5;

int n, m, l[maxn], r[maxn];
long long ans;

int main() {
	scanf("%d", &n);
	while(n--) {
		int x, y;
		scanf("%d%d", &x, &y);
		++l[y + Z];
		++r[x + Z];
	}
	++l[Z];
	++r[Z];
	for (int i = 1; i < maxn; ++i) {
		l[i] += l[i - 1];
	}
	for (int i = maxn - 2; ~i; --i) {
		r[i] += r[i + 1];
	}
	for (int i = 0; i < maxn - 1; ++i) {
		ans += min(l[i], r[i + 1]);
	}
	printf("%"LLFORMAT"d\n", ans << 1);
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
	int y , a ,cnt;
	cin>>a>>y;
	for(int x=0;x<=a;x++){
		for(int i=0;i<=a;i++){
			int z=y-(x+i);
			if((z>=0)&&(z<=a)){
				cnt++;
				
			}
		}
	}
	cout<<cnt;
}

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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
#endif
	int n;
	cin>>n;
	int ans=n%10;
	if(ans==3){
		cout<<"bon\n";
	}
	else if(ans==0 || ans==1 || ans==6 || ans==8){
		cout<<"pon\n";
	}
	else{
		cout<<"hon\n";
	}

	return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int n,m,x;

long int min_v=1000000000;
const int M = 2;
void dfs(vector<int> &A,vector<vector<int> >& a,vector<int> &c) {
    if (A.size() == n) {
      int ans=0; 
      vector<int> tmp(m,0);
        
      for (int i = 0; i < n; ++i){
        if(A[i]){
          for (int j = 0; j < m; ++j){
            tmp[j]+=a[i][j];
          }
          ans+=c[i];
        }
      }
      //cout<<ans<<endl;
      for (int j = 0; j < m; ++j){
        if(tmp[j]<x){
          return;
        }
      }
      if(ans<min_v){
        min_v=ans;
      }
      return;
    }

    for (int v = 0; v < M; ++v) {
        A.push_back(v);
        dfs(A,a,c);
        A.pop_back(); 
    }
}

int main(){
  cin>>n>>m>>x;
  vector<int> c(n);
  vector<vector<int>> a(n,vector<int>(m));
  vector<long int> aa(m,0);
  for(int i=0;i<n;i++){
    cin>>c[i];
    for(int j=0;j<m;j++){
      cin>>a[i][j];
      aa[j]+=a[i][j];
    }
  }
  
  for(int j=0;j<m;j++){
    if(aa[j]<x){
      cout<<-1;
      return 0;
    }
  }
  
  
  
  vector<int> A;
  dfs(A,a,c);
  
  cout<<min_v;
  
  
  return 0;
}

Measured memory_bytes: 3620
#include<string>
#include<cstdio>
#include<cctype>
#include<iostream>
#include <algorithm>
#include<cmath>
#include<queue>
using namespace std;

int main(){
        int ans, book[15]={0}, s;
        while(1){
        cin >>s;
        if(s==0)break;
        for(int i=0;i<9;i++){
                scanf("%d",&book[i]);
                s-=book[i];
            }
        cout <<s<<endl;
        }
    return 0;
}

Measured memory_bytes: 1236
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>
#include <ratio>

#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n"
#define MOD 998244353

const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;

using namespace std;

void solve()
{
    int n;
    cin >> n;

    vector<int> a(n);

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

    vector<int> dp(n);

    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);

    for(int i = 2; i < n; i++)
    {
        dp[i] = min(abs(a[i] - a[i - 1]) + dp[i - 1], abs(a[i] - a[i - 2]) + dp[i - 2]);
    }

    cout << dp[n - 1] << "\n";
}

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

    int T = 1;
    //cin >> T;

    while (T--)
    {
        solve();
    }

    return 0;
}



Measured memory_bytes: 3972
<?php
list($n, $q) = explode(" ", trim(fgets(STDIN)));
$str = trim(fgets(STDIN));

$I = strlen($str) - 1;
$c = 0;
for($i = 0; $i < $I; $i++){
   if($str[$i] == "A" && $str[$i+1] == "C")$c++;
   $map[$i] = $c;
}
//echo implode(" ", $map)."\n";

for($i = 0; $i < $q; $i++){
   $c = 0;
   list($l, $r) = explode(" ", trim(fgets(STDIN)));
   echo @($map[$r-2]-$map[$l-2])."\n";
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    vector<long long> a(n), pref(n+1, 0), suff(n+1, 0), sum(n+1, 0);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) {
        sum[i+1] = sum[i] + a[i];
        pref[i+1] = pref[i] + a[i] * (a[i] >= 0);
    }
    for (int i = n; i > 0; i--) {
        suff[i-1] = suff[i] + a[i-1] * (a[i-1] >= 0);
    }
    long long ans = 0;
    for (int i = 0; i <= n-k; i++) {
        long long y = sum[i+k] - sum[i];
        if (y < 0) y = 0;
        ans = max(ans, pref[i]+suff[i+k]+y);
    }
    cout << ans << "\n";
    return 0;
}

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

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> pos, neg;
  rep(i, n) {
    cin >> a.at(i);
    if (a.at(i) < 0) neg.push_back(a.at(i));
    else pos.push_back(a.at(i));
  }

  // 正にできるかチェック
  bool ok = true;
  if (pos.size() == 0) {
    ok = (k % 2 == 0);
  } else {
    if (n == k) ok = (neg.size() % 2 == 0);
  }

  mint ans = 1;
  if (!ok) {
    // 正にできない場合は絶対値の小さい順に取る
    sort(a.begin(), a.end(), [](int x, int y) {
      return abs(x) < abs(y);
    });
    rep(i, k) ans *= a.at(i);
  } else {
    // 正にできる場合は絶対値の大きいペアから順に取る
    sort(pos.begin(), pos.end()); // 絶対値の大きいほうが後ろ
    sort(neg.rbegin(), neg.rend());

    if (k % 2 != 0) {
      ans = pos.back();
      pos.pop_back();
    }

    vector<ll> p;
    while (pos.size() > 1) {
      ll tmp = pos.back(); pos.pop_back();
      tmp *= pos.back(); pos.pop_back();
      p.push_back(tmp);
    }
    while (neg.size() > 1) {
      ll tmp = neg.back(); neg.pop_back();
      tmp *= neg.back(); neg.pop_back();
      p.push_back(tmp);
    }
    sort(p.rbegin(), p.rend());

    rep(i, k/2) ans *= p.at(i);
  }

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

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long double ld;
typedef long long ll;

int32_t main() {
    IOS;
    ll t;
    // cin>>t;
    t=1;
    while(t--) {
        int n,k;
        cin>>n>>k;
        int a[n];
        for(int i=0;i<n;i++) {
            cin>>a[i];
        }
        int dp[n];
        dp[0]=0;
        dp[1]=abs(a[1]-a[0]);
        for(int i=2;i<n;i++) {
            dp[i]=INT_MAX;
            for(int j=1;j<=k;j++) {
                if(i-j<0) {
                    break;
                }
                else {
                    dp[i]=min(dp[i], dp[i-j] + abs(a[i]-a[i-j]));
                }
            }
            // dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]));
        }

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

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

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

H, W = MAP()

if H == 1 or W == 1:
    print(1)
    exit()

ans = ceil(H*W, 2)
print(ans)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define RFOR(i, begin, end) for(int i=(end)-1, i##_begin_=(begin);i>=i##_begin_;i--)
#define rep(i, N) FOR(i, 0, N)
#define rrep(i, N) RFOR(i, 0, N)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long int;
using V = vector<ll>;
using P = pair<ll, ll>;
using VP = vector<P>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
constexpr int inf = 1e9;
constexpr int mod = 1e9+7;
ll gcd(ll a, ll b) { return b? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}


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

    V h(n);
    rep(i, n) cin >> h[i];

    V dp(n+1, inf);
    dp[0] = 0;
    rep(i, n-1) {
        dp[i+1] = min(dp[i+1], abs(h[i]-h[i+1]) + dp[i]);
        dp[i+2] = min(dp[i+2], abs(h[i]-h[i+2]) + dp[i]);
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const ll N = 2e5 + 5, mod = 1e9 + 7;
int n, u, v, ans, sz[N], p[N];
vector<int>adj[N];
int sub(int a, int b){
    return (((a - b) % mod) + mod) % mod;
}
int add(int a, int b){
    return (a + b) % mod;
}
int mul(int a, int b){
    return (1ll * a * b) % mod;
}
ll fp(ll b, ll p){
    if(!p) return 1;
    ll res = fp(b, p / 2);
    res = mul(res, res);
    if(p & 1) res = mul(res, b);
    return res;
}
void dfs(int node, int parent){
    sz[node] = 1;
    for(auto i : adj[node]){
        if(i != parent)
            dfs(i, node);
    }
    sz[parent] += sz[node];
    ans = add(ans, sub(p[n - 1], 1));
    for(auto i: adj[node]){
        if(i == parent) continue;
        ans = sub(ans, sub(p[sz[i]], 1));
    }
    ans = sub(ans, sub(p[n - sz[node]], 1));
}
int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for(int i = 1; i < n; i++){
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    p[0] = 1;
    for(int i = 1; i <= n; i++)
        p[i] = mul(2, p[i - 1]);
    dfs(1, 0);
    cout << mul(ans, fp(p[n], mod - 2));
    return 0;
}


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

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int n = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        Arrays.sort(array);
        // 一番長い区間
        int max = 0;
        int maxStart = 0;
        for (int i = 1; i < n ; i++) {
            int v = array[i] - array[i - 1];
            if (v > max) {
                max = v;
                maxStart = i - 1;
            }
        }
        // 最後
        int v = (k - array[n - 1]) + array[0];
        if (v > max) {
            System.out.println(array[n - 1] - array[0]);
            return;
        }

        System.out.println(k - (array[maxStart + 1] - array[maxStart]));
    }
}

Measured memory_bytes: 80120
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define FORN(i, x, y) for (int i = x; i <= y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define scan1(X) scanf("%d", &X)
#define scan2(X, Y) scanf("%d%d", &X, &Y)
#define scan3(X, Y, Z) scanf("%d%d%d", &X, &Y, &Z)
#define scan4(X, Y, Z, W) scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define scanl1(X) scanf("%lld", &X);
#define scanl2(X, Y) scanf("%lld%lld", &X, &Y)
#define scanl3(X, Y, Z) scanf("%lld%lld%lld", &X, &Y, &Z)
#define scanl4(X, Y, Z, W) scanf("%lld%lld%lld%lld", &X, &Y, &Z, &W)
#define print1(X) printf("%d\n", X);
#define print2(X, Y) printf("%d %d\n", X, Y);
#define print3(X, Y, Z) printf("%d %d %d\n", X, Y, Z);
#define print4(X, Y, Z, W) printf("%d %d %d %d\n", X, Y, Z, W);
#define printl1(X) printf("%lld\n", X);
#define printl2(X, Y) printf("%lld %lld\n", X, Y);
#define printl3(X, Y, Z) printf("%lld %lld %lld\n", X, Y, Z);
#define printl4(X, Y, Z, W) printf("%lld %lld %lld %lld\n", X, Y, Z, W);
#define max3(X, Y, Z) max(X, max(Y, Z))
#define max4(X, Y, Z, W) max(max(X, Y), max(Z, W))
#define min3(X, Y, Z) min(X, min(Y, Z))
#define min4(X, Y, Z, W) min(min(X, Y), min(Z, W))
#define popcount(X) __builtin_popcount(X)
#define all(x) x.begin(), x.end()
#define size(X) (int)X.size()
#define mp make_pair
#define pb push_back
#define fr first
#define sc second
#define lc(x) 2 * x
#define rc(x) 2 * x + 1
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pldld;
const long long l_inf = numeric_limits<long long>::max();
const long long l_ninf = numeric_limits<long long>::min();
const int inf = numeric_limits<int>::max();
const int ninf = numeric_limits<int>::min();
const double pi = 1.00 * acos(-1.00);
const double eps = 1e-8;
void cio(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
ll gcd(ll a, ll b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return (a * (b / gcd(a, b))); }
int sq( int x ) {return x * x;}
////////////////////////////////////////////////////////////////////Header
const int maxn = 3005;
ll dp[maxn][maxn][2];
bool vis[maxn][maxn][2];
int n;
ll a[maxn];

ll getdp( int x, int y, int st ) {
    if ( x > y ) return 0;
    ll &ret = dp[x][y][st];
    if ( vis[x][y][st] ) return ret;

    vis[x][y][st] = true;
    int nst = st^1;
    if ( st ) ret = min(getdp(x+1, y, nst) - a[x], getdp(x, y-1, nst) - a[y]);
    else ret = max(getdp(x+1, y, nst) + a[x], getdp(x, y-1, nst) + a[y]);
    return ret;
}

int main () {
    scan1(n);
    for ( int i = 1; i <= n; i++ ) scanl1(a[i]);
    printl1(getdp(1, n, 0));
}

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

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e933
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long ll;
typedef std::pair<int,int> pii;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main() {
    int n,t;
    cin>>n>>t;
    vector<int> v(n);
    ll ans=0;
    rep(i,0,n){
        cin>>v[i];
    }
    rep(i,1,n){
        if(v[i]-v[i-1]>=t)ans+=t;
        else ans+=(v[i]-v[i-1]);
    }
    cout<<t+ans<<endl;
    return 0;
}


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

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

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back

int main(){
    string s;
    cin >> s;
    for(int i=0;i<s.length();i++) cout << "x";
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Tester
{
    static void Main()
    {
        int a, b, c;
        string x = Console.ReadLine();
        string[] result;
        const char Space = ' ';
        char[] delimiters = new char[] { Space };
        result = x.Split(delimiters);
        a = int.Parse(result[0]);
        b = int.Parse(result[1]);
        c = int.Parse(result[2]); //入力された文字列を分割するまで

        int counter = 0;

        for(int i=a; i<=b;i++)
        {
            if (c % i == 0)
                counter++; 
        }
        Console.WriteLine("{0}", counter);
    }
}


Measured memory_bytes: 18032
#include <bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define  ll  long long
int main()
{
    ft  
    ll i,j,n,a=1;
    string s;
    cin>>n>>s;
    for(i=1;i<n;i++)
    {
        if(s[i]!=s[i-1])
        {
            a++;
        }
    }
    cout<<a<<"\n";
    return 0;
}


Measured memory_bytes: 512
n,k=map(int,input().split())
x=list(map(int,input().split()))
ans=float('inf')

for i in range(n-k+1):
    ans=min(ans,abs(x[i])+abs(x[i]-x[i+k-1]),abs(x[i+k-1])+abs(x[i]-x[i+k-1]))
    
print(ans)

Measured memory_bytes: 14380
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	long long int n,m,a,b,some,count=0,some1[2000000],some2[2000000];
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		if(a==1){
			some1[b]=1;
		}
		else if(b==n){
			some2[a]=1;
		}
	}
	for(int i=2;i<n;i++){
		if(some1[i]==1 && some2[i]==1){
			count++;
		}
	}
	printf("%s\n",(count>0)? "POSSIBLE":"IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int H, W; cin >> H >> W;
    int N; cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++) cin >> a[i];
    int pos=0;

    int ans[H][W];

    for(int i=0; i<H; i++){
        if(i%2 == 0){
            for(int j=0; j<W; j++){
                ans[i][j] = pos+1;
                a[pos]--;
                if(a[pos] == 0) pos++;
            }
        } else {
            for(int j=W-1; j>=0; j--){
                ans[i][j] = pos+1;
                a[pos]--;
                if(a[pos] == 0) pos++;
            }
        }
    }

    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(j) cout << " ";
            cout << ans[i][j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define ii pair<int,int>
#define mod 1000000007
#define endl '\n'
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=((a%mod)*(a%mod))%mod;
		b>>=1;
	}
	return ans;
}

void sieve(int n){
	bool prime[n+1];
	memset(prime,true,sizeof(prime));
	for(int p=2;p*p<=n;p++){
		if(prime[p]){
			for(int i=p*p;i<=n;i+=p)
				prime[i]=false;
		}
	}
	for(int p=2;p<=n;p++){
		if(prime[p])
			cout<<p<<" ";
	}
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		int x;
		cin>>x;
		cout<<1-x;
	}
	return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll a, b = 0, num = 1; 
    string s;
    cin >> a >> s;
    reverse(all(s));
    rep(i, s.size()){
        if(s[i] == '.')continue;
        b += (s[i]-'0') * num;
        num *= 10;
    }
    cout << a * b / 100<< endl;
}

Measured memory_bytes: 3576
n = int(input())
s_dict = {}
ana = 0
for i in range(n):
    s = "".join(sorted(input()))
    #print(s)
    if s in s_dict:
        ana += s_dict[s]
        s_dict[s] += 1
    else:
        s_dict[s] = 1
        
print(ana)

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

int main() {
	// your code goes here
	long long k,n,c,b;
	cin>>k>>n;
	long long a[n+2];
	for(long long i=0;i<n;i++)cin>>a[i];
	long long  m=(k-a[n-1])+a[0];
	for(long long i=1;i<n;i++){
		m=max(m,a[i]-a[i-1]);
	}
	cout<<k-m<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

void solve(long long N) {
  vector<int> primes;
  for (int i = 2; i <= 100; i++) {
    bool ok = true;
    for (int j = 2; j < i; j++) {
      if (i % j == 0) ok = false;
    }
    if (ok) primes.push_back(i);
  }

  vector<int> cnt(primes.size());
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j < primes.size(); j++) {
      int p = primes[j];
      int val = i;
      while (val % p == 0) {
        val /= p;
        cnt[j]++;
      }
    }
  }
  LL ans = 0;
  vector<int> A(100, 0);
  for (auto c : cnt) {
    for (int i = 0; i <= c + 1; i++) A[i]++;
  }
  ans += A[5] * (A[5] - 1) / 2 * (A[3] - 2);
  ans += A[25] * (A[3] - 1);
  ans += A[15] * (A[5] - 1);
  ans += A[75];
  cout << ans << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pii pair<int,int>
#define piii pair<int,pii>
#define mp make_pair
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-5;
const double PI = M_PI;  
#define DEB cout<<"!"<<endl
#define SHOW(a,b) cout<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cout<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
  
#define DIV 1000000007
typedef vector<ll> Array;
typedef vector<Array> matrix;
typedef tuple<int,int,int> tiii;
#define mt make_tuple


int main(){
  ll ans = 0; string str; cin >> str;
  map<char,ll> table;
  rep(i,str.size())
    table[str[i]]++;
  for(int i = 'a'; i <= 'z'; i++)
    for(int j = i +1; j <= 'z'; j++)
      ans += table[i] * table[j];
  cout << ans +1 << endl;
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

typedef pair<ll, ll> p_ll;
const int nm = 2200;
vector<bool> isp(nm, true);
vector<ll> primes;

void sieve() {
  isp[0] = false;
  isp[1] = false;
  for (int i=2; pow(i,2)<=nm; i++) {
    if (isp[i]) for(int j=2; i*j<=nm; j++) isp[i*j] = false;
  }
  rep(i,nm) if (isp[i]) primes.push_back(i);
}

int main() {
  int N; cin >>N;
  ll s[N]; rep(i,N) cin >> s[i];
  sieve();
  map<p_ll, ll> num;
  ll result = 0;
  rep(i,N) {
    p_ll p = make_pair(1,1);
    for (auto prime: primes) {
      while (s[i]%(ll)pow(prime,3)==0) {s[i]/=(ll)pow(prime,3);}
      if (s[i]%prime!=0) continue;
      s[i]/=prime;
      if (s[i]%prime==0) { s[i]/=prime; p.first*=(ll)pow(prime,2); p.second*=prime; }
      else { p.first*=prime; p.second*=(ll)pow(prime,2); }
    }
    if (s[i]==1) num[p]++;
    else {
      double sq = sqrt(s[i]);
      if (s[i]<=pow(10,5)) {
        p.first*=s[i];
        p.second*=(ll)pow(s[i],2);
        num[p]++; 
      }
      else if (floor(sq)==sq) { 
        p.first*=s[i];
        p.second*=sq; 
        num[p]++; 
        }
      else result++;
    }
    // cout << p.first << " " << p.second << endl;
  }
  for (auto x: num) {
    if (x.first.first==1) { result++; continue; }
    p_ll ppp = make_pair(x.first.second, x.first.first);
    if (num[ppp]) {
      if (x.first.first>x.first.second) continue;
      result += max(x.second, num[ppp]);
    }
    else result += x.second;
    // cout << x.first.first << "&" << x.first.second << "->" << x.second << endl;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 11264
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int cnt = 0;
		bool[] used = new bool[N];
		for(int j=30;j>=0;j--){
			int gr = 0;
			for(int i=0;i<N;i++){
				gr ^= A[i];
			}
			
			if(gr == 0){
				Console.WriteLine(cnt);
				return;
			}
			
			if(((gr >> j) & 1) == 0) continue;
			
			int mask = 1 << j;
			bool chk = false;
			for(int i=0;i<N;i++){
				if(!used[i] && (A[i] % (mask << 1)) == mask){
					A[i]--;
					cnt++;
					chk = true;
					used[i] = true;
					break;
				}
			}
			
			if(!chk){
				Console.WriteLine(-1);
				return;
			}
			
		}
		
		int gg = 0;
		for(int i=0;i<N;i++) gg ^= A[i];
		Console.WriteLine(gg == 0 ? cnt : -1);
		
		
		
	}
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = new int[N];
		for(int i=0;i<N;i++) A[i] = ri();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 17244
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define pi 3.14159265358979323846264338327950288
#define MOD 1000000007
#define INF -100000000000000
#define ordered_set tree<pair< ll int ,ll  int>, null_type,less<pair<ll int, ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define lld long double
using namespace __gnu_pbds;
int main()
{
    fast;
    string s,t;
    cin>>s>>t;
    ll int i,j,cnt=0,ans=INT_MAX;
    for(i=0;i<=s.size()-t.size();i++)
    {cnt=0;
    	for(j=0;j<t.size();j++)
    	{
    		if(s[j+i]!=t[j])
    			cnt++;
    	}
    	ans=min(cnt,ans);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3664
import java.util.Collections;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.solveC();
	}

	private void solveC() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		TreeMap<Integer, Integer> map = new TreeMap<>(Collections.reverseOrder());
		for (int i = 0; i < N; i++) {
			int a = sc.nextInt();
			if (map.containsKey(a)) {
				map.put(a, map.get(a) + 1);
			} else {
				map.put(a, 1);
			}
		}
		long max = 0;
		long secMax = 0;
		for (Entry<Integer, Integer> entry : map.entrySet()) {
			if (max == 0) {
				if (entry.getValue() > 3) {
					max = entry.getKey();
					secMax = entry.getKey();
				} else if (entry.getValue() > 1) {
					max = entry.getKey();
				}
			} else if (entry.getValue() > 1) {
				secMax = entry.getKey();
			}
			if (secMax > 0) {
				break;
			}
		}
		System.out.println(max * secMax);
	}
}

Measured memory_bytes: 63012
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

ll df(ll a, ll b)
{
    if (b < 0) a = -a, b = -b;
    return a / b - (a % b < 0);
}

ll dc(ll a, ll b)
{
    if (b < 0) a = -a, b = -b;
    return a / b + (a % b > 0);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, d;
    cin >> n >> d;
    d *= 2;
    d += 1;
    cout << dc(n, d);
}


Measured memory_bytes: 256
import java.util.Scanner

object Main{
  val sc = new Scanner(System.in)
  def main(args: Array[String]): Unit ={
    val n = sc.nextInt
    val m = sc.nextInt
    val x = List.fill(m)(sc.nextInt).toArray.sorted
    if(n >= m) println(0)
    else{
      // m > 1

      val d = (1 to (m - 1)).foldLeft(Seq.empty[Int]) { (seq, i) =>
        ( x(m - (i - 1) - 1) - x(m - i - 1) ) +: seq
      }.sorted.toArray

      val res = (0 to (m - n - 1)).foldLeft(0){ (r, i)=>
        r + d(i)
      }

      println(res)

    }
  }
}

Measured memory_bytes: 59448
#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>

// output
#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
// utility
#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 T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#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;

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

signed main() {
  int H, W; 
  cin >> H >> W;

  vector<string> s(H);
  REP(i, H) cin >> s[i];

  vector<vector<int>> dist(H, vector<int>(W, INF));

  queue<pair<int, int>> q;
  REP(i, H) REP(j, W){
    if(s[i][j] == '#'){
      dist[i][j] = 0;
      q.push({i, j});
    }
  }

  while(!q.empty()){
    int x = q.front().first;
    int y = q.front().second; q.pop();
    REP(i, 4){
      int xx = x+dx[i];
      int yy = y+dy[i];
      if(OUT(0, xx, H)) continue;
      if(OUT(0, yy, W)) continue;
      if(dist[xx][yy] <= dist[x][y]+1) continue;
      dist[xx][yy] = dist[x][y]+1;
      q.push({xx, yy});
    }
  }

  int ans = 0;
  REP(i, H) REP(j, W){
    chmax(ans, dist[i][j]);
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 25524
l=input().split()
a=int(l[0])
b=int(l[1])
c=int(l[2])
if a>c:
    temp=a;a=c;c=temp
    if b<a:
         temp=a;a=b;b=temp
    elif b>c:
         temp=b;b=c;c=temp
elif b<a:
    temp=a;a=b;b=temp
elif b>c:
    temp=b;b=c;c=temp
        
print(a,b,c)


Measured memory_bytes: 5592
// practice with kaiboy, coached by rainboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	static final int INF = 0x3f3f3f3f;
	void main() {
		int n = sc.nextInt();
		long sum = 0;
		int b_ = INF;
		while (n-- > 0) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			sum += a;
			if (a > b)
				b_ = Math.min(b_, b);
		}
		println(b_ == INF ? 0 : sum - b_);
	}
}


Measured memory_bytes: 57360
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

#define MAX_N 200001
#define INF   1000000000000000000
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

ll find_top(ll n) {
  ll top = n;
  while(n/10 > 0) {
    n = n/10;
    top = n;
  }
  return top;
}

ll find_bot(ll n) {
  return n % 10;
}

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

    ll N;
    cin >> N;

    ll ans = 0;
    ll c[10][10];

    for(int i = 0; i < 10; i++) {
      for(int j = 0; j < 10; j++) {
	c[i][j] = 0;
      }
    }
    
    for(int k = 1; k <= N; k++) {
      ll top = find_top(k);
      ll bot = find_bot(k);
      c[top][bot]++;
    }

    for(int i = 1; i <= 9; i++) {
      for(int j = 1; j <= 9; j++) {
	ans += c[i][j] * c[j][i];
      }
    }
    
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from sys import stdin
import numpy as np

s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()


N, M = ds_in()

info_list = []
for _ in range(M):
    info_list.append(ds_in())
info_list = np.array(info_list)

ordered = np.argsort(info_list[:, 1])
pref_count = np.zeros(N)
ans_list = ['' for _ in range(M)]
for i in ordered:
    pref = info_list[i, 0]
    pref_count[pref - 1] += 1
    ans_list[i] = '%06d%06d' % (pref, pref_count[pref - 1])

for a in ans_list:
    print(a)


Measured memory_bytes: 43476