akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <unordered_map>
#define maxn 100005
#define mod 998244353
using namespace std;
typedef long long LL;
int main()
{

    int n;
    scanf("%d",&n);
    double x=n*1.0/3.0;
    printf("%.6lf",x*x*x);
    return 0;
}


Measured memory_bytes: 888
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x):
        return -self.parents[self.find(x)]
        
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())
    
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

v, e = map(int,input().split())
road = []
for i in range(e):
    a, b, c = list(map(int,input().split()))
    road.append((a,b,c))
road.sort(key = lambda x: x[2])
#print(road)

uf = UnionFind(v)
cost = 0
cnt = 0
for i in range(e):
    a = road[i][0]
    b = road[i][1]
    c = road[i][2]
    if uf.same(a,b) == False:
        uf.union(a,b)
        cost += c
        cnt += 1
        if cnt == v-1:
            break
#print("cost =", cost)
print(cost)


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

int main(){
    int a,b,c,N;
    cin >> a >> b >> c >> N;
    
    int ans = 0;
    for(int i = 0; i<= a; i++){
        for(int j = 0; j <= b; j++){
            for(int k = 0; k <= c; k++){
                if(i * 500 + j * 100 + k * 50 == N){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define P pair<int,int>
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()

using namespace std;

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

    ll n,m,a;
    cin >> n >> m;

    priority_queue<ll> que;
    rep(i,n) cin >> a, que.push(a);

    rep(i,m){
        a = que.top();
        que.pop();
        que.push(a/2);
    }

    ll ans = 0;
    rep(i,n){
        ans += que.top();
        que.pop();
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) (n); i++)
#define ll long long
#define scout cout << fixed << setprecision(20)
ll INF = 9e17;
ll mod = 1e9 + 7;

int main() {
	int a,b; cin >> a >> b;
	if(a<b) {
		rep(i,b) cout << a;
	}
	else {
		rep(i,a) cout << b;
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	string a, b, c;
  cin>>a>>b>>c;
  cout<<'A'<<b[0]<<'C'<<endl;
	return 0;
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    cout<<n*n*n<<endl;
    return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * 2928.cc: Mail Order
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_H = 100000;
const int MAX_W = 100000;

/* typedef */

typedef long long ll;

template <typename T, const int MAX_N>
struct BIT {
  int n;
  T bits[MAX_N + 1];
  BIT() {}

  void init(int _n) {
    n = _n;
    memset(bits, 0, sizeof(bits));
  }

  T sum(int x) {
    T s = 0;
    while (x > 0) {
      s += bits[x];
      x -= (x & -x);
    }
    return s;
  }

  void add(int x, T v) {
    while (x <= n) {
      bits[x] += v;
      x += (x & -x);
    }
  }
};

/* global variables */

int as[MAX_H], uas[MAX_H];
BIT<int,MAX_H> abit;
BIT<ll,MAX_H> sbit;

/* subroutines */

/* main */

int main() {
  int h, w;
  scanf("%d%d", &h, &w);

  for (int i = 0; i < h; i++)
    scanf("%d", as + i), uas[i] = as[i];

  sort(uas, uas + h);
  int un = unique(uas, uas + h) - uas;

  abit.init(un), sbit.init(un);
  for (int i = 0; i < h; i++) {
    int k = lower_bound(uas, uas + un, as[i]) - uas;
    abit.add(k + 1, 1);
    sbit.add(k + 1, as[i]);
  }

  ll sum = 0;
  for (int i = 0; i < w; i++) {
    int bi;
    scanf("%d", &bi);

    int k = upper_bound(uas, uas + un, bi) - uas;
    int j = abit.sum(k);
    sum += sbit.sum(k) + (ll)bi * (h - j);
  }

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



Measured memory_bytes: 5240
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
from numba import njit
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

# N = I()
N,K,Q = LI()
A = [I() for _ in range(Q)]

c = collections.Counter(A)
# print(c)

B = np.zeros(N,dtype='int')
for i in range(1,N+1):
    B[i-1] = c[i]

# print(B)
ans = (B - Q + K) > 0
for b in ans:
    # print(b)
    if b:
        print('Yes')
    else:
        print('No')

#A,B = zip(*AB)
# A = np.array(_A)

# B = np.zeros(N)
# B[0:-K+1] = A

# 和 - 自分の得点
# B_sum = np.sum(B)
# C = B - B_sum
# print(C)
# print(np.where(B > -K, True, False))
# print(C>-K)

# if ans:
#     print('Yes')
# else:
#     print('No')

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

bool acgt(char s){
  if(s== 'A' ||s=='C' || s=='G' || s=='T'){
    return 1;
  }
  else{
    return 0;
  }
}
  


int main (){
  string s;
  cin >> s;
  
  int ans=0;
  int b;
  
  if(acgt(s.at(0))){
    b =1;
  }
  else{
    b=0;
  }
     
  for (int i=0; i<s.size()-1;i++){
    if(acgt(s.at(i+1))){
      b++;
    }
    else{
      if(ans<b){
        ans=b;
      }
      
      b=0;
    }
  }
  
  if (b>ans){
    ans = b;
  }
  
     cout << ans << endl;
     
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int begin = 1;
    int i = 0;
    while(1) {
        if(begin <= n) {
            begin *= k;
            i++;
        } else {
            break;
        }
    }
    cout << i << endl;
    return 0;
}



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

int main(){

	ll a;
	long double b;
	cin>>a>>b;
	b=(int)(b*100+0.05);
	ll ans = a*b;
	cout<<ans/100;

}


Measured memory_bytes: 3696
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

void main() {
    int N, W;
    scan(N, W);

    auto w = new int[](N);
    auto v = new int[](N);
    iota(N).each!(i => scan(v[i], w[i]));

    auto dp = new int[](W + 1);

    foreach (i ; 0 .. N) {
        foreach (j ; 0 .. W + 1) {
            if (j - w[i] >= 0) chmax(dp[j], dp[j - w[i]] + v[i]);
        }
    }

    auto ans = dp[W];
    writeln(ans);
}







void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}



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

int main(){
  int N,K;cin >> N >> K;
  vector<int> P(N-1);
  for(int i=0;i<N-1;i++){
    P[i] = i+1;
  }
  vector<vector<int>> M(N,vector<int>(N,0));
  for(int j=0;j<K;j++){
    int a,b;cin >> a >> b;
    M[a-1][b-1] = 1;
    M[b-1][a-1] = 1;
  }
  int count = 0;
  do{
    bool valid = true;
    if(M[0][P[0]]==0){
      valid = false;
    }
    for(int j=1;j<N-1;j++){
      if(M[P[j-1]][P[j]]==0){
        valid = false;
      }
    }
    if(valid){
      count ++;
    }
  }while(next_permutation(P.begin(),P.end()));//,P.end());
  cout << count << endl;
}

Measured memory_bytes: 3620
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    k = 0

    while k * (k + 1) // 2 < n:
        k += 1

    x = k * (k + 1) // 2
    d = x - n

    for i in range(1, k + 1):
        if i == d:
            continue
        print(i)


if __name__ == '__main__':
    main()


Measured memory_bytes: 74484
#include <iostream>

using namespace std;
const int maxn = 1e6 + 50;
int a[maxn] = {0};
int main()
{
    int k, n;
    scanf("%d%d", &k,&n);
    for(int i = 1; i <= n; i++)
    {
       scanf("%d", &a[i]);
    }
    int re = 0;
    for(int i = 1; i < n; i++)
    {
        re = max(re, a[i + 1] - a[i]);
    }
    re = max(re, a[1] + k - a[n]);
    printf("%d\n", k - re);
    return 0;
}


Measured memory_bytes: 1024
S = input()
dp = [int(s) for s in S[::-1]]
dp.insert(0, 0)
for i in range(len(S)):
    dp[i+1] = (dp[i+1]*pow(10, i, 2019) + dp[i])%2019

from collections import Counter

c = Counter(dp)
# print(c)
print(sum([x*(x-1)//2 for x in c.values()]))

Measured memory_bytes: 16816
#include <cstdio>
using ll = long long;
inline ll gcd(ll x, ll y)
{
	while (y)
	{
		auto r = x % y;
		x = y;
		y = r;
	}
	return x;
}
inline bool chk(int n)
{
	for (int i = 2; i * i <= n; i++)
	{
		if (!(n % i))
			return false;
	}
	return true;
}
inline ll lcm(ll x, ll y) { return x && y ? x / gcd(x, y) * y : x + y; }
ll pri[1005], arr[505][505];
int main()
{
	// freopen("AGC027-D.in", "r", stdin);
	int n, cur = 0, len = 0;
	scanf("%d", &n);
	bool even = n & 1 ^ 1;
	n += even;
	for (int i = 2; len <= n * 2; i++)
	{
		if (chk(i))
			pri[len++] = i;
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
			arr[i][j] = 1;
	}
	for (int i = 0; i < n; i += 2, cur++)
	{
		int x = i, y = 0;
		while (x < n && y < n)
			arr[x++][y++] *= pri[cur];
	}
	for (int i = 2; i < n; i += 2, cur++)
	{
		int x = 0, y = i;
		while (x < n && y < n)
			arr[x++][y++] *= pri[cur];
	}
	cur = len - 1;
	for (int i = 0; i < n; i += 2, cur--)
	{
		int x = i, y = 0;
		while (x >= 0 && y < n)
			arr[x--][y++] *= pri[cur];
	}
	for (int i = 2; i < n; i += 2, cur--)
	{
		int x = n - 1, y = i;
		while (x >= 0 && y < n)
			arr[x--][y++] *= pri[cur];
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = i & 1 ^ 1; j < n; j += 2)
			arr[i][j] = lcm(lcm(i ? arr[i - 1][j] : 0, j ? arr[i][j - 1] : 0),
							lcm(arr[i + 1][j], arr[i][j + 1])) + 1;
	}
	n -= even;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
			printf("%lld%c", arr[i][j], " \n"[j + 1 == n]);
	}
	return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
int main()
{
	int K, N;
	int m;
	m = -1;
	cin >> K >> N;
	int sumlength[N+1];
	int i,j;
	sumlength[0] = 0;
	for(i=1;i<=N;i++)
	{
		cin >> sumlength[i];
	}
	for(i=1;i<N;i++)
	{
			int length;
			length = sumlength[i+1]-sumlength[i];
			m = max(m,length);
	}
	int min;
	min = K-(sumlength[N]-sumlength[1]);
	m = max(m,min);
	cout << K-m << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    char a, b;
    cin >> a >> b;
    if(a == b){
        cout << 'H' << endl;
    }else{
        cout << 'D' << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { //最大公約数
  if (b==0) return a;
  else return gcd(b, a%b);
}

ll lcm(ll a, ll b) { //最小公倍数
  return a * b / gcd(a, b);
}

ll digit_sum(ll a){ //10進桁和
  ll ans=0;
  while(a>0){
    ans+=a%10;
    a/=10;
  }
  return ans;
}



int main()
{
  string s;
  cin>>s;
  ll min=1e15;
  rep(i,s.length()-2){
    ll tmp=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
    if(abs(tmp-753)<min)min=abs(tmp-753);
  }

  cout<<min<<endl;
  return 0;
}


Measured memory_bytes: 3564
#include <stdio.h>
#include <string.h>
#define LEN 100000
typedef struct pp{
  char name[100];
  int t;
}P;
P Q[LEN+1];
void enqueue(P x);
P dequeue();
int head, tail, n;
int min(int a, int b) {return a < b ? a : b;}
int main(){
  int c, i, q;
  int col = 0;
  P u;
  scanf("%d %d", &n, &q);
  for (i = 1; i <= n; i++){
    scanf("%s %d", Q[i].name, &Q[i].t);
  }
  head = 1;
  tail = n+1;
  while(head != tail){
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    col += c;
    if(u.t > 0){
      enqueue(u);
    } else{
      printf("%s %d\n", u.name, col);
    }
  }
  return 0; }
void enqueue(P x){
  Q[tail] = x;
  if ( tail == LEN ) tail = 1;
  else tail++;
}
P dequeue(){
  P x = Q[head];
  if (head == LEN){
    head = 1; }
  else head++;
  return x; }


Measured memory_bytes: 11892
#include <bits/stdc++.h>
#define str string
using namespace std;
struct dt{
    str s;
    int len;
};
bool operator<(dt a,dt b)
{return a.len>b.len;}
priority_queue<dt> q;
str Pre(str &p,int kk)
{
    str ret="";
    for(int i=0;i<kk;i++)
        ret+=p[i];
    return ret;
}
str Suf(str &p,int kk)
{
    str ret="";
    for(int i=kk;i<p.length();i++)
        ret+=p[i];
    return ret;
}
int main()
{
    int tot=0;
    for(int i=0;i<62;i++){
        char o;
        if(i<26)o=i+'a';
        else if(i<52)o=i-26+'A';
        else o=i-52+'0';
        str op;
        for(int i=0;i<128;i++)op+=o;
        cout<<"? "<<op<<"\n",cout.flush();
        dt d;
        scanf("%d",&d.len),d.len=128-d.len;
        if(d.len){
            tot+=d.len;
            for(int i=0;i<d.len;i++)
                d.s+=o;
            q.push(d);
        }
    }
    while(q.size()>1){
        dt p1=q.top();q.pop();
        dt p2=q.top();q.pop();
        str now=p1.s;
        for(int i=0,j=0;i<p2.len;i++){
            char ch=p2.s[i];
            while(1){
                string a=Pre(now,j)+ch+Suf(now,j);
                cout<<"? "<<a<<"\n",cout.flush();
                ++j;
                int dp;
                cin>>dp;
                if(a.length()+dp==tot)
                    {now=a;break;}
            }
        }
        q.push((dt){now,(int)now.length()});
    }
    cout<<"! "<<q.top().s<<"\n";
    return 0;
}

Measured memory_bytes: 3764
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_6_C&lang=jp

def partition(target_list, l, r):
    x = int(target_list[r][1:])
    i = l - 1

    for j in range(l, r):
        if int(target_list[j][1:]) <= x:
            i = i + 1
            tmp = target_list[i]
            target_list[i] = target_list[j]
            target_list[j] = tmp
    tmp = target_list[r]
    target_list[r] = target_list[i + 1]
    target_list[i + 1] = tmp
    
    return  i + 1

def merge(l,r):
    
    l_index = 0
    r_index = 0
    merge_list = []
    l.append("X " + str(pow(10,9) + 1))
    r.append("X " + str(pow(10,9) + 1))
   
    for k in range(len(l) + len(r) - 2):
        if int(l[l_index][1:]) <= int(r[r_index][1:]):
            merge_list.append(l[l_index])
            l_index += 1
        else:
            merge_list.append(r[r_index])
            r_index += 1
    
    return merge_list
    
def merge_sort(target_list):
    if len(target_list) == 1:
        return target_list
    
    mid = int(len(target_list) / 2)
    l = merge_sort(target_list[:mid])
    r = merge_sort(target_list[mid:])
    
    return merge(l, r)

def check_stable(origin_list, target_list):
    sorted_list = merge_sort(origin_list)
    if sorted_list == target_list:
        return "Stable"
    return "Not stable"

def quick_sort(target_list, l, r):
    if l < r:
        c = partition(target_list, l, r)
        quick_sort(target_list, l, c - 1)
        quick_sort(target_list, c + 1, r)
        
if __name__ == "__main__":
    n_list = int(input())

    target_list = []
    for i in range(n_list):
        target_list.append(input())
    origin_list = [a for a in target_list]
    quick_sort(target_list, 0, n_list - 1)
    print(check_stable(origin_list, target_list))
    print("\n".join(target_list))

Measured memory_bytes: 17044
n = STDIN.gets.to_i
numbers = []

n.times do
  numbers << STDIN.gets.to_i
end

coefficients = []
if n % 2 == 0
  coefficients << -1
  coefficients << 1
else
  coefficients << -1
  coefficients << -1
end

(n - 2).times do |i|
  if i % 2 == 0
    coefficients << 2
  else
    coefficients << -2
  end
end


numbers.sort!

sum1 = coefficients.sort.zip(numbers).reduce(0) do |accum, (coefficient, number)|
  accum + coefficient * number
end

sum2 = coefficients.map {|i| i*(-1)}.sort.zip(numbers).reduce(0) do |accum, (coefficient, number)|
  accum + coefficient * number
end

puts sum1 <= sum2 ? sum2 : sum1


Measured memory_bytes: 14224
I=lambda:list(map(int,input().split()))[::-1];m,n=I();c=[0]*-~n;a=[0]*m
for y,p,i in sorted(I()+[i]for i in range(m)):c[p]+=1;a[i]='%06d%06d'%(p,c[p])
print('\n'.join(a))

Measured memory_bytes: 31172
import sys
input = sys.stdin.readline

sys.setrecursionlimit(10 ** 7)

N, MOD = map(int, input().split())


G = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    x, y = map(int, input().split())
    G[x].append(y)
    G[y].append(x)
G[0].append(1)
G[1].append(0)

DP1 = [0] * (N + 1)

parent = [-1] * (N + 1)
parent[1] = 0

order = []

stack = [1]
while stack:
    x = stack.pop()
    order.append(x)
    for next_ in G[x]:
        if next_ == parent[x]:
            continue
        parent[next_] = x
        stack.append(next_)

for v in order[::-1]:
    tmp = 1
    for next_ in G[v]:
        tmp *= DP1[next_] + 1
        tmp %= MOD
    DP1[v] = tmp
# print (DP1)

DP2 = [1] * (N + 1)

for x in order:
    # 累積積のパート
    #ここが同じ値を返すかチェックする
    n = len(G[x])
    lst1 = [1] * (n + 1)
    lst2 = [1] * (n + 1)
    for i in range(n):
        #親のときだけは違うルールで対処
        if G[x][i] == parent[x]:
            lst1[i + 1] = lst1[i] * DP2[x] % MOD
        else:
            lst1[i + 1] = lst1[i] * (DP1[G[x][i]] + 1) % MOD

        if G[x][n - 1 - i] == parent[x]:
            lst2[n - i - 1] = lst2[n - i] * DP2[x] % MOD
        else:
            lst2[n - i - 1] = lst2[n - i] * (DP1[G[x][n - 1 - i]] + 1) % MOD
    
    for i in range(n):
        if G[x][i] == parent[x]:
            continue
        tmp = lst1[i] * lst2[i + 1] % MOD
        tmp += 1 #白色の分
        DP2[G[x][i]] = tmp % MOD
        stack.append(G[x][i])

# print (DP2)

for i in range(1, N + 1):
    print ((DP1[i] * DP2[i]) % MOD)

# print (DP1)
# print (DP2)

Measured memory_bytes: 36920
#include <iostream>

using namespace std;

int main() {
  int N, K, u{}, p{};
  string S;
  cin >> N >> K >> S;
  if (S[0] == 'L') ++u;
  if (S[N - 1] == 'R') ++u;
  for (int i = 1; i != N; ++i)
    if (S[i - 1] == 'R' && S[i] == 'L') ++p;
  if (K <= p) {
    cout << N - 2 * (p - K) - u << endl;
  } else {
    cout << N - 1 << endl;
  }
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = a; i < (b + a); i++)
#define W1 while (1)
#define COUT(x) cout << x << endl
using namespace std;
using ll = long long;
using ld = long double;
#define ALL(x) x.begin(),x.end()
#define P pair<int,int>
#define mod 1000000007
#define PB push_back
#define F first
#define S second

int main() {
  int n;
  cin >> n;
  string ans = "No";
  rep(i, 3) {
    if (n % 10 == 7) {
      ans = "Yes";
      break;
    } else {
      n /= 10;
    }
  }
  COUT(ans);

  return 0;
}


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

using namespace std;

int main() {
	string b;
	int sum = 0;
	int counter = 0;
	while (getline(cin, b)) {
		while (b.find('.', 0) != string::npos) {
			int p = b.find('.', 0);
			for (int i = 0; i <= p; i++) {
				if (0 <= b[i]-'0' && b[i]-'0' <= 9) {
					counter *= 10;
					counter += b[i]-'0';
				} else {
					if (counter > 0) {
						sum += counter;
						counter = 0;
					}
				}
			}
			b = b.substr(p+1);
		}
		for (int i = 0; i < b.size(); i++) {
			if (0 <= b[i]-'0' && b[i]-'0' <= 9) {
				counter *= 10;
				counter += b[i]-'0';
			} else {
				if (counter > 0) {
					sum += counter;
					counter = 0;
				}
			}
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1188
import math
import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)

N,M,K = nm()

# parent
# if negative, it means the node is root and the value is the size of the group. 
par=[-1] * N  

# return the root node number of the group which the node x belong to  
def find(x):  
  if par[x]<0:  # this means that node x is a root node of the group
    return x    
  else:
    par[x]=find(par[x])  # the parent nodes is expected to have root node number info.
        # if the parent node were not root node, par[x] will be update to be a root node.
        # For the next search par[x] will be the root node. 
    return par[x]

# Unite the group which node x belongs to and the group which node y belongs to 
def unite(x,y):
  x=find(x)  # x will be a root node of the original x node 
  y=find(y)  # y will be a root node of the original y node
  if x==y:   # x and y belong to the same group already, do nothing and just return False 
    return False
  else:  
    if par[x]>par[y]: # Note this is size comparison
      # Size of the group x is smaller than that of the group y, then swap x and y  
      # Note, we are using negative number 
      x,y=y,x
    par[x]+=par[y]  # the size of the group x is increased by the size of the group y 
    par[y]=x  # now the parent of the node y is set to node x.
       # At this moment, parent of other nodes which belonged to the old group y is 
       # stil node Y. However, after find() for those nodes will be update the info  
    return True

def same(x,y):
  return find(x)==find(y)

def size(x):
  return -par[find(x)]

links=[0]*N   # set to all -1. Nubmer of friend and block + 1 
F = [0]* N 
for _ in range(M):
    A,B = nm()
    unite(A-1,B-1)
    links[A-1] +=1 
    links[B-1] +=1

for _ in range(K):
    C,D = nm()
    if same(C-1,D-1):
        links[C-1]+=1
        links[D-1]+=1

for i in range(N):
    F[i] = size(i) - 1 - links[i]
print(*F)


Measured memory_bytes: 14184
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    vector<int> dp(n);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i = 2; i < n; i++)
    {
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const int INF=1<<30,MOD=1000000007;
const ll LINF=1ll<<60;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPARR(i,v) for(int i=0;i<v.size();++i)
#define all(v) (v).begin(),(v).end()
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define bit(n) (1ll<<(n))
template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"":"im")<<"possible"<<endl
#define Poss(n) cout<<((n)?"P":"Imp")<<"ossible"<<endl
template<typename T>ostream&operator<<(ostream&o,const vector<T>&v){for(T i:v)o<<i<<' ';return o;}
template<typename T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<typename T>ostream&operator<<(ostream&o,const set<T>&v){for(T i:v)o<<i<<' ';return o;}
template<typename T,typename U>ostream&operator<<(ostream&o,const pair<T,U>&v){o<<v.first<<' '<<v.second;return o;}

int main(){
    int n,m;
    cin>>n>>m;
    vi a(n),b(m);
    cin>>a>>b;
    sort(all(a));
    sort(all(b));
    if(unique(all(a))!=a.end() ||
        unique(all(b))!=b.end()){
        cout<<0<<endl;
        return 0;
    }
    /*a.push_back(INF);
    b.push_back(INF);*/
    
    ll ans=1;
    REP(i,1,n*m+1){
        int ap=lower_bound(all(a), i) - a.begin();
        int bp=lower_bound(all(b), i) - b.begin();
        //cerr<<i<<','<<ap<<','<<bp<<endl;

        if(a[ap]==i && b[bp]==i)continue;
        //cerr<<n-ap<<' '<<m-bp<<endl;
        if(a[ap]==i){
            ans*=m-bp;
        }else if(b[bp]==i){
            ans*=n-ap;
        }else{
            ans*=(ll)(n-ap)*(m-bp)-(n*m-i);
        }
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  int n,cnt = 0;
  cin >> n;
  vector<int>num(n);
  for (int i = 0; i < n; i++) {
    cin >> num.at(i);
  }
  for (int i = 1; i < n-1; i++) {
    if (num.at(i) > num.at(i-1) && num.at(i) <= num.at(i+1)) {
      cnt++;
    }
    else if (num.at(i) > num.at(i+1) && num.at(i) <= num.at(i-1)) {
      cnt++;
    }
  }  
  cout << cnt;
}

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

using namespace std;

typedef long long ll;
#define mems(p) memset(p,-1,sizeof(p))
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define nl "\n"

const int mxN = 1e5;
const ll MOD = 1e9 + 7;

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

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

int main() {
	fast();
	int n, k;
	cin >> n >> k;
	vector<ll> a(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	for (int i = k; i < n; ++i)
	{
		if (a[i] <= a[i - k]) {
			cout << "No\n";
		} else {
			cout << "Yes\n";
		}
	}
}

Measured memory_bytes: 4780
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
vector<int> Zalgo(const string &S) {
    int N = (int)S.size();
    vector<int> res(N);
    res[0] = N;
    int i = 1, j = 0;
    while (i < N) {
        while (i+j < N && S[j] == S[i+j]) ++j;
        res[i] = j;
        if (j == 0) {++i; continue;}
        int k = 1;
        while (i+k < N && k+res[k] < j) res[i+k] = res[k], ++k;
        i += k, j -= k;
    }
    return res;
}

int main() { 
    int N;
    string S;
    cin >> N >> S;

    int res = 0;
    for (int i = 0; i < N; ++i) {
        string T = S.substr(i);
        auto lcp = Zalgo(T);

        for (int j = 0; j < T.size(); ++j) {
            int l = min(lcp[j], j);
            res = max(res, l);
        }
    }
        
    cout << res << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;
 
 
public class Main {
     
	public static String[] kan_alphabets = {
	    "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
	    "ld", "mb", "mp", "nc", "nd", "ng", "nt", "nw", "ps", "qu", "cw", "ts"
	};
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        final int n = sc.nextInt();
        
        Map<String, LinkedHashMap<String, Integer>> map = new HashMap<String, LinkedHashMap<String, Integer>>();
        for(String alphabet : kan_alphabets){
        	map.put(alphabet, new LinkedHashMap<String, Integer>());
        }
        
        while(sc.hasNext()){
        	String input = sc.next();
        	
        	String prev = null;
        	while(input.length() != 0){
        		String matched = null;
        		for(String alphabet : kan_alphabets){
        			if(input.startsWith(alphabet)){
        				matched = alphabet;
        			}
        		}
        		
        		if(matched == null){
        			break;
        		}
        		input = input.substring(matched.length());
        		
        		if(prev != null){
        			if(!map.get(prev).containsKey(matched)){
        				map.get(prev).put(matched, 0);
        			}
        			map.get(prev).put(matched, map.get(prev).get(matched) + 1);
        		}
        		prev = matched;
        	}
        }
        
        for(String alphabet : kan_alphabets){
        	if(map.get(alphabet).isEmpty()){
        		System.out.println(alphabet + " " + "a" + " " + 0);
        	}else{
        		String occur = null;
        		int max = 0;
        		for(Entry<String, Integer> entry : map.get(alphabet).entrySet()){
        			if(entry.getValue() >= max){
        				occur = entry.getKey();
        				max = entry.getValue();
        			}
        		}
        		
        		System.out.println(alphabet + " " + occur + " " + max);
        	}
        }
        
    }
 
}

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


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

    if (n%2 == 0){
        if (s.substr(0,n/2) == s.substr(n/2,n-1)){
            cout << "Yes";
        }else{cout << "No";}
    }else{cout << "No";}

    return 0;
}

Measured memory_bytes: 256
import sys
#input = sys.stdin.buffer.readline

def main():
    s = input()
    if len(s)%2 != 0:
        print("No")
        exit()
    for i in range(len(s)//2):
        if s[2*i:2*i+2] != "hi":
            print("No")
            exit()
    print("Yes")
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

const int INF = 1e9;
const int N = 1<<12;
const int M = 1001;
int dp[M][N];

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

	int n, m;
	scanf("%d%d", &n, &m);
	vi price(m), box(m);
	for (int i = 0; i < m; i++) {
		int b;
		scanf("%d%d", &price[i], &b);
		while (b-- > 0) {
			int c;
			scanf("%d", &c);
			box[i] |= 1 << (c-1);
		}
	}

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

	for (int i = 0; i < m; i++) {
		for (int j = 0; j < (1 << n); j++) {
			dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
			dp[i+1][j|box[i]] = min(dp[i+1][j|box[i]], dp[i][j] + price[i]);
		}
	}
	/*
	for (int i = 0; i <= m; i++) {
		for (int j = 0; j < (1 << n); j++) printf("%d ", dp[i][j]);
		puts("");
	}
	*/

	printf("%d\n", (dp[m][(1<<n)-1] == INF)? -1 : dp[m][(1<<n)-1]);
}


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

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
const int INF = 100000;

struct edge{int to, cost;};

#define MAX_V 11000
int V;
vector<edge> G[MAX_V];
int d[MAX_V];
int pre[MAX_V];

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + V, INF);
    fill(pre, pre + V, -1);
    d[s] = 0;
    que.push(P(0, s));
    
    while (!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (int i = 0; i < G[v].size(); i++){
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                pre[e.to] = v;
                que.push(P(d[e.to], e.to));
            }
        }
    }
    //for (int i = 0; i < V; i++){
    //    fprintf(stderr, "%d, %d: %d\n", s, i, d[i]);
    //}
    return;
}
////////////////////////////////////////

// x = i/W, y = i%W;
// xy = j * W + i;
int main() {
    int H, W, S, G1, ans = 0;
    cin >> H >> W;
    V = H * W;
    vector<string> A(H);
    rep(i, H)cin >> A[i];
    S = 0;
    G1 = V - 1;
    //rep(i, H)rep(j, W)cout << A[i][j];
    //exit(1);
    rep(i, V){
        int val;
        int h = i/W, w = i%W;
        //if (i/W > 0)G[i].push_back((edge){i - W, A[i - W]}), dd[i][i - W] = A[i - W];
        if (i/W < H - 1){
            val = (A[h][w] != A[h + 1][w]);
            G[i].push_back((edge){i + W, val});
        }
        if (i%W < W - 1){
            val = (A[h][w] != A[h][w + 1]);
            G[i].push_back((edge){i + 1, val});
        }
    }
    dijkstra(S);
    //cout << d[G1] << endl;
    int val = (A[0][0] == '#' && A[H - 1][W - 1] == '#');
    cout << val + (d[G1]+1)/2;
    return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<vector>
#include<cmath>
#include<climits>
using namespace std;

int main(){
	int n;
	cin>>n;
	int k;
	cin>>k;
	std::vector<int> h(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>h[i];
	}
	std::vector<int> dp(n,INT_MAX);
	dp[0] = {0};

	for (int i = 0; i < n; ++i)
	{
		for (auto x=i+1;x<=i+k;++x)
		{
			//cout<<dp[x] <<" "<<dp[i] << " "<<abs(h[i]- h[x])<<" "<<(dp[i]+abs(h[i]-h[x]))<<" ";
			dp[x] = min(dp[x], dp[i] + abs(h[i]-h[x]));
			//cout<<dp[x] <<" ";
		}
		//cout<<dp[i]<<" "<<endl;
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

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

using namespace std;
long long x[10000010], y[10000010];
#define rep(i, n) for (int i = 0; i < (n); i++)
#define lep(j, n) for (int j = 0; j < (n); j++)
#define reps(i, n) for (int i = 1; i < (n); i++)
#define leps(i, n) for (int j = 1; j < (n); j++)
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define int long long
#define gsort(x, n) sort((x), (x) + (n), greater<int>());
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

signed main()
{

   cin.tie(0);
   ios::sync_with_stdio(false);

   string a, b, c;
   cin >> a >> b >> c;
   cout << a[0] << b[1] << c[2] << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int n;
  ll k;
  cin >> n >> k;
  vector<int> t(n),tn(n);
  for(int i=0;i<n;i++){
    cin >> t[i]; t[i]--;
  }
  
  vector<int> ans(n);
  for(int i=0;i<n;i++) ans[i]=i;

  for(int i=0; i<60; i++){
    if((k>>i)&1){
      for(int j=0;j<n;j++){
        ans[j]=t[ans[j]];
      }
    }
    for(int j=0;j<n;j++){
      //cout << t[j] << " ";
      tn[j]=t[t[j]];
    }
    //cout << endl;
    swap(tn,t);
  }

  cout << ans[0]+1 << endl;


  return 0;
}


Measured memory_bytes: 5636
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())

R,G,B,N = readInts()
cnt = 0
for r in range(N//R+1):
    for g in range(N//G+1):
        b = (N - r*R - g*G)//B
        #print(r,g,b)
        if b >= 0:
            if r*R + g*G + b*B == N:
                cnt += 1
print(cnt)


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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			int l = cin.Int();
			int[] a = new int[n];
			int[] b = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = Math.Abs(l + i);
				b[i] = l + i;
			}

			int min = a.Min();
			int index = a.ToList().IndexOf(min);
			int minmin = b[index];
			int sum = b.Sum();
			Console.WriteLine(sum - minmin);
		}

	}

	public class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}


		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 13280
n, x, y = map(int,input().split())
li = [0] * (n - 1)
for i in range(1, n + 1):
    for j in range(i + 1, n + 1):
        k = min(j - i, abs(i - x) + abs(j - y) + 1)
        li[k - 1] += 1
for i in li:
    print(i)


Measured memory_bytes: 3444
#include <iostream>
#include <map>

int main() {
  uint32_t N = 0;
  std::cin >> N;

  std::map<int64_t, uint32_t> dict;
  int64_t sum = 0;
  dict[0]++;
  uint64_t ans = 0;
  for (size_t i = 0; i < N; i++) {
    int64_t A = 0;
    std::cin >> A;
    sum += A;
    ans += dict[sum];
    dict[sum]++;
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define ll long long
using namespace std;
    
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    c=a+b;
    if (a%3==0||b%3==0||c%3==0)
        cout<<"Possible";
    else
        cout<<"Impossible";
    return 0;
}


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

int main(){
    int n ;
    cin >> n ;
    vector<int> d(n) ;
    for (size_t i = 0; i < n; i++)
    {
        cin >> d.at(i) ;
    }
    if (d.at(0) != 0)
    {
        cout << 0 << endl ;
        return 0 ;
    }
    int64_t ans = 1 ;
    int64_t mod = 998244353 ;

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

    if (d.at(1) == 0)
    {
        cout << 0 << endl ;
        return 0 ;
    }
    
    int j = 1 ;
    int max = d.at(n-1) ;
    vector<int> count(max+1,0) ;
    count.at(0) = 1 ;
    
    for (int i = 1; i < max+1; i++)
    {
        
        while (1)
        {
            if (j == n)
            {
                break ;
            }
            
            
            if (d.at(j) == i)
            {
                count.at(i) ++ ;
                j ++ ;
            }else
            {
                break ;
            }
                
        }
        for (size_t k = 0; k < count.at(i); k++)
        {
            ans *= count.at(i-1) ;
            if (ans >= mod)
            {
                ans = ans % mod ;
            }
            
        }
        if (ans == 0)
        {
            break ;
        }
        
          
    }
    
    cout << ans << endl ;
    
    
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
  int a, b;
  scanf("%d %d", &a, &b);
  int i;
  if(a<=b)
    for(i=0;i<b;i++)
      printf("%d",a);
  else
    for(i=0;i<a;i++)
      printf("%d", b);
  return 0;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int n;
  cin >> n;

  int maxv = 0;
  vector<int> p(n+1);
  rep(i, n) {
    cin >> p[i];
    chmax(maxv, p[i]);
  }

  bool isNew = true;
  int ans = 0;
  rep(i, n) {
    if (isNew && p[i] == maxv) {
      ans += p[i] / 2;
      isNew = false;
    }
    else ans += p[i];
  }

  cout << ans << "\n";

  return 0;
}

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

const int MAXN = 112345;



int st[4 * MAXN];
int v[MAXN];

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

void build (int nd, int l, int r) {
	if (l == r) {
		st[nd] = v[l];
		return;
	}

	int mid = (l + r) >> 1;
	int nxt = nd << 1;

	build (nxt, l, mid);
	build (nxt + 1, mid + 1, r);

	st[nd] = gcd ( st[nxt], st[nxt + 1] );
	return;
}

int query (int nd, int l, int r, int ll, int rr) {
	if (rr < l || r < ll) return 0;
	if (ll <= l && r <= rr) return st[nd];

	int mid = (l + r) >> 1;
	int nxt = nd << 1;

	return gcd ( query (nxt, l, mid, ll, rr), query (nxt + 1, mid + 1, r, ll, rr) );
}

int n;
int query (int l, int r) { return query (1, 0, n - 1, l, r); }

int main () {

	scanf("%d", &n);

	for (int i = 0; i < n; ++i) scanf("%d", &v[i]);
	
	build (1, 0, n - 1);

	int x = query (1, n - 1);
	int y = query (0, n - 2);

	int mx = std::max (x, y);

	for (int i = 1; i < n - 1; ++i) {
		mx = std::max (mx, gcd (query (0, i - 1), query(i + 1, n - 1)));
	}

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





	return 0;
}	


Measured memory_bytes: 1664
#include <stdio.h>
int n,a[105],min=101,max=-101,ans=1<<30,s;
main(){
    scanf("%d",&n);for(register int i=1;i<=n;i++){scanf("%d",&a[i]);if(min>a[i]) min=a[i];if(max<a[i]) max=a[i];}
    for(register int i=min;i<=max;i++){
        s=0;for(register int j=1;j<=n;j++) s+=(a[j]-i)*(a[j]-i);
        if(s<ans) ans=s;
    }
    return printf("%d\n",ans),0;
}

Measured memory_bytes: 128
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main() {
    int N;
    cin >> N;
    struct Info {
        int idx;
        int value;
    };
    vector<Info> Pis;
    for (int i = 0; i < N; i++) {
        int Pi;
        cin >> Pi;
        Pis.push_back({i, Pi});
    }
    sort(Pis.begin(), Pis.end(), [](Info lhs, Info rhs){ return lhs.value < rhs.value; });
    int max_length = numeric_limits<int>::min();
    int start = -1;
    for (int i = 0; i < N; i++) {
        if (i == 0) {
            start = 0;
        } else {
            if (Pis[i].idx < Pis[i-1].idx) {
                start = i;
            }
        }
        max_length = max(max_length, i - start + 1);
    }
    cout << N - max_length << endl;
}


Measured memory_bytes: 2420
#include <stdio.h>

int     main(void)
{
    int i, a, b, c;
    int count;
    scanf("%d%d%d", &a, &b, &c);
    
    i = 0;
    count = 0;
    while (b - i >= a)
    {
        if (c % (b - i) == 0)
            count++;
        i++;
    }
    printf("%d\n", count);
}


Measured memory_bytes: 2096