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

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

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

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}
int N,K;
Vi A,F;

bool check(int x){
    int need=0;
    REP(i,0,N){
        int power=x/F[i];
        int aneed=max(0LL,A[i]-power);
        need += aneed;
   }

//   cout<<"x="<<x<<" need="<<need<<endl;

   if(need<=K) return true;
   else return false;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    scanf("%lld",&N);
    scanf("%lld",&K);
    A=Vi(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    F=Vi(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&F[i]);
    }

    sort(ALL(A));
    sort(ALL(F),greater<int>());

    int sum=0;
    REP(i,0,N) sum+=A[i];
    if(sum<=K) {cout<<0<<endl;return 0;}

    int low=0,high=INF;
    while(high-low>1){
        int mid=(low+high)/2;
        if(check(mid)) high=mid;
        else low=mid;
    }
    cout<<high<<endl;

    return 0;
}


Measured memory_bytes: 3328
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.util.Set;

public class Main {

	static void exec(MyScanner in, PrintWriter out) {
		int N = in.nextInt();
		Set<Integer> set = new HashSet<>(N);
		for (int i = 0; i < N; i += 1) {
			int a = in.nextInt();
			if (!set.add(a)) {
				set.remove(a);
			}
		}
		out.println(set.size());
	}

	public static void main(String[] args) {
		PrintWriter w = new PrintWriter(System.out);
		exec(new MyScanner(System.in), w);
		w.flush();
	}

	static class MyScanner {
		static final int BUFFER_SIZE = 1024;
		private final InputStream in;
		private final byte[] buffer = new byte[BUFFER_SIZE];
		private int point;
		private int readLength;
		MyScanner(InputStream in) {
			this.in = in;
		}
		private int readByte() {
			if (point < readLength) {
				int result = buffer[point];
				point += 1;
				return result;
			}
			try {
				readLength = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (readLength == -1) {
				return -1;
			}
			point = 1;
			return buffer[0];
		}
		static boolean isPrintableCharExceptSpace(int c) {
			return 33 <= c && c <= 126;
		}
		String next() {
			StringBuilder b = new StringBuilder();
			int c = readByte();
			while (!(c == -1 || isPrintableCharExceptSpace(c))) {
				c = readByte();
			}
			if (c == -1) {
				throw new NoSuchElementException();
			}
			do {
				b.appendCodePoint(c);
				c = readByte();
			} while (c != -1 && isPrintableCharExceptSpace(c));
			return b.toString();
		}
		long nextLong() {
			int c = readByte();
			while (!(c == -1 || isPrintableCharExceptSpace(c))) {
				c = readByte();
			}
			if (c == -1) {
				throw new NoSuchElementException();
			}
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long result = 0L;
			do {
				if (!('0' <= c && c <= '9')) {
					throw new InputMismatchException();
				}
				result = result * 10L + (c - '0');
				c = readByte();
			} while (c != -1 && isPrintableCharExceptSpace(c));
			return minus ? -result : result;
		}
		int nextInt() {
			long n = nextLong();
			if (Integer.MIN_VALUE <= n && n <= Integer.MAX_VALUE) {
				return (int) n;
			}
			throw new InputMismatchException();
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

}


Measured memory_bytes: 28604
#include"bits/stdc++.h"
using namespace std;


int main() {
	int N;	cin >> N;
	vector<int> T(N+1);
	for (int i = 1; i <= N; i++) cin >> T[i];
	int M;	cin >> M;
	vector<int> P(M+1), X(M+1);
	for (int i = 1; i <= M; i++) {
		cin >> P[i] >> X[i];
		int sum = 0;
		for (int j = 1; j <= N; j++) {
			if (P[i] == j) {
				sum += X[i];
			}
			else {
				sum += T[j];
			}
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  	int x ;
  	cin >> x ;
  	int i = 0;
  while(i<x){
    string s;
    cin >> s;
     if (s == "Y") {
      cout << "Four" << endl;
      break;
     }
    i++;
  }
 	if (i==x) cout << "Three" << endl;
  }

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int m,f,r;
while(1){
scanf("%d %d %d",&m ,&f ,&r);
if (m == -1 && f == -1 && r == -1){
break;
}else if (m == -1 || f == -1){
printf("F\n");
}else if (m+f >= 80){
printf("A\n");
}else if (m+f >= 65 && m+f < 80){
printf("B\n");
}else if (m+f >= 50 && m+f < 65){
printf("C\n");
}else if (m+f >= 30 && m+f < 50 && r >= 50){
printf("C\n");
}else if (m+f >= 30 && m+f < 50 && r < 50){
printf("D\n");
}else if (m+f < 30){
printf("F\n");
}
}
return 0;
}

Measured memory_bytes: 580
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;

int main()
{
 int N;
 scanf("%d",&N);
 if((N%10)==9||(N/10)==9){printf("Yes\n");}
 else{printf("No\n");}
} 



Measured memory_bytes: 3756
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := sc.NextIntArray()
	cnt := 0
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			if A[i] == A[j] {
				continue
			}
			for k := j + 1; k < N; k++ {
				if A[i] == A[k] {
					continue
				}
				if A[j] == A[k] {
					continue
				}

				T := []int{A[i], A[j], A[k]}
				sort.Ints(T)
				if T[0]+T[1] > T[2] {
					cnt++
				}

			}
		}
	}
	fmt.Println(cnt)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vi;

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

	int X, N;
	cin >> X >> N;
	bool p[220];
	for(int i = 0; i < 220; ++i) p[i] = false;
	for(int i = 0; i < N; ++i) {
		int x;
		cin >> x;
		p[x] = true;
	}
	for(int d = 0; true; ++d) {
		if(!p[X-d]) return cout << X-d << "\n", 0;
		if(!p[X+d]) return cout << X+d << "\n", 0;
	}

	return 0;
}

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

#define MOD 1000000007LL

long long dp[10010][110][2];

int main(){
	string K;
	int D;
	cin >> K >> D;
	
	dp[0][0][0]=1;
	for(int i=0;i<K.size();i++)for(int j=0;j<D;j++){
		int k=K[i]-'0';
		for(int x=0;x<10;x++){
			if(x==k)dp[i+1][(j+x)%D][0]+=dp[i][j][0];
			if(x<k)dp[i+1][(j+x)%D][1]+=dp[i][j][0];
			dp[i+1][(j+x)%D][1]+=dp[i][j][1];
			dp[i+1][(j+x)%D][0]%=MOD;
			dp[i+1][(j+x)%D][1]%=MOD;
		}
	}
	/*for(int i=0;i<=K.size();i++){
		for(int j=0;j<D;j++)cout << dp[i][j][0] << " ";
		cout << endl;
	}
	for(int i=0;i<=K.size();i++){
		for(int j=0;j<D;j++)cout << dp[i][j][1] << " ";
		cout << endl;
	}*/
	cout << (dp[K.size()][0][0]+dp[K.size()][0][1]+MOD-1)%MOD << endl;
	return 0;
}

Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
int pos(int x){
	if(x>=0) return x;
	return -1*x;
}
int main(){

	int n,a1,sum=0,ans;
	cin>>n;
	vector<int> a(n);
	for(a1=0;a1<n;++a1){
		cin>>a[a1];
		sum+=a[a1];
	}
	ans=sum;
	// sort(a.begin(),a.end());
	int dum=0;
	for(a1=0;a1<n;++a1){
		dum+=a[a1];
		ans=min(ans,pos(sum-2*dum));
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60
#define MOD 1000000007

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j
#define fix(i) fixed << setprecision(i)


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

int main(){
    string a[] = { "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" };

    vector<string> aa;
    rep(i, 0, 32){
        aa.push_back(a[i]);
    }

    int K;
    cin >> K;

    cout << aa[K - 1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
int main (){
    int D;
    scanf("%d",&D);
    if(D == 22){
        printf("Christmas Eve Eve Eve");
    }
     if(D == 23){
        printf("Christmas Eve Eve");
    }
     if(D == 24){
        printf("Christmas Eve");
    }
     if(D == 25){
        printf("Christmas");
    }
    

    
   
}
 //chcp 65001 cd contest

Measured memory_bytes: 128
import sys
from collections import defaultdict
from collections import deque
import numpy as np
import heapq
from heapq import heappop, heappush

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

M = int(input())
PList = [""] * M
Num = [0] * M

for i in range(M):
    s, t = input().split()
    t = int(t)
    PList[i] = s
    Num[i] = t

X = input()
x = PList.index(X)

print(sum(Num[x+1:]))


Measured memory_bytes: 22040
l = int(input())
m = input()

l = 0
r = 0
b = 0
for i in m:
    if i == ")":
        l += 1
    else:
        r += 1
    m = "(" * max(l-r,0) + m
    r += max(l-r,0)
m += ")" * max(r-l,0)
print(m)
        

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

using namespace std;

const int MaxN = 1e2 + 12;

int n;
int a[MaxN], b[MaxN], c[MaxN], d[MaxN];
bool used[MaxN];
int m[MaxN];

bool tryk(int x)
{
    if(used[x])
        return false;

    used[x] = true;

    for(int i = 1; i <= n; ++i)
    {
        if(a[x] <= c[i] && b[x] <= d[i] && (!m[i] || tryk(m[i])))
        {
            m[i] = x;
            return true;
        }
    }
    return false;
}

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

    cin >> n;
    for(int i = 1; i <= n; ++i)
        cin >> a[i] >> b[i];
    for(int i = 1; i <= n; ++i)
        cin >> c[i] >> d[i];

    int ans = 0;
    for(int i = 1; i <= n; ++i)
    {
        for(int j = 1; j <= n; ++j)
            used[j] = false;
        if(tryk(i))
            ++ans;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {

	int N, C[100], V[100];

	cin >> N;

	for (int i = 1; i <= N; i++) {
		cin >>V[i];
	}
	for (int i = 1; i <= N; i++) {
		cin >> C[i];
	}

	int ans = 0;

	for (int i = 1; i <= N; i++) {
		if (V[i] > C[i]) { ans += V[i] - C[i]; }
	}

	cout << ans << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n, k = ns()
    a = na()

    dp = [INF for _ in range(n)]
    dp[0] = 0

    for i in range(n):
        for j in range(k):
            if i + j + 1 < n:
                dp[i + j + 1] = min(dp[i + j + 1], dp[i] + abs(a[i] - a[i + j + 1]))
            else:
                break

    print(dp[n - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 94692
#include <iostream>
#include <stdio.h>
#include <stdint.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <deque>

using namespace::std;

int ri()
{
	int x;
	scanf("%d", &x);

	return x;
}

int64_t ri64()
{
	int64_t x;
	scanf("%lld", &x);

	return x;
}

void wi(int x)
{
	printf("%d\n", x);
}

void wvi(vector<int> &v)
{
	for (int i = 0; i < v.size(); i++)
		printf("%d ", v[i]);
	printf("\n");
}

void dbg(string &str, int x)
{
	cout << str << ": ";
	wi(x);
}

void dbg(string &str, vector<int> &x)
{
	cout << str << ": ";
	wvi(x);
}

int64_t mod = 1000000007;

int64_t get_num(int64_t N, int64_t K)
{
        int64_t low = (K * (K - 1)) / 2;
        int64_t high = (N * (N + 1)) / 2 - ((N - K) * (N - K + 1)) / 2;

        return (high + 1 - low);
}

int main()
{
        int64_t N = ri();
        int64_t K = ri();

        int64_t ans = 0;
        for (int64_t k = K; k <= (N + 1); k++)
                ans = (ans + get_num(N, k)) % mod;

        wi((int) ans);

	return 0;
}


Measured memory_bytes: 3816
#include<bits/stdc++.h>
#define isbs ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
int a,b,c,d,e,pas;
string s;
int main(){
	isbs;
	cin>>a;
	d=0;
	e=1;
	for(b=1; b<=a; b++){
		cin>>c;
		if(c!=d){
			pas=pas+e/2;
			e=1;
			d=c;
		}else{
			e++;
		}
	}
  pas=pas+e/2;
	cout<<pas;
	return 0;
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

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

    int n;
    cin >> n;
    vector<int> a(n), b(n);
    REP(i, n) cin >> a[i];

    REP(i, n) b[i] = a[i] - (i+1);
    sort(all(b));
    int mid = 0;
    if(n & 1) mid = b[n/2];
    else mid = (b[n/2-1] + b[n/2]) / 2;

    int ans = 0;
    REP(i, n) ans += abs(b[i]-mid);
    cout << ans << endl;
}


Measured memory_bytes: 3456
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int r,d,x;
    scanf("%d%d%d", &r, &d, &x);

    int i;
    ll tmp=x;
    for(i=0; i<10; i++) {
        tmp = tmp*r-d;
        printf("%lld\n", tmp);
    }

    return 0;
}



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

int main(){
  vector<int> a = {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};
  int N;cin >> N;
  cout << a[N - 1] << endl;
}

Measured memory_bytes: 256
import sys
from functools import lru_cache
sys.setrecursionlimit(1000000000)

N = int(input())

@lru_cache(maxsize=1000)
def recursive(n):
    if n==0:
        return 2
    elif n==1:
        return 1
    else:
        return recursive(n-1)+recursive(n-2)

print(recursive(N))

Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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; }
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0, 0,-1,1,-1, 1,-1};
int dy[]={0,1,-1, 0,1,-1,-1, 1};

 
 
LL fpow(LL a, LL n){
    LL x = 1;
    while(n > 0){
        if(n&1){
            x=x*a%mod;
        }
        a=a*a%mod;
        n >>= 1;
    }
    return x;
}
 

int main(){
    LL n;cin >> n;
    vector<LL> c(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    sort(ALL(c));
    LL ans = 0;
    for (int i = 0; i < n; i++) {
        ans = (ans + fpow(2, n) * ((n - 1 - i) * fpow(2, n - 2 - i) %mod + fpow(2, n - 1 - i))%mod * fpow(2, i) %mod * c[i]%mod)%mod;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<pair<long, long>> v(N*2);
	for(int i=0; i<N; ++i){
	    int a;
	    cin >> a;
	    v[i]=make_pair(a, 1);
	}
	for(int i=0; i<N; ++i){
	    int a;
	    cin >> a;
	    v[N+i]=make_pair(a, -1);
	}
	sort(v.begin(), v.end());
	long ans=1, now=0, mod=1000000007;
	for(int i=0; i<N*2; ++i){
	    if(now*v[i].second<0) ans=(ans*abs(now))%mod;
	    now += v[i].second;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
	long long n,i,j,k,sum=0,count=0;
	cin>>n;
	long long a[n][3],dp[n][3];
	for(i=0;i<n;i++)
	for(j=0;j<3;j++)
	cin>>a[i][j];
	dp[0][0]=a[0][0];
	dp[0][1]=a[0][1];
	dp[0][2]=a[0][2];
	for(i=1;i<n;i++)
	{
	   
	    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
	     dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
	      dp[i][2]=max(dp[i-1][1],dp[i-1][0])+a[i][2];
	}
     cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
     
	return 0;
} 

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

def input_one_number():
    return int(input())

def input_multiple_number():
    return map(int, input().split())

def input_multiple_number_as_list():
    return list(map(int, input().split()))

A,B,C,K = input_multiple_number()

ans = 0

if A >= K:
	print(K)
elif A+B >= K:
	print(A)
else:
	print(A-(K-A-B))


Measured memory_bytes: 9172
#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(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

pi calc(const string &s){
    int mn = 0;
    int c = 0;
    rep(i,s.size()){
        if(s[i]=='(') ++c;
        else --c;
        mn = min(mn, c);
    }

    return {c,mn};
}

string rev(const string &s){
    string t = s;
    int n = s.size();
    rep(i,n) t[n-1-i] = (s[i]=='('?')':'(');
    return t;
}

int dep(const vector<pi> &v){
    multiset<pi> ms;

    int n = v.size();
    rep(i,n) ms.insert({-v[i].fi, v[i].se});

    int ret = 0;
    while(!ms.empty()){
        auto itr = ms.begin();
        while(itr != ms.end()){
            if(ret + itr->se >= 0) break;
            ++itr;
        }

        if(itr == ms.end()) return -1;

        ret += -itr->fi;
        ms.erase(itr);
    }

    return ret;
}

bool solve(){
    int n;
    cin >>n;

    vector<pi> l,r;
    rep(i,n){
        string s;
        cin >>s;

        pi v = calc(s);
        if(v.fi>=0) l.pb(v);
        else r.pb(calc(rev(s)));
    }

    int ld = dep(l), rd = dep(r);
    return (ld!=-1 && rd!=-1 && ld==rd);
}

int main(){
    cout << (solve()?"Yes":"No") << endl;
    return 0;
}



Measured memory_bytes: 3200
#include <stdio.h>

int main(void)
{
  int A,B,C;
  scanf("%d %d %d",&A,&B,&C);
  
  if(A == B) {
    if(B == C) {
      printf("No\n");
    } else {
      printf("Yes\n");
    }
  } else {
    if(B == C || A == C) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }
  
  return 0;
}

  

Measured memory_bytes: 128
#include <iostream>
using namespace std;
typedef long long ll;

ll x, y;

int main() {
	cin >> x >> y;

	ll i = 0, num = x;
	while (true) {
		//cout << x*pow(2, i) << endl;
		if (y < num)break;
		num *= 2;
		i++;
	}

	cout << i << endl;
}

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

typedef struct point_1
{
	double x,y;
} point;

void koch(int n,point r,point w)
{
	point s, t, u;

	if (n == 0){return;}


	double z= M_PI * 60.00 / 180.00;
	s.x = (2.0 * r.x + 1.0 * w.x) / 3.0;
	s.y = (2.0 * r.y + 1.0 * w.y) / 3.0;
	t.x = (1.0 * r.x + 2.0 * w.x) / 3.0;
	t.y = (1.0 * r.y + 2.0 * w.y) / 3.0;
	u.x = (t.x - s.x) * cos(z) - (t.y - s.y) * sin(z) + s.x;
	u.y = (t.x - s.x) * sin(z) + (t.y - s.y) * cos(z) + s.y;

	koch(n - 1, r, s);

	printf("%.8f %.8f\n", s.x, s.y);
	koch(n - 1, s, u);

	printf("%.8f %.8f\n", u.x, u.y);
	koch(n - 1, u, t);
	
	printf("%.8f %.8f\n", t.x, t.y);
	koch(n - 1, t, w);

}

int main(int argc, char** argv)
{
	point r,w;
	int n;

	scanf("%d", &n);

	r.x = 0, r.y = 0;
	w.x = 100, w.y = 0;

	printf("%.8f %.8f\n", r.x, r.y);
	koch(n, r, w);
	printf("%.8f %.8f\n", w.x, w.y);


	return 0;
}



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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int a,b,c;cin>>a>>b>>c;
    cout<<min(a+b,min(b+c,c+a));
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	io := newIo()
	defer io.Flush()

	n := io.NextInt()
	k := io.NextInt()

	var one int
	for i := range make([]struct{}, n) {
		if io.NextInt() == 1 {
			one = i
		}
	}
	pos := one
	cnt := 0
	bonus := 0

	for pos > 0 {
		pos -= k - 1
		cnt++
		if pos < 0 {
			bonus += -pos
		}
	}
	pos = one
	for pos < n-1 {
		pos += k - 1
		cnt++
		if pos >= n {
			bonus += pos - (n - 1)
		}
	}
	io.Println(cnt - bonus/(k-1))
}

type io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func newIo() *io {
	return &io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *io) Flush() {
	_ = io.writer.Flush()
}

func (io *io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, _ := io.reader.ReadLine()
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *io) NextWord() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *io) NextInt() int {
	i, _ := strconv.Atoi(io.NextWord())
	return i
}

func (io *io) Print(a ...interface{}) {
	fmt.Fprint(io.writer, a...)
}

func (io *io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll i = 0; i < n; i++) cin >> a[i];
    ll ans = 0;
    for(ll i = 0; i < n-1; i++){
        if(a[i] > a[i+1]){
            ans += a[i]-a[i+1];
            a[i+1] = a[i];
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, x, s[210];

    cin >> n >> x;
    REP(i, n)
    {
        cin >> s[i];
        s[i] *= -1;
    }

    sort(s, s + n);

    REP(i, n)
    s[i] *= -1;

    if (n == 1)
    {
        cout << x % s[0] << endl;
        return 0;
    }

    //TODO:
    ll dp[210][112345];

    memset(dp, 0, sizeof(dp));

    dp[0][x % s[0]] += 1;
    dp[0][x] += n - 1;

    REP(i, n - 1)
    {
        for (int j = 0; j <= x; j++)
        {
            (dp[i + 1][j % s[i + 1]] += dp[i][j]) %= MOD;
            (dp[i + 1][j] += dp[i][j] * (n - i - 2)) %= MOD;
        }
    }

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

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 184576
#include <bits/stdc++.h>
using namespace std;
int a , b, raspuns[5000];
stack <int> stec;
inline bool intreb(int a , int b)
{

    printf("? %d %d\n", a - 1, b - 1);
    fflush(stdout);
    char raspuns;
    scanf("%c", &raspuns);
    if (raspuns != 'Y' && raspuns != 'N')
        scanf("%c", &raspuns);
    if (raspuns == 'Y')
        return true;
    return false;
}
int main()
{
    scanf("%d %d", &a, &b);
    int n = a + b;
    if (a <= b)
    {
        printf("Impossible");
        return 0;
    }
    stec.push(1);

    for (int i = 2; i<=n; ++i)
    {
        if (stec.empty())
        {
            stec.push(i);
            continue;
        }
        int top = stec.top();
        bool raspuns = intreb(top , i);
        if (raspuns == 1)
            stec.push(i);
        else stec.pop();
    }
    raspuns[stec.top()] = 1;


    for (int i = 1; i<=n; ++i)
        if (i != stec.top())
            raspuns[i] = intreb(stec.top() , i);

    printf("! ");
    for (int i = 1; i<=n; ++i)
    {
        printf("%d", raspuns[i]);
    }
    fflush(stdout);
    return 0;
}


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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, "\e[31;1m"); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\e[0m")
#else
    #define eprintf(...) 42
#endif

ll f(ll X, ll n)
{
    if (-1 == n)
    {
        return 0;
    }
    return (n / X + 1);
}

ll solve(ll A, ll B, ll X)
{
    ll a = f(X, A - 1);
    ll b = f(X, B);
    return b - a;
}

int main(void)
{
    ll A, B, X;
    std::cin >> A >> B >> X;
    std::cout << solve(A, B, X) << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 62;
const ll MODULO = 1e9+7;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    map<char, int> d;
    // cout << s << endl;
    long long res = 1;
    for (int i=0; i<n; i++) {
        d[s[i]]++;
    }
    for (int i=0; i<26; i++) {
        res *= d[char('a' + i)] + 1;
        res %= MODULO;
    }
    res--;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 512
from itertools import combinations_with_replacement

n, m, q = map(int,input().split())
l = []
s = []
for _ in range(q):
    a, b, c, d = map(int,input().split())
    l.append([a, b, c, d])

ps = list(combinations_with_replacement(range(1, m+1), n-1))
n_p = len(ps)

for i in range(n_p):
    ns = [1] + list(ps[i])
    ss = 0
    for j in range(q):
        k = l[j]
        if ns[k[1]-1] - ns[k[0]-1] == k[2]:
            ss += k[3]
    s.append(ss)

print(max(s))



Measured memory_bytes: 16572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1e9+7;
int n;
int arr[25][25];
int dp[(1LL<<21)+1];
int solve(int mask,int pos)
{
    //cout<<mask<<" "<<pos<<endl;
    if(pos>n)
        return 0;
    if(pos==n)
    {
        if(mask==((1LL<<n)-1))
            return 1;
        else
        {
            return 0;
        }
        
    }
    if(dp[mask]!=-1)
        return dp[mask];
    int ans = 0;
    for(int i=0;i<n;i++)
    {
        if(arr[pos][i])
        {
            if(mask&(1LL<<i))
                continue;
           // cout<<pos<<" "<<mask<<endl;
            ans += solve(mask|(1LL<<i),pos+1);
            ans%=mod;
        }
    }
    return dp[mask]=ans;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int i,j;
    cin>>n;
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            cin>>arr[i][j];
        }
    }
    memset(dp,-1,sizeof(dp));
    int ans=solve(0,0);
    cout<<ans<<endl;
    /*for(i=0;i<n;i++)
    {
        for(j=0;j<=(1LL<<n);j++)
        {
            cout<<dp[j]<<" ";
        }
        cout<<endl;
    }*/
}

Measured memory_bytes: 16640
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    ll l[103];
    for(int i = 0; i < n; i++) cin >> l[i];
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            for(int k = j + 1; k < n; k++){
                if(max(l[i], max(l[j], l[k])) * 2 < l[i] + l[j] + l[k] && l[i] != l[j] && l[j] != l[k] && l[k] != l[i]){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3624
x = gets.to_i
k = 0
case x
when 400..599
  k = 8
when 600..799
  k = 7
when 800..999
  k = 6
when 1000..1199
  k = 5
when 1200..1399
  k = 4
when 1400..1599
  k = 3
when 1600..1799
  k = 2
when 1800..1999
  k = 1
end
puts k


Measured memory_bytes: 14332
n, m = [int(_) for _ in input().split()]
l = []
AC = 0
WA = 0
for i in range(m):
    l.append(input().split())
d = {}
for i in range(n):
    d[i + 1] = 0
for i in range(m):
    p, s = l[i]
    p = int(p)
    if s == 'WA':
        if d[p] != -1:
            d[p] += 1
    else:
        if d[p] != -1:
            AC += 1
            WA += d[p]
            d[p] = -1
    # print(d)
    # print(AC, WA)
print(AC, WA)

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

l, r = (A[0], 1)
def is_ok(c):
    x = sum([math.ceil(a/c)-1 for a in A])
    return x <= K

l, r = max(A), 0
while l - r > 1:
    c = (l + r) // 2
    if is_ok(c):
        l = c
    else:
        r = c
print(l)


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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for(ll i = n-1; i >= 0LL; i--)
#define FOR(i, n, m) for(ll i = n; i < (ll)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()
#define INF (ll)1e18
#define INFD 1e18
#define PI 3.14159265358979
#define MOD 1000000007
#define vl vector<ll>

vector<ll> dx = {-1, 1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

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


void check(vector<bool> &v, ll N, string S) {
	FOR(i, 1, N-1) {
		if(S[i] == 'o') {
			if (v[i]) v[i+1] = v[i-1];
			else v[i+1] = !v[i-1];
		} else {
			if (v[i]) v[i+1] = !v[i-1];
			else v[i+1] = v[i-1];
		}
	}
	if (!(!((S[N-1] == 'o') ^ v[N-1]) ^ (v[N-2] == v[0]))) {
		if (!(!((S[0] == 'o') ^ v[0]) ^ (v[N-1] == v[1]))) {
			REP(i, N) {
				if (v[i]) cout << "S";
				else cout << "W";
			}
			cout << endl;
			exit(0);
		}
	}
}

int main()
{
	ll N;
	string S;
	cin >> N >> S;
	vector<bool> v(N);
	v[0] = true;
	v[1] = true;
	check(v,N,S);
	v[0] = false;
	v[1] = true;
	check(v,N,S);
	v[0] = true;
	v[1] = false;
	check(v,N,S);
	v[0] = false;
	v[1] = false;
	check(v,N,S);
	PRINT(-1);
	return 0;
}


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

using namespace std;

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

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

    sort(a.begin(), a.end());
    for (int i = 0; i < k; i++) {
        sum += a[i];
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>
int main(void){
    // 自分の得意な言語で
    // Let's チャレンジ！！

    int n;
    scanf("%d",&n);

    if(n==0){
        puts("1");
    }else if(n==1){
        puts("0");
    }
 
    
    return 0;
}

Measured memory_bytes: 1640
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
        String a=scan.next();
        String b=scan.next();
        int flag=0;
        if(a.charAt(0)=='H'){
            System.out.println(b);
        }
        else{
            if(b.charAt(0)=='H'){
                System.out.println("D");
            }
            else{
                System.out.println("H");
            }
        }
    }
}

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

int main(){
  int x, a, b;
  cin >> x >> a >> b;
  if(a >= b) cout << "delicious" << "\n";
  else {
    if(b-a > x) cout << "dangerous" << "\n";
    else cout << "safe" << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
// Problem : A - ∴ (Therefore)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define ll long long
#define mod 1000000007
int lcm(int x,int y){
	return x/__gcd(x,y)*y;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    reverse(s.begin(),s.end());
    if(s[0]=='2' || s[0]=='4' || s[0]=='5' || s[0]=='7' || s[0]=='9'){
    	cout<<"hon"<<endl;
    }
    if(s[0]=='0' || s[0]=='1' || s[0]=='6' || s[0]=='8'){
    	cout<<"pon"<<endl;
    }
    if(s[0]=='3'){
    	cout<<"bon";
    }
    return 0;
}


Measured memory_bytes: 3588
#include <cstdio>
#include <cstring>
#include <string>
#include <queue>
#include <cstdlib>
#include <algorithm>
using namespace std;
typedef long long LL;
const int MAXN = 1e5 + 5;
const LL P = -1e15;

struct XXX{
	LL a, b, c;
}s[MAXN + 5];

priority_queue<LL, vector<LL>, greater<LL> >Pa, Pb;
LL A[MAXN + 5], B[MAXN + 5], C[MAXN + 5];
LL sumL[MAXN + 5], sumR[MAXN + 5];
LL Csum = 0, suma, sumb;

int AA, BB, CC, N;

bool cmp(XXX a, XXX b) { return a.c < b.c; }

int main()
{
	scanf("%d %d %d", &AA, &BB, &CC);
	N = AA + BB + CC;
	for(int i = 1; i <= N; i++)
		scanf("%lld %lld %lld", &A[i], &B[i], &C[i]);
	for(int i = 1; i <= N; i++)
		s[i].a = A[i] - C[i], s[i].b = B[i] - C[i], Csum += C[i], s[i].c = s[i].a - s[i].b;
	stable_sort(s + 1, s + 1 + N, cmp);
	for(int i = 1; i <= N; i++){
		LL b = s[i].b;
		if(i <= BB) sumb += s[i].b, Pb.push(b);
		else if(b > Pb.top()){
			LL a = Pb.top();
			sumb -= a, sumb += b;
			Pb.pop(), Pb.push(b);
		}
		sumL[i] = sumb;
	}
	for(int i = N; i >= 1; i--){
		LL a = s[i].a;
		if(i >= N - AA + 1) suma += a, Pa.push(a);
		else if(a > Pa.top()){
			LL b = Pa.top();
			suma -= b, suma += a;
			Pa.pop(), Pa.push(a);
		}
		sumR[i] = suma;
	}
	LL Max = P;
	for(int i = BB; i <= N - AA; i++) Max = max(Max, sumL[i] + sumR[i + 1]);
	printf("%lld\n", Max + Csum);
}

Measured memory_bytes: 8300
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;

#define io ios_base::sync_with_stdio(false)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vll vector<long long>
#define pb push_back
#define mod 1000000007
#define pii pair<int, int>
#define PI 2*acos(0.0)
#define forn(i, n) for(int i = 0; i < n; i++)

vi prime;

void seive()
{
    prime.pb(2);
    bitset<1000005> ck;
    for(int i = 3; i*i <= 1000005; i+=2)
        if(!ck[i])
            for(int j = i*i; j <= 1000005; j+= 2*i)
                ck[j] = 1;

    for(int i = 2; i <= 1000005; i+=2)
        if(!ck[i])
            prime.pb(i);
}


int main()
{
    io;
    ll n;
    cin>>n;
    int ans = 0;
    for(ll x = 2; x*x <= n; x++)
    {
        if(n%x)
            continue;
        int p = 0;
        while(n%x == 0)
        {
            n/=x;
            p++;
        }
        int m = 1;
        while(p>=m)
        {
            ans++;
            p-=m;
            m++;
        }
    }
    if(n>1)
        ans++;
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3652
// $%U%$ $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	ll a,b;
	cin>>a>>b;
	cout<< a*(a-1)/2 + b*(b-1)/2 << endl;
	return 0;
}



Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main() {
     int a,b;
     cin >> a >> b;
     int cnt = 0;
     for(int i = a; i <= b; i++){
          int s = i % 10;
          int t = i / 10000;
          int u = i / 10 % 10;
          int v = i / 1000 % 10;
          if(s == t && u == v) cnt++;
     }
     cout << cnt << endl;
}

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

typedef long long ll;

int main() {
  ll n, m;
  cin >> n >> m;
  vector<vector<ll>> a(m);
  for (int i = 0; i < n; i++) {
    ll x, y;
    cin >> x >> y;
    if (x > m) {
      continue;
    }
    a[m - x].push_back(y);
  }
  priority_queue<ll> q;
  ll ans = 0;
  for (int i = m - 1; i >= 0; i--) {
    for (int j = 0; j < a[i].size(); j++) {
      q.push(a[i][j]);
    }
    if (q.empty()) {
      continue;
    }
    ans += q.top();
    q.pop();
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

template<typename T>   T max_self(T& a, T b) { if (a < b) a = b; return a; }
template<typename T>   T min_self(T& a, T b) { if (a > b) a = b; return a; }
template<typename T>   T add(T x, T y) { return ((x % MOD)  + (y % MOD)) % MOD;}
template<typename T>   T mul(T x, T y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;}
template<typename T>   T sub(T x, T y) { return add(x, -y + MOD);}
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 T>   vector<T> read(vector<T>& v, int n) {v.resize(n); for (auto &x : v)cin >> x;}
template<typename T>   void trav(vector<T> &v) {for (int i = 0 ; i < (int)v.size() ; ++i) {cout << v[i]; if (i != (int)v.size() - 1) cout << ' ';}}
int lg2(long long x)   {   return 64 - __builtin_clzll(x) - 1;	}
int lg2(int x)   {   return 32 - __builtin_clz(x) - 1;	}


//Variables Declaration
int N , W ;
vector<pair<ll, ll>> vect;

ll dp[110][MAXN];

ll solve(int n , int w) {
	if (dp[n][w] >= 0 ) return dp[n][w];
	if (n >= N) return 0;
	if (w == 0 ) return 0;

	if (w - vect[n].first < 0) return solve(n + 1, w);

	ll sol = 0;
	//debug(n);  debugg(w);
	sol = max( solve(n + 1, w) + 0 , solve(n + 1, w - vect[n].first) + vect[n].second );

	return dp[n][w] = sol ;

}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	memset(dp, 0, sizeof(dp));

	cin >> N >> W;
	vect.resize(N+1);

	for (int i = 1; i <= N; ++i)
	{
		pair<int,int> tmp;
		cin >> tmp.first >> tmp.second;
		vect[i]= tmp;
	}
	//cout << solve(0, W) << endl;


	for (int i = 1; i <=N; ++i) 	{
		for(int j = 0 ; j <= W ; ++j){
			if( j - vect[i].first >= 0 ){
				dp[i+1][j] = max ( dp[i+1][j] ,  dp[i][j-vect[i].first] + vect[i].second);
			}
			dp[i+1][j] = max(dp[i+1][j] , dp[i][j]);
		}
	}

	cout << dp[N+1][W] << endl;


	return 0;
}


Measured memory_bytes: 86272
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        long A = in.nextLong();
        long V = in.nextLong();
        long B = in.nextLong();
        long W = in.nextLong();
        long T = in.nextLong();

        long diff = Math.abs(A - B);
        long speed = V - W;
        long dist = speed * T;
        out.println(diff <= dist ? "YES" : "NO");

        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}



Measured memory_bytes: 32752
#include<iostream>
using namespace std;
int main(){
    int n,n11,n7,flag=0;
    cin >> n;
    n7 = n/7;
    for(int i=0;i<=n7;i++){
        if((n-(7*i))%4==0){
            flag = 1;
        }
    }
    if(flag == 1){
        cout << "Yes" << endl;
    }else{
         cout << "No" << endl;
    }
    return 0;
}


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

template <typename T>
inline T read(){
	T x=0,f=1;char c=getchar();
	while(!isdigit(c)){	if(c=='-') f=-f;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint
#define readint read<int>()
#define readlint read<lint>()
const int inf=1e9+1e7,MAXN=2e5+1e1;
const lint INF=1e18+1e9;

struct Node{
	lint r,b;
}a[MAXN];

lint Ans=INF,maxn,minn=inf;
bool vis[MAXN],vmax,vmin;
int n;

bool Cmpr(Node A,Node B){
	return (A.r==B.r ? A.b<B.b : A.r<B.r);
}

bool Cmpb(Node A,Node B){
	return (A.b==B.b ? A.r<B.r : A.b<B.b);
}

void Solve1(){
	lint maxm=maxn,minm=minn;
	for(int i=1;i<=n;i++) maxm=min(a[i].b,maxm),minm=max(a[i].r,minm);
	Ans=min((minm-minn)*(maxn-maxm),Ans);
	return;
}

void Solve2(){
	lint maxm=max(a[n].r,a[1].b),minm=min(a[n].r,a[1].b),tmp=INF;
	for(int i=2;i<n;i++) if(a[i].b<minm) minm=a[i].b,vis[i]=true;
	for(int i=2;i<n;i++) if(a[i].r>maxm) maxm=a[i].r,vis[i]=true;
	for(int i=2;i<n;i++) if(minm<=a[i].b && a[i].b<=maxm) vis[i]=true;
	for(int i=2;i<n;i++) if(minm<=a[i].r && a[i].r<=maxm) vis[i]=true;
	for(int i=2;i<n;i++) if(!vis[i]){
		tmp=min(maxm-min(a[i].r,minm),tmp),maxm=max(a[i].b,maxm);
	}
	if(tmp<INF) Ans=min((maxn-minn)*tmp,Ans);
	else Ans=min((maxn-minn)*(maxm-minm),Ans);
	return;
}

int main(void){

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	scanf("%d",&n);
	for(int i=1;i<=n;i++) a[i].r=readint,a[i].b=readint;
	for(int i=1;i<=n;i++) if(a[i].r>a[i].b) swap(a[i].r,a[i].b);
	sort(a+1,a+n+1,Cmpb),maxn=a[n].b,vmax=(a[n].b==a[n-1].b);
	sort(a+1,a+n+1,Cmpr),minn=a[1].r,vmin=(a[1].r==a[2].r);
	sort(a+1,a+n+1,Cmpb),sort(a+1,a+n,Cmpr);
	if(vmax || vmin || minn!=a[n].r || maxn!=a[n].b){
		minn=a[1].r,maxn=a[n].b,Solve2();
	}
	Solve1(),printf("%lld\n",Ans);

	return 0;
}

Measured memory_bytes: 7112
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
#define dancila 3.14159265359
#define eps 1e-9

using namespace std;

typedef long long ll;

ll n, m;
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> m;
    n %= m;
    cout << min(n, m - n);
    return 0;
}


Measured memory_bytes: 256