akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

public static partial class Program
{
    public static void Main()
    {
        var abc = CRL().ArrayInts();
        var k = CRL().ToInt();
        var sum = abc.Sum();
        var max = abc.Max();
        sum -= max;
        for (int i = 0; i < k; i++)
        {
            max *= 2;
        }

        sum += max;
        Console.WriteLine(sum);
    }
}

public static partial class Program
{
    //テンプレここから
    public static int Sigma(int n, int next = 1, int val = 0) => next > n ? val : Sigma(n, next + 1, val + next);  
    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);
    public static int GCD(int a, int b) => b == 0 ? a : GCD(b, a % b);
    public static long LCM(long a, long b) => a * b / GCD(a, b);
    public static int LCM(int a, int b) => a * b / GCD(a, b);
    public static string CRL() => Console.ReadLine();
    public static int ToInt(this double d) => (int) d;
    public static long ToLong(this double d) => (long) d;
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static int[] ArrayInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Diff(int a, int b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static readonly int[] Dx = new[] {0, -1, 0, 1};
    public static readonly int[] Dy = new[] {-1, 0, 1, 0};
    public const int Mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array) => array.OrderBy(x => x).ToArray();
    public static int[] Sort(this int[] array) => array.OrderBy(x => x).ToArray();
    public static long[] DSort(this long[] array) => array.OrderByDescending(x => x).ToArray();
    public static int[] DSort(this int[] array) => array.OrderByDescending(x => x).ToArray();
    public static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array);
    public static string Join(this IEnumerable<char> array, string sep = "") => string.Join(sep, array);

    public static string JoinToStr(this IEnumerable<int> array, string sep = "")
        => array.Select(x => x.ToString()).Join(sep);

    //テンプレここまで
}

Measured memory_bytes: 13396
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
  public static void main(String args[]) throws IOException{
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

   String original = br.readLine();//??????????????????
   int n = Integer.parseInt(br.readLine());


   for(int i = 0; i < n;i++){

     String[] order = br.readLine().split(" ");

      if( order[0].equals("print") ){

          String print = original.substring( Integer.parseInt(order[1]), Integer.parseInt(order[2])+1 );//substring????°????-1???????????????????????§+1??????
          System.out.println(print);

      }else if( order[0].equals("reverse") ){
    	  String left = original.substring( 0, Integer.parseInt(order[1]));//?????¢??????????????????????????´?????????????????????left??¨??????
    	  String right = original.substring(Integer.parseInt(order[2])+1 , original.length());//?????¢??????????????????????????´?????????????????????left??¨??????
    	  StringBuffer before = new StringBuffer( original.substring( Integer.parseInt(order[1]) , Integer.parseInt(order[2])+1 ) );//?????¢??????????????????????????????
    	  String reverse = before.reverse().toString();//reverse??§?????????????????¢
    	  original = left + reverse + right;//left????????¢??????????????????right????????????????????°?????????????????¨??????


      }else{

    	  String left = original.substring( 0, Integer.parseInt(order[1]));//????????????????????????????????´?????????????????????left??¨??????
    	  String right = original.substring(Integer.parseInt(order[2])+1 , original.length());//?????¢??????????????????????????´?????????????????????right??¨??????
    	  original = left + order[3] + right;//left???????????????????????????right????????????????????°?????????????????¨??????

      }
   }


  }
}

Measured memory_bytes: 25232
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()

bool rev(string s){
    string v(s.rbegin(),s.rend());
    return s==v;
}
int main() {
    string s;
    cin>>s;
    int n=s.size();
    
    if(rev(s)&&rev(s.substr(0,(n-1)/2))&&rev(s.substr((n+1)/2))){
        dunk("Yes");
    }
    else dunk("No");
    
    return 0;
    
    
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int,int>;

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

int N, M;
vector<P> G[10100], G2[10100];
P di[10100];

void dijkstra(){
    priority_queue<P, std::vector<P>, std::greater<P>> qu;

    for(int i=1;i<=N;++i){
        di[i] = std::make_tuple(1001001001, 1001001001, 252521);
    }
    
    di[1] = std::make_tuple(0, 0, 252521);
    qu.emplace(0, 0, 1);

    while(!qu.empty()){
        int dd, cc, v;
        tie(dd, cc, v) = qu.top();
        qu.pop();

        if(fst(di[v]) < dd){
            continue;
        }

        for(auto& p : G[v]){
            int u, d, c;
            tie(u, d, c) = p;

            if(fst(di[u]) > dd + d){
                di[u] = std::make_tuple(dd + d, cc + c, 252521);
                qu.emplace(fst(di[u]), snd(di[u]), u);
            }
        }
    }
}

void makeG2(){
    for(int i=1;i<=N;++i){
        for(auto& p : G[i]){
            int v, d, c;
            tie(v, d, c) = p;

            if(fst(di[v]) == fst(di[i]) + d){
                G2[v].emplace_back(i, d, c);
            }
        }
    }
}

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

    while(true){
        std::cin >> N >> M;
        if(N == 0){return 0;}

        for(int i=1;i<=N;++i){
            G[i].clear();
            G2[i].clear();
        }
        
        for(int i=0;i<M;++i){
            int u, v, d, c;
            std::cin >> u >> v >> d >> c;

            G[u].emplace_back(v, d, c);
            G[v].emplace_back(u, d, c);
        }

        dijkstra();
        makeG2();

        int res = 0;
        for(int i=2;i<=N;++i){
            int mn = 252521;
            for(auto& p : G2[i]){
                mn = min(mn, thd(p));
            }

            res += mn;
        }
    
        printf("%d\n", res);
    }
}

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

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
#define sbp(p, n) rep(i, n) { int a, b; scanf("%d %d", &a, &b); p[i] = make_pair(a, b); }
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
  //int a, b, c; cin >> a >> b >> c;
  //int n, k; cin >> n >> k;
  char a; cin >> a;
  if(a == 'A') cout << 'T' << endl;
  if(a == 'C') cout << 'G' << endl;
  if(a == 'G') cout << 'C' << endl;
  if(a == 'T') cout << 'A' << endl;
  //int ans = 0;
  //cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
    string str,str1,str2;
    cin>> str;
    
    str1 = str.substr(0,2);
    str2 = str.substr(2,2);
  
    if (stoi(str1)<=12 && stoi(str1)>0 && stoi(str2)<=12 && stoi(str2)>0)
        cout<<"AMBIGUOUS";   
    else if(stoi(str1)<=12 && stoi(str1)>0)
        cout<<"MMYY";
    else if(stoi(str2)<=12 && stoi(str2)>0)
        cout<<"YYMM";
    else
        cout<<"NA";
   
    return 0;
}

Measured memory_bytes: 3588
#include <stdio.h>

int main()
{
	int S,h,m,s;

	scanf("%d",&S);

	h=S/3600;
	S=S-h*3600;
	m=S/60;
	S=S-m*60;
	s=S;

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

	return 0;

}

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

#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
const int  p=31,po=1,N=2e5+1, M=(ll)1e9+1 ;
const int mod = 998244353 ;
// struct node{
//   ll prefixsum,suffixsum,bettersum,totalsum;
//   void create(ll val){
//     prefixsum=suffixsum=bettersum=val;
//   }
//   void Merge(node& a,node &b){
//     prefixsum=max(a.prefixsum,a.totalsum+b.prefixsum);
//     suffixsum=max(b.suffixsum,a.suffixsum+b.sum);
//     totalsum=a.totalsum+b.totalsum;
    
//   }
// }
//ll dp[2][100];
vl compute(string s){
        vl has(s.length());
        ll i;

        for(i=0;i<s.length();i++){
            if(i==0){
                has[i]=((s[i]-'a'+1))%mod;
            }
            else
                has[i]=(has[i-1]*p + (s[i]-'a'+1))%mod;
        }
        return has;
}
// ll g[N][N],keep[N*N];
vl g[N],a(N),gc(N),dist(N,1),vis(N,0);

// ll solve(ll l,ll r){
//   if(l==r)
//     return l;
//   ll n1=solve(l,(l+r)/2);
//   ll n2=solve((l+r)/2 +1,r);
//   if(g[n1][n2]>0){
//     keep[g[n1][n2]]=true;
//     return n1;
//   }
//   else{
//     keep[g[n2][n1]]=true;
//     return n2;
//   }
  
// }
ll ma=0;
void dfs(ll x){
  vis[x]=1;
  // cout << x << " ";
  for(auto &it:g[x]){
    if(vis[it])
      continue;
    dfs(it);
    if(__gcd(a[x],gc[it])!=1){
      if(dist[x]<1+dist[it]){
        dist[x]=1+dist[it];
        gc[x]=__gcd(a[x],gc[it]);
      }
    }
  }
  // if(a[x]!=1)
    ma=max(ma,dist[x]);
  // return ma;
}
int main(){
 ios_base::sync_with_stdio(0);
   vl a(4),b={1,4,7,9};
   ll i;
   for(i=0;i<4;i++)
    cin >> a[i];
   sort(a.begin(),a.end());
   for(i=0;i<4;i++){
     if(a[i]!=b[i]){
       cout << "NO";
       return 0;
     }
   }
    cout << "YES"; 
     
    return 0;
}

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

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

void solve() {
    Int n;
    cin >> n;
    vector<Int> a(n), b(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (Int i = 0; i < n; i++) {
        cin >> b[i];
    }
    sort(all(b), greater<Int>());
    Int l = 0;
    Int r = n - 1;
    for (Int i = 0; i < n; i++) {
        if (a[i] == b[i]) {
            if (b[l] != b[i] and a[l] != b[i]) {
                swap(b[l], b[i]);
                l++;
            } else if (b[r] != b[i] and a[r] != b[i]) {
                swap(b[r], b[i]);
                r--;
            }
        }
    }
    for (Int i = 0; i < n; i++) {
        if (a[i] == b[i]) {
            print("No");
            return;
        }
    }
    print("Yes");
    print(b);
}

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


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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

signed main(){
	int n=read();
	vi a;
	REP(i,n)a.PB(read());
	sort(ALL(a));
	vi s;
	int last=0;
	REP(i,n)
		s.PB(last+=a[i]);
	int ans=0;
	REP(i,n){
		int x=i;
		REP(_,30){
			int y=upper_bound(ALL(a),s[x]*2)-a.begin();
			if(y==n){
				x=n;
				break;
			}
			x=y-1;
		}
		if(x==n)ans++;
	}
	cout<<ans<<endl;
}


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

const int64_t mod=1e9+7;
int64_t n,fac[100005],Free[100005];

int64_t Mul(int64_t n,int64_t k)
{
    if(k==0)
        return 1;
    int64_t tmp=Mul(n,k/2);
    if(k%2==0)
        return tmp*tmp%mod;
    return tmp*tmp%mod*n%mod;
}

int64_t C(int64_t n,int64_t k)
{
    if(n<k)
        return 0;
    int64_t A=fac[n];
    int64_t B=fac[k]*fac[n-k]%mod;
    return A*Mul(B,mod-2)%mod;
}

int main()
{
    cin>>n;
    fac[0]=1;
    for(int64_t i=1;i<=n+1;i++)
        fac[i]=fac[i-1]*i%mod;
    int64_t x,tmp;
    for(int64_t i=1;i<=n+1;i++)
    {
        cin>>x;
        if(Free[x]==0)
            Free[x]=i;
        else
            tmp=(Free[x]-1)+(n+1-i);
    }
    for(int64_t i=1;i<=n+1;i++)
        cout<<(C(n+1,i)-C(tmp,i-1)+mod)%mod<<"\n";
}


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

int main() {
    int N;
    cin >> N;
    int L0 = 2, L1 = 1;
    if (N == 1) {
        cout << L1 << endl;
    }
    // else if (N == 2) {
    //     cout << L1 << endl;
    // }
    else {
        long long L = L1 + L0;
        long long L_1 = L1;
        long long L_2 = L0;
        for (int i = 0; i < N-1; i++) {
            L = L_1 + L_2;
            L_2 = L_1;
            L_1 = L;
        }
        
        cout << L << endl;
        
    }
    
    
    
}

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

int H, W;

int main(void){
	int i, j;
	char name[6];

	scanf("%d%d", &H, &W);
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			scanf("%s", name);
			if (strcmp(name, "snuke") == 0) {
					printf("%c%d\n", 'A' + j, i + 1);
					return 0;
			}
		}
	}
}

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

vector<string> bubbleSort(vector<string>& a, int n) {
    vector<string> b(a.size());
    copy(a.begin(), a.end(), b.begin());
    for (int i=0; i<n; i++) {
        for (int j=n-1; j>0; j--) {
            if (b[j][1] < b[j-1][1]) {
                swap(b[j], b[j-1]);
            }
        }
    }
    for (int i=0; i<n-1; i++) cout << b[i] << " ";
    cout << b[n-1] << endl;

    return b;
}

vector<string> selectionSort(vector<string>& a, int n) {
    vector<string> b(a.size());
    copy(a.begin(), a.end(), b.begin());
    for (int i=0; i<n; i++) {
        int min_j = i;
        for (int j=i; j<n; j++) {
            if (b[j][1] < b[min_j][1]) {
                min_j = j;
            }
        }
        swap(b[i], b[min_j]);
    }
    for (int i=0; i<n-1; i++) cout << b[i] << " ";
    cout << b[n-1] << endl;

    return b;
}

bool isStable(vector<string>& a, vector<string>& b, int n) {
    for (int i=0; i<n; i++) {
        for (int j=i+1; j<n; j++) {
            for (int x=0; x<n; x++) {
                for (int y=x+1; y<n; y++) {
                    if (a[i][1] == a[j][1] && a[i] == b[y] && a[j] == b[x]) {
                        return false;
                    }
                }
            }
        }
    }
    return true;
}

int main() {
    int N;
    cin >> N;
    vector<string> A(N);
    for (int i=0; i<N; i++) cin >> A[i];

    vector<string> B = bubbleSort(A, N);
    if (isStable(A, B, N)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }
    vector<string> S = selectionSort(A, N);
    if (isStable(A, S, N)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }

    return 0;
}



Measured memory_bytes: 3216
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)


using namespace std;


template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}

ll dx8[8]={1,0,-1,0,1,-1,1,-1};
ll dy8[8]={0,1,0,-1,1,-1,-1,1};
ll dx4[4]={0,0,1,-1};
ll dy4[4]={1,-1,0,0};
ll N=1e5+5;



int main(){
    IOS;
    make2(ll,n,y);
    bool f=0; y/=1000;
    for(ll c=0;c<=n;c++){
        if((5*(n+c)-y)%4==0 && (y-n-9*c)%4==0 && y-n-9*c>=0 && 5*(n+c)-y>=0) {
            cout<<c<<" "<<(y-n-9*c)/4<<" "<<(5*(n+c)-y)/4<<endl; f=1; break;
        }
    }
    if(!f) cout<<"-1 -1 -1 \n";



    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535897932;
const ll MOD = 1000000007;

int main()
{
    ll n;
    cin >> n;
    ll ans = (n * (n - 1)) / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long int max(long long a,long long b){
	if(a>b){
		return a;
	}else{
		return b;
	}
}

int main(){
	int N;
	long long answer=0;
	vector <long long>array;
	vector <long long>twice;
	vector <long long>fourth;
	cin >> N;
	for(int i=0;i<N;i++){
		long long a;
		cin >> a;
		array.push_back(a);
	}
	sort(array.begin(),array.end());
	
	long long memo=0;
	for(int i=0;i<array.size();i++){
		if(memo!=array[i]){
			memo=array[i];
		}else{
//			cout << "twice " << array[i] << endl;
			twice.push_back(array[i]);
			memo=0;
		}
	}
	
	memo=0;
	for(int i=0;i<twice.size();i++){
		if(memo!=twice[i]){
			memo=twice[i];
		}else{
//			cout << "fourth " << twice[i] << endl;
			fourth.push_back(twice[i]);
		}
	}
	
	if(fourth.size()>0){
		answer=max(answer,fourth[fourth.size()-1]*fourth[fourth.size()-1]);
//		cout << fourth[fourth.size()-1]*fourth[fourth.size()-1] << endl;
	}
	if(twice.size()>0){
		long long a=0,b=0;
		a=twice[twice.size()-1];
		for(int i=twice.size()-1;i>=0;i--){
			b=twice[i];
//			cout << "b " <<  b<<endl;
			if(a!=b){
				break;
			}
		}
//		cout << a << " "<<b << endl;
		answer=max(answer,a*b);
//		cout << a*b << endl;
	}
	cout << answer << endl;
	
	return 0;
}


Measured memory_bytes: 2292
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;

int main()
{
    ll N, K;
    cin >> N >> K;
    vll x(N),S(N);
    rep(i,N)
    {
        cin >> x[i];
        if(i>0)
        {
            ll dis = abs(x[i] - x[i - 1]);
            S[i] = S[i - 1] + dis;
        }
        else
        {
            S[0] = abs(x[i]);
        }
    }
    ll ans = S[N-1]+1,tmp=0,start=0;
    rep(i, N - K+1)
    {
        tmp = S[i + K - 1] - S[i] + min(abs(x[i]),abs(x[i+K-1]));
         if (ans > tmp)
        {
          //  start = i;
            ans = tmp;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1792
<?php
// Your code here!
 $n = trim(fgets(STDIN));
 
 $ans = ['ac' => 0, 'wa' => 0,'tle' => 0,'re' => 0];
 
 for($i=0;$i<$n;$i++){
      $target = trim(fgets(STDIN));
      if($target == 'AC'){
          $ans['ac'] += 1;
      }elseif ($target == 'WA') {
          $ans['wa'] += 1;
      }elseif ($target == 'TLE') {
          $ans['tle'] += 1;// code...
      }elseif ($target == 'RE') {
          $ans['re'] += 1;// code...
      }

 }
 echo 'AC x '.$ans['ac']."\n";
 echo 'WA x '.$ans['wa']."\n";
 echo 'TLE x '.$ans['tle']."\n";
 echo 'RE x '.$ans['re']."\n";

?>


Measured memory_bytes: 16028
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
inline int gcd(int a,int b) {
    while(b^=a^=b^=a%=b);
    return a;
}
int main()
{
    int k,ans=0,temp;
    string s;
    cin>>k;
    
    for(int a=1;a<=k;a++)
        for(int b=1;b<=k;b++)
            for(int c=1;c<=k;c++)
                ans=ans+gcd(a,gcd(b,c));
    
    cout<<ans<<endl;
    return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    i32 n; cin >> n;
    vi a(n), b(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];

    i32 A = 0, B = 0;
    rep(i,n) {
        if(a[i] > b[i]) A += a[i]-b[i];
        if(b[i] > a[i]) B += (b[i]-a[i])/2;
    }
    cout << (B >= A ? "Yes" : "No") << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 384
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <cassert>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

void solve()
{
    int n;
    scanf("%d", &n);
    vector<pair<ll, ll> > z;
    int i;
    for (i = 0; i < n; i++) {
        ll a, b;
        scanf("%lld%lld", &a, &b);
        z.push_back(make_pair(b, a));
    }
    sort(z.begin(), z.end());

    ll t = 0;
    for (i = 0; i < n; i++) {
        t += z[i].second;
        if (t > z[i].first) {
            printf("No\n"); return;
        }
    }
    printf("Yes\n");
    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 6384
n = int(input())
h = list(map(int, input().split()))
count = 1
if n == 1:
    print(count)
else:
    for i in range(1,n):
        for j in range(0, i):
            if h[j] > h[i]:
                break
        else:
            count += 1
    print(count)

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll a,b,n; cin >> a >> b >> n;
    ll ans = min(b-1,n);
    ll res = (a*ans)/b - a*(ans/b);
    out(res);
}


Measured memory_bytes: 3636
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }




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


int main(){
    ll N;
    cin >> N;

    ll A, B, C;
    ll cnt = 0;
    for(ll a = 1; a < N; a++){
        for (ll b = 1; a * b < N; b++){
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3632
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,m;
	cin>>n>>m;
	vp in(m);
	rep(i,m)cin>>in[i].second>>in[i].first;
	sort(all(in));
	rep(i,m)swap(in[i].first,in[i].second);
	int out=0;
	int t=-1;
	rep(i,m){
		if(t<=in[i].first){
			out++;
			t=in[i].second;
		}
	}
	cout<<out<<endl;
}







Measured memory_bytes: 1024
from collections import defaultdict
d1 = defaultdict(list)
d2 = defaultdict(list)
S = input()
T = input()
N = len(S)
for i in range(N):
    d1[S[i]].append(i)
for i in range(N):
    d2[T[i]].append(i)
val1 = d1.values()
val2 = d2.values()
val1 = list(val1)
val2 = list(val2)
val1.sort()
val2.sort()
if val1 == val2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 21040
import java.util.Scanner;

//Where's Your Robot?
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int[][] move = {{1,0},{0,1},{-1,0},{0,-1}};
		while(true){
			int c = sc.nextInt();
			int r = sc.nextInt();
			if((r|c)==0)break;
			int ri = 1;
			int rj = 1;
			int dir = 0;
			while(true){
				String cmd = sc.next();
				if("STOP".equals(cmd)){
					System.out.println(rj+" "+ri);break;
				}
				if("RIGHT".equals(cmd))dir=(dir+1)%4;
				else if("LEFT".equals(cmd))dir=(dir+3)%4;
				else if("FORWARD".equals(cmd)){
					int k = sc.nextInt();
					while(k--!=0){
						int ni = ri+move[dir][0];
						int nj = rj+move[dir][1];
						if(1<=ni&&ni<=r&&1<=nj&&nj<=c){
							ri = ni;
							rj = nj;
						}
						else break;
					}
				}
				else{
					int k = sc.nextInt();
					while(k--!=0){
						int ni = ri+move[(dir+2)%4][0];
						int nj = rj+move[(dir+2)%4][1];
						if(1<=ni&&ni<=r&&1<=nj&&nj<=c){
							ri = ni;
							rj = nj;
						}
						else break;
					}
				}
			}
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419194545;

int main() { 

    ll N; cin >> N;
    ll ans = N;
    map<ll, ll> mp;
    map<ll, ll> mp2;

    for(ll i = 0; i < N; i++){
        ll t; cin >> t;
        mp[t]++;
        if(mp[t] == 3){
            mp[t] = 1;
            ans -= 2;
        }
    }

    ll cn = 0;
    auto begin = mp.begin(); auto end = mp.end();
    for(auto iter = begin; iter != end; iter++){
        if(iter->second == 2){
            cn++;
        }
    }
    //cout << mp2[2] << endl;
    //2個残ったやつをどう消すか
    if(cn % 2 == 0){
        ans -= cn;
    }else{
        ans -= cn + 1;
    }

    cout << ans << endl;

}

Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long max = sc.nextLong();
		boolean flag = false;
		boolean ans = true;
		for(int i = 1; i < n; i++) {
			long tmp = sc.nextLong();
			long sub = tmp - max;
			if(sub == -1 && !flag) {
				flag = true;
				max = tmp;
			} else if(sub > 0) {
				flag = false;
				max = tmp;
			} else if(sub < -1) {
				ans = false;
				break;
			} else if(sub == -1 && flag) {
				ans = false;
				break;
			}
		}
		if(ans) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 48540
n = gets.to_i
as = n.times.map { gets.to_i }

counts = Hash.new(0)
as.each do |a|
  counts[a] += 1
end
keys = counts.keys.sort
max = keys.last

as.each do |a|
  if a == max && counts[max] < 2
    puts keys[-2]
  else
    puts max
  end
end


Measured memory_bytes: 15380
N,*as=$<.read.split.map(&:to_i)

as.unshift(0)
arr = [0] * (N+1)
i = as.length-1
while 1 <= i
  b = 0
  (i*2).step(N,i) do |j|
    b ^= arr[j]
  end
  arr[i] = b ^ as[i]
  i -= 1
end

sum = 0
ret = []
arr.each.with_index do |a,i|
  if a == 1
    sum += 1
    ret << i
  end
end

puts sum
puts ret.join(' ') unless ret.empty?


Measured memory_bytes: 24316
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}

vector< int > divisor(int n) {
  vector< int > ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret),greater<int>());
  return (ret);
}

int n;int g[510][510];

void f(int s, int e, int ind){
  if(e-s <= 1)return;
  repd(i,s,(e+s)/2){
    repd(j,(e+s)/2,e){
      g[i][j] = ind;

    }
  }
  //cout << s << " " << e << " " << ind << endl;
  f(s,(e+s)/2,ind+1);
  f((e+s)/2,e, ind+1);
}

signed main(){
  cin>>n;
  f(0,n, 1);
  rep(i,n){
    repd(j,i+1,n){
      cout << g[i][j] << (j == n-1 ? "\n" : " ");
    }
  }
}


Measured memory_bytes: 2432
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };



void solve() {
    ll a, b, c, d, e , m, n, k, x,l,r;
    string s;
    ll ans = 0;
    double dans = 0;
    string sans = "Yes";
    vector<ll> re;
    vector<ll> de;

    cin >> n >> m >> c;

    ll hoge[20];

    rep(i,m) cin >> hoge[i];

    rep(i,n){
        ll sum = 0;

        rep(j,m){
            ll tmp;
            cin >> tmp;

            sum += tmp * hoge[j];
        }
        sum += c;

        if(sum > 0)ans++;
    }

    
    std::cout << ans << endl; 

    // std::cout << sans << endl; 
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

Measured memory_bytes: 256
import heapq

n, m = map(int, input().split())
ls = [list(map(int, input().split())) for _ in range(n)]
ls.sort(key=lambda x: x[0])

q = []
res = 0
index = 0
for i in range(1, m + 1):
    while index < n and ls[index][0] <= i:
        heapq.heappush(q, -ls[index][1])
        index += 1
    if len(q) > 0:
        res += -heapq.heappop(q)
print(res)

Measured memory_bytes: 79064
N,K = map(int,input().split())
x = list(map(int,input().split()))

result = []
for i in range(N-K+1):
    s,g = i,i+K-1
    result.append(abs(x[s]) + abs(x[s] - x[g]))
    result.append(abs(x[g]) + abs(x[g] - x[s]))
result.sort()
print(result[0])

Measured memory_bytes: 14252
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define ll long long int
#define vec vector
#define forn(a) for(ll a=0; a<n; a++)
#define all(x) x.begin(), x.end()
#define deb(x) cerr<<#x<<" = "<<x<<endl

using namespace std;

int main() {
    IOS;

    int a, b, c; cin>>a>>b>>c;

    int r = min(c, a-b);
    
    cout<<c-r<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<utility>
#include<string>

using namespace std;

main(){
  int n,i,j,l,temp;
  string b;
  while(getline(cin,b)){
    while(1){
      for(i=0;i<b.size();i++){
	if(isalpha(b[i])){
	  if(b[i]=='z'){
	    b[i]='a';
	  }
	  else{
	    b[i]=b[i]+1;
	  }
	}
      }
      if(b.find("the")!=-1 || b.find("that")!=-1 || b.find("this")!=-1){
	cout << b <<endl;
	break;
      }
    }
  }
}

Measured memory_bytes: 0
#include<stdio.h>
#define N 100
int main(){

  int n,i,j,x[N],temp,count=0;

  scanf("%d",&n);

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

  for (i = 0; i < n - 1; i++) {
    for (j = n - 1; j > i; j--) {
      if (x[j - 1] > x[j]) {  /* 前の要素の方が大きかったら */
	temp = x[j];        /* 交換する */
	x[j] = x[j - 1];
	x[j - 1]= temp;
	count++;
      }
    }   
  }
  for(i=0;i<n-1;i++) printf("%d ",x[i]);
  printf("%d\n",x[n-1]);
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;


public class Main {

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

		int[][] A = new int[N+1][3];
		for(int i = 1 ; i <= N ; i++){
			for(int j = 0 ; j < 3 ; j++){
				A[i][j] = sc.nextInt();
			}
		}

		A[0][0] = 0;
		A[0][1] = 0;
		A[0][2] = 0;

		sc.close();
		int count = 0;
		for(int i = 1 ; i <= N ; i++){
			int tmp = Math.abs(A[i][1]-A[i-1][1]) + Math.abs(A[i][2] - A[i-1][2]);
			int tmp2 = Math.abs(A[i][0]-A[i-1][0]);

			//System.out.println("tmp : " +tmp);
			//System.out.println("tmp2 : " +tmp2);

			if((tmp2%2 == tmp%2) && tmp2 >= tmp){
				count++;
			}
		}

		if(count == N){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 97088
#include <iostream>

using namespace std;

int main() {
	int r, g, b;
	cin >> r >> g >> b;
	int kk = r * 100 + g * 10 + b;
	if (kk % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const int mod=1e9+7;
int n,k,a,b;
ll qpow(ll x,ll y)
{
    ll ans=1,base=x;
    while(y)
    {
        if(y&1)ans=ans*base%mod;
        base=base*base%mod;
        y=y>>1;
    }
    return ans;
}
ll Ca(int n,int m)
{
    m=min(m,n-m);
    ll down=1,up=1;
    for(int i=1;i<=m;i++) down=down*i%mod;
    for(int i=n;i>n-m;i--) up=up*i%mod;
    return up*qpow(down,mod-2)%mod;
}
int main()
{
    scanf("%d%d%d",&n,&a,&b);
    ll ans=qpow(2,n);
    ans=(ans+mod-Ca(n,a))%mod;
    ans=(ans+mod-Ca(n,b))%mod;
    printf("%lld",ans-1);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

double n,m,d;

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

  if(d==0){
    printf("%.10lf\n",(m-1)/n);
  }
  else{
    printf("%.10lf\n",2*(m-1)*(n-d)/(n*n));
  }

  return 0;
}

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

int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        mp[a]++;
    }
    int ans = 0;
    for (auto x : mp) {
        if (x.second % 2 != 0) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11

int main()
{
    string s; cin >> s;
    int n = s.size();
    rep(i,n){
        if(s[i] == '?') cout << 'D';
        else cout << s[i];
    }
}

Measured memory_bytes: 3720
import sys
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())

a, b, c, d = nm()

if b <= c or d <= a:
    print(0)
else:
    print(min(b, d) - max(a, c))


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <functional> 
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <utility>
//#include <cmath>
#include <cstdlib>

using namespace std;

int main(){

    int n;
    cin >> n;

    vector<int> a(8,0);
    int max = 0,ans =0;
    for(int i=0;i<n;i++){
        int r;
        cin >> r;
        if(r >= 3200) max++;
        else if(a[r/400] == 0){
            a[r/400] = 1;
            ans++;
        }
    }
  	if(ans == 0){
      	cout << "1" << " " <<  max;
      	return 0;
    }
    cout << ans << " " << ans + max;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		long a[]=new long[k+1];
		for(int i=1;i<=k;i++) {
		a[i]=sc.nextLong();
		}
		long n[]=new long[k+1];
		long N[]=new long[k+1];
		n[k]=2;
		N[k]=2;
		for(int i=k;i>0;i--) {
			n[i-1]=Math.max(n[i],(n[i]+a[i]-1)/a[i]*a[i]);
			N[i-1]=N[i]/a[i]*a[i]+a[i]-1;
					}
		if(N[0]<n[0])	System.out.println(-1);
		else	System.out.println(n[0]+" "+N[0]);

	}
}


Measured memory_bytes: 58088
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

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

int saiki(int count,int dirx,int diry,vector< vector<int> > map,int x,int y){
    int res = 11;
    while(true){
	x += dirx;
	y += diry;
	if(x<0||x>=w||y<0||y>=h){
	    return 11;
	}
	if(map[y][x] == 1){
	    map[y][x] = 0;
	    break;
	}else if(map[y][x] == 3){
	    return count;
	}
    }
    if(count == 10 ) return 11;
    x -= dirx;
    y -= diry;
    for(int i=0;i<4;i++){
	if(x+dx[i]>-1&&x+dx[i]<w&&y+dy[i]>-1&&y+dy[i]<h&&map[y+dy[i]][x+dx[i]] != 1){
	    res = min(res,saiki(count+1,dx[i],dy[i],map,x,y));
	}
    }
    return res;
}


int main(){

    
    int temp;
    int x,y;
    vector< vector<int> > map;
    while(true){
    cin >> w >> h;
    if(w == 0 && h==0) break;
    for(int i=0;i<h;i++){
	map.push_back(vector<int>());
	for(int j=0;j<w;j++){
	    cin >> temp;
	    map[i].push_back(temp);
	    if(temp == 2){
	       	x = j;
		y = i;
	    }
	}
    }
    int res=11;
    for(int i=0;i<4;i++){
	if(x+dx[i]>-1&&x+dx[i]<w&&y+dy[i]>-1&&y+dy[i]<h&&map[y+dy[i]][x+dx[i]] != 1){
	    res = min(res,saiki(1,dx[i],dy[i],map,x,y));
	}
    }
    if(res > 10) res = -1;
    cout << res << endl;
    map.clear();
    }

    return 0;
}

Measured memory_bytes: 1276