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

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int N = sc.nextInt();
        double sum = 0;
        for (int i = 0; i < N; i++) {
            double x = sc.nextDouble();
            String u = sc.next();
            if (u.equals("BTC")) {
                sum += x * 380000;
            } else {
                sum += x;
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 23252
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::max;

fn main() {
    let w: i64 = read();
    let a: i64 = read();
    let b: i64 = read();
    if a < b {
        if a + w < b {
            println!("{}", b - (w + a));
        } else {
            println!("{}", 0);
        }
    } else {
        if b + w < a {
            println!("{}", a - (b + w));
        } else {
            println!("{}", 0);
        }
    }
}



Measured memory_bytes: 4352
N = int(input())
S = [int(input()) for i in range(N)]
s_10 = []
s_other = []
for s in S:
  if s % 10:
    s_other.append(s)
  else:
    s_10.append(s)

s_other.sort()
ans = sum(S)
other_mod_10 = sum(s_other) % 10
if s_other:
  if other_mod_10:
    print(ans)
  else:
    print(ans - min(s_other))
else:
  print(0)

Measured memory_bytes: 9072
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a;
  string s;
  cin >> a >> s;
  if(a >= 3200) cout << s << endl;
  else cout << "red" << endl;
}

Measured memory_bytes: 3612
#include <cstdio>
#include <algorithm>
#define N 2000
using namespace std;

int n,a[N+5];
long long ans=0;

int main(void){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			int l=j+1,r=n,mid,maxn=0;
			while(l<=r){
				mid=(l+r)/2;
				if(a[mid]>=a[i]+a[j])r=mid-1;
				else maxn=max(maxn,mid),l=mid+1;
			}
			if(maxn!=0)
			ans+=maxn-j+0ll;
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(void) {
	int n, sum = 0, a = 0, b = 0, ab = 0;
	cin >> n;
	vector<string> s(n);
	for (int i = 0; i < n; i++) cin >> s[i];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < s[i].length() - 1; j++) {
			if (s[i][j] == 'A'&& s[i][j + 1] == 'B') sum++;
		}
	}
	for (int i = 0; i < n; i++) {
		int l = s[i].length() - 1;
		if (s[i][l] == 'A' && s[i][0] != 'B') a++;
		else if (s[i][0] == 'B' && s[i][l] != 'A') b++;
		else if (s[i][l] == 'A' && s[i][0] == 'B') ab++;
	}
	if (ab != 0) {
		if (a + b == 0) sum += ab - 1;
		else sum += min(a, b) + ab;
	}
	else sum += min(a, b);
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1e9+7
using namespace std;
typedef long long ll;

int main(){
    int n,d;
    cin>>n>>d;
    vector<vector<double> > x(n+1,vector<double> (d));

    rep(i,n){
        rep(j,d){
            cin>>x[i][j];
        }
    }

    int cnt=0;
    for(int i=1;i<n;i++){
        double sum;
        for(int k=0;k<i;k++){
            sum=0;
            for(int j=0;j<d;j++){
                sum += pow(abs(x[k][j]-x[i][j]),2);
           }
            if(sqrt(sum)-int(sqrt(sum))==0)
                cnt++;
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int N,A;
	scanf("%d %d",&N,&A);

	if(N%500 <= A){

		printf("Yes\n");

	}else{

		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

const int kSize = 'z' - 'a' + 1;

int main() {
//  freopen("../Console/1.txt", "rb", stdin);
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int N;
  cin >> N;

  vector<vector<int>> S(N, vector<int>(kSize, 0));
  for (int i = 0; i < N; ++i) {
    string s;
    cin >> s;
    for (char ch : s) {
      ++S[i][ch - 'a'];
    }
  }

  string result;
  for (int i = 0; i < kSize; ++i) {
    int mx = numeric_limits<int>::max();
    for (const auto& v : S) {
      mx = min(mx, v[i]);
    }

    for (int j = 0; j < mx; ++j) {
      result.push_back(i + 'a');
    }
  }

  cout << result << '\n';

  return 0;
}


Measured memory_bytes: 256
/**
     **author : _KMS_
     **created : 30-03-2020
**/
#include<bits/stdc++.h>
using namespace std;
const long long M =2e5+10,MOD=1e9+7;
typedef long long ll;
ll dp[1005][1005];
char ch[1005][1005];
bool vis[1005][1005];
void check(int x,int y,int r,int c)
{
 vis[x][y]=1;
 if(x+1<r&&y<c&&ch[x+1][y]=='.'&&!vis[x+1][y])check(x+1,y,r,c);
 if(x<r&&y+1<c&&ch[x][y+1]=='.'&&!vis[x][y+1])check(x,y+1,r,c);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int r,c;
    cin>>r>>c;
    for(int i=0;i<r;i++)
      for(int j=0;j<c;++j)cin>>ch[i][j];
    check(0,0,r,c);
    if(!vis[r-1][c-1]){cout<<0<<endl;
      return 0;}
      dp[0][0]=1;
     // cout<<"k";
      for(int i=0;i<r;++i)
      {
          for(int j=0;j<c;j++)
          {
            if((i==0&&j==0))continue;
            if(vis[i][j])
            {
              if(i-1>=0)dp[i][j]+=dp[i-1][j]%MOD;
              if(j-1>=0)dp[i][j]=(dp[i][j]+dp[i][j-1])%MOD;
            }
          }
      }
      cout<<dp[r-1][c-1]%MOD<<"\n";

    return 0;
}

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

using namespace std;

class Player
{	friend class Batler;
	vector<int> card;
	long long int point;
public:
	Player():point(0){}
};
class Batler
{
	Player *p1, *p2;
public:
	Batler(Player *P1, Player *P2):p1(P1),p2(P2){}

	void init();
	void input();
	void start();
};
void Batler::init()
{
	if(!p1->card.empty()){
		p1->card.clear();
		p2->card.clear();
	}
	p1->point = 0;
	p2->point = 0;
}
void Batler::input()
{
	int buf;
	cin>>buf;
	p1->card.push_back(buf);
	cin>>buf;
	p2->card.push_back(buf);
}
void Batler::start()
{
	for(unsigned int i = 0; i < p1->card.size(); i++){
		if( p1->card[i] > p2->card[i]){
			p1->point += p1->card[i] + p2->card[i];
		}else if( p1->card[i] < p2->card[i] ){
			p2->point += p1->card[i] + p2->card[i];
		}else{
			p1->point += p1->card[i];
			p2->point += p2->card[i];
		}
	}
	cout<<p1->point<<" "<<p2->point<<endl;
}
int main()
{
	int n;
	Player p1, p2;
	Batler batle(&p1,&p2);

	while(1){
		batle.init();
		cin>>n;
		if(n == 0) return 0;

		//üÍ
		for(int i = 0; i < n; i++){
			batle.input();
		}
		//ð
		batle.start();
	}
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.function.LongSupplier;

public class Main{ // 

	static class ConsoleScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			try {
				while (!st.hasMoreElements())
					st = new StringTokenizer(br.readLine());
				return st.nextToken();
			} catch (IOException e) {
				throw new AssertionError(e);
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

	static LongSupplier now = new LongSupplier() {
		private long t = System.currentTimeMillis();

		@Override
		public long getAsLong() {
			long a = t;
			t = System.currentTimeMillis();
			long ans = t - a;
			return ans;
		}
	};

	public static void main(String args[]) {
		ConsoleScanner cin = new ConsoleScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	static int tr(Object... objects) {
		System.out.println("tr:" + Arrays.deepToString(objects));
		return 0;
	}

	private static void solve(ConsoleScanner cin, PrintWriter cout) {
		// assert solve(1) == 1;

		int n = cin.nextInt();

		int[] a = new int[n];
		for (int i = 0; i < a.length; i++)
			a[i] = cin.nextInt();

		now.getAsLong();

		long ans = solve(n, a);
		cout.println(ans);

		assert 0 == tr("elapsed", now.getAsLong());
	}

	private static long solve(int n, int[] a) {
		HashMap<Integer, Integer> map = new HashMap<>();
		for (int k : a)
			map.put(k, 1 + map.getOrDefault(k, 0));
		long ans = map.values().stream().filter(cnt -> cnt % 2 == 1).count();
		return ans;
	}

}


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

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
	int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

int n, m, bit;

inline void printEdge(int u, int v) {//输出无向边 u -> v
	write(u);
	putchar(' ');
	write(v);
	putchar('\n');
}

int main() {
	read(n);
	for (int i = 0; (1 << i) <= n; ++i)
		if (n == (1 << i)) {
			puts("No");
			return 0;
		}
	puts("Yes");
	for (int i = 2; i + 1 <= n; i += 2) {
		printEdge(1, i), printEdge(i, i + 1);
		printEdge(1, i + n + 1), printEdge(i + n + 1, i + n);
		//对于每组 { x, x ^ 1 } 连边 
	}
	printEdge(3, n + 1);//把 n + 1 接在 3 的下面 
	if (!(n & 1)) {// n 是偶数 
		for (int i = 0; (1 << i) <= n; ++i)
			if (n & (1 << i)) bit = i;
		printEdge(n ^ (1 << bit), n), printEdge(((1 << bit) ^ 1) + n, n << 1);
	}
	return 0;
}

Measured memory_bytes: 2304
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

using ll = long long;

int main()
{
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print_container(const ContainerType<ValueType, Args...> &c)
{
	cout << "{ ";
	for (const auto &v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

void solve()
{
	ll q, h, s, d, n;
	cin >> q >> h >> s >> d >> n;
	ll ans = (n / 2) * min({8 * q, 4 * h, 2 * s, d}) + (n % 2) * min({4 * q, 2 * h, s});
	cout << ans << ln;
	return;
}

int main()
{
	FASTIO;
#ifdef file_input
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	clock_t start, stop;
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
#ifdef measure_time
	start = clock();
#endif
	for (int tc = 1; tc < t + 1; tc++)
		solve();
#ifdef measure_time
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


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

int main()
{
    int n, i, j, k;
    cin>>n;
    vector<vector<int>> happ(n);
    for(i=0;i<n;i++) {
        happ[i] = vector<int>(3);
    }
    for(i=0;i<n;i++) {
        for(j=0;j<3;j++) {
            cin>>happ[i][j];
        }
    }
    vector<int> curr(3);
    vector<int> next(3, 0);
    curr[0] = happ[0][0];
    curr[1] = happ[0][1];
    curr[2] = happ[0][2];
    for(i=0;i<n-1;i++) {
        for(j=0;j<3;j++) {
            for(k=0;k<3;k++) {
                if(k!=j) {
                    next[k] = max(next[k], curr[j] + happ[i+1][k]);
                }
            }
        }
        curr = next;
        next[0] = 0; next[1] = 0; next[2] = 0;
    }
    cout<< max({curr[0], curr[1], curr[2]})<<"\n";
    return 0;
}

Measured memory_bytes: 8776
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
using namespace std;
#define lli                                 long long int
#define lb                                  long double
#define pi                                  acos(-1)
#define FindDistance(ax,ay,bx,by)           sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by))
#define gcd(a,b)                            __gcd(a,b)
#define lcm(a,b)                           (a/gcd(a,b))*b
#define T                                  int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define all(v)                             v.begin(),v.end()
#define pb                                 push_back
#define inf                                999999999999999
#define mod                                1000000007
#define maxn                               100003
#define FastIO                             ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int main()
{
    lli n,i,x,j,ans;
    string s;
    map<string,lli>ma;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>s;
        ma[s]+=1;
    }
    ans=-1;
    //map<string,lli>:: iterator itr;
    for(auto itr=ma.begin();itr!=ma.end();itr++)
    {
        x=itr->second;
        if(x>ans)
            ans=x;
    }
    //map<string,lli>:: iterator itr;
    for(auto itr=ma.begin();itr!=ma.end();itr++)
    {
        if(itr->second==ans)
            cout<<itr->first<<endl;
    }


    return 0;
}


Measured memory_bytes: 19148
package main

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

func main() {
	sc := NewScanner()
	S := sc.Next()
	mx := 0
	for i := 0; i < 2; i++ {
		count := 0
		for j := 0; j < len(S); j++ {
			if int(S[j]-'0') == (i+j)%2 {
				count++
			}
		}
		if count > mx {
			mx = count
		}
	}
	fmt.Println(len(S) - mx)

}

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: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<double> x(n), y(n);
  for (int i = 0; i < n; ++i) {
    cin >> x.at(i) >> y.at(i);
  }
  vector<int> v(n);
  vector<vector<double>>  d(n, vector<double>(n));
  double sum_d = 0;
  for (int i = 0; i < n; ++i) v.at(i) = i;
  do {
    for (int i = 1; i < n; ++i) {
      int a = v.at(i - 1), b = v.at(i);
      if (d.at(a).at(b) == 0) {
        d.at(a).at(b) = sqrt(
          (x.at(a) - x.at(b)) * (x.at(a) - x.at(b)) + (y.at(a) - y.at(b)) * (y.at(a) - y.at(b))
        );
        d.at(b).at(a) = d.at(a).at(b);
        sum_d += d.at(a).at(b);
      } else {
        sum_d += d.at(a).at(b);
      }
    }
  } while ( next_permutation(v.begin(), v.end()) );
  double ans = sum_d / (double)n; 
  for (double i = 2; i < n; ++i) ans /= i;
  cout << setprecision(10) << ans << endl;
  return 0;
}

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

int main()
{
    int iLength = 0;
    int iBreadth = 0;
    int iArea = 0;
    int iPerimeter = 0;
    
    cin >> iLength >> iBreadth;
    iArea = iLength * iBreadth;
    iPerimeter = 2 * (iLength + iBreadth);
    
    cout << iArea << " " << iPerimeter << endl;
    return 0;
}



Measured memory_bytes: 3004
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
typedef pair<int,int> P;
vector<int> nex[114514],inv[114514];
int par[114514],deg[114514], rnk[114514];
vector<P> edge;
signed main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n+m-1;i++){
		int x,y;
		cin>>x>>y;
		nex[x].pb(y);
		inv[y].pb(x);
		deg[y]++;
	}
	int root = -1;
	for(int i=1;i<=n;i++){
		if( inv[i].size() == 0){
			root = i;
			break;
		}
	}
	vector< int > ans;
	queue<int> que;
	que.push( root );
	while(!que.empty()){
		int cur = que.front(); que.pop();
		ans.pb(cur);
		for(int i=0;i<nex[cur].size();i++){
			int nx = nex[cur][i];
			deg[nx]--;
			if( deg[nx] == 0){
				que.push(nx);
			}
		}
	}
	for(int i=0;i<n;i++){
		rnk[ ans[i] ] = i;
	}
	for(int i=1;i<=n;i++){
		int res = 0, tmp = -1;
		for(int j=0;j<inv[i].size();j++){
			int nx = inv[i][j];
			if( rnk[ nx ] > tmp ){
				res = nx;
				tmp = rnk[ nx ];
			}
		}
		par[i] = res;
	}
	for(int i=1;i<=n;i++){
		cout<<par[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 15864
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)






int main() {
	int A,B;
	cin >> A>>B;
	
	cout <<max(max(A+B,A-B),A*B)<< endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

const int MAX_N = 100100;

//隣接リストでもつ
struct edge {
    int to; 
    int cost;
    edge(int to, int cost) : to(to), cost(cost) {};
}; 
vector<vector<edge> > G(MAX_N, vector<edge>());
void add_edge(int from, int to, int cost) {
    G[from].push_back(edge(to, cost));
    G[to].push_back(edge(from, -cost)); 
}

vector<bool> used(MAX_N, false);
vector<int> x(MAX_N, 0); // 初期値:0, 二色:-1,+1
bool dfs(int v, int y) {
    used[v] = true;
    x[v] = y;
    for(int i = 0; i < (int)G[v].size(); ++i) { //頂点vから出る各辺を走査
        edge e = G[v][i];
        if (used[e.to] == true && x[e.to] != x[v] + e.cost) { //ちぐはぐなポテンシャルあったらダメ
            return false;
        } 
        if(used[e.to] == false) { //入ってないときは再起に入る
            bool flag = dfs(e.to, x[v] + e.cost); //次の点にポテンシャル設定
            if (!flag) {
                return false;
            }
        }
    }
    return true; //全部うまく設定できたらtrueを返す
}

int main() {
    int N,M; cin >> N>>M; 
    for (int i = 0; i < M; ++i) {
        int a,b,c; cin>>a>>b>>c;
        add_edge(a, b, c);
    }
    for (int i = 0; i < N; i++) {
        if (used[i] == false) {
            bool flag = dfs(i, 0);
            if (!flag) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}




Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

int n,m,a[50],b[50],ans = 0;
int g[50][50];
bool used[50];

void check(int i){
    used[i] = 1;
    rep0(j, n){
        if(g[i][j] && !used[j])check((int)j);
    }
    return;
}

int main()
{
    cin >> n >> m;
    rep0(i, m){
        cin >> a[i] >> b[i];
        g[a[i] - 1][b[i] - 1] = 1;
        g[b[i] - 1][a[i] - 1] = 1;
    }
    rep0(i, m){
        g[a[i] - 1][b[i] - 1] = 0;
        g[b[i] - 1][a[i] - 1] = 0;
        rep0(i, n)used[i] = 0;
        check(0);
        bool f = true;
        rep0(i, n)if(!used[i])f = false;
        if(!f)++ans;
        g[a[i] - 1][b[i] - 1] = 1;
        g[b[i] - 1][a[i] - 1] = 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*
 * atcoder/abc117/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/*
 * f(X) = (X mod A_1) + (X mod A_2) + ... + (X mod A_n) の最大値を求めよ（X <= K)
 */
ll N, K;
vector<ll> A;

// dp[n][b] := (b := 以前の桁でX < Kの保証があるなら1), (n := n桁目まで確認済み) の状態でのf(x)の最大値
ll dp[45][2];

void solve() {
  cin >> N >> K;
  A.resize(N);
  loop(n,0,N) cin >> A[n];

  loop(n,0,41) loop(l,0,2) dp[n][l] = -1;
  dp[40][0] = 0;
  for (int n=39; n>=0; n--) {
    int num1 = 0;
    for (auto&& a: A) num1 += (a>>n)&1;
    int num0 = N-num1;

    ll D = (1LL<<n);
    if (dp[n+1][1] >= 0) {
      // X<Kが保証されているならK[n]の値に関わらず最善（0と1の多い方）を採用する
      chmax(dp[n][1], dp[n+1][1] + D * max(num0, num1));
    }

    if (dp[n+1][0] == -1) continue;

    // K[n] = 0 ならX[n]は0 or 1の選択肢がある
    if ((K>>n)&1) {
      // X<Kの保証がない状態でX[n]=0を選択 => 次の桁以後でX<Kが保証される、かつ今回の最大値にすべてのA_iのn桁目が1のものの数だけ値を加える.
      chmax(dp[n][1], dp[n+1][0] + D * num1);
      // X<Kの保証がない状態でX[n]=1を選択 => 次もX<Kの保証なし.
      chmax(dp[n][0], dp[n+1][0] + D * num0);
    } else {
      // K[n]=0ならX[n]=0で選択肢なし
      chmax(dp[n][0], dp[n+1][0] + D * num1);
    }

  }

  cout << max(dp[0][1], dp[0][0]) << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


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

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    
    while (1) {
        int n, x;
        cin >> n >> x;
        if (n == 0 && x == 0) {
            break;
        }

        int count = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = i + 1; j <= n; j++) {
                for (int k = j + 1; k <= n; k++) {
                    if (i + j + k == x) {
                        count++;
                    }
                }
            }
        }
        cout << count << endl;
    }
    
}


Measured memory_bytes: 3096
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

n, m = load_list()

A = load_list()

ans = n - sum(A)
if ans < 0:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 10276
#include <iostream>

using namespace std;

int main(){
    int N;
    int sum = 0;
    int a_max = 0;
    cin >> N;
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        sum += a;
        a_max = max(a, a_max);
    }
    sum-=a_max/2;
    cout << sum << endl;
}

Measured memory_bytes: 256
//
//  second.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); i++)
#define rep1(i,n) for(int (i) = 1; (i) <= (int)(n); i++)
#define INF 1000000


int main()
{
    int N,R;
    cin >> N >> R;
    
    if (N >= 10) {
        cout << R << endl;
    } else {
        cout << R + 100 * (10-N) << endl;
    }
    
    
    return 0;
}



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

int main() {
  int N = 0, 
      stack = 0,
      sum = 0,
      surplus = 0;
  
  cin >> N;
  stack = N;
  
  while(N != 0) {
    surplus = N % 10;
    sum += surplus;
    N /= 10;
    
    //cout << stack << "," << surplus << "," << sum << "," << N << endl;
    
  }
  
  if (stack % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
n = int(input())
ans = 0

def count_div(i):
    ret = 0
    for j in range(1, i + 1):
        if i % j == 0:
            ret += 1
    
    return ret

for i in range(1, n + 1):
    if i % 2 == 1:
        cnt = count_div(i)
        if cnt == 8:
            ans += 1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  double t;
  double angle=0;
  cin >> n >> t;
  double x,h;
  for(int i=0;i<n;i++){
    cin >> x >> h;
    angle = ((angle < h/x) ? h/x : angle);
  }
  printf("%.10lf\n",angle*t);
  return 0;
}



Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){
  ll N;
  cin>>N;
ll A[N];

  for(ll i=0;i<N;i++){
  cin>>A[i];
  }

  ll ans=0;
  ll min=0;
  for(ll i=0;i<N;i++){
  
    if(min>A[i]){
    ans=ans+min-A[i];
    }
    if(min<A[i]){
    min=A[i];
    }
//    cout<<min<<endl;
  }
  
  cout<<ans<<endl;
  
}


Measured memory_bytes: 5152
#include<bits/stdc++.h>
using namespace std;
#define ran 111111
long long int tot;
int n,m,a[ran];

long long int sumk[ran], sumb[ran];
void add(int from, int to, int dk,int db){
	++to;
	sumk[from] += dk;
	sumk[to] -= dk;

	sumb[from] += db;
	sumb[to] -= db;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1; i<=n; i++)
		scanf("%d",&a[i]);
	for(int i=2; i<=n; i++){
		int from = a[i-1], to = a[i], step = (to - from + m) % m;
		tot += step;
		if(step == 0 || step == 1)continue;
		++ from; if(from == m+1) from = 1;
		if(to >= from){
			add(from, to, 1, -from);
		}else{
			add(from, m, 1, -from);
			add(1, to, 1, m-from);
		}
	}
	long long int mx = 0;
	for(int i=1; i<=m; i++){
		sumk[i] += sumk[i-1];
		sumb[i] += sumb[i-1];
		mx = max(mx, sumk[i] * i + sumb[i]);
	}
	cout << tot - mx << endl;
	return 0;
}


Measured memory_bytes: 2176
while True:
    n, m, a = map(int, input().split())
    if not n:
        break
    bars = [tuple(map(int, input().split())) for _ in range(m)]
    bars_h = [set() for _ in range(max(bars)[0])]
    for h, p, q in bars:
        bars_h[h - 1].add((p - 1, q - 1))

    amida = list(range(n))
    for bar_h in bars_h:
        for p, q in bar_h:
            amida[p], amida[q] = amida[q], amida[p]
    print(amida[a - 1] + 1)

Measured memory_bytes: 8520
d = list(map(int, input().split()))
L = d[0]
R = d[1]

a = L//2019
b = R//2019
c = L%2019
d = R%2019

list = []

if b-a >= 2:
  print(0)

elif b-a == 1:
  if d >= c:
    print(0)
  else:
    for i in range(c,d+2019):
      for j in range(i+1,d+2019+1):
        list.append(i*j%2019)
    print(min(list)) 

else :
  for i in range(c,d):
    for j in range(i+1,d+1):
        list.append(i*j%2019)
  print(min(list)) 

Measured memory_bytes: 75416
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
int k, n, a[400005];
void init(){
    k = read(), n = read();
    for (int i = 1; i <= n; ++i)
        a[i] = read(), a[n + i] = a[i] + k;
    
}
void solve(){
    int ans = INT_MAX;
    for (int i = 1; i <= n; ++i)
        ans = min(ans, a[i + n - 1] - a[i]);
    printf("%d\n", ans);
}
int main(){
    init();
    solve();
    return 0;
}

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

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++)
        cin >> a[i];
    
    sort(a.begin(),a.end());

    cout << a[n-1] - a[0] << endl;
}

Measured memory_bytes: 256
object Main extends App {
	val n = scala.io.StdIn.readInt
	var s = scala.io.StdIn.readLine.toList
	var a = Set[Char]()
	var b = Set[Char]()

	var ans = 0
	var cnt = 0
	for(i<-0 until n){
		a = a + s.head
		s = s.tail


		for(x <- a){
			if(s.contains(x)){
				cnt += 1
				b = b + x
			}
		}

		a = b
		ans = math.max(ans, cnt)
		cnt = 0
	}

	println(ans)
}


Measured memory_bytes: 25540
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)

typedef long long ll;

int main() {
    
    int A, B;
    cin >> A >> B;
  	if (B % A == 0) {
      cout << A + B << endl;
    } else {
      cout << B - A << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

N, M = map(int, input().split())

price_to_nums = defaultdict(int)
for i in range(N):
    a, b = map(int, input().split())
    price_to_nums[a] += b

prices = sorted(list(price_to_nums.keys()))

total = 0
left = M
for i in range(len(prices)):
    price = prices[i]
    c = min(price_to_nums[price], left)
    total += c * price
    left -= c
    if left <= 0:
        break

print(total)

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


#define fast_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
typedef long long int lli;
typedef long long ll;
typedef long double ld;

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

signed main(){
    fast_IO;
    int t=1;
    //cin>>t;
    while(t--){
        ll n,k;
        cin>>n>>k;
        vector<ll> a(n);
        vector<ll> b(n-k+1);
        ll sum=0;
        for(int i=0;i<n;i++){
            cin>>a[i];
            if(i<k)
                sum+=a[i];
        }
        b[0]=sum;
        int j=1;
        for(int i=k;i<n;i++){
            sum=sum+a[i]-a[i-k];
            b[j]=sum;
            j++;
        }
        for(int i=0;i<n-k;i++){
            if(b[i]<b[i+1])
                cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;
        }
    }   
    return 0;
}


Measured memory_bytes: 6308
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
const int N = 3e3+5,mod = 1e9+7,inv2 = 500000004;
it add(int x,int y){ return x+y>=mod?x+y-mod:x+y; }
it mul(int x,int y){ return 1ll*x*y%mod; }
il inc(int &x,int y){ x=add(x,y); }
int n,m,x,y,ans,val[N],f[N][N];
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),read(m);
	for(ri i=1;i<=n;++i) read(val[i]);
	for(ri i=1;i<=n;++i) for(ri j=1;j<=n;++j) f[i][j]=val[i]>val[j];
	for(ri i=1;i<=m;++i){
		read(x),read(y);
		f[x][y]=f[y][x]=mul(inv2,add(f[x][y],f[y][x]));
		for(ri j=1;j<=n;++j){
			if(j==x||j==y) continue;
			f[x][j]=f[y][j]=mul(inv2,add(f[x][j],f[y][j]));
			f[j][x]=f[j][y]=mul(inv2,add(f[j][x],f[j][y]));
		}
	}
	for(ri i=1;i<n;++i) for(ri j=i+1;j<=n;++j) inc(ans,f[i][j]);
	print(mul(ans,qpow(2,m,mod)));
	return 0;
}

Measured memory_bytes: 35584
#include <cstdio> 
#include <algorithm> 
using namespace std; 

int n, K, h[4009][2], l[4009][2], sum = 0, sn = 0, c[4009]; 
int dp[4009][4009][2], ans[4009], jc[4009], fin = 0ll; 
const long long mod = 924844033; 
bool ind[4009][4009]; 

int read(); 
void add(int x, int y)	{
	sn ++; 
	if(!l[x][0])	l[x][0] = y; 
	else l[x][1] = y; 
	if(!h[y][0])	h[y][0] = x; 
	else h[y][1] = x; 
} 

void find(int x, int y)	{
	ind[x][y] = true; sum ++; 
	for (int i = 0; i <= 1; i ++)	{
		if(l[x][i] && !ind[x][l[x][i]])	find(x, l[x][i]); 
		if(h[y][i] && !ind[h[y][i]][y])	find(h[y][i], y); 
	}
}

void set_pre()	{
	c[0] = 1; jc[0] = 1ll; 
	for (int i = 1; i <= 4000; i ++)	c[i] = c[i - 1] * -1; 
	for (int i = 1; i <= 4000; i ++){
		long long t = 1ll * jc[i - 1] * i % mod; 
		jc[i] = t; 
	}
}

int main()	{
	n = read(), K = read(); dp[0][0][0] = 1; 
	ans[0] = 1; set_pre(); 
	for (int i = 1; i <= n << 1; i ++)	{
		dp[i][0][0] = 1; 
		for (int j = 1; j <= i; j ++)
			dp[i][j][0] = (dp[i - 1][j][0] + dp[i - 1][j][1]) % mod,  
			dp[i][j][1] = dp[i - 1][j - 1][0]; 
	}
	for (int i = 1; i <= n; i ++)	{
		if(i - K >= 1)	add(i, i - K); 
		if(i + K <= n)	add(i, i + K); 
	} 
	for (int i = 1; i <= n; i ++)
		if(l[i][0] && !ind[i][l[i][0]]){
			sum = 0; find(i, l[i][0]); 
			for (int j = sn; j; j --)
				for (int k = 1; k <= min(j, sum); k ++)	{
					long long t = (long long)(1ll * ans[j - k] * ((dp[sum][k][0] + dp[sum][k][1]) % mod) % mod + ans[j]) % mod; 
					ans[j] = t; 
				}
		}
		else if(l[i][1] && !ind[i][l[i][1]]){
			sum = 0; find(i, l[i][1]); 
			for (int j = sn; j; j --)
				for (int k = 1; k <= min(j, sum); k ++)	{
					long long t = (long long)(1ll * ans[j - k] * ((dp[sum][k][0] + dp[sum][k][1]) % mod) % mod + ans[j]) % mod; 
					ans[j] = t; 
				}
		} 
	for (int i = 0; i <= n; i ++)
		fin = (long long)(1ll * ans[i] * c[i] * jc[n - i] % mod + fin + mod) % mod; 
	printf("%lld\n", fin); 
	return 0; 
} 

int read()	{
	int x = 0, f = 1; char c = getchar(); 
	while (c > '9' || c < '0')	f = (c == '-') ? -1 : f, c = getchar(); 
	while (c >= '0' && c <= '9')	x = x * 10 + c - '0', c = getchar(); 
	return x * f; 
}

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

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
   
    int n;
    cin >> n;
    
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    
    map<int,bool> mp;
    
    int sum = 0;
    rep(i,n){
        if(mp[a[i]]==false){
            sum++;
            mp[a[i]] = true;
        } else {
            sum--;
            mp[a[i]] = false;
        }
    }
    cout << sum << endl;
}


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

int main(){
  int A,B,C,X,Y;
  cin >> A >> B >> C >> X >> Y;
  int sum = 0;
  if(A + B > C * 2){
    int k = min(X, Y);
    sum = C * 2 * k;
    X -= k;
    Y -= k;
  }
  /*
  if(A > C * 2){
    sum += 2 * C * X;
  }else{
    sum += A * X;
  }
  if(B > C * 2){
    sum += 2 * C * Y;
  }else{
    sum += B * Y;
  }
*/
  sum += (A > C * 2) ? 2 * C * X : A * X;
  sum += (B > C * 2) ? 2 * C * Y : B * Y;

  cout << sum << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int i,j,n,count,num=0;
    static char prime[1000002];
    int p[80000]={0};

    for(i = 2;i < 1000001;i++) prime[i]=1;

    for(i = 2;i < 1000001;i++){
        if(prime[i]){
            p[num]=i;
            num++;
            for(j=i+i;j<=1000001;j+=i){
                prime[j]=0;
            }   
        }   
    }   

    while(scanf("%d",&n),n){

        count=0;

        if(n%2){
            for(i=0;p[i]<n;i++){
                if(p[i]==n-2) count++;
            }   
        } else {
            for(i=0;p[i]<=n/2;i++){
                if(prime[n-p[i]]){
                    count++;
                }   
            }   
        }   

        printf("%d\n",count);
    }   

    return 0;} 

Measured memory_bytes: 1896
//============================================================================
// Name        : atcoder.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
long long X;
int main(){
	cin>>X;
	if(X<0)X = (0-X);
	long long R = 0;
	int S = 0;
	for(long long i = 0; i<X+1; i++){
		R += i;
		if(R >= X && S == 0){
			cout<<i<<endl;
			S += 1;
		}
	}


	return 0;
}


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

int main(){

    int N;
    cin >> N;

    int count = 0;


    for (int i = 0; i < N; i++) {
        int num;
        cin >> num;
        if (num == count+1) {
            count++;
        }
    }

    if (count == 0)
        cout << -1 << endl;
    else
        cout << N-count << endl;

    return 0;
}


Measured memory_bytes: 256
import Data.List

count :: Int -> Int -> [Int] -> Int
count 0 x l  = if (0 == x) then 0 else (-1)
count n x l  = if ((head l) <= x)
                  then (+) 1 $ count (n-1) (x-(head l)) (tail l)
                  else 0

main :: IO ()
main = do
  [n,x] <- map read <$> words <$> getLine
  chi <-  map read <$> words <$> getLine
  putStrLn $ show $ count n x (sort chi)

Measured memory_bytes: 1020
#include<iostream>

using namespace std;

int main(void) {
	int S;

	cin >> S;

	int h = (int)(S / 3600);
	int m = (int)((S - 3600 * h) / 60);
	int s = S - 3600 * h - 60 * m;

	cout << h << ":" << m << ":" << s << endl;

	return 0;
}


Measured memory_bytes: 3108
import heapq

data = int(input())
array = [int(_) for _ in input().split()]

X = array[0:data]
B = array[data:2*data]
Y = [-_ for _ in array[2*data:3*data]]

heapq.heapify(X)
heapq.heapify(Y)

x = [sum(X)]
y = [sum(Y)]

for i in range(data):
    x += [B[i] - heapq.heappushpop(X, B[i])]
    y += [-B[-1-i] - heapq.heappushpop(Y, -B[-1-i])]

for i in range(data):
    x[i+1] = x[i]+x[i+1]
    y[i+1] = y[i]+y[i+1]

print(max([x[_] + y[-1 - _] for _ in range(data+1)]))

Measured memory_bytes: 40192
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>

using namespace std;

typedef long long int lli;

int gcd(int a, int b) {
	return b != 0 ? gcd(b, a%b) : a;
}
lli gcd(lli a, lli b) {
	return b != 0 ? gcd(b, a%b) : a;
}
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}
lli lcm(lli a, lli b) {
	return a * b / gcd(a, b);
}

#define N_MAX 100010
#define MOD 1000000007

lli fac[N_MAX], finv[N_MAX], inv[N_MAX];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < N_MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

lli COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lli modpow(lli base, lli p)
{
	if (0 == p) {
		return 1;
	}
	if (0 == p % 2) {
		lli val = modpow(base, p / 2);
		return (val*val) % MOD;
	}
	else {
		return (modpow(base, p - 1)*base) % MOD;
	}
}

void solv()
{
	int N, K; scanf("%d%d", &N, &K);
	int A[N_MAX];
	for (int i = 0; i < N; i++) {
		scanf("%d", A + i);
	}

	sort(A,A + N);

	if (1 == N) {
		printf("%d", 0);
		return;
	}

	COMinit();

	lli sum = 0;
	for (int i = 1; i < N; i++) {
		sum += (COM(i, K - 1) * (lli)A[i]) % MOD;
		sum = sum % MOD;
	}
	for (int i = 0; i < N - 1; i++) {
		sum -= (COM(N - i - 1, K - 1)*(lli)A[i]) % MOD;
		sum = (sum + MOD) % MOD;
	}

	printf("%lld", sum);

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_NK = 200005;
double p[MAX_NK];
double X[MAX_NK];

int main()
{
	int N,K;
	cin >> N >> K;
	rep(i,N)
	{
		cin >> p[i];
		X[i] = (p[i]+1)/2;
	}

	double temp = 0.0,ans = 0.0;
	rep(i,K)
	{
		temp += X[i];
	}
	ans = temp;
	//cout << temp << " ";
	rep(i,N-K)
	{
		temp -= X[i];
		temp += X[i+K];
		//cout << temp << " ";
		ans = max(ans,temp);
	}
	cout << setprecision(10) << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;


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

	vector<vector<ll>> dp(N + 1, vector<ll>(N + 1));
	for (int i = 1; i <= N; ++i){
		for (int j = 0; i + j <= N; ++j){
			if ((N - i) % 2 == 0)
				dp[j][i + j] = max(dp[j + 1][i + j] + a[j], dp[j][i + j - 1] + a[i + j - 1]);
			else
				dp[j][i + j] = min(dp[j + 1][i + j] - a[j], dp[j][i + j - 1] - a[i + j - 1]);
		}
	}

	cout << dp[0][N] << endl;
	return 0;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int n,m,c; cin>>n>>m>>c;
    vector<int> b(m);
    vector<vector<int>> a(n,vector<int>(m,0));
    rep(i,0,m) cin>>b[i];
    rep(i,0,n){
        rep(j,0,m) cin>>a[i][j];
    }
    int cnt=0;
    rep(i,0,n){
        int temp=0;
        rep(j,0,m){
            temp+=a[i][j]*b[j];
        }
        temp+=c;
        if(temp>0) cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
-- Computation - A / B Problem

import Control.Applicative
import Text.Printf

main :: IO ()
main = do
  xs <- map read . words <$> getLine
  let (d, r, f) = calc xs
  printf "%d %d %f" d r f
  putStrLn ""

calc :: [Int] -> (Int, Int, Double)
calc [a, b] = (div a b, mod a b, (fromIntegral a) / (fromIntegral b))



Measured memory_bytes: 3904