akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

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

		    int x = sc.nextInt();
		    int a = sc.nextInt();
		    int b = sc.nextInt();
		    
		    if(a - b >= 0) {
		    	System.out.println("delicious");
		    }
		    else if(b - a <= x){
		    	System.out.println("safe");
		    }
		    else {
		    	System.out.println("dangerous");
		    }
		    
		    sc.close(); }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

int n;
typedef struct Edge {
    ll to, cost;
} Edge;

vector<vector<Edge>> g;
vector<int> ans;
vector<bool> vi;

void dfs(int x, int t) {
    if (vi[x]) return;
    if (t%2 == 0) ans[x] = 0;
    else ans[x] = 1;

    vi[x] = true;
    for (auto &&e: g[x]) {
        dfs(e.to,t+e.cost);
    }
    return;
}

int main(int argc, char const *argv[]) {
    cin>>n;
    
    g.resize(n);
    ans.resize(n);

    rep(i,n-1) {
        ll u,v,w; cin>>u>>v>>w; --u;--v;
        g[u].push_back({v,w});
        g[v].push_back({u,w});
    }

    vi.assign(n,false);
    dfs(0,0);
    for (auto &&e: ans) cout << e << endl;
    return 0;
}

Measured memory_bytes: 8832
def unit_check(n, k, w_list, P):
    i = 0
    for j in range(k):
        weight = 0
        while weight + w_list[i] <= P:
            weight += w_list[i]
            i += 1
            if i == n:
                return 1
    return 0

n, k = map(int,input().split())
w_list = [0] * n
for i in range(n):
    w_list[i] = int(input())

left = 0
right = 100000*10000
while left+1 < right:
    mid = (left+ right)//2
    check = unit_check(n, k, w_list, mid)
    if check == 1:
        right = mid
    else:
        left = mid
print(right)


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

int main(){
  int N;
  cin >> N;
  vector<tuple<string, int, int>> a;
  
  for (int i = 1; i <= N; i++){
    string S;
    int P;
    cin >> S >> P;
    P = -P;
    a.push_back(tie(S,P,i));
  }
  
  sort(a.begin(),a.end());
  
  for (int i = 0; i < N; i++){
    cout << get<2>(a[i]) << endl;
  }
  
  return 0;
}

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


#define long long long int

using namespace std;


typedef vector<int> vi;
typedef pair<int, int> pi;

void print(const vector<long> &a) {
    for (auto item : a) {
        cout << item << " ";
        flush(cout);
    }
}

int main() {

    double a, b, x;
    cin >> a >> b >> x;
    double y = x / a / a * 2 - b;
    double ans;
    if (y >= 0) {
        ans = atan2(b - y, a);
    } else {
        y = x / a * 2 / b;
        ans = atan2(b, y);
    }
    ans = ans / M_PI * 180;
    cout << setprecision(20) << ans;
    return 0;
}

Measured memory_bytes: 256
//https://hcpc-hokudai.github.io/archive/dynamic_programming_rerooting.pdf
//https://qiita.com/keymoon/items/2a52f1b0fb7ef67fb89e#使用例


#include <iostream>
#include <vector>
#include <functional>
#include <stack>
using namespace std;
const long long INF = 1LL << 61;


//森の　Σ連結成分　＝　Σ頂点数　ー　Σ辺数
//Σ頂点数は、1の場合、2の場合と掛け算すれば求まる
//Σ辺数は両端の1.若い頂点番号よりも前の数と、2.大きい頂点番号後の番号数なら
//組み合わせなんでも良い

int main(){
    long long N;
    cin >> N;
    long long V =0, E=0;

    for(long long i=1; i<=N; ++i){
        V += i*((N+1)-i);
    }
    
    for(long long i=0; i<N-1; ++i){
        long long u, v;
        cin >> u >> v;
        if(u > v) swap(u, v);
        E += u * (N+1-v);
    }

    long long ans = V - E;
    cout << ans << endl;
}

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

public class Main {
	public static void printArray(int[] intArray){
		for (int i = 0; i < intArray.length; i++){
			System.out.print(intArray[i]);

			if (i == intArray.length - 1){
				break;
			}
			System.out.print(" ");
		}
		System.out.println();
	}

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

		int progNumLength = Integer.parseInt(br.readLine());

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

		int[] progNumResult = new int[progNumLength];

		for(int i = 0; i < progNumLength; i++) {
			progNumResult[i] = Integer.parseInt(progNum[i]);
		}

		int minNum = 0;
		int sortCount = 0;
		for(int i = 0; i < progNumLength; i++) {
			minNum = i;

			for(int j = i; j < progNumLength; j++) {
				if(progNumResult[j] < progNumResult[minNum]) {
					minNum = j;
				}
			}
			if(i != minNum) {
				int tmp = progNumResult[i];
				progNumResult[i] = progNumResult[minNum];
				progNumResult[minNum] = tmp;

				sortCount++;
			}
		}
		printArray(progNumResult);
		System.out.println(sortCount);
	}

}

Measured memory_bytes: 24472
#include <stdio.h>

int main(void)
{
	int N;
	int H;
	int W;
	int kind;
	
	scanf("%d%d%d", &N, &H, &W);
	
	kind = (((N - H) + 1) * ((N - W) + 1));
	
	printf("%d", kind);
	return 0;
}


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

#define SIZE (200001)

int main(void) {
    char A[SIZE];
    scanf("%s", A);

    long long size = strlen(A);

    int** count = new int*[26];
    for (int i=0; i<26; i++) {
        count[i] = new int[size];
        memset(count[i], 0x00, sizeof(count[i][0]) * size);
    }

    count[A[0]-'a'][0] = 1;
    for (int i=1; i<size; i++) {
        for (int j=0; j<26; j++) {
            count[j][i] = count[j][i-1];
        }
        count[A[i]-'a'][i]++;
    }

    long long total = size * (size-1) / 2 + 1; // +1 is no reverse.
    for (int i=1; i<size; i++) {
        char ai = A[i];
        int aiCount = count[ai-'a'][i-1];
        total -= aiCount;
    }

    printf("%lld\n", total);

    for (int i=0; i<26; i++) {
        delete count[i];
    }
    delete count;

    return 0;
}


Measured memory_bytes: 20864
#include <stdio.h>
int a,count=0;
int solve(long long int *b,int n){
for(int i=n;i<a;i++){
if(!(b[i]%2)){
b[i]/=2;
count++;
solve(&b[0],i);
} 
}
return count;
}

int main(void){
long long int b[10001]={0};
scanf("%d",&a);
for(int i=0;i<a;i++){
scanf("%d",&b[i]);
}
printf("%d\n",solve(&b[0],0));
return 0;
}

Measured memory_bytes: 9088
{
  const main = (input: string) => {
    const r = reader(input)
    const [a, b, c] = r.ns()

    console.log(a + b + c >= 22 ? 'bust' : 'win')
  }

  // const values = obj => Object.keys(obj).map(e => obj[e]);

  const reader = (str: string) => {
    const lines = str.trim().split('\n')
    const s = () => lines.shift() || ''
    const line = s
    const n = () => Number(s())

    const ss = () => s().split(' ')
    const ns = () => ss().map(Number)

    return { lines, line, s, n, ss, ns }
  }

  const getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')

  main(getInput())
}


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
using namespace std;
const int N = 100;

int n, t[N];
string s[N], p;

template <class T>
inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}

int main() {
    read(n);
    for (R int i = 1; i <= n; ++i) cin >> s[i], read(t[i]);
    cin >> p;
    for (R int i = 1; i <= n; ++i) {
        if (s[i] == p) {
            int ans = 0;
            for (R int j = i + 1; j <= n; ++j)
                ans += t[j];
            cout << ans << endl;
            return 0;
        }
    }
    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
vector<int> E[101010];
int S,T;

int D[101010][3];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,M) {
		cin>>x>>y;
		x--;y--;
		E[x].push_back(y);
	}
	cin>>S>>T;
	S--,T--;
	FOR(i,N) D[i][0]=D[i][1]=D[i][2]=1<<30;
	queue<int> Q;
	D[S][0]=0;
	Q.push(S*3);
	while(Q.size()) {
		int cur=Q.front()/3;
		int m=Q.front()%3;
		int n=(m+1)%3;
		Q.pop();
		FORR(e,E[cur]) {
			if(D[e][n]>D[cur][m]+1) {
				D[e][n]=D[cur][m]+1;
				Q.push(e*3+n);
			}
		}
	}
	
	if(D[T][0]<1<<30) cout<<D[T][0]/3<<endl;
	else cout<<-1<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 6912
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>

using namespace std;

#define rep(i,a,n) for(int (i)=a;(i)<(int)(n);(i)++)
#define rrep(i,a,n) for(int (i)=(n)-1;(i)>=a;(i)--)
#define all(x) (x).begin(),(x).end()

typedef long long ll;

int main() {
	double r;
	cin >> r;

	double ans1, ans2;

	ans1 = M_PI * r * r;
	ans2 = M_PI * 2 * r;

	printf("%.6f %.6f\n", ans1, ans2);
}

Measured memory_bytes: 3188
N = int(input())
A = list(map(int, input().split()))
A.sort()

A_tmp=A[0]
for i in A[1:]:
  if i%A_tmp != 0:
    A_tmp = i%A_tmp
    
while(1):
  tmp = [x%A_tmp for x in A if x%A_tmp != 0]
  if sum(tmp) != 0:
    A_tmp = min(tmp)
  else:
    break
print(A_tmp)



Measured memory_bytes: 14252
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		int a = sc.nextInt();
		String s = sc.next();
		if (a >= 3200) {
			System.out.println(s);
		} else {
			System.out.println("red");
		}

	}

}

class FScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 21076
def main():
    K = int(input())
    A, B = map(int, input().split())
    if B % K== 0 or A % K == 0:
        return True
    if (B//K) - (A //K) > 0:
        return True
    return False
if main():
    print('OK')
else:
    print('NG')


Measured memory_bytes: 9120
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long int lli;
#define rept(x, s, n) for (int x = s; x < n; x++)


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);

int main(void) {
	int   A[3],K,i;

	i_cins(3, A);
	i_cin(K);
	
	qsort((void*)A, 3, sizeof(A[0]), s_dsort);
	rept(i, 0, K)
		A[0] *= 2;

	i_cout(A[0] + A[1] + A[2]);

	return 0;
}

//降順
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
//
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	rept(i, 0, n) {
		i_cin(*(a + i));
	}
	return 0;
}




Measured memory_bytes: 128
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,m,que=MI()
lis=[[0]*n for i in range(n)]
for i in range(m):
    l,r=MI()
    lis[l-1][r-1]+=1
for i in range(n):
    lis[i]=list(accumulate(lis[i]))
for i in range(n):
    for j in range(n-1):
        lis[j+1][i]+=lis[j][i]
#print(lis)
#print(lis)
for i in range(que):
    p,q=MI()
    if p==1:
        ans=lis[q-1][q-1]
    else:
        ans=lis[q-1][q-1]-lis[p-2][q-1]
    print(ans)

Measured memory_bytes: 19368
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;
int main(){
    long long int ans=0,n,z=0;
    cin>>n;
    vector<long long int>a(300000);
    for(int i=0;i<n;i++){
        cin>>a[i];
        z=(z+a[i])%1000000007;
    }

    for(int i=0;i<n;i++){
        z=((z+1000000007)-a[i]%1000000007)%1000000007;
        ans=(ans+((z)*(a[i])))%1000000007;
    }
    cout<<ans<<endl;

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  int a[n];
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  
  int a_point = 0;
  int b_point = 0;
  for(int j = 0; j < n; j++) {
    int max = 0;
    int num;
    for(int k = 0; k < n; k++) {
      if(max < a[k]) {
        num = k;
        max = a[k];
      }
    }
    
    if(j % 2 == 0) a_point += a[num];
    else b_point += a[num];
    
    a[num] = 0;
  }
  
  int sub = a_point - b_point;
  if(sub < 0) sub *= -1;
  
  cout << sub << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int r;
	cin >> r;
	string s;
	cin >> s;
	int f=0;
	for(int i=0;i<r/2;i++){
		if(s[i]!=s[i+r/2]){
			f=1;break;
		}
	}
	if(r==1||r%2==1)	f=1;
	if(!f)	printf("Yes\n");
	else 	printf("No\n");
} 

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int arr[6];
    for (int i=1; i<=5; i++){
    	cin>> arr[i];
    }
    for (int i=1; i<=5; i++){
    	if (arr[i]==0){
        	cout << i << endl;
        }
    }
 }

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

using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

/*********** Constants ***********/
const auto INF = static_cast<ll>(1ll << 60);
const auto MOD = static_cast<ll>(1e9 + 7);
const auto NIL = nullptr;

/************* Utils *************/
struct Node {
    ll key;
    Node *parent, *left, *right;
};

void preOrder(Node **T) {
    if (*T == NIL) {
        return;
    }
    cout << " " << (*T)->key;
    preOrder(&(*T)->left);
    preOrder(&(*T)->right);
}

void inOrder(Node **T) {
    if (*T == NIL) {
        return;
    }
    inOrder(&(*T)->left);
    cout << " " << (*T)->key;
    inOrder(&(*T)->right);
}

void insert(Node **T, Node **z) {
    Node *y = NIL;
    Node *x = *T;
    while (x != NIL) {
        y = x;
        if ((*z)->key < x->key) {
            x = x->left;
        }
        else {
            x = x->right;
        }
    }
    (*z)->parent = y;
    if (y == NIL) {
        *T = *z;
    }
    else if ((*z)->key < y->key) {
        y->left = *z;
    }
    else {
        y->right = *z;
    }
}

bool find(Node **T, ll key) {
    Node *x = *T;
    while (x != NIL) {
        if (x->key == key) {
            return true;
        }
        else if (x->key > key) {
            x = x->left;
        }
        else {
            x = x->right;
        }
    }
    return false;
}

/*********** Variables ***********/
Node *Tree;

/*********** Functions ***********/
bool init() {
    return true;
}

void solve() {
    ll N; cin >> N;
    string command;
    for (ll i = 0; i < N; i++) {
        cin >> command;
        if (command == "print") {
            inOrder(&Tree);
            cout << endl;
            preOrder(&Tree);
            cout << endl;
        }
        else if (command == "find") {
            ll key; cin >> key;
            if (find(&Tree, key)) {
                cout << "yes" << endl;
            }
            else {
                cout << "no" << endl;
            }
        }
        else {
            ll key; cin >> key;
            Node *node = new Node{key, NIL, NIL, NIL};
            insert(&Tree, &node);
        }
    }
}

void output() {
}

int main() {
    //init();
    solve();
    //output();
    return 0;
}


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

int main(void){
  int a,b,c; cin >> a >> b >> c;
  if(  (( (a-b) * (a-c) ) > 0 ) && ( abs(a-b) >  abs(a-c) ) ){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
  return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n;
    cin >> n;
    vector<char> c;
    for (int i = 0; i < n; i++)
    {
        char cc;
        cin >> cc;
        if (cc != '-')
            c.push_back(cc);
    }
    n = c.size();
    vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, 0));
    dp[0][0] = 1;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (dp[i][j] == 0)
                continue;
            if (c[i] == 'D')
            {
                dp[i + 1][j] += dp[i][j] * j % MOD;
                dp[i + 1][j] %= MOD;

                if (j)
                {
                    dp[i + 1][j - 1] += dp[i][j] * j * j % MOD;
                    dp[i + 1][j - 1] %= MOD;
                }
            }
            else
            {
                dp[i + 1][j] += dp[i][j] * j % MOD;
                dp[i + 1][j] %= MOD;

                dp[i + 1][j + 1] += dp[i][j];
                dp[i + 1][j + 1] %= MOD;
            }
        }
    }
    cout << dp[n][0] << endl;
}



Measured memory_bytes: 3300
N = int(input())
D = []
for i in range(N):
    a, b = map(int, input().split())
    D.append((a, 0, i))
    D.append((b, 1, i))

D.sort()
ans = 0
C = [False] * N
db = False
gr = [0] * 2
for i in range(N):
    ans += D[i][0]
    gr[D[i][1]] += 1
    if C[D[i][2]]:
        db = True
    C[D[i][2]] = True

if not db and gr[0] != 0 and gr[1] != 0:
    if D[N - 1][2] == D[N][2]:
        ans = min(ans - D[N - 2][0] + D[N][0], ans - D[N - 1][0] + D[N + 1][0])
    else:
        ans = ans - D[N - 1][0] + D[N][0]

print(ans)

Measured memory_bytes: 75828
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

typedef pair<int,int> pii;

int main(){
  int n,m,x,y,sx,sy,lx,ly;
  vector<pii> map;

  cin>>n>>m;
  for(int i=0;i<n;i++){
    cin>>x>>y;
    map.push_back(make_pair(x,y));
  }
  sort(map.begin(),map.end());
  for(int i=0;i<m;i++){
    cin>>sx>>sy>>lx>>ly;
    int left,right;
    for(left=0;map[left].first<sx&&left<map.size();left++);
    int ans=0;
    for(right=left;map[right].first<=lx&&right<map.size();right++)
      if(sy<=map[right].second&&map[right].second<=ly) ans++;
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 1304
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "PP.hpp"
#define deb(x...) cerr << "[" << #x << "] = " << x << "\n";
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

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

int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a, p;
	cin >> a >> p;
	cout << (p + 3 * a) / 2 << '\n';
	return 0;
}



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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl

typedef pair<int, int> P;
typedef long long ll;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<char> n(4); 
    int ans = 0;
    REP(i,4){
        cin>>n[i];
        if (n[i] == '2') ans++;
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {
    n:i64,
     }
    // 2,5,10
    if n % 2 == 1 {
        println!("{}", 0);
        return;
    } else {
        let mut ans = 0;
        let mut dd = 10;
        for i in 0..333333333 {
            ans += n / dd;
            dd *= 5;
            if n / dd == 0 {
                break;
            }
        }
        println!("{}", ans);
    }
}


Measured memory_bytes: 2092
#include <stdio.h>
 
 
 
 
 
int main(){

  int i,j,n,r,l,c,d,k;
  int Gra[150][150];
   
  scanf("%d",&n);
   
 
  for(i = 0;i < n; i++){
     
    scanf("%d%d",&r,&j);

    for(k = 0;k < j; k++){
 
      scanf("%d",&l);
       
      Gra[r-1][l-1] = 1;
      
    }
  }
   
   
  for(c = 0;c < n; c++){
    for(d = 0;d < n-1; d++){
       
      printf("%d ",Gra[c][d]);
       
    }

    printf("%d",Gra[c][d]);
     
    printf("\n");
  }
  
   
  return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

int main() {
	string S, T;
	char table[256];
	table['b'] = 'd';
	table['d'] = 'b';
	table['p'] = 'q';
	table['q'] = 'p';

	cin >> T;
	S = T;
	reverse(begin(S), end(S));
	for (int i = 0; i < S.size(); i++) {
		S[i] = table[S[i]];
	}
	cout << (S == T ? "Yes" : "No") << endl;
	return (0);
}

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

#define mp make_pair
#define pb push_back

#define int int64_t

const int MOD = 1e9+7;
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    int ans=0;
    int min=10000000000;
    for(int i=0;i<n;i++) {
        if(arr[i]<=min)
        {
            ans++;
            min=arr[i];
        }
    }

    cout<<ans;

    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(void)
{
    int n;
    int h[100];
    int i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&h[i]);
    }
    int max=h[0];
    int ans=1;
    for(i=1;i<n;i++){
        if(max<=h[i]){
            ans+=1;
            max=h[i];
        }
    }

    printf("%d\n",ans);
    
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define prique priority_queue
int r,g,b,n;
int ans=0;
signed main(){
    cin>>r>>g>>b>>n;
    for(int i=0;i<=n/r;i++){
        for(int j=0;j<=(n-i*r)/g;j++){
            int x=n-i*r-j*g;
            if(x%b==0)ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>

int main(){
  ll N; cin >> N;
  VL a(N);
  VL b(N);
  rep(i,0,N) cin >> a[i];
  rep(i,0,N) cin >> b[i];
  
  ll ans = 0;
  ll tmp = 0;
  rep(i,0,N){
    tmp = 0;
    rep(j,0,i+1){
      tmp += a[j];
    }
    rep(k,i,N){
      tmp += b[k];
    }
    ans = max(tmp, ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(){
  int r=0;
  int g=0;
  int b=0;
  int n=0;
  int ans = 0;
  int ir = 0;
  int jg = 0;
  int kb = 0;

  int tmpi = 0;
  int tmpj = 0;
  int tmpk = 0;

  scanf("%d", &r);
  scanf("%d", &g);
  scanf("%d", &b);
  scanf("%d", &n);

  // (r * x) + (g + y) + (b + z) =n
  // x y zの組の数

  for(ir=0; 1; ir++){
    tmpi= ir*r;
    if( tmpi >n){ break; }

    for(jg=0; 1; jg++){
      int tmpn;
      tmpj = tmpi + (jg*g);
      if(tmpj>n){break;}
      tmpn = n-tmpj;
      if( !(tmpn%b)){
	ans++;
      }


      //      for(kb=0; 1; kb++){
      //	tmpk = tmpj + (kb*b);
      //	if(tmpk ==n  ){
      //	  ans++;
      //	}
      // 	if(tmpk>=n){break;}
      //      }

    }


  }

  printf("%d",ans);

  return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};

vector<lint> G[60]; // MAX_V,隣接リスト
lint root;

lint parent[7][60]; // logMAX_V,MAX_V
lint depth[60];

void LCAdfs(lint v,lint p,lint d){
    parent[0][v]=p;
    depth[v]=d;
    rep(i,G[v].size()) if(G[v][i]!=p) LCAdfs(G[v][i],v,d+1);
}

void LCAinit(lint V){
    LCAdfs(root,-1,0);
    for(int k=0;k+1<7;k++){
        for(int v=0;v<V;v++){
            if(parent[k][v]<0) parent[k+1][v]=-1;
            else parent[k+1][v]=parent[k][parent[k][v]];
        }
    }
}

lint LCA(lint u,lint v){
    if(depth[u]>depth[v]) swap(u,v);
    for(int k=0;k<7;k++){
        if((depth[v]-depth[u])>>k&1) v=parent[k][v];
    }
    if(u==v) return u;
    for(int k=7-1;k>=0;k--){
        if(parent[k][u]!=parent[k][v]){
            u=parent[k][u];
            v=parent[k][v];
        }
    }
    return parent[0][u];
}

vector<int> path(int s,int t){
    int lca=LCA(s,t);
    vector<int> ps,pt;
    int now=s;
    while(true){
        if(now==lca) break;
        ps.push_back(now);
        now=parent[0][now];
    }
    now=t;
    while(true){
        pt.push_back(now);
        if(now==lca) break;
        now=parent[0][now];
    }
    reverse(pt.begin(),pt.end());
    ps.insert(ps.end(),pt.begin(),pt.end());
    return ps;
}

map<pint,int> edge;

int main(void){
    int N;
    cin >> N;
    rep(i,N-1){
        int u,v;
        cin >> u >> v;
        u--,v--;
        G[u].push_back(v);
        G[v].push_back(u);
        edge[pint(u,v)]=i;
        edge[pint(v,u)]=i;
    }
    LCAinit(N);
    lint ans=(1LL<<(N-1));
    lint minus=0;
    int M;
    cin >> M;
    int u[M],v[M];
    rep(i,M) cin >> u[i] >> v[i];
    rep(i,M) u[i]--,v[i]--;
    int edgecnt[N-1]={};
    rep(i,(1<<M)){
        if(i==0) continue;
        int pick=Flagcount(i);
        rep(j,M) if(i&(1<<j)){
            vector<int> way=path(u[j],v[j]);
            rep(k,way.size()-1) edgecnt[edge[pint(way[k],way[k+1])]]++;
        }
        int vtx=0;
        rep(j,N-1) if(edgecnt[j]) vtx++;
        lint cnt=(1LL<<(N-1-vtx));
        if(pick%2) minus+=cnt;
        else minus-=cnt;
        rep(j,N-1) edgecnt[j]=0;
    }
    cout << ans-minus << endl;
}

Measured memory_bytes: 3668
use std::io;

fn main() {
    let mut x = String::new();
    io::stdin().read_line(&mut x).expect("");
    let x: u32 = x.trim().parse().expect("");
    let h: u32 = x / 3600;
    let m: u32 = (x - h * 3600) / 60;
    let s: u32 = x - h * 3600 - m * 60;
    println!("{}:{}:{}", h, m, s);
}



Measured memory_bytes: 5028
# -*- coding: utf-8 -*-

class dice_class:
    def __init__(self, top, front, right, left, back, bottom):
        self.top    =   top
        self.front  =   front
        self.right  =   right
        self.left   =   left
        self.back   =   back
        self.bottom =   bottom

    def roll(self, s):
        for i in s:
            if i == 'E':
                self.rollE()
            elif i == 'N':
                self.rollN()
            elif i == 'S':
                self.rollS()
            elif i == 'W':
                self.rollW()

    def rollE(self):
        tmp         =   self.top
        self.top    =   self.left
        self.left   =   self.bottom
        self.bottom =   self.right
        self.right  =   tmp

    def rollN(self):
        tmp         =   self.top
        self.top    =   self.front
        self.front  =   self.bottom
        self.bottom =   self.back
        self.back   =   tmp

    def rollS(self):
        tmp         =   self.top
        self.top    =   self.back
        self.back   =   self.bottom
        self.bottom =   self.front
        self.front  =   tmp

    def rollW(self):
        tmp         =   self.top
        self.top    =   self.right
        self.right  =   self.bottom
        self.bottom =   self.left
        self.left   =   tmp

if __name__ == "__main__":
    a = map(int, raw_input().split())
    s = str(raw_input())
    dice = dice_class(a[0], a[1], a[2], a[3], a[4], a[5])
    dice.roll(s)
    print dice.top

Measured memory_bytes: 6480
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const H = arg[1].split(" ").map(n=>parseInt(n)).reverse();
    
    for(let i=0; i<N-1; i++) {
        if(H[i] < H[i+1]) {
            H[i+1]--;
        }
    }
    
    H.reverse()
    
    for(let i=0; i<N-1; i++) {
        if(H[i] > H[i+1]) {
            console.log("No");
            return;
        }
    }
    
    console.log("Yes");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 17932
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

ll dp[100010];

int main(){
   int n,w;
   cin >> n >> w;
   vector<ll> val(n);
   vector<ll> wight(n);
   rep(i,n){
      ll x,y;
      cin >> x >> y;
      for (int j = w; j >= 0; j--){
         if (0 <= j - x) dp[j] = max(dp[j],dp[j-x] + y);
      }
   }
   //rep(i,n+1){
   //   rep(j,9){
   //      cout << dp[i][j] << " ";
   //   }
   //   cout << endl;
   //}
   cout << dp[w] << endl;
   


  
  return 0;
}


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

typedef unsigned long long L;
int main(){
	for(L n; cin>>n && n;){
		vector<L> v(n);
		for(L i=0; i<n; i++) cin>>v[i];
		sort(v.begin(),v.end());
		L ans=0;
		for(L i=0; i<n; i++) ans += v[i]*(n-i-1);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3096
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// namespace
using namespace std;
// type
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
// input
#define INIT              ({ ios::sync_with_stdio(false); cin.tie(0); })
#define VAR(type, ...)    type __VA_ARGS__; var_scan(__VA_ARGS__);
template<typename T>
static void var_scan(T& t)
{
    cin >> t;
}
template<typename T, typename... R>
static void var_scan(T& t, R&... rest)
{
    cin >> t;
    var_scan(rest...);
}
// output
#define OUT(var)          cout << (var)
#define SPC               cout << ' '
#define TAB               cout << '\t'
#define BR                cout << '\n'
#define ENDL              cout << endl
#define FLUSH             cout << flush
// debug
#ifdef DEBUG
#define EPRINTF(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
#define DUMP(var)         cerr << #var << '\t' << (var) << '\n'
#define DUMPITERABLE(i) do {                            \
        cerr << #i << '\t';                             \
        for (const auto& it : i) { cerr << it << ' '; } \
        cerr << '\n';                                   \
} while (0)
#define DUMPITERABLE2(i2) do {                          \
        cerr << #i2 << '\t';                            \
        for (const auto& it : i2) {                     \
            for (const auto& it2: it) {                 \
                cerr << it2 << ' ';                     \
            }                                           \
        }                                               \
        cerr << '\n';                                   \
} while (0)
#else
#define EPRINTF(fmt, ...)
#define DUMP(var)
#define DUMPITERABLE(i)
#define DUMPITERABLE2(i)
#endif
// util
// [l, r)
#define REP(i, n)       for (int i = 0; i < (n); i++)
#define RREP(i, n)      for (int i = (n)-1; i >= 0; i--)
#define FOR(i, l, r)    for (int i = (l); i < (r); i++)
#define RFOR(i, r, l)   for (int i = (r)-1; i >= (l); i--)
#define REPLL(i, n)     for (ll i = 0; i < (n); i++)
#define RREPLL(i, n)    for (ll i = (n)-1; i >= 0; i--)
#define FORLL(i, l, r)  for (ll i = (l); i < (r); i++)
#define RFORLL(i, r, l) for (ll i = (r)-1; i >= (l); i--)

int main(void)
{
    INIT;
    VAR(ll, a, b, c, d);
    ll l = b * d, m = a * c, n = a * d, o = b * c, maximum;
    maximum = max(o, max(n, max(l, m)));
    OUT(maximum);
    ENDL;
    return 0;
}


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


int main(){
    int N;
    ll sum;
    cin >> N;
    sum = 0;
    for(int i = 1; i <= N; i++){
        if(i % 3 == 0 || i % 5 == 0){
            continue;
        }
        sum += i;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3596
import math

def is_prime(n):
  if n == 1: return False
  for k in range(2, int(math.sqrt(n)) + 1):
    if n % k == 0:
      return False
  return True

def int_input():
    return int(input())
  
int_input = int_input()
while True:
  if is_prime(int_input):
    print(int_input)
    break
  else:
    int_input += 1



Measured memory_bytes: 2940
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
const int inf = 1e9;
const int mod = 1e9+7;

int main() {
    int L, R;
    cin >> L >> R;

    if (R - L >= 2019 || L == 0) {
        cout << 0 << endl;
        return 0;
    }

    int ans = 1e9;
    for (int i = L; i <= R; i++) {
        for (int j = i+1; j <= R; j++) {
            ll x = (ll)i * (ll)j;
            x %= 2019;
            ans = min(ans, (int)x);
        }
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//解説AC
int main() {
  string s;
  cin>>s;
  if(s.size()==1){
    cout<<s<<endl;
    return 0;
  }
  int kotae=s[0]-'0';
  bool hantei=false;
  for(int i=1;i<s.size();i++){
    if(s[i]=='9')hantei=true;
    else {
      hantei=false;
      break;
    }
  }
  kotae+=9*(s.size()-1);
  if(hantei==false)kotae--;
  cout<<kotae<<endl;
  return 0;
}
  


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

using namespace std;

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

	string alt_one;
	string alt_two;

	for(int i=0;i<s.length();i++)
	{	
		if(i&1)
			alt_one.push_back('0');
		else
			alt_one.push_back('1');
	}

	for(int i=0;i<s.length();i++)
	{
		if(i&1)
			alt_two.push_back('1');
		else
			alt_two.push_back('0');
	}

	int cnt1=0,cnt2=0;

	for(int i=0;i<s.length();i++)
	{
		cnt1+=(s[i]!=alt_one[i]);
		cnt2+=(s[i]!=alt_two[i]);
	}

	cout<<min(cnt1,cnt2)<<'\n';

	return 0;	
}

Measured memory_bytes: 640
import Data.List
import Data.Array
import Data.Maybe
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BS8
 
getInts :: IO [Int]
getInts = (map parseInt . BS8.words) <$> BS.getLine 
    where parseInt = fst . fromJust . BS8.readInt
 
solve :: Int -> [Int] -> Int
solve k ls = sum $ drop k v
    where v = sortBy (flip compare) $ map length $ group (sort ls)
 
main :: IO ()
main = do
    [n, k] <- getInts
    ls <- getInts
    print (solve k ls)

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

int main(){
    string S;cin>>S;
    long N=S.size();
    long num=0;long count=0;
    for(int i=0;i<N;i++){
        if(S.at(i)=='W'){
            count+=i-num;
            num++;
        }
    }cout<<count<<endl;
}  

Measured memory_bytes: 640
def rec(m,i,j)
  m[i][j]=0
  rec(m,i,j+1) if j<11 and m[i][j+1]==1
  rec(m,i,j-1) if j>0 and m[i][j-1]==1
  rec(m,i+1,j) if i<11 and m[i+1][j]==1
  return m
end
loop do
  m,c=[],0
  12.times do
    m<<gets.split("").map(&:to_i)
  end
  12.times do |i|
    12.times do |j|
      if m[i][j]==1
        m=rec(m,i,j)
        c+=1
      end
    end
  end
  p c
  break if !gets
end

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    bool check = false;
    if(a == 5 && b == 7 && c == 5){
        check = true;
    }else if(a == 7 && b == 5 && c == 5){
        check = true;
    }else if(a == 5 && b == 5 && c == 7){
        check = true;
    }else{

    }
    if(check) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	int minA=a/0.08;
	int minB=b/0.1;
	int start=min(minA,minB);
	while(0.02*start<abs(b-a)+1){
		int x=start*0.08;
		int y=start*0.10;
		if(x==a&&y==b){
			printf("%d",start);
			return 0;
		}
		start++;
	}
	printf("-1");
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        int xor = 0;
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
            xor ^= array[i];
        }
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < n; i++) {
            builder.append(xor ^ array[i]).append(" ");
        }
        System.out.print(builder);
    }
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    while(1) {
        ll n, l, r;
        cin >> n >> l >> r;
        if(!n) break;
        vector<ll> a(n);
        REP(i, n) cin >> a[i];

        ll ret = 0;
        FOR(i, l, r+1) {
            ll ans = -1;
            REP(j, n) {
                if(i%a[j]==0) {
                    if(j%2==0) ans = 1;
                    else ans = 0;
                    break;
                }
            }
            if(ans == -1) {
                if(n%2) ans = 0;
                else ans = 1;
            }
            ret += ans;
        }

        // cerr << "ans=";
        cout << ret << endl;
    }


    return 0;
}



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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1'000'000'000'000'007ll;
const llong mod = 1e9+7;

int main() {
	llong M;
	vector<lpair> dc;

	cin >> M;
	dc.resize(M);
	for (auto &in: dc) {
		cin >> in.first >> in.second;
	}

	llong ans = 0;
	int now = 0;
	stack<int> s;
	for (auto add: dc) {
		while (add.second > 0) {
			if (add.second&1) {
				s.push(add.first);
				--add.second;
				continue;
			}
			ans += add.second >> 1;
			add.second >>= 1;
			add.first <<= 1;
			if (add.first >= 10) {
				ans += add.second;
				add.first -= 9;
			}
		}

		while (s.size()) {
			int next = s.top();
			s.pop();

			++ans;
			now += next;
			if (now >= 10) {
				++ans;
				now -= 9;
			}
		}
	}

	cout << ans - 1 << endl;

	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////


int main() {

	ll N, W;
	cin >> N >> W;

	vector<ll> w(N + 1), v(N + 1);
	repn(i, N) cin >> w[i] >> v[i];

	ll ans = 0;

	rep(i,N+1){

		ll x = W - w[1] * i;
		x = min(x, 3 * N);
		if (x < 0) { continue; }

		ll dp[200][200][400] = {};

		repn(j, N)repn(k,N)rep(l, 3 * N + 1) {
			if (l < w[j] - w[1]) {
				dp[j][k][l] = dp[j - 1][k][l];
				continue;
			}
			dp[j][k][l] = max(dp[j - 1][k][l], dp[j-1][k - 1][l - (w[j] - w[1])] + v[j]);
		}

		ans = max(ans, dp[N][i][x]);

		
	}

	cout << ans;
	
	system("PAUSE");
}


Measured memory_bytes: 125440