akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int x; cin >> x;
    cout << 1-x << endl;
}


Measured memory_bytes: 3616
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		
		// 計算
		String result = "ABC" + n;
		
		// 出力
		System.out.println(result);
	}
}



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

int main(void) {
	int len,cnt,i;
	char S[100];

	scanf("%s",S);
	len=strlen(S)/2;
  
	if(memcmp(&S[0],&S[len+1],len))
	  {printf("No");return 0;}

	cnt=len/2;
	len--;
	for(i=0;i<cnt;i++)
		if(S[i]!=S[len-i])
		  {printf("No");return 0;}

	printf("Yes");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
using namespace std;

void solve(int n, int p)
{
	vector<int> num(n, 0);
	int bowl = p;

	for(int i=0; ; i = (i+1)%n){
		if(bowl > 0){
			-- bowl;
			++ num[i];
		}else{
			if(num[i] == p){
				cout << i << endl;
				break;
			}
			bowl = num[i];
			num[i] = 0;
		}
	}
}

int main()
{
	for(;;){
		int n, p;
		cin >> n >> p;
		if(n == 0 && p == 0)
			break;

		solve(n, p);
	}

	return 0;
}

Measured memory_bytes: 904
#include <stdio.h>
#include <iostream>
#include <vector>

class Hash {

  private:
    int m, l;
    std::vector<std::string> table;

  public:
    Hash(int m, int l):
      m(m),
      l(l)
    {
      std::vector<std::string> tmp(m);
      table = tmp;
    }

    int hash1(int key) {
      return key % m;
    }

    int hash2(int key) {
      return 1 + (key % (m-1));
    }

    int char2num(char ch) {
      if (ch == 'A') {
        return 1;
      } else if (ch == 'C') {
        return 2;
      } else if (ch == 'G') {
        return 3;
      } else if (ch == 'T') {
        return 4;
      }
    }

    long long getKey(std::string str) {
      long long sum = 0, p = 1;
      size_t i;
      for (i = 0; i < str.size(); i++) {
        sum += p*(char2num(str[i]));
        p *= 5;
      }
      return sum;
    }

    int find(std::string str) {
      long long key, i, h;
      key = getKey(str);
      for (i = 0; ; i++) {
        h = (hash1(key) + i*hash2(key)) % m;
        if (table[h] == str) {
          return 1;
        } else if (table[h].empty()) {
          return 0;
        }
      }
      return 0;
    }

    int insert(std::string str) {
      long long key, i, h;
      key = getKey(str);
      for (i = 0; ; i++) {
        h = (hash1(key) + i*hash2(key)) % m;
        if (table[h] == str) {
          return 1;
        } else if (table[h].empty()) {
          table[h] = str;
          return 0;
        }
      }
      return 0;
    }
};

int main() {
  int i, n, h;
  const int m = 1046527, l = 14;

  scanf("%d", &n);

  Hash hash = Hash(m, l);

  char char_str[l], char_com[9];


  for (i = 0; i < n; i++) {
    scanf("%s %s", char_com, char_str);

    std::string str = char_str;
    std::string com = char_com;

    if (com[0] == 'i') {
      hash.insert(str);
    } else {
      if (hash.find(str)) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
  return 0;
}



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

int selectionSort(vector<int> &a, int n)
{
    int count = 0;

    rep(i, n)
    {
        int minj = i;
        for (int j = i; j < n; j++)
        {
            if (a.at(j) < a.at(minj))
            {
                minj = j;
            }
        }
        if (i != minj)
        {
            swap(a.at(i), a.at(minj));
            count++;
        }
    }
    //cout <<"counts:" << count << endl;
    return count;
}

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N)
    {
        cin >> a.at(i);
    }

    int counts = selectionSort(a, N);

    for (int i = 0; i < N; i++)
    {
        if (i)
        {
            cout << " ";
        }

        cout << a.at(i);
    }
    cout << endl;
    cout << counts << endl;
    return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
//#define MOD 998244353

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

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; }

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

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

	ll N;
	cin >> N;

	vector<pair<ll, ll> > BA(N);
	rep(i, N) {
		cin >> BA[i].second >> BA[i].first;
	}

	sort(BA.begin(), BA.end());

	ll sum = 0;

	rep(i, N) {
		sum += BA[i].second;
		if (sum > BA[i].first) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;



	return 0;
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int H, W, K; cin >> H >> W >> K;
    vector<string> S(H);
    REP(i, 0, H) cin >> S[i];

    int ans = 0;
    for (int i = 0; i < (1 << H); i++) {
        for (int j = 0; j < (1 << W); j++) {
            int cnt = 0;
            REP(h, 0, H) {
                REP(w, 0, W) {
                    if ((i & (1 << h)) || (j & (1 << w))) continue;
                    if (S[h][w] == '#') cnt++;
                }
            }
            if (cnt == K) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define mainspring cout<<"mainspring\n";
#define barrel cout<<"barrel\n";
#define escapement cout<<"escapement\n";

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second
#define tik(i,a,b) for(int i = a; i < b; i++)
#define tok(i,a,b) for(int i = a; i >= b; i--)
#define error(args...) {string _s = #args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}

typedef long long ll;
typedef unsigned long long ull;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " ";
    err(++it, args...);
}

ll pow(ll x, ll y) {
	if(y == 0)
	return 1;
	ll temp = pow(x, y/2);
	temp = (temp*temp);
	if(y%2 == 1)
		temp *= x;
	return temp;
}

#define int ll

int32_t main() {
	int k, q;
	cin >> k >> q;
	int d[k];
	for(int i = 0; i < k; i++)
		cin >> d[i];
	while(q--) {
		int n, x, m;
		cin >> n >> x >> m;
		vi td(k);
		for(int i = 0; i < k; i++)
			td[i] = d[i]%m;
		int z = 0;
		for(int i = 0; i < k; i++)
			if(d[i]%m == 0)
				z++;
		z *= (n - 1)/k;
		for(int i = 0; i < (n - 1)%k; i++)
			if(d[i]%m == 0)
				z++;
		//error(z);
		int T = 0;
		for(int xx : td)
			T += xx;
		int lst = ((n - 1)/k)*T + x;
		for(int i = 0; i < (n - 1)%k; i++)
			lst += td[i];
		//error(lst);
		z += lst/m - x/m;
		//error(z);
		cout << n - 1 - z << '\n'; 
	}
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    for (int i = 0; i < h; ++i) {
        cin >> a[i];
    }
    map<char, int> cnt;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cnt[a[i][j]]++;
        }
    }
    bool ok = true;
    int ones = 0;
    int twoes = 0;
    int threes = 0;
    for (auto &p : cnt) {
        if (p.second % 4 == 1)
            ones++;
        else if (p.second % 4 == 2)
            twoes++;
        else if (p.second % 4 == 3)
            threes++;
    }

    if (h % 2 == 1 && w % 2 == 1) {
        if (ones == 1) {
            if (threes != 0)
                ok = false;
            if (twoes > w / 2 + h / 2)
                ok = false;
        } else if (threes == 1) {
            if (ones != 0)
                ok = false;
            if (twoes + threes > w / 2 + h / 2)
                ok = false;
        } else {
            ok = false;
        }
    } else if (h % 2 == 1) {
        if (ones != 0 || threes != 0)
            ok = false;
        if (twoes > w / 2 || twoes % 2 == 1)
            ok = false;
    } else if (w % 2 == 1) {
        if (ones != 0 || threes != 0)
            ok = false;
        if (twoes > h / 2 || twoes % 2 == 1)
            ok = false;
    } else {
        if (ones != 0 || twoes != 0 || threes != 0)
            ok = false;
    }

    if (ok)
        cout << "Yes"
             << "\n";
    else
        cout << "No"
             << "\n";
    return 0;
}

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

int main(void){
  const string keyence = "keyence";
  string S; cin >> S;
  for(int i = 0; i < S.size(); i++){
    for(int j = i; j < S.size(); j++){
      string cand = S.substr(0, i) + S.substr(j, S.size()-j);
      if(cand == keyence){
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;
  return 0;
}


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

int main() {
    ll n;
    cin>>n;
    vector<ll> a(n);
    ll minus=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]<0)minus++;
        a[i]=abs(a[i]);
    }
    ll sum=0;
    if(minus%2==0){
        rep(i,n){
            sum+=a[i];
        }
    }else {
        sort(a.begin(),a.end());
        sum-=a[0];
        rep(i,n-1){
            sum+=a[i+1];
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 1024
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
from collections import defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
a,b = readInts()
if 1 <= a <= 9 and 1 <= b <= 9:
    print(a*b)
else:
    print(-1)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

const i64 INF = 1LL << 40;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  i64 N, Z, W;
  cin >> N >> Z >> W;
  vector<i64> A(N);
  REP(i, N) cin >> A[i];

  map<tuple<int, i64>, i64> memo1;
  map<tuple<int, i64>, i64> memo2;

  auto maximize = [&](auto get_min, int i, i64 x, i64 y) -> i64 {
    if (i == N) return abs(x - y);
    tuple<int, i64> key = {i, y};
    auto it = memo1.find(key);
    if (it != memo1.end()) return it->second;
    i64 res = -INF;
    for (int k = i; k < N; ++k) {
      i64 minval = get_min(get_min, k + 1, A[k], y);
      res = max(res, minval);
    }
    memo1[key] = res;
    return res;
  };

  auto minimize = [&](auto get_min, int i, i64 x, i64 y) -> i64 {
    if (i == N) return abs(x - y);
    tuple<int, i64> key = {i, x};
    auto it = memo2.find(key);
    if (it != memo2.end()) return it->second;
    i64 res = INF;
    for (int k = i; k < N; ++k) {
      i64 maxval = maximize(get_min, k + 1, x, A[k]);
      res = min(res, maxval);
    }
    memo2[key] = res;
    return res;
  };

  cout << maximize(minimize, 0, Z, W) << endl;
}


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

using namespace std;

int main(){
	int n,k;
	long res = 0;
	cin >> n >> k;
	vector<int> a(n);
	for(int i=0;i<n;++i)cin >> a[i];
	sort(a.begin(),a.end());
	if(k > n)k = n;
	for(int i=0;i<k;++i){
		a.pop_back();
		n--;
	}
	for(int i=0;i<n;++i){
		res += a[i];
	}
	cout << res << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;
const ld eps = 1e-4;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int d; cin >> d;
    int c[26];
    REP(i,26) cin >> c[i];
    int v[d][26];
    REP(i,d)REP(j,26) cin >> v[i][j];
    V<> sol;
    V<> loss(26,0);
    REP(i,d){
        V<pair<ld,ll>> score(26,{0.0,0});
        REP(j,26) score[j] = {v[i][j] - loss[j] + c[j] * eps, j};
        sort(rall(score));
        int r = score[0].second;
        sol.pb(r + 1);
        REP(j,26){
            if(j == r) loss[j] = 0;
            else loss[j] += c[j];
        }
    }
    REP(i,d) cout << sol[i] << endl;
}

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

int main() {
  int a,b,x;
  cin>>a>>b;
  if((a+b)%2==0)x=(a+b)/2;
  if((a+b)%2==1)x=(a+b)/2+1;
  cout<<x<<endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
#define gc getchar_unlocked
#define fo(i, n) for (i = 0; i < n; i++)
#define ll long long
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%I64d", &x)
#define ss(s) scanf("%s", s)
#define pb push_back
#define em emplace_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define clr(x) memset(x, 0, sizeof(x))
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
const int mod = 1e9 + 7;
int epow(int base, int pow)
{
    int result = 1;
    while (pow)
    {
        if (!(pow % 2))
        {
            base = (base * base) % mod;
            pow /= 2;
        }
        else
        {
            result = (result * base) % mod;
            pow--;
        }
    }
    return result;
}
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    si(n);
    double d = 2 * n * PI;
    cout << setprecision(24) << d;
}

Measured memory_bytes: 3896
n = gets.to_i
a = gets.split(" ").map(&:to_i)
x = [0]*(100000)

for i in 0..n-1 do
    if a[i] == 0
        x[0] = x[0] + 1
        x[1] = x[1] + 1
    elsif a[i] == 99999
        x[99998] = x[99998] + 1
        x[99999] = x[99999] + 1
    else
        x[a[i] - 1] = x[a[i] - 1] + 1
        x[a[i] + 1] = x[a[i] + 1] + 1
        x[a[i]] = x[a[i]] + 1
    end
end
 
 puts x.max

Measured memory_bytes: 8844
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10


N = INT()
A = LIST()

a = [0] + list(accumulate(A[::2]))
b = [0] + list(accumulate(A[1::2]))

#print(a)
#print(b)

ans = []
for i in range(N):
	tmp = 0
	if i%2 == 0:
		tmp += a[-1] - a[i//2]*2
		tmp -= b[-1] - b[i//2]*2
	else:
		tmp += b[-1] - b[i//2]*2
		tmp -= a[-1] - a[(i+1)//2]*2
	ans.append(tmp)
print(*ans)

Measured memory_bytes: 24572
using System;

class B
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var a = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);

		var s = new long[n + 1];
		for (int i = 0; i < n; i++) s[i + 1] = s[i] + a[i];

		var j = Array.BinarySearch(s, (s[n] + 1) / 2);
		if (j < 0) j = ~j;
		Console.WriteLine(Math.Min(s[n] - 2 * s[j - 1], 2 * s[j] - s[n]));
	}
}


Measured memory_bytes: 37072
def jikann(a,b,c,d,e):
    an=0
    amari=9
    hasuu=0
    check=0
    for i in [a,b,c,d,e]:
        an+=i // 10 * 10
        check += i % 10
        if i % 10 != 0:
            hasuu+=1
            if amari >= i % 10:
                amari = i % 10
    if check==0:
        an=sum([a,b,c,d,e])
    else:
        an=an + (hasuu - 1) * 10 + amari
    return an
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
print(jikann(a,b,c,d,e))

Measured memory_bytes: 38256
def BvsA(i):
    min, max = 0, N
    while max-min>1:
        mid = (min+max)//2
        if B[i] > A[mid]:
            min = mid
        else:
            max = mid
    return min+1

def BvsC(i):
    min, max = -1, N-1
    while max-min>1:
        mid = (min+max)//2
        if B[i] < C[mid]:
            max = mid
        else:
            min = mid
    return N-max


N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
A.sort()
B.sort()
C.sort()

Ans = 0
for i in range(N):
    if A[0] < B[i] < C[N-1]:
        Ans += BvsA(i) * BvsC(i)
print(Ans)

Measured memory_bytes: 23296
#include <iostream>
#include <vector>
int main(){
    using namespace std;
    int h,w,i,j,k;
    vector<int> v;
    h = 1;
    w = 1;
    while(h!=0||w!=0){
        cin >> h >> w;
        if(h==0&&w==0){
            break;
        }
        v.push_back(h);
        v.push_back(w);
    }
    int size = v.size();
    for(i=0;i<(size/2);i++){
        h = v[2*i];
        w = v[2*i+1];
        for(j=0;j<h;j++){
            if(j%2==0){
                for(k=0;k<w;k++){
                    cout << "#";
                    if(k==w-1){
                        break;
                    }
                    k++;
                    cout << ".";
                }
            }else{
                for(k=0;k<w;k++){
                    cout << ".";
                    if(k==w-1){
                        break;
                    }
                    k++;
                    cout << "#";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n; cin>>n;
	int ans=0;
	vector<int> v(n);
	for(int i=0;i<n;i++) cin>>v[i];
	for(int i=0;i<n;i++){
	    if(i==0 || i==n-1) continue;
	    if(v[i] < v[i-1] && v[i] > v[i+1]) ans++;
	    if(v[i] > v[i-1] && v[i] < v[i+1]) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define F first
#define S second
#define def(x) cerr << #x << " is " << x << endl;
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(a) a.begin(),a.end()
const int NUM = 2e5 + 5;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
int main(){
    ios
    int num_tests=1; 
    //cin>>num_tests;
    while(num_tests-->0){
        int x,y; cin>>x>>y;
        //if(x*4>y or 2*x<y) {cout<<"No"; return 0;}
        for(int i=0;i<=x;i++){
            int cnt = 2*i+(x-i)*4;
            //cout<<cnt<<endl;
            if(cnt==y) {cout<<"Yes"; return 0;}
        }
        cout<<"No";
    }   
}



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

typedef long long ll;

int main()
{
    ll i,j;
    ll k,n;
    cin >> k >> n;
    vector<ll> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    vector<ll> tmp;
    for(i = 1;i < n;++i){
        tmp.push_back(a.at(i)- a.at(i-1));
    }
    tmp.push_back(a.at(0) + k-a.back());
    sort(tmp.begin(), tmp.end());
    cout << k - tmp.back() << endl;
    return 0;
}

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
int main()
{
int k,n;
  cin>>k>>n;
  vector<int> vec(n);
  for(int i=0;i<n;i++)cin>>vec[i]; 
reverse(vec.begin(), vec.end()); 
  int h=vec[n-1];
  for(int i=0;i<n-1;i++){
    int x=vec[i]-vec[i+1];
  h= max(h,x);
}
int kyori=k-vec[0]+vec[n-1];
int K=max(h,kyori);
cout <<k-K<<endl;
}


Measured memory_bytes: 4036
#include<iostream>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)

#include <algorithm>
using namespace std;
#include <cmath>
#include <string>
#include<vector>
#define elif else if
typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 200005
int N;

int main(){

    cin >>N;
    ll X[TENFIVE];
    ll y[TENFIVE];
    // vector<ll>vc;
    rep(i,N){
        cin>>X[i];
        y[i] = X[i];
    }
    sort(y,y+N);

    rep(i,N){
        if(X[i]<=y[N/2 - 1]) cout<<y[N/2]<<endl;
        else cout<<y[N/2 -1]<<endl;   
    
    }
    
    return 0;

}

Measured memory_bytes: 5376
#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 n;
void init(){
    n = read();
}
void solve(){
    printf("%d\n", (n - 1) / 2 + 1);
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.io.*
import java.util.*


fun gcd(x: Int, y: Int): Int = if (y == 0) x else gcd(y, x % y)
fun gcd(x: Long, y: Long): Long = if (y == 0L) x else gcd(y, x % y)

fun solve(N: Long, A: LongArray){
    println(A.reduce{a, b -> gcd(a,b)})
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toLong()
    val A = LongArray(N.toInt())
    for (i in 0 until N.toInt()) {
        A[i] = sc.next().toLong()
    }
    solve(N, A)
}



Measured memory_bytes: 44336
#include <stdio.h>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>

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; }
//constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;


using Real = double;

vector<Real> dijkstra(int start, vector<vector<pair<int, Real>>>& graph) {
	vector<Real> dist(graph.size(), INF); dist[start] = 0;
	priority_queue<pair<Real, int>, vector<pair<Real, int>>, greater<pair<Real, int>>> pq; pq.emplace(0, start);
	while (!pq.empty()) {
		Real cost; int idx; tie(cost, idx) = pq.top(); pq.pop();
		if (dist[idx] < cost) continue;
		for (auto next : graph[idx]) if (chmin(dist[next.first], cost + next.second)) pq.emplace(dist[next.first], next.first);
	}
	return dist;
}

int n;

int cnv(int cur, int pre, int v) {
	return v + pre * 31 + cur * n * 31;
}

void solve() {
	int m; cin >> n >> m; if (n == 0 and m == 0) exit(0);
	int s, t; cin >> s >> t; s--; t--;
	vector<vector<pair<int, Real>>> g(n * n * 35);
	for (int i = 0; i < m; i++) {
		int u, v, c; Real d;
		cin >> u >> v >> d >> c;
		u--; v--;
		for (int j = 0; j <= 30; j++) {
			for (int k = 0; k < n; k++) {
				if (j > 0 and j <= c and v != k) g[cnv(u, k, j)].emplace_back(cnv(v, u, j), d / j);
				if (j > 0 and j <= c and u != k) g[cnv(v, k, j)].emplace_back(cnv(u, v, j), d / j);
				if (j > 1 and j - 1 <= c) {
					if (k != v) g[cnv(u, k, j)].emplace_back(cnv(v, u, j - 1), d / (j - 1));
					if (k != u) g[cnv(v, k, j)].emplace_back(cnv(u, v, j - 1), d / (j - 1));
				}
				if (j + 1 <= c) {
					if (k != v) g[cnv(u, k, j)].emplace_back(cnv(v, u, j + 1), d / (j + 1));
					if (k != u) g[cnv(v, k, j)].emplace_back(cnv(u, v, j + 1), d / (j + 1));
				}
			}
		}
	}

	auto d = dijkstra(cnv(s, s, 0), g);
	Real res = 1e18;
	for (int k = 0; k < n; k++) chmin(res, d[cnv(t, k, 1)]);
	if (res > 1e15) cout << "unreachable" << "\n";
	else cout << fixed << setprecision(12) << res << "\n";
}

int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int kkt = 89; while (kkt) solve();

}



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

using ll = long long;
using namespace std;
static const int INF = 1000000000;


int main() {
    int n, m, q;
    cin >> n >> m >> q;
    vector<int> v (600, 0);
    vector<vector<int>> p(300001, vector<int>(3, INF));
    vector<int> ans(300000);
    for (int i = 0; i < m; ++i) {
        int l, r;
        scanf("%d %d", &l, &r);
        vector<int> e {r*2+2, l, -1};
        p.emplace_back(e);
    }
    for (int i = 0; i < q; ++i) {
        int l, r;
        scanf("%d %d", &l, &r);
        vector<int> e {r*2+3, l, i};
        p.emplace_back(e);
    }
    sort(p.begin(), p.end());
    for (auto &&a: p){
        if(a[0] == INF) break;
        if(a[0]%2 == 0){
            v[a[1]]++;
        }else{
            int sum = 0;
            for (int i = a[1]; i <= a[0]/2; ++i) {
                sum += v[i];
            }
            ans[a[2]] = sum;
        }
    }
    for (int i = 0; i < q; ++i) {
        cout << ans[i] << "\n";
    }
    return 0;
}


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

const int N = 60000;
int n;
bool isp[N];
vi ps;

void first() {
  fill(isp+2,isp+N,true);
  for (int x=2;x*x<N;x++) {
    if (!isp[x]) continue;
    for (int d=x*x;d<N;d+=x) isp[d] = false;
  }
  for (int x=2;x<N;x++) if (isp[x] && x%5==1) ps.pb(x);
}

int main() {
  first();
  cin>>n;
  rep(i,n) cout<<ps[i]<<" \n"[i == n-1];
  return 0;
}

Measured memory_bytes: 256
from sys import stdin
A,B,C = [int(x) for x in stdin.readline().rstrip().split()]
K = int(stdin.readline().rstrip())
while True:
    if B > A:
        break
    if K == 0:
        break
    B*=2
    K-=1

while True:
    if C > B:
        break
    if K == 0:
        break
    C*=2
    K-=1
    
if C > B:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + (ll)b) % mod
#define MUL(a, b) a = (a * (ll)b) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rer(i, a, b) for(int i = a - 1; i >= b; i--)
#define all(a) (a).begin(), (a).end()
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef pair<int, pi> ppi;

const int MAX_N = 200010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;

void Debug() {cout << '\n'; }

template<class FIRST, class... REST> 
void Debug(FIRST arg, REST... rest) { cout << arg << " "; Debug(rest...); }

template<class T>
ostream& operator<< (ostream& out, const vector<T>& v) {
	out << "[";
	if(!v.empty()) {
		rep(i, 0, (int)v.size() - 1) out << v[i] << ", ";
		out << v.back();
	}
	out << "]";
  return out;
}

template<class S, class T>
ostream& operator<< (ostream& out, const pair<S, T>& v) {
	out << "(" << v.first << ", " << v.second << ")";
	return out;
}

///g++ -g3 -std=c++0x -DLOCAL -Wall -ftrapv -D_GLIBCXX_DEBUG -Wl,-stack,268435456 -o
///g++ -O2 -std=c++0x -DLOCAL -Wall -Wl,-stack,268435456 -o

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

int n;

//BIT 1-origin

ll bit[MAX_N];

ll sum(int i) {
	ll s = 0;
	while(i > 0) {
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(int i, ll x) {
	while(i <= n) {
		bit[i] += x;
		i += i & -i;
	}
}

int N;
ll K;
ll B[MAX_N];
vector<ll> vec;

int fd(ll a) {
	return lower_bound(all(vec), a) - vec.begin();
}

void solve() {
	cin >> N >> K;
	rep(i, 1, N + 1) {
		cin >> B[i];
		B[i] += B[i - 1];
	}
	rep(i, 1, N + 1) {
		B[i] -= K * i;
		vec.push_back(B[i]);
	}
	sort(all(vec));
	vec.erase(unique(all(vec)), vec.end());
	n = vec.size();
	ll res = 0;
	rep(i, 0, N + 1) {
		res += sum(fd(B[i]) + 1);
		add(fd(B[i]) + 1, 1);
	}
	cout << res << "\n";
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(0);	
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 5104
# coding: utf-8
# Your code here!

x,y = [int(i) for i in input().split()]

fiboMax = 100

fibo = [0 for i in range(fiboMax)]
fibo[1] = 1
fibo[2] = 1

for i in range(3,fiboMax):
    fibo[i] = fibo[i-1] + fibo[i-2]
    
xMax = 0
yMax = 0
xMin = 0
yMin = 0

ans = -1
if(x <= xMax and y <= yMax and x >= xMin and y >= yMin):
    ans = 1
else:
    i = 2
    while(True):
        xMax += fibo[i]
        if(x <= xMax and y <= yMax and x >= xMin and y >= yMin):
            ans = i
            break
        else:
            i += 1
        yMax += fibo[i]
        if(x <= xMax and y <= yMax and x >= xMin and y >= yMin):
            ans = i
            break
        else:
            i += 1
        xMin -= fibo[i]
        if(x <= xMax and y <= yMax and x >= xMin and y >= yMin):
            ans = i
            break
        else:
            i += 1
        yMin -= fibo[i]
        if(x <= xMax and y <= yMax and x >= xMin and y >= yMin):
            ans = i
            break
        else:
            i += 1

ans %= 3
if ans == 0:
    ans = 3

print(ans)



Measured memory_bytes: 5620
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

int main() {
  ll n, d;
  cin >> n >> d;
  int ans = 0;
  REP(i, n) {
    ll x, y;
    cin>>x>>y;
    if(x*x + y*y <= d*d) ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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

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

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

ll wa(ll a,ll c,ll d,ll cd){
    ll t1 = (a-1)/c;
    ll t2 = (a-1)/d;
    ll t3 = (a-1)/cd;
    return  a-1-t1-t2+t3;
}

void solve() {
   string s;
   cin >> s;
   sort(s.begin(),s.end());
   bool flag = false;
   if(s[0] != s[1])flag = true;
   if(s[2] != s[3])flag = true;
   if(s[1] == s[2])flag = true;

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


}
int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<fstream>
#include<algorithm>
using namespace std;
using ll = long long;


int main(){
    ll n;
    cin >> n;
    string str;
    cin >> str;
    ll cnt=1;
    for(ll i=0;i<n-1;i++){
        if(str[i]!=str[i+1])    cnt++;
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int L=stdIn.nextInt();
		int z=0,sum=0,ans=0,ir=1,x=99999;
		while(z<N){
			sum+=z+L;
			z++;
		}z=0;
		while(z<N){
			if(sum-(sum-z-L)<0)
				ir=-1;
			if((sum-(sum-z-L))*ir<x){
				x=(sum-(sum-z-L))*ir;
				ans=sum-z-L;
			}
			ir=1;
			z++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21716
const MOD: u64 = 1_000_000_007;

fn mod_pow(r: u64, mut n: u64) -> u64 {
    let mut t = 1;
    let mut s = r;
    while n > 0 {
        if n & 1 == 1 {
            t = t * s % MOD;
        }
        s = s * s % MOD;
        n >>= 1;
    }
    t
}

fn comb(n: u64, k: u64) -> u64 {
    let mut nu = 1;
    let mut de = 1;
    for i in 0..k {
        nu = nu * (n - i) % MOD;
        de = de * (i + 1) % MOD;
    }
    nu * mod_pow(de, MOD - 2) % MOD
}

fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: u64 = it.next().unwrap().parse().unwrap();
    let a: u64 = it.next().unwrap().parse().unwrap();
    let b: u64 = it.next().unwrap().parse().unwrap();
    let ans = (mod_pow(2, n) + MOD - comb(n, a) - comb(n, b) - 1 + MOD) % MOD;
    println!("{}", ans);
}

fn main() {
    run();
}


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

int main() {
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> q[i];
    }

    //並び替えたい数列をaという配列に入れる
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        a[i] = i+1;
    }

    //next-permutationで数列aを並び替える
    //並び替えられた順列をキーとして値(mpのサイズ)を代入
    //次の順列がなければfalseを返す
    map<vector<int>, int> mp;
    do {
        mp[a] = mp.size();
    } while (next_permutation(a.begin(), a.end()));
    
    int ans = abs(mp[p] - mp[q]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5248
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < 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;
	}
}

// 二項係数計算
long long 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;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	int k, a, b;
	cin >> k >> a >> b;
	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			cout << "OK";
			return 0;
		}
	}
	cout << "NG";

}

Measured memory_bytes: 3596
#include <stdio.h>
 
int main()
{
    double a,b,c,d,e,f,x,y;
    while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) != EOF)
    {
        x=(c*e-b*f)/(double)(a*e-b*d);
        y=(c*d-a*f)/(double)(b*d-a*e);
        if(-0.0004<x&&x<=0)x=0;
        if(-0.0004<y&&y<=0)y=0;
        printf("%.3lf %.3lf\n",x,y);
    }
    return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <cmath>
using namespace std;

double triangle(double x1,double y1,double x2,double y2,double x3,double y3) {
  double a[2],b[2],theta,al,bl;
  a[0] = x2 - x1;
  a[1] = y2 - y1;
  b[0] = x3 - x1;
  b[1] = y3 - y1;
  al = sqrt(a[0] * a[0] + a[1] * a[1]);
  bl = sqrt(b[0] * b[0] + b[1] * b[1]);
  theta = acos((a[0] * b[0] + a[1] * b[1]) / (al * bl));
  return al * bl * abs(sin(theta)) / 2;
}

int main() {
  double x0,y0,x1,y1,x2,y2,x3,y3;
  double abc,bcd,cda,dab,abd,cbd,acd;
  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&x0,&y0,&x1,&y1,&x2,&y2,&x3,&y3) == 8) {
    abc = triangle(x0,y0,x1,y1,x2,y2);
    bcd = triangle(x1,y1,x2,y2,x3,y3);
    cda = triangle(x2,y2,x3,y3,x0,y0);
    dab = triangle(x3,y3,x0,y0,x1,y1);
    abd = triangle(x0,y0,x1,y1,x3,y3);
    cbd = triangle(x2,y2,x1,y1,x3,y3);
    acd = triangle(x0,y0,x2,y2,x3,y3);
    if(abc > abd + cbd)
      cout << "NO" << endl;
    else if(bcd > abc + acd)
      cout << "NO" << endl;
    else if(cda > abd + bcd)
      cout << "NO" << endl;
    else if(dab > abc + acd)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
}

Measured memory_bytes: 0
use std::io::Read;

const MOD: usize = 1_000_000_007;

fn mod_pow(r: usize, mut n: usize) -> usize {
    let mut t = 1;
    let mut s = r % MOD;
    while n > 0 {
        if n & 1 == 1 {
            t = t * s % MOD;
        }
        s = s * s % MOD;
        n >>= 1;
    }
    t
}

fn comb(n: usize, k: usize) -> usize {
    let k = std::cmp::min(k, n - k);
    let mut nu = 1;
    let mut de = 1;
    for i in 0..k {
        nu = nu * (n - i) % MOD;
        de = de * (i + 1) % MOD;
    }
    nu * mod_pow(de, MOD - 2) % MOD
}

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let x: usize = it.next().unwrap().parse().unwrap();
    let y: usize = it.next().unwrap().parse().unwrap();
    if !((x + y) % 3 == 0 && x <= 2 * y && 2 * x >= y) {
        println!("0");
        return;
    }
    let dx = (2 * x - y) / 3;
    let dy = (2 * y - x) / 3;
    let ans = comb(dx + dy, dx);
    println!("{}", ans);
}

fn main() {
    run();
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int x = 0;
    int maxv = 0;
    string s;
    int n;
    cin >> n;
    cin >> s;
    rep(i, n)
    {
        if (s[i] == 'I')
            x++;
        else
            x--;

        if (x > maxv)
            maxv = x;
    }

    OP(maxv);
    return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {

  val n = StdIn.readInt
  val f = Iterator.continually(StdIn.readLine)
    .take(n)
    .map(_.split(" ").map(_.toInt))
    .toArray
  val p = Iterator.continually(StdIn.readLine)
    .take(n)
    .map(_.split(" ").map(_.toInt))
    .toArray

  var ans = Int.MinValue
  val a = Array.ofDim[Int](10)
  val empty = a.clone

  def evaluate():Unit = {
    if(a sameElements empty) { }
    else {
      val score = 
        for(i <- 0 until n) yield {
          val itf = f(i).iterator
          val s = a.foldLeft(0)((acc, e) => {
            if((e & itf.next) == 1) acc+1
            else acc
          })
          p(i)(s)
        }
      ans = math.max(ans, score.sum)
    }
  }

  def dfs(pos:Int):Unit = {
    if(pos == 10) evaluate()
    else {
      a(pos) = 0; dfs(pos+1)
      a(pos) = 1; dfs(pos+1)
    }
  }

  dfs(0)
  println(ans)
}

Measured memory_bytes: 36624
#include <bits/stdc++.h>
#define long long long int
using namespace std;

// @author: pashka

long prog(long x) {
    return x * (x - 1) / 2;
}

int main() {
    ios::sync_with_stdio(false);

    int n;
    long x, d;
    cin >> n >> x >> d;
    if (d < 0) {
        x = -x;
        d = -d;
    }

    if (d == 0) {
        if (x == 0) {
            cout << 1;
        } else {
            cout << n + 1;
        }
        return 0;
    }

    map<int, vector<pair<long, long>>> seg;

    for (int a = -n; a <= n; a++) {
        if ((a & 1) != (n & 1)) continue;
        // plus + minus = n
        // plus - minus = a
        int plus = (n + a) / 2;

        long bmin = prog(plus) - (prog(n) - prog(plus));
        long bmax = -prog(n - plus) + (prog(n) - prog(n - plus));

        long p = a * x + bmin * d;
        long k = (bmax - bmin) / 2 + 1;

        int q = p % (2 * d);
        if (q < 0) q += 2 * d;

        long l = (p - q) / (2 * d);
        long r = l + k;

//        cout << a << " " << bmin << " " << bmax << " " <<
//        p << " " << k << " " << q << " " << l << " " << r << "\n";

        seg[q].push_back({l, r});
    }

    long res = 0;
    for (auto &p : seg) {
        auto &ss = p.second;
        sort(ss.begin(), ss.end());
        long r = LONG_MIN;
        for (auto s : ss) {
            if (s.second <= r) continue;
            res += s.second - max(r, s.first);
            r = s.second;
        }
    }
    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 23340