akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

vector<int> get_inverse(vector<int>& nums) {
    vector<int> b_search;
    vector<int> smaller;
    for (int i = nums.size() - 1; i >= 0; i--) {
        auto it = std::lower_bound(b_search.begin(), b_search.end(), nums[i]);
        auto index = distance(b_search.begin(), it);
        b_search.insert(b_search.begin() + index, nums[i]);
        // cout << "index: " << index << endl;
        smaller.push_back(index);
    }
    reverse(smaller.begin(), smaller.end());
    // for(int num: smaller)
    //    cout << num << " ";
    return smaller;
}

int main() {
    int n;
    ll k = 0;
    cin >> n >> k;

    vector<int> arr(n, 0);
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    ll mod = 1e9 + 7;
    vector<int> arr2 = arr;
    reverse(arr2.begin(), arr2.end());

    vector<int> nxt = get_inverse(arr);
    vector<int> pre = get_inverse(arr2);
    reverse(pre.begin(), pre.end());
    ll ans = 0;
    /*
    for(int num: nxt)
        cout << num << " ";
    cout << endl;
    for(int num: pre)
        cout << num << " ";
    */
    // 1 ~ K
    // K*(K-1) / 2;
    ll fac = (k*(k-1) / 2) % mod;
    for(int i = 0; i < n; i++) {
        ll sum = (nxt[i] + pre[i]) % mod;
        ans += sum * fac;
        ans %= mod;
        ans += (k * nxt[i]);
        ans %= mod;
    }
    cout << ans << endl;



    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;

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

	int x, t;
	cin >> x >> t;
	if (x - t > 0) {
		cout << x - t << endl;
	}
	else {
		cout << '0' << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        n = input()
        for i in range(n):
            o = raw_input()
            m = raw_input()
            for c in reversed(o):
                if c == 'J':
                    m = m[-1] + m[:-1]
                elif c == 'C':
                    m = m[1:] + m[0]
                elif c == 'E':
                    if len(m) % 2 == 0:
                        m = m[len(m)/2:] + m[:len(m)/2]
                    else:
                        m = m[len(m)/2+1:] + m[len(m)/2] + m[:len(m)/2]
                elif c == 'A':
                    m = m[::-1]
                elif c == 'P':
                    tmp = ''
                    for j in range(len(m)):
                        if m[j].isdigit():
                            d = int(m[j]) - 1
                            if d < 0:
                                d += 10
                            tmp += str(d)
                        else:
                            tmp += m[j]
                    m = tmp
                elif c == 'M':
                    tmp = ''
                    for j in range(len(m)):
                        if m[j].isdigit():
                            d = int(m[j]) + 1
                            if d > 9:
                                d -= 10
                            tmp += str(d)
                        else:
                            tmp += m[j]
                    m = tmp
            print m
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

Measured memory_bytes: 4680
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(a):
    if a%2==0:
        return int(a)
    else:
        return a*2
# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    return int(line)

def main():
    n = readQuestion()
    answer = solve(n)
    print(answer)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long long n,Ans[100],a[100],vis[100],have=0,OUT[100];
long long c1[100],c2[100],AA=0;
long long ss;
char s[100];
long long BEST()
{
	long long tmp1=0,tmp2=0;
	for (long long i=1;i<=n;i++) 
	{
		tmp1=tmp1*10+Ans[i];
		tmp2=tmp2*10+OUT[i];
	}
	long long ck1=min(abs(tmp1-AA),ss*2-abs(tmp1-AA));
	long long ck2=min(abs(tmp2-AA),ss*2-abs(tmp2-AA));
	if (ck1>ck2) return 1;
	if (ck1<ck2) return 0;
	if (tmp1<tmp2) return 1;
	else return 0;
}
void DO()
{
	for (long long i=1;i<=n;i++) OUT[i]=Ans[i];
	return;
}
void DFS(long long dep,long long tag)
{
	if (dep>n)
	{
		if (!have) DO(),have=1;
		else if (BEST()) DO();
		return;
	}
	long long tmp=a[dep];
	long long tmp1,tmp2;
	if (tag==0)
	{
		if (!vis[tmp])
		{
			Ans[dep]=tmp;
			vis[tmp]=1;
			DFS(dep+1,0);
			vis[tmp]=0;
			Ans[dep]=0;
		}
		tmp1=tmp-1;
		while (vis[tmp1]&&tmp1-1>=0) tmp1--;	
		if (tmp1>=0&&!vis[tmp1])
		{
			Ans[dep]=tmp1;
			vis[tmp1]=1;
			DFS(dep+1,1);
			vis[tmp1]=0;
			Ans[dep]=0;
		}
		tmp2=tmp+1;
		while (vis[tmp2]&&tmp2+1<=9) tmp2++;
		if (tmp2<=9&&!vis[tmp2])
		{
			Ans[dep]=tmp2;
			vis[tmp2]=1;
			DFS(dep+1,-1);
			vis[tmp2]=0;
			Ans[dep]=0;
		}
	}
	if (tag==1)
	{
		tmp=9;
		while (vis[tmp]) tmp--;
		Ans[dep]=tmp;
		vis[tmp]=1;
		DFS(dep+1,1);
		vis[tmp]=0;
		Ans[dep]=0;
	}
	if (tag==-1)
	{
		tmp=0;
		while (vis[tmp]) tmp++;
		Ans[dep]=tmp;
		vis[tmp]=1;
		DFS(dep+1,-1);
		vis[tmp]=0;
		Ans[dep]=0;
	}
	return;
}
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for (long long i=1;i<=n;i++) a[i]=s[i]-'0';
	ss=5;
	for (long long i=1;i<n;i++) ss=ss*10;
	for (long long i=1;i<=n;i++) AA=AA*10+a[i];
	Ans[1]=(a[1]+5)%10;
	vis[Ans[1]]=1;
	DFS(2,0);
	for (long long i=1;i<=n;i++) printf("%lld",OUT[i]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 3232
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <climits>
#define ll long long
#define MAX 25 * 1e13
#define N  200010

#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define EB(X) emplace_back(X)
#define REP(i,a) for(int i=0;i<(a);++i)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
#define VI vector<int>;

using namespace std;
int MOD = 1000000007;

int ok(int a,int b, int c) {
  if( a + b <= c ) return 0;
  return 1;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ret = 0;
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i,n) cin >>a[i];
  sort(a.begin(),a.end());
  for(int i = 0; i < n; i++ ){
    for(int j = i+1 ; j < n ; j++ ){
      //if( j > i+1 && a[j] == a[j-1] ) continue;
      for(int k = j+1 ; k < n ; k++ ){
        if( a[i] == a[j] || a[i] == a[k] || a[j] == a[k]) continue;
        //if( k > j+1 && a[k] == a[k-1] ) continue;
        if( ok(a[i],a[j],a[k] )) ret++;
      }
    }
  }
  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 3656
#include <stdio.h>
#define DECK 52

typedef struct Cards
{
	char suit;
	int rank;
	int flag;
}cards;

int main(void)
{
	int numofcard;

	cards cards[DECK];
	
	for(int i = 0; i < DECK; i++){
		if(i < 13){
			cards[i].suit = 'S';
			cards[i].rank = i + 1;
			cards[i].flag = 0;
		}
		else if(i < 26){
			cards[i].suit = 'H';
			cards[i].rank = i - 12 ;
			cards[i].flag = 0;
		}
		else if(i < 39){
			cards[i].suit = 'C';
			cards[i].rank = i - 25;
			cards[i].flag = 0;
		}
		else{
			cards[i].suit = 'D';
			cards[i].rank = i - 38;
			cards[i].flag = 0;
		}
	}
	
	scanf("%d", &numofcard);
	
	for(int k = 0; k < numofcard; k++){
		char ussuit;
		int usrank;
		scanf(" %c %d", &ussuit, &usrank);
		for(int j = 0; j < DECK; j++){
			if(cards[j].suit == ussuit && cards[j].rank == usrank) cards[j].flag = 1;
		}
	}
	
	//putchar('\n');
	for(int i = 0; i < DECK; i++){
		
		if(cards[i].flag == 0){
			printf("%c %d", cards[i].suit, cards[i].rank);
		}
		else{
			continue;
		}
		printf("\n");
	}
	//putchar('\n');
	return 0;
}



Measured memory_bytes: 2112
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner in=new Scanner(System.in);
		int N=in.nextInt();
		int[] arr=new int[N];
		for (int i=0;i<N;i++){
			arr[i]=in.nextInt();
		}
		int change=200*200*100;
		for (int i=-100;i<=100;i++){
			int temp=0;
			for (int j=0;j<N;j++){
				temp+=(i-arr[j])*(i-arr[j]);
			}
			if (temp<change){
				change=temp;
			}
		}
		System.out.print(change);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  

void solve(){
		int n ; cin >> n; 
		vi a(n), b(n);
		rep(i,0,n){
			cin >> a[i] >> b[i];
		}
		sort(all(a));sort(all(b));
		if(n&1)cout << b[n/2] - a[n/2] + 1 << endl;
		else cout << (b[n/2-1]-a[n/2-1]+b[n/2]-a[n/2]+1) << endl;
}
signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 6364
#include <iostream>
#include <queue>
#include <map>
#include <cmath>
#define INF 1e+9
using namespace std;

typedef pair<int,int> P;
struct edge{ int to,cost; };

int main(){
	int n,m,k,a,b,l,s;
	int d[3000];
	vector<edge> G[3000];
	queue<P> que; 
	cin >> n >> m >> k;
	for(int i = 0;i < n;i++) {
		d[i] = INF;
	}
	for(int i = 0;i < m;i++){
		cin >> a >> b >> l;
		G[a - 1].push_back({b - 1,l});
		G[b - 1].push_back({a - 1,l});
	}
	for(int i = 0;i < k;i++){
		cin >> s;
		que.push(P(s - 1,0));
	}
	while(!que.empty()){
		P p = que.front();que.pop();
		if(d[p.first] <= p.second) continue;
		d[p.first] = p.second;
		for(int i = 0;i < G[p.first].size();i++){
			if(d[p.first] + G[p.first][i].cost < d[G[p.first][i].to]) que.push({G[p.first][i].to,d[p.first] + G[p.first][i].cost});
		}
	}
	double ma = 0;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < G[i].size();j++){
			ma = max(ma,(double)(d[i] + d[G[i][j].to] + G[i][j].cost) / 2.0);
		}
	}
	cout << (int)round(ma) << endl;
	return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }
  sort(p.begin(), p.end());
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += p[i];
  }
  int border;
  if (sum % (4*M) == 0) border = sum / (4*M);
  else border = sum / (4*M) + 1;
  bool can = false;
  if (p[N - M] >= border) can = true;

  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
s = int(input())
k = int(input())

num1=1
ans = 0
for i in range(100):
	a =s//(10**(99-i))
	a -= (a//10)*10
	if a>1:
		ans = a
		break
	num1 +=a
	

if k < num1:
	ans = 1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	int n, t; cin >> n >> t;
	vi v(n); cin >> v;
	ll ans = t;
	REP(i, n - 1)
	{
		ans += min(v[i + 1] - v[i], t);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
	string str;
	cin >> str;
	sort (str.begin(), str.end());
	if (str[0] == str[1] && str[2] == str[3]) {
		if (str[1] != str[2]) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	} else {
		cout << "No" << endl;
	}
	return 0;
} 

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

a.sort(reverse=True)

i=0
icnt=0
ai=0
while icnt<=1 and i<=n-2:
    icnt=1
    while i<=n-2 and a[i]==a[i+1]:
        ai=a[i]
        i+=1
        icnt+=1 
    i+=1

if icnt>=4:
    print(ai*ai)
elif icnt>=2:
    icnt=0
    while icnt<=1 and i<=n-2:
        icnt=1
        while i<=n-2 and a[i]==a[i+1] :
            ai2=a[i]
            i+=1
            icnt+=1
        i+=1
    if icnt>=2:
        print(ai*ai2)
    else:
        print(0)
else:
    print(0)
        

Measured memory_bytes: 14672
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int P, Q, R;
    cin >> P >> Q >> R;
    int abc = P + Q;
    int acb = R + Q;
    int bac = P + R;
    int minv = min(abc, acb);
    minv = min(minv, bac);
    cout << minv << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    string s;cin>>s;
    vector<ll>a(26);
    ll cnt=0;
    rep(i,s.size()){
        a[s[i]-'a']++;
    }
    ll res=(ll)s.size();
    rep(i,26){
        res-=a[i];
        cnt+=a[i]*res;
    }
    cout<<cnt+1<<endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		@SuppressWarnings("resource")
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		
		int p1 = n * a;
		
		if (p1 < b) {
			System.out.println(Integer.toString(p1));
		} else {
			System.out.println(Integer.toString(b));
		}
		
	}

}


Measured memory_bytes: 21844
N = int(input())
a = list(map(int,input().split()))
ans = 1

if N < 3:
	print(ans)
	exit()

if a[0] < a[1]:
	flag = 1
if a[0] > a[1]:
	flag = -1
if a[0] == a[1]:
	flag = 0


for i in range(2,N):
	if flag == 1 and a[i-1] > a[i]:
		ans += 1
		flag = 0
	elif flag == -1 and a[i-1] < a[i]:
		ans += 1
		flag = 0
	elif flag == 0 and a[i-1] < a[i]:
		flag = 1
	elif flag == 0 and a[i-1] > a[i]:
		flag = -1
	
print(ans)

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

int main(){
    int n, k; cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h.at(i);
    }
    sort(h.begin(), h.end());
    int ans = 1001001001;
    for(int i = 0; i + k - 1 < n; i++){
        ans = min(ans, h.at(i + k - 1) - h.at(i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt();
		int[] line = {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};
		System.out.println(line[k-1]);
 	}

}

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

using namespace std;
typedef long long ll;

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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> s(m);
    vector<int> p(m);
    rep(i, m)
    {
        int k;
        cin >> k;
        s[i].resize(k);
        rep(j, k) cin >> s[i][j];
    }
    rep(i, m) cin >> p[i];

    int ans = 0;
    for (int bit = 0; bit < (1 << n); bit++)
    {
        int light = 0;
        rep(i, m)
        {
            int cnt = 0;
            rep(j, s[i].size())
            {
                if (bit & (1 << s[i][j] - 1))
                {
                    cnt++;
                }
            }
            if (cnt % 2 == p[i])
            {
                light++;
            }
        }
        if (light == m)
        {
            ans++;
        }
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>

void swap(std::vector<int> &b, int i, int j) {
    int tmp = b[i];
    b[i] = b[j];
    b[j] = tmp;
}

void fall(std::vector<int> &b, int k) {
    for (int i=k; i>0; i--) {
        if (b[i] > b[i-1]) {
            swap(b, i, i-1);
        } else {
            break;
        }
    }
}

int main() {
    int n, k;
    std::cin >> n >> k;
    std::vector<int> a(n), b(k+1);
    for (int i=0; i<n; i++) {
        std::cin >> a[i];
    }
    
    int j;
    for (int i=0; i<n; i++) {
        if (i > k) {
            j = k;
        } else {
            j = i;
        }
        b[j] = a[i];
        fall(b, j);
    }
    
    int cum = 0;
    for (int i=0; i<k; i++) {
        cum += b[i];
    }
    std::cout << cum << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;
int n;
ll a[200000];
ll b[200000];

int main()
{
    cin >> n;
    for (int i=1; i<=n; ++i)
        cin>>a[i];
    int flag = 1;
    ll now=0;
    for (int i=1; i<=n; ++i)
    {
        now += flag * a[i];
        flag*=-1;
    }
    b[1] = now; 
    for (int i=2; i<=n; ++i)
        b[i] = 2*a[i-1] - b[i-1];
    for (int i=1; i<=n; ++i)
        cout<<b[i]<<' ';
    cout<<endl;
    return 0;
}



Measured memory_bytes: 2944
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n = s.length();
        for (int i = 0; i + 2 <= n; i++) {
            String str = s.substring(i, i + 2);
            if (str.equals("AC")) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <bits/stdc++.h>
#define ll long long

using namespace std;
const ll Mod = 1e9 + 7;
ll n,a[300100],Bits[70];

void Add(ll x){
    for(ll i = 60;i>=0;i--){
        if(x & (1LL << i))  Bits[i]++;
    }
}

void Remove(ll x){
    for(ll i = 60;i>=0;i--){
        if(x & (1LL << i))  Bits[i]--;
    }
}


int main()
{
    cin >> n;
    for(int i = 0;i<n;i++)  cin >> a[i];
    for(int i = 0;i<n;i++)  Add(a[i]);
    ll Ans = 0;
    for(int i = 0;i<n;i++){
        for(ll j = 0;j<60;j++){
            if(a[i] & (1LL << j))  Ans+=((1LL << j)%Mod * ((n - i - Bits[j])%Mod))%Mod;
            else   Ans+=(((1LL << j)%Mod) * (Bits[j]%Mod))%Mod;
            Ans%=Mod;
        }
        Remove(a[i]);
    }
    cout << Ans;
    return 0;
}


Measured memory_bytes: 2560
<?php
/*
    http://cf16-final-open.contest.atcoder.jp/tasks/cf16-final-open_b

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

// define('DEBUG', true);
define('DEBUG', false);

ini_set('error_reporting', E_ALL & ~E_NOTICE);

fscanf(STDIN, "%d", $N);
$score = 0;
$ans = array();
for ($i = 1; $i < 100000; $i++) {
	$score += $i;
	$ans[] = $i;
	if ($score === $N) {
		echo implode(" ", $ans);
		echo PHP_EOL;
		exit;
	}
	if ($score > $N) {
		$diff = abs($score - $N);
		unset($ans[$diff-1]);
		echo implode(" ", $ans);
		echo PHP_EOL;
		exit;
	}
}


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

#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define fo(i, a, b, k) for(int i = a; i <= b; i += k)
#define _fo(i, a, b, k) for(int i = a; i >= b; i -= k)
#define foa(i, a) for (auto &i : a)
#define fod(i, a) for(int i = 1; i*i <= a; i++)
#define sz(a) ((int) a.size())
#define all(a) begin(a), end(a)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mk(x, y) make_pair(x, y)  
#define log2i(x) (31-__builtin_clz(x))
#define log2ll(x) (63-__builtin_clzll(x)) 
#define msz(x) __builtin_popcount(x) 
#define mszll(x) __builtin_popcountll(x) 
#define fom(i, a, b) for(int i = a; i < (1<<b); i++)
#define ifon(i, mask) if(mask&(1<<i))
#define ss(i, mask) while(i=(i-mask)&mask)
#define ifss(i, mask) if(i > (mask^i)) 

typedef int64_t ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int MAX = 1e5+1;
const int MOD = 1e9+7;
const ll INF = INT_MAX;
const ll _INF = INT_MIN;

int n, cnt = 0, cnt2 = 0;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin >> n;
	fo(i, 1, n, 1) {
		int val;
		cin >> val;
		if(val % 4 == 0) cnt++;
		if(val % 4 == 2) cnt2++;
	}
	
	int temp = n-cnt2;
	if(cnt2 > 0) temp += (temp%2);
	
	if(cnt >= temp/2) cout << "Yes";
	else cout << "No";
}

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

#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ff first
#define ss second

using namespace std;

const double pi = acos(-1);
const int N = 1e6 + 6, mod = 998244353, M = 1e7 + 7;
const ll MAX = 5e18;

int n, m, t, s;


int main()
{
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> t;
        s += t;
    }
    if(s > n)
        puts("-1");
    else
        cout << n - s;
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;

int main()
{
	int n, A[1000];

	while (true){
		cin >> n;
		if (!n) break;

		for (int i = 0; i < n; i++)
			cin >> A[i];

		int sum = 0;

		for (int i = 0; i < n; i++)
			sum += A[i];

		double avg = 1.0*sum / n;

		double dist = 0.0;

		for (int i = 0; i < n; i++){
			dist += (avg - A[i])*(avg - A[i]);
		}

		printf("%lf\n", sqrt(dist / n));

	}
	return 0;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n;
  cin >> n;
  vector<string> s(n);
  vector<ll> p(5);
  rep(i,n){
    cin >> s.at(i);
    if(s.at(i).at(0)=='M'){
      p.at(0)++;
    }
    if(s.at(i).at(0)=='A'){
      p.at(1)++;
    }
    if(s.at(i).at(0)=='R'){
      p.at(2)++;
    }
    if(s.at(i).at(0)=='C'){
      p.at(3)++;
    }
    if(s.at(i).at(0)=='H'){
      p.at(4)++;
    }
  }
  ll ans=0;
  int i,j,k;
  for(i=0;i<3;i++){
    for(j=i+1;j<4;j++){
      for(k=j+1;k<5;k++){
        ans+=p.at(i)*p.at(j)*p.at(k);
      }
    }
  }
  cout << ans;
}


Measured memory_bytes: 6380
#include <stdio.h>
void  dijkstra(void);
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INFTY 100000000
#define MAX 100

int n,M[MAX][MAX];

int main(){
  int i,j,k,c,u,v;
  scanf("%d",&n);
  for(i=0;i<n;i++){
   for(j=0;j<n;j++){
     M[i][j]=INFTY;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      M[u][v]=c;
    }
  }
  dijkstra();
  return 0;
}

void dijkstra(){
  int minv;
  int d[MAX],color[MAX];
  int i,u,v;

  for(i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }

  d[0]=0;
  color[0]=GRAY;
  for(;;){
    minv=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i]&&color[i]!=BLACK){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK && M[u][v]!=INFTY){
	if(d[v]>d[u]+M[u][v]){
	  d[v]=d[u]+M[u][v];
	  color[v]=GRAY;
	}
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%d ",i);
    if(d[i]==INFTY)printf("-1\n");
    else printf("%d\n",d[i]);
  }
}
    
    
      

Measured memory_bytes: 636
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e14;
const int ZERO = 0;
const int MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

signed main() {
    int H,W;
    cin >> H >> W;
    int ret = INF;
    for(int i = 0;i <= H;i++) {
        int A = W * i;
        int B,C;
        if(W % 2 == 0 || (H - i) % 2 == 0) {
            B = (H - i) * W / 2;
            C = (H - i) * W / 2;
        }
        else {
            int D = min(H - i,W);
            B = ((H - i) * W + D) / 2;
            C = ((H - i) * W - D) / 2;
        }
        int cnt = max(A, max(B,C));
        int cnt2 = min(A, min(B,C));
        ret = min(ret, abs(cnt - cnt2));
    }
    for(int i = 0;i <= W;i++) {
        int A = H * i;
        int B,C;
        if(H % 2 == 0 || (W - i) % 2 == 0) {
            B = (W - i) * H / 2;
            C = (W - i) * H / 2;
        }
        else {
            int D = min(W - i,H);
            B = ((W - i) * H + D) / 2;
            C = ((W - i) * H - D) / 2;
        }
        int cnt = max(A, max(B,C));
        int cnt2 = min(A, min(B,C));
        ret = min(ret, abs(cnt - cnt2));
    }
    cout << ret << endl;
}

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

typedef long long ll;
typedef long double lg;

using namespace std;

int main(){

 string s;
 cin>>s;

 long long n = s.length();
 int flag=0;

  if(n < 2 || n%2 == 1){
    cout<<"No"<<endl;
     return 0; }


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

   if(s[i] == 'h' && s[i+1] == 'i')
    continue;
   else{
     flag = 1;
        break;}
 }

  if(flag == 0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

return 0;
}


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

int main(void){
    char str[10];
    scanf("%s",str);
    int N = 0;

    for(int i=0; i<4 ; i++){
       
        if('+' == str[i]){
            N++;
        }else{
            N--;
        }
      
    }
   
        printf("%d\n",N);

    

}

Measured memory_bytes: 128
#include<iostream>
#include<queue>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846264338327950L
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	if (b == 0) return a;
	return gcd(b, a % b);
	//return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	ll g = gcd(a, b);
	return a / g * b; // Be careful not to overflow
	//return a * b / gcd(a, b);
}

template<typename T>
T binarysearch(vector<T> A, T key) {
	ll left = 0;ll right = 4;ll mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)//階乗
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

template<typename T>
T keta(T a) {
	ll kazu = 1;
	while (1) {
		if (a / 10 != 0) { a /= 10;kazu++; }
		else break;
	}
	return kazu;
}//桁数

//素数判定
template<typename T>
bool IsPrime(T num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

template<typename T>
T nCr(ll n, T r) {
	ll ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
//vector<vector<int>> data(3, vector<int>(4));
//vector<vector<Type>> vv(n);

int main() {
	//ll K; ll ans = 0;cin >> K;
	ll A, B, H, M;cin >> A >> B >> H >> M;
	//string S;cin >> S;
	long double mina = 0;
	long double ans = 0;
	vector<ll>sum;
	//vector<ll>C(N);
	//vector<ll>S(N), F(N);
	//for (ll i = 1;i < N;i++)cin >> C[i] >> S[i] >> F[i];
	mina = pi * 2 * ((long double)H / 12.0 + (long double)(M / 60.0) / 12.0 - (long double)M / 60.0);
	ans = (long double)(A * A) + (long double)(B * B) - (long double)(2 * A * B * cos(mina));
	cout << fixed << setprecision(20) << sqrtl(ans) << endl;
}


Measured memory_bytes: 4140
n, m = map(int, input().split())

listans = [0] * n
ans = 0

for i in range(m):
    s, c = map(int, input().split())
    s -= 1
    if listans[s] == 0:
        listans[s] = c
    elif listans[s] != c:
        ans = -1
    if n > 1 and s == 0 and c == 0:
        ans = -1

if n > 1 and listans[0] == 0:
    listans[0] = 1

if ans == 0:
    ans = "".join([str(li) for li in listans])

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct node
{
    ll w,v;
    double c;
};
node num[150];
node a[150],b[150],c[150],d[150];
node suma[150],sumb[150],sumc[150],sumd[150];
int n,W;
int cnt1=0,cnt2=0,cnt3=0,cnt4=0;
ll ans;
bool cmp(node a,node b)
{
    if(a.w==b.w)
        return a.v>b.v;
    return a.w<b.w;
}
int main()
{

    cin>>n>>W;
    for(int i=0; i<n; i++)
    {
        cin>>num[i].w>>num[i].v;
    }
    sort(num,num+n,cmp);
    ans=0;
    for(int i=0; i<n; i++)
    {
        if(num[i].w==num[0].w)
        {
            a[++cnt1]=num[i];
            suma[cnt1].v+=suma[cnt1-1].v+a[cnt1].v;
            suma[cnt1].w+=suma[cnt1-1].w+a[cnt1].w;
        }
        if(num[i].w==num[0].w+1)
        {
            b[++cnt2]=num[i];
            sumb[cnt2].v+=sumb[cnt2-1].v+b[cnt2].v;
            sumb[cnt2].w+=sumb[cnt2-1].w+b[cnt2].w;
        }
        if(num[i].w==num[0].w+2)
        {
            c[++cnt3]=num[i];
            sumc[cnt3].v+=sumc[cnt3-1].v+c[cnt3].v;
            sumc[cnt3].w+=sumc[cnt3-1].w+c[cnt3].w;
        }
        if(num[i].w==num[0].w+3)
        {
            d[++cnt4]=num[i];
            sumd[cnt4].v+=sumd[cnt4-1].v+d[cnt4].v;
            sumd[cnt4].w+=sumd[cnt4-1].w+d[cnt4].w;
        }
    }
    /*for(int i=0;i<cnt4;i++)
        cout << d[i].v<<endl;*/
    ll t1=0,t2=0,t3=0,t4=0;
    //cout << cnt1 << endl;
    for(int i=0; i<=cnt1; i++)
    {
        for(int j=0;j<=cnt2;j++)
        {
            for(int k=0;k<=cnt3;k++)
            {
                for(int u=0;u<=cnt4;u++)
                {
                    ll val=suma[i].v+sumb[j].v+sumc[k].v+sumd[u].v;
                    ll ww=suma[i].w+sumb[j].w+sumc[k].w+sumd[u].w;
                    if(ww<=W)
                    {
                        if(ans<val)
                            ans=val;
                    }
                }
            }
        }
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define INF (1 << 30)
#define MAX (1 << 20)

vector<int> prefix_function(vector<int>& s) {
    int n = (int)s.size();
    vector<int> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;

    cin >> n;

    int arr[n], b[n], a_x[n], b_x[n];

    for(int i = 0; i < n; i++)
    	cin >> arr[i];

    for(int i = 0; i < n; i++)
    	cin >> b[i];

    for(int i = 1; i < n; i++){
    	a_x[i-1] = (arr[i]^arr[i-1]);
    	b_x[i-1] = (b[i]^b[i-1]);
    }

    a_x[n-1] = arr[0]^arr[n-1];
    b_x[n-1] = b[0]^b[n-1];

    vector<int> vec, pref_vals;

    for(int i = 0; i < n; i++){
    	vec.push_back(b_x[i]);
    }

    vec.push_back(INF);

    for(int i = 0; i < n; i++){
    	vec.push_back(a_x[i]);
    }

    for(int i = 0; i < n; i++){
    	vec.push_back(a_x[i]);
    }

    pref_vals = prefix_function(vec);

    vector<pair<int, int> > ans;

    for(int i = 2*n; i < (3*n); i++){
    	if(pref_vals[i] == n){
    		ans.push_back({(i - 2*n), arr[(i-2*n)]^b[0]});
    	}
    }

    for(int i = 0; i < ans.size(); i++){
    	cout << ans[i].first << " " << ans[i].second << endl;
    }

    return 0;
}

Measured memory_bytes: 15340
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template


int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    string s;
    cin >> N >> s;
    string sl = s.substr(0, N);
    string sr = s.substr(N, N);
    vector<pair<string, string>> A(1 << N);
    map<string, string> B;
    map<pair<string, string>, ll> M;
    
    rep(i, 1 << N) {
        string a = "";
        string b = "";
        rep(j, N) {
            if((i >> j) & 1) a += sl[j];
            else b += sl[j];
        }
        reverse(all(b));
        A[i] = {a, b};
    }
//    rep(i, 1 << N) {
//        cout << A[i].first << "," << A[i].second << endl;
//    }
//    output("========");
    rep(i, 1 << N) {
        string a = "";
        string b = "";
        rep(j, N) {
            if((i >> j) & 1) a += sr[j];
            else b += sr[j];
        }
        reverse(all(b));
        M[{b, a}]++;
    }
//    for(auto m: M) {
//        cout << m.first.first << "," << m.first.second << ":" << m.second << endl;
//    }
    ll ans = 0;
    rep(i, 1 << N) {
        ans += M[{A[i].first, A[i].second}];
    }
    output(ans);
    
    return 0;
}


Measured memory_bytes: 91136
def main():
    N, M = (int(i) for i in input().split())
    xys = [[int(i)-1 for i in input().split()] for j in range(M)]
    boxes = [[False,1] for _ in range(N)]
    boxes[0][0] = True #Red
    for x,y in xys:
        if boxes[x][0] == True:
            if boxes[x][1] == 1:
                boxes[x][0] = False
            boxes[y][0] = True
        boxes[x][1] -= 1
        boxes[y][1] += 1
    ans = 0
    for tf,c in boxes:
        if tf:
            ans += 1
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 75352
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long K = sc.nextLong();
        sc.close();
        long remainA = Math.max(A - K, 0);
        long eatA = A - remainA;
        long eatB = Math.min(K - eatA, B);
        long remainB = B - eatB;
        System.out.println(remainA + " " + remainB);
    }
}



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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
typedef long long ll;
/*
    problem : http://abc058.contest.atcoder.jp/tasks/arc071_b
*/
int n, m;
const int MOD = 1e9 + 7;
ll calc(int num)
{
	VI A(num);
	REP(i, 0, num) cin >> A[i];

	ll res = 0;
	REP(i, 1, num){
		res = (res+(ll)(A[i]-A[i-1])*i%MOD*(num-i))%MOD;
	}

	return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	cin >> n >> m;


	ll sumX = calc(n), sumY = calc(m);
	
	cout << (sumX * sumY) % MOD << endl;

	return 0;
}

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

int main(void){
    
    ll n;
    double ans=0;
    
    cin >> n;
    
    vector<double> v(n);
    
    for(ll i=0; i<=n-1; i++){
        
        cin >> v.at(i);
        
    }
    
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    
    for(ll i=0; i<=n-2; i++){
        
        ans += v.at(i)/pow(2, i+1);
        
    }
    
    ans += v.at(n-1)/pow(2, n-1);
    
    printf("%.8f", ans);
    
    return 0;
    
}

Measured memory_bytes: 384
package main

import (
	"fmt"
)

func sum(l []int) int {
	s := 0
	for _, x := range l {
		s += x
	}
	return s
}

func abs(x int) int {
	if x >= 0 {
		return x
	} else {
		return -x
	}
}

func main() {
	var n int
	fmt.Scan(&n)
	w := make([]int, n)
	var ans, a int
	for i := 0; i < n; i++ {
		fmt.Scan(&w[i])
	}
	for i := 1; i < n; i++ {
		a = abs(sum(w[:i]) - sum(w[i:]))
		if ans == 0 || a <= ans {
			ans = a
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <stdio.h>
int main(void){
    long long int k, a, b;
    scanf("%lld %lld %lld", &k, &a, &b);
    long long int ans;
    if(a>=b-1 || a>k)ans=k+1;
    else ans=a+(k-a+1)/2*(b-a)+(k-a+1)%2;
    
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1700
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <cctype>
#include <climits> // INT_MAX ...
#include <cstring> // 

using namespace std;

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

    int h, a;
    cin >> h >> a;
    cout << (h - 1) / a + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
#define ll long long
int a[105];
int main()
{
    ll n;
    scanf("%lld",&n);
    if(n==0)
        puts("0");
    else
    {
        int t=0;
        while(n)
        {
            int yu=n%(-2);
            if(yu==-1)
            {
                a[t++]=1;
                n=n/(-2)+1;
            }
            else
            {
                a[t++]=yu;
                n=n/(-2);
            }
        }
        for(int i=t-1; i>=0; i--)
        {
            printf("%d",a[i]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 256
a1 = gets.chomp.split(" ").map(&:to_i);
a2 = gets.chomp.split(" ").map(&:to_i);
a3 = gets.chomp.split(" ").map(&:to_i);
m = gets.chomp.split(" ").map(&:to_i);
b = readlines.map(&:to_i)

for i in 0..(b.length-1) do
	for j in 0..2 do
		if b[i] == a1[j] then
			a1[j] = 999
		end
	end
	
	for j in 0..2 do
		if b[i] == a2[j] then
			a2[j] = 999
		end
	end
	
	for j in 0..2 do
		if b[i] == a3[j] then
			a3[j] = 999
		end
	end
end

ans ="No"
if a1[0]==999 && a1[1]==999 && a1[2]==999 then
	ans ="Yes"
end

if a2[0]==999 && a2[1]==999 && a2[2]==999 then
	ans ="Yes"
end

if a3[0]==999 && a3[1]==999 && a3[2]==999 then
	ans ="Yes"
end

if a1[0]==999 && a2[0]==999 && a3[0]==999 then
	ans ="Yes"
end

if a1[1]==999 && a2[1]==999 && a3[1]==999 then
	ans ="Yes"
end

if a1[2]==999 && a2[2]==999 && a3[2]==999 then
	ans ="Yes"
end
	
if a1[0]==999 && a2[1]==999 && a3[2]==999 then
	ans ="Yes"
end

if a1[2]==999 && a2[1]==999 && a3[0]==999 then
	ans ="Yes"
end

puts ans


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

typedef long long ll;

using namespace std;

int main() {
    int A, B, C, X, Y, x = 0, y = 0, totalCost = 0;
    cin >> A >> B >> C >> X >> Y;
    while (x < X && y < Y) {
        if (A + B < 2 * C) {
            totalCost += A + B;
        } else {
            totalCost += 2 * C;
        }
        x++; y++;
    }
    while (x < X) {
        if (A < 2 * C) {
            totalCost += A;
        } else {
            totalCost += 2 * C;
        }
        x++;
    }
    while (y < Y) {
        if (B < 2 * C) {
            totalCost += B;
        } else {
            totalCost += 2 * C;
        }
        y++;
    }
    cout << totalCost << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

			if (x < a) {
				System.out.println(0);
			} else {
				System.out.println(10);
			}
		}
	}
}


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

using namespace std;

#define el				'\n'
#define sz(v)			((int)((v).size()))
#define all(v)          ((v).begin()),((v).end())
#define clr(v, d)		memset(v, d, sizeof(v))

double const EPS = 1e-8, PI = acos(-1);
const int N = 1e5 + 9, M = 50 + 9, OO = (int) 1e9 + 1;
const long long MOD = 1e9 + 7;

typedef long long ll;

void OUTPUT() {
	cout << fixed << setprecision(12);
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
}

void INPUT() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(12);
//	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
}

int n, arr[M];
int main() {
	OUTPUT();
//	INPUT();
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	sort(arr, arr + n);
	long double ans = arr[0];
	for (int i = 1; i < n; i++) {
		ans = (ans + arr[i]) / 2.0;
	}
	cout << ans;

	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
const int mod=1e9+7;
using LL=long long;
using std::cout;using std::endl;using std::cin;
using std::vector;using std::string;using std::set;using std::multiset;
using std::pair;using std::map;
using std::min;using std::max;
using std::make_pair;
std::ostream& operator<<(std::ostream& os,std::map<int,int>& obj){for(std::map<int,int>::iterator itr=obj.begin();itr!=obj.end();itr++){os<<itr->first<<"^"<<itr->second<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::map<int,int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<int>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<" ";}return os;}

namespace ndifix{
template<class T> void sort(T &v){std::sort(v.begin(),v.end());}
}

int main(){
  int n,time;cin>>n>>time;
  int c,t;
  vector<pair<int,int>> ct;
  for(int i=0;i<n;i++){
    cin>>c>>t;
    if(t<=time)ct.push_back(make_pair(c,t));
  }
  ndifix::sort(ct);
  if(ct.size())cout<<ct[0].first<<endl;
  else cout<<"TLE"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vdo=vector<double>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vvdo=vector<vector<double>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vpii=vector<pair<int,int>>;
using pqin=priority_queue<int>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG
int main(){
    int n,m;
    cin>>n>>m;
    vpii c(m);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        c[i]=mp(b,a);
    }
    sort(all(c));
    int sum=1;
    int t=c[0].first;
    rep2(i,1,m){
        if(t<=c[i].second){
            sum++;
            t=c[i].first;
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <string>

using namespace std;
const int MOD = 2019;

void solve(int L, int R) {
  long long ans = 2019;
  for (int i = L; i <= R; i++) {
    for (int j = i + 1; j <= R; j++) {
      long long tmp = (i % MOD) * (j % MOD);
      tmp %= MOD;
      ans = min(ans, tmp);
      if (ans == 0) {
        printf("%lld\n", ans);
        return;
      }
    }
  }
  printf("%lld\n", ans);
}

int main() {
  int L, R;
  cin >> L >> R;
  solve(L, R);
  return 0;
}

Measured memory_bytes: 384
#ABC047D
N,T=map(int,input().split())
A=list(map(int,input().split()))
ma=0
mi=10**9+1
dif=0
c=0
for a in A:
	if a<mi:
		mi=a
	else: #mi<a
		if ma<a: #mi<ma<a
			ma=a
			dif=ma-mi
			c=1
		else: #mi<a<ma
			if dif==a-mi:
				c+=1
			elif dif<a-mi:
				dif=a-mi
	
print(c)

Measured memory_bytes: 14244