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

using namespace std;

int main() {

    int N;
    cin >> N;

    vector<pair<int, int>> tasks;

    for(int i = 1; i <= N; i++) {
        int A, B;
        cin >> A >> B;
        tasks.emplace_back(B, A);
    }

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

    int sum = 0;

    bool ans = true;

    for(auto v : tasks) {
        sum += v.second;

        if(sum > v.first) {
            ans = false;
            break;
        }
    }

    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

 
int main() {
    ll n;
    double ans = 0;
    vector<double> v;
    
    cin >> n;

    for (int i = 0; i < n; i++) {
        int temp;
        cin >> temp;
        v.push_back (temp);
    }

    sort(ALL(v));

    for (int i = 0; i < n-1; i++) {
        v[i+1] = 0.5 * (v[i] + v[i+1]);
    }
    
    cout << setprecision(10) << v[n-1] << endl;

    
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <cstdio>

using namespace std;

struct dice{
  int surface[6];

  void numReplace(int num[6], int n0, int n1, int n2, int n3, int n4, int n5){
    num[0] = n0;
    num[1] = n1;
    num[2] = n2;
    num[3] = n3;
    num[4] = n4;
    num[5] = n5;
  }
  
  void rotation(struct dice *self, char c){
    int num[6];
    for(int i = 0; i < 6; i++){
      num[i] = self->surface[i];
    }

    if(c == 'N'){
      numReplace(self->surface, num[1], num[5], num[2], num[3], num[0], num[4]);
    }
    else if(c == 'E'){
      numReplace(self->surface, num[3], num[1], num[0], num[5], num[4], num[2]);
    }
    else if(c == 'S'){
      numReplace(self->surface, num[4], num[0], num[2], num[3], num[5], num[1]);
    }
    else if(c == 'W'){
      numReplace(self->surface, num[2], num[1], num[5], num[0], num[4], num[3]);
    }
  }

  void spin(struct dice *self, string s){
    int num[6];
    for(int i = 0; i< 6; i++){
      num[i] = self->surface[i];
    }

    if(s == "CW"){
      numReplace(self->surface, num[0], num[2], num[4], num[1], num[3], num[5]);
    }
    else if(s == "CCW"){
      numReplace(self->surface, num[0], num[3], num[1], num[4], num[2], num[5]);
    }
  }
};

int main(){
  struct dice d1{{0}};
  bool check[6] = {};
  int q, t, f, ans=-1;
  
  for(int i = 0; i < 6; i++){
    cin >> d1.surface[i];
  }
  cin >> q;

  for(int i = 0; i < q; i++){
    cin >> t >> f;

    for(int j = 0; j < 6; j++){
      for(int k = 0; k < 4; k++){
	if(t == d1.surface[0] && f == d1.surface[1]){
	  ans = d1.surface[2];
	  break;
	}
	d1.spin(&d1, "CW");
      }
      if(ans != -1){ break; }

      if(j%2){ d1.rotation(&d1, 'E'); }
      else{ d1.rotation(&d1, 'S'); }
    }

    if(ans != -1){
      cout << ans << endl;
      ans = -1;
    }
  }
  
  return 0;
}



Measured memory_bytes: 3160
#include <iostream>
#include<algorithm>
using namespace std;
#define N int(2e5)
long long sum[N+10],a[N+10];
int main()
{
    int n;
    cin>>n;
    for (int i=0;i<n;i++) cin>>a[i];
    sum[0]=0;
    for (int i=1;i<=n;i++)
    {
        sum[i]=sum[i-1]+a[i-1];
    }
    sort(sum,sum+n+1);
    long long ans=0,t=1;
    for (int i=1;i<=n;i++)
        if (sum[i]==sum[i-1]) t++;
        else {
            ans+=t*(t-1)/2;
            t=1;
        }
    ans+=t*(t-1)/2;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3328
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 Sol()
    {

        int N = int.Parse(Console.ReadLine());
        int[] a = new int[N+1];
        bool[] idxI = new bool[N + 1];
        int index = 1;
        for (int i = 1; i <= N; i++) {
            a[i] = int.Parse(Console.ReadLine());
            idxI[i] = false;
        }

        int step =0;
        idxI[1] = true;
        while (index != 2)
        {
            // press index button
            
            step++;
            index = a[index];
            if (idxI[index])
            {
                Console.WriteLine(-1); return;
            }
            else if (index == 2)
            {
                Console.WriteLine(step); return;
            }
            else
            {
                idxI[index] = true;
            }
        }

    }


    public void Solve()
    {

    }

    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().Trim().Split(sep), e => int.Parse(e)); }
    static long[] rla(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
    static double[] rda(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }


}

Measured memory_bytes: 13408
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <memory.h>
#include <math.h>
#include <queue>
#include <map>
#include <stack>
#include <bitset>

#define INFI 0x7fffffff
#define MAXN 100010

using namespace std;

int ma[MAXN];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;++i)
        scanf("%d",&ma[i]);
    int ans=0;
    for(int i=1;i<=n;++i)
    {
        if(ma[i]<=i && ma[ma[i]]==i) ++ans;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int memo[100000];
int minCost(int arr[], int p)
{
    if(memo[p] != -1)
        return memo[p];
    if(p==0){
        memo[p] = p;
        return 0;
    }
    if(p==1){
        memo[p] = abs(arr[p] - arr[0]);
        return abs(arr[p] - arr[0]);
    }
    int q1 = abs(arr[p] - arr[p-1]) + minCost(arr,p-1);
    int q2 = abs(arr[p] - arr[p-2]) + minCost(arr, p-2);
    memo[p] = min(q1, q2);
    return memo[p];
}
int main() {
    int n;
    cin >> n;
    int arr[n];
    for(int i=0; i<n; i++)
        cin >> arr[i];
    memset(memo, -1, sizeof(memo));
    int ans = minCost(arr, n-1);
    cout << ans;
}

Measured memory_bytes: 8832
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, s, n) for(int i = s; i < n; i++)
using namespace std;

int main(){
  int n;
  string s;
  cin >> n;
  cin >> s;
  if (n % 2 == 0 && s.substr(0, n/2) == s.substr(n/2))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;


int main()
{
	double n,k;
	cin>>n>>k;
	double *A = new double[(int)n];
	unsigned long long int sum = 0;
	int minNum = 1e7;
	int minIndex = -1;
	for(int i = 0; i < n; i++){
		int num;
		cin>>num;
		
	}
	cout<<ceil((n-1)/(k-1))<<endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		boolean isA = true;
		StringBuilder sb = new StringBuilder();
		for (char c : arr) {
		    if (isA && c == 'A') {
		        sb.append(c);
		        isA = false;
		    } else if (!isA && c == 'Z') {
		        sb.append(c);
		        isA = true;
		    }
		}
		if (sb.length() % 2 == 1) {
		    sb.deleteCharAt(sb.length() - 1);
		}
		if (sb.length() == 0) {
		    System.out.println(-1);
		} else {
		    System.out.println(sb);
		}
	}
}



Measured memory_bytes: 26316
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S,T;
  cin>>S>>T;
  string ans="";
  int len=S.size();
  for(int i=0;i<len;i++){
    ans+=S[len-1];
    for(int k=0;k,k<len-1;k++){
      ans+=S[k];
    }
    if(ans==T){
      cout<<"Yes"<<endl;
      return 0;
    }
    S=ans;
    ans="";
  }
  cout<<"No"<<endl;
  return 0;
}



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

using namespace std;

int main()
{
	int n;
	long long c, r = 0, z = 0, sd, sn, so;
	cin >> n >> c;
	vector <pair <long long, long long> > a(n);
	
	for (int i = 0; i < n; i++)
		cin >> a[i].first >> a[i].second;
		
	for (int i = 0; i < n; i++)
	{
		z += a[i].second - (i ? a[i].first - a[i-1].first : a[0].first);
		r = max(r, z);
	}

	z = 0;
	
	for (int i = n-1; i >= 0; i--)
	{
		z += a[i].second - (i == n-1 ? c-a[n-1].first : a[i+1].first - a[i].first);
		r = max(r, z);
	}
	
	if (n == 1)
	{
		cout << r;
		return 0;
	}
	
	so = 0;
	
	for (int i = 1; i < n; i++)
		so += a[i].second;

	sd = a[0].first;
	sn = a[0].second;
	z = sn - sd;
	r = max(r, so+z-2*(c - a[1].first));

	for (int i = 2; i < n; i++)
	{
		sd += a[i-1].first-a[i-2].first;
		sn += a[i-1].second;
		so -= a[i-1].second;
		z = max(z, sn-sd);
		r = max(r, so+z-2*(c - a[i].first));
	}
	
	for (int i = 0; i < n; i++)
		a[i].first = c - a[i].first;
		
	reverse(a.begin(), a.end());
	
	so = 0;
	
	for (int i = 1; i < n; i++)
		so += a[i].second;
	
	sd = a[0].first;
	sn = a[0].second;
	z = sn - sd;
	r = max(r, so+z-2*(c - a[1].first));

	for (int i = 2; i < n; i++)
	{
		sd += a[i-1].first-a[i-2].first;
		sn += a[i-1].second;
		so -= a[i-1].second;
		z = max(z, sn-sd);
		r = max(r, so+z-2*(c - a[i].first));
	}
	
	cout << r;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<string> s(N);
  for(int i=0;i<N;i++){
    cin >> s.at(i);
  }
  int M;
  cin >> M;
  vector<string> t(M);
  for(int i=0;i<M;i++){
    cin >> t.at(i);
  }

  int count=0,ans=0;
  for(int i=0;i<N;i++){
    count=0;
    for(int j=i;j<N;j++){
      if(s.at(i)==s.at(j))  count++;
    }
    for(int k=0;k<M;k++){
      if(s.at(i)==t.at(k))  count--;  
    }
    if(ans<count) ans=count;
  }

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

Measured memory_bytes: 256
#include <iostream> 
#include <cstdio> 
#include <cstdlib> 
#include <cstring> 
#include <cmath> 
#include <algorithm> 
using namespace std; 
const int Mod = 998244353; 
int fpow(int x, int y) {
	int res = 1; 
	while (y) {
		if (y & 1) res = 1ll * res * x % Mod; 
		x = 1ll * x * x % Mod; 
		y >>= 1; 
	} 
	return res; 
} 
const int MAX_N = 1e6 + 5; 
int N = 1e6, M, fac[MAX_N], ifc[MAX_N]; 
int C(int n, int m) {
	if (n < m || n < 0 || m < 0) return 0; 
	else return 1ll * fac[n] * ifc[m] % Mod * ifc[n - m] % Mod; 
} 
int main () { 
	for (int i = fac[0] = 1; i <= N; i++) fac[i] = 1ll * fac[i - 1] * i % Mod; 
	ifc[N] = fpow(fac[N], Mod - 2); 
	for (int i = N - 1; ~i; i--) ifc[i] = 1ll * ifc[i + 1] * (i + 1) % Mod; 
	cin >> N >> M; 
	if (N > M) swap(N, M); 
	int ans = 0; 
	for (int i = 1; i <= N; i++) ans = (ans + 1ll * C(i << 1, i) * C(N - i + M - i, N - i)) % Mod; 
	ans = 1ll * ans * fpow(2 * C(N + M, M) % Mod, Mod - 2) % Mod; 
	printf("%d\n", (ans + M) % Mod); 
    return 0; 
} 

Measured memory_bytes: 8064
import java.util.Scanner;

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

	int x = scan.nextInt();

	if(x < 1200){
	    System.out.println("ABC");
	}else{
	    System.out.println("ARC");
	}
    }
}


Measured memory_bytes: 21584
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int N;
    cin>>N;
    vi X(N, 0), A(N);
    REP(i, 0, N) cin >> A[i];
    long count = 0;
    REP(i, 0, N){
        if(A[i] > i || (i>=1 && A[i] - A[i-1] >= 2)){
            cout << -1 << endl;
            return 0;
        }else{
            if(i>=1 && A[i] - A[i-1] == 1) count++;
            else count += A[i];
        }
    }
    cout << count << endl;
}

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

using namespace std;
#define int long long
int f(int a,int b){
	int s=1;
	while(b){
		if(b%2) s*=a;
		a*=a;
		b/=2;
	}
	return s;
}
signed main(){
	
	int n,m;
	cin>>n>>m;
	for(int i=0;i<100;i++){
		int s=f(2,i)*n;
		if(s==m){
			cout<<i+1;return 0;
		}
		if(s>m){
			cout<<i;return 0;
		}
	}
	return 0;
} 

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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

//#define _USE_MATH_DEFINES
//#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>
#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

//const i64 mod = 1000000007ll;
const i64 smod = 11; //  998244353ll;
//const i64 inf = 1000000007; // 10000000000000007ll;

const double eps = 1e-8;

const i64 MAXN = 4 * 1'000'000 + 6;

i64 T;

i64 n, k, c;
string s;

i64 lp[MAXN];
i64 rp[MAXN];

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n >> k >> c;
    cin >> s;
    s = " " + s;

    set<i64> pq;
    set<i64> nq;

    for (i64 i = 1; i <= n; i++) {
        if (s[i] != 'x') {
            pq.insert(i);
            nq.insert(-i);
        }
    }

    for (auto i : pq) {
        lp[i] = 1;
        auto nit = nq.upper_bound(-i + c);
        if (nit != nq.end()) {
            lp[i] += lp[-*nit];
        }

    }

    for (auto i : nq) {
        rp[-i] = 1;
        auto pit = pq.upper_bound(-i + c);
        if (pit != pq.end()) {
            rp[-i] += rp[*pit];
        }

    }

    bool f = false;

    set<i64> z;
    for (auto i : pq) {
        if (lp[i] + rp[i] > k + 1) {
            f = true;
            break;
        }
        if (lp[i] + rp[i] == k + 1) {
            z.insert(i);
        }
    }

    if (f) {
        return 0;
    }

    set<i64> r = z;

    {
        i64 j = 1;

        for (auto t : z) {
            i64 imin = max(j, t - c);
            i64 imax = min(n, t + c);
            for (i64 i = imin; i <= imax; i++) {
                if (i == t) {
                    continue;
                }
                if (s[i] == 'o') {
                    r.erase(i);
                }
            }
            j = max(j, t + c + 1);
        }
    }

    {
        i64 j = n;

        for (auto it = z.rbegin(); it != z.rend(); it++) {
            i64 t = *it;

            i64 imin = max(0ll, t - c);
            i64 imax = min(j, t + c);
            for (i64 i = imin; i <= imax; i++) {
                if (i == t) {
                    continue;
                }
                if (s[i] == 'o') {
                    r.erase(i);
                }
            }
            j = min(j, t - c - 1);
        }

    }



    stringstream ss;
    for (auto t : r) {
        ss << t << endl;
    }
    cout << ss.str();

    return 0;
}

Measured memory_bytes: 47952
N = int(input())
S = list(input())

n = [1]*26
dict = {'a':0, 'b':1, 'c':2, 'd':3, 'e':4, 'f':5, 'g':6, 'h':7,
        'i':8, 'j':9, 'k':10, 'l':11, 'm':12, 'n':13, 'o':14,
        'p':15, 'q':16, 'r':17, 's':18, 't':19, 'u':20, 'v':21,
        'w':22, 'x':23, 'y':24, 'z':25}
for i in range(N):
	n[dict[S[i]]] += 1
ans = 1
# print(n)
for i in range(len(n)):
	ans *= n[i]
# print(ans)
mod = 10**9+7
print((ans-1)%mod)


Measured memory_bytes: 3956
#include <iostream>
using namespace std;
int main()
{
    int H1,M1,H2,M2,K,x;
    cin >> H1 >> M1 >> H2 >>M2 >> K;
    x=(H2*60+M2)-(H1*60+M1)-K;
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 3564
/*
	ARIJIT SUR 
	@duke_knight
	@surcode
    @comeback
	IIT ISM 
 */
#include<bits/stdc++.h>
#define SIZE 100008
#define mod (ll)(1e9+7)
#define INF 0x3f3f3f3f
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define abs(a) (a>0?a:-a)
#define all(a) a.begin(),a.end()
#define maxelem(a) *max_element(all(a))
#define minelem(a) *min_element(all(a))
#define pb push_back
#define pi pair<int,int>
#define sort(a) sort(all(a))
#define reverse(a) reverse(all(a))
#define input(a) {for(int i1=0;i1<a.size();i1++) cin>>a[i1];}
#define display(a) {for(int i1=0;i1<a.size();i1++) cout<<a[i1]<<" "; cout<<endl;}
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long ll;
void solve(){
    double d,t,s;
    cin>>d>>t>>s;
    double t1 = d/s;
    if(t1<=t) printf("Yes\n");
    else printf("No\n");
}
int main()
{
    IOS
    int t=1;
    //cin>>t;
    while(t--){
    	solve();
    }
    return 0;
}

Measured memory_bytes: 3740
#include <stdio.h>

int main(void) {

  long n,m;
  scanf("%ld", &n);
  m = n*(n-1)/2;
  m -= n/2;
  printf("%ld\n", m);
  for (long i = 1; i <= n; i++) {
    for (long j = i+1; j <= n; j++) {
      if (n%2 != 0) {
        if (i+j != n) {
          printf("%ld %ld\n", i, j);
        }
      } else {
        if (i+j != n+1) {
          printf("%ld %ld\n", i, j);
        }
      }
    }
  }

  return 0;
}

Measured memory_bytes: 1696
class Team
  include Comparable
  attr_reader :id
  def initialize(name, win, lose, drow, i)
    @name = name
    @win = win.to_i
    @drow = drow.to_i
    @id = i
  end
  def to_i
    return 3 * @win + @drow
  end
  def <=>(other)
    if (other.to_i == to_i)
      return @id <=> other.id
    else
      return other.to_i <=> to_i
    end
  end
  def to_s
    return "#{@name},#{to_i}"
  end
end
i = gets.to_i
while i != 0
  arr = Array.new(i){|id|Team.new(*gets.split(" "), id)}
  puts arr.sort.map(&:to_s).join("\n")
  i = gets.to_i
  puts "\n" if (i != 0)
end

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

using namespace std;

int main(void){

	
	unsigned int N;
	scanf("%d", &N);
	//printf("N:%d\n", N);
	//unsigned int A[N+1], order[N+1];//A[0], order[0] は使わない
	unsigned int A[N], order[N];

	for(int i=0; i<N; i++){ 
		scanf("%d", &A[i]); //A[i]:ID=i+1の学生はA[i] 番目に登校した。
		order[A[i]-1] = i+1; 
	}

	for(int i=0; i<N; i++){
		printf("%d ", order[i]);
	
	}

	return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define fr(dt,i,a,b) for(dt i=a;i<b;i++)
#define f0(a,b) for(int i=a;i<b;i++)
#define fn(b,a) for(int i=b;i>a;i--)
#define dbg(x); cout<<"\n"<<#x<<": "<<x;
#define ret return
#define pb push_back
#define pf push_front
#define fastIO(); ios_base::sync_with_stdio(false); cin.tie(NULL);
#define UL9 1000000007
#define UL5 100007
#define INF 1e9+7
#define PI 3.1415926
#define SQ(a) (a)*(a)
#define fst first
#define scd second
typedef vector<long long int> vlli;
typedef vector<int> vi;
typedef long long int lli;  //  e-18 to e18
int main(){
    fastIO();
    int n;
    string s;
    set<string> b;
    cin>>n;
    while(n--){
        cin>>s;
        b.insert(s);
    }
    cout<<b.size()<<"\n";
    ret 0; 
}                                                             

Measured memory_bytes: 19212
/*author:revolIA*/
/*明日を変えるなら今日変えなきゃ*/
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+7;
int vis[100];
int main(){
    for(int i=1;i<=9;i++)for(int j=1;j<=9;j++)vis[i*j] = 1;
    int n;
    scanf("%d",&n);
    puts(vis[n]?"Yes":"No");
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
int main() {
  int num1,num2,num3,tmp;
  int A[3];
  scanf("%d %d %d",&num1,&num2,&num3);
  if(num1 <= num2) {
    A[0] = num1;
    A[1] = num2;
  } else {
    A[0] = num2;
    A[1] = num1;
  }
  if(A[1] <= num3) A[2] = num3;
  else {
    A[2] = A[1];
    A[1] = num3;
  }
  if(A[0] > A[1]) {
    tmp = A[1];
    A[1] = A[0];
    A[0] = tmp;
  }
  printf("%d %d %d\n",A[0],A[1],A[2]);
  return 0;
}



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

int main() {
  int a,b,x;
  cin >> x >> a >> b;
  if(b-a <= 0) cout << "delicious" << endl;
  else if(b-a <= x) cout << "safe" << endl;
  else cout << "dangerous" << endl;
    
}

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

int main(){
    string s,t; cin>>s>>t;
    
    string ans="No";

    s+=s;

    for(int i=0;i<s.length();i++){
        if(s[i]==t[0]){
            bool flag=true;
            for(int j=0;j<t.length();j++){
                if(s[i+j]!=t[j]){
                    flag=false;
                    break;
                }
            }

            if(flag){
                ans="Yes";
                break;
            }
        }
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll N;
    cin >> N;
    rep(i, N){
        ll a;
        cin >> a;
        if(a % 2 == 0){
            if(a % 3 != 0 && a % 5 != 0){
                cout << "DENIED";
                return 0;
            }
        }
    }
    cout << "APPROVED";
}

Measured memory_bytes: 3620
#include<stdio.h>

int main(void)
{
	int a,b=0;
	while(1)
	{
		scanf("%d",&a);
		if(a <= -1){break;}
		b = 4280 - 1150;
		if(a > 30)
		{
			a = a - 30;
			b = b - a * 160;
			a = 30;
		}
		if(a > 20)
		{
			a = a - 20;
			b = b - a * 140;
			a = 20;
		}
		if(a > 10)
		{
			a = a - 10;
			b = b - a * 125;
		}
		printf("%d\n",b);
	}
	return 0;
}

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

using namespace std;

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

typedef long long ll;

constexpr ll INF = 0x3fffffffffffffff;
constexpr int inf = 0x1fffffff;
constexpr double inf_l = 1e18;
constexpr ll MOD = 1000000007LL;
constexpr int mod = 1000000007;

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

	int N; cin >> N;
	vector<int> a(N, 0);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		ans += (i == (a[a[i] - 1] - 1));
	}
	cout << ans / 2 << endl;
	return 0;
}

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

int N;
int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> N;
    for (int i = 0, x; i < N; i++) {
        cin>>x;
        if(x%2==0){
            if(x%3 ==0 || x%5==0) continue;
            cout << "DENIED\n";
            return 0;
        }
    }
    cout <<"APPROVED\n";
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(
            new InputStreamReader(System.in));
        StringBuilder str = new StringBuilder();
        while(true){
        String line = br.readLine();
        int index = line.indexOf(" ");
        int x = Integer.parseInt(line.substring(0,index));
        int y = Integer.parseInt(line.substring(index+1,line.length()));
        if(x == 0&& y==0) break;
        str.append(x<y ? x+" "+y : y+" "+x).append("\n");
        }
        System.out.print(str);
    }
}

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

using namespace std;

int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    int sum=0;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        sum+=a[i];
    }
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        cnt+=(a[i]*4*m>=sum);
    }
    if(cnt>=m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
// eddy1021
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long ll;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<LD,LD> Pt;
typedef tuple<int,int,int> tiii;
typedef tuple<LL,LL,LL> tlll;
#define mod9 1000000009ll
#define mod7 1000000007ll
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define FI first
#define SE second
#define X FI
#define Y SE
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline ll getint(){
  ll _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline ll add( ll _x , ll _y , ll _mod = mod7 ){
  ll _ = _x + _y;
  if( _ >= _mod ) _ -= _mod;
  return _;
}
inline ll sub( ll _x , ll _y , ll _mod = mod7 ){
  ll _ = _x - _y;
  if( _ < 0 ) _ += _mod;
  return _;
}
inline ll mul( ll _x , ll _y , ll _mod = mod7 ){
  ll _ = _x * _y;
  if( _ >= _mod ) _ %= _mod;
  return _;
}
ll mypow( ll _a , ll _x , ll _mod ){
  if( _x == 0 ) return 1ll;
  ll _tmp = mypow( _a , _x / 2 , _mod );
  _tmp = mul( _tmp , _tmp , _mod );
  if( _x & 1 ) _tmp = mul( _tmp , _a , _mod );
  return _tmp;
}
ll mymul( ll _a , ll _x , ll _mod ){
  if( _x == 0 ) return 0ll;
  ll _tmp = mymul( _a , _x / 2 , _mod );
  _tmp = add( _tmp , _tmp , _mod );
  if( _x & 1 ) _tmp = add( _tmp , _a , _mod );
  return _tmp;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
int __ = 1 , _cs;
/*********default*********/
#define N 2048
void build(){

}
LL n , x , a[ N ] , b[ N ];
void init(){
  n = getint();
  x = getint();
  for( int i = 0 ; i < n ; i ++ )
    a[ i ] = getint();
}
void solve(){
  LL ans = INF16;
  for( int i = 0 ; i < n ; i ++ )
    b[ i ] = a[ i ];
  for( int i = 0 ; i < n ; i ++ ){
    LL tans = 0;
    for( int j = 0 ; j < n ; j ++ ){
      b[ j ] = min( b[ j ] , a[ ( j - i + n ) % n ] );
      tans += b[ j ];
    }
    ans = min( ans , tans + x * i );
  }
  cout << ans << endl;
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,count=0,res=0;
  int h[100000];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&h[i]);
  }
  
  for(int i=0;i<n-1;i++){      
      if(h[i]>=h[i+1]){
        count++;
        if(count>res) res=count;
      }else{
        count=0;
      }
    
   
  }
  printf("%d",res);
  return 0;
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size(a) int(a.size())

const int mod = 1e9 + 7;
const ll inf = ll(1e15);
const double PI = acos(-1);

ll modexp(ll x,ll n,int md){
    if(n==0)return 1;
    if(n%2==0)return modexp((x*x)%md,n/2,md);
    return (x*modexp((x*x)%md,n/2,md))%md;
}


int main(){
    fastio;
    //clock_t tm = clock();
    ll x;
    cin>>x;
    ll ans=1000*(x/500);
    x%=500;
    ans=ans+5*(x/5);
    cout<<ans<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,d,n,c=0;
    long double s,p,q;
    cin>>n>>d;
    for(i=0;i<n;i++)
    {
        cin>>p>>q;
        s=sqrt((p*p)+(q*q));
        if(s<=d)
        {
            c++;
        }
    }
    cout<<c<<endl;

}


Measured memory_bytes: 3840
#include <iostream>
using namespace std;
int main(){int n,a,b,c,d,e,f,g,h,x,y,z,w;while(cin>>n,n){while(n--){cin>>a>>b>>c>>d>>e>>f>>g>>h;cout<<a*e-b*f-c*g-d*h<<" "<<a*f+b*e+c*h-d*g<<" "<<a*g-b*h+c*e+d*f<<" "<<a*h+b*g-c*f+d*e<<endl;}}}

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

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

  for (int i = 1; i <= 9; ++i) {
    for (int j = 1; j <= 9; ++j) {
      if (i * j == n) {
        cout << "Yes";
        return 0;
      }
    }
  }

  cout << "No";

  return 0;
}


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

int H, W;
string S[50];

int countBombs(int i, int j) {
	int cnt = 0;
	for (int m = max(0, i - 1); m < min(H, i + 2); m++) {
		for (int n = max(0, j - 1); n < min(W, j + 2); n++) {
			if (S[m][n] == '#') cnt++;
		}
	}
	return cnt;
}

int main(void) {
	scanf("%d %d", &H, &W);
	for (int i = 0; i < H; i++) {
		cin >> S[i];
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S[i][j] == '#') continue;
			S[i][j] = '0' + countBombs(i, j);
		}
		cout << S[i] << "\n";
	}
	return 0;
}


Measured memory_bytes: 3676
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#include <iterator>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

set <int> in[100005], out[100005];
int ans[100005];

void bfs(int root) {
    queue<int> q;
    q.push(root);

    while (q.size()) {
        int p = q.front();
        q.pop();
        set <int> :: iterator itr;
        for (itr = out[p].begin(); itr != out[p].end(); itr++) {
            if (in[*itr].size() == 1) {
                ans[*itr] = p+1;
                q.push(*itr);
            }
            in[*itr].erase(p);
        }
    }
}

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

    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n + m - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        in[b].insert(a);
        out[a].insert(b);
    }

    int root;
    for (int i = 0; i < n; i++) {
        if (in[i].size() == 0) {
            root = i;
            break;
        }
    }

    bfs(root);

    for (int i = 0; i < n; i++) {
        cout << ans[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 20064
import sys
import  math
import bisect
from statistics import *
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
k = ni()
ans = 1000000000000000
for i in range(1 << n):
    tmp = 1
    for j in range(n):
        if i>>j&1:
            tmp *= 2
        else:
            tmp += k
    ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 5148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long ul;
// for文短縮類
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
// iteratorのbeginとendをまとめて渡す
#define ALL(x) (x).begin(), (x).end()
//略
#define PB push_back  // vectorヘの挿入
#define MP make_pair  // pairのコンストラクタ
#define F first       // pairの一つ目の要素
#define S second      // pairの二つ目の要素
//出力
#define COUT(x) cout << (x) << endl
#define SCOUT(x) cout << (x) << " "
#define ENDL cout << endl
/************ Combination wtih MOD ************
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// preprocess for some tables
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
// combination
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
*******************************************************/
/********** UnionFind ***************
struct UnionFInd {
vector<ll> par;
UnionFInd(ll N) : par(N) {
for (ll i = 0; i < N; i++) {
par[i] = i;
}
}
ll root(ll x) {
if (par[x] == x) return x;
return par[x] = root(par[x]);
}
void unite(ll x, ll y) {
ll rx = root(x);
ll ry = root(y);
if (rx == ry) return;
par[rx] = par[ry];
}
bool same(ll x, ll y) {
ll rx = root(x);
ll ry = root(y);
return rx == ry;
}
};
*************************************/
/***********************************
ll gcd(ll a, ll b) {
  if (a < b) {
    swap(a, b);
  }

  ll r = a % b;
  while (r > 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
***********************************/
const int MAX = pow(10, 5) + 1;
int main(int argc, char *argv[])
{
    // input高速化。cinとcoutの結合解除。scanfとprintfは使えない。
    cin.tie(0);
    ios_base::sync_with_stdio(0);

    ll q;
    cin >> q;
    vector<ll> l(q);
    vector<ll> r(q);
    REP(i, q){
        ll li, ri;
        cin >> li >> ri;
        l[i] = li;
        r[i] = ri;
    }

    vector<bool> furui(MAX, true);
    for (int i = 2; i < MAX; i++)
    {
        if (furui[i])
        {
            ll tmp = i * 2;
            while (tmp < MAX)
            {
                furui[tmp] = false;
                tmp += i;
            }
        }
    }

    vector<ll> kouho;
    for (int i = 3; i < MAX; i += 2){
        if(furui[i] && furui[(i + 1)/2]){
            kouho.push_back(i);
        }
    }

  

    vector<ll> ans;
    REP(i, q){
        auto itl = lower_bound(ALL(kouho), l[i]);
        auto itr = upper_bound(ALL(kouho), r[i]);

        ans.push_back(itr - itl);
    }

    REP(i, q){
        cout << ans[i] << endl;
    }
}

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

#define rap(N) for(int i = 0; i < N; i++)

using namespace std;

int main(void){
  int N,K;
  int tmp;
  int ans = 0;
  vector<int > price;
  cin >> N >> K;

  rap(N){
    cin >> tmp;
    price.push_back(tmp);
  }
  sort(price.begin(), price.end());
  
  rap(K){
    ans += price[i];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3188
#include <stdio.h>

typedef int keytype;

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int main(){
    int n, k;
    int p[1500];

    scanf("%d %d", &n, &k);
    for(int i = 1; i <= n; ++i){
        scanf("%d", &p[i]);
    }

    quicksort(p, 1, n);
    int sum = 0;
    for(int i = 1; i <= k; ++i){
        sum += p[i];
    }

    printf("%d\n", sum);

    return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define lld long long
#define pb push_back
#define mk make_pair
#define MAX 1e9+7
#define lim 1e5
using namespace std;


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

	std::vector<int> v(n+1);
	std::vector<int> dp(n+1);

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

	for(int i=2;i<=n;i++)
	{
		
		if(i-2>0)
			dp[i] = min( dp[i-1]+abs(v[i]-v[i-1]) , dp[i-2]+abs(v[i]-v[i-2]));

		else
			dp[i]= dp[i-1]+abs(v[i]-v[i-1]);


	}

	cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define LL long long 
#define LD long double
LL t1,t2,a1,a2,b1,b2,ans;
int main()
{
	cin>>t1>>t2;
	cin>>a1>>a2;
	cin>>b1>>b2;
	b1-=a1;b2-=a2;
	ans=0;
	LL sum=b1*t1+b2*t2;
	if(sum==0)puts("infinity");
	else 
	{
		if(b1<0&&b2<0)puts("0");
		else if(b1>0&&b2>0)puts("0");
		else if(sum>0)
		{
			if(b1<0)ans+=-b1*t1/sum*2-(b1*t1%sum==0);
			//if(b2<0)ans+=-b2*t2/sum*2;
			if(b1<0)ans++;
			cout<<ans<<endl;
		}
		else 
		{
			if(b1>0)ans+=-b1*t1/sum*2-(b1*t1%sum==0);
			//if(b2>0)ans+=-b2*t2/sum*2;
			if(b1>0)ans++;
			cout<<ans<<endl;
		}
			
	}
	return 0;
}

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

int main() {
    int N, K; cin >> N >> K;
    vector<int> V(N);
    rep(i, N) cin >> V[i];
    int ans = 0;
    for (int l = 0; l <= min(N, K); l++) {
        for (int r = 0; l+r <= min(N,K); r++) {
            if (l+r > min(N, K)) break;
            vector<int> tmp;
            rep(i, l) tmp.push_back(V[i]);
            rep(i, r) tmp.push_back(V[N-1-i]);
            sort(ALL(tmp));
            reverse(ALL(tmp));
            int cnt = 0;
            rep(i, tmp.size()) {
                if (K-l-r >= tmp.size()-i && tmp[i] < 0) break;
                else cnt += tmp[i];
            }
            chmax(ans, cnt);
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 3632
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
ll f(ll n){
    vector<int>id(n);
    iota(id.begin(),id.end(),1);
    ll ans = 0;
    do{
        ll temp = 0;
        for(int i = 0; i < n; i++){
            temp += (i + 1) % id[i];
        }
        ans = max(ans, temp);
    }while(next_permutation(id.begin(),id.end()));
    return ans;
}
int main(){
    for(int i = 1; i <= 10; i++){
//        show(i,f(i));
    }
    ll n;
    cin >> n;
    cout << n * (n - 1) /2 << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

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

		int[] A = new int[N];
		for(int i=0; i<N; i++)
			A[i] = sc.nextInt();

		for(int i=0; i<N; i++){ 
			String id = "node "+(i+1)+": ";
			String k = "key = "+A[i]+", ";
			String p = ( (i!=0)? "parent key = "+A[(i+1)/2-1]+", " : "" );
			String lk = ( 2*(i+1)<=N?  "left key = "+A[2*(i+1)-1]+", " : "");
			String rk = ( 2*(i+1)+1<=N? "right key = "+A[2*(i+1)]+", " : "");
			
			System.out.print(id + k + p + lk + rk + "\n");
		}

	}
}

	

Measured memory_bytes: 27580
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int N, M;
long* X;
long* Y;
long* Z;
long LONG_MINI = -2147483648;

long saiki(int left, int start, long x, long y, long z){
    if(left == 0){
        return abs(x) + abs(y) + abs(z);
    }
    else if(N - start == left){
        for(int i = start; i < N; i ++){
            x += X[i];
            y += Y[i];
            z += Z[i];
        }
        return abs(x) + abs(y) + abs(z);
    }
    else{
        // eat
        long eat = saiki(left - 1, start + 1, x + X[start], y + Y[start], z + Z[start]);
        // not eat
        long notEat = saiki(left, start + 1, x, y, z);
        if(eat > notEat){
            return eat;
        }
        else{
            return notEat;
        }
    }
}

int main(){

    cin >> N >> M;
    X = new long[N];
    Y = new long[N];
    Z = new long[N];
    for(int i = 0; i < N; i ++){
        cin >> X[i] >> Y[i] >> Z[i];
    }

    long max = LONG_MINI;


    for(long x_fugou = -1; x_fugou < 2; x_fugou += 2){
        for(long y_fugou = -1; y_fugou < 2; y_fugou += 2){
            for(long z_fugou = -1; z_fugou < 2; z_fugou += 2){
                long result = 0;
                long* scores = new long[N];
                for(long i = 0; i < N; i ++){
                    scores[i] = X[i] * x_fugou + Y[i] * y_fugou + Z[i] * z_fugou;
                }
                sort(scores, scores+N);
                long finalScore = 0;
                for(long i = 0; i < M; i ++){
                    finalScore += scores[N - i - 1];
                }
                if(max < finalScore){
                    max = finalScore;
                }
            }
        }
    }

    //long result = saiki(M, 0, 0, 0, 0);

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

Measured memory_bytes: 384
import java.util.*;
public class Main {

	public static void main(String[] args) {
		long INF = Long.MAX_VALUE;
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long xmax = -INF, xmin = INF, ymax = -INF, ymin = INF;
		for(int i = 0; i < N; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			xmax = Math.max(xmax, x+y);
			xmin = Math.min(xmin, x+y);
			ymax = Math.max(ymax, x-y);
			ymin = Math.min(ymin, x-y);
		}
		System.out.println(Math.max(xmax - xmin, ymax - ymin));
	}

}


Measured memory_bytes: 59220
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

ll dp[2005][2005];

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

    int n, m;
    cin >> n >> m;

    int s[n], t[m];
    for (int i = 0; i < n; i++) cin >> s[i];
    for (int i = 0; i < m; i++) cin >> t[i];

    for (int i = 0; i <= n; i++) dp[i][0] = 1;
    for (int i = 0; i <= m; i++) dp[0][i] = 1;

    for (int i = 0; i < n; i++) {
        ll tmp = 0;
        for (int j = 0; j < m; j++) {
            if (s[i] == t[j]) {
                tmp = (tmp + dp[i][j]) % MOD;
            }

            dp[i+1][j+1] = (dp[i][j+1] + tmp) % MOD;
        }
    }

    cout << dp[n][m] << "\n";
    return 0;
}

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

#define LL long long
#define Dl double
#define Pb push_back
#define Po pop_back
#define Mp make_pair
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

typedef vector<LL> Vl;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef vector<Pll> Vpl;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
#define X first
#define Y second
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

LL ch[30];

int main()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

    string s;
    cin >> s;

    LL L = s.size();
    for(LL i = 0; i < L; i++)
        ch[s[i] - 'a']++;

    for(LL i = 0; i < 26; i++)
        if(!ch[i])
            return cout << (char)(i + 'a') << '\n', 0;

    cout << "None\n", 0;
    return 0;
}



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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n;
    cin >> n;
    vector<i64> a(n);
    for (auto& e : a) cin >> e;
    if (find(all(a), 0) != end(a)) {
        cout << 0 << endl;
        return;
    }

    i64 ans = 1;
    for (auto& e : a) {
        if (ans > (i64) 1e18 / e) {
            cout << -1 << endl;
            return;
        }
        ans *= e;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3992
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))

Cn, ans = N * (N-1) // 2, 0

for i in range(60):
    count = int(np.sum(A % 2))
    A //= 2
    if count == 0:
        continue
    ans += (Cn - (count*(count-1)//2 + (N-count)*(N-count-1)//2)) * (2**i)
print(ans % (10**9 + 7)) 

Measured memory_bytes: 48824
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int xcomp(vector<LL>& a, vector<LL>& b) {
	return a[0] < b[0];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;



int main() {
	vector<LL> v(3, 0);
	cin >> v[0] >> v[1] >> v[2];
	if (v[0] == v[1] && v[1] == v[2]) {
		if (v[0] % 2 == 0) {
			cout << -1 << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
	else {
		LL sum = 0;
		while (true) {
			if (v[0] % 2 == 1 || v[1] % 2 == 1 || v[2] % 2 == 1) {
				break;
			}
			LL A = v[1] / 2 + v[2] / 2;
			LL B = v[0] / 2 + v[2] / 2;
			LL C = v[1] / 2 + v[0] / 2;
			v[0] = A;
			v[1] = B;
			v[2] = C;
			sum++;
		}
		cout << sum << endl;
	}

}

Measured memory_bytes: 256
#include <stdio.h>

int main (int argc, char* argv[])
{
  int n, array[3], temp, i, j, k;
  scanf("%d", &n);

  for (i=0; i<n; i++) {
    scanf("%d %d %d", &array[0], &array[1], &array[2]);
    for (j=2; 0<j; j--) {
      for (k=0; k<j; k++) {
	if (array[k+1] < array[k]) {
	  temp = array[k];
	  array[k] = array[k+1];
	  array[k+1] = temp;
	}
      }
    }
    if (array[0]*array[0] + array[1]*array[1] == array[2]*array[2]) {
      puts("YES");
    } else {
      puts("NO");
    }
  }
  return 0;
}

Measured memory_bytes: 0