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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int n,a,b;

main() {
    cin >> n >> a >> b;
    cts(min(a,b)) ct(max((n-a-b)*-1,(int)0))

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I=int(A);I<int(B);I++)
#define SORT(x) (sort(x.begin(),x.end()))
#define REV(x) (reverse(x.begin(),x.end()))


int main(){
  ll n,ans=0;
  
  cin >> n;
  vector<ll> a(n);
  FOR(i,0,n)cin >> a[i];
  SORT(a);
  FOR(i,0,n)FOR(j,i+1,n)FOR(k,j+1,n){
    if(a[i]+ a[j]>a[k])ans++;
  }

  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include<stdio.h>

int ext(int A[ ], int n, int key){
  int i =0;
  A[n] = key;
  while(A[i] != key) i++;
  return i != n;
}

int main( ){
  int i,q,n;
  int A[10000+1];
  int key,sum = 0;

  scanf("%d",&n);
  for(i = 0; i < n; i++) scanf("%d",&A[i]);
  
  scanf("%d",&q);
  
  for(i = 0; i < q; i++){
    scanf("%d",&key);
    if(ext(A,n,key)){
      sum++;
    }

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



Measured memory_bytes: 2100
#include<stdio.h>
#include<string.h>
int main()
{
    char input[10];

    scanf("%s", &input);

    if(input[0] == 'S'){
        printf("Cloudy\n");
    }
    else if(input[0]=='C'){
        printf("Rainy\n");
    }
    else if(input[0]=='R'){
        printf("Sunny\n");
    }

    return 0;
}


Measured memory_bytes: 1620
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)
int H, A[MAX+1];

void maxHeapify(int i){
    int l, r, largest;
    l = 2*i;
    r = 2*i+1;

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

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


int extract(){
    int maxv;
    if(H<1) return INFTY;
    maxv = A[1];
    A[1] = A[H--];
    maxHeapify(1);
    return maxv;
}

void increaseKey(int i, int key){
    if(key < A[i]) return;
    A[i] = key;
    while(i>1 && A[i/2] < A[i]){
        swap(A[i], A[i/2]);
        i = i/2;
    }
}

void insert(int key){
    H++;
    A[H] = -INFTY;
    increaseKey(H, key);
}

int main(int argc, char const *argv[])
{
    int key;
    char com[10];
    while(1){
        scanf("%s", com);
        if(com[0] == 'e' && com[1] == 'n') break;
        if(com[0] == 'i'){
            scanf("%d", &key);
            insert(key);
        }
        else{
            printf("%d\n", extract());
        }
    }
    return 0;
}



Measured memory_bytes: 6464
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
	public static void main(String[] args) throws Exception{
		int[] t = {0, 1,3,1,2,1,2,1,1,2,1,2,1};
		String[] u = br.readLine().split(" ");
		int a = Integer.parseInt(u[0]), b = Integer.parseInt(u[1]);
		System.out.println(t[a] == t[b] ? "Yes" : "No");
		
	}
}

Measured memory_bytes: 21076
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <stack>
#include <cctype>
#include <cmath>
#include <bitset>

using namespace std;
/* typedef */
typedef long long ll;
/* constant */
const int MAX = 1405;
// const int MAX = 5;
/* global variables */
vector< vector<int> > Area(MAX, vector<int>(MAX)), dp(MAX, vector<int>(MAX));
int H, W;
/* function */
void calc_dp_table(int &maxValue) {
    // init
    for (int i = 0; i < H; i++)
        if (Area[i][0] == 0) dp[i][0] = 1;
        else dp[i][0] = 0;
    for (int i = 0; i < W; i++)
        if (Area[0][i] == 0) dp[0][i] = 1;
        else dp[0][i] = 0;

    for (int i = 1; i < H; i++) {
        for (int j = 1; j < W; j++) {
            if (Area[i][j] == 0) {
                dp[i][j] = min({dp[i][j-1], dp[i-1][j], dp[i-1][j-1]}) + 1;
                maxValue = max(maxValue, dp[i][j]);
            }
            else {
                dp[i][j] = 0;
            }
        }
    }
}
/* main */
int main() {
    cin >> H >> W;
    int maxValue = 0;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> Area[i][j];
            if (Area[i][j] == 0) maxValue = 1;
        }
    }
    calc_dp_table(maxValue);

    cout << maxValue * maxValue<< '\n';

}



Measured memory_bytes: 18308
// @Author :- Gaurav Bharti
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define empb emplace_back
#define mp make_pair
#define F first
#define S second
#define vii vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define mapii map<int,int> 
#define mapll map<ll,ll>
#define all(a) a.begin(),a.end()
#define test int t; cin>>t; while(t--)
#define prec(n) fixed<<setprecision(n)
#define ItsFUN ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
const int MIN = INT_MIN;
const int MAX = INT_MAX;

bool comp(const pair<ll,ll> &a, const pair<ll,ll> &b) {
	return (a.second < b.second) ;
}

ll binpow(ll a, ll b) {
	ll res = 1;
	while(b) {
		if(b&1) res = res * a;
		a = a*a;
		b = b >> 1;
	}

	return res;
}


/*
BHAI EFFORT DAAL
*/


int main(){
	ItsFUN;

	ll n, c = 0; cin >> n;
	string s; cin >> s;

	for(int i = 0; i <= n-3; ++i) {
		if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ++c;
	}

	cout << c << "\n";

	return 0;
}

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


int main() {

    int64_t n;
    cin>>n;

    cout<<n<<':';

    for(int64_t i=2;i*i<=n;i++){
        if(n%i==0){
            while(n%i==0){
                cout<<' '<<i;
                n/=i;
            }
        }
    }

    if(n!=1)
        cout<<' '<<n<<endl;
    else
        cout<<endl;

	return 0;
}


Measured memory_bytes: 3116
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	string s;
	cin >> s;
	s.replace(3, 1, "8");
	cout << s << endl;
}

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

#define MAX_LEN 200000

int main(int argc, char *argv[]) {
  char S[MAX_LEN+2];
  char T[MAX_LEN+2];
  char map[128];
  int pointed[128];
  int len;
  fgets(S, MAX_LEN+2, stdin);
  fgets(T, MAX_LEN+2, stdin);
  len = strlen(S);
  // printf("S = %s", S);
  // printf("T = %s", T);
  // printf("len = %d\n", len);
  // fflush(stdout);
  for (int i = 0; i < 128; i++) {
    map[i] = -1;
    pointed[i] = 0;
  }
  for (int i = 0; i < len; i++) {
    char s = S[i], t = T[i];
    if (map[s] >= 0) {  // already an entry
      if (map[s] != t) {  // doesn't match previous
        printf("No\n");
        return 0;
      }
    } else {  // no entry yet
      map[s] = t;
      pointed[t]++;
      if (pointed[t] >= 2) {
        printf("No\n");
        return 0;
      }
    }
  }
  printf("Yes\n");
  return 0;
}


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

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

    string a,b;

    cin >> a >> b;

    if(a==b.substr(0,b.length()-1))
    {
    	cout << "Yes" << '\n';
    }
    else
    {
    	cout << "No" << '\n';
    }
    
    return 0;
}

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

int main(){
  string s, t;
  cin >> s;
  cin >> t;
  int count;
  for (int i=0; i<3; i++){
    if (s.at(i) == t.at(i)){
      count++;
    }
  }
  cout << count << endl;
}


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

typedef long long ll;
typedef pair<int,int> pii;
typedef map<int,int> mkmap;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vp;
typedef vector<vi> vv;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
const ll mod=1000000007;
const int sz=1000001;
#define endl "\n"
#define all(a) (a).begin(),(a).end()
#define rep(i,a,b) for(i=a;i<b;++i)
#define rrep(i,a,b) for(i=a;i>=b;--i)
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db(x) cout << (#x) << " = " << x << endl;

inline ll mult(ll a, ll b) {return (((a % mod) * (b % mod)) % mod);}

int main(){
    fast;
    int i,j;
    string s,t;
    cin>>s>>t;
    string dp1[3001],dp2[3001];
    rep(i,0,3001) dp1[i]="";

    for(i=s.length()-1;i>-1;--i){
        dp2[t.length()]=dp1[t.length()];
        dp1[t.length()]="";
        for(j=t.length()-1;j>-1;--j){
            dp2[j]=dp1[j];
            if(s[i]==t[j]) dp1[j]=s[i]+dp2[j+1];
            else if(dp2[j].length()>dp1[j+1].length()) dp1[j]=dp2[j];
            else dp1[j]=dp1[j+1];
        }
    }

    cout<<dp1[0];

    // for(auto i:dp){
    //     for(auto p:i) cout<<p<<" ";
    //     cout<<endl;
    // }
}

/*
    
*/

Measured memory_bytes: 15428
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const int MOD = 1e9 +7;


int main(){
    int n,y;
    cin >> n >> y;
    int a,b,c;
    bool flag = true;
    for(int i = 0;i<=n;i++){
        for(int j=0;j<=n-i;j++){
            if(10000*i+5000*j+1000*(n-i-j) ==y && flag){
                flag = false;
                cout << i  << " "<< j << " "<< n-i-j << endl;
                break;
            }
        }
    }
    if(flag){
        cout << -1 << " " << -1  <<" "<< -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int c=0,i,count[26]={0},num=0;
    char a,b='a';
    while(scanf("%c",&a)!=EOF){
        if(a>='a'&&a<='z'){
            num=a-'a';
            count[num]++;
        }else if(a>='A'&&a<='Z'){
            num=a+32-'a';
            count[num]++;
        }
    }
    for(i=0;i<26;i++){
            printf("%c : %d\n",b++,count[i]);
    }
    return 0;
}


Measured memory_bytes: 2056
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>
#include <map>

using namespace std;


int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    string s;
    long long m = 0, a = 0, r = 0, c = 0, h = 0;
    for(int i = 0; i < n; i++){
        cin >> s;
        switch(s[0]){
            case 'M' :
                m++;
                break;
            case 'A':
                a++;
                break;
            case 'R':
                r++;
                break;
            case 'C':
                c++;
                break;
            case 'H':
                h++;
                break;
        }
    }
    cout <<
    m*a*r +
    m*a*c +
    m*a*h +
    m*r*c +
    m*r*h +
    m*c*h +
    a*r*c +
    a*r*h +
    a*c*h +
    r*c*h
    <<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}


int main(){
    ll a,b,k; cin>>a>>b>>k;
    ll res=0;
    for(ll i=100; i>=1; i--){
        if(a%i==0 && b%i==0){
            res++;
            if(res==k){
                cout<<i<<endl;
                return 0;
            }
        }
    }
    return 0;
}

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

typedef long long ll;

int main(){
    ll march[5] = {};
    int n;
    string s;

    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> s;
        if(s[0] == 'M') march[0]++;
        if(s[0] == 'A') march[1]++;
        if(s[0] == 'R') march[2]++;
        if(s[0] == 'C') march[3]++;
        if(s[0] == 'H') march[4]++;        
    }

    ll res = 0;
    for(int i = 0; i < 3; i++){
        for(int j = i+1; j < 4; j++){
            for(int k = j+1; k < 5; k++){
                res += march[i]*march[j]*march[k];
            }
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define fr(i,x,y) for(int i=x;i<y;i++)
#define f(n) for(int i=0;i<n;i++)
#define ff(m) for(int j=0;j<m;j++)
#define F(x) for(auto it:x)
#define in insert
#define pb push_back
#define pi pair<int,int>
#define si second
#define fi first
#define show_(x) cerr<<"-> "<<#x<<endl;F(x){cerr<<it<<" ";}cout<<endl;
#define show(x) cerr<<#x<<"-> "<<x<<endl;
//#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
//#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0;
#define FILEIO freopen("F:\\inout\\input.txt", "r", stdin); freopen("F:\\inout\\output.txt", "w", stdout);
using namespace std;
void print(int a[],int n){f(n){cout<<a[i]<<" ";}cout<<endl;}
int m(int x){return x%1000000007;} 
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
int p(int a,int b){if(b==0)return 1;int t=p(a,b/2); if(b%2==0)return t*t; else return a*t*t; } 
//strlen(s.c_str());  set <int, greater<int>> s; numeric_limits<double>::max()
//---------------------------------------------------------------------------------------------------------------------------------------------
 int t[100000];


signed main(){
	//FILEIO
	//cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin>>s;
	sort(s.begin(),s.end());
	if(s[0]==s[1] && s[2]==s[3] && s[1]!=s[2]){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}

	

	
	
	






	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define sort(a) sort(all(a))
using P = pair<int, int>;
using ll = long long;
using ld = long double;
int dx[4] = { 0, 1, 0,-1 };
int dy[4] = { 1, 0,-1, 0 };

signed main() {
  int X,Y,A,B,C;
  cin >> X >> Y >> A >> B >> C;
  vector<int> p(A);
  for (int i = 0; i < A; i++) cin >> p[i];
  vector<int> q(B);
  for (int i = 0; i < B; i++) cin >> q[i];
  vector<int> r(C);
  for (int i = 0; i < C; i++) cin >> r[i];
  sort(p); sort(q);
  p = vector<int>(p.end()-X, p.end());
  q = vector<int>(q.end()-Y, q.end());
  p.insert(p.end(), q.begin(), q.end());
  p.insert(p.end(), r.begin(), r.end());
  int ans = 0;
  int N = p.size();
  sort(p);
  for (int i = N-X-Y; i < N; i++) {
    ans += p[i];
  }
  cout << ans << endl;
}



Measured memory_bytes: 5920
while True:
    n, m = map(int, raw_input().split())

    if n == 0 and m == 0:
        break

    s = map(int, raw_input().split())
    ans = -1

    for i in range(n):
        for j in range(i+1, n):
            if s[i] + s[j] <= m:
                ans = max(ans, s[i] + s[j]);

    print "NONE" if ans == -1 else ans



Measured memory_bytes: 4708
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int ,int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int R, G;
	cin >> R >>G;
	cout << 2*G-R << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, x);
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

int gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(void) {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << (a * b > c * d ? a * b : c * d) << endl;
  return 0;
}

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

int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  
  list<int> b;
  if(n % 2 == 0){
    for(int i=0;i<n;i++){
      if(i%2==0)b.push_back(a[i]);
      else b.push_front(a[i]);
    }
  }else{
    for(int i=0;i<n;i++){
      if(i%2==0)b.push_front(a[i]);
      else b.push_back(a[i]);
    }
  }
  for(auto x : b) {
    cout << x << " ";
  }cout << endl;

  return 0;
}

Measured memory_bytes: 9216
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pi=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
void Yes(bool c) { if (c)print("Yes"); else print("No"); };
void YES(bool c) { if (c)print("YES"); else print("NO"); };

void solve() {
    int R; cin >> R;
    if(R<1200){
        print("ABC");
    }else if(R<2800){
        print("ARC");
    }else{
        print("AGC");
    }

}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 3580
#include <stdio.h>

void maxHeapify(int *A, int k,int n){
  int v,i,l,r,z;
  l=k*2;
  r=k*2+1;
  z=k;
  if(l<=n&&A[l]>A[k]) z=l;
  if(r<=n&&A[r]>A[z]) z=r;

  if(z!=k){
    v=A[k];
    A[k]=A[z];
    A[z]=v;
    maxHeapify(A,z,n);
  }
}

int main() {

    int i;
    int n;
    int A[500001];

    scanf("%d",&n);

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

    for(i=n/2;i>=1;i--){
      maxHeapify(A,i,n);
    }

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

    return 0;
}

    



Measured memory_bytes: 3744
#include<iostream>
#include<string>
#include<complex>
#include<vector>
#include<algorithm>
#include<functional>
#include<array>
#include<map>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int n, k;
	cin >> n >> k;
	if (n%k == 0) cout << "0" << endl;
	else cout << "1" << endl;


	return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <map>
using namespace std;
const long mod = 1000000007;
int main()
{
  int N;
  cin >> N;
  map<int, int> mp;
  for (int i = 2; i <= N; i++)
  {
    int n = i;
    for (int j = 2; j * j <= n; j++)
    {
      while (n % j == 0)
      {
        if (mp.find(j) == mp.end())
          mp[j] = 1;
        else
          mp[j] = mp[j] + 1;
        n /= j;
      }
    }
    if (n != 1)
    {
      if (mp.find(n) == mp.end())
        mp[n] = 1;
      else
        mp[n] = mp[n] + 1;
    }
  }
  long ans = 1;
  for (auto m : mp)
  {
    ans *= m.second + 1;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
}; 

int main(){
    Stream io;
    
    int A, B;
    io.read(A, B);
    int ans = 0;
    for(int i = A; i <= B; i++){
        string s = to_string(i);
        if(s[0] == s[4] && s[1] == s[3]) ans++;
    }
    cout << ans;
    return 0;
}

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

signed main() {
	int N;
	cin >> N;
	int last = -1, ans = 0;
	for (int i = 0; i < N; ++i) {
		int cur;
		cin >> cur;
		if (cur == last) {
			++ans;
			cur = -1;
		}
		last = cur;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define M 100005
#define pb push_back
#define mod 1000000007
#define rep(i,a,b) for(lli i=a;i<b;i++)

#define PI 3.14285714286
#define db double
#define fs first
#define sc second
#define pii pair<db,db>
void fast()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
}

db ans,sum=0;
vector<db> a;
vector<pair<db,db> > vec;
lli sz,fact=0;
db dist(lli i,lli j)
{
	db s1 = (vec[i].fs-vec[j].fs)*(vec[i].fs-vec[j].fs) + (vec[i].sc-vec[j].sc)*(vec[i].sc-vec[j].sc) ;
	s1=sqrt(s1);
	return s1;
}

void permute(lli k,lli n)
{
	if(k==n)
	{
		//sum=0;
		fact++;
		rep(i,1,sz)
		{
			sum+=dist(a[i],a[i-1]);
		}
		return;
	}
	for(lli i=k;i<n;i++)
	{
		swap(a[i],a[k]);
		permute(k+1,n);//k+1
		swap(a[i],a[k]);
	}
}
void solve()
{
	lli n;
	db x,y,u,v;
	cin>>n;
	sz=n;
	rep(i,0,n)
	{
		cin>>x>>y;
		vec.push_back({x,y});
		a.pb((db)i);
	}
	permute(0,n);
	db res=sum/fact;
	printf("%.10lf",res);
}
int main()
{
	fast();
	lli t=1;
	//cin>>t;
	while(t--)solve();
	
	return 0;
}

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

using namespace std;
using ll = long long;

const ll INF = 1LL << 60;
const int maxn = 2*1e5+10;

int n;
ll a[maxn];
map<pair<int,int>,ll> dp;

ll get_ans(int pos,int picked){
	if(picked > n/2 || picked + (n-pos+1)/2 < n/2) return -INF;
	if(pos >= n) return 0;
	pair<int,int> cur = {pos,picked};
	if(dp.count(cur)) return dp[cur];
	return dp[cur] = max(get_ans(pos+1,picked),get_ans(pos+2,picked+1)+a[pos]);
}

void solve(){
	cin >> n;
	for(int i=0;i<n;++i) cin >> a[i];
	cout << get_ans(0,0) << '\n';
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	//cin >> t;
	while(t--){ 
		solve();
	}
	return 0;
}

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

using namespace std;

const int max_n = 100011, inf = 1000111222;

int n, a[max_n], b[max_n];
set<int> q;

void no() {
    puts("No");
    exit(0);
}

void yes() {
    puts("Yes");
    exit(0);
}

bool check() {
    sort(b, b + n);
    for (int i = 0; i < n; ++i) {
        if (a[i] != b[i]) {
            return false;
        }
    }
    return true;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        q.insert(a[i]);
    }
    sort(a, a + n);
    if (q.size() > 3) {
        no();
    }
    for (int x : q) {
        for (int y : q) {
            b[0] = x;
            b[1] = y;
            for (int i = 2; i < n; ++i) {
                b[i] = b[i - 1] ^ b[i - 2];
            }
            if (b[n - 1] == b[n - 2] ^ b[0] && check()) {
                yes();
            }
        }
    }
    no();
    return 0;
}


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

int main(){
  string j, k;
  cin >> j >> k;
  bool ans = false;
  for (int i = 0;i<j.size();i++){
    if(j==k){
      ans = true;
      break;
    }
    rotate(j.begin(),j.begin()+1,j.end());
  }
  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる





int main() {
  ll n,k,r,s,p;
  string t;
  cin>>n>>k>>r>>s>>p>>t;

  vector<vector<char>> te(k);
  rep(i,n){
    te[i%k].pb(t[i]);
  }

  ll ans=0;
  rep(i,k){
    ll cnt=1;
    char now=te[i][0];
    repo(j,te[i].size()){
      if(te[i][j]!=now) {
        cnt=(cnt+1)/2;
        if(now=='r') ans+=p*cnt;
        if(now=='s') ans+=r*cnt;
        if(now=='p') ans+=s*cnt;
        cnt=1;
        now=te[i][j];
      }
      else cnt++;
    }
    cnt=(cnt+1)/2;
    if(now=='r') ans+=p*cnt;
    if(now=='s') ans+=r*cnt;
    if(now=='p') ans+=s*cnt;
  }


  cout << ans << endl;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    ll N;
    cin >> N;
    vector<ll> vec;
    ll ans = 0;
    bool exist = false;  //10の倍数でない数があるか
    for (ll i = 0;i<N;i++) {
        ll a; cin >> a;
        vec.push_back(a);
        ans += a;
        if (a%10 != 0) exist = true;
    }
    sort(vec.begin(),vec.end());
    if ( !exist ) cout << 0 << endl;
    else if (ans % 10 != 0) cout << ans << endl;
    else {
        for (ll i = 0;i<N;i++) {
            if (vec.at(i) % 10 != 0) {
                cout << ans - vec.at(i) << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

vector<pair<int, int>> A;

int main(){
    int N, M, shop, num, count = 0;
    long long int total = 0;
    cin >> N >> M;
    for(int i = 0; i < N; i++){
        int a, b;
        cin >> a >> b;
        A.push_back(make_pair(a, b));
    }
    sort(A.begin(), A.end(), [](pair<int, int> x, pair<int, int> y) -> bool{return (x.first < y.first);});
    for(int i = 0; i < N; i++){
        for(int j = 0; j < A[i].second; j++){
            count++;
            total += A[i].first;
            //cout << total << endl;
            if(count == M) break;
        }
        if(count == M) break;
    }
    cout << total << endl;
    return 0;
}

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

int main() {
  int A,B,C,D,E,F;
  cin>>A>>B>>C>>D>>E>>F;
  double water,sugar,ans,ans1,ans2;
  ans1=A*100;
  ans2=0;
  ans=0;
  for(int i=0;i<32;i++){
    for(int j=0;;j++){
      if(i==0&&j==0)continue;
      water=(A*i+B*j)*100;
      if(water>F)break;
      for(int k=0;water/100*E>C*k;k++){
        for(int l=0;;l++){
          sugar=C*k+D*l;
          if(water+sugar>F)break;
          if(water/100*E<sugar)break;
          if(ans<100*sugar/(water+sugar)){ans1=water+sugar;ans2=sugar;}
          ans=max(ans,100*sugar/(water+sugar));
        }
      }
    }
  }
  cout<<ans1<<" "<<ans2<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;



int main(){
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;

  vector<ll> ret;
  while(true){
    if(N == 0) break;
    if(N == 1 || N == 2){
      ret.push_back(N);
      break;
    }

    ll x = 0;
    for(ll i=1; i<=N; i++){
      if(x+i >= N){
        ret.push_back(i);
        N-=i;
        break;
      }
      x+=i;
    }
  }
  
  rep(i,ret.size()){
    cout << ret[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main(){
    FAST
    int n,k;
    cin>>n>>k;
    unordered_map<int,int>mp;
    int x;
    for(int i=0;i<n;i++){
        cin>>x;
        mp[x]++;
    }
    if(mp.size()<=k) cout<<0<<endl;
    else{
        vector<int>v;
        int ans=0;
        for(auto x:mp){
            v.push_back(x.second);
        }
        sort(v.begin(),v.end());
        int toRemove = mp.size()-k;
        for(int i=0;i<toRemove;i++){
            ans+=v[i];
        }
        cout<<ans;
    }
}


Measured memory_bytes: 10312
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;



int main() {
	int n, count = 0, ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		count = 0;
		if (i % 2 == 1) {
			for (int j = 1; j <= i; j++) {
				if (i % j == 0)count++;
			}
		}
		
		if (count == 8)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static Scanner stdIn = new Scanner(System.in);
    public static void main(String[] args){
		int n = stdIn.nextInt();
		int k = stdIn.nextInt();
		int s = stdIn.nextInt();
		int[] a = new int[n];
		for(int i=0; i<k; i++){
			a[i] = s;
		}
		for(int i=k; i<n; i++){
			a[i] = (s+1)%1000000000;
		}

		for(int i=0; i<n; i++){
			System.out.print(a[i] + " ");
		}
	}
}


Measured memory_bytes: 52920
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int a, b;
	bool ans = false;
	cin >> a >> b;
	if (a % 3 == 0) ans = true;
	if (b % 3 == 0) ans = true;
	if ((a + b) % 3 == 0) ans = true;

	if (ans) cout << "Possible\n";
	else cout << "Impossible\n";

	return 0;
}


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

int dp[100005], pai[100005];

int main(){

    int n, m; cin >> n >> m;
    string s; cin >> s;
    dp[0] = 0;
    queue<ii> q; q.push({0, 0});
    for(int i = 1; i <= n; i++){
        if(s[i] == '1') continue;
        while(!q.empty() and q.front().second+m < i)
            q.pop();
        if(q.empty()) break;
        pai[i] = q.front().second;
        dp[i] = q.front().first + 1;
        // printf("chegou na posição %d vindo de %d\n", i, pai[i]);
        while(!q.empty() and q.front().first >= dp[i])
            q.pop();
        q.push({dp[i], i});
    }
    if(dp[n] == 0) cout << -1 << endl;
    else{
        vector<int> vec;
        int pos = n;
        while(pos != 0){
            // cout << pos << endl;
            vec.push_back(pos - pai[pos]);
            pos = pai[pos];
        }
        reverse(vec.begin(), vec.end());
        for(int val : vec)
            cout << val << " ";
        cout << endl;
    }
	return 0;
}


Measured memory_bytes: 1912
using System;

class Program{
    static void Main(string[] args){
        string[] arr = Console.ReadLine().Split(' ');
        int a = Int32.Parse(arr[0]);
        int b = Int32.Parse(arr[1]);

        if((a*b)%2 == 0){
            Console.WriteLine("Even");
        }else{
            Console.WriteLine("Odd");
        }
    }
}

Measured memory_bytes: 11092
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char[] c = new char[3];

    for(int i=0 ; i<3 ; i++){
      c[i]=s.charAt(i);
      if(c[i]=='1'){
        c[i]='9';
      }else if(c[i]=='9'){
        c[i]='1';
      }
    }
    for(int i=0 ; i<3 ; i++){
      System.out.print(c[i]);
    }
    System.out.println();
  }
}


Measured memory_bytes: 23892
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {

    int t,h,m,s;

    cin >> t;

    h = t / 3600;
    t = t % 3600;
    m = t / 60;
    s = t % 60;

    printf("%d:%d:%d\n",h,m,s);

	return 0;
}


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

int main(void) {
    int cnt=0,ans=0;
    long long int N;
    cin>>N;
    vector<int> vec(N);

    for (int i=0;i<N;i++){
      cin>>vec[i];
    }
    int min = *std::min_element(vec.begin(), vec.end());
    int max = *std::max_element(vec.begin(), vec.end());


    cout<<max-min<<endl;

    return 0;
}


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


public class Main{
	public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
	int[] input=new int[5];
	int[] output=new int[5];
	for(int i=0;i<input.length;i++){
		input[i]=scan.nextInt();
	}
	Arrays.sort(input);
	for(int i=0;i<input.length;i++){
		output[i]=input[input.length-i-1];
	}
	System.out.println(output[0]+" "+output[1]+" "+output[2]+" "+output[3]+" "+output[4]);
	}

}

Measured memory_bytes: 17168
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    int N; cin >> N;
    vector<int> P(N), Q(N);
    for (int i = 0; i < N; i++) cin >> P[i];
    for (int i = 0; i < N; i++) cin >> Q[i];

    vector<int> A(N);
    for (int i = 0; i < N; i++) A[i] = i+1;

    int a, b;

    int i = 0;
    do {
        i++;
        if (P == A) a = i;
        if (Q == A) b = i;
    } while (next_permutation(A.begin(), A.end()));

    cout << abs(a - b) << endl;
}


int main() {
    solve();
    return 0;
}

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

int main() {
 map<string,UL> S;
 UL Q; scanf("%u",&Q);
 rep(q,Q){
  UL c; scanf("%u",&c);
  if(c==0){
   char buf[21]; UL x; scanf("%s%u",buf,&x);
   S[buf]=x;
  }
  if(c==1){
   char buf[21]; scanf("%s",buf);
   auto f=S.find(buf);
   printf("%u\n",(f==S.end()) ? 0 : f->second);
  }
  if(c==2){
   char buf[21]; scanf("%s",buf);
   S.erase(buf);
  }
  if(c==3){
   string L,R;
   char buf[21];
   scanf("%s",buf); L=string(buf);
   scanf("%s",buf); R=string(buf);
   auto f=S.lower_bound(L);
   for(;f!=S.end();f++){
    if(f->first>R) break;
    printf("%s %u\n",f->first.c_str(),f->second);
   }
  }
 }
 return 0;
}




Measured memory_bytes: 25984
#include<bits/stdc++.h>
using namespace std;
const int mo=1000000007,N=105;
int c[N][N],f[N][N],n;
int main(){
	scanf("%d",&n);
	for (int i=0;i<=n;i++){
		c[i][0]=1;
		for (int j=1;j<=i;j++)
			c[i][j]=(c[i-1][j]+c[i-1][j-1])%mo;
	}
	f[1][n]=f[1][n-1]=1;
	for (int i=1;i<=n;i++)
		for (int j=-i;j<=i;j++){
			int tmp=f[i][j+n];
			if (!tmp) continue;
			int s=max(1,abs(j));
			s+=(j+s)%2;
			for (;s<=n-i;s+=2)
				for (int ss=0;ss<=s;ss++){
					int val=((j-s)/2+ss);
					if (val<-n||val>n) continue;
					f[i+s][val+n]=(f[i+s][val+n]+1ll*c[i+s][s]*c[s][ss]%mo*tmp)%mo;
				}
		}
	printf("%d\n",f[n][n]);
}

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

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

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let n: usize = read();
    let av: Vec<usize> = read_vec();
    let mut cnt: Vec<i64> = vec![0; n + 1];

    for i in 0..n {
        let a = av[i];
        cnt[a] += 1;
    }

    let mut total = 0;

    for i in 0..n + 1 {
        let tmp = cnt[i];
        total += tmp * (tmp - 1) / 2;
    }

    for i in 0..n {
        let a = av[i];
        let c = cnt[a];
        let mut tmp = total;
        tmp -= c * (c - 1) / 2;
        tmp += (c - 1) * (c - 2) / 2;
        println!("{}", tmp);
    }
}


Measured memory_bytes: 11504
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n,d;
  cin >> n >> d;

  vector<vector<int>> vvi(n,vector<int>(d));

  rep(i,n)
  rep(j,d)
  {
    cin >> vvi[i][j];
  }

  int cnt = 0;

  rep(i,n)
  for(int j = i; j < n;j++)
  {
    if(i == j)
      continue;
    int dist = 0;
    rep(k,d)
    {
      dist += pow(vvi[i][k] - vvi[j][k],2);
    }

    int x = sqrt(dist);

    // cout << x << " " << dist << endl;;

    if(x * x == dist)
      cnt++;
  }

  cout << cnt;



  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
A, B = map(int, input().split())
n = 1
a = 0
b = 0
while b <= 100:
    a = int(n * 0.08)
    b = int(n * 0.10)
    if a == A and b == B:
        print(n)
        break
    n += 1
else:
    print(-1)

Measured memory_bytes: 38384
import sys
def main():
    def input():
        return sys.stdin.readline()[:-1]
    N = int(input())
    ans = 0
    a, b, c = 0, 0, 0
    for k in range(N):
        s = input()
        if s[0] == "B" and s[-1] == "A":
            c += 1
        if s[0] == "B":
            b += 1
        if s[-1] == "A":
            a += 1
        for k in range(len(s)-1):
            if s[k:k+2] == "AB":
                ans += 1
    if c > 0 and a == b == c:
        print(ans + c-1)
    else:
        print(ans + min(a,b))

if __name__ == '__main__':
    main()


Measured memory_bytes: 41456
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  console.log(' ' + buildMaxHeap(lines.shift().split(' ').map(Number)).join(' '));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
    let left, right, largest;
    left = 2 * i + 1;
    right = 2 * i + 2;
    if (left >= n && right >= n) return;
    if (left < n && arr[left] > arr[i]) largest = left;
    else largest = i;
    if (right < n && arr[right] > arr[largest]) largest = right;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };

  for (let i = Math.floor(arr.length / 2); i >= 0; i--) maxHeapify(i);
  return arr;
}



Measured memory_bytes: 110728
#include<bits/stdc++.h>
#define int long long
using namespace std;
main()
{
    int a,b;
    cin>>a>>b;
    int diff=abs(a+b);
    diff/=2;
    if(abs(a-diff)==abs(b-diff)){
        cout<<diff<<"\n";
    }else{
        cout<<"IMPOSSIBLE\n";
    }
}

Measured memory_bytes: 256
import copy
#import time

h,w = map(int,input().split())
a = [input() for _ in range(h)]
b = [[False]*w for _ in range(h)]
#s = time.time()
c = []
d = [(-1,0), (1,0), (0,-1), (0,1)]
ans = 0

for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            b[i][j] = True
            c.append((i,j))
#print(time.time()-s)

while True:
    tmp = []
    cnt = 0
    for i,j in c:
        for d1,d2 in d:
            if 0 <= i + d1 < h and 0 <= j + d2 < w:
                if not b[i+d1][j+d2]:
                    tmp.append((i+d1, j+d2))
                    b[i+d1][j+d2] = True
                    cnt += 1
    #print(time.time()-s)
    if cnt > 0:
        c = copy.copy(tmp)
        ans += 1
    else:
        break
    #print(time.time()-s)

print(ans)


Measured memory_bytes: 145420
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  set<int> s;
  FOR(i,0,M) {
    int a;
    cin >> a;
    s.insert(a);
  }
  ll dp[N+1];
  FOR(i,0,N+1) dp[i] = 0;
  dp[0] = 1;
  FOR(i,1,N+1) {
    if (s.count(i)) {
      continue;
    }
    if (i - 1 >= 0) {
      (dp[i] += dp[i-1]) %= 1000000007;
    }
    if (i - 2 >= 0) {
      (dp[i] += dp[i-2]) %= 1000000007;
    }
  }
  cout << dp[N] % 1000000007 << endl;
}



Measured memory_bytes: 5760
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		long[] L = new long[N + 1];
		L[0] = 2;
		L[1] = 1;

		for (int i = 2; i <= N; i++)
			L[i] = L[i - 1] + L[i - 2];

		System.out.println(L[N]);
	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 20948
from string import*;from itertools import*;b=ascii_lowercase;s=r=input();t=s[::-1];d=0
if len(s)>25:d=-[p*len(list(k))for p,k in groupby([i<j for i,j in zip(t,t[1:])])][0]-2;u=s*2;s,b,r=s[:d],s[d+1:],b[:ord(u[d])-97]
print(-(d<-26)or s+sorted(set(b)-set(r))[0])

Measured memory_bytes: 3772