akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>

static void
set(unsigned int *table, unsigned int N, int px, int py, unsigned int v)
{
    unsigned int x, y;

    if (px > py) {
        x = px;
        y = py;
    }
    else {
        x = py;
        y = px;
    }

    table[x + y * N] = v;
}

static unsigned int
get(unsigned int *table, unsigned int N, int px, int py)
{
    unsigned int x, y;

    if (px > py) {
        x = px;
        y = py;
    }
    else {
        x = py;
        y = px;
    }

    return table[x + y * N];
}

static void
dump(unsigned int *table, unsigned int N)
{
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            fprintf(stderr, "%u ", table[i + j * N]);
        }
        fprintf(stderr, "\n");
    }
    fprintf(stderr, "\n");
}

int
main(int argc, char *argv[])
{
    unsigned int N, X, Y;
    unsigned n;

    scanf("%u %u %u", &N, &X, &Y);

    unsigned int *table = calloc(N * N, sizeof(unsigned int));
    unsigned int *counter = calloc(N + 1, sizeof(unsigned int));

    for (unsigned int i = 0; i < N; i++) {
        for (unsigned int j = i + 1; j < N; j++) {
            unsigned int d = 1;
            if (i <= (X - 1)) {
                d += (X - 1) - i;
            }
            else {
                d += i - (X - 1);
            }

            if (j <= (Y - 1)) {
                d += (Y - 1) - j;
            }
            else {
                d += j - (Y - 1);
            }

            //fprintf(stderr, "(%u, %u) d %u j-i %u\n", i, j, d, j - i);
            if (d < j - i) {
                set(table, N, i, j, d);
            }
            else {
                set(table, N, i, j, j - i);
            }
        }
    }
    //dump(table, N);

    for (unsigned int i = 0; i < N; i++) {
        for (unsigned int j = i + 1; j < N; j++) {
            unsigned int v = get(table, N, i, j);
            counter[v]++;
        }
    }

    for (int i = 1; i < N; i++) {
        printf("%u\n", counter[i]);
    }

    return EXIT_SUCCESS;
}


Measured memory_bytes: 15744
use proconio::input;

fn main() {
  input! {
    n: isize,
  }
  let f = |n,d| {
    let k = n / d; // k terms
    d * k * (k + 1) / 2
  };
  println!("{}", f(n,1) - f(n,3) - f(n,5) + f(n,15));

}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<(int)(r); i++)
#define rep_eq(i,l,r) for(int i=l; i<=(int)(r); i++)
#define all(vec) vec.begin(),vec.end()
#define allr(vec) vec.rbegin(),vec.rend()
using namespace std;

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=int64_t;

using vb=vector<bool>;
using vc=vector<char>;
using vs=vector<string>;
using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;

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

  ll N; cin >>N;

  string ans="";
  while (0<N) {
    int a=--N%26;
    char b=a+'a';
    ans+=b;
    N/=26;
  }

  reverse(all(ans));
  cout <<ans <<'\n';
  return 0;
}


Measured memory_bytes: 3596
// ConsoleApplication1.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include<iostream>
using namespace std;
int max(int a, int b);
int main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	cout << max(A*B, C*D);
    return 0;
}
int max(int x, int y) {
	if (x > y) {
		return x;
	}
	else {
		return y;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
 
using namespace std;
 
struct Card
{
    int num;
    char design;
    int suffix;
};
 
int partition(Card A[], int p, int r) {
    int x = A[r].num;
    int i = p;
 
    for (int j = p; j < r; j++) {
        if (A[j].num <= x) {
            swap(A[i++], A[j]);
        }
    }
    swap(A[i], A[r]);
 
    return i;
}
 
void quicksort(Card A[], int p, int r) {
    if (p < r) {
        int q = partition(A, p, r);
        quicksort(A, p, q - 1);
        quicksort(A, q + 1, r);
    }
}
 
bool stable(Card A[], int n) {
    for (int i = 0; i < n - 1; i++) {
        if (A[i].num == A[i + 1].num && A[i].suffix > A[i + 1].suffix) {
            return false;
        }
    }
 
    return true;
}
 
int main() {
    int n;
    cin >> n;
    Card A[n];
 
    for (int i = 0; i < n; i++) {
        cin >> A[i].design >> A[i].num;
        A[i].suffix = i;
    }
 
    quicksort(A, 0, n - 1);
 
    if (stable(A, n)) {
        cout << "Stable";
    }
    else {
        cout << "Not stable";
    }
    cout << endl;
 
    for (int i = 0; i < n; i++) {
        cout << A[i].design << " " << A[i].num << endl;
    }
 
    return 0;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 2e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

#define K 1010
int k;
vector<vll> sum(2 * K + 1, vll(2 * K + 1, vl(2, 0)));


ll add(int i0, int j0, int i1, int j1, int c) {
	ll temp = 0;
	temp += sum[i1][j1][c];
	temp -= sum[i1][j0][c];
	temp -= sum[i0][j1][c];
	temp += sum[i0][j0][c];
	return temp;
}

int main() {
	int n, i, j;
	cin >> n >> k;
	for (i = 0; i < n; i++) {
		ll x, y;
		char c;
		cin >> x >> y >> c;
		x %= (2 * k);
		y %= (2 * k);
		if (c == 'B') {
			sum[x + 1][y + 1][0]++;
		}
		else {
			sum[x + 1][y + 1][1]++;
		}
	}
	for (i = 0; i < 2 * k; i++) {
		for (j = 0; j < 2 * k; j++) {
			sum[i + 1][j + 1][0] += sum[i + 1][j][0];
			sum[i + 1][j + 1][1] += sum[i + 1][j][1];
		}
		for (j = 0; j < 2 * k; j++) {
			sum[i + 1][j + 1][0] += sum[i][j + 1][0];
			sum[i + 1][j + 1][1] += sum[i][j + 1][1];
		}
	}
	/*
	for (i = 0; i <= 2 * k; i++) {
		for (j = 0; j <= 2 * k; j++) {
			printf("(%lld, %lld) ", sum[i][j][0], sum[i][j][1]);
		}
		cout << endl;
	}
	//*/

	ll ans = -1;
	for (i = 0; i <= k; i++) {
		for (j = 0; j <= k; j++) {
			for (int c = 0; c <= 1; c++) {
				ll temp = 0;
				temp += add(0, 0, i, j, 1 - c);
				temp += add(i, j, i + k, j + k, 1 - c);
				temp += add(i + k, 0, 2 * k, j, 1 - c);
				temp += add(0, j + k, i, 2 * k, 1 - c);
				temp += add(i + k, j + k, 2 * k, 2 * k, 1 - c);
				temp += add(i, 0, i + k, j, c);
				temp += add(0, j, i, j + k, c);
				temp += add(i + k, j, 2 * k, j + k, c);
				temp += add(i, j + k, i + k, 2 * k, c);
				ans = max(ans, temp);
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 223744
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
#define all(a) a.begin(), a.end()
#define mp(a, b) make_pair(a, b)

int INF = 100100100;
int MOD = 10e7+9;

ll sum(ll x){
    return (x*(x+1))/2;
}

int main(){
    int N;
    cin >> N;
    ll ans = 0;
    rep(i, 1, N+1){
        ll j;
        j = sum(N/i)*i;
        ans += j;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <vector>
#include <sstream>
#include <algorithm>
#include <fstream>
#include <list>
#include <map>
#include <istream>
#include <bitset>
#include <sstream>
#include <unordered_map>
#include <stack>
#include <set>
#include <cmath>
#include <random>
#include <iostream>
#include <bitset>
#include <iomanip>
#include <queue>
#include <string>

#define int long
#define endl "\n"
#define all(x) x.begin(),x.end()
#define rr return 0
#define xx first
#define yy second
#define pii pair<int,int>

using namespace std;

typedef long long ll;
typedef long double ld;

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    int ans = 0;
    for(int i = 0;i  <n;i++){
        cin >> a[i];
    }
    int p = 0;
    for(int i = 1;i < n;i++){
        if(a[i] > a[i - 1]){
            ans = max(ans, i - p);
            p = i;
        }
    }
    ans = max(ans, n - p);
    cout << ans - 1;
    rr;
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())
#define MIN(c) (*min_element(ALL(c))) 
#define MAX(c) (*max_element(ALL(c)))
#define ACC(c) (accumulate(ALL(c), 0))
#define SLL(x, n) ((x) << (n))
#define SRL(x, n) ((x) >> (n))
#define MP(a, b) (make_pair((a), (b)))
#define ENDL "\n"
#define PRINT(x) cout << (x) << ENDL

using namespace std;
using ll = long long;
using pint = pair<int, int>;

inline int in(int& a) {return scanf("%d", &a);}
inline void out(int n) {printf("%d\n", n);}
template<typename T> inline void swap(T& a, T& b) {T tmp = a; a = b; b = tmp;}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


const int MOD = (int)(1e9 + 7);
int len;
string L;
ll dp[100002][2];   //index, flag

ll solve(){
    dp[0][0] = 1; dp[0][1] = 0;
    REP(i, len){
        dp[i + 1][0] = dp[i][0] % MOD;
        dp[i + 1][1] = 3 * dp[i][1] % MOD;
        if(L[i] == '1'){
            dp[i + 1][0] = 2 * dp[i + 1][0] % MOD;
            dp[i + 1][1] = (dp[i + 1][1] + dp[i][0]) % MOD;
        }
    }
    return (dp[len][0] + dp[len][1]) % MOD;
}

signed main(){
    cin >> L;
    len = L.length();
    PRINT(solve());
    return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
int gcd(ll a, ll b){
    if(b == 0) return a;
    gcd(b,a%b);
}

int main() {
  /*箱にN個のボールがあり、二つのボールを取り、その差の絶
  対値が書かれたボールと一緒に箱に戻ず*/
  /*Kが書かれたボールが箱の中に入っている状態にできるか？*/
  //K > MAX-minの時はダメ
  
  /*最大公約数がある時、最小の数は最大公約数となる,KがMax-min以下で、gcdの倍数だったらok*/
  /*1以外の最大公約数がなく、奇数と偶数があるとき、任意の数を作れる?*/
  /*a(奇数)>b(偶数))の時、新たに、奇数a%b = c(0<c<=b-1)を作れる{a,b,c}において,新たに奇数d＝b%c(0<d<=c-1)を作れる
   これを繰り返すといずれ1を作れる  */
  /*a(偶数)>b(奇数)の時、新たに奇数c= a%b(0<c<=b-1)を作れる*/
  /*奇数と偶数があるとき、一方から他方を引けるだけ引いた残りの奇数を新たに箱に加え、その数で、箱の偶数をまた引けるだけ引くといずれ1を作れる*/
  ll N,K;
  cin >> N >> K;
  vector<ll> A(N);
  for(ll i = 0;i<N;i++){
      cin >> A[i];
  }
  sort(A.begin(),A.end());
  ll c = gcd(A[0],A[1]);
  for(ll i = 2;i<N;i++){
    c = gcd(c,A[i]);
  }
 
for(int i  = 0;i<N;i++){
  if(A[i] == K){
    cout << "POSSIBLE" <<endl;
    return 0;
  }
}
  if(K > A[A.size()-1]) cout << "IMPOSSIBLE" <<endl;
  else{
      if(c != 1){
          if(K%c == 0) cout << "POSSIBLE"<<endl;
          else cout << "IMPOSSIBLE" <<endl;
      }
      else cout << "POSSIBLE" <<endl;
  }
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)cin >> a[i];
    for (int i = n-1; i>=0; i--)cout <<(i!=n-1?" ":"")<<a[i];
    cout << endl;
    return 0;
}


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

using std::pair;
using std::vector;
using std::string;

typedef long long ll;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int oo = 0x3f3f3f3f;
 
template<typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48; 
    return x *= f;
}

const int N = 100000;

int n;
int v[N + 5];

int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif

    int f = 0, t = 0;

    read(n);
    for(int i = 1; i <= n; ++i) {
        read(v[i]);
        if(chkmax(t, std::abs(v[i]))) f = v[i] > 0 ? i : -i;
    }

    if(!f) {
        puts("0");
    } else if(f > 0) {
        printf("%d\n", 2*n - 1);
        for(int i = 1; i <= n; ++i) { printf("%d %d\n", f, i); }
        for(int i = 2; i <= n; ++i) { printf("%d %d\n", i-1, i); }
    } else {
        printf("%d\n", 2*n - 1);
        for(int i = 1; i <= n; ++i) { printf("%d %d\n", -f, i); }
        for(int i = n; i >= 2; --i) { printf("%d %d\n", i, i-1); }
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int p[23][2200000],po[28],mk[23][2200000];
vector<int>v[22];
main()
{
	int t;
	scanf("%d",&t);
	po[0]=1;
	for(int i = 1;i < 26;i++)
	po[i]=po[i-1]*2;
	queue<int>q;
	q.push(0);
	for(int i = 0;i < t;i++)
	{
		for(int j = 0;j < t;j++)
		{
			scanf("%d",&p[i][j]);
			if(p[i][j]==1)
			v[i].push_back(j);
			p[i][j]=0;
		}
	}
	p[0][0]=1;
	for(int i = 0;i <= t;i++)
	{
		int co=q.size();
		while(co>0)
		{
			int val=q.front();
			for(int j = 0;j < v[i].size();j++)
			{
				//printf("%d %d %d %d\n",val,po[v[i][j]],v[i][j],val&po[v[i][j]]);
				if((val&po[v[i][j]]) ==0)
				{
					//printf("g");
					p[i+1][val|po[v[i][j]]]+=p[i][val];
					p[i+1][val|po[v[i][j]]]%=1000000007;
					if(mk[i+1][val|po[v[i][j]]]==0)
					q.push(val|po[v[i][j]]);
					mk[i+1][val|po[v[i][j]]]=1;
				}
			}
			q.pop();
			co--;
		}
	}
	printf("%d",p[t][po[t]-1]);
	/*for(int j = 0;j <= t+1;j++)
	{
		for(int i = 0;i < po[t+1];i++)
		printf("%d",p[j][i]);
		printf("\n");
	}*/
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

struct UnionFind {
  vector<int> data;

  UnionFind(int n){
    data.resize(n+1);
    fill(data.begin(), data.end(), -1);
  }

  int root(int x){
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }

  void unite(int x, int y){
    int rx=root(x);
    int ry=root(y);

    if(rx!=ry){
      if(data[ry] < data[rx])swap(rx, ry);

      data[rx]+=data[ry];
      data[ry]=rx;
    }
  }

  bool same(int x, int y){
    return root(x)==root(y);
  }

  int size(int x){
    return -data[root(x)];
  }
};

int main(){
  int n, m;cin>>n>>m;
  vector<int> a(m), b(m);
  rep(i, m)cin>>a[i]>>b[i];
  UnionFind uf(n);
  ll unc=(ll)n*(ll)(n-1)/2;
  vector<ll>results;
  rrep(i, m){
    results.push_back(unc);
    if(!uf.same(a[i], b[i])){
      unc -= (ll)uf.size(a[i]) * (ll)uf.size(b[i]);
      uf.unite(a[i], b[i]);
    }
  }
  rrep(i, m)cout<<results[i]<<endl;

  return 0;
}


Measured memory_bytes: 3444
def power2(base, exp, mod)
  if(exp == 1)
    return base % mod;
  else
    if exp % 2 == 0
      return (power2(base, exp/2, mod) ** 2) % mod
    else
      return (base * (power2(base, (exp-1)/2, mod) ** 2)) % mod
    end
  end
end

def comb(n, k, mod)
  c = 1
  d = 1
  for i in (1..k)
    c = (c * (n - k + i)) % mod
    d = (d * i) % mod
  end
  
  return (c * power2(d, mod - 2, mod)) % mod
end

n, a, b = gets.split.map(&:to_i)

mod = 10 ** 9 + 7

if a != b
  X = comb(n, a, mod) + comb(n, b, mod)
else
  X = comb(n, a, mod)
end
A = power2(2, n, mod) - 1 + mod
puts (A - X % mod) % mod


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int l = sc.nextInt();

        int[] taste = new int[n];
        int[] min = {-1, 300};
        for (int i = 0; i < n; i++) {
            taste[i] = i + l;
            if (min[1] >= Math.abs(taste[i])) {
                min[0] = i;
                min[1] = Math.abs(taste[i]);
            }
        }
        int result = 0;
        for (int i = 0; i < n; i++) {
            if (i != min[0]) {
                result += taste[i];
            }
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 23636
### main

m = gets.to_i

m.times do
  fund = gets.to_i
  year = gets.to_i

  max_fund = 0
  n = gets.to_i

  n.times do
    line = gets.strip.split
    inti = Rational(line[1])
    costi = line[2].to_i
    #p [flagi, inti, costi]

    if line[0] == '0'	# Simple Interest
      f = fund
      sumi = 0

      year.times do
        sumi += (f * inti).truncate
        f -= costi
      end
      f += sumi

      max_fund = f if max_fund < f
    else		# Compound Interest
      f = fund

      year.times do
        f += (f * inti).truncate - costi
      end

      max_fund = f if max_fund < f
    end
  end

  puts max_fund
end

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  ll X, Y, A, B, C; cin >> X >> Y >> A >> B >> C;
  vector<ll> p(A); REP(i, A) cin >> p[i];
  vector<ll> q(B); REP(i, B) cin >> q[i];
  vector<ll> r(C); REP(i, C) cin >> r[i];
  ll ans = 0;
  sort(all(p), greater<ll>());
  sort(all(q), greater<ll>());
  sort(all(r), greater<ll>());
  vector<ll> tmp;
  REP(i, X) tmp.push_back(p[i]);
  REP(i, Y) tmp.push_back(q[i]);
  REP(i, C) tmp.push_back(r[i]);
  sort(all(tmp), greater<int>());
  for(int i = 0; i < (X + Y); ++i) {
    ans += tmp[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 9724
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#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 rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

ll gcd(ll a, ll b) {
  if (b > a) {
    swap(a, b);
  }
  ll r = a%b;
  while (r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}

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


signed main() {
    fio();
    int k;
    cin >> k;
    ll ans = 0;
    rep1 (a, k) {
        rep1 (b, k) {
            rep1 (c, k) {
                ans += gcd(a, gcd(b, c));
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

using VL = vector<long long>;
using VVL = vector<VL>;

void show(VVL dp) {
	for (auto v: dp) {
		for (auto x: v) {
			printf(" %3lld", x);
		}
		printf("\n");
	}
}

int main() {
	int n, w_limit;
	cin >> n >> w_limit;

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

	VVL dp(n+1, VL(2*w_limit + 1, 0)); // [i+1番目の品物][重さjの時の最大価値]

	for (int i = 0; i < n; i++) {
		for (int j = w_limit; j >= 0; j--) {
			if (dp[i][j] == 0) {
				continue;
			}
			dp[i+1][j] = dp[i][j];

			int next_w = j + w[i];
			dp[i+1][next_w] = max(dp[i+1][next_w], dp[i+1][j] + v[i]);
		}
		dp[i+1][w[i]] = max(dp[i+1][w[i]], (long long)v[i]);
	}

	long long ans = 0;
	for (int i = 0; i <= w_limit; i++) {
		ans = max(ans, dp[n][i]);
	}
	cout << ans << endl;

	// show(dp);
	return 0;
}


Measured memory_bytes: 159744
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = readLine()!!
    val B = readLine()!!
    val C = readLine()!!

    var count = 0
    for (i in 0 until N) {
        val c = booleanArrayOf(A[i] == B[i], B[i] == C[i], C[i] == A[i]).count { it }
        count += when (c) {
            0 -> 2
            1 -> 1
            else -> 0
        }
    }
    println(count)
}

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

int main(){
    int A,B,K;
    cin >> A>>B>>K;
if(B-A+1>=2*K){
    for(int i=0;i<K;i++){
        cout <<A+i<<endl;
    }
    for(int i=K-1;i>=0;i--){
        cout <<B-i<<endl;
    }
}
else{
    for(int i=A;i<=B;i++){
        cout<<i<<endl;
    }
}
return 0;
 }

Measured memory_bytes: 3624
#include <cstdio>
#include <set>
#include <vector>
#include <cstring>

using namespace std;

typedef long long ll;
const ll mod = 1e9+7;
ll dp[333][333][333];

ll pl(ll a, ll b) {
  return (a+b)%mod;
}
ll ml(ll a, ll b) {
  return (a*b)%mod;
}

vector<int> p;
vector<int> g[11];
int n, m;
bool used[11];
bool chk(int x) {
  if (x == 0) return true;
  if (used[x]) return false;
  used[x] = true;
  for (int i = 0; i < int(g[x].size()); i++) {
    if (chk(g[x][i])) return true;
  }
  return false;
}

int solve(int v) {
  if (int(p.size()) == m+1) {
    if (p[0] != 0) return 0;
    for (int i = 0; i < n; i++) {
      g[i].clear();
    }
    for (int i = 0; i < int(p.size())-1; i++) {
      if (p[i] != p[i+1]) {
        g[p[i]].push_back(p[i+1]);
      }
    }
    for (int i = 1; i < n; i++) {
      memset(used, 0, sizeof(used));
      if (!chk(i)) {
        return 0;
      }
    }
    return 1;
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    p.push_back(i);
    res += solve(i);
    p.pop_back();
  }
  return res;
}

int main(void) {
  scanf("%d%d", &n, &m);
  // printf("%d\n", solve(0));
  dp[0][1][0] = 1;
  for (int i = 0; i < m; i++) {
    for (int j = 1; j <= n; j++) {
      //*
      // 強連結な頂点から強連結な頂点へ
      dp[i+1][j][0] = pl(dp[i+1][j][0], ml(dp[i][j][0], j));
      // 強連結な頂点から強連結でない頂点へ
      dp[i+1][j][1] = pl(dp[i+1][j][1], ml(dp[i][j][0], n-j));
      //*/
      for (int k = 1; k < n; k++) {
        // 強連結でない頂点から強連結でない頂点，新しく加える
        if (n-j-k >= 0) {
          dp[i+1][j][k+1] = pl(dp[i+1][j][k+1], ml(dp[i][j][k], n-j-k));
        }
        // 強連結でない頂点から強連結でない頂点へ
        dp[i+1][j][k] = pl(dp[i+1][j][k], ml(dp[i][j][k], k));
        // 強連結でない頂点から強連結な頂点へ
        if (j+k <= n) {
          dp[i+1][j+k][0] = pl(dp[i+1][j+k][0], ml(dp[i][j][k], j));
        }
      }
    }
  }
  ll res = 0;
  for (int i = 0; i < n; i++) {
    // printf("%lld\n", dp[m][n][i]);
    res = pl(res, dp[m][n][i]);
  }
  printf("%lld\n", res);
  return 0;
}


Measured memory_bytes: 235520
#include <iostream>
#include <bitset>
#include <vector>
#include <stdio.h>
using namespace std;

/*
void print_bingo(int A[3][3]){
    for(int i=0;i!=3;++i){
        for(int j=0;j!=3;++j){
            cout<<A[i][j];
            if(j<2){
                cout<<" ";
            }else{
                cout<<endl;
            }
        }
        
    }
}
*/
bool is_bingo(int A[3][3]){
    bool flag=false;
    for(int i=0;i!=3;++i){
        if(A[0][i]=='o'&&A[1][i]=='o'&&A[2][i]=='o'){
            flag=true;
            break;
        }
        if(A[i][0]=='o'&&A[i][1]=='o'&&A[i][2]=='o'){
            flag=true;
            break;
        }
    }
    if(A[0][0]=='o'&&A[1][1]=='o'&&A[2][2]=='o'){
        flag=true;
    }
    if(A[2][0]=='o'&&A[1][1]=='o'&&A[0][2]=='o'){
          flag=true;
    }
    return flag;
}

int main(){
    
    int A[3][3];
    
    for(int i=0;i!=3;++i){
        for(int j=0;j!=3;++j){
            scanf("%d",&A[i][j]);
        }
    }
    int N;
    scanf("%d",&N);
    int b;
    for(int i=0;i!=N;++i){
        scanf("%d",&b);
        for(int j=0;j!=3;++j){
            for(int k=0;k!=3;++k){
                if(A[j][k]==b){
                    A[j][k]='o';
                }
            }
            
        }
       //print_bingo(A);
    }
    
    if(is_bingo(A)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 1001001001;
//stoi(s) : string→int stoll(s) :string→longlong  int→string to_string(i)
const double PI = acos(-1.0);
//小数点の表し方 cout << fixed << setprecision(5);
int x[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

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

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Scanner;
import java.util.Vector;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		
		int v = sc.nextInt();
		int e = sc.nextInt();
		
		ArrayList<Edge> path = new ArrayList<Edge>();
		for(int i = 0; i < e; i++){
			
			path.add(new Edge(sc.nextInt(), sc.nextInt(), sc.nextInt(), 0));
		}
		
		System.out.println(solve(v, path));

	}
	
	static int solve(int V, ArrayList<Edge> path){
		//グラフの隣接リスト表現
		@SuppressWarnings("unchecked")
		Vector<Edge> G[] = new Vector[V];
		for(int i = 0; i < G.length; i++){
			G[i] = new Vector<Edge>();
		}
				
		//頂点間を結ぶ
		Iterator<Edge> it = path.iterator();
		while(it.hasNext()){
			Edge tmpEdge = it.next();
			addEdge(G, tmpEdge.from, tmpEdge.to, tmpEdge.cap);
		}
		
		return maxFlow(G, 0, V - 1);
	}
	
	static void addEdge(Vector<Edge>[] graph, int from, int to, int cap){
		graph[from].add(new Edge(-1, to, cap, graph[to].size()));
		graph[to].add(new Edge(-1, from, 0, graph[from].size() - 1));
	}
	
	static int maxFlow(Vector<Edge>[] graph, int s, int t){
		int flow = 0;
		
		boolean used[] = new boolean[graph.length];
		
		while(true){
			Arrays.fill(used, false);
			int f = dfs(graph, used, s, t, Integer.MAX_VALUE);
			if(f == 0){
				return flow;
			}
			flow += f;
			
		}
	}
	
	static int dfs(Vector<Edge>[] graph, boolean[] used, int v, int t, int f){
		if(v == t){
			return f;
		}
		
		used[v] = true;
		
		for(int i = 0; i < graph[v].size() ; i++){
			Edge e = graph[v].get(i);

			if(!used[e.to] && e.cap > 0){
				int d = dfs(graph, used, e.to, t, Math.min(f, e.cap));
				if(d > 0){
					e.cap -= d;
					graph[e.to].get(e.rev).cap += d;
					return d;
				}
			}
		}

		return 0;
	}	
}

class Edge {
	int from;
	int to;//行き先
	int cap;//容量
	int rev;//逆辺
	private int originalCap;
	
	Edge(int from, int to, int cap, int rev){
		this.from = from;
		this.to = to;
		this.cap = cap;
		this.rev = rev;
		this.originalCap = cap;
	}
	
	void recovery(){
		cap = originalCap;
	}
}


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

#define ll long long
#define nl '\n'
#define forn(i, n) for(ll i = 0; i < n; ++i)
#define fori(i, a, b) for(ll i = a; i < b; ++i)

using namespace std;

int main(){

    #ifdef LOCAL  
        freopen("input.txt", "r", stdin);
    #endif
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    vector<string> v;

    ll n; cin >> n;
    ll l; cin >> l;

    forn(i, n){
        string s; cin >> s;
        v.push_back(s);
    }

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

    for(auto x : v) cout << x;
    cout << nl;

    return 0;
}	
    

Measured memory_bytes: 3664
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,i;
	double x1,y1,x2,y2,x3,y3,x4,y4,x;
	scanf("%d",&n);
	for(i=0;i<n;i++)	{
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		if((x2-x1==0) || (x4-x3==0))	{
			if((x2-x1==0) && (x4-x3==0))	{
				printf("YES\n");
			}
			else {
				printf("NO\n");
			}
		}
		else {
			x=(y2-y1)/(x2-x1)-(y4-y3)/(x4-x3);
			if(x<0.0000001 && x>-0.0000001)	{
				printf("YES\n");
			}
			else {
				printf("NO\n");
			}
		}
	}
	return 0;
}


Measured memory_bytes: 1048
def solve(s):
    t = "AKIHABARA"
    u = ""
    i, j = 0, 0
    if len(s) > len(t):
        return "NO"
    while True:
        if len(t) <= i:
            break
        if (j < len(s)) and (t[i] == s[j]):
            u += s[j]
            i += 1
            j += 1
        elif t[i] == "A":
            u += "A"
            i += 1
        else:
            break
    return "YES" if (u == t) else "NO"

assert solve("KIHBR") == "YES"
assert solve("AKIBAHARA") == "NO"
assert solve("AAKIAHBAARA") == "NO"

s = input()
print(solve(s))

Measured memory_bytes: 3064
#include <iostream>
#include <string>

using namespace std;

int main(){
  int N;cin>>N;
  string S;cin>>S;
  int ans=0;
  for(int i=0;i<(N-1);i++){
    string temp;
    for(int j=0;j<=i;j++){
      if((S.find(S[j],i+1)!=-1)&&(temp.find(S[j])==(-1))){
        temp.push_back(S[j]);
      }
    }
    if(temp.size()>ans) ans=temp.size();
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

const int MAX_L = 3e3+10;

int dp[MAX_L][MAX_L] = {0};

string LongestCommonSubsequence(string s1, string s2) {
    int N = (int) s1.size();
    int M = (int) s2.size();
    vector < vector < int > > dp(N + 10, vector < int > (M + 10, 0));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if (s1[i] == s2[j]) {
                dp[i + 1][j + 1] = dp[i][j] + 1;
            } else {
                dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
            }
        }
    }

    string ret;
    for (int i = N, j = M; i > 0 && j > 0;) {
    	if (s1[i-1]==s2[j-1]) {
    		ret = ret + s1[i-1];
    		i--;
    		j--;
    	}
    	else {
    		if (dp[i-1][j] >= dp[i][j-1]) i--;
    		else j--;
    	}
    }
    reverse(ret.begin(), ret.end());
    return ret;
}

int main(int argc, char const *argv[])
{
	string s, t;
	cin >> s >> t;

	string ans = LongestCommonSubsequence(s, t);

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

Measured memory_bytes: 35712
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define ri register int
#define il inline
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define all(x) x.begin(),x.end() 
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define per(i,a,b) for(ri i=(a);i>=(b);--i)
#define ls (x<<1)
#define rs (x<<1|1)
#define mid (l+r>>1)
#define db(x) cout << "#x:" << x << endl
#define dd() cout << "Out put!\n"
const int mod=1e9+7,maxn=1000010;
const double eps=1e-8,pi=acos(-1.0);
const int inf=0x7f7f7f7f;
using namespace std;
int a[maxn],b[maxn],v[maxn];
string s,t;
signed main()
{
	ios::sync_with_stdio(0);


		cin >> s >> t;
		int l = s.size()-1;
		int ans = 0;
		rep(i,0,l)
			if(s[i] != t[i])
				ans++;
			cout << ans <<endl;
	
}


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

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

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T> void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U> void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

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

   vector<pair<LL,int>> p(n);
   for (int i = 0; i < n; ++i) {
      p[i] = make_pair(H[i] + P[i], i);
   }
   sort(p.begin(), p.end());

   vector<LL> _H(H), _P(P);
   for (int i = 0; i < n; ++i) {
      _P[i] = P[p[i].second];
      _H[i] = H[p[i].second];
   }
   swap(_P, P);
   swap(_H, H);

   auto dp = make_v<LL>(n+1, n+1);

   fill_all(dp, LINF);
   dp[0][0] = 0;

   for (int i = 1; i <= n; ++i) {
      for (int j = 0; j <= n; ++j) {
         chmin(dp[i][j], dp[i-1][j]);
         if (j > 0 && dp[i-1][j-1] <= H[i-1]) {
            chmin(dp[i][j], dp[i-1][j-1] + P[i-1]);
         }
      }
   }

   for (int i = 1; i <= n; ++i) {
      if (dp[n][i] == LINF) {
         cout << i-1 << endl;
         return 0;
      }
   }

   cout << n << endl;

   return 0;
}


Measured memory_bytes: 196096
# -*- coding: utf-8 -*-
n,l = list(map(int,input().split()))
apple_list = [i for i in range(l,l+n)]
max_al = max(apple_list)
min_al = min(apple_list)
ret = sum(apple_list)
if 0 not in apple_list:
    if abs(max_al) >= abs(min_al):
        ret -= min_al
    else:
        ret -= max_al
print(ret)


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


public class Main {
	private	static	BufferedReader br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String	line   = null;
		String	answer = null;
		int		weight = 0;

		while((line = parseNum()) != null) {
			answer = "";
			weight = Integer.parseInt(line);

			for (int n = 0, bit = 1; n < 10 && weight > 0; n++, bit <<= 1, weight >>= 1) {
				if (weight % 2 != 0) {
					if (!answer.isEmpty()) {
						answer += " ";
					}
					answer += bit;
				}
			}

			System.out.println(answer);
		}
	}

	private static String parseNum() {
		String	strNum = null;

		try {
			String line = br.readLine();
			if (line != null) {
				if (!line.isEmpty()) {
					strNum = line;
				}
			}
		}
		catch (IOException e) {}

		return strNum;
	}
}

Measured memory_bytes: 17068
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String r = sc.next();
    String t = sc.next();
    int answer =0;
    for(int i=0;i<3;i++){
      if(r.charAt(i)==(t.charAt(i))){
        answer=answer+1;
      }
    }
    System.out.println(answer);
      
  }
}

Measured memory_bytes: 22736
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		String S;
		String T;
		Scanner sc = new Scanner(System.in);
		S = sc.next();
		T = sc.next();
		if (S.length() < 1 || S.length() > 10 || T.startsWith(S) == false || S.length() + 1 != T.length()) {
			System.out.println("No");
		} else
			System.out.println("Yes");
	}
}

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

long long n, m, u, v, visited[100010], a = 0, b = 0;
vector<long long> graph[100010]; bool pos = false;

void dfs(long long u) {
	for(long long i = 0; i < graph[u].size(); i++) {
		long long v = graph[u][i];
		if(visited[v] > -1) {
			pos |= (visited[u] == visited[v]);
			continue;
		}
		visited[v] = not visited[u];
		a += not visited[v], b += visited[v];
		dfs(v);
	}
}

int main() {
	memset(visited, -1, sizeof(visited));
	scanf("%lld%lld", &n, &m);
	for(long long i = 0; i < m; i++) {
		scanf("%lld%lld", &u, &v);
		graph[u].push_back(v);
		graph[v].push_back(u);
	}
	a = 1, visited[1] = 0; dfs(1);
	if(pos) printf("%lld\n", n*(n-1)/2 - m);
	else printf("%lld\n", a*b - m);
}

Measured memory_bytes: 8064
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 4 2019
 * 
 */

#include <bits/stdc++.h>

//#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 

    char c;

    cin>>c;

    switch(c){
        case 'A':
            puts("T");
            break;

        case 'T':
            puts("A");
            break;

        case 'G':
            puts("C");
            break;

        case 'C':
            puts("G");
            break;

    }

    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("ain","r",stdin);
    freopen("aout","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

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

int main(){
    ll N;
    cin >> N;
    ll ans = 0;
    rep(i, 0, N){
        ll a; cin >> a;
        while(a % 2 == 0){
            ans++;
            a /= 2;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int K,A,B;
    cin>>K>>A>>B;
    string ans="NG";
    for(int i=A;i<B+1;i++){
        if(i%K==0){
            ans="OK";
        }
    }
    cout<<ans<<endl;
   return 0; 
}


Measured memory_bytes: 3592
//This is getting accepted!
// I HATE BUG
// God Of The Bugs
// 12/11/2016
#include<bits/stdc++.h>

using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define FI first
#define SE second
#define pb push_back
#define mp make_pair
#define ll long long
#define sz(a) ((int)(a).size())
#define __builtin_popcount __builtin_popcounll
#define ld long double

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> ppi;

const double PI = acos(0) * 2;
const double EPS = 1e-8;
const ll MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
const int oo = 1e9;
const double foo = 1e30;

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcounll(s);}
template<class T> T sqr(T x) { return x * x; }

inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}

int n, a[MAXN], b[MAXN], c[MAXN];
ll val[MAXN];
ll ans;

int main() {
//#ifndef ONLINE_JUDGE
//    freopen("inp.txt", "r", stdin);
////    freopen("out.txt", "w", stdout);
//#endif

    cin >> n;
    
    FOR(i, 0, n) cin >> a[i];
    FOR(i, 0, n) cin >> b[i];
    FOR(i, 0, n) cin >> c[i];
    
    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);
    
    FOR(i, 0, n) {
        val[i] = lower_bound(a, a + n, b[i]) - a;
        if (i) val[i] += val[i - 1];
    }
    
    FOR(i, 0, n) {
        int pos = lower_bound(b, b + n, c[i]) - b;
        if (pos) {
            pos--;
            ans += val[pos];
        }
    }
    
    cout << ans;
    
    return 0;
}


Measured memory_bytes: 2304
#include<stdio.h>
int main()
{
    int a,b,i,j,k,count,m[5];
    while(~scanf("%d%d",&a,&b))
    {
        count=0;
        for(k=a;k<=b;k++)
        {
            j=0;
            i=k;
            while(i)
            {
                m[j++]=i%10;
                i=i/10;
            }
            if(m[0]==m[4]&&m[1]==m[3])
                count++;
        }
        printf("%d\n",count);
    }
    return 0;
}


Measured memory_bytes: 128
require 'pp'

n = gets.chomp!.to_i
v_n = gets.chomp!.split(" ").map(&:to_i)

v_n.sort!


while v_n.length >= 2
    v1 = v_n.shift
    v2 = v_n.shift
    y = (v1 + v2) / 2.0
    v_n.unshift(y)
end 

puts v_n[0]


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

 
string multiply(string &num1, string num2) {
        string zero = "0";
        if(num1 == zero || num2 == zero)
            return zero;
        string mul = "";
        int size1 = num1.size(), size2 = num2.size(), c = 0;
        vector<int> count(size1 + size2 - 1, 0);
        for(int i = 0; i < size1; i ++)
            for(int j = 0; j < size2; j ++)
                count[i + j] += (num1[i] - '0') * (num2[j] - '0');
        
        for(auto i = count.rbegin(); i != count.rend(); i ++){
            int tmp = *i + c;
            mul.insert(mul.begin(), tmp % 10 + '0');
            c = tmp / 10;
        }
        if(c)
            mul.insert(mul.begin(), c + '0');
        return mul;
}
int main() 
{ 
	//input();
	ll n;
	ll max = 1e18;
	cin>>n;
	string ans="1";
	string s1 = "1000000000000000000";
	ll count = 0 ;
	vector<string>v;
	bool flag = true;
	for( ll i =0 ; i<n ; i++){
		string s ;
		cin>>s;
		v.push_back(s);
	}
	for( ll i=0 ; i<n ; i++){
		if(v[i]=="0"){
			count++;
		}
	}
	if( count == 0 ){
		for(ll i = 0 ; i<n ; i++){
		
		ans = multiply( ans ,v[i]);
		//cout<<ans<<endl;
		if( ans.size() >= 19 && ans != s1){
			flag = false;
			break;
			
		}
	}
   }



	if( count > 0 ){
		cout<<0<<endl;
	}
	else if( (ans.size() >= 19 && ans != s1 && count == 0 ) || ( flag == false)) cout<<-1<<endl;
	else cout<<ans<<endl;
} 


Measured memory_bytes: 9560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] list = new int[n];

		for (int i = 0; i < k; i++) {
			int num = sc.nextInt();
			for (int j = 0; j < num; j++) {
				int index = sc.nextInt();
				list[index-1] += 1;
			}
		}

		int count = 0;
		for (int num : list) {
			if(num == 0) {
				count++;
			}
		}
		System.out.println(count);
		sc.close();

	}

}


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

inline void change(string &s){
  int a = s[0]-'0', b = s[1]-'0';
  string res;
  if(a+b>9){
    res += '0'+(a+b)/10;
    res += '0'+(a+b)%10;
  }else{
    res += '0'+a+b;
  }

  s = res + s.substr(2);
}

int main(){
  int n;
  string s;
  cin >> n;
  while(n--){
    cin >> s;
    int cnt = 0;
    while(s.size()>1)change(s), cnt++;
    cout << ((cnt&1)?"Fabre":"Audrey") << " wins.\n";
  }
}

Measured memory_bytes: 1200
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <typename T>
struct edge {
    int from, to;
    T cost;

    edge(int to, T cost) : from(-1), to(to), cost(cost) {}
    edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}

    explicit operator int() const {return to;}
};

class UnionFind {
    vector<int> uni;
    int n;
public:
    explicit UnionFind(int n) : uni(static_cast<u32>(n), -1) , n(n){};

    int root(int a){
        if (uni[a] < 0) return a;
        else return (uni[a] = root(uni[a]));
    }

    bool unite(int a, int b) {
        a = root(a);
        b = root(b);
        if(a == b) return false;
        if(uni[a] > uni[b]) swap(a, b);
        uni[a] += uni[b];
        uni[b] = a;
        return true;
    }
};

template< typename T >
T kruskal(vector<edge<T>> &G, int V) {
    sort(begin(G), end(G), [](const edge<T> &a, const edge<T> &b) { return (a.cost < b.cost); });
    UnionFind tree(V);
    T ret = 0;
    for(auto &e : G) {
        if(tree.unite(e.from, e.to)) ret += e.cost;
    }
    return (ret);
}

int main() {
    int n;
    while(cin >> n, n){
        vector<edge<int>> G;
        int m;
        cin >> m;
        for (int i = 0; i < m; ++i) {
            int a, b, d;
            scanf("%d,%d,%d", &a, &b, &d);
            G.emplace_back(a, b, d/100-1);
        }
        cout << kruskal(G, n) << "\n";
    }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
    int n;
    cin >> n;
    vector<int>sq(n);
    rep(i, n)cin >> sq[i];
    int cnt = 0;
    for (int i = 1; i < n - 1; i++) {
        if (sq[i - 1] > sq[i] && sq[i]  > sq[i + 1] || sq[i - 1] < sq[i] && sq[i]< sq[i + 1])cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256