akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int n,m,cnt=2,cntl=0,aa[1100000],aako=1,jyougen;
int e,f=0,ab[1100],counte=0;
queue<int> insu,que;
void sosu(){
	int c=que.size();
    rep(i,c){
        que.pop();
    }
	aa[0]=2;
	que.push(2);
    while(1){
        cnt++;
        rep(i,aako){
            if(aa[i]>sqrt(cnt)){
                aa[aako]=cnt;
                aako++;
				que.push(cnt);
                break;
            }
            if(cnt%aa[i]==0){
                break;
            }
        }
        cnt++;
        if(cnt>jyougen){
            break;
        }
    }
}
void insubunkai(int a){
    cntl=0;
    sosu();
    int b=a;
    while(1){
        if(b==1||sqrt(a)<que.front()||que.size()==0){
            break;
        }
        if(b%que.front()!=0){
            que.pop();
        }else{
            insu.push(que.front());
            b/=que.front();
            cntl++;
        }
    }
    if(cntl==0){
        insu.push(a);
    }else{
        if(b!=1){
            insu.push(b);
        }
    }
}
signed main(){
    cin>>n;
    if(n==1){
        cout<<0;
        return 0;
    }
    //nは10^14*2で1sくらい
    jyougen=sqrt(n)+100;
    insubunkai(n);
    m=insu.size();
    if(m==1){
        cout<<1;
        return 0;
    }
    e=insu.front();
    ab[0]++;
    insu.pop();
    rep(i,m-1){
        if(insu.front()==e){
            ab[f]++;
        }else{
            e=insu.front();
            f++;
            ab[f]++;
        }
        insu.pop();
    }
    rep(i,f+1){
        if(ab[i]<3){
            counte++;
        }elif(ab[i]<6){
            counte+=2;
        }elif(ab[i]<10){
            counte+=3;
        }elif(ab[i]<15){
            counte+=4;
        }elif(ab[i]<21){
            counte+=5;
        }elif(ab[i]<28){
            counte+=6;
        }elif(ab[i]<36){
            counte+=7;
        }else{
            counte+=8;
        }
    }
    cout<<counte;
}

Measured memory_bytes: 4996
#include <iostream>

using namespace std;
template <typename T = int>
T in() {
    T temp;
    cin >> temp;
    return temp;
}

class XorWorld {
    uint64_t const A;
    uint64_t const B;
    uint64_t const diff;

    static uint64_t constexpr period = 4; // = 100b
    static uint64_t constexpr periodicMask = period - 1; // = 011b

public : 
    XorWorld(uint64_t A_p, uint64_t B_p) : A(min(A_p, B_p)), B(max(A_p,B_p)), diff(B - A + 1) {}

    uint64_t GetXor () const {
        uint64_t ret;
        for (uint64_t i = A; i <=B; i++) {
            if (i == A) ret = i;
            else ret ^= i;
        }
        return ret;
    }

    uint64_t Calculate() const {

        // When the size is too small, no problem even calculate greedly
        if (diff < (period + 1)) return GetXor();
       
        // Otherwise retry calculating after getting new A
        // If the A is even number.
        // Shorten A to (B - 1), (B - 2), (B - 3).            
        //return subWorld.Calculate();
        if ((A & 1) == 0) {
            uint64_t newDiff = (diff & periodicMask);
            if (newDiff == 0) newDiff = 4;
            else return XorWorld(B - newDiff + 1, B).Calculate();
        }

        // Otherwise A is odd number and size is very large.
        // Separate numbers to A and then after((A + 1)(must be even number) to B)
        return A ^ XorWorld(A + 1, B).Calculate();
    }
};
int main() {
    uint64_t A(in<uint64_t>()), B(in<uint64_t>());
    XorWorld const world(A, B);
    cout << world.Calculate() << endl;
    return 0;
}




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

#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) for(int i=int(n-1);i>=0;i--)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define D(a) cerr << #a << " = " << a << endl
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
typedef pair<int,int> pii;
typedef long long int ll;
typedef vector<int> vi;
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first

const double EPS = 1e-9;
#define eq(a,b) (abs((a) - (b)) < EPS) // ==
#define le(a,b) ((a) < (b) - EPS)      // <
#define leq(a,b) ((a) < (b) + EPS)     // <=
#define gr(a,b) ((a) > (b) + EPS)      // >
#define geq(a,b) ((a) > (b) - EPS)     // >=

struct pto {
	double x, y;
	pto(double _x=0, double _y=0) : x(_x),y(_y) {}
	pto operator+(pto a) { return pto(x + a.x, y + a.y); }
	pto operator-(pto a) { return pto(x - a.x, y - a.y); }
	pto operator*(double a) { return pto(x*a, y*a); }
	pto operator/(double a) { return pto(x/a, y/a); }
	double norm() { return sqrt(x*x + y*y); }
};
double dist(pto a, pto b) { return (b-a).norm(); }
pto CCW90(pto p) { return pto(-p.y, p.x); }

struct circle { pto p; double r; };

bool inside(circle &c, pto &p) { return leq(dist(c.p, p), c.r); }

vector<pto> interCC(circle &a, circle &b) {
    vector<pto> r;
    double d = dist(a.p, b.p);
    if (gr(d, a.r + b.r) || le(d + min(a.r, b.r), max(a.r, b.r))) return r;
    double x = (d*d + a.r*a.r - b.r*b.r) / (2*d);
    double y = sqrt(a.r*a.r - x*x);
    pto v = (b.p - a.p) / d;
    r.pb(a.p + v*x + CCW90(v)*y);
    if (gr(y, 0)) r.pb(a.p + v*x - CCW90(v)*y);
    return r;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    
    int n,k; cin >> n >> k;
    vector<pto> a(n); 
    int b[n];
    forn(i, n) cin >> a[i].x >> a[i].y >> b[i];

    auto f = [&](double t) { // O(n^3)
        vector<circle> cir(n);
        forn(i, n) cir[i] = {a[i], t/b[i]};

        vector<pto> can(all(a));
        forn(i, n) forsn(j, i+1, n)
            for (pto &p : interCC(cir[i], cir[j])) 
                can.pb(p);

        int m = 0;
        for (auto &p : can) {
            int q = 0;
            for (auto &c : cir)
                if (inside(c, p)) q++;
            m = max(m, q);
        }
        return m < k;
    };

    double l = 0, h = 3e5;
    while (!eq(l, h)) {
        double m = (l+h)/2;
        if (f(m)) l = m;
        else h = m;
    }
    cout << fixed << setprecision(6) << l << endl;
    return 0;
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
    int a,d,n;
    cin >> a >> d >> n;
    if(n==0) return 0;
    int x;
    int count=0;
    for(int i=0;1;i++){
      x=a+d*i;
      for(int j=2;j<=sqrt(x);j++){
        if(x%j==0){
          goto next;
        }
      }
      if(x>1) count++;
      if(count==n){
        cout << x << endl;
        break;
      }
      next:
      continue;
    }
  }
  return 0;
}



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

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

  vector<int> l(n);
  int sum = 0;
  int m = 0;

  for(int i = 0;i < n;i++){
    cin >> l[i];
    sum += l[i];
    m = max(m,l[i]);
  }
  
  if(sum-m > m){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
a = [0, 0, 0, 0]
for t in range(10):
    a[3] = input()
    for i in range(2, -1, -1):
        if (a[i] < a[i+1]):
            a[i], a[i+1] = a[i+1], a[i]

for i in range(0, 3):
    print a[i]

Measured memory_bytes: 6428
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

int x;

int main()
{
  ll ans;

  cin >> x;

  for (ans=1; x*ans % 360 != 0; ) ans++;

  // x*K == 360*n

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


Measured memory_bytes: 3632
package main

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

// N, M, Q
var (
	N          int
	M          int
	Q          int
	a, b, c, d []int
	result     int
)

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func dfs(A []int) {
	if len(A) == N+1 {
		t := 0
		for i := 0; i < Q; i++ {
			if A[b[i]]-A[a[i]] == c[i] {
				t += d[i]
			}
		}
		result = max(result, t)
		return
	}

	A = append(A, A[len(A)-1])
	for A[len(A)-1] <= M {
		dfs(A)
		A[len(A)-1]++
	}
}

func main() {
	defer flush()

	N = readInt()
	M = readInt()
	Q = readInt()
	a = make([]int, Q)
	b = make([]int, Q)
	c = make([]int, Q)
	d = make([]int, Q)
	for i := 0; i < Q; i++ {
		a[i] = readInt()
		b[i] = readInt()
		c[i] = readInt()
		d[i] = readInt()
	}

	dfs([]int{1})
	println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

func readInts(n int) []int {
	result := make([]int, n)
	for i := 0; i < n; i++ {
		result[i] = readInt()
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdoutWriter, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}

func printIntln(v ...int) {
	b := make([]byte, 0, 4096)
	for i := 0; i < len(v)-1; i++ {
		b = append(b, strconv.Itoa(v[i])...)
		b = append(b, " "...)
	}
	b = append(b, strconv.Itoa(v[len(v)-1])...)
	println(string(b))
}


Measured memory_bytes: 3328
#include<iostream>
#include<cstring>
//#include<bits/stdc++.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#include<set>
#define  si(a)       scanf("%d",&a)
#define  sl(a)       scanf("%lld",&a)
#define  sii(a,b)    scanf("%d%d",&a,&b)
#define  sll(a,b)    scanf("%lld%lld",&a,&b)
#define  queues      priority_queue
#define mod 998244353
#define mem(a)  memset(a,0,sizeof(a));
#define def(a) ((a)&(-a))
#define fi  first
#define se  second
#define mp  make_pair
#define  pb push_back
typedef long long ll;
//priority_queue<int,vector<int >,greater<int > >q;
const ll INF=0x3f3f3f3f;
//const double E=exp(1);
//const double PI=acos(-1);
using namespace std;
int main()
{

   ll n,s[6];
   cin>>n;
   for(int i=1;i<=5;i++)
    cin>>s[i];
   sort(s+1,s+6);
   ll t=5;
   t+=n%s[1]?n/s[1]:n/s[1]-1;
   cout<<t<<endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ar array
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define precision cout<<fixed<<setprecision(10)
#define w(t) ll t;cin>>t;while(t--)
#define setbits(x) __builtin_popcountll(x)
const double pi=3.1415926535897932384626;
//const ll mod = 998244353;
const ll mod=1e9+7;
int main()
{
  IOS
  ll n;
  cin>>n;
  ll a[n];
  fo(i,n) cin>>a[i];
  ll c=0;
  fo(i,n){
    for(ll j=i+1;j<n;j++){
        if(a[i]!=a[j]){
            for(ll k=j+1;k<n;k++){
                if(a[k]!=a[i]&&a[k]!=a[j]){
                    if((a[i]+a[j])>a[k]&&((a[i]+a[k])>a[j])&&(a[j]+a[k]>a[i]))
                        c++;
                }
            }
        }
    }
  }
  cout<<c;
  return 0;
}

Measured memory_bytes: 3640
string = input()
d = int(input())

nums = [int(v) for v in string]
length = len(string) - 1
k = int(string)

M = 10**9 + 7
def mod(v):
    if v >= M:
        return v % M
    return v

dp = [[[None] * 2 for _ in range(d)] for _ in range(length + 2)]
def dfs(i=0, s=0, border=True):
    if dp[i][s][border] is not None:
        return dp[i][s][border]

    if i > length:
        r = int(not bool(s))
        dp[i][s][border] = r
        return r

    cnt = 0
    for n in range(max(9 * (not border), nums[i]) + 1):
        cnt = mod(cnt + dfs(i + 1, (s + n) % d, border and nums[i] == n))
    dp[i][s][border] = cnt
    return cnt
# print(mod(dfs() - 1))

for i in reversed(range(length + 2)):
    for s in reversed(range(d)):
        for border in [False, True]:
            if i > length:
                dp[i][s][border] = int(not bool(s))
                continue

            cnt = 0
            for n in range(max(9 * (not border), nums[i]) + 1):
                cnt = mod(cnt + dp[i + 1][(s + n) % d][border and nums[i] == n])
            dp[i][s][border] = cnt

print(mod(dp[0][0][1] - 1 + M))


Measured memory_bytes: 144392
import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        ans += bisect.bisect_left(L, L[i] + L[j]) - j - 1
print(ans)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n,k;
	cin >> n >> k;
	int x;
	set<int> s;
	vector<ll> a(n+1,0);
	for(int i = 0; i < n; i++) {
		cin >> x;
		s.emplace(x);
		a[x]++;
	}

	sort(ALL(a));
	a.erase(remove(ALL(a),0),a.end());//値が0のものをすべて削除
	ll ans = 0;
	if (s.size() > k){
		for(int i = 0; i < s.size() - k; i++) {
			ans += a[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11136
#include <stdio.h>

void trace(int A[],int N){
    int i;
    for(i = 0; i<N;i++){
        if(i) printf(" ");//学习!
        printf("%d",A[i]);
    }
    printf("\n");
}

void insertionSort(int A[],int N){
    int i,j,v;
    for (i=1;i<N;i++){
        v = A[i];
        j = i-1;
        while(j>=0&&A[j]>v){//找之前已排序部分的需要移动的元素。
                A[j+1] = A[j];
                j--;
        }
        A[j+1] = v;//插入排序的后移之后的赋值。

        trace(A,N);
    }
}

int main(){
    int N,i,j;
    int A[100];
    scanf("%d",&N);

    for(i=0; i<N;i++){
        scanf("%d",&A[i]);
    }
    trace(A,N);
    insertionSort(A,N);

    return 0;

}


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

#define INF (1LL << 60)

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

	long long n, m, i, j, k, best, t;
	long long v[8][3] = { -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1 };
	cin >> n >> m;	
	vector<vector<long long>> a(n, vector<long long>(3));

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

	best = 0;
	for (t = 0; t < 8; t++) {
		vector<vector<long long>> dp(n + 1, vector<long long>(m + 1, -INF));
		dp[0][0] = 0;
		for (i = 0; i < n; i++) {
			dp[i + 1] = dp[i];
			for (j = 0; j < m; j++) {
				dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + v[t][0] * a[i][0] + v[t][1] * a[i][1] + v[t][2] * a[i][2]);
			}
		}
		best = max(best, dp[n][m]);
	}

	cout << best << "\n";

	return 0;
}


Measured memory_bytes: 8216
N = int(input())
D, X = [int(x) for x in input().split()]

A = []
for i in range(N):
    A.append(int(input()))

sum = 0
for a in A:
    j = 0
    while j * a + 1 <= D:
        sum += 1
        j += 1
print(sum + X)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#define ll long long
#define fr(i,k,N) for(decltype(N+k) i=k; i<N;i++)
#define rep(i,N) for(decltype(N) i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return 約数unordered_set 1 <= x <= n
auto divv = [](auto n) {
  unordered_set<decltype(n)> v;
  for(decltype(n) i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.insert(i);
      if(i*i != n) v.insert(n/i);
    }
  }
  return v;
};

// check prime (and n>=2) or not
auto isPrime = [](auto n){
  if(n <= 1) return false;
  for(decltype(n) i = 2; i <= sqrt(n); ++i) {
      if(n % i == 0) {
          return false;
      }
  }
  return true;
};

int main() {
    ll a;
    cin>>a;
    pr(a*a);
}


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

using namespace std;

int main() {
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int ans = 0;
    while (a>=b) {
        b*=2;
        k--;
    }
    while (b>=c) {
        c*=2;
        k--;
    }
    cout << ((k>=0) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        int k = scan.nextInt();
        HashSet<String> a = new HashSet<String>();

        for (int i=1;i<=Math.min(k,s.length());i++){
            for (int j=0;j<s.length()+1-i;j++){
                a.add(s.substring(j,j+i));
            }
        }
        ArrayList<String> b = new ArrayList<String>(a);
        Collections.sort(b);
        System.out.println(b.get(k-1));
    }
    
}

Measured memory_bytes: 39272
#include<cstdio>
using namespace std;
#define MAX 100000
#define NIL -1

struct Node{int parent,left,right;};

Node T[MAX];
int n;

void preParse(int u){
  if(u==NIL) return;
  printf(" %d",u);
  preParse(T[u].left);
  preParse(T[u].right);
}

void inParse(int u){
  if(u==NIL) return;
  inParse(T[u].left);
  printf(" %d",u);
  inParse(T[u].right);
}

void postParse(int u){
  if(u==NIL) return;
  postParse(T[u].left);
  postParse(T[u].right);
  printf(" %d",u);
}

int main(){
  scanf("%d",&n);
  for(int i=0;i<n;i++) T[i].parent = NIL;

  int v,l,r;
  for(int i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].left = l;
    T[v].right = r;
    if(l != NIL) T[l].parent = v;
    if(r != NIL) T[r].parent = v;
  }

  int root;
  for(int i=0;i<n;i++) if(T[i].parent == NIL) root = i;

  printf("Preorder\n");
  preParse(root);
  printf("\n");

  printf("Inorder\n");
  inParse(root);
  printf("\n");

  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}



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

int a[1000];
int p[1000];

int main() {
	// your code goes here
	int i, j, n;
	cin>>n;
	int minv=n, maxv=0;
	string s="Possible", t="Impossible";
	for(i=0; i<n; ++i) {
		cin>>a[i];
		p[a[i]]++;
		minv=min(minv, a[i]);
		maxv=max(maxv, a[i]);
	}
	int cnt=0;
	bool flag=true;
	for(i=minv; i<=maxv; ++i)
		if(!p[i]) {
			flag=false;
			break;
		}
	if(!flag)	{
		cout<<t;
		return 0;
	}
	for(i=0; i<n; ++i) {
		if(a[i]==minv)	cnt++;
	}
	if(cnt==1) {
		if(maxv==2*minv)	cout<<s;
		else	cout<<t;
		return 0;
	}
	if(cnt==2) {
		if(maxv==2*minv-1)	cout<<s;
		else	cout<<t;
		return 0;
	}
	cout<<t;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N;
            string buf;
            int length;
            buf = Console.ReadLine();
            length = buf.Length;
            if (buf[length - 1] == '0'|| buf[length - 1] == '1'|| buf[length - 1] == '6'|| buf[length - 1] == '8')
            {
                Console.WriteLine("pon");
            }
            if (buf[length - 1] == '2' || buf[length - 1] == '4' || buf[length - 1] == '5' || buf[length - 1] == '7' || buf[length - 1] == '9')
            {
                Console.WriteLine("hon");
            }
            if(buf[length - 1] == '3')
            {
                Console.WriteLine("bon");
            }
        }
    }
}


Measured memory_bytes: 25800
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>
# define MOD 1000000000+7
# define INF 1e9
# define LINF 1e18
typedef long long ll;

using namespace std;
int gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
 
int a = 0, b = 0, c = 0,k = 0;
int x = 0;
vector<string> strs;
pair<pair<string, int>, int> p[100];

int main() {

	int n = 0;

	cin >> n;


	for (int i = 0; i < n; i++) {
		string a;
		int b, c;

		cin >> a >> b;

		p[i] = make_pair(make_pair(a, -b), i+1);

	}

	sort(p, p + n);

	for (int i = 0; i < n; i++) {
		cout << p[i].second << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <time.h>

#include <string>

const int MAX_N = 100000;
const int MAX_M = 100000;

//int p_in[MAX_N+1];
int A[MAX_M+1], B[MAX_M+1];
int N, M;

int par[MAX_N+1];
int child_num[MAX_N+1];

long long connect_num;
long long ret[MAX_M+1];

//bool tmp[MAX_N+1];

int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
}

void unite(int x, int y) {
    const int rx = root(x);
    const int ry = root(y);
    if (rx == ry) return;
    connect_num += child_num[rx] * child_num[ry];

    par[rx] = ry;
    child_num[ry] += child_num[rx];
    child_num[rx] = 0;
}

bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
}

int main(int argc, char **argv) {
    std::cin >> N >> M;
    for (int i = 1; i <= M; i++) {
        std::cin >> A[i] >> B[i];
    }
    const long long NC2 = (long long)N * (N-1) / 2;
    connect_num = 0;
    for (int i = 1; i <= N; i++) {
        par[i] = i;
        child_num[i] = 1;
    }
    
    for (int i = M; i >= 1; i--) {
        unite(A[i], B[i]);
        ret[i] = NC2 - connect_num;
    }

    for (int i = 1; i <= M - 1; i++) {
        std::cout << ret[i+1] << std::endl; 
    }
    std::cout << NC2 << std::endl;
    return 0;
}

Measured memory_bytes: 3712
#include <cstdio>
#include <algorithm>
#define ll long long
using namespace std;

const ll Mod = 1e9 + 7, N = 200010;
ll a[N], tot  = 0;

int main()
{
	int n;
	scanf("%d%d", &n, &a[1]);
	a[1] %= Mod;
	for (int i = 2; i <= n; i ++ )
	{
		scanf("%d", &a[i]);
		tot = (((a[i] * a[i - 1]) % Mod ) + tot) % Mod;
		a[i] = (a[i] + a[i - 1]) % Mod;
	}
	printf("%lld\n", tot);
	
	return 0;
}

Measured memory_bytes: 3284
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define debug(x) (cout << # x ": " << x << endl)
#define int long long int
#define repeat(n) for (int i = 0; i < n; ++i)
#define repeat2(n) for (int j = 0; j < n; ++j)
#define all(x) x.begin(), x.end()
#define llcast static_cast<long long int>

#define MAX_SIZE (10000001)

int dp[MAX_SIZE];

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

    for (int i = 1; i < MAX_SIZE; ++i) {
        for (int j = i; j < MAX_SIZE; j += i) {
            ++dp[j];
        }
    }

    int ans = 0;
    repeat(n) {
        ans += (i + 1) * dp[i + 1];
    }

    cout << ans;
    
    return 0;
}


Measured memory_bytes: 81276
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        double r;
        
        double b;
        double c;
        
        
        r = sc.nextDouble();
        
        
        b = r*r*3.141592653589;
        c = 2.0*3.141592653589*r;
        
        System.out.println(String.format("%.6f",b) + " " + String.format("%.6f",c));
        
    }
}



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

int main(){
	int x1,x2,x3,x4,x5;
 	cin >> x1 >> x2 >> x3 >> x4 >> x5;
 	if(x1==0)
      cout << 1 << endl;
  if(x2==0)
      cout << 2 << endl;
  if(x3==0)
      cout << 3 << endl;
  if(x4==0)
      cout << 4 << endl;
  if(x5==0)
      cout << 5 << endl;
  return 0;
}

Measured memory_bytes: 3676
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#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 REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

using Graph=vector<vector<ll>>;

int main(){
    ll N;
    cin>>N;
    vector<ll> c(N);
    vector<ll> ans(N);
    Graph G(N);
    REP(i,N-1){
        ll a,b;
        cin>>a>>b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    ll sum=0;
    REP(i,N){
        cin>>c[i];
        sum+=c[i];
    }
    sort(ALL(c),greater<ll>());
    sum-=c[0];

    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;
    
    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする
    ll cnt=0;
    ans[0]=c[0];
    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();
        
        
    
        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない
    
            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            cnt++;
            ans[nv]=c[cnt];
            que.push(nv);
        }
    }
    cout<<sum<<endl;
    REP(i,N){
        cout<<ans[i];
        if(i!=N-1) cout<<" ";
        else cout<<endl;
    }

}

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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define ci(a) cin>>a
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define cfs(a) cout<<fixed<<setprecision(a)
#define INF 1e16
#define mod 1e9+7
//vvll v(n,vll(m)) n行m列
//A.erase(A.begin()+i) 配列Aのi番目を消せる
//std::binary_search(v.bgn,v.en,a);
//abs(a,b)   pow(a,n)  to_string  stoll
//auto Iter=lower_bound(v.bgn,v.en,a);
//lower//upper  co(*Iter)co(Iter-v.bgn);

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void Comuse() {
    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;
    }
}
#define comuse Comuse()
ll combi(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;
}

int main() {
  ll a,b;
  cin>>a>>b;
  ll c=max(a+b,a-b);
  ll ans=max(c,a*b);
  co(ans);
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
	FastIO
	lld n, i;
	cin >> n;
	cout << ((n*(n-1))/2);
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>  
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <bitset>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
const double PI=acos(-1.0);

typedef long long Int;
typedef long long LL;
typedef unsigned long long UINT;
typedef vector <int> VI;
typedef pair <int, int> PII;
typedef pair <double, double> PDD;

const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 500000;
const int MAX1 = 2007;
const int MAX2 = 24000000;
const int LEN = 21;
const int BASE = 1000000000;

const int CNT = 100;

struct edge
{
  int u, v;
  Int w;
  edge(){}
  bool operator<(const edge& e) const
  {
    return w < e.w;
  }
};

const int MOD = 1000000007;

int n, m;
Int x;
int P[MAX];
int B[MAX];
vector<edge> E;

int find(int x)
{
  if (P[x] == x) return x;
  return P[x] = find(P[x]);
}

void unite(int x, int y)
{
  x = find(x);
  y = find(y);
  if (rand() % 2) P[x] = y;
  else P[y] = x;
}

int main()
{
  cin >> n >> m >> x;
  FOR (i,0,m)
  {
    edge e;
    cin >> e.u >> e.v >> e.w;
    -- e.u;
    -- e.v;
    E.PB(e);
  }

  sort(ALL(E));

  FOR (i,0,n) P[i] = i;
  FOR (i,0,m)
  {
    if (find(E[i].u) != find(E[i].v))
    {
      unite(E[i].u, E[i].v);
      B[i] = 1;
    }
  }

  Int res = 0;
  int c1 = 0, c2 = 0;
  FOR (i,1,m)
  {
    //if (B[i]) continue;

    FOR (j,0,n)
      P[j] = j;

    Int tot = E[i].w;
    unite(E[i].u, E[i].v);

    FOR (j,0,m)
    {
      if (find(E[j].u) != find(E[j].v))
      {
        unite(E[j].u, E[j].v);
        tot += E[j].w;
      }
    }

    if (tot == x) ++ c1;
    else if (tot > x) ++ c2;
  }

  res = 2;
  FOR (i,0,c2) res = res * 2 % MOD;

  Int p = 1;
  FOR (i,0,c1) p = p * 2 % MOD;
  p = (p-1+MOD) % MOD;

  res = res * p % MOD;

  cout << res << endl;

  
  return 0;
}


Measured memory_bytes: 384
package main

import (
	"fmt"
	"strconv"
)

func stringToInt(s string) int {
	i, _ := strconv.Atoi(s)
	return i
}

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, 0, 0)
	f := make([]int, 0, 0)
	for i := 0; i < n; i++ {
		tmp := 0
		fmt.Scan(&tmp)
		a = append(a, tmp)
	}
	f = append(f, a[0])
	for i := 1; i < n; i++ {
		f = append(f, f[i-1]+a[i])
	}

	f1 := make([]int, 0, 0)
	f2 := make([]int, 0, 0)
	for i := 0; i < n; i++ {
		f1 = append(f1, f[i])
		f2 = append(f2, f[i])
	}

	num := 0
	tmpNum := 0

	for i := 0; i < n; i++ {
		tmpNum = 0
		if i%2 == 1 {
			if f1[i] <= 0 {
				tmpNum = 1 - f1[i]
				f1[i] = f1[i] + tmpNum
			}
		} else {
			if f1[i] >= 0 {
				tmpNum = f1[i] + 1
				f1[i] = f1[i] - tmpNum
			}
		}
		if i < n-1 {
			f1[i+1] = f1[i] + a[i+1]
		}

		num += tmpNum
	}
	num1 := num

	num = 0
	tmpNum = 0

	for i := 0; i < n; i++ {
		tmpNum = 0
		if i%2 == 0 {
			if f2[i] <= 0 {
				tmpNum = 1 - f2[i]
				f2[i] = f2[i] + tmpNum
			}
		} else {
			if f2[i] >= 0 {
				tmpNum = f2[i] + 1
				f2[i] = f2[i] - tmpNum
			}
		}
		if i < n-1 {
			f2[i+1] = f2[i] + a[i+1]
		}
		num += tmpNum
	}
	num2 := num
	fmt.Println(min(num1, num2))
}

Measured memory_bytes: 9088
import math
n=int(input())
l=[2]
for i in range(3,n+1):
    for p in l:
        if i%p==0:break
    else: l.append(i)
a=1
for p in l:
    s=0
    for i in range(1,int(math.log(n,p))+1):
        s+=n//p**i
    a=a*(s+1)%(10**9+7)
print(a)

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

int main() {
    ll S;

    cin >> S;
    
    ll s = ceil(sqrt(S));

    printf("0 0 ");
    printf("%lld %d ", s, 1);
    printf("%lld %lld", s*s-S, s);

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100

int main(void)
{
    int i, j, k, n, min, tmp, r[MAX + 1], m[MAX][MAX];

    scanf("%d", &n);
    for ( i = 0;  i < n;  i++ ) {
        scanf("%d %d", &r[i], &r[i + 1]);
    }
    for ( i = 0; i < n; i++ ) {
        m[ i ][ i ] = 0;
    }

    for ( i = 1; i < n; i++ ) {
        for ( j = 0; j < n - i; j++ ) {
            for ( k = j; k < j + i; k++ ) {
                tmp = m[ j ][ k ] + m[ k + 1 ] [ j + i ] + r[ j ] * r[ k + 1 ] * r[ j + i + 1 ];
                if ( k == j || min > tmp )
                    min = tmp;
            }
            m[ j ] [ j + i ] = min;
        }
    }

    printf("%d\n", m[0][n - 1]);

    return 0;
}

Measured memory_bytes: 1860
n, k, q = (int(i) for i in input().split())
x = [0]*n
for i in range(q):
    a = int(input()) - 1
    x[a] = x[a] + 1

if q < k:
    for i in range(n):
        print('Yes')
else:
    for i in range(n):
        if k - q + x[i] > 0:
            print('Yes')
        else:
            print('No')

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

int main()
{
	int N;
	scanf("%d", &N);
	std::vector<int> b(N), b_cpy;
	for (auto& e: b)
	{
		scanf("%d", &e);
		e--;
	}
	b_cpy = b;

	std::vector<int> ans(N);
	for (int i{N - 1}; i >= 0; i--)
	{
		int same{N};
		for (int j{i}; j >= 0; j--)
			if (b_cpy[j] == j)
			{
				same = j;
				break;
			}
		if (same == N)
		{
			puts("-1");
			return 0;
		}
		ans[i] = b_cpy[same];
		b_cpy.erase(b_cpy.begin() + same);
	}
	std::vector<int> build;
	for (int i{}; i < N; i++)
	{
		if (ans[i] > i)
		{
			puts("-1");
			return 0;
		}
		build.insert(build.begin() + ans[i], ans[i]);
	}
	if (build == b)
	{
		for (int i{}; i < N; i++)
			printf("%d%c", ans[i] + 1, i == N - 1?'\n':' ');
	}
	else
		puts("-1");

	return 0;
}

Measured memory_bytes: 256
# ABC113-B
N = int(input())
T, A = (int(x) for x in input().split())
H = [T - int(x) * 0.006 for x in input().split()]
zi = 0
zdiff = 10000
for i in range(len(H)):
    zt = abs(A - H[i])
    if zt < zdiff:
        zi = i
        zdiff = zt
print(zi + 1)

Measured memory_bytes: 3060
import bisect
n,m=map(int,input().split())
d=[]
for i in range(m):
     p,y=map(int,input().split())
     d.append([p,y,i])
d=sorted(d,key=lambda x:(x[0],x[1]))
tmp2=[0 for i in range(m)]
p_=0
cnt=0
for x in d:
     p,y,i=x
     if p_!=p:
          p_=p
          cnt=0
     cnt+=1
     tmp2[i]=str(p).zfill(6)+str(cnt).zfill(6)
for x in tmp2:
     print(x)

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

   typedef long long ll;

   const double EPS = (1e-7);
   const ll INF =(1e9);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   int gcd(int a,int b){return b?gcd(b,a%b):a;};

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

const ll MAX_N = 1e5;
ll N;
ll A[MAX_N];

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

    cin >> N;
    REP(i, N){
        cin >> A[i];
    }
    sort(A, A + N);
    vector<ll> P, P1, P2;
    

    if (N % 2 == 0){
        REP(i, N / 2 -1) P.pb(-2);
        P.pb(-1); P.pb(1);
        REP(i, N / 2 - 1) P.pb(2);
        
        ll ans = 0;
        REP(i, N){
            ans += P[i] * A[i];
        }
        cout << ans << endl;
    }
    else {
        REP(i, (N -1) /2) P1.pb(-2);
        P1.pb(1); P1.pb(1);
        REP(i, (N - 3) / 2) P1.pb(2);

        REP(i, (N - 3) /2) P2.pb(-2);
        P2.pb(-1); P2.pb(-1);
        REP(i, (N - 1) / 2) P2.pb(2);

        ll ans1 = 0, ans2 = 0;
        REP(i, N){
            ans1 += P1[i] * A[i];
            ans2 += P2[i] * A[i];
            
        }
        cout << max(ans1, ans2) << endl;

    }

}

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ll long long
#define pb push_back


using namespace std;


int main() {
  int n, k;
  cin >> n >> k;
  int arr[n + 1];
  for(int i = 0; i < n; i++)
    cin >> arr[i];

  sort(arr, arr + n);
  ll ans = 0;
  for(int i = 0;i < k; i++)
    ans += arr[i];
  cout << ans;
}



Measured memory_bytes: 3624
/**Lucky Boy**/
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define maxc 1000000007
#define maxn 200005
#define maxm 1000006
#define pii pair <int,int>
#define Task ""
template <typename T> inline void read(T &x){char c;bool nega=0;while((!isdigit(c=getchar()))&&(c!='-'));if(c=='-'){nega=1;c=getchar();}x=c-48;while(isdigit(c=getchar())) x=x*10+c-48;if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10);putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){putchar('-');x=-x;}writep(x);putchar(' ');}
template <typename T> inline void writeln(T x){write(x);putchar('\n');}
using namespace std;
long long k;
int n,a[maxn],same[maxn],pos[maxn],val[maxn];
vector <int> s;
int main()
{
    ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
    //freopen(Task".inp", "r",stdin);
    //freopens(Task".out", "w",stdout);
    cin >> n >> k;
    FOR(i,1,n)
    {
        cin >> a[i];
        if (!val[a[i]]) val[a[i]] = i;
    }
    FORD(i,n,1)
    {
        same[i] = pos[a[i]];
        pos[a[i]] = i;
    }
    int cur = 1,ck = 1;
    pos[1] = 1;
    while (cur <= n)
    {
        if (same[cur]) cur = same[cur] + 1;
        else
        {
            cur = val[a[cur]] + 1;
            pos[++ck] = cur;
        }
    }
    k %= ck;
    FOR(i,1,n) same[a[i]] = 0;
    if (k)
    {
        FOR(j,pos[k],n)
        {
            if (same[a[j]])
            {
                while (s.back() != a[j])
                {
                    same[s.back()] = 0;
                    s.pop_back();
                }
                same[s.back()] = 0;
                s.pop_back();
            }
            else
            {
                s.pb(a[j]);
                same[a[j]] = 1;
            }
        }
        for (int v : s) cout << v << ' ';
    }
    return 0;
}


Measured memory_bytes: 5620
import sys
c = []

for _ in range(3):
    c += [list(map(int, input().split()))]

a = [0, -1, -1]
b = c[0]

for l, m in enumerate(c[1:]):
    for j, k in enumerate(m):
        if j == 0:
            a[l+1] = k - b[j] 
        else:
            if k != a[l+1] + b[j]:
                print('No')
                sys.exit()
print('Yes')
    



Measured memory_bytes: 9116
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;
#pragma endregion

void solve() {
    int h, n;
    cin >> h >> n;
    vector<pair<int, int>> magic(n);
    for (int i=0; i<n; i++) {
        cin >> magic.at(i).first >> magic.at(i).second;
    }
    vector<int> dp(h+1, INF);
    dp.at(h) = 0;
    for (int i=h-1; i>=0; i--) {
        for (int j=0; j<n; j++) {
            chmin(dp.at(i), dp.at(min(i+magic.at(j).first, h)) + magic.at(j).second);
        }
    }
    cout << dp.at(0) << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int N, K; cin >> N >> K;
    vector<int> p(N);
    REP(i, 0, N) cin >> p[i];
    sort(ALL(p));
    ll ans = 0;
    REP(i, 0, K) ans += p[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
long long n,a,b,x,d,l,t,r,c,p;
int main() {
	scanf("%lld %lld %lld %lld %lld", &n, &a, &b, &c, &d);
	 p = b - a;
	for (int i = 0; i <= n - 1; i++) {
		int j = (n - 1) - i;
		l = (i - j) * c - j * (d - c);
		r = (i - j) * c + i * (d - c);
		if (l <= p && r >= p) {
			cout<<"YES"<<endl;
			return 0;
		} 
	}
	cout<<"NO"<<endl;
}

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

int main(){
  int n; cin>>n;
  vector<int> a(n);
  int mod=1000000007;
  long long total=0;
  for (int i=0; i<n; i++){
    cin>>a[i];
    total+=a[i];
    total%=mod;
  }
  
  long long ans=0;
  
  for (int i=0; i<n; i++){
    total-=a[i];
    if (total<0) total+=mod;
    ans+=a[i]*total;
    ans%=mod;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3972
#include<stdio.h>

int main(){

    int a,b;
    int c;
    scanf("%d %d",&a,&b);
    if(a+b>=24){
        c = (a+b)-(((a+b)/24)*24);
        printf("%d\n",c);
    }
    else {
        c = a+b;
        printf("%d\n",c);
    }

return 0;
}


Measured memory_bytes: 128
#include <iostream>

int main()
{
    int a, b;
    std::cin >> a >> b;

    if (a > b) {
        std::cout << "a > b" << std::endl;
    } else if (a == b) {
        std::cout << "a == b" << std::endl;
    } else {
        std::cout << "a < b" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int n,y;
    cin >> n >> y;
    y/=1000;
    REP(i, n+1){
        REP(j, n+1){
            if(n-i-j<0)continue;
            if(10*i+5*j == y-(n-i-j)){
                pr(i,j,n-i-j);
                return 0;
            }
        }
    }
    pr(-1,-1,-1);
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	
	Scanner sc = new Scanner(System.in);
	
	void run() {
		
		String s = sc.next();
		
		StringBuffer strBuf = new StringBuffer(s);
		
		strBuf = strBuf.reverse();
		
		s = strBuf.toString();
		
		System.out.println(s);
		
		
		
	}
	
	public static void main(String[] args) {
		
		new Main().run();
		
	}
}

Measured memory_bytes: 11000
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] t = new int[n+1];
        int[] x = new int[n+1];
        int[] y = new int[n+1];
        for(int i = 1; i <= n; i++){
            t[i] = Integer.parseInt(sc.next());
            x[i] = Integer.parseInt(sc.next());
            y[i] = Integer.parseInt(sc.next());
        }
        
        String ans = "Yes";
        for(int i = 1; i <= n; i++){
            if(t[i] - t[i-1] < Math.abs(x[i] - x[i-1]) + Math.abs(y[i] - y[i-1])){
                ans = "No";
                break;
            }
            if(t[i] % 2 != (x[i] + y[i]) % 2){
                ans = "No";
                break;
            }
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 63048