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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////

int main()
{
    FASTIO;

    ll n , m;

    cin >> n >> m;

    ll a[n+1];



    ll sum = 0;

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

    if(sum>n)
    {
        cout << -1 << endl;
        return 0;
    }

    if(sum==n)
    {
        cout << 0 << endl;
        return 0;
    }


    cout << abs(n-sum) << endl;




    return 0;
}



Measured memory_bytes: 3740
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}


signed main()
{
	fio
	inp(x)
	ld pi=3.14159265359;
	cout<<fixed<<setprecision(10)<<pi*x*2<<'\n';
	printclock;
}

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


using namespace std;


int main(void){
  
  vector<int> A;
  int N;
  string ans = "APPROVED";
  
  cin >> N;
  
  for(int i = 0; i < N ; i++){
    int tmp;
    cin >> tmp;
    A.push_back(tmp);
  }

  for(int i = 0; i < N ; i++){
    if(A.at(i)%2 == 0){
      if(A.at(i)%3 != 0 && A.at(i)%5 != 0){
        ans = "DENIED";
        break;
      }
    }


  }

  cout << ans << endl;
  

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <class T1, class T2>
bool chmax(T1 &a, const T2 b){if(a < b){a = b; return true;} return false;}
template <class T1, class T2>
bool chmin(T1 &a, const T2 b){if(a > b){a = b; return true;} return false;}
ll pow2(const int n){return (1LL << n);}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (const T &i : v) os << i << ' ';
    return os;
}
void co() { cout << '\n'; }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) {
    cout << head << ' ';
    co(forward<Tail>(tail)...);
}
void ce() { cerr << '\n'; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) {
    cerr << head << ' ';
    ce(forward<Tail>(tail)...);
}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1000000001;
constexpr ll LINF = 1000000000000000001;
constexpr ll MOD = 1000000007;
constexpr ll MOD_N = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

int main(void) {
    ll n;
    cin >> n;
    Vec a(n);
    rep(i, n) cin >> a[i];

    ll l = 0, r = 3e5;
    while (r - l > 1) {
        ll m = (l + r) / 2;
        map<ll, ll> mp;
        ll len = 0;
        rep(i, n){
            if (a[i] > len) {
                len = a[i];
                continue;
            }
            if(m == 1){
                mp[0]++;
                break;
            }
            len = a[i];
            ll p = len;
            while(p >= 1 && mp[p] >= m - 1){
                --p;
            }
            mp.erase(mp.upper_bound(p), mp.end());
            mp[p]++;

            if (mp[0] != 0) break;
        }

        if (mp[0] == 0) r = m;
        else l = m;
    }
    co(r);

    return 0;
}

Measured memory_bytes: 4824
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}

vector<int> v1[100005];
int pl[100005][2];

int main(){
	int n,m,q;
	int i,j,k;
	int a,b,c;
	cin>>n>>m>>q;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			cin>>a;
			a--;
			pl[a][0]=i,pl[a][1]=j;
		}
	}
	for(i=0,j=0;i<n*m;i++,j++){
		if(j>=q)j-=q;
		if(!v1[j].empty()){
			a=v1[j].back(),b=abs(pl[i][0]-pl[i-q][0])+abs(pl[i][1]-pl[i-q][1]);
		}else a=0,b=i+j;
		v1[j].push_back(a+b);
	}

	cin>>n;
	for(i=0;i<n;i++){
		cin>>a>>b;
		a--,b--;
		c=a%q;
		a/=q,b/=q;
		cout<<v1[c][b]-v1[c][a]<<endl;
	}
}

Measured memory_bytes: 6272
N, K = map(int,input().split())
A = list(map(int,input().split()))

mod = 10**9 + 7

right_numbers = [0]*N
left_numbers = [0]*N
right_ans = [0]*N
left_ans = [0]*N

right_total = K*(K+1)//2
left_total = K*(K-1)//2

for i in range(N):
    for r in range(i+1,N):
        if A[i] > A[r]:
            right_numbers[i] += 1
    for l in range(0,i):
        if A[i] > A[l]:
            left_numbers[i] += 1
    #print(right_numbers[i] * right_total)
    #print(left_numbers[i] * left_total)
    right_ans[i] = right_numbers[i] * right_total
    left_ans[i] = left_numbers[i] * left_total

"""
print(right_numbers)
print(left_numbers)
print(right_ans)
print(left_ans)
print(sum(right_ans))
print(sum(left_ans))
"""
print((sum(right_ans) + sum(left_ans)) % mod)

Measured memory_bytes: 3384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{int k;
string s;
cin>>k>>s;
if(s.size()<=k)
    cout<<s;
else
{for(int i=0;i<k;i++)
        cout<<s[i];
    cout<<"...";}
}

Measured memory_bytes: 3624
import java.util.*;
public class Main {
  /*
  private static void roop(int a, int b){
    for(int i = 0; i < a; i++){
      System.out.print(b);
    }
    System.out.println();
  }
  */
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Set<Integer> set = new HashSet<Integer>();
    boolean flg = true;
    int tmp;
    for(int i = 0; i < n; i++){
      tmp = sc.nextInt();
      if(!set.contains(tmp)){
        set.add(tmp);
      }
      else
      {
        flg = false;
        break;
      }
    }
    //char[] a = sc.nextLine().toCharArray();
    
    if(flg)
    {
      System.out.println("YES");
    }
    else
    {
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 100800
import sys

table = [0]*26

letters = "abcdefghijklmnopqrstuvwxyz"
input_str = sys.stdin.read()

for A in input_str:
    index = 0
    for B in letters:
        if A == B or A == B.upper():
            table[index] += 1
            break
        index += 1

for i in range(len(letters)):
    print("%s : %d"%(letters[i],table[i]))



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

#define ll long long 

long long floor_sum(long long n, long long m, long long a, long long b) {
    long long ans = 0;
    if (a >= m) {
        ans += (n - 1) * n * (a / m) / 2;
        a %= m;
    }
    if (b >= m) {
        ans += n * (b / m);
        b %= m;
    }

    long long y_max = (a * n + b) / m, x_max = (y_max * m - b);
    if (y_max == 0) return ans;
    ans += (n - (x_max + a - 1) / a) * y_max;
    ans += floor_sum(y_max, a, m, (a - x_max % a) % a);
    return ans;
}


void test_case(){
	ll n , m , a , b;
	cin >> n >> m >> a >> b;
	cout<<floor_sum(n,m,a,b)<<"\n";
	
}


int main(){
	int t;
	cin >> t;
	while(t--)
		test_case();
	}
	
// i = 0 to i = n
// (a*i+b)/m


Measured memory_bytes: 3596
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
#include <map>
#include <queue>
#include <clocale>
#include <bitset>
#include <cstring>
#include <memory.h>
#include <numeric>
#include <iomanip>
#include <stack>
#include <list>
#include <functional>
#include <unordered_set>

using namespace std;

#pragma comment (linker, "/STACK:667177216")
#define ll long long
#define LL long long
#define ull unsigned long long
#define ld long double
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pb push_back
const ll mod = 1000000007;
#define INF (int)(2e9)
#define LINF (ll)(4e18)
#define forit(mas) for(auto(it)=(mas).begin();(it)!=(mas).end();(it)++)
#define pii pair<int,int>


int main() {

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, T;
	cin >> n >> T;
	ll mn = 4e18;
	for (int i = 0; i < n; i++) {
		ll c, t;
		cin >> c >> t;
		if (t <= T) mn = min(mn, c);
	}
	if (mn == 4e18) cout << "TLE";
	else cout << mn;
	return 0; 
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

class UF{
private:
    vector<int> par,rank,elm;
    vector<vector<int>> elmList;    //don't be validated
public:
    int groups;
    
    UF(int __size):par(__size) , rank(__size,0) , elm(__size,1) , groups(__size), elmList(__size){
        rep(i,__size)elmList[i] = vector<int>(1,i);
        for(int i=0;i<__size;i++)par[i]=i;
    }
    
    int getElements(int n){ return elm[find(n)]; }
    vector<int> getElementsList(int n){ return elmList[find(n)]; }
    
    int find(int x){
        if(par[x]==x) {
            return x;
        }else{
            return par[x]=find(par[x]);
        }
    }
    
    void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        
        groups--;
        if(rank[x]<rank[y]){
            par[x]=y;
            elm[y]+=elm[x];
            for(auto &e:elmList[x])elmList[y].pb(e);
            
        }else{
            par[y]=x;
            elm[x]+=elm[y];
            for(auto &e:elmList[y])elmList[x].pb(e);
            if(rank[x]==rank[y])rank[x]++;
        }
    }
    
    bool isSame(int x,int y){
        return find(x)==find(y);
    }
};


int main(){
    int n;
    while(cin>>n&&n){
        UF uf(26);
        vector<int> indeg(26,0), outdeg(26,0);
        set<int> used;
        rep(i,n){
            string s;
            cin>>s;
            indeg [s[s.size()-1]-'a']++;
            outdeg[s[0]-'a']++;
            uf.unite(s[0]-'a',s[s.size()-1]-'a');
            used.insert(s[0]-'a');
            used.insert(s[s.size()-1]-'a');
        }
        
        vector<int> notzero;
        rep(i,26){
            if(indeg[i]-outdeg[i]!=0)
                notzero.pb(indeg[i]-outdeg[i]);
        }
        if(notzero.size()==0&&uf.groups==1+26-used.size())cout<<"OK"<<endl;
        else cout<<"NG"<<endl;
    }
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define LL long long
#define endl '\n'
using namespace std;
const LL MOD = 1e9+7;
const LL INF = 1e9+7;


int main(){
	string s;
	cin>>s;
	s[3] = '8';
	cout<<s<<endl;
	return 0;
	
}


Measured memory_bytes: 256
import collections 
def solve():
  h,w,n = (int(i) for i in input().split())
  
  query = []
  for i in range(n):
    a,b = (int(i) for i in input().split())
    d = [(-1,-1),(-1,0),(-1,1),(0,-1),(0,0),(0,1),(1,-1),(1,0),(1,1)]
    for dx,dy in d:
      if 2 <= a+dx <= h-1 and 2 <= b+dy <= w-1:
        query.append((a+dx,b+dy))
  ans = [0]*10
  if query:
   query = collections.Counter(query)
   values, counts = zip(*query.most_common())
   for i in range(10):
     ans[i] = counts.count(i)
  tp = sum(ans)
  ans[0] = (h-2)*(w-2)-tp
  
  for i in ans:
    print(i)
solve()


Measured memory_bytes: 243136
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define LL long long
using namespace std;
LL a[200005],sum[200005];
int main(void)
{
	int i,x1=1,x3=3,n;
	LL ans=0x3F3F3F3F3F3F3F3F;
	scanf("%d",&n);
	for(i=1;i<=n;++i)
	{
		scanf("%lld",&a[i]);
		sum[i]=sum[i-1]+a[i];
	}
	for(i=2;i<=n;++i)
	{
		while(x1<n-3&&abs(sum[x1]-(sum[i]-sum[x1]))>abs(sum[x1+1]-(sum[i]-sum[x1+1])))++x1;
		while(x3<n-1&&abs(sum[x3]-sum[i]-(sum[n]-sum[x3]))>abs((sum[x3+1]-sum[i])-(sum[n]-sum[x3+1])))++x3;
		LL v1=sum[x1],v2=sum[i]-sum[x1],v3=sum[x3]-sum[i],v4=sum[n]-sum[x3];
		ans=min(ans,max(max(v1,v2),max(v3,v4))-min(min(v1,v2),min(v3,v4)));
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define M 100006
#define ll long long int 
using namespace std;
ll f[M];
struct node{
	int v,m;
}a[101];
int max(int a,int b)
{
	if(a>b)return a;
	return b;
}
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i].m>>a[i].v;
	}
	for(int i=1;i<=n;++i)
	for(int j=m;j>=a[i].m;--j)f[j]=max(f[j],f[j-a[i].m]+a[i].v);
	cout<<f[m];
}

Measured memory_bytes: 1024
import Data.List
import Control.Monad.State

main = do
    [n, m] <- map read . words <$> getLine
    xss <- map (map read . tail . words) <$> sequence (replicate n getLine)
    print . fst $ runState (acnt n m xss) (replicate m 0) 

acnt :: Int -> Int -> [[Int]] -> State [Int] Int
acnt n m [] = state $ \s -> let s' = zipWith (+) (replicate m 0) s
                                in (length . filter (==n) $ s', s')
acnt n m (xs:xss) = state $ \s -> let xs' = map (\x -> if x `elem` xs then 1 else 0) [1..m]
                                      (_, xs'') = runState (acnt n m xss) s
                                      s' = zipWith (+) xs' xs''
                                      in (length . filter (==n) $ s', s')


Measured memory_bytes: 1148
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>

#define x first
#define y second

using namespace std;

typedef long long LL;
typedef pair<int,int>PII;

const int maxn = 2e5 + 10;

int deep[maxn],fa[maxn],vis[maxn];

int t,n,m;

vector<int>G[maxn];

void BFS(int root) {
	queue<int>Q;
	Q.push(root);
	fa[root] = 1;
	while(Q.size()) {
		int top = Q.front();
		Q.pop();
		if(vis[top]) continue;
		vis[top] = 1;
		for(int i = 0; i < G[top].size(); i ++) {
			int y = G[top][i];
			if(fa[y]) continue;
			Q.push(y);
			fa[y] = top;
		}
	}
	return ;
}

int main(void) {
	scanf("%d%d",&n,&m);
	int u,v;
	for(int i = 1; i <= m; i ++) {
		scanf("%d%d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}

	BFS(1);
	bool flag = true;
	int idx = 1;
	for(int i = 2; i <= n; i ++) {
		if(fa[i] == 0) {
			flag = false;
			break;
		}
	}
	if(!flag) puts("No");
	else {
		puts("Yes");
		for(int i = 2; i <= n; i ++) {
			printf("%d\n",fa[i]);
		} 
	}
	return 0;
}


Measured memory_bytes: 13336
#include<bits/stdc++.h>
using namespace std;
main(){
  int w,h,n;
  cin>>w>>h>>n;
  vector<vector<bool>>white(h,vector<bool>(w,true));
  while(n--){
    int a,b,c;
    cin>>a>>b>>c;
    if(c==1){
      for(int i=0;i<h;++i)
        for(int j=0;j<a;++j)
          white[i][j]=false;
    }
    else if(c==2){
      for(int i=0;i<h;++i)
        for(int j=a;j<w;++j)
          white[i][j]=false;
    }
    else if(c==3){
      for(int i=0;i<b;++i)
        for(int j=0;j<w;++j)
          white[i][j]=false;
    }
    else if(c==4){
      for(int i=b;i<h;++i)
        for(int j=0;j<w;++j)
          white[i][j]=false;
    }
  }
  int ans=0;
  for(auto y:white)for(auto x:y)ans+=x;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let m = ((1+8*n) as f64).sqrt() as usize;
    if m*m != 1+8*n {
        println!("No");
        return;
    }

    println!("Yes");
    let k = (1+m)/2;
    println!("{}", k);
    let mut counts = vec![Vec::new(); n];
    for i in 0..k {
        print!("{} ", k-1);
        let mut rnum = 0usize;
        let mut inte = BTreeSet::new();
        for j in 0..n {
            if inte.len() < i {
                if counts[j].len() == 1 && !inte.contains(&counts[j][0]) {
                    inte.insert(counts[j][0]);
                    rnum += 1;
                    counts[j].push(i);
                    print!("{} ", j+1);
                }
            } else if rnum < k-1 {
                if counts[j].len() == 0 {
                    rnum += 1;
                    counts[j].push(i);
                    print!("{} ", j+1);
                }
            }
        }
        println!("");
    }
}


Measured memory_bytes: 15740
#include <bits/stdc++.h>
using namespace std;
int main()
{
  char ch;
  cin >> ch;
  if(ch>='A'&&ch<='Z')
  {
    cout << "A" <<endl;
  }
  else
  {
    cout << "a" << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<sstream>
#include<string>
#include<math.h>
using namespace std;

int main()
{
	int a[200005];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int maa = 0;
	int memo[200005];
	for (int i = n - 1; i!=0; i--)
	{
		maa = max(maa, a[i]);
		memo[i-1] = maa;
	}
	int ans = -1000000000;
	for (int i = 0; i < n-1; i++)
	{
		ans = max(memo[i] - a[i], ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2720
#include<stdio.h>
int main(void)
{
    int a,i,j,cnt=0;
    int k[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    scanf("%d",&a);

    for(i=0;i<32;i++){
        if(a==i+1){
            printf("%d\n",k[i]);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int[] X = new int[N];
            for (int i = 0; i < N; i++) {
                X[i] = sc.nextInt();
            }

            int ans = Integer.MAX_VALUE;
            for (int p = 1; p <= 100; p++) {
                int sum = 0;
                for (int i = 0; i < N; i++) {
                    sum += (X[i] - p) * (X[i] - p);
                }

                if (sum < ans) {
                    ans = sum;
                }
            }

            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 22228
// At Coder :: Beginner Contest 178 :: A - Not 
// https://atcoder.jp/contests/abc178/tasks/abc178_a

#include <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int x;
    cin >> x;
    if (x == 0) {
        cout << 1 << "\n";
    } else if (x == 1) {
        cout << 0 << "\n";
    }
    return EXIT_SUCCESS;
}


Measured memory_bytes: 3652
main = getLine >>= putStrLn . (\[a, b] -> solve a b) . map (read :: String -> Int) . words

solve :: Int -> Int -> String
solve a b
    | b < 0 && (b - a) `mod` 2 == 0 = "Negative"
    | a == 0 || b == 0 || (a < 0 && 0 < b) = "Zero"
    | otherwise = "Positive"


Measured memory_bytes: 508
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
//using Graph = vector<vector<int>>;
typedef long long ll;
using Graph = vector<vector<pair<ll,ll>>>;
const int mod =1e+9+7;

const int dy[4]={0,1,0,-1};
const int dx[4]={1,0,-1,0};
const ll INF=1e10;

int main(){
    ll x; cin>>x;
    if(x==1)cout<<0<<endl;
    else cout<<1<<endl;
}











Measured memory_bytes: 3628
Li = [int(input()) for _ in range(4)]
a, b, c, x = Li[0], Li[1], Li[2], Li[3]
ans = 0
for i in range(min(x//500, a)+1):
    for j in range(min((x-500*i)//100, b)+1):
        ans += 1 if (x-500*i-100*j)//50 <= c else 0
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
int main(int argc, char* argv[])
{
	string S,T;
	cin>>S>>T;
	if (!strncmp(S.c_str(),T.c_str(),S.size())){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

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

int main() {
  string s; cin >> s;
  int ssize = s.size();
  int del = (ssize & 1 ? 1 : 2);
  int ans = 0;
  for (int slen = ssize - del; slen > 0; slen -= 2) {
    if (s.substr(0, slen / 2) == s.substr(slen / 2, slen / 2)) {
      ans = slen;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
let lcs x y =
  let m = String.length x in
  let n = String.length y in
  let dp = Array.make_matrix (m + 1) (n + 1) 0 in
  for i = 1 to m do
    for j = 1 to n do
      dp.(i).(j) <-
        if x.[i-1] = y.[j-1] then dp.(i-1).(j-1) + 1
        else
          let x = dp.(i-1).(j) in
          let y = dp.(i).(j-1) in
          if x > y then x else y;
    done
  done;
  dp.(m).(n)

let () =
  let q = read_int () in
  for _ = 0 to q - 1 do
    let x = read_line () in
    let y = read_line () in
    lcs x y |> Printf.printf "%d\n"
  done

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

using namespace std;

int main(void) {

	int number;
	string str;
	cin >> str >> number;


	for (int i = 0; i<number; i++) {
		string com;
		cin >> com;

		if (com == "replace") {
			int n1, n2;
			string str2;
			cin >> n1 >> n2 >> str2;
			str.replace(n1, n2 - n1 + 1, str2);
		}
		else if (com == "reverse") {
			int n1, n2;
			string str_2;
			str_2 = str;
			cin >> n1 >> n2;
			for (int j = n1; j <= n2; j++) {
				str[j] = str_2[n2 + n1 - j];
			}
		}
		else if (com == "print") {
			int n1, n2;
			cin >> n1 >> n2;
			cout << str.substr(n1, n2 - n1 + 1) << endl;
		}
	}

	return 0;
}

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

const int mx=500*500+777;

int a[mx], b[mx], c[mx], d[mx];

int main() {
	int h,w; cin>>h>>w;
	int x[h+1][w+1];
	for (int i=1; i<=h; i++)
		for (int j=1; j<=w; j++)
			cin>>x[i][j];
	int k=0;
	for (int i=1; i<=h; i++) {
		for (int j=1; j<=w; j++) {
			if (x[i][j]%2==0)
				continue;
			if (j!=w)
				x[i][j+1]++, a[k]=i, b[k]=j, c[k]=i, d[k]=j+1, k++;
			else if(i!=h)
				x[i+1][j]++, a[k]=i, b[k]=j, c[k]=i+1, d[k]=j, k++;
		}
	}
	cout<<k<<"\n";
	for (int i=0; i<k; i++)
		cout<<a[i]<<" "<<b[i]<<" "<<c[i]<<" "<<d[i]<<"\n";
	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9+7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;


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

struct Edge {
	int to, cap, rev;
	Edge(int _to, int _cap, int _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, int from, int to, int cap, bool revFlag, int revCap) {
	G[from].push_back(Edge(to, cap, G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, G[from].size() - 1));
}

ll b[1010101];

void solve() {
	ll n;
	string s;
	cin >> n >> s;

	bool flag = false;
	REP(i, n - 1) {
		b[i] = abs(s[i] - s[i + 1]);
		if (b[i] == 1) flag = true;
	}
	
	if (!flag)	REP(i, n - 1) b[i] /= 2;//1がない場合は(0,2)->(0,1)にする

	ll ans = 0;
	REP(i, n-1) {
		if (b[i] == 1 && ((n - 2) & i) == i) {
			ans ^= 1;
		}
	}

	if (!flag) ans *= 2;//(0,1)->(0,2)

	cout << ans << en;


}

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

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}


Measured memory_bytes: 9116
#include<stdio.h>

#define M 100

struct gif{
  int k;
  int r[M];
};
typedef struct gif git;

int T[M][M]={};


int main(){
  int a,b,c,i,j;
  git A[M];
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&A[i].k);
    scanf("%d",&b);
    for(j=0;j<b;j++){scanf("%d",&c);T[i][c-1]=1;}
  }
  //for(i=0;i<a;i++){
  //j=0;
  //while(A[i].r[j]!=0){T[i][A[i].r[j]-1]=1;j++;}
  //}
  for(i=0;i<a;i++){
    for(j=0;j<a;j++){printf("%d",T[i][j]);if(j!=a-1)printf(" ");}
    printf("\n");
  }
}



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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    int a, b, k;
    cin >> a >> b >> k;

    for (int i = 0; i < k; i++)
    {
        if (i % 2 == 0)
        {
            if (a % 2)
            {
                a--;
            }
            b += a / 2;
            a /= 2;
        }
        else
        {
            if (b % 2)
            {
                b--;
            }
            a += b / 2;
            b /= 2;
        }
    }
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
function Main(input) {
  const args = input.split('\n');
  const n = args[0];
  const a = args[1].split(' ');
  const max = Math.max(...a);
  const min = Math.min(...a);
  console.log(max-min);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
//#include "bits/stdc++.h"
#include <atcoder/all>

using namespace std;
using namespace atcoder;
typedef long long ll;

/*
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
void Add(ll &pos,ll val){pos=mod(pos+val);}
void mod_print(ll k){
    ll P=50000;
    rep(y,1,P){
        ll x=mod(y*k);
        
        if(abs(x)<=P||x+P>=i_7){
            if(x+P>=i_7){
                x-=i_7;
            }
            cout<<x<<"/"<<y<<endl;
            //cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
*/

#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

typedef long double dd;
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
dd EPS=1E-12;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second

#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
//#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define all(c) c.begin(),c.end()
typedef vector<ll> vl;


//using mint = modint998244353;
using mint = modint1000000007;
//////////////////////////

int main(){fastio
    
    ll n,m;cin>>n>>m;
    scc_graph g(n);
    while(m--){
        ll a,b;cin>>a>>b;
        g.add_edge(a,b);
    }
    auto v=g.scc();
    cout<<v.size()<<endl;
    for(auto x:v){
        cout<<x.size()<<" ";
        for(auto y:x)cout<<y<<" ";
        cout<<endl;
    }
    
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
      cin >> a.at(i);
  }

  int AlicePoint = 0;
  int BobPoint = 0;

  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  for (int aliceDraw = 0; aliceDraw < N; aliceDraw += 2) {
      AlicePoint += a.at(aliceDraw);
  }
  for (int bobDraw = 1; bobDraw < N; bobDraw += 2) {
      BobPoint += a.at(bobDraw);
  }

  cout << AlicePoint - BobPoint << endl;
}

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

using namespace std;

int main(){
    long long N, P;
    cin >> N >> P;

    long long cnt0 = 0, cnt1 = 0;
    for (int i = 0; i < N; i++){
        int A;
        cin >> A;
        if (A % 2 == 0){
            cnt0 ++;
        }else{
            cnt1 ++;
        }
    }

    long long ALL = pow(2, N);
    long long ALL0 = pow(2, cnt0);

    long long a1;
    if (cnt1 != 0){
        a1 = pow(2, cnt1 - 1);
    }else{
        a1 = 0;
    }

    long long ans = ALL0 * a1;
    if (P == 0){
        ans = ALL - ans;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
int main() {
	ios_base::sync_with_stdio(false);
	ll a,b,c;
	cin>>a>>b>>c;
	if ((a&1)&(b&1)&(c&1)) {
		cout<<min(min(a*b,a*c),b*c)<<endl;
	}
	else cout<<0<<endl;
}

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

const int INF =1001001001;

int c[10][1005];

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i,h) cin >>s[i];
    int ans = INF;
    rep(div,1<<(h-1)){
        int g = 0;
        vector<int> id(h);
        rep(i,h){
            id[i]= g;
            if(div>>i&1) ++g;
        }
        ++g;
        rep(i,g)rep(j,w) c[i][j] = 0; //初期化
        rep(i,h)rep(j,w) c[id[i]][j] += (s[i][j]-'0');
        
        int num = g-1;
        vector<int> now(g);
        auto add=[&](int j){
            rep(i,g) now[i] += c[i][j];
            rep(i,g) if (now[i]>k) return false;
            return true;
        };
        rep(j,w){
            if (!add(j)){
                num++;
                now = vector<int>(g);
                if(!add(j)){
                    num = INF;
                    break;
                }
            }
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
fun readInts() = readLine()!!.split(' ').map(String::toInt)

fun main(args: Array<String>) {
    val (a, b, c, x, y) = readInts()
    val z = Math.min(x, y)
    var amt = if (0 < x - z) {
        Math.min(a, c + c) * (x - z)
    } else {
        Math.min(b, c + c) * (y - z)
    }
    amt += z * Math.min(a + b, c + c)
    println(amt)
}


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

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        h: usize, w: usize,
        s: [chars; h],
    }
    const INF: i64 = 1 << 40;
    let mut dp = vec![vec![INF; w]; h];
    dp[0][0] = if s[0][0] == '#' { 1 } else { 0 };
    for i in 0..h {
        for j in 0..w {
            if i + 1 < h {
                let cos = if s[i][j] == '.' && s[i + 1][j] == '#' {
                    1
                } else {
                    0
                };
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + cos);
            }
            if j + 1 < w {
                let cos = if s[i][j] == '.' && s[i][j + 1] == '#' {
                    1
                } else {
                    0
                };
                dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + cos);
            }
        }
    }
    puts!("{}\n", dp[h - 1][w - 1]);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#!/usr/bin/env python3

import heapq


def minimize_money(n, m, xs):
    pq = [-x for x in xs]
    heapq.heapify(pq)
    for _ in range(m):
        x = -heapq.heappop(pq)
        new_x = -(x // 2)
        heapq.heappush(pq, new_x)
    res = sum(-y for y in pq)
    return res


def main():
    n, m = (int(z) for z in input().split())
    xs = [int(z) for z in input().split()]
    res = minimize_money(n, m, xs)
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14180
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
    for(int t; cin >> t && t; )
	{
		int n, time = 0;
		cin >> n;
		
		for(int s, t; n-- && cin >> s >> t; ) time += t - s;
		
		if(t <= time) cout << "OK" << endl;
		else cout << t - time << endl;
	}
}

Measured memory_bytes: 0
import math

n, d = list(map(int, input().split()))
x = [list(map(int, input().split())) for i in range(n)]


dis = []
for i in range(n):
    for j in range(n):
        distanse = 0
        for k in range(d):
            distanse += abs(x[i][k]-x[j][k])**2
        dis.append(math.sqrt(distanse))

ans = 0
for i in dis:
    a = i
    if a.is_integer() == True:
        ans += 1
print(int((ans-n)/2))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>

typedef long long ll;
const ll MOD = 998244353;

using namespace std;


int main(){
    ll n, q;
    string s;
    cin >> n >> s >> q;
    set<int> mm[26];

    for(int i = 0; i < n; i++){
        mm[s[i]-'a'].insert(i+1);
    }

    for(ll i = 0; i < q; i++){
        int t;
        cin >> t;
    
        if(t == 1){
            ll c1;
            char c2;
            cin >> c1 >> c2;
            if(s[c1-1] != c2){
                mm[s[c1-1]-'a'].erase(c1);
                mm[c2-'a'].insert(c1);
                s[c1-1] = c2;
            }
        } else {
            ll l, r;
            cin >> l >> r;
            int ans = 0;
            for(int j = 0; j < 26; j++){
                auto it = mm[j].lower_bound(l);
                if(*it >= l && *it <= r){
                    ans++;
                }
            }
            cout << ans << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 24196
// AOJ 1175: And Then. How Many Are There?
// 2017.12.21 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <math.h>

typedef struct { int x, y, r, c; } T;
T d[25]; int n;
char rel[25][25];	// rel[i][j]???1??¨????????????i???j??????????????£??????j?????????????????¶???
typedef struct { int n, id[25]; } S;
S up[25];			// ?????????????????????????????°??¨??????
char none[16];
char visited[16777216];
int ans;

void dfs(int s, int del, int m)
{
	int i, j, k, a;

	if (m == 1) return;
	if (visited[s]) return;
	visited[s] = 1;
	for (i = 0; i < n; i++) {
		if (none[i]) continue;
		for (k = 0; k < up[i].n; k++) {
			a = up[i].id[k];
			if (!none[a]) break;
		}
		if (k != up[i].n) continue;

		for (j = i+1; j < n; j++) {
			if (none[j]) continue;
			if (d[j].c != d[i].c) continue;
			for (k = 0; k < up[j].n; k++) {
				a = up[j].id[k];
				if (!none[a]) break;
			}
			if (k != up[j].n) continue;

			if (del+2 > ans) ans = del+2;
			none[i] = none[j] = 1;
			dfs(s|(1<<i) | (1<<j), del+2, m-2);
			none[i] = none[j] = 0;
		}
	}
}

int main()
{
	int i, j;

	while (scanf("%d", &n) && n > 0) {
		for (i = 0; i < n; i++) scanf("%d%d%d%d", &d[i].x, &d[i].y, &d[i].r, &d[i].c);
		memset(rel, 0, sizeof(rel));
		memset(up, 0, sizeof(up));
		for (i = 0; i < n; i++) for (j = i+1; j < n; j++) {
			if (hypot(d[i].x-d[j].x, d[i].y-d[j].y) < d[i].r+d[j].r) {
				rel[i][j] = 1;
				up[j].id[up[j].n++] = i;
			}
		}

		ans = 0;
		memset(none, 0, sizeof(none));
		memset(visited, 0, sizeof(visited));
		dfs(0, 0, n);
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 18244
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=400;

int n;
int a[MAXN];

ll sum[MAXN+1];
ll dp[MAXN][MAXN];

ll solve() {
	sum[0]=0; REP(i,n) sum[i+1]=sum[i]+a[i];
	REP(i,n) dp[i][i]=0;
	FORE(len,2,n) REPE(i,n-len) {
		int j=i+len-1; dp[i][j]=LLONG_MAX;
		FORE(k,i,j-1) {
			dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]);
		}
		dp[i][j]+=sum[j+1]-sum[i];
	}
	return dp[0][n-1];
}

void run() {
	scanf("%d",&n);
	REP(i,n) scanf("%d",&a[i]);
	printf("%lld\n",solve());
}

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


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    vector<ll>a;
    for(int i=0;i<n;i++)
    {
        int c;
        cin>>c;
        a.push_back(c);
    }
    for(int i=0;i<n;i++)
    {
        a[i]-=(i+1);
    }
    sort(a.begin(),a.end());
    if(n%2==1)
    {
        int h = a[n/2];
        ll ans = 0;
        for(int i=0;i<n;i++)
        {
            ans += abs(a[i]-h);
        }
        cout<<ans<<endl;
    }
    else
    {
        int h = (a[n/2-1]+a[n/2])/2;
        ll ans1 = 0;
        for(int i=0;i<n;i++)
        {
            ans1 += abs(a[i]-h);
        }
        h = (a[n/2+1]+a[n/2])/2;
        ll ans2 = 0;
        for(int i=0;i<n;i++)
        {
            ans2 += abs(a[i]-h);
        }
        cout<<min(ans1,ans2)<<endl;
    }
    return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;
 
int main(){
    int n;
    cin >> n;
    vector<vector<long long> > P;
    REP(i,3) P.push_back(vector<long long>(n,0LL));
    REP(i,3) REP(j,n) cin >> P[i][j];
 
    sort(ALL(P[0]));
    sort(ALL(P[2]));
    // REP(i,3){
    //     REP(j,n)cout << P[i][j] << " ";
    //     cout << endl;
    // }
    // cout << "====" << endl;
    ll sum=0LL;
    REP(j,n){
        ll b=P[1][j];
        ll a_sum = upper_bound(ALL(P[0]), b-1)-P[0].begin();
        ll c_sum = P[2].end()-lower_bound(ALL(P[2]), b+1);
        // cout << b<<" " <<  a_sum << " " << c_sum << endl;
        sum+=a_sum*c_sum;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 2560